]> granicus.if.org Git - linux-pam/commitdiff
innetgr may not be there so make sure that when innetgr is not present
authorThorsten Kukuk <kukuk@thkukuk.de>
Mon, 4 Apr 2016 09:39:45 +0000 (11:39 +0200)
committerThorsten Kukuk <kukuk@thkukuk.de>
Mon, 4 Apr 2016 09:39:45 +0000 (11:39 +0200)
then we inform about it and not use it. [ticket#46]

* modules/pam_group/pam_group.c: ditto
* modules/pam_succeed_if/pam_succeed_if.c: ditto
* modules/pam_time/pam_time.c: ditto

Signed-off-by: Khem Raj <raj.khem at gmail.com>
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
modules/pam_group/pam_group.c
modules/pam_succeed_if/pam_succeed_if.c
modules/pam_time/pam_time.c

index da8237f15f236a44e2e1a6c868d226e696018daf..263b3d518b7d4ee2bb6a6d196984887cc24930a2 100644 (file)
@@ -656,7 +656,11 @@ static int check_account(pam_handle_t *pamh, const char *service,
        }
        /* If buffer starts with @, we are using netgroups */
        if (buffer[0] == '@')
+#ifdef HAVE_INNETGR
          good &= innetgr (&buffer[1], NULL, user, NULL);
+#else
+         pam_syslog (pamh, LOG_ERR, "pam_group does not have netgroup support");
+#endif
        /* otherwise, if the buffer starts with %, it's a UNIX group */
        else if (buffer[0] == '%')
           good &= pam_modutil_user_in_group_nam_nam(pamh, user, &buffer[1]);
index c39b1cb168a6bf4c6a4fb657d67483ef3c58b24c..856db0ca510e04bcdc54d7c9d38b3b960dc122ab 100644 (file)
@@ -231,18 +231,27 @@ evaluate_notingroup(pam_handle_t *pamh, const char *user, const char *group)
 }
 /* Return PAM_SUCCESS if the (host,user) is in the netgroup. */
 static int
-evaluate_innetgr(const char *host, const char *user, const char *group)
+evaluate_innetgr(const pam_handle_t* pamh, const char *host, const char *user, const char *group)
 {
+#ifdef HAVE_INNETGR
        if (innetgr(group, host, user, NULL) == 1)
                return PAM_SUCCESS;
+#else
+       pam_syslog (pamh, LOG_ERR, "pam_succeed_if does not have netgroup support");
+#endif
+
        return PAM_AUTH_ERR;
 }
 /* Return PAM_SUCCESS if the (host,user) is NOT in the netgroup. */
 static int
-evaluate_notinnetgr(const char *host, const char *user, const char *group)
+evaluate_notinnetgr(const pam_handle_t* pamh, const char *host, const char *user, const char *group)
 {
+#ifdef HAVE_INNETGR
        if (innetgr(group, host, user, NULL) == 0)
                return PAM_SUCCESS;
+#else
+       pam_syslog (pamh, LOG_ERR, "pam_succeed_if does not have netgroup support");
+#endif
        return PAM_AUTH_ERR;
 }
 
@@ -387,14 +396,14 @@ evaluate(pam_handle_t *pamh, int debug,
                const void *rhost;
                if (pam_get_item(pamh, PAM_RHOST, &rhost) != PAM_SUCCESS)
                        rhost = NULL;
-               return evaluate_innetgr(rhost, user, right);
+               return evaluate_innetgr(pamh, rhost, user, right);
        }
        /* (Rhost, user) is not in this group. */
        if (strcasecmp(qual, "notinnetgr") == 0) {
                const void *rhost;
                if (pam_get_item(pamh, PAM_RHOST, &rhost) != PAM_SUCCESS)
                        rhost = NULL;
-               return evaluate_notinnetgr(rhost, user, right);
+               return evaluate_notinnetgr(pamh, rhost, user, right);
        }
        /* Fail closed. */
        return PAM_SERVICE_ERR;
index 75d08645ba3b9a4a7f437f952c49926bba18922f..b67a4c24aeef12debb68dcb744b9d10b1ec992f7 100644 (file)
@@ -555,7 +555,11 @@ check_account(pam_handle_t *pamh, const char *service,
          }
          /* If buffer starts with @, we are using netgroups */
          if (buffer[0] == '@')
+#ifdef HAVE_INNETGR
            good &= innetgr (&buffer[1], NULL, user, NULL);
+#else
+           pam_syslog (pamh, LOG_ERR, "pam_time does not have netgroup support");
+#endif
          else
            good &= logic_field(pamh, user, buffer, count, is_same);
          D(("with user: %s", good ? "passes":"fails" ));