LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 11-16-2010, 12:01 PM   #1
HarryBoy
Member
 
Registered: Apr 2008
Distribution: MontaVista Linux Version 4.0.1, Professional Edition
Posts: 215

Rep: Reputation: 16
run my cgi as root using setreuid failing


I'm calling a cgi-script on an apache webserver. The script needs to create a textfile and write certain values into it.

When I do:
Code:
static const std::string outputFile( "/flash/myfile.ini" );
std::fstream fileStr( outputFile.c_str(), ( std::fstream::out | std::fstream::trunc ) );

if( !fileStr.is_open() )
{
	throw std::runtime_error( "Failed to open config file." );
}
The runtime error is always thrown.

So I wish to run this cgi as root by doing this:
Code:
if( 0 != ::setreuid(0, -1) )
{
	throw std::runtime_error( "Failed to set root user." );
}
But this also fails??

What is going wrong with setreuid??
 
Old 11-16-2010, 01:25 PM   #2
devnull10
Member
 
Registered: Jan 2010
Location: Lancashire
Distribution: Slackware Stable
Posts: 572

Rep: Reputation: 120Reputation: 120
What user is the cgi script running as, what groups is that user a member of and what are the permissions on the directory into which you are writing the file, and also on the file itself.
 
  


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
failing to run svnserve as a service wslyhbb Linux - Server 6 06-16-2007 08:14 PM
Failing to run aol messenger on Debian Yahweee Debian 1 12-14-2006 04:02 AM
CGI install by CPAN keeps failing coyos Linux - Newbie 1 09-29-2006 03:37 AM
Java Failing to Run... javaman21011 Red Hat 1 03-10-2005 02:27 PM
Trying to run CGI - please help!! jacksmash Linux - Newbie 1 11-19-2003 11:28 PM

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

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