0

I have two groups. ftpgroup and www-data. I'm using proftpd and mysql to store the ftp users and their homes. When the user registers it creates the folder first and then creates the user account in MySQL. My issue lies in the fact that apache seems to have no problem creating the directory. Users can then log in, but afterwards they have no write access. Same goes for the home directory. Users inherit the group ftpgroup and ftpuser when they are created in the SQL database and then restricted to their home directories. I also just saw that my main user cannot write in their home directory.

Permissions for /var/www:

drwxr-xr-x 4 www-data ftpgroup 4096 Jan 22 21:28 /var/www

I can of course chown -R ftpuser:ftpgroup /var/www but then Apache can no longer write to /var/www/html/accounts

I tried setting chown -R ftpuser:www-data /var/www but then I still couldn't create the file with apache and when set to chown -R www-data:ftpgroup I can't modify any files with ftp. Another concern raised is what kind of issues are going to be raised by apache with permissions when php creates the new directory after looking at permissions.

Current Script to Create Folder

public function CreateUserFolder($arg,$arg2,$arg3) {
    if(file_exists(ROOT_PATH.'/accounts/'.$arg)) {
        echo "User Exists";

    }
    else {
    mkdir(ROOT_PATH.'/accounts/'.$arg, 0777, true);
    self::CreateFTPAccount($arg,$arg2,$arg3);
    }
}
0

I'm not sure if this would really constitute as a fix or not, but it's what I did to make it so that the users could write to their directory.

chown -R ftpuser:ftpgroup /var/www

Afterwards within /etc/apache2/envvars

# Since there is no sane way to get the parsed apache2 config in scripts, some
# settings are defined via environment variables and then used in apache2ctl,
# /etc/init.d/apache2, /etc/logrotate.d/apache2, etc.
export APACHE_RUN_USER=www-data //Replaced
export APACHE_RUN_GROUP=www-data //Replaced

And simply replaced it with

# Since there is no sane way to get the parsed apache2 config in scripts, some
# settings are defined via environment variables and then used in apache2ctl,
# /etc/init.d/apache2, /etc/logrotate.d/apache2, etc.
export APACHE_RUN_USER=ftpuser
export APACHE_RUN_GROUP=ftpgroup

So far I've seen no issues and everything is working great.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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