Merge branch 'master' of ssh://router/data/git/fio
[fio.git] / fio.c
diff --git a/fio.c b/fio.c
index 93482f5294ed55c245e25a0e98f8151fe7354ced..280dbe6660c1513dedebb6a551f1258a8bb162b1 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -1069,14 +1069,18 @@ static void *thread_main(void *data)
         */
        fio_mutex_remove(td->mutex);
 
-       if (td->o.uid != -1U && setuid(td->o.uid)) {
-               td_verror(td, errno, "setuid");
-               goto err;
-       }
+       /*
+        * A new gid requires privilege, so we need to do this before setting
+        * the uid.
+        */
        if (td->o.gid != -1U && setgid(td->o.gid)) {
                td_verror(td, errno, "setgid");
                goto err;
        }
+       if (td->o.uid != -1U && setuid(td->o.uid)) {
+               td_verror(td, errno, "setuid");
+               goto err;
+       }
 
        /*
         * May alter parameters that init_io_u() will use, so we need to