Skip to contentSkip to conversation

package/mysql: add MYSQL_SOCKET variable

PATCH Superseded Floris Bos 3 participants 6 messages Sep 8, 2016 – Sep 9, 2016

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Floris Bos

author
#0 lore raw

PATCH 1/2 package/mysql: add MYSQL_SOCKET variable

Add MYSQL_SOCKET variable with default socket location for other packages to use.

---
 package/mysql/mysql.mk | 3 +++
 1 file changed, 3 insertions(+)
package/mysql/mysql.mk +3 -0
index 534bd97..a9e48ad 100644
@@ -14,6 +14,9 @@ MYSQL_AUTORECONF = YES
 MYSQL_LICENSE = GPLv2
 MYSQL_LICENSE_FILES = README COPYING
 
+# Variable with default socket location for other buildroot packages to use
+MYSQL_SOCKET = /tmp/mysql.sock
+
 MYSQL_CONF_ENV = \
 	ac_cv_sys_restartable_syscalls=yes \
 	ac_cv_path_PS=/bin/ps \
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH 2/2 package/php: Set MySQL socket path

If the buildroot MySQL server is being build set the PHP default MySQL socket path to match what the server is using.

---
 package/php/php.mk | 7 +++++++
 1 file changed, 7 insertions(+)
package/php/php.mk +7 -0
index deaf56e..86a8ca0 100644
@@ -210,6 +210,13 @@ PHP_DEPENDENCIES += unixodbc
 endif
 endif
 
+ifneq ($(BR2_PACKAGE_PHP_EXT_MYSQLI)$(BR2_PACKAGE_PHP_EXT_PDO_MYSQL),)
+ifeq ($(BR2_PACKAGE_MYSQL_SERVER),y)
+# Set default MySQL unix socket to what the MySQL server is using by default
+PHP_CONF_OPTS += --with-mysql-sock=$(MYSQL_SOCKET)
+endif
+endif
+
 define PHP_DISABLE_PCRE_JIT
 	$(SED) '/^#define SUPPORT_JIT/d' $(@D)/ext/pcre/pcrelib/config.h
 endef
Signature · 1 line
2.7.4
#2 lore raw

PATCH 1/2 package/mysql: add MYSQL_SOCKET variable

In reply to Floris Bos

Floris, All,

On 2016-09-08 16:33 +0200, Floris Bos spake thusly:

Quoted 13 lines

Add MYSQL_SOCKET variable with default socket location for other packages to use.

---
 package/mysql/mysql.mk | 3 +++
 1 file changed, 3 insertions(+)
package/mysql/mysql.mk +0 -0
index 534bd97..a9e48ad 100644

package/mysql/mysql.mk MYSQL_AUTORECONF = YES · line 18

Quoted 5 lines
package/mysql/mysql.mk +2 -0
@@ -14,6 +14,9 @@ MYSQL_AUTORECONF = YES
 MYSQL_LICENSE = GPLv2
 MYSQL_LICENSE_FILES = README COPYING
 
+# Variable with default socket location for other buildroot packages to use
+MYSQL_SOCKET = /tmp/mysql.sock

Should we also use that location in the sysv startup script and systemd unit?

If that is the default of mysql, is there a way to force it during configure? I'm a bit uneasy to rely on magic values, in case a future version changes this default location...

Regards,
Yann E. MORIN.

Quoted 10 lines
package/mysql/mysql.mk +0 -0
 MYSQL_CONF_ENV = \
 	ac_cv_sys_restartable_syscalls=yes \
 	ac_cv_path_PS=/bin/ps \
Signature · 6 lines
2.7.4

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
author
#3 lore raw

PATCH 1/2 package/mysql: add MYSQL_SOCKET variable

Quoted 19 lines · Yann E. MORIN

Floris, All,

On 2016-09-08 16:33 +0200, Floris Bos spake thusly:

Quoted 16 lines

Add MYSQL_SOCKET variable with default socket location for other packages to use.

