-
Notifications
You must be signed in to change notification settings - Fork 262
newsubgid: add deny_setgroups option to /etc/subgid #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
fdfb3b9
4a43149
0d368da
b1a1af3
626af91
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -152,7 +152,8 @@ | |
| int i; | ||
| char **tmp; | ||
|
|
||
| assert (NULL != list); | ||
| if (NULL == list) | ||
| return NULL; | ||
|
|
||
| for (i = 0; NULL != list[i]; i++); | ||
|
|
||
|
|
@@ -169,6 +170,23 @@ | |
| return tmp; | ||
| } | ||
|
|
||
| /* | ||
| * Free a list. | ||
| * The output list isn't modified, but the memory is freed. | ||
| */ | ||
| void free_list (char *const *list) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did this to match the signature of |
||
| { | ||
| int i; | ||
|
|
||
| if (NULL == list) | ||
| return; | ||
|
|
||
| for (i = 0; NULL != list[i]; i++) | ||
| free(list[i]); | ||
| free((void *)list); | ||
| } | ||
|
|
||
|
|
||
| /* | ||
| * Check if member is part of the input list | ||
| * The input list is not modified, but in order to allow the use of this | ||
|
|
@@ -269,3 +287,30 @@ bool is_on_list (char *const *list, const char *member) | |
| return array; | ||
| } | ||
|
|
||
| /* | ||
| * comma_from_list - inverse of comma_to_list | ||
| */ | ||
|
|
||
| /*@only@*/char *comma_from_list (char *const *list) | ||
| { | ||
| char *comma; | ||
| int i, commalen = 0; | ||
|
|
||
| if (NULL == list) | ||
| return NULL; | ||
|
|
||
| for (i = 0; NULL != list[i]; i++) | ||
| commalen += strlen(list[i]) + 1; | ||
|
|
||
| comma = xmalloc(commalen + 1); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technically +1 shouldn't be needed here right? Each entry is followed by either comma or \0, and you add +1 to the length of each entry as you add up.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interestingly, the loops are simpler if we leave a trailing comma, so that a CSV would look like |
||
| memset(comma, '\0', commalen + 1); | ||
|
|
||
| for (i = 0; NULL != list[i]; i++) { | ||
| int j = strlen(comma); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't really performance critical, but re-calculating j at each iteration here is unnecessary.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, but you're using strncat which doesn't give you the printed length, I see :)
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We now have stpecpy(), which is designed precisely with this in mind. |
||
| if (j > 0) | ||
| comma[j++] = ','; | ||
| strncat(comma, list[i], commalen - j); | ||
| } | ||
|
|
||
| return comma; | ||
| } | ||
|
Comment on lines
+308
to
+316
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use stpecpy() instead. We have forbidden strncat() with string input; we only allow it with With stpecpy() --which is defined in char *p, *e;
[...]
p = comma;
e = comma + commalen + 1;
for (int i = 0; NULL != list[i]; i++) {
p = stpecpy(p, e, list[i]);
p = stpecpy(p, e, ",");
}
if (p == NULL) {
free(comma);
return NULL;
}
return comma;
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or, since we know there won't be truncation, we can just use stpcpy(3) from libc. char *p;
[...]
p = comma;
for (int i = 0; NULL != list[i]; i++) {
p = stpecpy(p, list[i]);
p = stpecpy(p, ",");
}
return comma; |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iiuc this is a gnu extension, probably not safe for shadow to use, so please make it options ? options : ""
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have recently embraced this GNU extension.