Bugzilla – Bug 8461
MySQL (and therefore SqueezeCenter) fail to start if TMP/TMPDIR env vars present
Last modified: 2009-09-08 09:12:35 UTC
I've been unable to start SC7.2 on an Ubuntu 6.06 LTS system. Today I found the culprit. I have login scripts that set TMP and TMPDIR environment variables for security reasons. If such variables are set, MySQL fails to start and SC7 keeps restarting in hopes that MySQL will come up. This means tha SC7 will start when my machine boots (the init process doesn't set TMP/TMPDIR), but from a command line I could not start/restart SqueezeCenter. The simplest solution is to unset the TMP and TMPDIR environment variables in the init script, e.g. --- /etc/init.d/squeezecenter 2008/03/28 16:19:48 1.1 +++ /etc/init.d/squeezecenter 2008/06/18 01:36:57 @@ -23,6 +23,9 @@ LOGDIR=/var/log/$NAME/ CACHEDIR=/var/lib/$NAME/cache SLIMOPTIONS= +# unset TMP/TMPDIR env vars so mysql won't try using a dir it cannot access +unset TMP +unset TMPDIR # Read config file if it is present.
Matt are you the right person to consider this fix?
I'm not sure this is somethign we should fix... in the case where someone sets a specific TMP dir, that is usually done for a good reason and we don't want to be overwriting that setting. Rather, in the specific case where a user overrides these directories with a TMP and TMPDIR variable that do not work, I think it should be up to them to solve the issue for their system. The much more common reason to replace TMP and TMPDIR is to point them to a memory disk partition, or some other system location where all users have access to write files. In this case, mysqld should start up just fine ... but if we override the TMP and TMPDIR variables, then we start writing files somewhere the sysadmin of that box had not intended. Does that make sense?
I follow your argument. In my experience TMP/TMPDIR are generally used for security reasons (most apps default to /tmp which is world-writable and often tmpfs anyway). That said, you're right that security isn't the only motivator for TMPDIR, and regardless of the user's motivation, SC7 shouldn't ignore TMPDIR if it specifies a workable location. Here's a different approach that takes care of both concerns -- it detects problems with TMPDIR, complains, and unsets TMPDIR *only* if trying to honor TMPDIR would cause MySQL to fail. If an admin has set TMPDIR to a value that SC7 can use, this patch will leave TMPDIR intact. Sound good? --- squeezecenter_safe 2008/06/18 01:33:46 1.1 +++ squeezecenter_safe 2008/06/19 21:33:22 @@ -27,6 +27,14 @@ echo `date "+%F %H:%M:%S"` "squeezecenter_safe started." >> /var/log/squeezecenter/server.log +# make sure TMPDIR won't keep MySQL from starting +if [ "$TMPDIR" != "" ]; then + if [ \( \! -d "$TMPDIR" \) -o \( \! -w "$TMPDIR" \) ]; then + echo `date "+%F %H:%M:%S"` "squeezecenter_safe: TMPDIR \"${TMPDIR}\" not valid, will not be used " >> /var/log/squeezecenter/server.log + unset TMPDIR + fi +fi + while true do # From the Bash Reference Manual:
I wonder if this change can actually be made in slimserver.pl... if I just make the change to the _safe file, it only affects ReadyNas and Debian.
Moving to 7.3 ....
Peter, Sorry its taken a while... Can you look at the new OSDetect code that has been split up into individual modules and work up a patch for that code? Once we have it we'll review the patch and implement it.
Ping peter...
Sorry, guys. I've been pretty busy over here & haven't had time to look at the new code beyond looking at the wiki page. It'll likely be a(nother) week before I can really look at this.
Created attachment 4489 [details] patch against SVN that fixes the problem OK, I found some time to look at this. At first glance, MySQLHelper::startServer() looks like the most appropriate place to add the logic. I haven't tested this with a proper OS build (.deb/.rpm/.dmg/.EXE), but it tests fine with the SVN code (recognizes bad TMPDIR values & rejects them, recognizes good values & respects them).
I just used 'strings' to look at the included Linux binaries; 'alac' also appears to use TMPDIR. With 8.0 moving away from MySQL, maybe the TMPDIR check should reside elsewhere to prevent weird hard-to-debug transcoding problems.
...and references to TMPDIR are sprinkled throughout the CPAN File code...
Matt: can you have a look at the patch in comment 9 and assign this bug an appropriate target?
No longer applicable. Next major release of SqueezeCenter will use SQLLite as DB back end instead of MySQL.