Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Problems:</strong></p> <ol> <li><p><strong>Explicit home directory:</strong> Your command line syntax is wrong. Try the following instead:</p> <p><code>sudo useradd -m username</code></p> <p>or</p> <p><code>sudo useradd -d /home/username -m username</code></p></li> <li><p><strong>Is PHP a sudoer?</strong> Only certain accounts are able to execute sudo. Check that the account PHP runs under is listed in the sudoers file. You can usually easily the file with</p> <p><code>visudo</code></p></li> <li><p><strong>Is PHP <code>chroot</code>-ed?</strong> If so, you may not be able to create new linux user accounts from scripts with any reasonable code.</p></li> </ol> <p><strong>A working test</strong></p> <p>The following worked for me under Debian (without sudo).</p> <p><em>newuser.sh</em></p> <pre><code>#!/bin/bash useradd -d /home/$1 -m $1 </code></pre> <p><em>newuser.php</em></p> <pre><code>&lt;?php exec('/bin/bash /var/www-scripts/newuser.sh joe'); ?&gt; </code></pre> <p><em>test invocation:</em> <code>php newuser.php</code></p> <p>If you can perform the same tests (but add sudo as needed), then the only reason it would not work when invoked by your web server is a security problem. That could either be a chroot environment, or lacking sudoer privilege.</p> <p><strong>Additional resources</strong></p> <p>You can see how other people have solved this problem by reviewing the following:</p> <ol> <li><a href="http://www.weberdev.com/get_example.php3?ExampleID=3766" rel="nofollow">http://www.weberdev.com/get_example.php3?ExampleID=3766</a></li> <li><a href="http://www.linuxforums.org/forum/programming-scripting/176031-solved-crafting-php-script-create-unix-user.html" rel="nofollow">http://www.linuxforums.org/forum/programming-scripting/176031-solved-crafting-php-script-create-unix-user.html</a></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload