Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > muc.lists.netbsd.tech.userlevel > #11516
| From | David Holland <dholland-tech@netbsd.org> |
|---|---|
| Newsgroups | muc.lists.netbsd.tech.userlevel |
| Subject | Re: Proposal: getexecpath(3) |
| Date | 2025-01-09 13:52 +0000 |
| Organization | Newsgate at muc.de e.V. |
| Message-ID | <Z3_UgWdVDwJu5cNf@netbsd.org> (permalink) |
| References | <b21c0413-a7a3-4db5-9152-5e7dd5e902d6@helkyn.org> <> |
On Mon, Jan 06, 2025 at 06:50:25PM +0100, Jean-Yves Migeon (NetBSD) wrote: > > For the sake of argument, I wrote the code, stuck it in /usr/local/bin, > > and ran it in various ways, first from sh: > > This is not a shell matter. It absolutely is. argv[0] is provided by the program that calls execve, which for ordinary 3rd-party application software that wants this feature is either the shell or a shell substitute (such as a window manager, desktop start button, etc.) There is no reason to care about what an "uncooperative" caller does. Furthermore, as I've already pointed out a couple times, a hostile caller can confuse any of these schemes. The simplest method (assuming for the sake of argument we're trying to run /usr/pkg/bin/qemu and convince it its $PREFIX is /tmp/confusion) is as follows: % mkdir /tmp/confusion /tmp/confusion/bin % ln /usr/pkg/bin/qemu . % ./qemu Then the path to the executable _is_ /tmp/confusion/bin, and you're done. You can't do it that way if /usr/pkg isn't on the same volume as /tmp, at which point things become more complicated, but configs where it is are quite common. -- David A. Holland dholland@netbsd.org -- Posted automagically by a mail2news gateway at muc.de e.V. Please direct questions, flames, donations, etc. to news-admin@muc.de
Back to muc.lists.netbsd.tech.userlevel | Previous | Next — Next in thread | Find similar | Unroll thread
Re: Proposal: getexecpath(3) David Holland <dholland-tech@netbsd.org> - 2025-01-09 13:52 +0000
Re: Proposal: getexecpath(3) Robert Elz <kre@munnari.OZ.AU> - 2025-01-10 03:09 +0700
Re: Proposal: getexecpath(3) David Holland <dholland-tech@netbsd.org> - 2026-11-01 19:16 +0000
csiph-web