diff mbox

[v3,1/2] package/mysql: add MYSQL_SOCKET variable

Message ID 1473437448-27903-1-git-send-email-bos@je-eigen-domein.nl
State Changes Requested
Headers show

Commit Message

Floris Bos Sept. 9, 2016, 4:10 p.m. UTC
Add MYSQL_SOCKET variable with MySQL socket location

v3: fix systemd missing user
v2: move socket to /run/mysql/mysql.sock
chmod 755 /run/mysql to allow users access to it
---
 package/mysql/S97mysqld      | 2 +-
 package/mysql/mysql.mk       | 4 ++++
 package/mysql/mysqld.service | 3 +++
 3 files changed, 8 insertions(+), 1 deletion(-)

Comments

Thomas Petazzoni Sept. 11, 2016, 7:32 p.m. UTC | #1
Hello,

On Fri,  9 Sep 2016 18:10:47 +0200, Floris Bos wrote:
> Add MYSQL_SOCKET variable with MySQL socket location
> 
> v3: fix systemd missing user
> v2: move socket to /run/mysql/mysql.sock
> chmod 755 /run/mysql to allow users access to it

This patch lacks your Signed-off-by line.

Also, this patch defines the MYSQL_SOCKET variable, which in PATCH 2/2
gets used in the PHP package. Sharing variables between packages
doesn't work in all situations, so we usually refrain from doing so.
Maybe we should document in the manual which cases work and which cases
don't work. Cc'ing Arnout, who knows quite a bit about this topic :)

Thanks,

Thomas
Floris Bos Sept. 11, 2016, 8:25 p.m. UTC | #2
On 09/11/2016 09:32 PM, Thomas Petazzoni wrote:
> Hello,
>
> On Fri,  9 Sep 2016 18:10:47 +0200, Floris Bos wrote:
>> Add MYSQL_SOCKET variable with MySQL socket location
>>
>> v3: fix systemd missing user
>> v2: move socket to /run/mysql/mysql.sock
>> chmod 755 /run/mysql to allow users access to it
> This patch lacks your Signed-off-by line.
>
> Also, this patch defines the MYSQL_SOCKET variable, which in PATCH 2/2
> gets used in the PHP package. Sharing variables between packages
> doesn't work in all situations, so we usually refrain from doing so.
> Maybe we should document in the manual which cases work and which cases
> don't work. Cc'ing Arnout, who knows quite a bit about this topic :)

Ah, didn't know.
Thought that always all package .mk files were included, and that 
variable expansion was deferred until actual use when created with the = 
operator (as opposed to := )

Anyway, if you prefer to do without variable, and have the value 
hardcoded at both places, that's fine with me as well.


Yours sincerely,

Floris Bos
Thomas Petazzoni Sept. 11, 2016, 8:54 p.m. UTC | #3
Hello,

On Sun, 11 Sep 2016 22:25:08 +0200, Floris Bos wrote:
> On 09/11/2016 09:32 PM, Thomas Petazzoni wrote:
> > Hello,
> >
> > On Fri,  9 Sep 2016 18:10:47 +0200, Floris Bos wrote:  
> >> Add MYSQL_SOCKET variable with MySQL socket location
> >>
> >> v3: fix systemd missing user
> >> v2: move socket to /run/mysql/mysql.sock
> >> chmod 755 /run/mysql to allow users access to it  
> > This patch lacks your Signed-off-by line.
> >
> > Also, this patch defines the MYSQL_SOCKET variable, which in PATCH 2/2
> > gets used in the PHP package. Sharing variables between packages
> > doesn't work in all situations, so we usually refrain from doing so.
> > Maybe we should document in the manual which cases work and which cases
> > don't work. Cc'ing Arnout, who knows quite a bit about this topic :)  
> 
> Ah, didn't know.
> Thought that always all package .mk files were included, and that 
> variable expansion was deferred until actual use when created with the = 
> operator (as opposed to := )
> 
> Anyway, if you prefer to do without variable, and have the value 
> hardcoded at both places, that's fine with me as well.

Just discussed this with Yann, and this particular usage is OK, so
patches are good.

Can you resend with:

 1. Your Signed-off-by line added.

 2. The changelog below the "---" sign (which itself should be after
    the Signed-off-by line). See
    https://patchwork.ozlabs.org/patch/668485/ for a good example.

Thanks!

Thomas
diff mbox

Patch

diff --git a/package/mysql/S97mysqld b/package/mysql/S97mysqld
index 1d87e68..5a660e9 100644
--- a/package/mysql/S97mysqld
+++ b/package/mysql/S97mysqld
@@ -9,7 +9,7 @@  case "$1" in
 
 		# mysqld runs as user mysql, but /run is only writable by root
 		# so create a subdirectory for mysql.
-		install -d -o mysql -g root -m 0700 /run/mysql
+		install -d -o mysql -g root -m 0755 /run/mysql
 
 		# We don't use start-stop-daemon because mysqld has
 		# its own wrapper script.
diff --git a/package/mysql/mysql.mk b/package/mysql/mysql.mk
index 534bd97..7af4711 100644
--- a/package/mysql/mysql.mk
+++ b/package/mysql/mysql.mk
@@ -14,6 +14,9 @@  MYSQL_AUTORECONF = YES
 MYSQL_LICENSE = GPLv2
 MYSQL_LICENSE_FILES = README COPYING
 
+# Unix socket. This variable can also be consulted by other buildroot packages
+MYSQL_SOCKET = /run/mysql/mysql.sock
+
 MYSQL_CONF_ENV = \
 	ac_cv_sys_restartable_syscalls=yes \
 	ac_cv_path_PS=/bin/ps \
@@ -31,6 +34,7 @@  MYSQL_CONF_OPTS = \
 	--without-readline \
 	--with-low-memory \
 	--enable-thread-safe-client \
+	--with-unix-socket-path=$(MYSQL_SOCKET) \
 	--disable-mysql-maintainer-mode
 
 # host-mysql only installs what is needed to build mysql, i.e. the
diff --git a/package/mysql/mysqld.service b/package/mysql/mysqld.service
index 2ded9c2..c9e5e42 100644
--- a/package/mysql/mysqld.service
+++ b/package/mysql/mysqld.service
@@ -5,6 +5,9 @@  Description=MySQL database server
 ExecStartPre=/bin/sh -c 'test -d /var/mysql/mysql || mysql_install_db --user=mysql --ldata=/var/mysql'
 ExecStart=/usr/bin/mysqld_safe
 Restart=always
+User=mysql
+RuntimeDirectory=mysql
+RuntimeDirectoryMode=0755
 
 [Install]
 WantedBy=multi-user.target