Permission problem with admin level ftp backup (suPHP & ncftpput)

zormal

Verified User
Joined
Jul 21, 2011
Messages
5
Hello,

I'm running DirectAdmin on CentOS with suPHP, and I have some permission problems with admin-level backup. When I try to back up to a remote ftp server, I get the following error message:

Subject: An error occurred during the backup.
User X has been backed up.
ncftpput /home/tmp/admin/user.admin.site.tar.gz: server said: Can't open that file: Permission denied​

/home/tmp is chmod 777, but the files inside are 751. Both owner and group are root.

I'm guessing ncftpput is not running as root, and that's why it's not able to access the backup files. Can I change the backup file permissions easily somewhere, or should I try something else?
 
Hello,

You should set up a backup task manually in Directadmin with "now" and run

Code:
# /usr/local/directadmin/dataskq d8000

to see detailed debug info. Share it here, so we could check it for you.
 
Here's the output for a local backup, which works
Code:
Debug mode. Level 8000

root priv set: uid:0 gid:0 euid:0 egid:0
pidfile written
staring queue
dataskq: command: action=backup&local%5Fpath=%2Fhome%2Fjuhani%2Fadmin%5Fbackups&owner=juhani&select%30=juhanitest&type=admin&value=multiple&when=now&where=local
InternalText::init(user)
InternalText::init(backup)
InternalText::init(backup)
InternalText::init(user)
User::setQuota(0) user=juhanitest
quota command: /usr/sbin/setquota juhanitest 0 0 0 0 /
Quotas set
InternalText::init(email)
(null) has not changed. Skipping write
/etc/virtual/juhanitest.com/autoresponder.conf has not changed. Skipping write
/etc/virtual/juhanitest.com/vacation.conf has not changed. Skipping write
/home/juhani/admin_backups/juhanitest/backup/juhanitest.com/email/email.conf has not changed. Skipping write
InternalText::init(ftp)
InternalText::init(ip)
/home/juhani/admin_backups/juhanitest/backup/juhanitest.com/ftp.passwd has not changed. Skipping write
/home/juhani/admin_backups/juhanitest/backup/juhanitest.com/ftp.conf has not changed. Skipping write
InternalText::init(database)
Database::connect 0
Database::connect 0.5 - da_admin : [b]secret[/b]
Database::connect 1
Database::connect 5
InternalText::init(domain)
just after hc.init("domain"); for juhanitest.com.
Currently in getlock(/home/juhani/admin_backups/juhanitest/backup/juhanitest.com/ftp.conf) : finished
./data/users/juhanitest/user.conf has not changed. Skipping write
./data/users/juhanitest/user.usage has not changed. Skipping write
/home/juhani/admin_backups/juhanitest/backup/juhanitest.com/domain.conf has not changed. Skipping write
InternalText::init(redirect)
executeAsUser('/bin/nice -n 19 /bin/tar czfp /home/juhani/admin_backups/juhanitest/backup/home.tar.gz -C /home/juhanitest/ 2>&1 '.bash_logout' '.bash_profile' '.bashrc'', 153, juhanitest, 1, '(null)', int *child_pid, *snd, group=(null)) uid=556 gid=557
Running backup command: /bin/nice -n 19 /bin/tar czfp /home/juhani/admin_backups/juhanitest/user.juhani.juhanitest.tar.gz  -C /home/juhani/admin_backups/juhanitest backup -C /home/juhanitest/ domains > /dev/null
User::setQuota(1000) user=juhanitest
quota command: /usr/sbin/setquota juhanitest 1024000 1126400 0 0 /
Quotas set
done queue
I appreciate you taking a look.
 
Here's the right one:
Code:
Debug mode. Level 8000

