Hey Otto, Sorry I totally forgot about this. Yes, I do have an updated patch. I actually found there to be some issues with containers which had embedded mysqld forked from the start script so I added an additional check to the 2) version.
Following problems might exist in the future with this version: - When mysqld is called without mysqld_safe - Somebody managed to start mysqld as init So it shouldn't be too much of an issue in general. Lennart On Sun, Feb 21, 2016 at 03:48:38PM +0200, Otto Kekäläinen wrote: > Hello Lennart! > > Do you intend to make one more version of the patch so that it is > perfect and it is safe for me to include it in the next upload? > > Thanks for your help! > > 2016-01-26 11:13 GMT+02:00 Otto Kekäläinen <o...@seravo.fi>: > >> 2) Check the parent process id being 1 > >> In this case parent of the parent because of mysqld_safe > >> # test $(ps -o ppid= -p $(ps -o ppid= -p $PID)) -eq 1 > >> This would work in most cases I can think of. mysqld run by a user > >> or a container would not be started by the init. But seems like a > >> rather complex solution to a fairly simple problem. > > > > Option 2 seems OK. Alternatively we could check processed owned by user > > 'mysql'. > > > > Yes, the solution might be a bit complex, but I am fine with it as > > long as the bash code is well documented and as clean as possible, so > > that potential regressions/bugs in future are easy to track down and > > new people are confident in tweaking the code. Try avoiding long > > oneliners and short-cut code style (to the extend possible, it is > > after all bash scripting).
diff --git a/mysql-server b/mysql-server.new index 52f1292..19b1614 100644 --- a/mysql-server +++ b/mysql-server @@ -16,10 +16,14 @@ MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf" if [ -z "`$MYADMIN ping 2>/dev/null`" ]; then # Really no mysqld or in incorrect authentication in /etc/mysql/debian.cnf user? - # If this occurs and is not a error please report a bug. - if ps cax | grep -q mysqld; then - exit 1 - fi + for PID in $(pgrep mysqld); do + # If the parent of the parent (mysqld_safe) PID is 1 we can assume it's the system + # mysqld and it should have responded to the ping + PPID=$(ps -o ppid= -p $PID) + if [ $(ps -p $PPID -o comm=) = mysqld_safe ]; then + test $(ps -o ppid= -p $PPID) -eq 1 && exit 1 + fi + done else $MYADMIN flush-logs fi
signature.asc
Description: Digital signature