diff options
author | delphij <delphij@FreeBSD.org> | 2015-09-01 06:32:02 +0000 |
---|---|---|
committer | delphij <delphij@FreeBSD.org> | 2015-09-01 06:32:02 +0000 |
commit | b440f05ba475f60fec7155b56d8c85a8302e96a3 (patch) | |
tree | ccb5bac88aba125d09bd5f7e3af65663c3c50c9e /usr.sbin/trpt | |
parent | 061b55cf1969e8b2c2bca1d8c94923962d4c4283 (diff) | |
download | FreeBSD-src-b440f05ba475f60fec7155b56d8c85a8302e96a3.zip FreeBSD-src-b440f05ba475f60fec7155b56d8c85a8302e96a3.tar.gz |
Check and fail if drop of privileges failed.
MFC after: 2 weeks
Diffstat (limited to 'usr.sbin/trpt')
-rw-r--r-- | usr.sbin/trpt/trpt.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/usr.sbin/trpt/trpt.c b/usr.sbin/trpt/trpt.c index fbdc4de..d85d41d 100644 --- a/usr.sbin/trpt/trpt.c +++ b/usr.sbin/trpt/trpt.c @@ -148,7 +148,8 @@ main(int argc, char **argv) * Discard setgid privileges if not the running kernel so that * bad guys can't print interesting stuff from kernel memory. */ - setgid(getgid()); + if (setgid(getgid()) != 0) + err(1, "setgid"); } else syst = getbootfile(); @@ -157,7 +158,8 @@ main(int argc, char **argv) errx(1, "%s: no namelist", syst); if ((memf = open(core, O_RDONLY)) < 0) err(2, "%s", core); - setgid(getgid()); + if (setgid(getgid()) != 0) + err(1, "setgid"); if (kflag) errx(1, "can't do core files yet"); (void)klseek(memf, (off_t)nl[N_TCP_DEBX].n_value, L_SET); |