* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#define RCSID "$Id: options.c,v 1.99 2006/06/04 07:04:57 paulus Exp $"
+#define RCSID "$Id: options.c,v 1.100 2006/06/18 11:26:00 paulus Exp $"
#include <ctype.h>
#include <stdio.h>
option_t *opt;
int oldpriv, n;
char *oldsource;
+ uid_t euid;
char *argv[MAXARGS];
char args[MAXARGS][MAXWORDLEN];
char cmd[MAXWORDLEN];
+ euid = geteuid();
if (check_prot && seteuid(getuid()) == -1) {
option_error("unable to drop privileges to open %s: %m", filename);
return 0;
}
f = fopen(filename, "r");
err = errno;
- if (check_prot && seteuid(0) == -1)
+ if (check_prot && seteuid(euid) == -1)
fatal("unable to regain privileges");
if (f == NULL) {
errno = err;
char **argv;
{
int fd, err;
+ uid_t euid;
+ euid = geteuid();
if (!privileged_option && seteuid(getuid()) == -1) {
option_error("unable to drop permissions to open %s: %m", *argv);
return 0;
if (fd < 0 && errno == EEXIST)
fd = open(*argv, O_WRONLY | O_APPEND);
err = errno;
- if (!privileged_option && seteuid(0) == -1)
+ if (!privileged_option && seteuid(euid) == -1)
fatal("unable to regain privileges: %m");
if (fd < 0) {
errno = err;