diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2014-05-20 14:38:37 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2014-05-20 14:38:37 +0300 |
commit | f664b904fde206c6c7e0dc45b690ed7d28bea571 (patch) | |
tree | 5d8ecd3ab9afed8b1a19b2b522c355aae5bdda9d | |
parent | 37e557be7bba1d0611365b40b26ad03e4b66e95b (diff) | |
download | pam-modules-f664b904fde206c6c7e0dc45b690ed7d28bea571.tar.gz pam-modules-f664b904fde206c6c7e0dc45b690ed7d28bea571.tar.bz2 |
pam_ldaphome: don't run initrc program if the home dir already exists.
* pam_ldaphome/pam_ldaphome.c (create_exists): New return code.
(create_home_dir): Return create_exists if the directory already
exists.
(ldaphome_main): Run initrc only after creating the home dir.
-rw-r--r-- | pam_ldaphome/pam_ldaphome.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/pam_ldaphome/pam_ldaphome.c b/pam_ldaphome/pam_ldaphome.c index f89b151..83b9cf7 100644 --- a/pam_ldaphome/pam_ldaphome.c +++ b/pam_ldaphome/pam_ldaphome.c @@ -1384,12 +1384,13 @@ dir_in_path(const char *dir, const char *path) } return 0; } enum create_status { create_ok, + create_exists, create_failure, create_skip }; static enum create_status create_home_dir(pam_handle_t *pamh, struct passwd *pw, struct gray_env *env) @@ -1427,13 +1428,14 @@ create_home_dir(pam_handle_t *pamh, struct passwd *pw, struct gray_env *env) return create_failure; } } else if (!S_ISDIR(st.st_mode)) { _pam_log(LOG_ERR, "%s exists, but is not a directory", pw->pw_dir); return create_failure; - } + } else + return create_exists; return create_ok; } extern char **environ; @@ -1879,12 +1881,14 @@ ldaphome_main(pam_handle_t *pamh, int flags, int argc, const char **argv, if (check_user_groups(pamh, env, &pw, &retval) == 0) { switch (create_home_dir(pamh, pw, env)) { case create_ok: retval = run_initrc(pamh, pw, env); if (retval) break; + /* fall through */ + case create_exists: retval = import_public_key(pamh, pw, env); break; case create_failure: retval = PAM_SERVICE_ERR; break; case create_skip: |