diff options
author | Tyler Murphy <tylerm@tylerm.dev> | 2023-05-15 10:57:33 -0400 |
---|---|---|
committer | Tyler Murphy <tylerm@tylerm.dev> | 2023-05-15 10:57:33 -0400 |
commit | 04150a407f65b63ea5117bc8b7297a5fbefc7487 (patch) | |
tree | 6d7981fa6cba7a32ed29c71d86ef3fec0892da9d /command | |
parent | refactor and add su (diff) | |
download | lazysphere-04150a407f65b63ea5117bc8b7297a5fbefc7487.tar.gz lazysphere-04150a407f65b63ea5117bc8b7297a5fbefc7487.tar.bz2 lazysphere-04150a407f65b63ea5117bc8b7297a5fbefc7487.zip |
refactor cmd names
Diffstat (limited to 'command')
-rw-r--r-- | command/cat.c | 2 | ||||
-rw-r--r-- | command/chmod.c | 2 | ||||
-rw-r--r-- | command/chown.c | 2 | ||||
-rw-r--r-- | command/cp.c | 2 | ||||
-rw-r--r-- | command/dd.c | 2 | ||||
-rw-r--r-- | command/echo.c | 2 | ||||
-rw-r--r-- | command/ed.c | 2 | ||||
-rw-r--r-- | command/grep.c | 2 | ||||
-rw-r--r-- | command/groups.c | 2 | ||||
-rw-r--r-- | command/head.c | 2 | ||||
-rw-r--r-- | command/id.c | 2 | ||||
-rw-r--r-- | command/ls.c | 2 | ||||
-rw-r--r-- | command/mkdir.c | 2 | ||||
-rw-r--r-- | command/mv.c | 2 | ||||
-rw-r--r-- | command/printf.c | 2 | ||||
-rw-r--r-- | command/rm.c | 2 | ||||
-rw-r--r-- | command/su.c | 12 | ||||
-rw-r--r-- | command/sync.c | 2 | ||||
-rw-r--r-- | command/tac.c | 2 | ||||
-rw-r--r-- | command/tail.c | 2 | ||||
-rw-r--r-- | command/tee.c | 2 | ||||
-rw-r--r-- | command/wc.c | 2 | ||||
-rw-r--r-- | command/whoami.c | 2 | ||||
-rw-r--r-- | command/xargs.c | 2 | ||||
-rw-r--r-- | command/yes.c | 2 |
25 files changed, 29 insertions, 31 deletions
diff --git a/command/cat.c b/command/cat.c index c392a46..f88ca28 100644 --- a/command/cat.c +++ b/command/cat.c @@ -110,7 +110,7 @@ static int short_arg(char c, char* next) { return ARG_UNUSED; } -COMMAND(cat) { +COMMAND(cat_main) { int start; int arg_len; diff --git a/command/chmod.c b/command/chmod.c index ef4ec3d..eabb91c 100644 --- a/command/chmod.c +++ b/command/chmod.c @@ -190,7 +190,7 @@ end: return mode; } -COMMAND(chmod_cmd) { +COMMAND(chmod_main) { int start, i; diff --git a/command/chown.c b/command/chown.c index dcb6941..e78c1d2 100644 --- a/command/chown.c +++ b/command/chown.c @@ -149,7 +149,7 @@ group: } } -COMMAND(chown_cmd) { +COMMAND(chown_main) { int start, i; diff --git a/command/cp.c b/command/cp.c index 47a4ff0..4c65a51 100644 --- a/command/cp.c +++ b/command/cp.c @@ -197,7 +197,7 @@ static void cp_file(char* path) { pop_path_buffer_2(save2); } -COMMAND(cp) { +COMMAND(cp_main) { int start, i; struct stat s; diff --git a/command/dd.c b/command/dd.c index 1fb81c5..e298c69 100644 --- a/command/dd.c +++ b/command/dd.c @@ -12,7 +12,7 @@ static void help(void) { printf("\tcount=N\t\tCopy only N input blocks\n"); } -COMMAND(dd) { +COMMAND(dd_main) { FILE* in_file = stdin; FILE* out_file = stdout; diff --git a/command/echo.c b/command/echo.c index a0ab78d..49008da 100644 --- a/command/echo.c +++ b/command/echo.c @@ -74,7 +74,7 @@ static int short_arg(char c, char* next) { return ARG_UNUSED; } -COMMAND(echo) { +COMMAND(echo_main) { int start, i; diff --git a/command/ed.c b/command/ed.c index 8e8eae1..f839258 100644 --- a/command/ed.c +++ b/command/ed.c @@ -903,7 +903,7 @@ static void help(void) { printf("\t\t=\t\tprint current line number\n"); } -COMMAND(ed) { +COMMAND(ed_main) { parse_help(argc, argv, help); diff --git a/command/grep.c b/command/grep.c index 0dad094..fc0d280 100644 --- a/command/grep.c +++ b/command/grep.c @@ -227,7 +227,7 @@ static bool run_match(char* path, void* pattern, bool many) { } } -COMMAND(grep) { +COMMAND(grep_main) { int start, i; char* pattern; diff --git a/command/groups.c b/command/groups.c index f95ee80..161e38c 100644 --- a/command/groups.c +++ b/command/groups.c @@ -13,7 +13,7 @@ static void help (void) { printf("Print the groups USER is in\n"); } -COMMAND(groups) { +COMMAND(groups_main) { uid_t uid; int ngroups, i; diff --git a/command/head.c b/command/head.c index c28a82c..ccaa467 100644 --- a/command/head.c +++ b/command/head.c @@ -110,7 +110,7 @@ static int short_arg(char c, char* next) { return ARG_UNUSED; } -COMMAND(head) { +COMMAND(head_main) { int start, count, i; diff --git a/command/id.c b/command/id.c index 3d3d19e..c3d12e9 100644 --- a/command/id.c +++ b/command/id.c @@ -13,7 +13,7 @@ static void help (void) { printf("Print information about the USER\n"); } -COMMAND(user_id) { +COMMAND(id_main) { uid_t uid; gid_t gid, *groups; diff --git a/command/ls.c b/command/ls.c index d4d19c1..517264b 100644 --- a/command/ls.c +++ b/command/ls.c @@ -533,7 +533,7 @@ static int long_arg(char* cur, char* next) { return ARG_UNUSED; } -COMMAND(ls) { +COMMAND(ls_main) { int start, i; bool titled; diff --git a/command/mkdir.c b/command/mkdir.c index e6d6268..36ca4d8 100644 --- a/command/mkdir.c +++ b/command/mkdir.c @@ -46,7 +46,7 @@ static bool mkdir_parents(char* path) { return true; } -COMMAND(makedir) { +COMMAND(mkdir_main) { int start, i; diff --git a/command/mv.c b/command/mv.c index 8f8f0c7..1bd3159 100644 --- a/command/mv.c +++ b/command/mv.c @@ -70,7 +70,7 @@ static void mv_dir(bool exists) { } } -COMMAND(mv) { +COMMAND(mv_main) { int start, dest, i; struct stat s; diff --git a/command/printf.c b/command/printf.c index 99139d0..401941c 100644 --- a/command/printf.c +++ b/command/printf.c @@ -97,7 +97,7 @@ static void help(void) { printf("Format and print ARG(s) according to FORMAT (a-la C prinf)\n"); } -COMMAND(print) { +COMMAND(printf_main) { size_t index; int arg_index; diff --git a/command/rm.c b/command/rm.c index 9834a40..6cee3fc 100644 --- a/command/rm.c +++ b/command/rm.c @@ -110,7 +110,7 @@ static void rm_file(char* path) { pop_path_buffer(save); } -COMMAND(rm) { +COMMAND(rm_main) { int start, i; diff --git a/command/su.c b/command/su.c index 942f37e..dc37652 100644 --- a/command/su.c +++ b/command/su.c @@ -14,7 +14,7 @@ static struct { static bool restricted_shell(const char *shell) { char *line; - int result = true; + bool result = true; while ((line = getusershell()) != NULL) { if (strcmp(line, shell) == 0) { @@ -54,7 +54,7 @@ static int short_arg (char c, char* next) { return ARG_UNUSED; } -COMMAND (su) { +COMMAND (su_main) { int start, res; uid_t cur_uid; @@ -78,15 +78,13 @@ COMMAND (su) { pw = xgetpwnam(flags.user); cur_uid = getuid(); - if (cur_uid != 0) { + if (cur_uid != 0) res = prompt_password(pw, "Password: "); - } else { + else res = PASSWORD_VALID; - } - if (res != PASSWORD_VALID) { + if (res != PASSWORD_VALID) error("invalid password"); - } if (flags.shell && cur_uid != 0 && pw->pw_shell && restricted_shell(pw->pw_shell)) { error_s("using restricted shell"); diff --git a/command/sync.c b/command/sync.c index 89ff86f..1e92866 100644 --- a/command/sync.c +++ b/command/sync.c @@ -63,7 +63,7 @@ static bool sync_file(char* path) { return ret; } -COMMAND(sync_cmd) { +COMMAND(sync_main) { int start, i, ret = EXIT_SUCCESS; diff --git a/command/tac.c b/command/tac.c index 9e9e48e..b209bf2 100644 --- a/command/tac.c +++ b/command/tac.c @@ -88,7 +88,7 @@ cleanup: stack_free(&stack); } -COMMAND(tac) { +COMMAND(tac_main) { FILE* in; int i; diff --git a/command/tail.c b/command/tail.c index 64f4608..4d6a258 100644 --- a/command/tail.c +++ b/command/tail.c @@ -210,7 +210,7 @@ static int short_arg(char c, char* next) { return ARG_UNUSED; } -COMMAND(tail) { +COMMAND(tail_main) { int start, count, i; diff --git a/command/tee.c b/command/tee.c index b9ff974..beb1fdc 100644 --- a/command/tee.c +++ b/command/tee.c @@ -52,7 +52,7 @@ static int short_arg(char c, char* next) { return ARG_UNUSED; } -COMMAND(tee_cmd) { +COMMAND(tee_main) { int start, i; FILE** files; diff --git a/command/wc.c b/command/wc.c index 3150045..73ccce2 100644 --- a/command/wc.c +++ b/command/wc.c @@ -120,7 +120,7 @@ static int short_arg(char c, char* next) { return ARG_UNUSED; } -COMMAND(wc) { +COMMAND(wc_main) { int start, i; diff --git a/command/whoami.c b/command/whoami.c index 5823b8f..efb80a6 100644 --- a/command/whoami.c +++ b/command/whoami.c @@ -11,7 +11,7 @@ static void help(void) { exit(EXIT_SUCCESS); } -COMMAND(whoami) { +COMMAND(whoami_main) { uid_t usr; struct passwd* passwd; diff --git a/command/xargs.c b/command/xargs.c index 47e0f0b..f742dd4 100644 --- a/command/xargs.c +++ b/command/xargs.c @@ -111,7 +111,7 @@ void read_args(FILE* file, char*** args, int* size, int* capacity) { } } -COMMAND(xargs) { +COMMAND(xargs_main) { int start, arg_start, arg_on_stack_count; int size, capacity, i; diff --git a/command/yes.c b/command/yes.c index f979a9f..58d4d67 100644 --- a/command/yes.c +++ b/command/yes.c @@ -6,7 +6,7 @@ static void help(void) { printf("Repeatedly output a line with all specified STRING(s), or 'y'.\n"); } -COMMAND(yes) { +COMMAND(yes_main) { const char* repeat; int i; |