Bug#795269: TMPTIME not honored anymore

Josh Triplett josh at joshtriplett.org
Thu Jul 28 07:59:21 BST 2016


Control: tags -1 + patch

On Wed, 12 Aug 2015 10:36:07 -0700 Josh Triplett <josh at joshtriplett.org> wrote:
> On Wed, 12 Aug 2015 15:00:22 +0200 Joey Schulze <joey at infodrom.org> wrote:
> > Package: systemd
> > Version: 215-17+deb8u1
> > 
> > /etc/default/rcS contains a line
> > 
> > # delete files in /tmp during boot older than x days.
> > # '0' means always, -1 or 'infinite' disables the feature
> > #TMPTIME=0
> > TMPTIME=10
> > 
> > This setting is completely ignored by systemd during system boot.
> > 
> > I would consider this a bug and breaks functionality during an upgrade.
> 
> systemd's postinst does a one-time migration from TMPTIME in
> /etc/default/rcS to /etc/tmpfiles.d/tmp.conf , if the former has tmp
> wiping disabled.  That migration, however, doesn't handle the case of
> TMPTIME set to a non-zero, non-infinite value.  It should be possible to
> do so, by copying /usr/lib/tmpfiles.d/tmp.conf to
> /etc/tmpfiles.d/tmp.conf by way of a sed that changes the '-' on the D
> line to ${TMPTIME}d, assuming TMPTIME is numeric.  The following patch
> to systemd.postinst *should* work (not tested).
> 
> --- /var/lib/dpkg/info/systemd.postinst	2015-08-01 05:20:45.000000000 -0700
> +++ /tmp/systemd.postinst	2015-08-12 10:33:21.108381657 -0700
> @@ -72,6 +72,15 @@
>  # /etc/default/rcS where TMPTIME was set to infinite.
>  EOF
>                  ;;
> +            0)
> +                ;;
> +            [0-9]*)
> +                {
> +                    echo "# Automatically generated to migrate TMPTIME=${TMPTIME} from /etc/default/rcS"
> +                    echo
> +                    sed -e "/^D /s/-\$/${TMPTIME%%[^0-9]*}d/" < /usr/lib/tmpfiles.d/tmp.conf
> +                } > /etc/tmpfiles.d/tmp.conf
> +                ;;
>          esac
>      fi
>  fi

A correction to this patch: in addition to changing the '-' at the end
to a time period, this also needs to change the 'D' at the beginning to
'd'.  Otherwise, the directory will still get wiped at boot.  Corrected
patch:

--- /var/lib/dpkg/info/systemd.postinst	2015-08-01 05:20:45.000000000 -0700
+++ /tmp/systemd.postinst	2015-08-12 10:33:21.108381657 -0700
@@ -72,6 +72,15 @@
 # /etc/default/rcS where TMPTIME was set to infinite.
 EOF
                 ;;
+            0)
+                ;;
+            [0-9]*)
+                {
+                    echo "# Automatically generated to migrate TMPTIME=${TMPTIME} from /etc/default/rcS"
+                    echo
+                    sed -e "/^D /s/^D\(.*\)-\$/d\1${TMPTIME%%[^0-9]*}d/" < /usr/lib/tmpfiles.d/tmp.conf
+                } > /etc/tmpfiles.d/tmp.conf
+                ;;
         esac
     fi
 fi



More information about the Pkg-systemd-maintainers mailing list