Recently because of a PHP interface, but because of permissions problems, can not execute some specific commands, because PHP to run nobody.
Online search for some solutions, one is the use of the Su method, a C program to achieve, there is a super program to achieve.
Compared to the next, I think the Super command PHP calls more convenient, so this article mainly introduces the super simple implementation method.
First, download and install super, the process is as follows:
[root@ossec.cn ~] #wget ftp://ftp.ucolick.org/pub/users/will/super-3.30.0-tar.gz
[root@ossec.cn ~] #tar zxvf super-3.30.0-tar.gz
[root@ossec.cn ~] #cd super-3.30.0
[Root@ossec.cn Super-3.30.0]#./configure
[root@ossec.cn super-3.30.0] #make && make install
[root@ossec.cn ~] #super
Super
Super Version 3.30 Patchlevel 0
Commands available to User root (Use option '-h ' for a long-winded listing):
Command Name Comments
or pattern
———— ——–
When the installation is complete, the execution of super, as shown above, is verified to have been installed.
Second, the next configuration super (need to configure Super recognizable alias command)
[root@ossec.cn ~] #vi/usr/local/etc/super.tab
For example, if you want to invoke adduser with root privileges, add a line to the last line,
Auser/user/sbin/adduser Nobody,root
* First column is the command alias, the second column is the path to the calling command, and the third is the PHP startup username (the account that can do this), and the last one is any single user in the system *
If you also want to invoke other commands, you can install the above method to construct, of course, the first column alias can not be the same, such as
CPASS/USER/BIN/PASSWD Nobody,root
At this point, the configuration is complete.
Third, call
3.1, the use of super is:
super+ alias + other parameters (optional)
Cases:
[root@ossec.cn ~] #super auser Test
[root@ossec.cn ~] #super cpass Test
Change the password for user test.
New Password:
Invalid password: It is based on dictionary words
Re-enter the new password:
PASSWD: All authentication tokens have been successfully updated.
3.2, PHP calls the Super command:
Cases:
<?php system (' Super Auser test1′);?>