[PATCH] Prevent unintentionally running as root

Lubomir I. Ivanov neolit123 at gmail.com
Fri Mar 25 03:31:46 PDT 2016


hello,

On 25 March 2016 at 10:27, Robert C. Helling <helling at atdotde.de> wrote:
> +       if ((getegid() == 0) && !verbose) {
> +               printf("You are running Subsurface as root. This is not recommended.\n");
> +               printf("If you insist to do so, run with option -v.\n");
> +               exit(0);
> +       }

there is no WINAPI (Windows) wrapper for the POSIX function getegid(),
as the SIDs on Windows work slightly differently that the Unix GIDs.

i'd suggest the following function in all the platform specific files
(linux.c, windows.c...):
subsurface_user_is_root()

where getegid() == 0 is used on Unix OSes and possibly IsUserAnAdmin()
on Windows.
i can send a patch later for that.

lubomir
--


More information about the subsurface mailing list