summaryrefslogtreecommitdiffabout
path: root/src/socket.c
Side-by-side diff
Diffstat (limited to 'src/socket.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/socket.c54
1 files changed, 28 insertions, 26 deletions
diff --git a/src/socket.c b/src/socket.c
index aa01543..40c7aa7 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -25,9 +25,12 @@ switch_eids (uid_t *puid, gid_t *pgid, mode_t *pumask)
mode_t omask = umask (*pumask);
-
- if (setegid (*pgid))
- logmsg (LOG_ERR, _("cannot switch to EGID %lu: %s"),
- (unsigned long) *pgid, strerror (errno));
- if (seteuid (*puid))
- logmsg (LOG_ERR, _("cannot switch to EUID %lu: %s"),
- (unsigned long) *puid, strerror (errno));
+
+ if ((*puid && *puid != ouid) || (*pgid && *pgid != ogid))
+ {
+ if (setegid (*pgid))
+ logmsg (LOG_ERR, _("cannot switch to EGID %lu: %s"),
+ (unsigned long) *pgid, strerror (errno));
+ if (seteuid (*puid))
+ logmsg (LOG_ERR, _("cannot switch to EUID %lu: %s"),
+ (unsigned long) *puid, strerror (errno));
+ }
*puid = ouid;
@@ -53,3 +56,3 @@ create_socket (struct pies_url *url, int socket_type,
int switch_back;
-
+
if (strcmp (url->scheme, "unix") == 0
@@ -60,3 +63,3 @@ create_socket (struct pies_url *url, int socket_type,
const char *group = NULL;
-
+
user = url->user;
@@ -101,3 +104,3 @@ create_socket (struct pies_url *url, int socket_type,
}
-
+
if (user)
@@ -113,3 +116,3 @@ create_socket (struct pies_url *url, int socket_type,
}
-
+
if (group)
@@ -124,3 +127,3 @@ create_socket (struct pies_url *url, int socket_type,
}
-
+
if (strlen (url->path) > sizeof addr.s_un.sun_path)
@@ -161,3 +164,3 @@ create_socket (struct pies_url *url, int socket_type,
short port = url->port;
-
+
uid = 0;
@@ -168,3 +171,3 @@ create_socket (struct pies_url *url, int socket_type,
socklen = sizeof (addr.s_in);
-
+
if (!host)
@@ -187,3 +190,3 @@ create_socket (struct pies_url *url, int socket_type,
break;
-
+
default:
@@ -200,3 +203,3 @@ create_socket (struct pies_url *url, int socket_type,
}
-
+
fd = socket (addr.sa.sa_family, socket_type, url->proto);
@@ -252,3 +255,3 @@ pass_fd0 (int fd, int payload)
# endif /* ! CMSG_SPACE */
-
+
char control[CMSG_SPACE (sizeof (int))];
@@ -292,3 +295,3 @@ pass_fd (const char *socket_name, int fd, unsigned maxtime)
struct sockaddr_un addr;
-
+
if (strlen (socket_name) > sizeof addr.sun_path)
@@ -300,3 +303,3 @@ pass_fd (const char *socket_name, int fd, unsigned maxtime)
strcpy (addr.sun_path, socket_name);
-
+
for (;;)
@@ -364,3 +367,3 @@ pass_fd (const char *socket_name, int fd, unsigned maxtime)
struct timeval tv;
-
+
FD_ZERO (&fds);
@@ -432,3 +435,3 @@ calc_fd_max (void)
void *
-register_socket (int fd,
+register_socket (int fd,
socket_handler_t rd,
@@ -456,3 +459,3 @@ register_socket (int fd,
}
-
+
si_tail = sip;
@@ -495,3 +498,3 @@ delete_sockinst (struct sockinst *sp)
fd_max = -1;
-
+
if (sp->prev)
@@ -574,3 +577,3 @@ pies_pause (void)
return;
-
+
if (fd_max == -1)
@@ -583,3 +586,3 @@ pies_pause (void)
fd_set exset = fdset[PIES_EVT_EX];
-
+
int rc = select (fd_max + 1, &rdset, &wrset, &exset, NULL);
@@ -639,2 +642 @@ pies_pause (void)
}
-

Return to:

Send suggestions and report system problems to the System administrator.