]> granicus.if.org Git - sudo/commitdiff
If sudo is invoked as "sudoedit" the -e flag is implied and no other
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 21 Jan 2004 23:01:35 +0000 (23:01 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 21 Jan 2004 23:01:35 +0000 (23:01 +0000)
flags are permitted.

Makefile.in
sudo.c

index 13f26daaac3d88d8feaf6625ff2567b1152b4cc3..8e06986ee868820bc18d7ed7aefc17504ba43105 100644 (file)
@@ -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 0b287952ca9444af382efbd491f17588083d1b7b..986ce2e694915e399e40dc2f43a20db16f55965a 100644 (file)
--- 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 | <command> }\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 | <command> }\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);
 }