GNU bug report logs - #6330
Feature request: mktemp creates named pipes

Previous Next

Package: coreutils;

Reported by: Sebastien Andre <wayana <at> users.sourceforge.net>

Date: Wed, 2 Jun 2010 15:47:02 UTC

Severity: normal

Tags: notabug

Merged with 6900

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

Full log


Message #11 received at 6330 <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: Sebastien Andre <wayana <at> users.sourceforge.net>
Cc: 6330 <at> debbugs.gnu.org
Subject: Re: bug#6330: Feature request: mktemp creates named pipes
Date: Wed, 02 Jun 2010 10:14:41 -0600
[Message part 1 (text/plain, inline)]
On 06/02/2010 04:08 AM, Sebastien Andre wrote:
> Hello guys!
> 
> When needing a temporary named pipe in shell scripts, I've often been
> writing the following function:
> 
> mktempfifo() {
>     local path=$(mktemp -t)
>     rm "$path"
>     mkfifo -m 0600 "$path"
>     echo "$path"
> }

First off, thanks for the suggestion.

What's wrong with the example given in the manual (info coreutils
mktemp), as adjusted to your usage pattern:

mktempfifo() {
    local dir
    dir=$(mktemp -t -d) || return 1
    mkfifo -m 0600 "$dir/fifo" || return 1
    echo "$dir/fifo"
}

other than the fact that you have to remember to also remove the
temporary directory?  And if you need to create more than one secure
temporary object, it becomes a much easier paradigm to create a single
secure directory in which to place all the other objects, and use a
simple 'rm -rf "$tmpdir"' in your cleanup paths.  That's how coreutils
'make check' works - every test is run inside its own temporary
directory, and within the body of the test, there is no need to worry
about name collisions from external processes.

> 
> I was wondering if anybody would be interested in having an option -p --pipe
> (or -f --fifo since -p is deprecated)
> to create temporary named pipes?

You are correct that a short option -p cannot be used.  And I'm
reluctant to burn -f unless there is another implementation that already
does it.  But you have a point that adding a long option --fifo may make
sense.  However, I thought about that same point the last time I touched
mktemp(1), and did not implement it at that time because I felt that a
temporary directory was enough.  But I can be swayed if you can present
good arguments why the addition is better than using existing tools.

> 
> PS: I can try to provide a patch if my bug is accepted

Patches speak volumes, although by the time you add the code and the
documentation, your contribution would probably be non-trivial and
require copyright assignment to the FSF.  Let us know if you'd like to
start that process.

-- 
Eric Blake   eblake <at> redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

This bug report was last modified 13 years and 351 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.