From 3f4190bb5c21d5feb0474b8f547e93a7f99d270c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Eivind=20N=C3=A6ss?= Date: Mon, 20 Sep 2021 09:34:15 -0700 Subject: [PATCH] Fixing compiler warnings with regards to GCC, w.r.t. unused results of setuid/setgid MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Eivind Næss --- pppd/tty.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pppd/tty.c b/pppd/tty.c index 41328fb..7e208ba 100644 --- a/pppd/tty.c +++ b/pppd/tty.c @@ -909,7 +909,7 @@ open_socket(char *dest) static int start_charshunt(int ifd, int ofd) { - int cpid; + int cpid, ret; cpid = safe_fork(ifd, ofd, (log_to_fd >= 0? log_to_fd: 2)); if (cpid == -1) { @@ -923,10 +923,14 @@ start_charshunt(int ifd, int ofd) log_to_fd = -1; else if (log_to_fd >= 0) log_to_fd = 2; - setgid(getgid()); - setuid(uid); - if (getuid() != uid) - fatal("setuid failed"); + ret = setgid(getgid()); + if (ret != 0) { + fatal("setgid failed, %m"); + } + ret = setuid(uid); + if (ret != 0 || getuid() != uid) { + fatal("setuid failed, %m"); + } charshunt(0, 1, record_file); exit(0); } -- 2.39.2