Apparmor causes failure when mysql.sock.lock configured to live in non-standard directory (e.g. under /opt)

Bug #1928569 reported by Akanksha Bagmar
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
mysql-8.0 (Ubuntu)
Expired
Undecided
Unassigned

Bug Description

Ubuntu release -20.04
issue -
I am using XAMPP server for mysql programs with php, but mysql is not connecting, instead it giving me error as:
Fatal error: Uncaught Error: Call to undefined function mysql_connect()

ProblemType: Package
DistroRelease: Ubuntu 20.04
Package: mysql-server-8.0 8.0.25-0ubuntu0.20.04.1
ProcVersionSignature: Ubuntu 5.8.0-53.60~20.04.1-generic 5.8.18
Uname: Linux 5.8.0-53-generic x86_64
ApportVersion: 2.20.11-0ubuntu27.16
AptOrdering:
 mysql-client-8.0:amd64: Install
 mysql-server-8.0:amd64: Install
 mysql-server-core-8.0:amd64: Install
 NULL: ConfigurePending
Architecture: amd64
CasperMD5CheckResult: skip
Date: Sat May 15 17:34:34 2021
ErrorMessage: installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1
InstallationDate: Installed on 2020-08-14 (274 days ago)
InstallationMedia: Ubuntu 20.04.1 LTS "Focal Fossa" - Release amd64 (20200731)
Logs.var.log.daemon.log:

MySQLConf.etc.mysql.conf.d.mysql.cnf: [mysql]
MySQLConf.etc.mysql.conf.d.mysqldump.cnf:
 [mysqldump]
 quick
 quote-names
 max_allowed_packet = 16M
ProcCmdline: BOOT_IMAGE=/vmlinuz-5.8.0-53-generic root=/dev/mapper/vgubuntu-root ro quiet splash vt.handoff=7
Python3Details: /usr/bin/python3.8, Python 3.8.5, python3-minimal, 3.8.2-0ubuntu2
PythonDetails: N/A
RelatedPackageVersions:
 dpkg 1.19.7ubuntu3
 apt 2.0.2ubuntu0.2
SourcePackage: mysql-8.0
Title: package mysql-server-8.0 8.0.25-0ubuntu0.20.04.1 failed to install/upgrade: installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1
UpgradeStatus: No upgrade log present (probably fresh install)
modified.conffile..etc.mysql.mysql.cnf: [modified]
mtime.conffile..etc.mysql.mysql.cnf: 2021-05-04T19:27:39.765899

Revision history for this message
Akanksha Bagmar (akankshabagmar) wrote :
tags: removed: need-duplicate-check
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Hi Akanksha,
in your logs I see

mysqld is running as pid 9221
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.

Which implies it failed to start/restart on an upgrae,.
When looking for errors I found:

2021-05-16T07:06:41.654237Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2021-05-16T07:06:41.657827Z 0 [ERROR] [MY-010273] [Server] Could not create unix socket lock file /opt/lampp/var/mysql/mysql.sock.lock.
2021-05-16T07:06:41.658385Z 0 [ERROR] [MY-010268] [Server] Unable to setup unix socket lock file.

Which shows us what failed and made me suspicious as this is an uncommon path that was used.
With that in mind I found

[ 1737.039283] audit: type=1400 audit(1621080213.808:139): apparmor="DENIED" operation="mknod" profile="/usr/sbin/mysqld" name="/opt/lampp/var/mysql/mysql.sock.lock" pid=10896 comm="mysqld" requested_mask="c" denied_mask="c" fsuid=126 ouid=126

And now things made sense, if you configure "too far away" from the default config you have to modify the apparmor profile as well to allow that.
By default apparmor tries to isolate the mysqld process to protect your system and in this case the new path that you have configured is blocked by that isolation.

If you have changed that (either allowed the path or configured it to a common one that is allowed by default) the upgrade will likely work again.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Thank you for your report.

This looks like a local configuration problem, rather than a bug in Ubuntu.

You can find pointers to get help for this sort of problem here: http://www.ubuntu.com/support/community

Since we use this bug tracker to track bugs in Ubuntu, rather than configuration problems, I'm marking this bug as Invalid. This helps us to focus on fixing bugs in Ubuntu.

If you believe that this is really a bug, then you may find it helpful to read "How to report bugs effectively" http://www.chiark.greenend.org.uk/~sgtatham/bugs.html. We'd be grateful if you would then provide a more complete description of the problem, explain why you believe this is a bug in Ubuntu rather than a problem specific to your system, and then change the bug status back to New.

Changed in mysql-8.0 (Ubuntu):
status: New → Incomplete
Bryce Harrington (bryce)
summary: - package mysql-server-8.0 8.0.25-0ubuntu0.20.04.1 failed to
- install/upgrade: installed mysql-server-8.0 package post-installation
- script subprocess returned error exit status 1
+ Apparmor causes failure when mysql.sock.lock configured to live in non-
+ standard directory (e.g. under /opt)
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for mysql-8.0 (Ubuntu) because there has been no activity for 60 days.]

Changed in mysql-8.0 (Ubuntu):
status: Incomplete → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.