=================================================================== RCS file: /home/cvs/OpenXM_contrib/gnuplot/Attic/plot.c,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.2 diff -u -p -r1.1.1.1 -r1.1.1.2 --- OpenXM_contrib/gnuplot/Attic/plot.c 2000/01/09 17:00:54 1.1.1.1 +++ OpenXM_contrib/gnuplot/Attic/plot.c 2000/01/22 14:15:59 1.1.1.2 @@ -1,5 +1,5 @@ #ifndef lint -static char *RCSid = "$Id: plot.c,v 1.1.1.1 2000/01/09 17:00:54 maekawa Exp $"; +static char *RCSid = "$Id: plot.c,v 1.1.1.2 2000/01/22 14:15:59 maekawa Exp $"; #endif /* GNUPLOT - plot.c */ @@ -84,7 +84,7 @@ char *call_args[10] = { NULL, NULL, NULL, NULL, NULL, char *infile_name = NULL; /* name of command file; NULL if terminal */ -#ifdef GNU_READLINE +#ifdef HAVE_LIBREADLINE extern char *rl_readline_name; extern int rl_complete_with_tilde_expansion; #endif @@ -216,6 +216,8 @@ static struct udvt_entry udv_pi = { NULL, "pi", FALSE struct udvt_entry *first_udv = &udv_pi; struct udft_entry *first_udf = NULL; +static int exit_status = EXIT_SUCCESS; + #ifdef OS2 # define INCL_DOS # define INCL_REXXSAA @@ -256,7 +258,55 @@ int anint; #endif } +#ifdef LINUXVGA +/* utility functions to ensure that setuid gnuplot + * assumes root privileges only for those parts + * of the code which require root rights. + * + * By "Dr. Werner Fink" + */ +static uid_t euid, ruid; +static gid_t egid, rgid; +static int asked_privi = 0; +void +drop_privilege() +{ + if (!asked_privi) { + euid = geteuid(); + egid = getegid(); + ruid = getuid(); + rgid = getgid(); + asked_privi = 1; + } + if (setegid(rgid) == -1) + (void) fprintf(stderr, "setegid(%d): %s\n", + (int) rgid, strerror(errno)); + if (seteuid(ruid) == -1) + (void) fprintf(stderr, "seteuid(%d): %s\n", + (int) ruid, strerror(errno)); +} + +void +take_privilege() +{ + if (!asked_privi) { + euid = geteuid(); + egid = getegid(); + ruid = getuid(); + rgid = getgid(); + asked_privi = 1; + } + if (setegid(egid) == -1) + (void) fprintf(stderr, "setegid(%d): %s\n", + (int) egid, strerror(errno)); + if (seteuid(euid) == -1) + (void) fprintf(stderr, "seteuid(%d): %s\n", + (int) euid, strerror(errno)); +} +#endif /* LINUXVGA */ + + /* a wrapper for longjmp so we can keep everything local */ void bail_to_command_line() { @@ -329,7 +379,7 @@ char **argv; unsigned int status[2] = { 1, 0 }; #endif -#ifdef GNU_READLINE +#ifdef HAVE_LIBREADLINE rl_readline_name = argv[0]; rl_complete_with_tilde_expansion = 1; #endif @@ -417,6 +467,9 @@ char **argv; fprintf(stderr, "\nTerminal type set to '%s'\n", term->name); } else { /* come back here from int_error() */ + if (interactive == FALSE) + exit_status = EXIT_FAILURE; + #ifdef AMIGA_SC_6_1 (void) rawcon(0); #endif @@ -472,7 +525,7 @@ char **argv; while (!com_line()); - /* interactive = FALSE; /* should this be here? */ + /* interactive = FALSE; */ /* should this be here? */ } else load_file(fopen(*argv, "r"), *argv, FALSE); @@ -499,7 +552,7 @@ char **argv; if (aesid > -1) atexit(appl_exit); #endif - return (IO_SUCCESS); + return (exit_status); } #if (defined(ATARI) || defined(MTOS)) && defined(__PUREC__)