summaryrefslogtreecommitdiffabout
path: root/pam_umotd/pam_umotd.c
Side-by-side diff
Diffstat (limited to 'pam_umotd/pam_umotd.c') (more/less context) (ignore whitespace changes)
-rw-r--r--pam_umotd/pam_umotd.c49
1 files changed, 34 insertions, 15 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
@@ -342,11 +342,17 @@ pam_sm_open_session(pam_handle_t *pamh, int flags, int argc, const char **argv)
slist = gray_slist_create();
- gray_expand_string(pamh, motd_file_name, slist);
- gray_slist_append_char(slist, 0);
- file = gray_slist_finish(slist);
- retval = read_file(pamh, file);
+ 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;
@@ -357,13 +363,26 @@ pam_sm_open_session(pam_handle_t *pamh, int flags, int argc, const char **argv)
}
- 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();
- 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);
+ 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);
}
- xargv[i] = NULL;
- retval = exec_file(pamh, xargv, logfile_name);
- free(xargv);
- gray_slist_free(&slist);
} else

Return to:

Send suggestions and report system problems to the System administrator.