Diff for /embedaddon/sudo/common/aix.c between versions 1.1 and 1.1.1.6

version 1.1, 2012/02/21 16:23:02 version 1.1.1.6, 2014/06/15 16:12:54
Line 1 Line 1
 /*  /*
 * Copyright (c) 2008, 2010-2011 Todd C. Miller <Todd.Miller@courtesan.com> * Copyright (c) 2008, 2010-2013 Todd C. Miller <Todd.Miller@courtesan.com>
  *   *
  * Permission to use, copy, modify, and distribute this software for any   * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above   * purpose with or without fee is hereby granted, provided that the above
Line 31 Line 31
 #include <usersec.h>  #include <usersec.h>
 #include <uinfo.h>  #include <uinfo.h>
   
   #define DEFAULT_TEXT_DOMAIN     "sudo"
   #include "gettext.h"            /* must be included before missing.h */
   
 #include "missing.h"  #include "missing.h"
 #include "alloc.h"  #include "alloc.h"
#include "error.h"#include "fatal.h"
 #include "sudo_debug.h"
 #include "sudo_util.h"
   
 #define DEFAULT_TEXT_DOMAIN     "sudo"  
 #include "gettext.h"  
   
 #ifdef HAVE_GETUSERATTR  #ifdef HAVE_GETUSERATTR
   
 #ifndef HAVE_SETRLIMIT64  #ifndef HAVE_SETRLIMIT64
Line 72  static int Line 74  static int
 aix_getlimit(char *user, char *lim, rlim64_t *valp)  aix_getlimit(char *user, char *lim, rlim64_t *valp)
 {  {
     int val;      int val;
       debug_decl(aix_getlimit, SUDO_DEBUG_UTIL)
   
     if (getuserattr(user, lim, &val, SEC_INT) != 0)      if (getuserattr(user, lim, &val, SEC_INT) != 0)
        return -1;        debug_return_int(-1);
     *valp = val;      *valp = val;
    return 0;    debug_return_int(0);
 }  }
   
 static void  static void
Line 85  aix_setlimits(char *user) Line 88  aix_setlimits(char *user)
     struct rlimit64 rlim;      struct rlimit64 rlim;
     rlim64_t val;      rlim64_t val;
     int n;      int n;
       debug_decl(aix_setlimits, SUDO_DEBUG_UTIL)
   
     if (setuserdb(S_READ) != 0)      if (setuserdb(S_READ) != 0)
        error(1, "unable to open userdb");        fatal(U_("unable to open userdb"));
   
     /*      /*
      * For each resource limit, get the soft/hard values for the user       * For each resource limit, get the soft/hard values for the user
Line 105  aix_setlimits(char *user) Line 109  aix_setlimits(char *user)
             else              else
                 rlim.rlim_cur = rlim.rlim_max;  /* soft not specd, use hard */                  rlim.rlim_cur = rlim.rlim_max;  /* soft not specd, use hard */
         } else {          } else {
            /* No hard limit set, try soft limit. */            /* No hard limit set, try soft limit, if it exists. */
            if (aix_getlimit(user, aix_limits[n].soft, &val) == 0)            if (aix_getlimit(user, aix_limits[n].soft, &val) == -1)
                rlim.rlim_cur = val == -1 ? RLIM64_INFINITY : val * aix_limits[n].factor;                continue;
             rlim.rlim_cur = val == -1 ? RLIM64_INFINITY : val * aix_limits[n].factor;
   
             /* Set hard limit per AIX /etc/security/limits documentation. */              /* Set hard limit per AIX /etc/security/limits documentation. */
             switch (aix_limits[n].resource) {              switch (aix_limits[n].resource) {
Line 126  aix_setlimits(char *user) Line 131  aix_setlimits(char *user)
         (void)setrlimit64(aix_limits[n].resource, &rlim);          (void)setrlimit64(aix_limits[n].resource, &rlim);
     }      }
     enduserdb();      enduserdb();
       debug_return;
 }  }
   
 #ifdef HAVE_SETAUTHDB  #ifdef HAVE_SETAUTHDB
Line 138  void Line 144  void
 aix_setauthdb(char *user)  aix_setauthdb(char *user)
 {  {
     char *registry;      char *registry;
       debug_decl(aix_setauthdb, SUDO_DEBUG_UTIL)
   
     if (user != NULL) {      if (user != NULL) {
         if (setuserdb(S_READ) != 0)          if (setuserdb(S_READ) != 0)
            error(1, _("unable to open userdb"));            fatal(U_("unable to open userdb"));
         if (getuserattr(user, S_REGISTRY, &registry, SEC_CHAR) == 0) {          if (getuserattr(user, S_REGISTRY, &registry, SEC_CHAR) == 0) {
             if (setauthdb(registry, NULL) != 0)              if (setauthdb(registry, NULL) != 0)
                error(1, _("unable to switch to registry \"%s\" for %s"),                fatal(U_("unable to switch to registry \"%s\" for %s"),
                     registry, user);                      registry, user);
         }          }
         enduserdb();          enduserdb();
     }      }
       debug_return;
 }  }
   
 /*  /*
Line 157  aix_setauthdb(char *user) Line 165  aix_setauthdb(char *user)
 void  void
 aix_restoreauthdb(void)  aix_restoreauthdb(void)
 {  {
       debug_decl(aix_setauthdb, SUDO_DEBUG_UTIL)
   
     if (setauthdb(NULL, NULL) != 0)      if (setauthdb(NULL, NULL) != 0)
        error(1, _("unable to restore registry"));        fatal(U_("unable to restore registry"));
 
     debug_return;
 }  }
 #endif  #endif
   
Line 167  aix_prep_user(char *user, const char *tty) Line 179  aix_prep_user(char *user, const char *tty)
 {  {
     char *info;      char *info;
     int len;      int len;
       debug_decl(aix_setauthdb, SUDO_DEBUG_UTIL)
   
     /* set usrinfo, like login(1) does */      /* set usrinfo, like login(1) does */
     len = easprintf(&info, "NAME=%s%cLOGIN=%s%cLOGNAME=%s%cTTY=%s%c",      len = easprintf(&info, "NAME=%s%cLOGIN=%s%cLOGNAME=%s%cTTY=%s%c",
Line 181  aix_prep_user(char *user, const char *tty) Line 194  aix_prep_user(char *user, const char *tty)
   
     /* set resource limits */      /* set resource limits */
     aix_setlimits(user);      aix_setlimits(user);
   
       debug_return;
 }  }
 #endif /* HAVE_GETUSERATTR */  #endif /* HAVE_GETUSERATTR */

Removed from v.1.1  
changed lines
  Added in v.1.1.1.6


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>