logo

skeud

Simple and portable utilities to deal with user accounts (su, login)
commit: 4ebf9696aef6ae1de706ee706d536fd0b12a70b7
parent 496ec40ffce5f0d5745c83276358741527d5e15b
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sun, 10 Sep 2023 13:13:31 +0200

su: Simplify handling of -l

Diffstat:

Msu.c9++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/su.c b/su.c @@ -42,7 +42,7 @@ main(int argc, char *argv[]) } /* flawfinder: ignore CWE-120, CWE-20 */ - while((c = getopt(argc, argv, ":c:l:s:p")) != EOF) + while((c = getopt(argc, argv, ":c:ls:p")) != EOF) { switch(c) { @@ -50,8 +50,7 @@ main(int argc, char *argv[]) command = optarg; break; case 'l': // login-mode - opt_l = true; - username = optarg; + opt_l = true; break; case 's': // shell if(getuid() != 0) @@ -97,13 +96,13 @@ main(int argc, char *argv[]) } } - if((opt_l && argc > 0) || argc > 1) + if(argc > 1) { fprintf(stderr, "su: Too many arguments given.\n"); return 1; } - if(!opt_l && argc == 1) + if(argc == 1) { username = argv[0]; }