Welcome to the most active Linux Forum on the web.
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, 12: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, 01:25 PM   #2
Registered: Jan 2010
Location: Lancashire
Distribution: Slackware Stable
Posts: 553

Rep: Reputation: 116Reputation: 116
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 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 > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:20 AM.

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