logo

skeud

Simple and portable utilities to deal with user accounts (su, login)
commit: 371f5a899203fa1af6a11a45e794da7ea7ee2b01
parent f4479ed7ac4a976ecb48bdd2f50a3cd53b69bc94
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sun,  9 Oct 2022 03:49:25 +0200

su: Add support for - option

Diffstat:

Msu.c14++++++++++++++
1 file changed, 14 insertions(+), 0 deletions(-)

diff --git a/su.c b/su.c @@ -74,6 +74,20 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; + if(argv[0] && strcmp(argv[0], "-") == 0) + { + if(argc < 2) + { + fprintf(stderr, "su: Option - requires an operand\n"); + return 1; + } + + opt_l = true; + username = argv[1]; + argc -= 2; + argv += 2; + } + if((opt_l && argc > 0) || argc > 1) { fprintf(stderr, "su: Too many arguments given.\n");