]> granicus.if.org Git - sudo/commitdiff
added EDITOR envar
authorTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 3 Dec 1993 02:35:54 +0000 (02:35 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 3 Dec 1993 02:35:54 +0000 (02:35 +0000)
visudo.c

index 418878d9a316c9c7d700d4c46117df37163f1800..e8546baad202401d3240cf14d3fbad5fa5a4d036 100644 (file)
--- a/visudo.c
+++ b/visudo.c
@@ -42,11 +42,18 @@ static char rcsid[] = "$Id$";
 #include <sys/stat.h>
 #include <sys/file.h>
 #include <stdio.h>
+#ifdef STD_HEADERS
+#include <stdlib.h>
+#endif /* STD_HEADERS */
 #include <errno.h>
 #include <signal.h>
 
 #include "sudo.h"
 
+#ifndef STD_HEADERS
+extern char *getenv();
+#endif /* !STD_HEADERS */
+
 extern FILE *yyin, *yyout;
 extern int errno, yylineno;
 
@@ -72,6 +79,7 @@ main(argc, argv)
 {
     int fd;
     struct stat sbuf;
+    char * Editor;
 
     /*
      * handle the signals
@@ -93,6 +101,13 @@ main(argc, argv)
      */
     umask(077);
 
+    /*
+     * set up the Editor variable correctly
+     */
+    if ( (Editor = getenv("EDITOR")) == NULL)
+       if ( (Editor = getenv("VISUAL")) == NULL )
+           Editor = EDITOR;
+
     /*
      * open the sudoers file read only
      */
@@ -138,7 +153,7 @@ main(argc, argv)
        /*
         * build strings in buffer to be executed by system()
         */
-       (void) sprintf(buffer, "%s +%d %s", EDITOR, err_line_no,
+       (void) sprintf(buffer, "%s +%d %s", Editor, err_line_no,
            sudoers_tmp_file);
 
        /* edit the file */