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

Bruce Steers bsteers4 at gmail.com
Wed Aug 25 11:50:35 CEST 2021


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/77bec0de/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Desktop2.class
Type: application/x-java
Size: 3294 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20210825/77bec0de/attachment.bin>


More information about the User mailing list