This also incorporates the comments from @paulusmack.
Generally, fixes:
- Suppresed warnings w.r.t. unused results in signal handling and result from write()
- Unused results w.r.t. setuid/getuid/chdir
Signed-off-by: Eivind Næss <eivnaes@yahoo.com>
char numbuf[16];
int pipefd[2];
char numbuf[16];
int pipefd[2];
exit(0); /* parent dies */
}
setsid();
exit(0); /* parent dies */
}
setsid();
+ ret = chdir("/");
+ if (ret != 0) {
+ fatal("Could not change directory to '/', %m");
+ }
dup2(fd_devnull, 0);
dup2(fd_devnull, 1);
dup2(fd_devnull, 2);
dup2(fd_devnull, 0);
dup2(fd_devnull, 1);
dup2(fd_devnull, 2);
/* Send the signal to the [dis]connector process(es) also */
kill_my_pg(sig);
notify(sigreceived, sig);
/* Send the signal to the [dis]connector process(es) also */
kill_my_pg(sig);
notify(sigreceived, sig);
+ if (waiting) {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
write(sigpipe[1], &sig, sizeof(sig));
write(sigpipe[1], &sig, sizeof(sig));
+#pragma GCC diagnostic pop
+ }
/* Send the signal to the [dis]connector process(es) also */
kill_my_pg(sig);
notify(sigreceived, sig);
/* Send the signal to the [dis]connector process(es) also */
kill_my_pg(sig);
notify(sigreceived, sig);
+ if (waiting) {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
write(sigpipe[1], &sig, sizeof(sig));
write(sigpipe[1], &sig, sizeof(sig));
+#pragma GCC diagnostic pop
+ }
chld(int sig)
{
got_sigchld = 1;
chld(int sig)
{
got_sigchld = 1;
+ if (waiting) {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
write(sigpipe[1], &sig, sizeof(sig));
write(sigpipe[1], &sig, sizeof(sig));
+#pragma GCC diagnostic pop
+ }
open_ccp(int sig)
{
got_sigusr2 = 1;
open_ccp(int sig)
{
got_sigusr2 = 1;
+ if (waiting) {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-result"
write(sigpipe[1], &sig, sizeof(sig));
write(sigpipe[1], &sig, sizeof(sig));
+#pragma GCC diagnostic pop
+ }
int pid;
int status = -1;
int errfd;
int pid;
int status = -1;
int errfd;
if (log_to_fd >= 0)
errfd = log_to_fd;
if (log_to_fd >= 0)
errfd = log_to_fd;
}
/* here we are executing in the child */
}
/* here we are executing in the child */
-
- setgid(getgid());
- setuid(uid);
- if (getuid() != uid) {
- fprintf(stderr, "pppd: setuid failed\n");
- exit(1);
+ ret = setgid(getgid());
+ if (ret != 0) {
+ perror("pppd: setgid failed\n");
+ exit(1);
+ }
+ ret = setuid(uid);
+ if (ret != 0 || getuid() != uid) {
+ perror("pppd: setuid failed\n");
+ exit(1);
}
update_system_environment();
execl("/bin/sh", "sh", "-c", program, (char *)0);
}
update_system_environment();
execl("/bin/sh", "sh", "-c", program, (char *)0);
pid_t
run_program(char *prog, char **args, int must_exist, void (*done)(void *), void *arg, int wait)
{
pid_t
run_program(char *prog, char **args, int must_exist, void (*done)(void *), void *arg, int wait)
{
/* Leave the current location */
(void) setsid(); /* No controlling tty. */
(void) umask (S_IRWXG|S_IRWXO);
/* Leave the current location */
(void) setsid(); /* No controlling tty. */
(void) umask (S_IRWXG|S_IRWXO);
- (void) chdir ("/"); /* no current directory. */
- setuid(0); /* set real UID = root */
- setgid(getegid());
+ ret = chdir ("/"); /* no current directory. */
+ if (ret != 0) {
+ fatal("Failed to change directory to '/', %m");
+ }
+ ret = setuid(0); /* set real UID = root */
+ if (ret != 0) {
+ fatal("Failed to set uid, %m");
+ }
+ ret = setgid(getegid());
+ if (ret != 0) {
+ fatal("failed to set gid, %m");
+ }
#ifdef BSD
/* Force the priority back to zero if pppd is running higher. */
#ifdef BSD
/* Force the priority back to zero if pppd is running higher. */