root priv set: uid:0 gid:0 euid:0 egid:0
pidfile written
staring queue
dataskq: command: action=backup&ftp%5Fip=%31%38%38%2E%31%36%35%2E%31%34%34%2E%31%34%31&ftp%5Fpassword=dzVxdjBzcHB%3D&ftp%5Fpath=%2F&ftp%5Fport=%32%31%32%31&ftp%5Fusername=ftpbackup&owner=juhani&select%30=juhanitest&type=admin&value=multiple&when=now&where=ftp
InternalText::init(user)
InternalText::init(backup)
InternalText::init(backup)
InternalText::init(user)
User::setQuota(0) user=juhanitest
quota command: /usr/sbin/setquota juhanitest 0 0 0 0 /
Quotas set
InternalText::init(email)
(null) has not changed. Skipping write
/etc/virtual/juhanitest.com/autoresponder.conf has not changed. Skipping write
/etc/virtual/juhanitest.com/vacation.conf has not changed. Skipping write
/home/tmp/juhani/juhanitest/backup/juhanitest.com/email/email.conf has not changed. Skipping write
InternalText::init(ftp)
InternalText::init(ip)
/home/tmp/juhani/juhanitest/backup/juhanitest.com/ftp.passwd has not changed. Skipping write
/home/tmp/juhani/juhanitest/backup/juhanitest.com/ftp.conf has not changed. Skipping write
InternalText::init(database)
Database::connect 0
Database::connect 0.5 - da_admin : [b]secret[/b]
Database::connect 1
Database::connect 5
InternalText::init(domain)
just after hc.init("domain"); for juhanitest.com.
Currently in getlock(/home/tmp/juhani/juhanitest/backup/juhanitest.com/ftp.conf) : finished
./data/users/juhanitest/user.conf has not changed. Skipping write
./data/users/juhanitest/user.usage has not changed. Skipping write
/home/tmp/juhani/juhanitest/backup/juhanitest.com/domain.conf has not changed. Skipping write
InternalText::init(redirect)
executeAsUser('/bin/nice -n 19 /bin/tar czfp /home/tmp/juhani/juhanitest/backup/home.tar.gz -C /home/juhanitest/ 2>&1 '.bash_logout' '.bash_profile' '.bashrc'', 143, juhanitest, 1, '(null)', int *child_pid, *snd, group=(null)) uid=556 gid=557
Running backup command: /bin/nice -n 19 /bin/tar czfp /home/tmp/juhani/juhanitest/user.juhani.juhanitest.tar.gz  -C /home/tmp/juhani/juhanitest backup -C /home/juhanitest/ domains > /dev/null
User::setQuota(1000) user=juhanitest
quota command: /usr/sbin/setquota juhanitest 1024000 1126400 0 0 /
Quotas set
Load to env:
 0: action=backup
 1: ftp_ip=188.165.144.141
 2: ftp_local_file=/home/tmp/juhani/user.juhani.juhanitest.tar.gz
 3: ftp_password=censored
 4: ftp_path=/
 5: ftp_port=2121
 6: ftp_remote_file=user.juhani.juhanitest.tar.gz
 7: ftp_username=ftpbackup
 8: owner=juhani
 9: select0=juhanitest
10: type=admin
11: value=multiple
12: when=now
13: where=ftp
executeAsUser('/bin/sh', 512, diradmin, 1, 'FTPPUT=/usr/bin/ncftpput
TOUCH=/bin/touch
PORT=${ftp_port}

if [ ! -e $TOUCH ] && [ -e /usr/bin/touch ]; then
        TOUCH=/usr/bin/touch
fi

if [ ! -e $FTPPUT ]; then
        echo "";
        echo "*** Backup not uploaded ***";
        echo "Please install $FTPPUT by running:";
        echo "";
        echo "cd /usr/local/directadmin/scripts";
        echo "./ncftp.sh";
        echo "";
        exit 10;
fi

if [ ! -e "${ftp_local_file}" ]; then
        echo "Cannot find backup file ${ftp_local_file} to upload";
        exit 11;
fi

CFG=${ftp_local_file}.cfg
/bin/rm -f $CFG
$TOUCH $CFG
/bin/chmod 600 $CFG
/bin/echo "host $ftp_ip" >> $CFG
/bin/echo "user $ftp_username" >> $CFG
/bin/echo "pass $ftp_password" >> $CFG

$FTPPUT -f $CFG -V -t 25 -P $PORT -m "$ftp_path" "$ftp_local_file" 2>&1
RET=$?

/bin/rm -f $CFG

exit $RET
', int *child_pid, *snd, group=(null)) uid=101 gid=101
InternalText::init(ticket)
/usr/local/directadmin/data/tickets/000000/373/000.conf has not changed. Skipping write
./data/admin/tickets.list has not changed. Skipping write
InternalText::init(user)
InternalText::init(user)
./data/users/juhani/ticket.conf has not changed. Skipping write
done queue
 
Hide your passwords!!! What are you doing!!?

da_admin password in both your posts and now password for FTP

Change your passwords for both FTP account and Directadmin/MySQL
 
Not my real passwords. Perhaps I should have removed them completely, to not give you guys heart attacks :P

Could have hidden my ip, though...
 
Anyway, I don't see any error. What if you try manually to connect to remote FTP server with those credentials?
 
No problem with the ftp. I'm pretty sure that the cause is read permissions, as I had no problems before installing suPHP.

Do you know where I can find the script where ncftpput is called? I think I could do something there.
 
You should change your mysql da_admin password now too.
 
Back
Top