Forum Moderators: coopster
i using this line of code in PHP:
$res=`bash /var/www/cgi-bin/del.sh $username 2>&1`;
while in the del.sh, the code is like this:
userdel -r $1
In the apache there, i already set the root for apache in /etc/sudoers.. i set like this:
apache ALL= NOPASSWD:/usr/sbin/userdel \
/bin/mkdir, /bin/ln, /bin/chown
Can anyone know why i fail to delete the user in linux.. Thank..
$res=`bash /var/www/cgi-bin/del.sh $username 2>&1`;
while in the del.sh, the code is like this:
sudo userdel -r $1
In the apache there, i already set the root for apache in /etc/sudoers.. i set like this:
apache ALL= NOPASSWD:/usr/sbin/userdel \
/bin/mkdir, /bin/ln, /bin/chown
Can anyone know why i fail to delete the user in linux.. Thank..
1) Coding in PHP page:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="form1" method="post" action="deleteLinux.php">
<p>Login:
<input name="login" type="text" id="login">
</p>
<p>
<input type="submit" name="Submit" value="Crear">
</p>
</form>
</body>
</html>
<?php
if (isset($_POST['Submit'])) {
$login=$_POST['login'];
$res=`bash /var/www/cgi-bin/del.sh $login 2>&1`;
echo"<pre>$res</pre>";
}
?>
2) While the below is the del.sh
sudo userdel -r $1
I am assuming this is something that needs to be done often and may involve many steps
I have used shell scripts for complicated processes many times but I always have to login as root to fire them off.
maybe if you explain the reasoning behind doing this scripted user removal I might be ble to shed a little more light
So, is it clear enough?