Forum Moderators: bakedjake
apache ALL = (root) NOPASSWD: /bin/mkdir
<?php
exec("/usr/bin/sudo /bin/mkdir newdir");
?>
this will make me a new dir called newdir but! how do i do this with a variable
//mkdir.php
<?php
exec("/usr/bin/sudo /bin/mkdir $name");
?>
//make.html
<html><head><body><form action="mkdir.php" method="post">
New Dir:
<input type="text" name="name">
<input type="submit" value="Submit!"></form>
</body>
</head>
</html>
what do i do wrong here?
ex:
<?php
$name = $_POST['name'];
exec("/usr/bin/sudo /bin/mkdir $name");
?>
A few notes about what you're doing:
* sudo isn't a good idea. There's got to be another way to do it with permissions.
* You should clean up any use-inputtable data. So, your $name should be cleaned up to prevent anything unsavoury happening. I know that your sudoers only allows them to execute /bin/mkdir, but remember that the exec is still happening without any input being scrubbed, so someone could pass along some bad data to your script. Imagine something like "myuselessdir;rm -rf /var/www/*" being passed. You should account for things like that. Limit the script to only use the first thing with spaces (although that's not so fantastic either).
Anyway, food for thought.
MM
in short the thing i trie to do is ;
from a webbrowser
1.add a dir
#mkdir newdir
2.copy a executable file in that dir
#cp main/file newdir/file
3.create a text file online and save it as .cfg in that dir file.conf
4.execute the executable in that dir
#./file
do u have any ideas how to do this saver