mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-22 07:39:35 -05:00
don't set unsigned variables to -1 and expect them to be negative.
verify uid/gid are positive, not non-negative.
This commit is contained in:
parent
2e7600588b
commit
cf89dd83cd
1 changed files with 5 additions and 5 deletions
|
|
@ -37,8 +37,8 @@
|
||||||
void
|
void
|
||||||
slap_init_user( char *user, char *group )
|
slap_init_user( char *user, char *group )
|
||||||
{
|
{
|
||||||
uid_t uid = (uid_t) -1;
|
uid_t uid = (uid_t) 0;
|
||||||
gid_t gid = (gid_t) -1;
|
gid_t gid = (gid_t) 0;
|
||||||
|
|
||||||
if ( user ) {
|
if ( user ) {
|
||||||
struct passwd *pwd;
|
struct passwd *pwd;
|
||||||
|
|
@ -56,7 +56,7 @@ slap_init_user( char *user, char *group )
|
||||||
user, 0, 0 );
|
user, 0, 0 );
|
||||||
exit( 1 );
|
exit( 1 );
|
||||||
}
|
}
|
||||||
if ( uid >= 0 ) {
|
if ( uid > 0 ) {
|
||||||
free( user );
|
free( user );
|
||||||
user = (pwd != NULL ? ch_strdup( pwd->pw_name ) : NULL);
|
user = (pwd != NULL ? ch_strdup( pwd->pw_name ) : NULL);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -104,7 +104,7 @@ slap_init_user( char *user, char *group )
|
||||||
endgrent();
|
endgrent();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( gid >= 0 ) {
|
if ( gid > 0 ) {
|
||||||
if ( setgid( gid ) != 0 ) {
|
if ( setgid( gid ) != 0 ) {
|
||||||
Debug( LDAP_DEBUG_ANY, "Could not set real group id to %d\n",
|
Debug( LDAP_DEBUG_ANY, "Could not set real group id to %d\n",
|
||||||
gid, 0, 0 );
|
gid, 0, 0 );
|
||||||
|
|
@ -119,7 +119,7 @@ slap_init_user( char *user, char *group )
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( uid >= 0 ) {
|
if ( uid > 0 ) {
|
||||||
if ( setuid( 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 effective user id to %d\n",
|
||||||
uid, 0, 0 );
|
uid, 0, 0 );
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue