Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 29th, 2006, 2:27 PM   #1
MegaArcon
Programmer
 
MegaArcon's Avatar
 
Join Date: Aug 2005
Posts: 66
Rep Power: 0 MegaArcon is an unknown quantity at this point
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
MegaArcon is offline   Reply With Quote
Old Mar 29th, 2006, 2:32 PM   #2
OpenLoop
Expert Programmer
 
OpenLoop's Avatar
 
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4 OpenLoop is on a distinguished road
and user id is ???
OpenLoop is offline   Reply With Quote
Old Mar 29th, 2006, 2:54 PM   #3
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
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
nnxion is offline   Reply With Quote
Old Mar 29th, 2006, 3:15 PM   #4
MegaArcon
Programmer
 
MegaArcon's Avatar
 
Join Date: Aug 2005
Posts: 66
Rep Power: 0 MegaArcon is an unknown quantity at this point
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
MegaArcon is offline   Reply With Quote
Old Mar 29th, 2006, 4:29 PM   #5
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
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
nnxion is offline   Reply With Quote
Old Mar 30th, 2006, 7:49 AM   #6
MegaArcon
Programmer
 
MegaArcon's Avatar
 
Join Date: Aug 2005
Posts: 66
Rep Power: 0 MegaArcon is an unknown quantity at this point
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
MegaArcon is offline   Reply With Quote
Old Mar 30th, 2006, 11:15 AM   #7
jim mcnamara
Hobbyist Programmer
 
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 4 jim mcnamara is on a distinguished road
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.
jim mcnamara is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting 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
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:17 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC