![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Aug 2005
Posts: 66
Rep Power: 0
![]() |
changing a user id.
Hi all,
I was wondering if anybody out there could tell me how to change a user id. I'm writing a c wrapper for a java program. Since java does not seem to have any way to do a change uid, I figured I'd write a c wrapper to call the program and use c to do a change uid. However, I don't know how....I just heard that it could be done. Thanks for any and all help ![]()
__________________
Isn't that just the way life goes? If it's worth doing, it's NP-Hard. Todd Wareham - Memorial University of Newfoundland |
|
|
|
|
|
#2 |
|
Expert Programmer
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4
![]() |
and user id is ???
|
|
|
|
|
|
#3 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
So you are root? I'm pretty sure it can't be done when you're not root. I'm not sure if you can when you are.
@OpenLoop: it's a *nix thing, the system can tell who is logged on by the userid (often shortened to UID, like Process ID is shortened to PID).
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." -- Socrates |
|
|
|
|
|
#4 |
|
Programmer
Join Date: Aug 2005
Posts: 66
Rep Power: 0
![]() |
I could be root if it was required. Basically, the user would log in to a web interface and ask to do an operation. The web server is run by a different user (apache). So, before I get the server to call the operation, I wanted to change the user id to the logged in user and then change back to apache after it was complete.
However, should root be required, I do have a module that can run a process as root. So, I could get that process to run my c program which will change to the given uid and then change back.
__________________
Isn't that just the way life goes? If it's worth doing, it's NP-Hard. Todd Wareham - Memorial University of Newfoundland |
|
|
|
|
|
#5 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
http://www.hmug.org/man/2/setuid.php
Go down on that page, so you can read the "standards" section. Check your system's man pages on setuid though for more information.
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." -- Socrates |
|
|
|
|
|
#6 |
|
Programmer
Join Date: Aug 2005
Posts: 66
Rep Power: 0
![]() |
Cool, thanks. I'll play around with that and come back if I need further help. ^_^
__________________
Isn't that just the way life goes? If it's worth doing, it's NP-Hard. Todd Wareham - Memorial University of Newfoundland |
|
|
|
|
|
#7 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 4
![]() |
setuid() and setgid() are what you're looking for.
"setuid" programs require great care in coding to be secure. Since you didn't know what setuid was, I'd be inclined to think that you need to do a lot reading. setuid on net-exposed systems is a security risk. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|