Hacker News new | ask | show | jobs
by fs111 2492 days ago
Apples libc used to shell-out to perl in a function: https://github.com/Apple-FOSS-Mirror/Libc/blob/2ca2ae7464771...
7 comments

I thought this is what the Unix philosophy is supposed to be all about.

(Realistically, calling wordexp should just abort the program. Now I actually want to make a hacked up musl that aborts in all the various "libc functions no one should ever use" and see how far I get into a Ubuntu boot..)

Would be pretty awesome if Perl called wordexp(3) somewhere along this code path
I seem to recall that perl used to shell out to /bin/sh for some related task...
Yep, still there in the latest perl5: Perl_start_glob https://github.com/Perl/perl5/blob/blead/doio.c

It's somewhat messier than I remember, because it uses csh as the first choice and falls back to sh.

> I thought this is what the Unix philosophy is supposed to be all about.

Perhaps from the perspective of an end user running things from a shell. Generally speaking though, shelling out from within a program is not ideal.

/* wordexp is also rife with security "challenges", unless you pass it WRDE_NOCMD it must support subshell expansion, and even if you don't beause it has to support so much of the standard shell (all the odd little variable expansion options for example) it is hard to do without a subshell). It is probbably just plan a Bad Idea to call in anything setuid, or executing remotely. */
That's hilarious. You're not supposed to go the other direction libc!

    /* XXX this is _not_ designed to be fast */
it is hard to do without a subshell). It is probbably just plan a Bad Idea to call in anything setuid, or executing remotely. */

laughing so hard :')

Which raises the question what libc functions perl calls...

And imagine the debug errors:

>perl error X

"But I'm just calling libc ?!?"

Or unintended stackoverflows.
in this case, unintended fork bombs
Die ganzen Zahlen hat der liebe Gott gemacht, alles andere ist Menschenwerk.

https://en.wikipedia.org/wiki/Leopold_Kronecker

What if Perl uses libc ?????
It does on my system:

  $ otool -L /usr/bin/perl
  /usr/bin/perl:
      /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1663.0.0)
      /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.0.0)
That's not an issue unless perl calls wordexp (as part of the stuff it does when called by wordexp).
then it calls the Perl implementation... is there some nuance of perl that would cause a problem with that?
They're jokingly positing a loop: libc shells to perl, perl implements the function via libc call, which shells to perl... and so on.
So if Perl uses libc, which shells put to perl, which uses libc... get it? :)
O_o