fixed
This commit is contained in:
parent
a51d35681b
commit
6c318515a3
2
configs/group
Normal file
2
configs/group
Normal file
|
@ -0,0 +1,2 @@
|
|||
root::0:root
|
||||
|
4
configs/os-release
Normal file
4
configs/os-release
Normal file
|
@ -0,0 +1,4 @@
|
|||
NAME="Plain Os"
|
||||
ID=plainos
|
||||
VERSION_ID=0.1
|
||||
PRETTY_NAME="PlainOs/Linux 0.1 "
|
|
@ -16,19 +16,11 @@ char r_flag;
|
|||
char u_flag;
|
||||
|
||||
int print_groups(const struct passwd *pwd, const char *fmt, const int flag) {
|
||||
int ngroups = 0;
|
||||
getgrouplist(pwd->pw_name, pwd->pw_gid, NULL, &ngroups);
|
||||
if (ngroups <= 0)
|
||||
gid_t groups[NGROUPS_MAX];
|
||||
int ngroups = NGROUPS_MAX;
|
||||
if (getgrouplist(pwd->pw_name, pwd->pw_gid, groups, &ngroups) < 0)
|
||||
return 1;
|
||||
|
||||
gid_t *groups = malloc(ngroups * sizeof(gid_t *));
|
||||
if (groups == NULL) {
|
||||
fprintf(stderr, "id: malloc failed\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
getgrouplist(pwd->pw_name, pwd->pw_gid, groups, &ngroups);
|
||||
|
||||
for (int i = 0; i < ngroups; i++) {
|
||||
struct group *grp = getgrgid(groups[i]);
|
||||
if (grp && !n_flag)
|
||||
|
@ -43,7 +35,6 @@ int print_groups(const struct passwd *pwd, const char *fmt, const int flag) {
|
|||
putchar(' ');
|
||||
}
|
||||
|
||||
free(groups);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user