What's new

Why is mkfifo missing?

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

ryandesign

Occasional Visitor
I'm curious why the busybox in asuswrt merlin (382.1_1, at least) does not contain "mkfifo".

Code:
# mkfifo
-sh: mkfifo: not found
# busybox mkfifo
mkfifo: applet not found

According to busybox.net, "mkfifo" was added in busybox 0.39 in 1999; asuswrt merlin allegedly contains busybox 1.25.1 from 2016.

(I am trying to make my router's custom scripts log to a file as well as to stdout and stderr. The usual one-liner to do that uses bashisms and isn't compatible with busybox's sh. The longer alternative implementation I found involves using "mkfifo" but that doesn't exist on the router. busybox does have "mknod", and I can substitute "mkfifo foo" with "mknod foo p", which works fine on the router, but that's not compatible with the macOS version of "mknod" so it makes my scripts less portable and harder to test on my Mac.)
 
I'm curious why the busybox in asuswrt merlin (382.1_1, at least) does not contain "mkfifo".

Simply because the firmware has no need for it. For performance and security reasons, busybox isn't compiled with every single applet enabled, only those that are used, or are useful enough to be enabled.
 
(I am trying to make my router's custom scripts log to a file as well as to stdout and stderr. The usual one-liner to do that uses bashisms and isn't compatible with busybox's sh. The longer alternative implementation I found involves using "mkfifo" but that doesn't exist on the router. busybox does have "mknod", and I can substitute "mkfifo foo" with "mknod foo p", which works fine on the router, but that's not compatible with the macOS version of "mknod" so it makes my scripts less portable and harder to test on my Mac.)

Might consider using Homebrew and install the coreutils keg - it'll install the GNU stuff and you update your paths accordingly - Homebrew is fairly handy stuff...
 
I already have coreutils installed with MacPorts.

Make sure you're calling the right mknod then, you might still be using the older one that Apple pulled from FreeBSD - it's been years since I've used MacPorts, made the shift to Homebrew as it's easier to deal with OS X major upgrades compared to MacPorts.

Homebrew install coreutils, but they're all prefaced with g - so gmknod calls the GNU variant (yes, there's ways to change that in Homebrew).

All commands have been installed with the prefix 'g'.

If you really need to use these commands with their normal names, you
can add a "gnubin" directory to your PATH from your bashrc like:

PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"

Additionally, you can access their man pages with normal names if you add
the "gnuman" directory to your MANPATH from your bashrc as well:

MANPATH="/usr/local/opt/coreutils/libexec/gnuman:$MANPATH"
 
Yes, I know my script was still using Apple's mknod. I'm aware that a different mknod is available from coreutils. My question was, since there are different implementations of mknod and it is inconvenient to code a script that correctly works with any mknod implementation, why does asuswrt merlin not include mkfifo, which would make the use of mknod unnecessary, and RMerlin has answered that. I wonder how much space is really saved by excluding mkfifo, but maybe some routers are so space-constrained that every byte counts.

I'm a manager of MacPorts so I'm sorry to hear MacPorts didn't meet your needs. If you or anyone else would like to discuss why we handle major OS upgrades the way we do, or any other problem, please open a thread on the macports-users mailing list.
 
I'm a manager of MacPorts so I'm sorry to hear MacPorts didn't meet your needs. If you or anyone else would like to discuss why we handle major OS upgrades the way we do, or any other problem, please open a thread on the macports-users mailing list.

Welcome to the community here - I've much respect for the contributors at both MacPorts and Homebrew (should also mention Fink, because someone might bring it up) - these projects exist as some of the BSD tools that Apple includes is fairly ancient.

Wish Apple would dedicate a couple of devs and QA guys to comb thru things and at least bring things up to a more current BSD codebase there - many devs would very much appreciate that at least... understanding of course that Apple is somewhat adverse to GNU unless it serves their interests...

Getting back to the thread - mkfifo can be a problem on embedded devices, esp. on Routers like AsusWRT and others that are built on the old code base that is what it is - everything runs as root, so something like mkfifo can be a security concern, which is likely why Asus built busybox as they did. Their code doesn't need it.

One can always clone RMerlin's project, and build accordingly as a private release.
 
Thanks but I've no interest in building and maintaining a custom release of the firmware. As I said I'm able to make fifos using "mknod foo p" instead of "mkfifo foo". Adding mkfifo would make the router no less secure than it already is by having mknod.
 
I think Entware contains its own busybox build. See if it contains the applet you need.
 
If there is no mkfifo, use mknod instead.

Usage: mknod [-m MODE] NAME TYPE MAJOR MINOR

Create a special file (block, character, or pipe)

-m MODE Creation mode (default a=rw)
TYPE:
b Block device
c or u Character device
p Named pipe (MAJOR and MINOR are ignored)
 
mknod xxxx p is the same as mkfifo, the only difference I know is that mkfifo follows POSIX standard, mknod is in the old Unix way.
 

Similar threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top