Package: systemd
Version: 36-1
Severity: wishlist

systemd does not use the TMPTIME setting in /etc/default/rcS; it uses
/usr/lib/tmpfiles.d/tmp.conf (overridable via /etc/tmpfiles.d/tmp.conf).
Thus, even if a user has configured TMPTIME=infinite (or equialently a
negative value) to prevent removal of files in /tmp, systemd will still
remove files in /tmp.

To avoid this, please consider doing a one-time migration of the TMPTIME
setting to /etc/tmpfiles.d/tmp.conf in systemd's postinst, similar to
the existing migration of the UTC setting.

I've attached a patch which implements this one-time migration.

Note that I intentionally *didn't* migrate other TMPTIME settings
(explicit numbers of days); while straightforward, it seems unnecessary.
If you want /tmp cleared periodically by age, the exact age doesn't
really matter, and systemd has a reasonably conservative default that
I'd rather not override gratuitously.

- Josh Triplett

-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 3.0.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages systemd depends on:
ii  initscripts         2.88dsf-13.11
ii  libacl1             2.2.51-3     
ii  libaudit0           1.7.18-1     
ii  libc6               2.13-21      
ii  libcap2             1:2.22-1     
ii  libcryptsetup1      2:1.3.0-3    
ii  libdbus-1-3         1.4.16-1     
ii  libpam0g            1.1.3-4      
ii  libselinux1         2.1.0-1      
ii  libsystemd-daemon0  36-1         
ii  libsystemd-login0   36-1         
ii  libudev0            172-1        
ii  libwrap0            7.6.q-21     
ii  udev                172-1        
ii  util-linux          2.19.1-5     

Versions of packages systemd recommends:
pn  libpam-systemd  <none>

Versions of packages systemd suggests:
pn  python       2.6.7-3
pn  systemd-gui  <none> 

-- no debconf information
>From 9c1153b936c3aeeb0498039b8365d36c58b49e2a Mon Sep 17 00:00:00 2001
From: Josh Triplett <[email protected]>
Date: Wed, 28 Sep 2011 11:04:12 -0700
Subject: [PATCH] Do a one-time migration of $TMPTIME

setting from /etc/default/rcS to /etc/tmpfiles.d/tmp.conf

If /etc/default/rcS has a TMPTIME setting of "infinite" or equivalent,
migrate it to an /etc/tmpfiles.d/tmp.conf that overrides the default
/usr/lib/tmpfiles.d/tmp.conf and avoids clearing /tmp.
---
 debian/changelog        |    8 ++++++++
 debian/systemd.postinst |    9 ++++++++-
 2 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 4ecac08..0fed8b6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,8 +1,16 @@
 systemd (36-2) unstable; urgency=low
 
+  [ Tollef Fog Heen ]
   * Change the type of the debian-fixup service to oneshot.
     Closes: #642961
 
+  [ Josh Triplett ]
+  * Do a one-time migration of the $TMPTIME setting from /etc/default/rcS to
+    /etc/tmpfiles.d/tmp.conf. If /etc/default/rcS has a TMPTIME setting of
+    "infinite" or equivalent, migrate it to an /etc/tmpfiles.d/tmp.conf that
+    overrides the default /usr/lib/tmpfiles.d/tmp.conf and avoids clearing
+    /tmp.
+
  -- Tollef Fog Heen <[email protected]>  Wed, 28 Sep 2011 20:04:13 +0200
 
 systemd (36-1) unstable; urgency=low
diff --git a/debian/systemd.postinst b/debian/systemd.postinst
index 04f7890..1b0cbc0 100644
--- a/debian/systemd.postinst
+++ b/debian/systemd.postinst
@@ -6,7 +6,7 @@ if [ -n "$2" ]; then
     systemctl daemon-reexec || true
 fi
 
-# Do a one-time migration of the local time setting
+# Do a one-time migration of the local time and TMPTIME settings
 if dpkg --compare-versions "$2" lt "33-1"; then
     if [ -f /etc/default/rcS ]; then
         . /etc/default/rcS
@@ -14,6 +14,13 @@ if dpkg --compare-versions "$2" lt "33-1"; then
     if [ "$UTC" = "no" ] && [ ! -e /etc/adjtime ]; then
         printf "0.0 0 0.0\n0\nLOCAL" > /etc/adjtime
     fi
+    if [ ! -e /etc/tmpfiles.d/tmp.conf ]; then
+        case "$TMPTIME" in
+            -*|infinite|infinity)
+                printf "# Automatically migrated from TMPTIME in /etc/default/rcS\n# Clear /var/tmp as in /usr/lib/tmpfiles.d/tmp.conf, but avoid clearing /tmp\nd /var/tmp 1777 root root 30d\n" > /etc/tmpfiles.d/tmp.conf
+                ;;
+        esac
+    fi
 fi
 
 systemd-machine-id-setup
-- 
1.7.6.3

Reply via email to