From: Kurt Zeilenga Date: Sun, 27 Jun 1999 03:58:06 +0000 (+0000) Subject: don't set unsigned variables to -1 and expect them to be negative. X-Git-Tag: OPENLDAP_REL_ENG_2_BP~240 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=cf89dd83cda88a3ac83030ba1ca346b45a3f9f8d;p=openldap don't set unsigned variables to -1 and expect them to be negative. verify uid/gid are positive, not non-negative. --- diff --git a/servers/slapd/user.c b/servers/slapd/user.c index e32a61ad3f..5412780c75 100644 --- a/servers/slapd/user.c +++ b/servers/slapd/user.c @@ -37,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; @@ -56,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 { @@ -104,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 ); @@ -119,7 +119,7 @@ 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", uid, 0, 0 );