Date: Wed, 17 May 2017 21:15:05 +0000 From: mzpqnxow <musl@...qnxow.com> To: musl@...ts.openwall.com Subject: Re: Question about setting argv when manually using dynamic linker Does the shell built-in "exec" -a app1 /bah/dynamic-loader.so /path/to/app1" work or it has the same problem with argv getting reset? On Wed, May 17, 2017 at 15:16 John Regan <saxindustries@...il.com> wrote: > > On Wed, May 17, 2017 at 2:07 PM, <u-uy74@...ey.se> wrote: > >> On Wed, May 17, 2017 at 12:24:28PM -0400, Rich Felker wrote: >> > > >>> On Tue, May 16, 2017 at 08:38:56PM -0400, John Regan wrote: >> > > >>> > Hi there - I was wondering if it's possible to somehow set >> argv when >> > > >>> > calling the dynamic linker to load a program. >> >> > > >>> Set argv to whatever you need when you exec*() the dynamic >> loader, >> > > >>> which is straightforward with a binary wrapper (not with a shell). >> > > >>> >> > > >>> A binary wrapper also adds less overhead then going through a >> shell. >> >> > > >>> Rune >> >> > a completely reasonable and recommended way for deploying dynamic >> > linked apps in a self-contained way that doesn't depend on musl libc >> > on the host. Unfortunately there's no way to set argv like you want >> >> We do deploy dynamic linked apps without any dependencies on the libraries >> on the host. It works just fine with musl-as-it-is, including the >> questionably designed applications like busybox and gcc who >> analyze argv. >> >> > at this time. Perhaps adding an option like --argv0=foo would be >> > appropriate. >> >> What would be the justification for adding the supporting code (to every >> instance of the dynamic loader)? >> >> It looks like --argv0=foo is meant to overcome a specific limitation in >> bourne shell, in a specific context where the task can be solved easily >> and generally better without involving the bourne shell in the first hand. >> >> I would like to see an example of a situation where a wrapper in C (or >> any language allowing setting of argv) is less appropriate? >> >> If one really has a reason to express the wrapper in sh, a one-liner in >> C and an extra exec from the shell (much cheaper than starting the >> shell itself was) is sufficient to make it work. >> >> Rune >> >> Hi Rune - would you mind sharing some tips on doing that? > > I wrote and compiled a short program that just dumps the elements in argv, > then a wrapper program that figures out the needed paths for libc, real > binary, etc, but it seems like argv gets reset by the dynamic loader. > > I'm calling execve with the path to the libc.so, and argv is somenthing > like: > > argv - desired process name > argv - full path to the real binary > argv[2...] arguments > > The 'real' binary is loaded and ran, but winds up printing out: > > argv - full path to the real binary > argv[1...] arguments > Content of type "text/html" skipped
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.