Bug 16024

Summary: chroot should clear TMPDIR environment variable
Product: Sisyphus Reporter: Michael Shigorin <mike>
Component: coreutilsAssignee: placeholder <placeholder>
Status: CLOSED FIXED QA Contact: qa-sisyphus
Severity: normal    
Priority: P2 CC: glebfm, ldv, placeholder
Version: unstable   
Hardware: all   
OS: Linux   
See Also: https://bugzilla.altlinux.org/show_bug.cgi?id=40041

Description Michael Shigorin 2008-06-14 17:58:06 MSD
While performing rescue jobs in a chroot (changing rootfs type):

# mkinitrd --help
/sbin/mkinitrd: line 1557: cannot create temp file for here document: No such file or directory

# set | grep T.*MP
TMP=/tmp/.private/root
TMPDIR=/tmp/.private/root
# ls /tmp/.private/root
ls: cannot access /tmp/.private/root: No such file or directory

Indeed.
Comment 1 Dmitry V. Levin 2008-06-14 18:07:42 MSD
(In reply to comment #0)
> While performing rescue jobs in a chroot (changing rootfs type):

This is not a regular operation, right?

> # mkinitrd --help
> /sbin/mkinitrd: line 1557: cannot create temp file for here document: No such file or directory
> 
> # set | grep T.*MP
> TMP=/tmp/.private/root
> TMPDIR=/tmp/.private/root
> # ls /tmp/.private/root
> ls: cannot access /tmp/.private/root: No such file or directory
> 
> Indeed.

There are many ways to fool yourself.
Try "env TMPDIR= chroot" next time.
Comment 2 Michael Shigorin 2008-06-14 22:33:20 MSD
(In reply to comment #1)
> > While performing rescue jobs in a chroot (changing rootfs type):
> This is not a regular operation, right?
It is one of operations when:
- the stress is usually above usual;
- weird diagnostics don't really help.

> > # mkinitrd --help
> > /sbin/mkinitrd: line 1557: cannot create temp file for here document: No such file or directory
> > ls: cannot access /tmp/.private/root: No such file or directory
> There are many ways to fool yourself.
> Try "env TMPDIR= chroot" next time.
I'll sure forget it 'till next time.

Rather wanted to draw your attention to the fact that corner cases like this do matter; is it unreasonable to request that directory existence[/writability] check be performed before setting TMP/TMPDIR?
Comment 3 Dmitry V. Levin 2008-06-14 23:36:11 MSD
Lets handle this issue in chroot(1).
Comment 4 Michael Shigorin 2008-06-15 12:05:21 MSD
Thanks in advance!
Comment 5 Dmitry V. Levin 2008-08-30 03:26:54 MSD
6.11-alt1-2-gc4aa447
Comment 6 Michael Shigorin 2008-09-01 01:02:56 MSD
Your advance has arrived :-)