GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sun Apr 20, 2014 11:31 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Detect gtk+ app ran by an administrator
PostPosted: Thu Aug 08, 2013 2:03 pm 
Offline
GTK+ Guru

Joined: Sun Apr 06, 2008 6:43 pm
Posts: 281
Location: Fortress of solitude
Is there a port way to detect if my gtk+ app is executed by user with administrative privilegies?

_________________
* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.


Top
 Profile  
 
 Post subject: Re: Detect gtk+ app ran by an administrator
PostPosted: Thu Aug 08, 2013 9:52 pm 
Offline
Familiar Face

Joined: Tue Aug 06, 2013 1:09 pm
Posts: 6
Why do you need to do that? To prevent the user shooting themself in the foot, or because the app performs some action which requires administrative privileges? The latter presumably needs some non-portable code anyway.

Different OSes have different privilege and user models. Different kinds of administrator can do different privileged operations even within the same OS. Sure, you could use glib's g_get_user_name() and a lookup table but that's half-assed, not really portable, and insecure too if you're trying to achieve any degree of security.

It might be better to use conditional compilation or its scripting equivalent, and write the test in detail for each different OS you might be running on.


Top
 Profile  
 
 Post subject: Re: Detect gtk+ app ran by an administrator
PostPosted: Fri Aug 09, 2013 2:27 pm 
Offline
GTK+ Guru

Joined: Sun Apr 06, 2008 6:43 pm
Posts: 281
Location: Fortress of solitude
Because I need to change some settings like /etc/lightdm/* files that only a root user can edit them.
comparing current user with "root" might solve my poblem, thanks

_________________
* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.


Top
 Profile  
 
 Post subject: Re: Detect gtk+ app ran by an administrator
PostPosted: Fri Aug 09, 2013 5:41 pm 
Offline

Joined: Tue Aug 06, 2013 5:42 pm
Posts: 3
Maybe bash script before ?
Like:
Code:
su -c

But this is for su if you use sudo, I don't know.

I found also http://www.nongnu.org/gksu/


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group