summaryrefslogtreecommitdiffabout
path: root/pam_umotd/pam_umotd.c
Side-by-side diff
Diffstat (limited to 'pam_umotd/pam_umotd.c') (more/less context) (show whitespace changes)
-rw-r--r--pam_umotd/pam_umotd.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/pam_umotd/pam_umotd.c b/pam_umotd/pam_umotd.c
index 2fea67c..008e87b 100644
--- a/pam_umotd/pam_umotd.c
+++ b/pam_umotd/pam_umotd.c
@@ -340,13 +340,19 @@ pam_sm_open_session(pam_handle_t *pamh, int flags, int argc, const char **argv)
char *file;
slist = gray_slist_create();
+ if (!slist)
+ retval = errno_to_pam(errno);
+ else {
gray_expand_string(pamh, motd_file_name, slist);
gray_slist_append_char(slist, 0);
file = gray_slist_finish(slist);
+ if (file)
retval = read_file(pamh, file);
+ else
+ retval = errno_to_pam(errno);
+ }
gray_slist_free(&slist);
} else if (optindex >= 0) {
- int i;
char **xargv;
argc -= optindex;
@@ -355,17 +361,30 @@ pam_sm_open_session(pam_handle_t *pamh, int flags, int argc, const char **argv)
_pam_log(LOG_INFO, "empty command line");
return retval;
}
- xargv = gray_malloc((argc + 1) * sizeof (xargv[0]));
+ xargv = calloc((argc + 1), sizeof (xargv[0]));
+ if (!xargv)
+ return errno_to_pam(errno);
slist = gray_slist_create();
+ if (!slist)
+ retval = errno_to_pam(errno);
+ else {
+ int i;
+ int ec;
+
for (i = 0; i < argc; i++) {
gray_expand_string(pamh, argv[i], slist);
gray_slist_append_char(slist, 0);
xargv[i] = gray_slist_finish(slist);
}
xargv[i] = NULL;
+ ec = gray_slist_err(slist);
+ if (ec)
+ retval = errno_to_pam(ec);
+ else
retval = exec_file(pamh, xargv, logfile_name);
free(xargv);
gray_slist_free(&slist);
+ }
} else
_pam_log(LOG_ERR,
"invalid usage: either file or exec must be specified");

Return to:

Send suggestions and report system problems to the System administrator.