Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linux/Apache/C Language/System call - SetUserId problem

Status
Not open for further replies.

Glomet

Programmer
Nov 23, 2005
1
0
0
IT
Hello.

Years ago I used to run some system-dependent procedures via a CGI interface, simply running them inside a system call. But with more recent systems it doesn't work the same way: now there are user concerning problems (I think it depends on Apache updates occurred in the last years). The same identical procedures that I used to run on older system doesn't work properly on newer. Do you have any idea?

IE:

[blue]#include <stdio.h>
#include <stdlib.h>
main (void) {
FILE *fp;
char st [16];
printf ("Content-type: text/html\n\n");
system ("echo \"Hello\" > /tmp/appo/cgiOutputFile");
fp = fopen ("/tmp/appo/cgiOutputFile", "r");
if (fp) {
fscanf (fp, "%s", st);
fclose (fp);
printf ("%s", st);
}
else
printf ("Error");
}[/blue]

The problem is about the user that is used to run such a call. If I wanted a particular user to be used as, I simply had to "chmod u+s" the CGI script, and it was run just like it was run from the user that owned the script.
But now it doesn't work anymore: any file directly created from behind the CGI script, after having chmoded +s the script, it is owned by the same user as that of the CGI script (as in the past :)), but any file indirectly created from the outside system called command, they are owned by nobody:users on a system or apache:apache on another system (this last is a Fedora Core 1), and not as "user" :-(.

Have I to reconfigure/recompile apache? Or do you have any other idea?

Please, help.

Regards
-- Umberto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top