Bring back closefrom settings.

This commit is contained in:
Todd C. Miller
2010-05-24 15:40:36 -04:00
parent 60e0e496ef
commit 0487aee6b4
10 changed files with 154 additions and 86 deletions

View File

@@ -393,6 +393,7 @@ command_info_to_details(char * const info[], struct command_details *details)
char *cp, *ep;
memset(details, 0, sizeof(*details));
details->closefrom = -1;
#define SET_STRING(s, n) \
if (strncmp(s, info[i], sizeof(s) - 1) == 0 && info[i][sizeof(s) - 1]) { \
@@ -407,6 +408,20 @@ command_info_to_details(char * const info[], struct command_details *details)
SET_STRING("chroot=", chroot)
SET_STRING("command=", command)
SET_STRING("cwd=", cwd)
if (strncmp("closefrom=", info[i], sizeof("closefrom=") - 1) == 0) {
cp = info[i] + sizeof("closefrom=") - 1;
if (*cp == '\0')
break;
errno = 0;
lval = strtol(cp, &ep, 0);
if (*cp != '\0' && *ep == '\0' &&
!(errno == ERANGE &&
(lval == LONG_MAX || lval == LONG_MIN)) &&
lval < INT_MAX && lval > INT_MIN) {
details->closefrom = (int)lval;
}
break;
}
break;
case 'l':
SET_STRING("login_class=", login_class)