Hi,

I have a new project that needs to add users to the linux system. They have to have a user name and password assigned.

I know I can use the

exec('adduser test -p password');

Now that should add a user test with the password password.

But when I run my ftp program and try to use the user name and password it won't work.

If I execute the same in linux command but with just

adduser test
passwd test

it will work. Aren't these two commands the same?

Thanks for the help. or if someone has a better whay to do it I would love to know.

scandog

    Make sure that PHP is allowed to do this. I'm not sure what the variable is that you would need to check, but it seems like this would generally be disallowed by the parser and/or apache for security reasons (someone can add themselves as a user through a webpage, then log into the server, and do damage). If this is the case, then you should be able to turn that off, but I'd think twice before you want to do that.

      I think your right about permissions, the apache user probibly can't add users.

      How can I get around this.

      What I am trying to do is create a way so that people can ftp into my server for backups. Once they have registered I need to be able to create a user with his own home directory. Each user must be different with their own password.

      Is this possible with php?

        do research on the SUDO command, configure and install this and execute the useradd as a sudo command it will work out properly, and keep security at a decient level.

          alternatively, you could do this two other ways. one would be to create a file which contains the usernames and passwords, and add them manually every day. it could get tedious, but you could be sure that there aren't stray entries that are getting in.

          the other way could be to, again, create a file containing the usernames and passwords, but then to also create a cron job which runs once a day (or more often if you like) that runs as root and adds the users, reading the file where the info is.

            Write a Reply...