* libmisc/limits.c: Replace strtol() by getlong().

* libmisc/limits.c: Replace HAVE_UTMPX_H by USE_UTMPX.
This commit is contained in:
nekral-guest 2009-04-28 19:12:48 +00:00
parent 76b51939aa
commit b0c0a94c66
2 changed files with 18 additions and 14 deletions

View File

@ -1,3 +1,8 @@
2009-04-27 Nicolas François <nicolas.francois@centraliens.net>
* libmisc/limits.c: Replace strtol() by getlong().
* libmisc/limits.c: Replace HAVE_UTMPX_H by USE_UTMPX.
2009-04-27 Nicolas François <nicolas.francois@centraliens.net> 2009-04-27 Nicolas François <nicolas.francois@centraliens.net>
* man/groupmod.8.xml, man/usermod.8.xml, man/groupadd.8.xml, * man/groupmod.8.xml, man/usermod.8.xml, man/groupadd.8.xml,

View File

@ -89,14 +89,13 @@ setrlimit_value (unsigned int resource, const char *value,
static int set_prio (const char *value) static int set_prio (const char *value)
{ {
int prio; long prio;
char **endptr = (char **) &value;
prio = strtol (value, endptr, 10); if ( (getlong (value, &prio) == 0)
if ((0 == prio) && (value == *endptr)) { || (prio != (int) prio)) {
return 0; return 0;
} }
if (setpriority (PRIO_PROCESS, 0, prio) != 0) { if (setpriority (PRIO_PROCESS, 0, (int) prio) != 0) {
return LOGIN_ERROR_RLIMIT; return LOGIN_ERROR_RLIMIT;
} }
return 0; return 0;
@ -120,11 +119,11 @@ static int set_umask (const char *value)
/* Counts the number of user logins and check against the limit */ /* Counts the number of user logins and check against the limit */
static int check_logins (const char *name, const char *maxlogins) static int check_logins (const char *name, const char *maxlogins)
{ {
#if HAVE_UTMPX_H #ifdef USE_UTMPX
struct utmpx *ut; struct utmpx *ut;
#else #else /* !USE_UTMPX */
struct utmp *ut; struct utmp *ut;
#endif #endif /* !USE_UTMPX */
unsigned long limit, count; unsigned long limit, count;
if (getulong (maxlogins, &limit) == 0) { if (getulong (maxlogins, &limit) == 0) {
@ -137,13 +136,13 @@ static int check_logins (const char *name, const char *maxlogins)
} }
count = 0; count = 0;
#if HAVE_UTMPX_H #ifdef USE_UTMPX
setutxent (); setutxent ();
while ((ut = getutxent ())) { while ((ut = getutxent ())) {
#else #else /* !USE_UTMPX */
setutent (); setutent ();
while ((ut = getutent ())) { while ((ut = getutent ())) {
#endif #endif /* !USE_UTMPX */
if (USER_PROCESS != ut->ut_type) { if (USER_PROCESS != ut->ut_type) {
continue; continue;
} }
@ -158,11 +157,11 @@ static int check_logins (const char *name, const char *maxlogins)
break; break;
} }
} }
#if HAVE_UTMPX_H #ifdef USE_UTMPX
endutxent (); endutxent ();
#else #else /* !USE_UTMPX */
endutent (); endutent ();
#endif #endif /* !USE_UTMPX */
/* /*
* This is called after setutmp(), so the number of logins counted * This is called after setutmp(), so the number of logins counted
* includes the user who is currently trying to log in. * includes the user who is currently trying to log in.