Discussion:
[ast-developers] mktemp(1)'s -p not working with O_XATTR dirs
Simon Toedt
2013-12-03 11:28:42 UTC
Permalink
I think I found a bug in mktemp(1)'s -p option:
If I use mktemp(1) with -p in an O_XATTR directory it returns a path
in /tmp instead:

/bin/ksh -c 'builtin mktemp ; touch x1 ; cd -@ x1 ; mktemp -p "$PWD" ;
:'
/tmp/tmp246Y9N0.EZ3

I would've expected the path to be like this one:
/dev/file/xattr@/home/stoe/x1//@//tmp246Y9N0.EZ3

Simon
Glenn Fowler
2013-12-03 16:19:56 UTC
Permalink
i don't really care for the utility of -p but it seems to be working as
advertised
try something like: mktemp myprefix "$PWD" or mktemp "" "$PWD"

mktemp --?p
-p, --default=directory
Use directory if the TMPDIR environment variable is not
defined. Implies --tmp.

gnu man mktemp
-p DIR use DIR as a prefix; implies -t [deprecated]

-t interpret TEMPLATE as a single file name component, relative
to a directory: $TMPDIR, if set; else the
directory specified via -p; else /tmp [deprecated]
Post by Simon Toedt
If I use mktemp(1) with -p in an O_XATTR directory it returns a path
:'
/tmp/tmp246Y9N0.EZ3
Simon
_______________________________________________
ast-users mailing list
ast-users at lists.research.att.com
http://lists.research.att.com/mailman/listinfo/ast-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.research.att.com/pipermail/ast-developers/attachments/20131203/4be314f2/attachment.html>
Simon Toedt
2013-12-03 17:02:33 UTC
Permalink
Post by Glenn Fowler
i don't really care for the utility of -p but it seems to be working as
advertised
try something like: mktemp myprefix "$PWD"
ksh -c 'builtin mktemp ; touch x1 ; cd -@ x1 ; mktemp myprefix "$PWD"
; :'
/tmp/myprejFqre.FAL
Post by Glenn Fowler
or mktemp "" "$PWD"
does not work either
Post by Glenn Fowler
mktemp --?p
-p, --default=directory
Use directory if the TMPDIR environment variable is not
defined. Implies --tmp.
gnu man mktemp
-p DIR use DIR as a prefix; implies -t [deprecated]
-t interpret TEMPLATE as a single file name component, relative
to a directory: $TMPDIR, if set; else the
directory specified via -p; else /tmp [deprecated]
What I wish to archive is to get a temporary file in the O_XATTR dir
so that the temp file disappears when I remove the underlying parent
file.

And I am confused: Why does this not work? I'd expect a temporary file
in /dev/file/xattr@/home/stoe/x1//@//, but instead always get one in
/tmp:
env - /bin/ksh -x -c 'builtin mktemp ; touch x1 ; cd -@ x1 ;
TMPDIR="$PWD" ; mktemp "" "$PWD" ; :'
+ builtin mktemp
+ touch x1
+ cd -@ x1
+ TMPDIR=/dev/file/xattr@/home/stoe/x1//@//
+ mktemp '' /dev/file/xattr@/home/stoe/x1//@//
/tmp/8nR0snQsJI.JID
+ :
env - /bin/ksh -x -c 'builtin mktemp ; touch x1 ; cd -@ x1 ;
TMPDIR="$PWD" ; mktemp ; :'
+ builtin mktemp
+ touch x1
+ cd -@ x1
+ TMPDIR=/dev/file/xattr@/home/stoe/x1//@//
+ mktemp
/tmp/tmp5Sy9yoF.syY
+ :

