diff options
-rw-r--r-- | modules/pam_motd/pam_motd.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/modules/pam_motd/pam_motd.c b/modules/pam_motd/pam_motd.c index f0cd317d..3be129a5 100644 --- a/modules/pam_motd/pam_motd.c +++ b/modules/pam_motd/pam_motd.c @@ -259,23 +259,23 @@ static void try_to_display_directories_with_overrides(pam_handle_t *pamh, for (j = 0; j < num_motd_dirs; j++) { char *abs_path = NULL; + int fd; if (join_dir_strings(&abs_path, motd_dir_path_split[j], - dirnames_all[i]) < 0) { + dirnames_all[i]) < 0 || abs_path == NULL) { continue; } - if (abs_path != NULL) { - int fd = open(abs_path, O_RDONLY, 0); - if (fd >= 0) { - try_to_display_fd(pamh, fd); - close(fd); + fd = open(abs_path, O_RDONLY, 0); + _pam_drop(abs_path); - /* We displayed a file, skip to the next file name. */ - break; - } + if (fd >= 0) { + try_to_display_fd(pamh, fd); + close(fd); + + /* We displayed a file, skip to the next file name. */ + break; } - _pam_drop(abs_path); } } |