Bugzilla – Bug 687
SlimServer truncates config file on startup
Last modified: 2008-12-18 11:55:14 UTC
On the Nov 26 build, installed on RedHat 8.0 from the RPM distribution. When SlimServer runs, it is truncating the /etc/slimserver.conf file to 0 bytes. This initial instance of SlimServer runs without any problems, however if SlimServer is restarted, it naturally reverts to defaults (as it has no configuration file). This has been reproduced with my normal slimserver.conf file, as well as with a clean configuration. The Nov 25 build does not have this problem.
Correction, I have also reproduced this behaviour on the Nov 20 build. Seems my slimserver.conf file was owned by root and therefore unwriteable by the actual Slimserver process (which runs as "slimserver"). Having not needed to make any real configuration changes lately, this had gone unnoticed. If I chown the slimserver.conf file to the slimserver user, I get the same behaviour on the Nov 20 build. Further testing shows that if I run slimserver.pl directly (rather than using the init.d script), the problem does not occur, so I am presuming that the issue must live eitehr in the init.d script, or in the way that slimserver.pl is called from that script.... Will dig further and report back on what I find.
Further testing now shows the problem only occurs when running slimserver as a non-root user. If I run slimserver.pl directly from the bash prompt, even providing the arguments that would normally be given through the init.d script, everything works just fine. The slimserver.conf is read from and written to normally. In fact, if I go into the init.d/slimserver script and remote the "daemon" directive, the problem goes away (but of course, SlimServer starts up and runs as root). If I su to a non-root account and run slimserver.pl directly, the /etc/slimserver.conf file again ends up truncated. It does not seem to matter what non-root account I su to (as long as it has write privileges to the conf file). Note as well that this process of truncating the file appears to occur with every attempt to write to the file. In other words, the slimserver.conf file remains at zero bytes no matter what I do through the process, and in fact if I copy in a correct slimserver.conf file while SlimServer is running, and attempt to modify the configuration will again result in a 0-byte file. By contrast, if I start SlimServer as root with a 0-byte file, the file is very quickly populated with default values, resulting in a size of approximately 7585 bytes. If I run SlimServer as any other user, I get a consistely emtpy configuration file.
the rpm is designed to run via the init.d script. If you run as a user, the conf file should default to ~/.slimserver.pref. if you are forcing it to do something it wasn't designed to do (IE copying the init.d arguments), and expecting slimserver to go against Linux's design for permissions...well, really this isn't very clear. as a user, just let it run without --prefsfile. that way eash user get their own set of prefs. OR, if you really want to, change the permissions of /etc/slimserver.conf and make ~/.slimserver.pref links back to it.
Well, I feel incredibly stupid... Turns out my root filesystem was low on disk space. There is about 10mb of space reserved so that root can still function, which is why it was working fine as root. For all non-root users, however, no further disk space could be allocated, hence the 0-byte file whenever SlimServer tried to write any changes to the slimserver.conf file... <sigh> My configuration has the /usr and /var in separate partitions, and they both have *plenty* of space left, so this would explain why the problem wasn't immediately obvious. At any rate, freed up some space and everything's fine now. As a minor enhancement resulting from this, however, perhaps it would be a good idea to put some kind of obvious error message somewhere when the config file can't be written... I wasn't actually getting a "Can't write" message, even with d_prefs turned on. The messages seemed to think that it was writing the config file just fine at every point. It wasn't until I actually su'ed to the "slimserver" user and tried to edit the slimserver.conf file manually that I got a message about being out of disk space.
It appears that it will actually default to using the /etc/slimserver.conf file if it already exists. During testing on this, I frequently ran "slimserver.pl" directly and it used the existing .conf file. From looking at the code in Prefs.pm, under the prefsFile sub, it seems that it only uses the .slimserver.pref if /etc/slimserver.conf is not found. At any rate, sorry for not being clear in some of my earlier descriptions. I wasn't really trying to do anything in my later comments but diagnose the problem by trying different scenarios. I normally run the init.d script with all default startup parameters, and never even paid much attention to these files until I actually started losing my config information...
Routine bug db maintenance; removing old versions which cause confusion. I apologize for the inconvenience.