summaryrefslogtreecommitdiff
path: root/command/su.c
diff options
context:
space:
mode:
authorTyler Murphy <tylerm@tylerm.dev>2023-05-15 10:57:33 -0400
committerTyler Murphy <tylerm@tylerm.dev>2023-05-15 10:57:33 -0400
commit04150a407f65b63ea5117bc8b7297a5fbefc7487 (patch)
tree6d7981fa6cba7a32ed29c71d86ef3fec0892da9d /command/su.c
parentrefactor and add su (diff)
downloadlazysphere-04150a407f65b63ea5117bc8b7297a5fbefc7487.tar.gz
lazysphere-04150a407f65b63ea5117bc8b7297a5fbefc7487.tar.bz2
lazysphere-04150a407f65b63ea5117bc8b7297a5fbefc7487.zip
refactor cmd names
Diffstat (limited to 'command/su.c')
-rw-r--r--command/su.c12
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");