summaryrefslogtreecommitdiff
path: root/modules/pam_rhosts/pam_rhosts.c
diff options
context:
space:
mode:
Diffstat (limited to 'modules/pam_rhosts/pam_rhosts.c')
-rw-r--r--modules/pam_rhosts/pam_rhosts.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/modules/pam_rhosts/pam_rhosts.c b/modules/pam_rhosts/pam_rhosts.c
index ed98d630..a1b394d9 100644
--- a/modules/pam_rhosts/pam_rhosts.c
+++ b/modules/pam_rhosts/pam_rhosts.c
@@ -1,4 +1,6 @@
/*
+ * pam_rhosts module
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -35,13 +37,13 @@
#include <pwd.h>
#include <netdb.h>
#include <string.h>
+#include <stdlib.h>
#include <syslog.h>
-#define PAM_SM_AUTH /* only defines this management group */
-
#include <security/pam_modules.h>
#include <security/pam_modutil.h>
#include <security/pam_ext.h>
+#include "pam_inline.h"
int pam_sm_authenticate (pam_handle_t *pamh, int flags, int argc,
const char **argv)
@@ -58,12 +60,14 @@ int pam_sm_authenticate (pam_handle_t *pamh, int flags, int argc,
opt_silent = flags & PAM_SILENT;
while (argc-- > 0) {
+ const char *str;
+
if (strcmp(*argv, "debug") == 0)
opt_debug = 1;
else if (strcmp (*argv, "silent") == 0 || strcmp(*argv, "suppress") == 0)
opt_silent = 1;
- else if (strncmp(*argv, "superuser=", sizeof("superuser=")-1) == 0)
- opt_superuser = *argv+sizeof("superuser=")-1;
+ else if ((str = pam_str_skip_prefix(*argv, "superuser=")) != NULL)
+ opt_superuser = str;
else
pam_syslog(pamh, LOG_WARNING, "unrecognized option '%s'", *argv);
@@ -86,11 +90,12 @@ int pam_sm_authenticate (pam_handle_t *pamh, int flags, int argc,
retval = pam_get_user(pamh, &luser, NULL);
if (retval != PAM_SUCCESS) {
- pam_syslog(pamh, LOG_ERR, "could not determine name of local user");
+ pam_syslog(pamh, LOG_NOTICE, "cannot determine local user name: %s",
+ pam_strerror(pamh, retval));
return retval;
}
- if (rhost == NULL || ruser == NULL || luser == NULL)
+ if (rhost == NULL || ruser == NULL)
return PAM_AUTH_ERR;
if (opt_superuser && strcmp(opt_superuser, luser) == 0)