LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-27-2007, 04:34 AM   #1
rajorshi
Member
 
Registered: Jun 2003
Location: Calcutta, India
Distribution: Slackware 9.0
Posts: 34

Rep: Reputation: 15
Smile su equivalent


Hi,

I want to write a program that should be run only as root. However, I don't want it to exit if the program sees that its uid != 0.

This is similar to running things under "kdesu" for example. My (console) program should determine if its not running as root. Then it prompts the user for the root password, and finally elevates to root permissions.

I'm confused regarding how to do this. Essentially I want to do "su -c my_algorithm" in my program. My basic question is:

1) What is the accepted way to ask the user for the root password? (getpass() ?)

2) Now that I have the password, how to I verify that its the proper password?

3) How do I change my permissions to root? (I can't simply do a setuid(0) right?)

Thanks in advance :-)
~Raj
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
equivalent to urpmi spx2 Linux - Newbie 10 01-19-2006 04:28 AM
MS Money or equivalent Paulsuk Linux - Software 5 12-15-2005 11:52 AM
Equivalent to setDefaultJava? JordanH Red Hat 0 09-15-2005 11:50 AM
frontpage equivalent redfedora88 Linux - Software 8 08-30-2005 05:59 PM
equivalent to c? codename000 Programming 3 04-03-2003 11:08 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration