From owner-freebsd-stable@FreeBSD.ORG Thu Sep 30 07:56:18 2010 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 43417106566C for ; Thu, 30 Sep 2010 07:56:18 +0000 (UTC) (envelope-from jdc@koitsu.dyndns.org) Received: from qmta01.emeryville.ca.mail.comcast.net (qmta01.emeryville.ca.mail.comcast.net [76.96.30.16]) by mx1.freebsd.org (Postfix) with ESMTP id 280278FC0C for ; Thu, 30 Sep 2010 07:56:17 +0000 (UTC) Received: from omta17.emeryville.ca.mail.comcast.net ([76.96.30.73]) by qmta01.emeryville.ca.mail.comcast.net with comcast id CvF11f0041afHeLA1vwH9s; Thu, 30 Sep 2010 07:56:17 +0000 Received: from koitsu.dyndns.org ([98.248.41.155]) by omta17.emeryville.ca.mail.comcast.net with comcast id CvwG1f00A3LrwQ28dvwGEu; Thu, 30 Sep 2010 07:56:17 +0000 Received: by icarus.home.lan (Postfix, from userid 1000) id 88B719B418; Thu, 30 Sep 2010 00:56:16 -0700 (PDT) Date: Thu, 30 Sep 2010 00:56:16 -0700 From: Jeremy Chadwick To: Alex Dupre Message-ID: <20100930075616.GA11519@icarus.home.lan> References: <20100930065151.GA9634@icarus.home.lan> <20100930070333.GU87427@hoeg.nl> <20100930072819.GA10678@icarus.home.lan> <4CA43C91.5040000@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4CA43C91.5040000@FreeBSD.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Ed Schouten , freebsd-stable@freebsd.org Subject: Re: mysqld_safe holding open a pty/tty on FreeBSD (7.x and 8.x) X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Sep 2010 07:56:18 -0000 On Thu, Sep 30, 2010 at 09:30:25AM +0200, Alex Dupre wrote: > Jeremy Chadwick ha scritto: > > Until rc(8) can be updated to support daemon(8) natively, > > This would be the Right Thing IMHO. > > > the ~76 ports > > which Do The Wrong Thing(tm) should get updated to do it this way. Ones > > like mysqlXX-server should be placed high on the priority list given > > their popularity/importance. > > If you have an already tested patch for the mysql rc script, I'll commit > it asap. Just finished it for databases/mysql51-server. Tested on RELENG_8 with the below variables in use, and also tested with mysql_limits="yes". mysql_enable="yes" mysql_dbdir="/storage/mysql" mysql_args="--skip-innodb" Should work fine on RELENG_7 since it has /usr/sbin/daemon too. Tested using stop, start, and restart. I can test a reboot if you'd like, just let me know. Validation: icarus# /usr/local/etc/rc.d/mysql-server stop Stopping mysql. Waiting for PIDS: 12015. icarus# /usr/local/etc/rc.d/mysql-server start Starting mysql. icarus# ps -auxwww -U mysql USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND mysql 12271 0.0 0.0 8228 1600 ?? Is 12:53AM 0:00.01 /bin/sh /usr/local/bin/mysqld_safe --defaults-extra-file=/storage/mysql/my.cnf --user=mysql --datadir=/storage/mysql --pid-file=/storage/mysql/icarus.home.lan.pid --skip-innodb mysql 12352 0.0 0.3 35100 11032 ?? I 12:53AM 0:00.02 [mysqld] I'll also take this opportunity to point this out, since I'm certain someone will mention it: daemon's -u argument would be ideal except that it """breaks""" when using rc.subr's xxx_user variable (which uses su(1) to change credentials/spawn $command). With both in use, daemon then fails on setusercontext(), which in turn fails because of initgroups() returning EPERM -- and this does make sense. So let's not use daemon -u in rc.subr for the time being. The diff is pretty obvious/simple (2 line change), so the other databases/mysqlXX-server ports can be upgraded in the same manner. --- files/mysql-server.sh.in.orig 2010-03-27 03:24:53.000000000 -0700 +++ files/mysql-server.sh.in 2010-09-30 00:45:38.000000000 -0700 @@ -35,8 +35,8 @@ mysql_user="mysql" mysql_limits_args="-e -U ${mysql_user}" pidfile="${mysql_dbdir}/`/bin/hostname`.pid" -command="%%PREFIX%%/bin/mysqld_safe" -command_args="--defaults-extra-file=${mysql_dbdir}/my.cnf --user=${mysql_user} --datadir=${mysql_dbdir} --pid-file=${pidfile} ${mysql_args} > /dev/null 2>&1 &" +command="/usr/sbin/daemon" +command_args="-c -f /usr/local/bin/mysqld_safe --defaults-extra-file=${mysql_dbdir}/my.cnf --user=${mysql_user} --datadir=${mysql_dbdir} --pid-file=${pidfile} ${mysql_args}" procname="%%PREFIX%%/libexec/mysqld" start_precmd="${name}_prestart" start_postcmd="${name}_poststart" -- | Jeremy Chadwick jdc@parodius.com | | Parodius Networking http://www.parodius.com/ | | UNIX Systems Administrator Mountain View, CA, USA | | Making life hard for others since 1977. PGP: 4BD6C0CB |