Simon
Glenn Fowler
2013-12-03 19:13:49 UTC
Permalink
what does this output (-u prints the tmp file but does not create)
--
set -x
mktemp --?-version
cd
print $PWD
mktemp -u "" "$PWD"
touch x1
cd -@ x1
mktemp -u "" "$PWD"
cd -
rm x1
Post by Simon Toedt
Post by Glenn Fowler
i don't really care for the utility of -p but it seems to be working as
advertised
try something like: mktemp myprefix "$PWD"
; :'
/tmp/myprejFqre.FAL
Post by Glenn Fowler
or mktemp "" "$PWD"
does not work either
Post by Glenn Fowler
mktemp --?p
-p, --default=directory
Use directory if the TMPDIR environment variable is not
defined. Implies --tmp.
gnu man mktemp
-p DIR use DIR as a prefix; implies -t [deprecated]
-t interpret TEMPLATE as a single file name component,
relative
Post by Glenn Fowler
to a directory: $TMPDIR, if set; else the
directory specified via -p; else /tmp [deprecated]
What I wish to archive is to get a temporary file in the O_XATTR dir
so that the temp file disappears when I remove the underlying parent
file.
And I am confused: Why does this not work? I'd expect a temporary file
TMPDIR="$PWD" ; mktemp "" "$PWD" ; :'
+ builtin mktemp
+ touch x1
/tmp/8nR0snQsJI.JID
TMPDIR="$PWD" ; mktemp ; :'
+ builtin mktemp
+ touch x1
+ mktemp
/tmp/tmp5Sy9yoF.syY
Simon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.research.att.com/pipermail/ast-developers/attachments/20131203/df1856c2/attachment.html>
Roland Mainz
2013-12-03 23:45:21 UTC
Permalink
Post by Glenn Fowler
Post by Simon Toedt
Post by Glenn Fowler
i don't really care for the utility of -p but it seems to be working as
advertised
try something like: mktemp myprefix "$PWD"
; :'
/tmp/myprejFqre.FAL
Post by Glenn Fowler
or mktemp "" "$PWD"
does not work either
Post by Glenn Fowler
mktemp --?p
-p, --default=directory
Use directory if the TMPDIR environment variable is not
defined. Implies --tmp.
gnu man mktemp
-p DIR use DIR as a prefix; implies -t [deprecated]
-t interpret TEMPLATE as a single file name component, relative
to a directory: $TMPDIR, if set; else the
directory specified via -p; else /tmp [deprecated]
What I wish to archive is to get a temporary file in the O_XATTR dir
so that the temp file disappears when I remove the underlying parent
file.
And I am confused: Why does this not work? I'd expect a temporary file
TMPDIR="$PWD" ; mktemp "" "$PWD" ; :'
+ builtin mktemp
+ touch x1
/tmp/8nR0snQsJI.JID
TMPDIR="$PWD" ; mktemp ; :'
+ builtin mktemp
+ touch x1
+ mktemp
/tmp/tmp5Sy9yoF.syY
what does this output (-u prints the tmp file but does not create)
--
set -x
mktemp --?-version
cd
print $PWD
mktemp -u "" "$PWD"
touch x1
mktemp -u "" "$PWD"
cd -
rm x1
The output of that script looks like this with ast-ksh.2013-10-10 on
Solaris 11/B145/AMD64/64bit:
-- snip --
$ env - ~/bin/ksh xxx.sh
+ mktemp '--?-version'
version mktemp (AT&T Research) 2012-12-12
+ cd
xxx.sh[3]: cd: bad directory
+ print /home/test001/tmp
/home/test001/tmp
+ mktemp -u '' /home/test001/tmp
/home/test001/tmp/4sfuBB7Hll.llT
+ touch x1
+ cd -@ x1
+ mktemp -u '' /dev/file/xattr@/home/test001/tmp/x1//@//
/tmp/hWzxGz8X0v.0vJ
+ cd -
/home/test001/tmp
+ rm x1
-- snip --

----

