X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fuser.c;h=b533b04277de6a3cfb736c054d42b822769fa30a;hb=a7f4102bbfd42681ac505f2adb3ff35d8aba3d88;hp=29aa25b4298e9f2f5fd05610e4f390c3f00da87c;hpb=dc0eacd40b625258355eea866d62188e5aa7ce3b;p=openldap diff --git a/servers/slapd/user.c b/servers/slapd/user.c index 29aa25b429..b533b04277 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-2005 The OpenLDAP Foundation. + * Copyright 1998-2009 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;