zsh-users
 help / color / mirror / code / Atom feed
* implementation of <() (creating a temp fifo) ?
@ 2017-02-12 12:32 Timothee Cour
  2017-02-12 18:17 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Timothee Cour @ 2017-02-12 12:32 UTC (permalink / raw)
  To: Zsh Users

[-- Attachment #1: Type: text/plain, Size: 334 bytes --]

Could someone kindly point me source code showing how zsh implements <()
(temporary named pipe creation)? (ideally a url)

* c tempfile creates an (unnamed) File, which can't be used to create a fifo

* my workaround is to use tempnam but docs says it's not recommended (
http://man7.org/linux/man-pages/man3/tempnam.3.html)

Thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: implementation of <() (creating a temp fifo) ?
  2017-02-12 12:32 implementation of <() (creating a temp fifo) ? Timothee Cour
@ 2017-02-12 18:17 ` Bart Schaefer
  2017-02-13  2:30   ` Timothee Cour
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2017-02-12 18:17 UTC (permalink / raw)
  To: Timothee Cour, Zsh Users

On Feb 12,  4:32am, Timothee Cour wrote:
}
} Could someone kindly point me source code showing how zsh implements <()
} (temporary named pipe creation)? (ideally a url)
} 
} * my workaround is to use tempnam but docs says it's not recommended (
} http://man7.org/linux/man-pages/man3/tempnam.3.html)

There doesn't seem to be any better option for a temporary named pipe.
mkfifo is relatively safe because there's no way to cause it to re-use
an existing fifo, so as long as you're confident that the directory
where the fifo is placed cannot itself be spoofed, using tempnam is OK.

Note that the default build mode for zsh is to instead use /dev/fd/ or
the equivalent to get a handle to the stdin or stdout of the process,
and not use a named pipe at all.

Also since any process can connect to a named pipe once it exists, be
sure you're passing appropriately restrictive file modes to mkfifo.

To answer your direct question:

https://sourceforge.net/p/zsh/code/ci/master/tree/Src/exec.c
   search for "namedpipe"

https://sourceforge.net/p/zsh/code/ci/master/tree/Src/utils.c
   search for "gettempname"


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: implementation of <() (creating a temp fifo) ?
  2017-02-12 18:17 ` Bart Schaefer
@ 2017-02-13  2:30   ` Timothee Cour
  0 siblings, 0 replies; 3+ messages in thread
From: Timothee Cour @ 2017-02-13  2:30 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh Users

[-- Attachment #1: Type: text/plain, Size: 1251 bytes --]

thanks!

On Sun, Feb 12, 2017 at 10:17 AM, Bart Schaefer <schaefer@brasslantern.com>
wrote:

> On Feb 12,  4:32am, Timothee Cour wrote:
> }
> } Could someone kindly point me source code showing how zsh implements <()
> } (temporary named pipe creation)? (ideally a url)
> }
> } * my workaround is to use tempnam but docs says it's not recommended (
> } http://man7.org/linux/man-pages/man3/tempnam.3.html)
>
> There doesn't seem to be any better option for a temporary named pipe.
> mkfifo is relatively safe because there's no way to cause it to re-use
> an existing fifo, so as long as you're confident that the directory
> where the fifo is placed cannot itself be spoofed, using tempnam is OK.
>
> Note that the default build mode for zsh is to instead use /dev/fd/ or
> the equivalent to get a handle to the stdin or stdout of the process,
> and not use a named pipe at all.
>
> Also since any process can connect to a named pipe once it exists, be
> sure you're passing appropriately restrictive file modes to mkfifo.
>
> To answer your direct question:
>
> https://sourceforge.net/p/zsh/code/ci/master/tree/Src/exec.c
>    search for "namedpipe"
>
> https://sourceforge.net/p/zsh/code/ci/master/tree/Src/utils.c
>    search for "gettempname"
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-02-13  2:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-12 12:32 implementation of <() (creating a temp fifo) ? Timothee Cour
2017-02-12 18:17 ` Bart Schaefer
2017-02-13  2:30   ` Timothee Cour

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).