do not complain when negating selection if we can't find a user/group
This commit is contained in:
parent
c5ee091e4c
commit
c29ce7be61
20
ps/parser.c
20
ps/parser.c
@ -95,10 +95,14 @@ static const char *parse_uid(char *str, sel_union *ret){
|
||||
num = strtoul(str, &endp, 0);
|
||||
if(*endp != '\0'){ /* hmmm, try as login name */
|
||||
passwd_data = getpwnam(str);
|
||||
if(!passwd_data) return _("user name does not exist");
|
||||
num = passwd_data->pw_uid;
|
||||
if(!passwd_data){
|
||||
if(!negate_selection) return _("user name does not exist");
|
||||
num = -1;
|
||||
}
|
||||
else
|
||||
num = passwd_data->pw_uid;
|
||||
}
|
||||
if(num > 0xfffffffeUL) return _("user ID out of range");
|
||||
if(!negate_selection && (num > 0xfffffffeUL)) return _("user ID out of range");
|
||||
ret->uid = num;
|
||||
return 0;
|
||||
}
|
||||
@ -110,10 +114,14 @@ static const char *parse_gid(char *str, sel_union *ret){
|
||||
num = strtoul(str, &endp, 0);
|
||||
if(*endp != '\0'){ /* hmmm, try as login name */
|
||||
group_data = getgrnam(str);
|
||||
if(!group_data) return _("group name does not exist");
|
||||
num = group_data->gr_gid;
|
||||
if(!group_data){
|
||||
if(!negate_selection) return _("group name does not exist");
|
||||
num = -1;
|
||||
}
|
||||
else
|
||||
num = group_data->gr_gid;
|
||||
}
|
||||
if(num > 0xfffffffeUL) return _("group ID out of range");
|
||||
if(!negate_selection && (num > 0xfffffffeUL)) return _("group ID out of range");
|
||||
ret->gid = num;
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user