From f664b904fde206c6c7e0dc45b690ed7d28bea571 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Tue, 20 May 2014 14:38:37 +0300 Subject: 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. --- pam_ldaphome/pam_ldaphome.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 @@ -1387,6 +1387,7 @@ dir_in_path(const char *dir, const char *path) enum create_status { create_ok, + create_exists, create_failure, create_skip }; @@ -1430,7 +1431,8 @@ create_home_dir(pam_handle_t *pamh, struct passwd *pw, struct gray_env *env) _pam_log(LOG_ERR, "%s exists, but is not a directory", pw->pw_dir); return create_failure; - } + } else + return create_exists; return create_ok; } @@ -1882,6 +1884,8 @@ ldaphome_main(pam_handle_t *pamh, int flags, int argc, const char **argv, 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: -- cgit v1.2.1