2009-03-09 01:56:56 +05:30
|
|
|
/*
|
2021-12-05 21:05:27 +05:30
|
|
|
* SPDX-FileCopyrightText: 2009 , Nicolas François
|
2009-03-09 01:56:56 +05:30
|
|
|
*
|
2021-12-05 21:05:27 +05:30
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
2009-03-09 01:56:56 +05:30
|
|
|
*/
|
|
|
|
|
|
|
|
#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 17:16:06 +05:30
|
|
|
if ( ('\0' == *uidstr)
|
2009-03-09 01:56:56 +05:30
|
|
|
|| ('\0' != *endptr)
|
|
|
|
|| (ERANGE == errno)
|
2009-05-01 02:42:33 +05:30
|
|
|
|| (/*@+longintegral@*/val != (uid_t)val)/*@=longintegral@*/) {
|
2009-03-09 01:56:56 +05:30
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-02-01 18:20:48 +05:30
|
|
|
*uid = val;
|
2009-03-09 01:56:56 +05:30
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|