Skip navigation.
Home
The QNX Community Portal

View topic - Asking for password, and network settings file.

Asking for password, and network settings file.

Isn't the name clear?

Asking for password, and network settings file.

Postby thegman » Wed Oct 15, 2003 8:39 pm

Hello,
Is there a standard way to ask for the root password like when you launch Software Installer as a normal user, and then assume root priveleges from that? If there is not, does anyone have any tips on how to do it? I am writing a wee utility that requires root access to work, but it would be nice if any user could launch it from Photon and then give the root password if they had it.

Another thing, if I change the /etc/net.cfg file, how can I tell QNX to use the updated settings, bar restarting the machine?

Thanks a lot

Garry
thegman
Senior Member
 
Posts: 439
Joined: Sun Jun 15, 2003 8:10 pm

Postby cdm » Thu Oct 16, 2003 4:11 am

Simple one first, it's netmanager -rto update the settings from /etc/net.cfg. There are other options as well (like writing /etc/net.cfg based on current settings, etc). Check the help page or run "use netmanager".

As for the root access, it's tricky. You have to have the binary setuid root and you have to check the password they enter against the value in the password/shadow file. getpwent() and friends are the API you need to check.
cdm
QNX Master
 
Posts: 789
Joined: Fri Jul 05, 2002 9:38 am

Postby thegman » Mon Oct 20, 2003 5:57 pm

Thanks for the first one, exactly what I'm after.

I need a little more help on the second, however. Once I have the password, and have confirmed it's correct, how do I give the process root priveleges? Basically I'm making a little util so I can learn more about C/Photon and the idea is that the user can pick network settings for home/work etc. and apply them. To copy in the new settings to /etc, I'll need root priveleges, I'm guessing there is a C function to do this?

Cheers

Garry
thegman
Senior Member
 
Posts: 439
Joined: Sun Jun 15, 2003 8:10 pm

Postby noc » Mon Oct 20, 2003 6:09 pm

My guess what cdm meant was
you setuid root your program so it has the root privillage! you add the logic in your program:
you do a "getuid()", if it returns 0, you go ahead do the work. if returns non 0, you prompt for the root password, and verify it ( getpwent() etc), if it is correct, you go ahead do the work, otherwise, gives permission denied and quit.
noc
Senior Member
 
Posts: 1634
Joined: Sat Jul 06, 2002 4:34 am

Postby thegman » Mon Oct 20, 2003 11:39 pm

Doh! I just re-read it, and makes sense now!

Cheers!

Garry
thegman
Senior Member
 
Posts: 439
Joined: Sun Jun 15, 2003 8:10 pm


Return to GUI Programming

Who is online

Users browsing this forum: No registered users and 1 guest