From: Todd C. Miller Date: Sat, 5 Apr 2008 19:54:11 +0000 (+0000) Subject: Fall back to default stanza if no user-specific limit is found. X-Git-Tag: SUDO_1_7_0~130 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7ddbc66eb6ff0d5d9f24b2545401b4ecd58c30a5;p=sudo Fall back to default stanza if no user-specific limit is found. --- diff --git a/aix.c b/aix.c index 71a1b050b..27195f742 100644 --- a/aix.c +++ b/aix.c @@ -54,6 +54,17 @@ static struct aix_limit aix_limits[] = { { RLIMIT_NOFILE, S_UNOFILE, S_UNOFILE_HARD } }; +static int +aix_getlimit(user, lim, valp) + char *user; + char *lim; + int *valp; +{ + if (getuserattr(user, lim, valp, SEC_INT) != 0) + return getuserattr("default", lim, valp, SEC_INT); + return(0); +} + void aix_setlimits(user) char *user; @@ -70,15 +81,15 @@ aix_setlimits(user) * We have two strategies, depending on whether or not the * hard limit has been defined. */ - if (getuserattr(user, aix_limits[n].hard, &i, SEC_INT) == 0) { + if (aix_getlimit(user, aix_limits[n].hard, &i) == 0) { rlim.rlim_max = i == -1 ? RLIM_INFINITY : i; - if (getuserattr(user, aix_limits[n].soft, &i, SEC_INT) == 0) + if (aix_getlimit(user, aix_limits[n].soft, &i) == 0) rlim.rlim_cur = i == -1 ? RLIM_INFINITY : i; else rlim.rlim_cur = rlim.rlim_max; /* soft not specd, use hard */ } else { /* No hard limit set, try soft limit. */ - if (getuserattr(user, aix_limits[n].soft, &i, SEC_INT) == 0) + if (aix_getlimit(user, aix_limits[n].soft, &i) == 0) rlim.rlim_cur = i == -1 ? RLIM_INFINITY : i; /* Set hard limit per AIX /etc/security/limits documentation. */