LinuxQuestions.org
Visit Jeremy's Blog.
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-05-2002, 11:12 PM   #1
whepin
Member
 
Registered: Dec 2001
Location: thunder bay, on, Canada
Distribution: Windows vista & Ubuntu
Posts: 113

Rep: Reputation: 15
How to get root privilege in program using c?


In my program,I want to write sth in system dirs,but i donot have enough privilege.
I think obtainning root privilege maybe the only way.But how to do?
Thanks.
 
Old 04-06-2002, 05:27 AM   #2
llama_meme
Member
 
Registered: Nov 2001
Location: London, England
Distribution: Gentoo, FreeBSD
Posts: 590

Rep: Reputation: 30
for the program to have root privelages it must either be executed as root or be setuid root. being setuid root means that the program binary is owned by root, and executes as root even when a normal user runs it. to make and executable setuid root do this:

chown root executable
chmod a+xs executable

obviously you have to do those commands as root. i'm not sure if that's the only way of getting root permissions for your program, but it's pretty standard for programs that need root privelages but want to be run by ordinary users.
 
  


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
How to execute root-privilege programs in KDE autostart? rylan76 Linux - Software 3 07-31-2005 04:40 AM
how to get root privilege in a script jpan Linux - General 5 01-07-2005 02:46 PM
Insufficient Privilege instead of Root Password Request buckberger Linux - Security 3 12-25-2004 08:00 PM
Temp root privilege in program? ZX_SA Programming 1 07-22-2004 08:14 AM
Why root has no privilege to access some directories ymei Linux - General 4 10-08-2003 08:14 AM

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

All times are GMT -5. The time now is 09:57 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