From owner-svn-src-head@freebsd.org Tue Sep 1 06:32:03 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 71F949C7ED1; Tue, 1 Sep 2015 06:32:03 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 63357991; Tue, 1 Sep 2015 06:32:03 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t816W38B039083; Tue, 1 Sep 2015 06:32:03 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t816W3PK039082; Tue, 1 Sep 2015 06:32:03 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201509010632.t816W3PK039082@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Tue, 1 Sep 2015 06:32:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r287346 - head/usr.sbin/trpt X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 06:32:03 -0000 Author: delphij Date: Tue Sep 1 06:32:02 2015 New Revision: 287346 URL: https://svnweb.freebsd.org/changeset/base/287346 Log: Check and fail if drop of privileges failed. MFC after: 2 weeks Modified: head/usr.sbin/trpt/trpt.c Modified: head/usr.sbin/trpt/trpt.c ============================================================================== --- head/usr.sbin/trpt/trpt.c Tue Sep 1 06:28:16 2015 (r287345) +++ head/usr.sbin/trpt/trpt.c Tue Sep 1 06:32:02 2015 (r287346) @@ -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);