From cc548e1c9a4f01e060adea12e49af66b43faf7ca Mon Sep 17 00:00:00 2001 From: Stefan Ritt Date: Mon, 16 Jul 2007 13:43:56 +0000 Subject: [PATCH] Replaced seteuid/setegid by setreuid/setregid for HP-UX compatibility SVN revision: 1888 --- Makefile | 2 +- elog.spec | 2 +- src/elogd.c | 11 ++++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 6e5e9975..afedebab 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ RCDIR = $(ROOT)/etc/rc.d/init.d # Default compilation flags unless stated otherwise. # Add "-DHAVE_CRYPT" and "-lcrypt" to use crypt() function. -CFLAGS += -O3 -funroll-loops -fomit-frame-pointer -W -Wall +CFLAGS += -g -O0 -funroll-loops -fomit-frame-pointer -W -Wall CC = gcc IFLAGS = -kr -nut -i3 -l110 diff --git a/elog.spec b/elog.spec index 730b52c8..8a162f6c 100755 --- a/elog.spec +++ b/elog.spec @@ -2,7 +2,7 @@ Name: elog Summary: elog is a standalone electronic web logbook -Version: 2.6.4 +Version: 2.6.5 Release: 1 License: GPL Group: Applications/Networking diff --git a/src/elogd.c b/src/elogd.c index b4a58440..5cdca998 100755 --- a/src/elogd.c +++ b/src/elogd.c @@ -1163,7 +1163,7 @@ int subst_shell(char *cmd, char *result, int size) /* child process */ /* restore original UID/GID */ - if (setegid(orig_gid) < 0 || seteuid(orig_uid) < 0) + if (setregid(-1, orig_gid) < 0 || setreuid(-1, orig_uid) < 0) eprintf("Cannot restore original GID/UID.\n"); /* give up root privilege permanently */ @@ -1915,7 +1915,7 @@ int setegroup(char *str) gr = getgrnam(str); if (gr != NULL) - if (setegid(gr->gr_gid) >= 0 && initgroups(gr->gr_name, gr->gr_gid) >= 0) + if (setregid(-1, gr->gr_gid) >= 0 && initgroups(gr->gr_name, gr->gr_gid) >= 0) return 0; else { eprintf("Cannot set effective GID to group \"%s\"\n", gr->gr_name); @@ -1938,9 +1938,9 @@ int seteuser(char *str) pw = getpwnam(str); if (pw != NULL) - if (seteuid(pw->pw_uid) >= 0) + if (setreuid(-1, pw->pw_uid) >= 0) { return 0; - else { + } else { eprintf("Cannot set effective UID to user \"%s\"\n", str); eprintf("setuser: %s\n", strerror(errno)); } else @@ -25747,6 +25747,7 @@ void server_loop(void) strcpy(remote_host[i_conn], (char *) inet_ntoa(rem_addr)); strcpy(rem_host, remote_host[i_conn]); + printf("X-forwarded-host: %s\n", rem_host); } if (_logging_level > 3) { @@ -26544,7 +26545,7 @@ void cleanup(void) struct stat finfo; /* regain original uid */ - if (setegid(orig_gid) < 0 || seteuid(orig_uid) < 0) + if (setregid(-1, orig_gid) < 0 || setreuid(-1, orig_uid) < 0) eprintf("Cannot restore original GID/UID.\n"); if (pidfile[0] && stat(pidfile, &finfo) >= 0) { if (remove(pidfile) < 0) {