X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fuser.c;h=358e6f38116fab2bb7179e719b93dd45befbcb3a;hb=7ce9e7b7c637a69fa1fdd78cfdfbf2581bb8217e;hp=2de0ffd17c7e224d877c3f28b13d83b52e52e652;hpb=d611a4b49a00238ed32ae84c68f27c6a0ef2273a;p=openldap diff --git a/servers/slapd/user.c b/servers/slapd/user.c index 2de0ffd17c..358e6f3811 100644 --- a/servers/slapd/user.c +++ b/servers/slapd/user.c @@ -2,7 +2,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2004 The OpenLDAP Foundation. + * Copyright 1998-2006 The OpenLDAP Foundation. * Portions Copyright 1999 PM Lashley. * All rights reserved. * @@ -34,6 +34,7 @@ #include #include "slap.h" +#include "lutil.h" /* * Set real and effective user id and group id, and group access list @@ -49,9 +50,17 @@ slap_init_user( char *user, char *group ) if ( user ) { struct passwd *pwd; - if ( isdigit( (unsigned char) *user )) { + if ( isdigit( (unsigned char) *user ) ) { + unsigned u; + got_uid = 1; - uid = atoi( user ); + if ( lutil_atou( &u, user ) != 0 ) { + Debug( LDAP_DEBUG_ANY, "Unble to parse user %s\n", + user, 0, 0 ); + + exit( EXIT_FAILURE ); + } + uid = (uid_t)u; #ifdef HAVE_GETPWUID pwd = getpwuid( uid ); goto did_getpw; @@ -86,7 +95,15 @@ slap_init_user( char *user, char *group ) if ( group ) { struct group *grp; if ( isdigit( (unsigned char) *group )) { - gid = atoi( group ); + unsigned g; + + if ( lutil_atou( &g, group ) != 0 ) { + Debug( LDAP_DEBUG_ANY, "Unble to parse group %s\n", + group, 0, 0 ); + + exit( EXIT_FAILURE ); + } + gid = (uid_t)g; #ifdef HAVE_GETGRGID grp = getgrgid( gid ); goto did_group;