2 * Wrapper to run the svnserve process setgid.
3 * The idea is to avoid the problem that some interpreters like bash
4 * invoked by svnserve in hook scripts will reset the effective gid to
5 * the real gid, nuking the effect of an ordinary setgid svnserve binary.
6 * Sadly, to set the real gid portably, you need to be root, if only
8 * Also smashes the environment to something known, so that games
9 * can't be played to try to break the security of the hook scripts,
10 * by setting IFS, PATH, and similar means.
13 * Written by Perry Metzger, and placed into the public domain.
19 #define REAL_PATH "/usr/bin/svnserve.real"
21 char *newenv
[] = { "PATH=/bin:/usr/bin", "SHELL=/bin/sh", NULL
};
24 main(int argc
, char **argv
)
26 if (setgid(getegid()) == -1) {
27 perror("setgid(getegid())");
31 if (seteuid(getuid()) == -1) {
32 perror("seteuid(getuid())");
36 execve(REAL_PATH
, argv
, newenv
);
37 perror("attempting to exec " REAL_PATH
" failed");