Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I want to control my ProFTPd authentication by a MySQL database. Users will be able to change the username and password of their FTP account(s) in a PHP web application. This provokes a following problem: The users set in the database usertable do not match the system users. So I am not able to change the directory permissions in my filesystem and ProFTPd logs the error:

username chdir("/var/www/vhosts/sites/username"): Permission denied

But how could I give these FTP users access to these folders? If I set up a user called www-data it works fine but the usernames will not be defined in /etc/passwd.

The second thing I want to manage is the restriction of this only directory, in this case /var/www/vhosts/sites/username. The user mustn't have access to other directories if they are not in the home directory above.

How do I fix this?

share|improve this question
    
Are you saying that you want to use MySQL for authentication, yet you still want to set permissions on directories as if they were system users? –  Kvisle Oct 29 '11 at 13:04

1 Answer 1

up vote 3 down vote accepted

You will have to give your proftpd virtual users ownership of their files and directories just like you would a real user. You can do this with chown. As the users aren't system users you will have to use the numeric UID:GID e.g. if username is UID 10001 and GID 1111 (from the mysql database) then

chown  10001:1111 /var/www/vhosts/sites/username
chown  -R 10001:1111 /var/www/vhosts/sites/username

should give username control over their own files. Ensure that www-data user has suitable read only access to the file & directories e.g. give world r-x to directories and r-- to files.

If you set the

DefaultRoot  ~

directive then the users will be confined within their own directory tree.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.