]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/user.c
fix substring_comp_candidates logic if intersection of candidates
[openldap] / servers / slapd / user.c
index e92598d800f8293bed227e83c940636001492007..8f31b06cc5185c0768439a82aa571f15824115fe 100644 (file)
@@ -14,7 +14,8 @@
 #if defined(HAVE_SETUID) && defined(HAVE_SETGID)
 
 #include <stdio.h>
-#include <stdlib.h>
+
+#include <ac/stdlib.h>
 
 #ifdef HAVE_PWD_H
 #include <pwd.h>
@@ -36,8 +37,8 @@
 void
 slap_init_user( char *user, char *group )
 {
-    uid_t      uid = (uid_t) -1;
-    gid_t      gid = (gid_t) -1;
+    uid_t      uid = (uid_t) 0;
+    gid_t      gid = (gid_t) 0;
 
     if ( user ) {
        struct passwd *pwd;
@@ -55,7 +56,7 @@ slap_init_user( char *user, char *group )
                       user, 0, 0 );
                exit( 1 );
            }
-           if ( uid >= 0 ) {
+           if ( uid > 0 ) {
                free( user );
                user = (pwd != NULL ? ch_strdup( pwd->pw_name ) : NULL);
            } else {
@@ -103,7 +104,7 @@ slap_init_user( char *user, char *group )
     endgrent();
 #endif
 
-    if ( gid >= 0 ) {
+    if ( gid > 0 ) {
        if ( setgid( gid ) != 0 ) {
            Debug( LDAP_DEBUG_ANY, "Could not set real group id to %d\n",
                   gid, 0, 0 );
@@ -118,15 +119,15 @@ slap_init_user( char *user, char *group )
 #endif
     }
 
-    if ( uid >= 0 ) {
+    if ( uid > 0 ) {
        if ( setuid( uid ) != 0 ) {
-           Debug( LDAP_DEBUG_ANY, "Could not set effective user id to %d\n",
+           Debug( LDAP_DEBUG_ANY, "Could not set real user id to %d\n",
                   uid, 0, 0 );
            exit( 1 );
        }
 #ifdef HAVE_SETEUID
        if ( seteuid( uid ) != 0 ) {
-           Debug( LDAP_DEBUG_ANY, "Could not set real user id to %d\n",
+           Debug( LDAP_DEBUG_ANY, "Could not set effective user id to %d\n",
                   uid, 0, 0 );
            exit( 1 );
        }