--- embedaddon/sudo/common/aix.c 2012/02/21 16:23:02 1.1.1.1 +++ embedaddon/sudo/common/aix.c 2013/10/14 07:56:33 1.1.1.5 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2010-2011 Todd C. Miller + * Copyright (c) 2008, 2010-2013 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -33,7 +33,8 @@ #include "missing.h" #include "alloc.h" -#include "error.h" +#include "fatal.h" +#include "sudo_debug.h" #define DEFAULT_TEXT_DOMAIN "sudo" #include "gettext.h" @@ -72,11 +73,12 @@ static int aix_getlimit(char *user, char *lim, rlim64_t *valp) { int val; + debug_decl(aix_getlimit, SUDO_DEBUG_UTIL) if (getuserattr(user, lim, &val, SEC_INT) != 0) - return -1; + debug_return_int(-1); *valp = val; - return 0; + debug_return_int(0); } static void @@ -85,9 +87,10 @@ aix_setlimits(char *user) struct rlimit64 rlim; rlim64_t val; int n; + debug_decl(aix_setlimits, SUDO_DEBUG_UTIL) if (setuserdb(S_READ) != 0) - error(1, "unable to open userdb"); + fatal("unable to open userdb"); /* * For each resource limit, get the soft/hard values for the user @@ -105,9 +108,10 @@ aix_setlimits(char *user) else rlim.rlim_cur = rlim.rlim_max; /* soft not specd, use hard */ } else { - /* No hard limit set, try soft limit. */ - if (aix_getlimit(user, aix_limits[n].soft, &val) == 0) - rlim.rlim_cur = val == -1 ? RLIM64_INFINITY : val * aix_limits[n].factor; + /* No hard limit set, try soft limit, if it exists. */ + if (aix_getlimit(user, aix_limits[n].soft, &val) == -1) + continue; + rlim.rlim_cur = val == -1 ? RLIM64_INFINITY : val * aix_limits[n].factor; /* Set hard limit per AIX /etc/security/limits documentation. */ switch (aix_limits[n].resource) { @@ -126,6 +130,7 @@ aix_setlimits(char *user) (void)setrlimit64(aix_limits[n].resource, &rlim); } enduserdb(); + debug_return; } #ifdef HAVE_SETAUTHDB @@ -138,17 +143,19 @@ void aix_setauthdb(char *user) { char *registry; + debug_decl(aix_setauthdb, SUDO_DEBUG_UTIL) if (user != NULL) { if (setuserdb(S_READ) != 0) - error(1, _("unable to open userdb")); + fatal(_("unable to open userdb")); if (getuserattr(user, S_REGISTRY, ®istry, SEC_CHAR) == 0) { if (setauthdb(registry, NULL) != 0) - error(1, _("unable to switch to registry \"%s\" for %s"), + fatal(_("unable to switch to registry \"%s\" for %s"), registry, user); } enduserdb(); } + debug_return; } /* @@ -157,8 +164,12 @@ aix_setauthdb(char *user) void aix_restoreauthdb(void) { + debug_decl(aix_setauthdb, SUDO_DEBUG_UTIL) + if (setauthdb(NULL, NULL) != 0) - error(1, _("unable to restore registry")); + fatal(_("unable to restore registry")); + + debug_return; } #endif @@ -167,6 +178,7 @@ aix_prep_user(char *user, const char *tty) { char *info; int len; + debug_decl(aix_setauthdb, SUDO_DEBUG_UTIL) /* set usrinfo, like login(1) does */ len = easprintf(&info, "NAME=%s%cLOGIN=%s%cLOGNAME=%s%cTTY=%s%c", @@ -181,5 +193,7 @@ aix_prep_user(char *user, const char *tty) /* set resource limits */ aix_setlimits(user); + + debug_return; } #endif /* HAVE_GETUSERATTR */