Domain management - issues delete domain

bcx

Verified User
Joined
Dec 11, 2015
Messages
77
Hi all,

I'm having this weird issue when deleting a domain.
As i'm having troubles with my wordpress website, i'm building a stage website from scratch... but the folder permission doesn't seem to be right. So want to delete a domain that i use for staging, to re-add it to build the stage website on it.. However i'm getting the following error: cannot unlinkat full message below

I hope someone can assist me with this issue. Never had this before.
Thank you in advance.

Domain Deletion Results​


Error deleting mywebsite.com
/home/admin/domains/mywebsite.com: cannot unlinkat /home/admin/domains/mywebsite.com/public_html/wp-admin/tools.php: Permission denied
cannot unlinkat directory /home/admin/domains/mywebsite.com/public_html/wp-admin: Directory not empty
cannot unlinkat directory /home/admin/domains/mywebsite.com/public_html: Directory not empty
Unable to remove /home/admin/domains/mywebsite.com: Directory not empty

mywebsite.com's config files have been removed

Im running on DirectAdmin Version 1.63.1 on OpenLiteSpeed.
 
Try to reset permissions :
So i runned these commands in putty. Tried to re-add the domain, this work fine. but when i retry to delete it, the same error message shows up.
And if i try to just random add test.com and remove this one, no error shows up.

So it seems to be related to this specific domain name.

cd /usr/local/directadmin/scripts
./set_permissions.sh all
 
@smtalk I am seeing same issue as bcx (failure to remove some files) in DA 1.63.7.
When i try to delete DA accounts from within reseller account list, some files removal failed (cannot unlinkat /path/to/file: Permission denied)
It is possible that these files was previously a cPanel full backups having immutable bit or similar and your cpanel->DA script restored it and being unable to remove the file. Consider if removal script can be run with more permissions to allow removal, or notify server root about commands to remove these files manually? Accounts was visually removed for a reseller, but in reality some files remains (errors "Unable to remove /home/user/domains/domain.here: Directory not empty")
UPDATE: server admin reply my request to delete the reported permission denied files: "We are not being able to remove any of the files on this list as these doesn't seem to exist" so DA either false alarm or admin did a mistake? UPDATE2: today after i have tried to restore one of the account backup it told me: Error while creating User accountname. Path '/home/accountname' already exists before User creation. Please remove/rename this path first.
So maybe this indeed is a bug in removal or in restore...
 
Last edited:
I encountered a similar error today, with a user that was removed in the background after an API call. The API call returned:

Code:
$resDeleteAccount (->fetch_parsed_body())                                                                                                                                                             
array(3) {                                                                                                                                                                                           
  ["error"]=>                                                                                                                                                                                         
  string(1) "0"                                                                                                                                                                                       
  ["text"]=>                                                                                                                                                                                         
  string(40) "Users will be deleted in the background."                                                                                                                                               
  ["details"]=>                                                                                                                                                                                       
  string(168) "The disk usage for the selected Users totals more than 10240 MB, thus will be removed in the background.<br>You will be notified via the Message System upon completion."             
}

And the notification in the message systems is as follows:

Code:
Subject: Error while deleting Users

Error Removing User <redacted>
User removed from SSH
Email:destroy: Error removing /home/<redacted>/imap/<redacted>: cannot unlinkat directory /home/<redacted>/imap/<redacted>/<redacted>/Maildir: Directory not empty
cannot unlinkat directory /home/<redacted>/imap/<redacted>/<redacted>: Directory not empty
Unable to remove /home/<redacted>/imap/<redacted>: Directory not empty


<redacted>'s config files have been removed

Users's domains directory removed.

Error removing path /home/<redacted>/imap: cannot unlinkat directory /home/<redacted>/imap/<redacted>/<redacted>/Maildir: Directory not empty
cannot unlinkat directory /home/<redacted>/imap/<redacted>/<redacted>: Directory not empty
cannot unlinkat directory /home/<redacted>/imap/<redacted>: Directory not empty
Unable to remove /home/<redacted>/imap: Directory not empty


Unix User removed from the server
User's config files deleted
User's data directory removed.
Left user on admin's list

