
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#define GOGS_BIN "@l_prefix@/sbin/gogs"
#define GOGS_CMD "serv"

int main(int argn, char **argv)
{
    if (setuid(geteuid()) == -1) {
        perror("setuid");
        exit(1);
    }
    if (setgid(getegid()) == -1) {
        perror("setgid");
        exit(1);
    }
    int i;
    char **args = malloc(sizeof(char *) * (argn + 2));
    args[0] = GOGS_BIN;
    args[1] = GOGS_CMD;
    for (i = 1; i < argn; i++)
        args[i + 1] = argv[i];
    args[i + 1] = NULL;
    if (execv(args[0], args) == -1)
        abort();
    return 0;
}

