diff options
Diffstat (limited to 'src/commands/groups.c')
-rw-r--r-- | src/commands/groups.c | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/src/commands/groups.c b/src/commands/groups.c deleted file mode 100644 index bd2e5f9..0000000 --- a/src/commands/groups.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "../command.h" - -#include <grp.h> -#include <pwd.h> - -COMMAND_EMPTY(groups) { - - uid_t uid; - int ngroups, i; - gid_t* groups; - struct passwd* pw; - - uid = getuid(); - - pw = getpwuid(uid); - if(pw == NULL){ - error("failed to fetch groups: %s", strerror(errno)); - } - - ngroups = 0; - getgrouplist(pw->pw_name, pw->pw_gid, NULL, &ngroups); - - groups = malloc(sizeof(gid_t) * ngroups); - getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups); - - for (i = 0; i < ngroups; i++){ - struct group* gr = getgrgid(groups[i]); - - if(gr == NULL) { - free(groups); - error("failed to fetch groups: %s", strerror(errno)); - } - - printf("%s ",gr->gr_name); - } - - printf("\n"); - - free(groups); - - return EXIT_SUCCESS; -} |