Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > before awakeFromNib: ?

before awakeFromNib: ?
Thread Tools
Forum Regular
Join Date: May 2001
Location: France
Status: Offline
Reply With Quote
Jan 31, 2003, 11:13 AM
 
hi !

my app currently has the suid bit set to access root privilege.

in one one my Controller awakeFromNib method, i instantiate an object which needs to be with root priv. (RootController)

as stated clearly in Cocoa doc on apple website, the order in which nib objects are instantiated (thus their awakeFromNib: method is called) is random.

Here is my problem :
to be sure to have root right when RootController is inited, in *ALL* my controllers awakeFromNib method, i save the effective uid (in case this controller is the first one inited) :
effective = geteuid();
then temporary loose them :
seteuid(getuid()); //temporary loose root rights

//make some init here

then at the end of the awakeFromNib, i restitute root right :
seteuid(effective); // take root rights

just to be sure that if next awakeFromNib method is the one of RootController, i have root priv...

isn't that crazy ? is there a more common entry point to ALL nib's objects? a method called before all awakeFromNib ?

like a main()
(as i understand, main.m must not be changed in cocoa apps)

please help !
CarraFix, the traffic shaper for OS X !

Enjoy The [CFx] Community !
http://www.carrafix.com
     
Professional Poster
Join Date: Apr 2001
Location: Long Beach, CA
Status: Offline
Reply With Quote
Jan 31, 2003, 11:57 AM
 
Have you tried modifying main()? Try it. See what happens.

ACSA 10.4/10.3, ACTC 10.3, ACHDS 10.3
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Jan 31, 2003, 05:34 PM
 
It's probably not wise to give your app the setuid bit... Instead you should factor out your privileged code into a small tool and call that.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 02:08 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2