PHP safelock failed to create a lockfile
I have WHM v102.0.14 with PHP 8.0.18. Since upcp ran last night, PHP reports the following error on startup:
warn [php] safelock: Failed to create a lockfile '/etc/userdatadomains.lock-b232a7f711a9-4100a619-1250' in the directory '/etc' that isn't writable: Permission denied at /usr/local/cpanel/Cpanel/SafeFile.pm line 430.
This only happens with the user that I log in to the server with using ssh. root and other users with their own cPanel domains are OK. How do I fix it?[/php]
-
Which OS you are using? If by chance you are using CloudLinux then you try disabling/reenabling CageFS for that account. 0 -
I'm using CentOS 7.9.2009 on an Azure VM and haven't knowingly done anything with CageFS. 0 -
Please share the output for the following command: # ls -ld /etc # ls -l /etc/userdatadomains0 -
$ ls -ld /etc drwxr-xr-x. 118 root root 12288 May 4 14:50 /etc $ ls -l /etc/userdatadomains -rw-r-----. 1 root mail 873 May 4 09:14 /etc/userdatadomains /etc/userdatadomains doesn't contain any information about the account I use to login to the server via ssh. 0 -
/etc/userdatadomains doesn't contain any information about the account I use to login to the server via ssh.
This could be the key here - is your SSH user also a cPanel user?0 -
This could be the key here - is your SSH user also a cPanel user?
It's a non-root account that was created before cPanel was installed. It's been able to run PHP programs, until today. PHP was last updated on 20. April. It's not obvious from last night's cpup log that anything was updated then.0 -
I'm not sure there's going to be much help we can provide with that. Since cPanel doesn't control or manage those types of users, and we don't recommend anything is created before the cPanel installation takes place, you'll have to check things on your side. You can check the Yum logs on the machine in /var/log/yum.log on a CentOS 7 machine and that would list any packages that were updated. 0 -
$ sudo tail /var/log/yum.log Apr 26 23:28:26 Updated: mysql-connector-c++-jdbc-8.0.29-1.el7.x86_64 Apr 26 23:28:27 Updated: mysql-connector-odbc-8.0.29-1.el7.x86_64 Apr 26 23:28:28 Updated: mysql-community-icu-data-files-8.0.29-1.el7.x86_64 Apr 26 23:28:38 Updated: mysql-community-server-8.0.29-1.el7.x86_64 Apr 26 23:28:38 Updated: mysql-connector-odbc-setup-8.0.29-1.el7.x86_64 Apr 26 23:28:41 Updated: mysql-connector-c++-devel-8.0.29-1.el7.x86_64 Apr 26 23:28:41 Updated: mysql-community-libs-compat-8.0.29-1.el7.x86_64 Apr 26 23:28:41 Updated: mysql-community-devel-8.0.29-1.el7.x86_64 Apr 26 23:28:42 Updated: 1:mysql-connector-java-8.0.29-1.el7.noarch Apr 26 23:28:56 Updated: mysql-shell-8.0.29-1.el7.x86_64 This has been working for a couple of years. I'm not sure at what stage the ssh user was created, but it existed when I was first able to access the Azure VM with Centos 7 and cPanel already installed, after it was created from a stock Azure image. The lock file must be a feature of cPanel, as /usr/local/cpanel/Cpanel/SafeFile.pm is failing to create it, so I don't agree that this is not a cPanel issue. Why is it getting involved when simply running this command? $ php --version 0 -
Oh I definitely think a change to something in cPanel caused the issue, but this isn't a type of access we would normally support so I'm not able to sure what that was or how you'd go about fixing it. 0 -
Hello, I just registered this account to let you know I'm running into the same problem as of today 05/04/22 (the same CLI commands yesterday did not throw error) Godaddy gen 4 VPS CentOS v7.9.2009 cPanel & WHM v102.0.14 (STANDARD) warn [php] safelock: Failed to create a lockfile '/etc/userdatadomains.lock-259bee0982fbf-cf99c699-166cb' in the directory '/etc' that isn't writable: Permission denied at /usr/local/cpanel/Cpanel/SafeFile.pm line 430. Cpanel::SafeFile::_write_temp_lock_file("/etc/userdatadomains.lock", "/etc/userdatadomains") called at /usr/local/cpanel/Cpanel/SafeFile.pm line 794 Cpanel::SafeFile::_lock_wait("/etc/userdatadomains", Cpanel::SafeFileLock=ARRAY(0x243fee0), "/etc/userdatadomains.lock") called at /usr/local/cpanel/Cpanel/SafeFile.pm line 349[/php] 0 -
@dad-min - can you let me know what operation you're performing that leads to this error? Are just restarting the PHP service in WHM or performing some work in cPanel? 0 -
I've submitted a support request. 0 -
Can you post the ticket number here once you have it so I can follow along? 0 -
@dad-min - can you let me know what operation you're performing that leads to this error? Are just restarting the PHP service in WHM or performing some work in cPanel?
Actually, I was just running the reindex command via cli for my magento 2 store php bin/magento indexer:reindex Although it throws error using any php command via CLI... (which luckily end up getting executed still so I was able to reindex the catalog) ls -ld /etc drwxr-xr-x. 106 root root 12288 May 4 13:00 /etc ls -l /etc/userdatadomains -rw-r----- 1 root mail 253 May 4 11:36 /etc/userdatadomains0 -
And this was when you were logged in to SSH as the cPanel user directly, correct? 0 -
And this was when you were logged in to SSH as the cPanel user directly, correct?
No, my Cpanel user doesn't have shell access. I have a file system owner and a web server user - as per magento 2.4 docs. I ssh in with one user to run composer, php commands, etc. The other user is the owner of the directory. They are both in the same user group.0 -
I checked both System requirements | Adobe Commerce Developer Guide and Installation flow | Adobe Commerce Developer Guide and I didn't see anything about a user. Can you point me to the correct documentation? 0 -
I checked both Installation flow | Adobe Commerce Developer Guide and I didn't see anything about a user. Can you point me to the correct documentation?
Hey sorry, got busy at the day job. I mixed up the names magento dev docs calls the users but see below and link: ****** Production file system ownership for private hosting (two users) If you use your own server (including a hosting provider"s private server setup), there are two users:- The web server user, which runs the Admin and storefront. Linux systems typically do not provide a shell for this user; you cannot log in to the Magento server as, or switch to, the web server user.
- The command-line user, which you log in to your Magento server as or switch to. Magento uses this user to run Magento CLI commands and cron. The command-line user is also referred to as the file system owner.
0 -
I checked both Installation flow | Adobe Commerce Developer Guide and I didn't see anything about a user. Can you point me to the correct documentation?
Thanks for that - most users use the cPanel user associated with the account:
0 -
Again, thanks for the articles and your time. I actually posted the "fix" to my issue earlier without even realizing it: source /opt/cpanel/ea-php74/enable The contents of "/opt/cpanel/ea-php74/enable": [INDENT=2]export PATH=/opt/cpanel/ea-php74/root/usr/bin:/opt/cpanel/ea-php74/root/usr/sbin${PATH:+:${PATH}} [INDENT=2]export MANPATH=/opt/cpanel/ea-php74/root/usr/share/man:${MANPATH} ***** Maybe that can help the first guy that was having a similar error. Cheers! 0 -
Again, thanks for the articles and your time. I actually posted the "fix" to my issue earlier without even realizing it: source /opt/cpanel/ea-php74/enable The contents of "/opt/cpanel/ea-php74/enable": [INDENT=2]export PATH=/opt/cpanel/ea-php74/root/usr/bin:/opt/cpanel/ea-php74/root/usr/sbin${PATH:+:${PATH}} [INDENT=2]export MANPATH=/opt/cpanel/ea-php74/root/usr/share/man:${MANPATH} ***** Maybe that can help the first guy that was having a similar error. Cheers!
This led me to a solution as well, thanks. We had a xinetd service that ran a script using "/usr/local/bin/php". Changing the path to "/opt/cpanel/ea-php74/root/usr/bin/php" resolved the safelock errors. Obviously the path would need to be manually updated to use a different version of PHP down the road, but this is a sufficient workaround for us.0 -
i aliased php in .bashrc alias php=/opt/cpanel/ea-php74/root/usr/bin/php of course, if it were another version of php i'd use that. unfortunately i have to change all the #! interpreter fields in the php script. it only reads text. 0 -
Hi, I'm having the same problem. I'm running cPanel 106.0.11 on CentOS 7. I have set in /etc/aliases to send mail for apache to a script that will process e-mail bounces. If I send an e-mail to apache@my_domain the script fails (noted in exim_mainlog) and sends back the following: [2022-12-13 10:25:55 -0500] warn [php] safelock: Failed to create a lockfile '/etc/userdatadomains.lock-28c16d1c0139-148bfb5c9-17e78' in the directory '/etc' that isn't writable: Permission denied [2022-12-13 10:25:55 -0500] warn [php] safelock: Failed to create a lockfile '/etc/userdatadomains.lock-833962b56758-148bfb5c9-17e78' in the directory '/etc' that isn't writable: Permission denied [2022-12-13 10:25:55 -0500] warn [php] safelock: waited for lock (/etc/userdatadomains.lock) 90 times PHP Warning: require_once(/home//application/../public_html/includes/pre.bootstrap.globals.php): failed to open stream: Permission denied in /home//cli/bootstrap.php on line 29 PHP Fatal error: require_once(): Failed opening required '/home//application/../public_html/includes/pre.bootstrap.globals.php' (include_path='/home//application/../library:/home//library:.:/opt/cpanel/ea-php74/root/usr/share/pear') in /home//cli/bootstrap.php on line 29 Error in exim_mainlog: 2022-12-14 15:25:11 1p5YJT-0008Rf-Bm ** |/opt/cpanel/ea-php74/root/usr/bin/php -q /home//cli/_process.forwarded.email.bounce.php > R=system_aliases T=address_pipe: Child process of address_pipe transport returned 255 (could mean shell command ended by signal 127 (Unknown signal 127)) from command: /opt/cpanel/ea-php74/root/usr/bin/php 1. this code has been working for years 2. userdatadomains is a cPanel construct and seems to be manipulated somewhere below our code. 3. why is anything trying to write a lock file in /etc ? 4. tried everyting mentioned above, including changing the owner/group of the script to match /etc.[/php] 0 -
@cfl_adm - did you try checking the earlier ideas posted in this thread? If not, it might be best to create a ticket as we never came to an official resolution here. 0 -
Hello cPRex I have same problem,and from this thread i can't find correct solution for this problem. Did i need to paste some command in terminal or? Please check attachment. 0 -
@friv - please create a ticket with our support team. So far, we don't have enough information yet and no one in this thread has been able to create a ticket so we can get more details. 0
Please sign in to leave a comment.
Comments
38 comments