From b0c0a94c669a8e2d77894454785862f97d212549 Mon Sep 17 00:00:00 2001 From: nekral-guest Date: Tue, 28 Apr 2009 19:12:48 +0000 Subject: [PATCH] * libmisc/limits.c: Replace strtol() by getlong(). * libmisc/limits.c: Replace HAVE_UTMPX_H by USE_UTMPX. --- ChangeLog | 5 +++++ libmisc/limits.c | 27 +++++++++++++-------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3051169e..909c99b1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-04-27 Nicolas François + + * libmisc/limits.c: Replace strtol() by getlong(). + * libmisc/limits.c: Replace HAVE_UTMPX_H by USE_UTMPX. + 2009-04-27 Nicolas François * man/groupmod.8.xml, man/usermod.8.xml, man/groupadd.8.xml, diff --git a/libmisc/limits.c b/libmisc/limits.c index a6d8df7a..c25c5f02 100644 --- a/libmisc/limits.c +++ b/libmisc/limits.c @@ -89,14 +89,13 @@ setrlimit_value (unsigned int resource, const char *value, static int set_prio (const char *value) { - int prio; - char **endptr = (char **) &value; + long prio; - prio = strtol (value, endptr, 10); - if ((0 == prio) && (value == *endptr)) { + if ( (getlong (value, &prio) == 0) + || (prio != (int) prio)) { return 0; } - if (setpriority (PRIO_PROCESS, 0, prio) != 0) { + if (setpriority (PRIO_PROCESS, 0, (int) prio) != 0) { return LOGIN_ERROR_RLIMIT; } return 0; @@ -120,11 +119,11 @@ static int set_umask (const char *value) /* Counts the number of user logins and check against the limit */ static int check_logins (const char *name, const char *maxlogins) { -#if HAVE_UTMPX_H +#ifdef USE_UTMPX struct utmpx *ut; -#else +#else /* !USE_UTMPX */ struct utmp *ut; -#endif +#endif /* !USE_UTMPX */ unsigned long limit, count; if (getulong (maxlogins, &limit) == 0) { @@ -137,13 +136,13 @@ static int check_logins (const char *name, const char *maxlogins) } count = 0; -#if HAVE_UTMPX_H +#ifdef USE_UTMPX setutxent (); while ((ut = getutxent ())) { -#else +#else /* !USE_UTMPX */ setutent (); while ((ut = getutent ())) { -#endif +#endif /* !USE_UTMPX */ if (USER_PROCESS != ut->ut_type) { continue; } @@ -158,11 +157,11 @@ static int check_logins (const char *name, const char *maxlogins) break; } } -#if HAVE_UTMPX_H +#ifdef USE_UTMPX endutxent (); -#else +#else /* !USE_UTMPX */ endutent (); -#endif +#endif /* !USE_UTMPX */ /* * This is called after setutmp(), so the number of logins counted * includes the user who is currently trying to log in.