96 reputation
239
bio website
location
age
visits member for 2 years, 3 months
seen Sep 25 '12 at 15:43

Sep
10
comment Execute shell script from php, as root user?
I looked at the path i added to the sudoers file and realized the path i wrote was to the add_user.sh script, which isn't being used now. I'm just calling sudo ls from index.php as i said earlier, so add_user.sh has nothing to do with it. I tried changing the path to /var/www/index.php instead but that didn't work either. When i think about it though, the script isn't really being run from the index.php file itself, right? Apache/PHP reads the file and then procceses the contents, right? Maybe need to add permission to some apache/php path in the sudoers file?
Sep
10
comment Execute shell script from php, as root user?
No worries! Oh, i'll post it in the question in the future. That's a good point. I tried moving it to the absolute bottom, then restarted apache in case it was needed, but it still doesn't work. Log looks the same as before. I also checked /etc/sudoers.d/ to see if something might be overwriting it, but it was empty. Is it possible it might be overwritten from somewhere else?
Sep
9
comment Execute shell script from php, as root user?
And as for what i expect to happen, is for it to echo out index.php index.php on the page. That's what happens if i remove sudo before the ls command. I don't need sudo to list a directory, i just use it to see if sudo works. I don't know why it echos index.php two times, as there is only one index.php file, but that's irrelevant.
Sep
9
comment Execute shell script from php, as root user?
"Did you check the log like i suggested?" If you read my previous commend you'll see that i quoted an important piece of the log file. The command "sudo ls" didn't work, for the same reason the adduser.sh script didn't work. At the absolute top of the PHP file i run this line: echo system('sudo ls'); die(); to which i get a completely blank respond. So, no respond in PHP. All i know is what's written in the log, and i don't know how to fix that. This is exactly what's written to auth.log on every page load: pastebin.com/raw.php?i=wfn4htxS
Sep
9
comment Execute shell script from php, as root user?
Also, if it matters, permissions for the make_account.sh file is -rwxrwxrwx which probably isn't very smart, but at least that confirms the problem isn't related to file permissions, right?
Sep
9
comment Execute shell script from php, as root user?
My bad, heh. I'm new to Linux, so i wasn't even aware that log existed, although i assumed there was a log somewhere. The log says auth could not identify password for [www-data] so i'm pretty sure it's sudo failing. I even tried doing system("sudo ls"); from PHP just to see if sudo worked. It didn't. Anyways, i added the code to /etc/sudoers as you advised but it still doesn't seem to be working. I have triple checked the path, so that's not the problem. If it helps, here is my sudoers file: pastebin.com/FNhdaJzL
Sep
8
comment Execute shell script from php, as root user?
Sorry, i didn't mean to sound ignorant, i know security is very important but it just wasn't what i was looking for. I do very much appreciate your help and will keep your suggestions in mind. I already have a bash script that creates a user, but the last code block sounds very interesting. I've tried to add www-data to the sudoers list, but it didn't seem to work (as written in the question), but i will try the code you suggested.
Sep
8
comment Execute shell script from php, as root user?
The problem is not about making the data secure by sanitizing/validating it before using it. I'm not concerned at all about the security since only i will be using it. Either way i still sanitize and validate the data before passing it on to the shell script, so that should work fine. The problem is that i don't know to execute a shell script with root access (without entering password) from a user that has no root access. You mentioned a "wrapper script", can you explain a bit more about that?
Sep
7
revised Automatically start named pipe reader on startup?
deleted 2 characters in body
Sep
7
asked Automatically start named pipe reader on startup?
Sep
7
comment Execute shell script from php, as root user?
I've been fibbling with named pipes for some time now and i really can't figure out how to actually use it for my purpose. I understand the principle of named pipes, but can't apply it to my needs. This is how i imagine it would work: Send data (in my case username and password) to named pipe from PHP, no root needed. I have another process running (with root access) which constantly reads from the pipe, and then executes the script with root access. Am i on the right track? If so, my question is, how do i create that other process that runs with root access and constantly reads from the pipe?
Sep
5
comment Execute shell script from php, as root user?
Thanks, i'll take a look at that!
Sep
5
comment Execute shell script from php, as root user?
I already knew it was a security breach, but since i'm just experimenting on a development server to learn i was going to let it pass. But fair enough, i'll do it the way it should be done. Your idea sounds fine except i need to create the user instantly, it has to be done as soon the PHP script goes off. Any ideas how to solve that? Thank you btw!
Sep
5
accepted Execute shell script from php, as root user?
Sep
4
asked Execute shell script from php, as root user?
Sep
4
accepted Can't SSH/FTP into new user account in Ubuntu?
Sep
4
asked Can't SSH/FTP into new user account in Ubuntu?
Sep
4
accepted Apache not responding on port 80 after forwarding port?
Sep
2
comment Home folder structure in Ubuntu 12.04.1?
Thanks, but i'm pretty sure i managed to screw it up completely now. Can't even access it through SSH anymore, i just get a timeout. Wasn't able to remove the old user account either. I'll mark your answer as accepted though, and just reinstall ubuntu tomorrow. I didn't have anything important on it, i'm just experimenting with it. Thanks though!
Sep
2
accepted Home folder structure in Ubuntu 12.04.1?