Fix compilation errors caused by more files not added in previous commit
This commit is contained in:
34
lib/other/initgroups.c
Normal file
34
lib/other/initgroups.c
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
initgroups.c
|
||||
*/
|
||||
#include <sys/param.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <grp.h>
|
||||
|
||||
|
||||
int initgroups(const char *name, gid_t basegid)
|
||||
{
|
||||
struct group *gr;
|
||||
int r, found = 0, n = 0;
|
||||
gid_t groups[NGROUPS];
|
||||
|
||||
if((r = setgid(basegid)) < 0)
|
||||
return(r);
|
||||
|
||||
setgrent();
|
||||
while ((gr = getgrent()) != NULL && (n + 1) <= NGROUPS) {
|
||||
char **mem;
|
||||
for(mem = gr->gr_mem; mem && *mem; mem++) {
|
||||
if(!strcmp(name, *mem)) {
|
||||
groups[n++] = gr->gr_gid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endgrent();
|
||||
|
||||
return setgroups(n, groups);
|
||||
}
|
||||
|
||||
7
lib/syscall/setgroups.s
Normal file
7
lib/syscall/setgroups.s
Normal file
@@ -0,0 +1,7 @@
|
||||
.sect .text
|
||||
.extern __setgroups
|
||||
.define _setgroups
|
||||
.align 2
|
||||
|
||||
_setgroups:
|
||||
jmp __setgroups
|
||||
Reference in New Issue
Block a user