However the home directory /home/<redacted> is gone, so the deletion worked in the end I guess. There are some leftover entries though I can find references to the username/domain that was deleted in these files:
  • /usr/local/directadmin/data/admin/php_safe_mode.cache
  • /usr/local/directadmin/data/users/admin/users.list
  • /usr/local/directadmin/data/users/admin/bandwidth.reseller.tally
The user itself no longer has a directory in /usr/local/directadmin/data/users/, and it's not listed in DA under "Show all users". The user *is* however listed under "My Users", with "Creation in Progress" in the Bandwidth column. Clicking on it, shows the error "Unable to show user - Error reading their user files".

I can also see some errors from dovecot that are related. The errors above might occur because an email account was being accessed at the time?

Code:
Mar  4 14:13:04 <redacted> dovecot[7928]: imap(<redacted>)<23512><<redacted>>: Error: unlink(/home/<redacted>/imap/<redacted>/<redacted>/Maildir/dovecot.index.cache.tmp) failed: No such file or directory (in mail-cache-purge.c:518)
Mar  4 14:13:04 <redacted> dovecot[7928]: imap(<redacted>)<23512><<redacted>>: Warning: Our dotlock file /home/<redacted>/imap/<redacted>/<redacted>/Maildir/dovecot-uidlist.lock was deleted (locked 1 secs ago, touched 1 secs ago)
Mar  4 14:13:04 <redacted> dovecot[7928]: imap(<redacted>)<23512><<redacted>>: Disconnected: IMAP session state is inconsistent, please relogin. in=4622 out=423623 deleted=0 expunged=0 trashed=0 hdr_count=0 hdr_bytes=0 body_count=0 body_bytes=0
Mar  4 14:13:05 <redacted> dovecot[7928]: auth: missing passwd file: /etc/virtual/<redacted>/passwd
Mar  4 14:13:07 <redacted> dovecot[7928]: imap-login: Disconnected: Aborted login by logging out (auth failed, 1 attempts in 2 secs): user=<<redacted>>, method=PLAIN, rip=<redacted>, lip=<redacted>, TLS, session=<<redacted>>
Mar  4 14:13:07 <redacted> dovecot[7928]: imap(<redacted>)<23514><<redacted>>: Fatal: master: service(imap): child 23514 killed with signal 9

It's possible that the OP's issue was caused by similar things, files being open/in use, and the deletion process not dealing with it properly?

Edit: As a sidenote, it would be nice if the message told us what we should do now, to clean up properly. Going into those files I listed and just delete the relevant lines seems like maybe a bad idea? But if not, I'll have leftovers sitting there forever?
 
Last edited:
And just a followup on the deletion progress, I ticked the box next to the user in the "My users" list, and clicked delete, which triggered this message:

Code:
Error while deleting Users
User <redacted> did not exist on the server. Removing it from your list.

It is now only referenced in these two files:
  • /usr/local/directadmin/data/admin/php_safe_mode.cache
  • /usr/local/directadmin/data/users/admin/bandwidth.reseller.tally
 
Hi Guys,

Thanks for the info. Seems like there's something hidden, not getting removed for these cases.

1) For the WordPress tools.php, that sounds like a chattr +i issue, or something like that, possibly root owned, else ownership issue, not too sure.
Either way, that error itself might be valid unless the cause is found to be something else. If you can reproduce it reliably, let us know the info on that file prior to deletion. I might be able to make some changes to account for that state. I won't likely override a chattr or root ownership though. Those error triggers would be valid to report.

2) For the /home/user/imap/domain.com error, to debug what's left behind, there is a debug code in place that can spit out the full remaining tree for the reason. Deleting in debug mode would let you know the tree info.
However, as we're all suspecting a race condition with dovecot, I've made a few minor tweaks:
- the unlinkat failure will check if it's a ENOENT case (no such file/directory) and ignore that, as no need to throw a deletion error on something that isn't there.
- for ~/imap/domain.com deletion, I've set it to call the removal twice in a row as a basic work-around to the dovecot race condition (we'll see who wins).

Alpha binaries should be up in about 12 hours after the nightly build:
Code:
/usr/local/directadmin/scripts/getDA.sh alpha
Let me know if there's any extra known cases not covered or if anyone has any other issues.

I *could* set it to just ignore any directory deletions below /home/user, as I believe the userdel would cleanup anything else, but for just one domain deletion (not the whole User) we would still want to throw errors as that would leave behind broken directories.

John
 
Back
Top