Imported Upstream version 1.6.9p9
[debian/sudo] / ldap.c
diff --git a/ldap.c b/ldap.c
index fb7e9f203f4374fccb176f22ca779d23c7f33b9c..14d046c74be36990fe3ea4c04ee9830fd9e54bad 100644 (file)
--- a/ldap.c
+++ b/ldap.c
@@ -65,7 +65,7 @@
 #include "parse.h"
 
 #ifndef lint
-__unused static const char rcsid[] = "$Sudo: ldap.c,v 1.11.2.16 2007/09/04 14:58:46 millert Exp $";
+__unused static const char rcsid[] = "$Sudo: ldap.c,v 1.11.2.20 2007/11/27 17:06:54 millert Exp $";
 #endif /* lint */
 
 #ifndef LINE_MAX
@@ -163,7 +163,7 @@ sudo_ldap_check_host(ld, entry)
     /* walk through values */
     for (p = v; p && *p && !ret; p++) {
        /* match any or address or netgroup or hostname */
-       if (!strcasecmp(*p, "ALL") || addr_matches(*p) ||
+       if (!strcmp(*p, "ALL") || addr_matches(*p) ||
            netgr_matches(*p, user_host, user_shost, NULL) ||
            !hostname_matches(user_shost, user_host, *p))
            ret = TRUE;
@@ -257,9 +257,10 @@ sudo_ldap_check_runas(ld, entry)
  * Walk through search results and return TRUE if we have a command match.
  */
 int
-sudo_ldap_check_command(ld, entry)
+sudo_ldap_check_command(ld, entry, setenv_implied)
     LDAP *ld;
     LDAPMessage *entry;
+    int *setenv_implied;
 {
     char *allowed_cmnd, *allowed_args, **v = NULL, **p = NULL;
     int foundbang, ret = FALSE;
@@ -272,8 +273,10 @@ sudo_ldap_check_command(ld, entry)
     /* get_first_entry */
     for (p = v; p && *p && ret >= 0; p++) {
        /* Match against ALL ? */
-       if (!strcasecmp(*p, "ALL")) {
+       if (!strcmp(*p, "ALL")) {
            ret = TRUE;
+           if (setenv_implied != NULL)
+               *setenv_implied = TRUE;
            DPRINTF(("ldap sudoCommand '%s' ... MATCH!", *p), 2);
            continue;
        }
@@ -666,7 +669,7 @@ char *
     /* paste values together */
     for (p = v; p && *p; p++) {
        if (p != v && sep != NULL)
-           ncat(&b, &sz, sep); /* append seperator */
+           ncat(&b, &sz, sep); /* append separator */
        ncat(&b, &sz, *p);      /* append value */
     }
 
@@ -919,6 +922,7 @@ sudo_ldap_check(pwflag)
     LDAPMessage *entry = NULL, *result = NULL; /* used for searches */
     char *filt;                                        /* used to parse attributes */
     int rc, ret = FALSE, do_netgr;             /* temp/final return values */
+    int setenv_implied;
     int ldap_user_matches = FALSE, ldap_host_matches = FALSE; /* flags */
 
     /* Open a connection to the LDAP server. */
@@ -942,7 +946,7 @@ sudo_ldap_check(pwflag)
      * user netgroups.  Then we take the netgroups returned and
      * try to match them against the username.
      */
-
+    setenv_implied = FALSE;
     for (do_netgr = 0; !ret && do_netgr < 2; do_netgr++) {
        filt = do_netgr ? estrdup("sudoUser=+*") : sudo_ldap_build_pass1();
        DPRINTF(("ldap search '%s'", filt), 1);
@@ -968,13 +972,15 @@ sudo_ldap_check(pwflag)
            /* add matches for listing later */
                sudo_ldap_add_match(ld, entry, pwflag) &&
            /* verify command match */
-               sudo_ldap_check_command(ld, entry) &&
+               sudo_ldap_check_command(ld, entry, &setenv_implied) &&
            /* verify runas match */
                sudo_ldap_check_runas(ld, entry)
                ) {
                /* We have a match! */
                DPRINTF(("Perfect Matched!"), 1);
                /* pick up any options */
+               if (setenv_implied)
+                   def_setenv = TRUE;
                sudo_ldap_parse_options(ld, entry);
                /* make sure we don't reenter loop */
                ret = VALIDATE_OK;