diff options
author | Tyler Murphy <tylerm@tylerm.dev> | 2023-05-14 21:43:02 -0400 |
---|---|---|
committer | Tyler Murphy <tylerm@tylerm.dev> | 2023-05-14 21:43:02 -0400 |
commit | e735ad6710a82604a206ad29f6cbcdd7dc4b024c (patch) | |
tree | 5fe8eebbb7a2bff20bb71bd2368955356979e0a2 /command/groups.c | |
parent | sync (diff) | |
download | lazysphere-e735ad6710a82604a206ad29f6cbcdd7dc4b024c.tar.gz lazysphere-e735ad6710a82604a206ad29f6cbcdd7dc4b024c.tar.bz2 lazysphere-e735ad6710a82604a206ad29f6cbcdd7dc4b024c.zip |
refactor and add su
Diffstat (limited to '')
-rw-r--r-- | command/groups.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/command/groups.c b/command/groups.c index cb950be..f95ee80 100644 --- a/command/groups.c +++ b/command/groups.c @@ -1,13 +1,12 @@ -#include "args.h" #include "command.h" #include "lslib.h" -#include <errno.h> #include <grp.h> #include <pwd.h> #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <errno.h> static void help (void) { printf("Usage: groups [USER]\n\n"); @@ -34,14 +33,14 @@ COMMAND(groups) { if (errno == 0) { error("user not found"); } else { - error("failed to fetch groups: %s", strerror(errno)); + error("failed to fetch groups"); } } ngroups = 0; getgrouplist(pw->pw_name, pw->pw_gid, NULL, &ngroups); - groups = malloc(sizeof(gid_t) * ngroups); + groups = xalloc(sizeof(gid_t) * ngroups); getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups); for (i = 0; i < ngroups; i++){ @@ -49,7 +48,7 @@ COMMAND(groups) { if(gr == NULL) { free(groups); - error("failed to fetch groups: %s", strerror(errno)); + error("failed to fetch groups"); } printf("%s ",gr->gr_name); |