Hi there,
I am just starting out some php programming, with some c experience.
I am attempting to build a web interface for some common unix administration tasks, but while apache runs as user 'nobody', the commands can't get executed due to lack of root privilege.
The only way I could get it to work is by dumping the dynamic command into a file, logging on as root to the console and executing it.
I do have an idea, but it is a little far fetched. One question is, how do I output a string to a file so that the filename will never be the same. (ie. increment ++ the filename, so php will recognize the last filename output?) eg. file00001, file00002
If someone has some ideas, please help!
knight
exec as root
Moderator: General Moderators
For Progressive filenames
One quick way to get progressive file names that aren't the same could be to use date and time the file was created for the name. The only hitch I can see is if two files get created at the exact same second.
Another way is to use a file that simply stores a number, for example call it "counter_file.cnt". When you need a file name, read the "counter_file.cnt" to a variable, use that as the file name, then increment that number and write over "counter_file.cnt" with the new number in it.
Either way should be pretty simple to implement.
Hope that helps.
Another way is to use a file that simply stores a number, for example call it "counter_file.cnt". When you need a file name, read the "counter_file.cnt" to a variable, use that as the file name, then increment that number and write over "counter_file.cnt" with the new number in it.
Either way should be pretty simple to implement.
Hope that helps.
-
dark_knight
- Forum Newbie
- Posts: 2
- Joined: Wed Jul 10, 2002 9:06 pm
exec as root
Hi there
As I see it there are two ways for you to solve the exec problem.
You can put the commands you need to run as root into a shell script. When you have this working as it should (as user root) set it setuid root. This means that the program will run as root even if it's another user that starts it. Search google or man pages (man chmod/chown) for more info about this.
Another way is to run you program / script with sudo. This means actually that you run the program through sudo, which execute it's as root. Search google or check a man page (man sudo) for more information.
I hope this helpes.
As I see it there are two ways for you to solve the exec problem.
You can put the commands you need to run as root into a shell script. When you have this working as it should (as user root) set it setuid root. This means that the program will run as root even if it's another user that starts it. Search google or man pages (man chmod/chown) for more info about this.
Another way is to run you program / script with sudo. This means actually that you run the program through sudo, which execute it's as root. Search google or check a man page (man sudo) for more information.
I hope this helpes.