[Gambas-user] A modification to User.Name/User.Home

Bruce Steers bsteers4 at gmail.com
Wed Aug 25 12:02:35 CEST 2021

Hmm, this may be flawed because it requires sudo to be installed and sudo
may not be :(

I will think of a better way.


On Wed, 25 Aug 2021 at 10:50, Bruce Steers <bsteers4 at gmail.com> wrote:

> I propose this modification to Desktop.class that now exists in
> gb.gui.base.
> (See attached file)
> I have added a property to it called UseRoot As Boolean = True
> And i have also added 2 r/o properties
> Desktop.UserName  and Desktop.UserHome
> The purpose..
> If your application is run as root then User.Name is root and User.Home is
> roots home
> the additional UseRoot property is set to True by default and
> Desktop.UserName will return root
> If you set UseRoot = False then Desktop.UserName will return the standard
> user name not root.
> Using the Env vars this method can be applied to all the xdg functions
> involving directory names
> I think this is ideal as nobody ever wants to know the roots desktop
> folder in an app run as superuser do they?
> So i will also add a Desktop.GetDirectory(sName As String) that will also
> return info relevant to the UseRoot setting.
> I have often found an issue with a program i am running as root when i
> want the normal users name.
> What do you think of something like this Ben?
> Respects
> BruceS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20210825/b4c27319/attachment.htm>

More information about the User mailing list