[Gambas-user] How to authenticate and switch to root userfromwithin gambas application?

Timothy Marshal-Nichols timothy.marshal-nichols at ...247...
Thu Oct 5 09:07:40 CEST 2006


> -----Original Message-----
> From: gambas-user-bounces at lists.sourceforge.net [mailto:gambas-user-
> bounces at lists.sourceforge.net] On Behalf Of Jose J. Rodriguez
> Sent: 04 October 2006 14:43
> To: mailing list for gambas users
> Subject: Re: [Gambas-user] How to authenticate and switch to root
> userfromwithin gambas application?
> 
> On 10/4/06, Timothy Marshal-Nichols
> <timothy.marshal-nichols at ...247...> wrote:
> >
> > Hello
> >
> > Not sure how you can switch to being root user when the application
is
> > running.
> 
> I need to check the source code of "su" I guess, see how it pulls off
> this bit of magic.
> 
> > But you could test if the current user is root and provide a
> > warning message and also disable option only available to root:
> >
> >         ' root user always has an Id of 0
> >         IF User.Id = 0 THEN
> >                 ' Disable options that can only be run by root
> >                 Message.Info("Not root user - you would have a
better
> > message")
> >         END IF
> >
> 
> That's mostly what I do, except I check for username "root". Is it
> safer to check for id = 0 because the name of root can be changed? I
> never thought of that.


You can change the name of the root user. Also some Linux distributions,
especially those that try to emulate Window look and feel, sometime call
the root user something like 'administrator' or 'admin'.

Of course there is an error in the above code fragment. It should be:

  IF User.Id <> 0 THEN

to take action if the current user id is not the root user id.

> 
> > In KDE you can create desktop shortcuts and menu items that will run
an
> > application as root and prompt for the root password.
> >
> 
> Unfortunately, that's a KDE-specific .desktop file setting. It doesn't
> work in XFCE.
> 
> Regards,
> Joe1962
> 


Thanks

8-) Timothy Marshal-Nichols
<mailto: timothy.marshal-nichols at ...247...>







More information about the User mailing list