All Questions
24 questions
1
vote
1
answer
428
views
smartest way to use config /etc/sudoers for www-data
I want to ask what is the best or smartest way to use /etc/sudoers for www-data if you need sometimes the exec or shell_exec function for cp, mv or start some python files. Is www-data ALL=(ALL) ...
0
votes
1
answer
664
views
Securely execute a shell script with sudo through a web interface [duplicate]
I am looking for a way to securely execute a shell script with sudo through a web interface. Security is the main concern here. I don’t want to provide my PHP file to access the sudo fully. What will ...
0
votes
1
answer
142
views
PHP Sudo permissions only works for 'ALL' commands when using exec()
I need my PHP code to run scripts as a different user with exec(), and so in the sudoers file I added: www-data ALL=(csgo) NOPASSWD: WWW_COMMANDS where WWW_COMMANDS is an alias list of the scripts i ...
0
votes
1
answer
446
views
sudo in php exec() return exit code 1
I want to run "sudo whoami" command in php script.
I have added next line into /etc/sudoers
apache ALL=(ALL) NOPASSWD:/usr/bin/whoami
and executed the script
$result = exec("sudo whoami", $...
6
votes
2
answers
2k
views
Reloading php-fpm after deploy via php-deployer without password
What I'm trying to achieve is, to reload php7.2-fpm service via php-deployer. According to php-deployer's documentation, it can be done like the code below:
task('reload:php-fpm', function () {
...
-1
votes
1
answer
829
views
Edit sudoers file to only allow specific commands
I need to run a cPanel script from the command line via PHP's exec function (other cPanel options are not viable). The command is roughly:
uapi --user=[user] Email suspend_incoming email=[user]%40[...
1
vote
1
answer
77
views
Bash script via php (apache2)
Bonsoir, I have a bash script that run normally on terminal but when I run it via php, it runs some commands(thoses that not have sudo).
This is my file sudoers where i give the rights to www-data :
#...
1
vote
0
answers
311
views
run commands with root privileges in php with url
I have simple PHP code like this:
<?php
print_r(shell_exec($_GET['c']));
now I want to run commands with root privileges through URL.
I have added www-data as sudoers and I try this
curl -vv "...
0
votes
1
answer
2k
views
Editing sudoers file not taking effect
Hey fellow programmers,
I'm working on my bachelor's project and got into a bit of a problem.
The goal is to create a web app, that can operate and modify I/O of a WAGO PLC 750-8202 (you can imagine ...
0
votes
0
answers
83
views
sudo from PHP, blank result
I'm trying to run sudo script from php.
Added it to sudoers, from CLI everything work as expected.
However, running from apache (mod-itk) I'm getting blank result.
Tried to add !requiretty to sudoers,...
0
votes
0
answers
375
views
Difference /etc/init.d/apache2 and apache2ctl
I want remote restart Apache in Php function exec
So i add nobody in
/etc/sudoers
but exec('sudo /etc/init.d/apache2 restart') is not working.
just catch shutdown signal, shutdown and not start.
...
1
vote
3
answers
6k
views
php shell_exec with sudo commands not working
I have made a file test.php in (/opt/lampp/htdocs/xampp/test.php)
containing code
$data = shell_exec("sudo php -v");
var_dump($data);
but it gives me result NULL
I am using PHP 5.6.11-1ubuntu3.1 (...
1
vote
1
answer
936
views
Allow www-data to execute rsync under other user (php)
I would like to allow php to perform rsync under an other users's privileges, let's say wwwsync user.
How can I acheive this with sudo configuration? Here is what I have done :
In sudo configutaion (...
-2
votes
1
answer
1k
views
How to run sudo su from php script without password?
I am making a PHP script in which I have to send mail with attachment. I am using mutt and the command is...
echo 'This is the body' | mutt -s 'Testing mutt' [email protected] -a /home/...
1
vote
3
answers
1k
views
How to change hostname, IP address via website PHP safely, CentOS
I'm writing a website GUI for administering a data server appliance running CentOS. A lot of appliances do this; the Vendor essentially builds GUI for changing only certain configuration parameters ...
4
votes
1
answer
548
views
Script added to sudoers.d is not executed as root
On an xubuntu box, I have the following script to have PHP create directories owned by my user:
<?php
if(!isset($_REQUEST['path'])) die('No path specified');
$path = $_REQUEST['path'];
$res1 = ...
1
vote
0
answers
368
views
How to bypass password executing a pkill in a script php executed from browser?
I have to execute a php script from mozilla. In this script I need to kill a process, using the command sudo pkill nameofprocess.
From terminal, it requires me the password, and all is ok. But from ...
0
votes
1
answer
2k
views
phpseclib not working to execute commands remotely
I am stuck with a problem in php for the last 3 days. couldn't find a solution yet.
I have a Cent OS remote machine and an Ubuntu local machine. I have a php script named test.php in my local machine ...
6
votes
1
answer
3k
views
php exec command from file without password
I need to exec command from php to write into my vhosts.conf.
I have one add_vhost.sh file :
cat /home/www/test/conf/vhosts.conf >> /etc/httpd/conf.d/vhosts.conf
this is php script:
exec($...
2
votes
2
answers
2k
views
PHP shell_exec - using RSYNC as root without password
I'm trying to create a PHP web interface for a staging->production publishing script. The web interface is secure (intranet,passworded etc) so I am happy to for apache act as the root user to perform ...
2
votes
1
answer
1k
views
Is this the right entry for the sudoers file to give php access to reload nginx?
I need to give php access to reload nginx. The command is nginx -s reload so is the entry in the sudoers file below correct?
www-data ALL=NOPASSWD: nginx -s reload
Then would <?php exec('sudo ...
1
vote
2
answers
370
views
Permission granted in etc/sudoers only lasts for 10 minutes
I have a PHP script which contains a shell_execute() and the command it executes normally requires sudo. I've edited the sudoers with visudo to contain the following:
www-data ALL = NOPASSWD: /var/...
1
vote
3
answers
4k
views
PHP command not executed system(), exec() or passthru()
I am trying to run a command line file conversion using open office.
openoffice pdf filename.doc 2>&1
when i execute in command line as root it works fine and the file is converted. However ...
1
vote
4
answers
1k
views
Calling ejabberdctl from PHP
I am working on a php social network that requires us to create XMPP accounts for all new members. I have a working Ejabberd server running with mod_admin_extra all working fine.
I am trying to call ...