Back out if Quake II is run as root or if eUID != rUID

This is a sanity check to prevent stupid users from running Quake II as
root or as a setuid binary. Quake II is such a mess that running it as
root or setuid is just reckless.
This commit is contained in:
Yamagi Burmeister 2012-06-02 16:33:12 +02:00
parent deaeac42b7
commit f28e005e1e

View file

@ -45,9 +45,28 @@ main ( int argc, char **argv )
/* register signal handler */ /* register signal handler */
registerHandler(); registerHandler();
/* go back to real user for config loads */ /* Prevent running Quake II as root. Only very mad
saved_euid = geteuid(); minded or stupid people even think about it. :) */
seteuid( getuid() ); if (getuid() == 0)
{
printf("Quake II shouldn't be run as root! Backing out to save your ass. If\n");
printf("you really know what you're doing, edit src/unix/main.c and remove\n");
printf("this check. But don't complain if Quake II eats your dog afterwards!\n");
return 1;
}
/* Enforce the real UID to
prevent setuid crap */
if (getuid() != geteuid())
{
printf("The effective UID is not the real UID! Your binary is probably marked\n");
printf("'setuid'. That is not good idea, please fix it :) If you really know\n");
printf("what you're doin edit src/unix/main.c and remove this check. Don't\n");
printf("complain if Quake II eats your dog afterwards!\n");
return 1;
}
/* enforce C locale */ /* enforce C locale */
setenv("LC_ALL", "C", 1); setenv("LC_ALL", "C", 1);