LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 05-23-2005, 09:24 AM   #1
Shekarbabu
LQ Newbie
 
Registered: May 2005
Location: Bangalore
Posts: 3

Rep: Reputation: 0
Get root access thro program


Hi,
I want to write a simple C program which works similar to su command in Linux, i.e. my program should prompt user to enter root password and should get him the root access if he enters root password correctly.
 
Old 05-23-2005, 10:48 AM   #2
TruckStuff
Member
 
Registered: Apr 2002
Posts: 498

Rep: Reputation: 30
whats wrong with sudo?
 
Old 05-24-2005, 04:36 AM   #3
Shekarbabu
LQ Newbie
 
Registered: May 2005
Location: Bangalore
Posts: 3

Original Poster
Rep: Reputation: 0
Actually before executing my application I need to explicitly ask user to enter root password, I don’t know the procedure to compare the password entered by user with the actual root password, also if the comparison is success I don’t know how to grant the root privileges to that user.
I think all systems use shadowed passwords, which means the root password is encrypted with a one-way algorithm and stored in the password file. Is there any system call or API through which we can pass the password as argument on success comparison grant the root privilege?
 
Old 05-24-2005, 05:31 AM   #4
Poetics
Senior Member
 
Registered: Jun 2003
Location: California
Distribution: Slackware
Posts: 1,181

Rep: Reputation: 49
Basically you're doing an "su -" in the middle of a program execution then?
 
Old 05-25-2005, 02:29 AM   #5
Shekarbabu
LQ Newbie
 
Registered: May 2005
Location: Bangalore
Posts: 3

Original Poster
Rep: Reputation: 0
If i do su in my program i.e system("su"); i think after typing password it wont execute the next line of the program after su command until i do exit from the new shell.
Eg:
main()
{
system("su");
printf("after su");
}
out put:
password:
[root@localhost shekar]#exit
after su
[shekar@localhost shekar]$

Note: if i don't do exit above then my program will never continue executing.
I want my program to run continuously without any interrupt. Here before exit i am root i can do what ever i want, but after exit i cant. I want to know the technique to compare the shadowed password and grant the root privileges to user.
 
Old 06-08-2005, 05:09 AM   #6
Nathanael
Member
 
Registered: May 2004
Location: Karlsruhe, Germany
Distribution: debian, gentoo, os x (darwin), ubuntu
Posts: 940

Rep: Reputation: 33
Quote:
I want to know the technique to compare the shadowed password and grant the root privileges to user.
md5...?
that is to compare the shadowed password

but i think you will make your sys even more vulnerable with that prog... !
but you could write it to use 'su' and let su execute a 2nd part of your app (splitting your c app into 2 parts, one run by the user, the other called by 'su -c <path-to-app>'
adding commandline params will give you the option of continuing whatever has been started - or by saving stuff to a temporary file!)

and whatever you do, test it well - let others test it - make sure every user entry is exactly what you want... and make sure you have no space for somebody using your app in a negative way... make it secure

Last edited by Nathanael; 06-08-2005 at 05:16 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Internet thro another computer super_teds Linux - Networking 1 11-30-2005 09:09 AM
C++ program to access mysql ? SQLAPI++ ?? Bluesuperman Programming 3 06-30-2005 09:56 PM
Windows can't open files transferred thro' ProFTPd zatka Linux - Networking 3 02-08-2005 08:35 AM
How to run the hacking programs thro remotely... yuva_mca Linux - Security 1 09-25-2004 01:49 PM
how to create ppp server in RH 7.2 as small ISP thro serial port pentium5 Linux - General 5 07-06-2002 07:35 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 08:06 PM.

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