---
  package/mysql/mysql.mk | 3 +++
  1 file changed, 3 insertions(+)
package/mysql/mysql.mk +0 -0
index 534bd97..a9e48ad 100644
@@ -14,6 +14,9 @@ MYSQL_AUTORECONF = YES
  MYSQL_LICENSE = GPLv2
  MYSQL_LICENSE_FILES = README COPYING
 
Quoted 8 lines

package/mysql/mysql.mk MYSQL_AUTORECONF = YES · line 18

Quoted 2 lines
package/mysql/mysql.mk +2 -0
+# Variable with default socket location for other buildroot packages to use
+MYSQL_SOCKET = /tmp/mysql.sock

Should we also use that location in the sysv startup script and systemd unit?

If that is the default of mysql, is there a way to force it during configure? I'm a bit uneasy to rely on magic values, in case a future version changes this default location...

Yes, could force it to use that value with a --with-unix-socket-path= configure option or in the server configuration file.

Do note that while /tmp is the upstream default for all MySQL versions, it is naturally not the safest location for multi-user systems. If an unprivileged user gains access to the system sooner than MySQL is up & running, he could create his own /tmp/mysql.sock and intercept authentication details and queries of clients connecting.
So normal Linux distributions would override the default to a different location, e.g. under /var/run
Something we could also consider, if we want to set the socket path anyway.

OTOH do note that the MySQL branch we currently have has been EOL for 3 years, and newer versions uses a totally different (cmake based) build system.
So personally I am not that keen to spend too much time patching up the current package either.
Might be better to create a brand new one for a later MySQL (or MariaDB) version, but that would take some time.

Yours sincerely,

Floris Bos

#4 lore raw

PATCH 1/2 package/mysql: add MYSQL_SOCKET variable

Hello,

Quoted 6 lines · Floris Bos
Quoted 3 lines

If that is the default of mysql, is there a way to force it during configure? I'm a bit uneasy to rely on magic values, in case a future version changes this default location...

Yes, could force it to use that value with a --with-unix-socket-path= configure option or in the server configuration file.

That would be a good idea.

Quoted 9 lines

Do note that while /tmp is the upstream default for all MySQL versions, it is naturally not the safest location for multi-user systems. If an unprivileged user gains access to the system sooner than MySQL is up & running, he could create his own /tmp/mysql.sock and intercept authentication details and queries of clients connecting.
So normal Linux distributions would override the default to a different location, e.g. under /var/run

So why not use --with-unix-socket-path=/var/run/mysql.sock ?

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
author
#5 lore raw

PATCH 1/2 package/mysql: add MYSQL_SOCKET variable

Quoted 10 lines · Thomas Petazzoni
Quoted 5 lines · Floris Bos
Quoted 3 lines

If that is the default of mysql, is there a way to force it during configure? I'm a bit uneasy to rely on magic values, in case a future version changes this default location...

Yes, could force it to use that value with a --with-unix-socket-path= configure option or in the server configuration file.

That would be a good idea.

Quoted 1 line
Quoted 8 lines
Quoted 7 lines

Do note that while /tmp is the upstream default for all MySQL versions, it is naturally not the safest location for multi-user systems. If an unprivileged user gains access to the system sooner than MySQL is up & running, he could create his own /tmp/mysql.sock and intercept authentication details and queries of clients connecting.
So normal Linux distributions would override the default to a different location, e.g. under /var/run

So why not use --with-unix-socket-path=/var/run/mysql.sock ?

Ok, submitted a v2.
Still needs the second PHP part as well.

However someone else would need to check and test the systemd change, as I am never having much luck getting systemd to just work with buildroot. "Timed out waiting for device dev-console.device" this time and no login prompt.
"Dependency failed for Serial Getty on console"
And no easy way to login by SSH either, given "*** automatic network configuration via DHCP is not compatible with networkd ***"

Yours sincerely,

Floris Bos