Bug#915671: symlinking /tmp to /run/tmp does not work

2018-12-06 Thread Thorsten Glaser
On Thu, 6 Dec 2018, Serge Belyshev wrote:

> Indeed your version is better.  (Although as a minor nitpick
> bootclean.sh uses [ and -L in other places, so it will look inconsistent)

I’d recommend replacing at least the -L “while here anyway”.

Using test over [ is personal preference, but makes it IMHO
clearer to people not well-versed in shell that it’s an ex‐
ternal command with no magic syntax sugar regarding quoting
(which the Korn shell [[ has) and not comparable with the
normal if (…) in C.

Meow,
//mirabilos
-- 
„Cool, /usr/share/doc/mksh/examples/uhr.gz ist ja ein Grund,
mksh auf jedem System zu installieren.“
-- XTaran auf der OpenRheinRuhr, ganz begeistert
(EN: “[…]uhr.gz is a reason to install mksh on every system.”)



Bug#915671: symlinking /tmp to /run/tmp does not work

2018-12-05 Thread Serge Belyshev
> This is *WRONG*, it will also return 0 if /tmp is not a symlink.

Wow, my bad, sorry for the noise.  Should not have really mixed C and
shell code in my head.

> (Also, use test -h instead of test -L for symlinks, cf. the
> GNU autoconf texinfo manual, *Limitations of Builtins::)
>
> What about this instead:
>
>   if test -h /tmp; then
>   # symbolic link
>   # will be created by mount_tmp if it does not exist
>   test -d /tmp || return 0
>   # but we’ll clean it if it does
>   fi

Indeed your version is better.  (Although as a minor nitpick
bootclean.sh uses [ and -L in other places, so it will look inconsistent)



Bug#915671: symlinking /tmp to /run/tmp does not work

2018-12-05 Thread Thorsten Glaser
On Wed, 5 Dec 2018, Serge Belyshev wrote:

>  clean_tmp() {
> + # Will be created by mount_tmp()
> + [ -L /tmp ] && [ -d /tmp ] || return 0

This is *WRONG*, it will also return 0 if /tmp is not a symlink.

(Also, use test -h instead of test -L for symlinks, cf. the
GNU autoconf texinfo manual, *Limitations of Builtins::)

What about this instead:

if test -h /tmp; then
# symbolic link
# will be created by mount_tmp if it does not exist
test -d /tmp || return 0
# but we’ll clean it if it does
fi

bye,
//mirabilos
-- 
tarent solutions GmbH
Rochusstraße 2-4, D-53123 Bonn • http://www.tarent.de/
Tel: +49 228 54881-393 • Fax: +49 228 54881-235
HRB 5168 (AG Bonn) • USt-ID (VAT): DE122264941
Geschäftsführer: Dr. Stefan Barth, Kai Ebenrett, Boris Esser, Alexander Steeg



Bug#915671: symlinking /tmp to /run/tmp does not work

2018-12-05 Thread Serge Belyshev
Package: initscripts
Version: 2.93-1

In /usr/share/doc/initscripts/README.Debian it is documented that /tmp
could be a symlink to (for example) /run/tmp. This feature was
implemented in version 2.88dsf-13.3 (see
https://salsa.debian.org/debian/sysvinit/commit/3bec14850 ).

But currently it does not work, because bootclean.sh happens to run
before mountall.sh and chokes on a broken symlink.

Another issue is that mount_tmp() function creates the pointed-to
directory with the 755 mode, which is wrong for /tmp.

The following is a possible patch to fix these two problems (first
posted and discussed here:
http://www.chiark.greenend.org.uk/pipermail/debian-init-diversity/2018-December/000544.html
 ):

---
 debian/src/initscripts/lib/init/bootclean.sh   | 2 ++
 debian/src/initscripts/lib/init/mount-functions.sh | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/debian/src/initscripts/lib/init/bootclean.sh 
b/debian/src/initscripts/lib/init/bootclean.sh
index 67e15a66..55f1c8b2 100644
--- a/debian/src/initscripts/lib/init/bootclean.sh
+++ b/debian/src/initscripts/lib/init/bootclean.sh
@@ -52,6 +52,8 @@ checkflagfile()
}
 
 clean_tmp() {
+   # Will be created by mount_tmp()
+   [ -L /tmp ] && [ -d /tmp ] || return 0
# Does not exist
[ -d /tmp ] || return 1
# tmpfs does not require cleaning
diff --git a/debian/src/initscripts/lib/init/mount-functions.sh 
b/debian/src/initscripts/lib/init/mount-functions.sh
index e453f6a8..cd09883f 100644
--- a/debian/src/initscripts/lib/init/mount-functions.sh
+++ b/debian/src/initscripts/lib/init/mount-functions.sh
@@ -627,7 +627,7 @@ mount_tmp ()
# If /tmp is a symlink, make sure the linked-to directory exists.
if [ -L /tmp ] && [ ! -d /tmp ]; then
TMPPATH="$(readlink /tmp)"
-   mkdir -p --mode=755 "$TMPPATH"
+   mkdir -p --mode="$TMP_MODE" "$TMPPATH"
[ -x /sbin/restorecon ] && /sbin/restorecon "$TMPPATH"
fi