clone 285871 -1 -2 retitle 285871 xdm: logrotate script needs improvement severity 285871 normal retitle -1 xdm: incapable of reopening its logfile, preventing sane log rotation retitle -2 xdm: sets up signal handlers that call unsafe functions tag -1 = upstream tag -2 = upstream thanks On Fri, Mar 25, 2005 at 11:26:17PM +0000, Andrew Suffield wrote: > While xdm is running, edit /var/lib/logrotate/status and set the date > on /var/log/xdm.log to a couple of days ago, then run: > > logrotate /etc/logrotate.conf > > as root. This causes a new rotation, rather than having to wait for > it. > > After this, you should see: > > asuffield@cyclone:~$ ls -l /var/log/xdm.log* > -rw-r----- 1 root adm 0 Mar 25 23:16 /var/log/xdm.log > -rw-r----- 1 root adm 1573 Mar 25 23:16 /var/log/xdm.log.1.gz > > asuffield@cyclone:~$ sudo lsof | grep var/log/xdm > xdm 1965 root 2w REG 3,6 8376 179574 /var/log/xdm.log.1 (deleted) > XFree86 2023 root 2w REG 3,6 8376 179574 /var/log/xdm.log.1 (deleted) > xdm 2024 root 2w REG 3,6 8376 179574 /var/log/xdm.log.1 (deleted) > > xdm will now proceed to log into this deleted file. Eventually > xdm.log.1.gz will be rotated out of existance, and xdm will continue > logging into the deleted file, leaving you with no xdm logs at all. Fixing this doesn't require just an updated logrotate script; in fact, xdm never reopens its log file (which is just stderr dup2()ed). While looking further into this (with some help from Andrew Suffield and Adam Heath on IRC), I learned that signal handling in general in xdm appears to be done a bit carelessly -- signal handlers call functions that are not guaranteed to be safe (like vsnprintf(), which is used by the logging functions like Debug() and LogInfo() in error.c, and called from signal handlers like RescanNotify() in dm.c). The quick-and-dirty way to fix this is just to bolt a new signal handler onto xdm, for SIGUSR2 (SIGUSR1 is already used internally by xdm as a crude means of IPC between a parent xdm daemon and its children). The good way to fix this is to do the above and tidy up xdm's signal handling in general while I'm at it, but the code has nice(?) features like nonlocal exits from signal handlers, and I'm going to have to curl up with _APUE_ before I can make much more progress on that front. I'll also very much want someone to audit my changes. With the sarge freeze imminent, I'm afraid the quick-and-dirty fix may be the only feasible one for the time being. -- G. Branden Robinson | Humor is a rubber sword -- it Debian GNU/Linux | allows you to make a point without branden@debian.org | drawing blood. http://people.debian.org/~branden/ | -- Mary Hirsch
Attachment:
signature.asc
Description: Digital signature