Set-uid root program that runs a program as the user “restrict” (follow-up)
You should really check the return value of getpwnam(). If, for whatever reason, the user "restrict" is not found, your program will crash. I'm not sure whether a null dereference can be exploited (I think not), but it's a "bad thing" anyways.

As already mentioned, giving a descriptive error message when execv fails is a good idea, too. In fact, do this on every possible error; no need for extra verbosity where you don't exepect an error -- in this case a perror with the failed function name should be enough.

You probably don't want the user name configurable in any way for security reasons, but just to make it easier to "configure" at compile time, I'd suggest to #define it.

All in all somehow like this:

#define _GNU_SOURCE
#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include &lt;errno.h&gt;
#include &lt;sys/types.h&gt;
#include &lt;unistd.h&gt;
#include &lt;pwd.h&gt;
#include &lt;grp.h&gt;

#define USERNAME "restrict"

int main (int argc, char **argv)
{
    if (argc &lt; 2) return 1;
    struct passwd *r = getpwnam(USERNAME);
    if (!r)
    {
        perror("User " USERNAME " not found");
        return 1;
    }

    gid_t supp[] = {};
    if (setgroups(0, supp))
    {
        perror("setgroups");
        return 1;
    }

    if (setgid(r-&gt;pw_gid))
    {
        perror("setgid");
        return 1;
    }

    if (setuid(r-&gt;pw_uid))
    {
        perror("setuid");
        return 1;
    }

    char *env[] = {NULL};
    execvpe(argv[1], &amp;argv[1], env);
    /* the following is only reached on error */

    fprintf(stderr, "Cannot execute `%s': %s\n", argv[1],
            strerror(errno));        
    return 1;
}