added EDITOR envar

This commit is contained in:
Todd C. Miller
1993-12-03 02:35:54 +00:00
parent 62ea70cb3a
commit 07f4067d5e

View File

@@ -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 */