Bye,
Roland
--
__ . . __
(o.\ \/ /.o) roland.mainz at nrubsig.org
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 3992797
(;O/ \/ \O;)
Roland Mainz
2013-12-04 00:02:58 UTC
Permalink
Post by Roland Mainz
Post by Glenn Fowler
Post by Simon Toedt
Post by Glenn Fowler
i don't really care for the utility of -p but it seems to be working as
advertised
try something like: mktemp myprefix "$PWD"
; :'
/tmp/myprejFqre.FAL
Post by Glenn Fowler
or mktemp "" "$PWD"
does not work either
Post by Glenn Fowler
mktemp --?p
-p, --default=directory
Use directory if the TMPDIR environment variable is not
defined. Implies --tmp.
gnu man mktemp
-p DIR use DIR as a prefix; implies -t [deprecated]
-t interpret TEMPLATE as a single file name component, relative
to a directory: $TMPDIR, if set; else the
directory specified via -p; else /tmp [deprecated]
What I wish to archive is to get a temporary file in the O_XATTR dir
so that the temp file disappears when I remove the underlying parent
file.
And I am confused: Why does this not work? I'd expect a temporary file
TMPDIR="$PWD" ; mktemp "" "$PWD" ; :'
+ builtin mktemp
+ touch x1
/tmp/8nR0snQsJI.JID
TMPDIR="$PWD" ; mktemp ; :'
+ builtin mktemp
+ touch x1
+ mktemp
/tmp/tmp5Sy9yoF.syY
what does this output (-u prints the tmp file but does not create)
--
set -x
mktemp --?-version
cd
print $PWD
mktemp -u "" "$PWD"
touch x1
mktemp -u "" "$PWD"
cd -
rm x1
The output of that script looks like this with ast-ksh.2013-10-10 on
-- snip --
$ env - ~/bin/ksh xxx.sh
+ mktemp '--?-version'
version mktemp (AT&T Research) 2012-12-12
+ cd
xxx.sh[3]: cd: bad directory
+ print /home/test001/tmp
/home/test001/tmp
+ mktemp -u '' /home/test001/tmp
/home/test001/tmp/4sfuBB7Hll.llT
+ touch x1
/tmp/hWzxGz8X0v.0vJ
+ cd -
/home/test001/tmp
+ rm x1
-- snip --
Interesting... the (likely unrelated to the original issue)
"xxx.sh[3]: cd: bad directory" only happens if I launch the shell with
$ env - ~/bin/ksh ... # ... does anyone know why ?

----

