[PATCH] Prevent unintentionally running as root

Robert Helling helling at atdotde.de
Fri Mar 25 03:44:48 PDT 2016


Hi,

> On 25.03.2016, at 11: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.
> 
> lubomir
> --

Here is an updated patch.

Best
Robert
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 0001-Prevent-unintentionally-running-as-root.txt
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20160325/6bf4064a/attachment.txt>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20160325/6bf4064a/attachment.sig>


More information about the subsurface mailing list