diff options
author | Tyler Murphy <tylerm@tylerm.dev> | 2023-05-06 00:39:44 -0400 |
---|---|---|
committer | Tyler Murphy <tylerm@tylerm.dev> | 2023-05-06 00:39:44 -0400 |
commit | d8f2c10b7108fff6b7e437291093a1cadc15ab9f (patch) | |
tree | 3fc50a19d6fbb9c94a8fe147cd2a6c4ba7f59b8d /src/commands/groups.c | |
parent | ansii c (diff) | |
download | lazysphere-d8f2c10b7108fff6b7e437291093a1cadc15ab9f.tar.gz lazysphere-d8f2c10b7108fff6b7e437291093a1cadc15ab9f.tar.bz2 lazysphere-d8f2c10b7108fff6b7e437291093a1cadc15ab9f.zip |
refactor
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; -} |