Hi,
I am running my box on Linux FC4, and using Tomcat as my Web Server.
There is a user called utomcat who own the files/directories related to Tomcat and who own its process.
I am writing a binary file using C language and gcc compiler to allow web user (utomcat) to call (execute) a binary which can only be executed by root, those binaries are:
/home/vpopmail/bin/vadduser
/home/vpopmail/bin/vuserinfo
My problem is in the output that those binaries offer as a response to the acton they did.
I used "popen" in my program as following:
Code:
//### C Code ###
#include "stdio.h"
int main (int args, char *argv[]) {
int result = 1;
char *command = "/home/vpopmail/bin/vuserinfo user1@domain.com";
FILE *output = popen(command , "r");
while(result != EOF) printf("%c" , result = fgetc(output));
pclose(output);
};
//##############
The program compiled with no errors nor warnings and I named it "uinfo.exec", and chmod to 755.
I have set the "setuid" and "setgid" flags to the file "uinfo.exec" which is owned by root:root .
When I run the binary as root user , I get the output as supposed on the console terminal and every thing is fine
But
when su-ing to another user and running it (utomcat user for example) I see no output at all.
I need the output be visible to any user who call my binary.
Any solutions?
Thanks