Register a domain and help support LQ
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 11-16-2010, 01:01 PM   #1
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:
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:
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, 02:25 PM   #2
Registered: Jan 2010
Location: Lancashire
Distribution: Slackware Stable
Posts: 547

Rep: Reputation: 115Reputation: 115
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.


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

All times are GMT -5. The time now is 11:32 PM.

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