Nerd Sniped by BINFMT_MISC
31–36 of 36 posts
Re: Nerd Sniped by BINFMT_MISC
#32Too bad the more narrow minded segment of the HN population appears to have buried this one out of spite.. because this is some super pro badass shit, packaged in a hilarious format by jessfraz. Guess it's not everyone's kind of humor, a real tradgedy if you ask me. Can you imagine a future where you don't have to install runtimes to run things anymore because they are all distributed with everything you need? It wou…
What you are describing is just a statically linked binary, the world of computing moved away from this well before I started my career but there are pros and cons about it, not only related to disk space.
Re: Nerd Sniped by BINFMT_MISC
#33FWIW, you don't need to fiddle around with binfmt_misc (which requires root permissions) to execute a Go program as a script. The following shebang works: ///bin/true; exec /usr/bin/env go run "$0" "$@" See https://stackoverflow.com/a/30082862/334761 for detailed explanation what's going on there. The only downside is that all exit codes != 0 get mapped to exit code 1 by `go run`. It will show the original exit code…
Re: Nerd Sniped by BINFMT_MISC
#34FWIW, you don't need to fiddle around with binfmt_misc (which requires root permissions) to execute a Go program as a script. The following shebang works: ///bin/true; exec /usr/bin/env go run "$0" "$@" See https://stackoverflow.com/a/30082862/334761 for detailed explanation what's going on there. The only downside is that all exit codes != 0 get mapped to exit code 1 by `go run`. It will show the original exit code…
Compared to that, the example snipped you provided is doing many more, and different things:
1. Launches a shell language interpreter: usually the system default POSIX-compliant sh, but could (rarely) be something else. Compared to "read the first line, and if it's a shebang launch python or whatever" in the kernel, this is massively complicated: it starts another whole runtime. Run "strace" on a file that just does "///bin/true; sleep 1000" to see exactly how much is happening just for that shell launch.
1. Executes /bin/true. It's probably present everywhere, and probably the right program, but still an assumption.
2. Evaluates a bunch of string slinging statements in the shell to interpolate arguments, then replaces itself via "exec".
3. Launches /usr/bin/env (hopefully the right program, and hopefully in the right place) to find the go interpreter.
4. env (hopefully) also calls "exec" again and then launches the go run command to start the compilation/execution sequence.
That's a lot of stuff. Pretty garden-variety stuff, but still a lot of additional complexity. A shebang adds none of it, though "trampolining" shebangs (which themselves are just programs to do basically this) can reintroduce some internally.
That's the beauty of the shebang as a trick for truly interpreted languages: it's extremely direct and simple as a means of getting your code executing on your desired runtime.
Re: Nerd Sniped by BINFMT_MISC
#35Earlier quoted context omitted.
I believe you need to be a on an admin account in Windows to change global file associations. In fairness though, most people are logged in as an Administrator.
You can also have user file associations on Windows though.
Re: Nerd Sniped by BINFMT_MISC
#36Earlier quoted context omitted.
You can also have user file associations on Windows though.
Certainly. I supposed the point I am trying to make is that a lot of old windows behaviors that lead to security incidents are finding their way into non-desktop linux machines. My servers have binfmt mounted, for example. SystemD appears to be bringing in a bit of desktop behavior to both desktops and servers. Maybe this is ok if people are aware?
I'm not a fan of systemd in the slightest, but blaming systemd for an in-kernel facility that has existed since the mid-90s (and isn't even used by systemd to my knowledge) doesn't make any sense.
[1]: https://elixir.bootlin.com/linux/v4.15.7/source/fs/binfmt_mi...