From mboxrd@z Thu Jan 1 00:00:00 1970 From: Richard Palethorpe Date: Tue, 15 May 2018 12:55:00 +0200 Subject: [LTP] [PATCH] read_all: Drop privileges In-Reply-To: <20180515103042.GB7220@rei> References: <20180515095118.26282-1-rpalethorpe@suse.com> <20180515103042.GB7220@rei> Message-ID: <87bmdhyyrf.fsf@rpws.prws.suse.cz> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: ltp@lists.linux.it Hello, Cyril Hrubis writes: > Hi! >> +static void maybe_drop_privs(void) >> +{ >> + struct passwd *nobody; >> + >> + if (!drop_privs) >> + return; >> + >> + nobody = SAFE_GETPWNAM("nobody"); >> + >> + TEST(setgid(nobody->pw_gid)); >> + if (TEST_RETURN < 0 && TEST_ERRNO != EPERM) >> + tst_res(TBROK | TTERRNO, "Failed to use nobody gid"); > ^ > Shouldn't this be tst_brk()? > >> + TEST(setuid(nobody->pw_uid)); >> + if (TEST_RETURN < 0 && TEST_ERRNO != EPERM) >> + tst_res(TBROK | TTERRNO, "Failed to use nobody uid"); > ^ > And here as well? > > Otherwise it looks fine. Well spotted, yes it should. -- Thank you, Richard.