From: Todd C. Miller Date: Wed, 21 Jan 2004 23:01:35 +0000 (+0000) Subject: If sudo is invoked as "sudoedit" the -e flag is implied and no other X-Git-Tag: SUDO_1_6_8~217 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2be964efeafcbbdc49ed78952a83477c21a6ba77;p=sudo If sudo is invoked as "sudoedit" the -e flag is implied and no other flags are permitted. --- diff --git a/Makefile.in b/Makefile.in index 13f26daaa..8e06986ee 100644 --- a/Makefile.in +++ b/Makefile.in @@ -316,6 +316,8 @@ install-dirs: install-binaries: $(PROGS) $(INSTALL) -O $(install_uid) -G $(install_gid) -M 4111 -s sudo $(DESTDIR)$(sudodir)/sudo + ln -f $(DESTDIR)$(sudodir)/sudo $(DESTDIR)$(sudodir)/sudoedit + $(INSTALL) -O $(install_uid) -G $(install_gid) -M 0111 -s visudo $(DESTDIR)$(visudodir)/visudo install-noexec: sudo_noexec.la diff --git a/sudo.c b/sudo.c index 0b287952c..986ce2e69 100644 --- a/sudo.c +++ b/sudo.c @@ -665,6 +665,15 @@ parse_args(argc, argv) NewArgv = argv + 1; NewArgc = argc - 1; + /* Check to see if we were invoked as "sudoedit". */ + if (strcmp(getprogname(), "sudoedit") == 0) { + rval = MODE_EDIT; + if (NewArgc == 0 || NewArgv[0][0] == '-') + usage(1); + return(rval); + } + + rval = MODE_RUN; if (NewArgc == 0) { /* no options and no command */ rval |= (MODE_IMPLIED_SHELL | MODE_SHELL); return(rval); @@ -1072,18 +1081,22 @@ static void usage(exit_val) int exit_val; { + if (strcmp(getprogname(), "sudoedit") == 0) { + fprintf(stderr, "usage: sudoedit file [...]\n"); + exit(exit_val); + } - (void) fprintf(stderr, "usage: sudo -K | -L | -V | -h | -k | -l | -v\n"); - (void) fprintf(stderr, "usage: sudo [-HPSb]%s%s [-p prompt] [-u username|#uid]\n { -e file [...] | -i | -s | }\n", + fprintf(stderr, "usage: sudo -K | -L | -V | -h | -k | -l | -v\n"); + fprintf(stderr, "usage: sudo [-HPSb]%s%s [-p prompt] [-u username|#uid]\n { -e file [...] | -i | -s | }\n", #ifdef HAVE_BSD_AUTH_H - " [-a auth_type]", + " [-a auth_type]", #else - "", + "", #endif #ifdef HAVE_LOGIN_CAP_H - " [-c class|-]"); + " [-c class|-]"); #else - ""); + ""); #endif exit(exit_val); }