diff options
author | Thorsten Kukuk <kukuk@thkukuk.de> | 2006-08-06 11:38:43 +0000 |
---|---|---|
committer | Thorsten Kukuk <kukuk@thkukuk.de> | 2006-08-06 11:38:43 +0000 |
commit | 9fe629581bf126af81233706e71bec60decee79c (patch) | |
tree | 24358d9de5cd0f6f399cef9761dcbd5af03a9b9e /modules/pam_umask/pam_umask.c | |
parent | ea68558c25723480e609918b8ce11b3a8ac10b93 (diff) | |
download | pam-9fe629581bf126af81233706e71bec60decee79c.tar.gz pam-9fe629581bf126af81233706e71bec60decee79c.tar.bz2 pam-9fe629581bf126af81233706e71bec60decee79c.zip |
Relevant BUGIDs:
Purpose of commit: bugfix
Commit summary:
---------------
2006-08-06 Thorsten Kukuk <kukuk@thkukuk.de>
* modules/pam_umask/pam_umask.c (setup_limits_from_gecos):
Add error handling.
* modules/pam_umask/pam_umask.8.xml: Document silent option.
* xtests/Makefile.am: Fix includes for bootstrapping.
Reported by Greg Schafer <gschafer@zip.com.au>.
Diffstat (limited to 'modules/pam_umask/pam_umask.c')
-rw-r--r-- | modules/pam_umask/pam_umask.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/modules/pam_umask/pam_umask.c b/modules/pam_umask/pam_umask.c index 46f25ae7..c5fa773b 100644 --- a/modules/pam_umask/pam_umask.c +++ b/modules/pam_umask/pam_umask.c @@ -39,6 +39,7 @@ #include <grp.h> #include <stdio.h> #include <ctype.h> +#include <errno.h> #include <string.h> #include <stdarg.h> #include <unistd.h> @@ -57,6 +58,7 @@ struct options_t { int debug; int usergroups; + int silent; char *umask; }; typedef struct options_t options_t; @@ -73,6 +75,8 @@ parse_option (const pam_handle_t *pamh, const char *argv, options_t *options) options->umask = strdup (&argv[6]); else if (strcasecmp (argv, "usergroups") == 0) options->usergroups = 1; + else if (strcasecmp (argv, "silent") == 0) + options->silent = 1; else pam_syslog (pamh, LOG_ERR, "Unknown option: `%s'", argv); } @@ -211,13 +215,26 @@ setup_limits_from_gecos (pam_handle_t *pamh, options_t *options, if (strncasecmp (cp, "umask=", 6) == 0) umask (strtol (cp + 6, NULL, 8) & 0777); else if (strncasecmp (cp, "pri=", 4) == 0) - nice (strtol (cp + 4, NULL, 10)); + { + errno = 0; + if (nice (strtol (cp + 4, NULL, 10)) == -1 && errno != 0) + { + if (!options->silent || options->debug) + pam_error (pamh, "nice failed: %m\n"); + pam_syslog (pamh, LOG_ERR, "nice failed: %m"); + } + } else if (strncasecmp (cp, "ulimit=", 7) == 0) { struct rlimit rlimit_fsize; rlimit_fsize.rlim_cur = 512L * strtol (cp + 7, NULL, 10); rlimit_fsize.rlim_max = rlimit_fsize.rlim_cur; - setrlimit (RLIMIT_FSIZE, &rlimit_fsize); + if (setrlimit (RLIMIT_FSIZE, &rlimit_fsize) == -1) + { + if (!options->silent || options->debug) + pam_error (pamh, "setrlimit failed: %m\n"); + pam_syslog (pamh, LOG_ERR, "setrlimit failed: %m"); + } } } } @@ -233,6 +250,8 @@ pam_sm_open_session (pam_handle_t *pamh, int flags UNUSED, int retval = PAM_SUCCESS; get_options (pamh, &options, argc, argv); + if (flags & PAM_SILENT) + options.silent = 1; /* get the user name. */ if ((retval = pam_get_user (pamh, &name, NULL)) != PAM_SUCCESS) |