logo

skeud

Simple and portable utilities to deal with user accounts (su, login)
commit: 7ea8455aaa574504026dc6d1dcea50fc29a9f6d3
parent 798faf0af328622e6979a856a7ac8c2a46b2984d
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sun, 10 Sep 2023 15:48:08 +0200

su: Restrict [-p] to super-user

Diffstat:

Msu.c8+++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/su.c b/su.c @@ -55,13 +55,19 @@ main(int argc, char *argv[]) case 's': // shell if(getuid() != 0) { - fprintf(stderr, "su: Only the super-user can override the target shell"); + fprintf(stderr, "su: Only the super-user can override the target shell\n"); return 1; } shell = optarg; break; case 'p': // preserve environment + if(getuid() != 0) + { + fprintf(stderr, "su: Only the super-user can preserve the environment\n"); + return 1; + } + opt_p = true; break; case ':':