added EDITOR envar
This commit is contained in:
17
visudo.c
17
visudo.c
@@ -42,11 +42,18 @@ static char rcsid[] = "$Id$";
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#ifdef STD_HEADERS
|
||||||
|
#include <stdlib.h>
|
||||||
|
#endif /* STD_HEADERS */
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include "sudo.h"
|
#include "sudo.h"
|
||||||
|
|
||||||
|
#ifndef STD_HEADERS
|
||||||
|
extern char *getenv();
|
||||||
|
#endif /* !STD_HEADERS */
|
||||||
|
|
||||||
extern FILE *yyin, *yyout;
|
extern FILE *yyin, *yyout;
|
||||||
extern int errno, yylineno;
|
extern int errno, yylineno;
|
||||||
|
|
||||||
@@ -72,6 +79,7 @@ main(argc, argv)
|
|||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
struct stat sbuf;
|
struct stat sbuf;
|
||||||
|
char * Editor;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* handle the signals
|
* handle the signals
|
||||||
@@ -93,6 +101,13 @@ main(argc, argv)
|
|||||||
*/
|
*/
|
||||||
umask(077);
|
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
|
* open the sudoers file read only
|
||||||
*/
|
*/
|
||||||
@@ -138,7 +153,7 @@ main(argc, argv)
|
|||||||
/*
|
/*
|
||||||
* build strings in buffer to be executed by system()
|
* 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);
|
sudoers_tmp_file);
|
||||||
|
|
||||||
/* edit the file */
|
/* edit the file */
|
||||||
|
Reference in New Issue
Block a user