aboutsummaryrefslogtreecommitdiff
path: root/Linux-PAM/modules/pam_shells/pam_shells.c
diff options
context:
space:
mode:
authorSteve Langasek <steve.langasek@ubuntu.com>2019-01-03 12:48:14 -0800
committerSteve Langasek <steve.langasek@ubuntu.com>2019-01-03 12:48:14 -0800
commitd5b06b67bbeeed7c05c0eb2e05d6a972ad050d1c (patch)
treeba5654cffacfd2002eefc5bc3764a7971afff1dc /Linux-PAM/modules/pam_shells/pam_shells.c
parent4c51da22e068907adb7857d50f5109a467c94d7c (diff)
parent7cbfa335c57d068d59508c844f3957165cccfb9b (diff)
downloadpam-d5b06b67bbeeed7c05c0eb2e05d6a972ad050d1c.tar.gz
pam-d5b06b67bbeeed7c05c0eb2e05d6a972ad050d1c.tar.bz2
pam-d5b06b67bbeeed7c05c0eb2e05d6a972ad050d1c.zip
New upstream version 0.99.7.1
Diffstat (limited to 'Linux-PAM/modules/pam_shells/pam_shells.c')
-rw-r--r--Linux-PAM/modules/pam_shells/pam_shells.c48
1 files changed, 18 insertions, 30 deletions
diff --git a/Linux-PAM/modules/pam_shells/pam_shells.c b/Linux-PAM/modules/pam_shells/pam_shells.c
index 64359eac..89fc297e 100644
--- a/Linux-PAM/modules/pam_shells/pam_shells.c
+++ b/Linux-PAM/modules/pam_shells/pam_shells.c
@@ -8,7 +8,7 @@
* This code shamelessly ripped from the pam_securetty module.
*/
-#define _BSD_SOURCE
+#include "config.h"
#include <pwd.h>
#include <stdarg.h>
@@ -31,22 +31,10 @@
#define PAM_SM_ACCOUNT
#include <security/pam_modules.h>
-#include <security/_pam_modutil.h>
+#include <security/pam_modutil.h>
+#include <security/pam_ext.h>
-/* some syslogging */
-
-static void _pam_log(int err, const char *format, ...)
-{
- va_list args;
-
- va_start(args, format);
- openlog("PAM-shells", LOG_CONS|LOG_PID, LOG_AUTH);
- vsyslog(err, format, args);
- va_end(args);
- closelog();
-}
-
-static int perform_check(pam_handle_t *pamh, int flags)
+static int perform_check(pam_handle_t *pamh)
{
int retval = PAM_AUTH_ERR;
const char *userName;
@@ -73,28 +61,27 @@ static int perform_check(pam_handle_t *pamh, int flags)
return PAM_SERVICE_ERR;
}
- pw = _pammodutil_getpwnam(pamh, userName);
+ pw = pam_modutil_getpwnam(pamh, userName);
if (!pw) {
return PAM_AUTH_ERR; /* user doesn't exist */
}
userShell = pw->pw_shell;
if (stat(SHELL_FILE,&sb)) {
- _pam_log(LOG_ERR, "%s cannot be stat'd (it probably does not exist)",
- SHELL_FILE);
+ pam_syslog(pamh, LOG_ERR, "Cannot stat %s: %m", SHELL_FILE);
return PAM_AUTH_ERR; /* must have /etc/shells */
}
if ((sb.st_mode & S_IWOTH) || !S_ISREG(sb.st_mode)) {
- _pam_log(LOG_ERR, "%s is either world writable or not a normal file",
- SHELL_FILE);
+ pam_syslog(pamh, LOG_ERR,
+ "%s is either world writable or not a normal file",
+ SHELL_FILE);
return PAM_AUTH_ERR;
}
shellFile = fopen(SHELL_FILE,"r");
if (shellFile == NULL) { /* Check that we opened it successfully */
- _pam_log(LOG_ERR,
- "Error opening %s", SHELL_FILE);
+ pam_syslog(pamh, LOG_ERR, "Error opening %s: %m", SHELL_FILE);
return PAM_SERVICE_ERR;
}
@@ -118,14 +105,15 @@ static int perform_check(pam_handle_t *pamh, int flags)
/* --- authentication management functions (only) --- */
PAM_EXTERN
-int pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc,
- const char **argv)
+int pam_sm_authenticate(pam_handle_t *pamh, int flags UNUSED,
+ int argc UNUSED, const char **argv UNUSED)
{
- return perform_check(pamh, flags);
+ return perform_check(pamh);
}
PAM_EXTERN
-int pam_sm_setcred(pam_handle_t *pamh, int flags, int argc,const char **argv)
+int pam_sm_setcred(pam_handle_t *pamh UNUSED, int flags UNUSED,
+ int argc UNUSED, const char **argv UNUSED)
{
return PAM_SUCCESS;
}
@@ -133,10 +121,10 @@ int pam_sm_setcred(pam_handle_t *pamh, int flags, int argc,const char **argv)
/* --- account management functions (only) --- */
PAM_EXTERN
-int pam_sm_acct_mgmt(pam_handle_t *pamh, int flags, int argc,
- const char **argv)
+int pam_sm_acct_mgmt(pam_handle_t *pamh, int flags UNUSED,
+ int argc UNUSED, const char **argv UNUSED)
{
- return perform_check(pamh, flags);
+ return perform_check(pamh);
}
#ifdef PAM_STATIC