2009-03-08 20:26:56 +00:00
|
|
|
/*
|
2021-12-05 09:35:27 -06:00
|
|
|
* SPDX-FileCopyrightText: 2009 , Nicolas François
|
2009-03-08 20:26:56 +00:00
|
|
|
*
|
2021-12-05 09:35:27 -06:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
2009-03-08 20:26:56 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ident "$Id$"
|
|
|
|
|
|
|
|
#include "prototypes.h"
|
|
|
|
#include "defines.h"
|
|
|
|
|
|
|
|
int get_uid (const char *uidstr, uid_t *uid)
|
|
|
|
{
|
|
|
|
long long int val;
|
|
|
|
char *endptr;
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
val = strtoll (uidstr, &endptr, 10);
|
2009-04-23 11:46:06 +00:00
|
|
|
if ( ('\0' == *uidstr)
|
2009-03-08 20:26:56 +00:00
|
|
|
|| ('\0' != *endptr)
|
|
|
|
|| (ERANGE == errno)
|
2009-04-30 21:12:33 +00:00
|
|
|
|| (/*@+longintegral@*/val != (uid_t)val)/*@=longintegral@*/) {
|
2009-03-08 20:26:56 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-02-01 13:50:48 +01:00
|
|
|
*uid = val;
|
2009-03-08 20:26:56 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|