Hacker News new | ask | show | jobs
by spankalee 3732 days ago
Automatically running pre and post scripts is absolutely insane.
5 comments

All package managers (that I know of) for dynamic languages offer a mechanism for compiling native code for packages that include bindings to C libraries.

That mechanism could easily be used to achieve the same goal, even if there was no explicit "post-script" mechanism.

Debian solved this particular problem a long time ago, with pbuilder(1): packages that are installed "from source" simply get compiled in a chroot. Strangely, nobody has ever copied the idea.

The modern hipster-language equivalent would probably be to make the package manager depend on the presence of Docker/rkt/systemd, and use it to pull down a dev-env container and build the native bindings in that.

Nix/NixOS - everything is build not only in a chroot, but also in various namespaces. Of course that doesn't help if you actually use a package (directly or indirectly) hence executing it outside of the build chroot.
Similar with Gobolinux, iirc. With a union mount on top to redirect the files written during the install step.

Afterwards the sub-directory in /Programs can basically be turned into an archive for future installs.

the problem with relying on chroot is that (AFAIK) it might not be available on all platforms supported by the language-specific package managers.
The new Docker runs on Microsoft Hyper-V and on Mac's equivalent. So that would actually be a solution.
in a very restricted sense maybe, but for example perl's CPAN also supports stuff like HP-UX, AIX, z/OS, NonStop and OS/400[0].

[0] http://www.cpan.org/ports/

Don't give them ideas!
Yes, with that you don't even need to "socially fool the package owner". You can use common misspelling for famous packages. It gets you very far.

For example "lowdash" instead of lodash.

I wonder if npm has metrics for this - how many times a month are people attempting to "npm install boostrap"?
Once you've installed a malicious package that you intend to use, you've already lost. Even without a pre/post install script, it'll be executed eventually. The underlying problem is managing risk of the packages you install.
This is very true, but execution at install time (sometimes with root privileges) is a bad idea from a security perspective, especially when it happens with dependencies, which makes it very hard to check all packages that you're installing...
Again, they are run only when you run those commands explicitly on the packages in question. The only reason you would do that on code that wasn't yours was is if you were developing on a forked module, which should be trustworthy, or you've at least read it's code.
Unfortunately native modules like canvas cannot be installed with npm install --ignore-scripts