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/su.c | |
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/su.c')
-rw-r--r-- | command/su.c | 12 |
1 files changed, 5 insertions, 7 deletions
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"); |