Asking for password, and network settings file.

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

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.

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

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.

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

Cheers!

Garry