setgid first, setuid second
authorStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Fri, 7 Jan 2011 20:58:05 +0000 (20:58 +0000)
committerJens Axboe <jaxboe@fusionio.com>
Sat, 8 Jan 2011 19:29:12 +0000 (20:29 +0100)
commitdfc6e7513c82d83491e90b8583fb52e301053d1b
tree8f9a2fa8fdd207def87260b97ac69723e1c278be
parent5b42a488b1e3be03ecec9305affbbabaa2f2134e
setgid first, setuid second

Setting a new effective gid requires privileges.  We must set the gid
while we potentially still have superuser privileges.  Otherwise
setgid(2) fails because we've already changed to an unprivileged uid.

Here is a test case:
[global]
rw=read
directory=tmp
size=512m
buffered=0

[file1]
uid=1000
gid=1000

Without this patch fio will fail when invoked by root.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
fio.c