* This version of set_perms() works fine with the "stay_setuid" option.
*/
int
-set_perms(perm)
- int perm;
+set_perms2(int perm, int push_it)
{
const char *errstr;
int noexit;
noexit = ISSET(perm, PERM_NOEXIT);
CLR(perm, PERM_MASK);
+ if (perm_stack_depth == PERM_STACK_MAX) {
+ errno = EINVAL;
+ goto bad;
+ }
if (perm == perm_current)
- return(1);
+ goto done;
switch (perm) {
case PERM_ROOT:
break;
}
+done:
+ if (push_it)
+ perm_stack[perm_stack_depth++] = perm_current;
perm_current = perm;
return(1);
bad:
* NOTE: does not support the "stay_setuid" option.
*/
int
-set_perms(perm)
- int perm;
+set_perms2(int perm, int push_it)
{
const char *errstr;
int noexit;
noexit = ISSET(perm, PERM_NOEXIT);
CLR(perm, PERM_MASK);
+ if (perm_stack_depth == PERM_STACK_MAX) {
+ errno = EINVAL;
+ goto bad;
+ }
if (perm == perm_current)
- return(1);
+ goto done;
/*
* Since we only have setuid() and seteuid() and semantics
break;
}
+done:
+ if (push_it)
+ perm_stack[perm_stack_depth++] = perm_current;
perm_current = perm;
return(1);
bad:
* Also, SUDOERS_UID and SUDOERS_GID are not used.
*/
int
-set_perms(perm)
- int perm;
+set_perms2(int perm, int push_it)
{
const char *errstr;
int noexit;
noexit = ISSET(perm, PERM_NOEXIT);
CLR(perm, PERM_MASK);
+ if (perm_stack_depth == PERM_STACK_MAX) {
+ errno = EINVAL;
+ goto bad;
+ }
if (perm == perm_current)
- return(1);
+ goto done;
switch (perm) {
case PERM_ROOT:
break;
}
+done:
+ if (push_it)
+ perm_stack[perm_stack_depth++] = perm_current;
perm_current = perm;
return(1);
bad: