From: Todd C. Miller Date: Fri, 3 Dec 1993 02:35:54 +0000 (+0000) Subject: added EDITOR envar X-Git-Tag: SUDO_1_3_0~51 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=07f4067d5e9610488d1b03d03cccfbb740ccecd6;p=sudo added EDITOR envar --- diff --git a/visudo.c b/visudo.c index 418878d9a..e8546baad 100644 --- a/visudo.c +++ b/visudo.c @@ -42,11 +42,18 @@ static char rcsid[] = "$Id$"; #include #include #include +#ifdef STD_HEADERS +#include +#endif /* STD_HEADERS */ #include #include #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 */