summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorThorsten Kukuk <kukuk@thkukuk.de>2006-08-06 11:38:43 +0000
committerThorsten Kukuk <kukuk@thkukuk.de>2006-08-06 11:38:43 +0000
commit9fe629581bf126af81233706e71bec60decee79c (patch)
tree24358d9de5cd0f6f399cef9761dcbd5af03a9b9e /modules
parentea68558c25723480e609918b8ce11b3a8ac10b93 (diff)
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')
-rw-r--r--modules/pam_umask/README4
-rw-r--r--modules/pam_umask/pam_umask.89
-rw-r--r--modules/pam_umask/pam_umask.8.xml14
-rw-r--r--modules/pam_umask/pam_umask.c23
4 files changed, 45 insertions, 5 deletions
diff --git a/modules/pam_umask/README b/modules/pam_umask/README
index 2a4f2641..69003ec3 100644
--- a/modules/pam_umask/README
+++ b/modules/pam_umask/README
@@ -29,6 +29,10 @@ debug
Print debug information.
+silent
+
+ Don't print informative messages.
+
usergroups
If the user is not root, and the user ID is equal to the group ID, and the
diff --git a/modules/pam_umask/pam_umask.8 b/modules/pam_umask/pam_umask.8
index 230a4676..43160d63 100644
--- a/modules/pam_umask/pam_umask.8
+++ b/modules/pam_umask/pam_umask.8
@@ -1,11 +1,11 @@
.\" Title: pam_umask
.\" Author:
.\" Generator: DocBook XSL Stylesheets v1.70.1 <http://docbook.sf.net/>
-.\" Date: 06/09/2006
+.\" Date: 08/06/2006
.\" Manual: Linux\-PAM Manual
.\" Source: Linux\-PAM Manual
.\"
-.TH "PAM_UMASK" "8" "06/09/2006" "Linux\-PAM Manual" "Linux\-PAM Manual"
+.TH "PAM_UMASK" "8" "08/06/2006" "Linux\-PAM Manual" "Linux\-PAM Manual"
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
@@ -14,7 +14,7 @@
pam_umask \- PAM module to set the file mode creation mask
.SH "SYNOPSIS"
.HP 13
-\fBpam_umask.so\fR [debug] [usergroups] [umask=\fImask\fR]
+\fBpam_umask.so\fR [debug] [silent] [usergroups] [umask=\fImask\fR]
.SH "DESCRIPTION"
.PP
pam_umask is a PAM module to set the file mode creation mask of the current environment. The umask affects the default permissions assigned to newly created files.
@@ -46,6 +46,9 @@ UMASK entry from /etc/login.defs
\fBdebug\fR
Print debug information.
.TP 3n
+\fBsilent\fR
+Don't print informative messages.
+.TP 3n
\fBusergroups\fR
If the user is not root, and the user ID is equal to the group ID, and the username is the same as primary group name, the umask group bits are set to be the same as owner bits (examples: 022 \-> 002, 077 \-> 007).
.TP 3n
diff --git a/modules/pam_umask/pam_umask.8.xml b/modules/pam_umask/pam_umask.8.xml
index 8bb866a0..d65e6660 100644
--- a/modules/pam_umask/pam_umask.8.xml
+++ b/modules/pam_umask/pam_umask.8.xml
@@ -22,6 +22,9 @@
debug
</arg>
<arg choice="opt">
+ silent
+ </arg>
+ <arg choice="opt">
usergroups
</arg>
<arg choice="opt">
@@ -97,6 +100,17 @@
<varlistentry>
<term>
+ <option>silent</option>
+ </term>
+ <listitem>
+ <para>
+ Don't print informative messages.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
<option>usergroups</option>
</term>
<listitem>
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)