Bye,
Roland
--
__ . . __
(o.\ \/ /.o) roland.mainz at nrubsig.org
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 3992797
(;O/ \/ \O;)
Glenn Fowler
2013-12-04 03:21:10 UTC
Permalink
env - ... unsets HOME among others causing cd with no args to fail as it
should
Post by Roland Mainz
On Tue, Dec 3, 2013 at 8:13 PM, Glenn Fowler <glenn.s.fowler at gmail.com>
On Tue, Dec 3, 2013 at 12:02 PM, Simon Toedt <simon.toedt at gmail.com>
On Tue, Dec 3, 2013 at 5:19 PM, Glenn Fowler <glenn.s.fowler at gmail.com
Post by Glenn Fowler
i don't really care for the utility of -p but it seems to be working
as
Post by Glenn Fowler
advertised
try something like: mktemp myprefix "$PWD"
; :'
/tmp/myprejFqre.FAL
Post by Glenn Fowler
or mktemp "" "$PWD"
does not work either
Post by Glenn Fowler
mktemp --?p
-p, --default=directory
Use directory if the TMPDIR environment variable is not
defined. Implies --tmp.
gnu man mktemp
-p DIR use DIR as a prefix; implies -t [deprecated]
-t interpret TEMPLATE as a single file name component, relative
to a directory: $TMPDIR, if set; else the
directory specified via -p; else /tmp [deprecated]
What I wish to archive is to get a temporary file in the O_XATTR dir
so that the temp file disappears when I remove the underlying parent
file.
And I am confused: Why does this not work? I'd expect a temporary file
TMPDIR="$PWD" ; mktemp "" "$PWD" ; :'
+ builtin mktemp
+ touch x1
/tmp/8nR0snQsJI.JID
TMPDIR="$PWD" ; mktemp ; :'
+ builtin mktemp
+ touch x1
+ mktemp
/tmp/tmp5Sy9yoF.syY
what does this output (-u prints the tmp file but does not create)
--
set -x
mktemp --?-version
cd
print $PWD
mktemp -u "" "$PWD"
touch x1
mktemp -u "" "$PWD"
cd -
rm x1
The output of that script looks like this with ast-ksh.2013-10-10 on
-- snip --
$ env - ~/bin/ksh xxx.sh
+ mktemp '--?-version'
version mktemp (AT&T Research) 2012-12-12
+ cd
xxx.sh[3]: cd: bad directory
+ print /home/test001/tmp
/home/test001/tmp
+ mktemp -u '' /home/test001/tmp
/home/test001/tmp/4sfuBB7Hll.llT
+ touch x1
/tmp/hWzxGz8X0v.0vJ
+ cd -
/home/test001/tmp
+ rm x1
-- snip --
Interesting... the (likely unrelated to the original issue)
"xxx.sh[3]: cd: bad directory" only happens if I launch the shell with
$ env - ~/bin/ksh ... # ... does anyone know why ?
----
Bye,
Roland
--
__ . . __
(o.\ \/ /.o) roland.mainz at nrubsig.org
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 3992797
(;O/ \/ \O;)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.research.att.com/pipermail/ast-developers/attachments/20131203/619eb82d/attachment-0001.html>
Roland Mainz
2013-12-04 07:06:39 UTC
Permalink
On Tue, Dec 3, 2013 at 7:02 PM, Roland Mainz <roland.mainz at nrubsig.org>
Post by Roland Mainz
Post by Roland Mainz
On Tue, Dec 3, 2013 at 5:19 PM, Glenn Fowler
<glenn.s.fowler at gmail.com>
Post by Glenn Fowler
i don't really care for the utility of -p but it seems to be working as
advertised
try something like: mktemp myprefix "$PWD"
[snip]
Post by Roland Mainz
Post by Roland Mainz
The output of that script looks like this with ast-ksh.2013-10-10 on
-- snip --
$ env - ~/bin/ksh xxx.sh
+ mktemp '--?-version'
version mktemp (AT&T Research) 2012-12-12
+ cd
xxx.sh[3]: cd: bad directory
+ print /home/test001/tmp
/home/test001/tmp
+ mktemp -u '' /home/test001/tmp
/home/test001/tmp/4sfuBB7Hll.llT
+ touch x1
/tmp/hWzxGz8X0v.0vJ
+ cd -
/home/test001/tmp
+ rm x1
-- snip --
Interesting... the (likely unrelated to the original issue)
"xxx.sh[3]: cd: bad directory" only happens if I launch the shell with
$ env - ~/bin/ksh ... # ... does anyone know why ?
env - ... unsets HOME among others causing cd with no args to fail as it
should
Ok...
$ ~/bin/ksh -c 'rm x1 ; touch x1 ; cd -@ x1 ; ls -l ; true >
/dev/file/xattr@/home/test001/tmp/x1//@//foo ; ls -l ; true'
total 2
-r--r--r-- 1 root root 156 Dec 4 08:03 SUNWattr_ro
-rw-r--r-- 1 root root 472 Dec 4 08:03 SUNWattr_rw
total 3
-rw-r--r-- 1 test001 staff 0 Dec 4 08:03 foo
-r--r--r-- 1 root root 156 Dec 4 08:03 SUNWattr_ro
-rw-r--r-- 1 root root 472 Dec 4 08:03 SUNWattr_rw

----

Bye,
Roland
--
__ . . __
(o.\ \/ /.o) roland.mainz at nrubsig.org
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 3992797
(;O/ \/ \O;)
Loading...