[PATCH] Prevent unintentionally running as root
Lubomir I. Ivanov
neolit123 at gmail.com
Fri Mar 25 03:45:06 PDT 2016
On 25 March 2016 at 12:31, Lubomir I. Ivanov <neolit123 at gmail.com> wrote:
> 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.
>
hmm...on the other hand many users on Windows (me including) simply
run as an "Administrator" (root) all the time, so i don't think we
want to throw the error on Windows, as is.
for now, i can suggest a:
#ifndef Q_OS_WIN
if ((getegid() == 0) && !verbose) {
...
#endif
lubomir
--
More information about the subsurface
mailing list