From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11330 Path: news.gmane.org!.POSTED!not-for-mail From: u-uy74@aetey.se Newsgroups: gmane.linux.lib.musl.general Subject: Re: Question about setting argv[0] when manually using dynamic linker Date: Wed, 17 May 2017 11:01:03 +0200 Message-ID: <20170517070115.GL6320@example.net> References: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1495011915 27692 195.159.176.226 (17 May 2017 09:05:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 17 May 2017 09:05:15 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-11345-gllmg-musl=m.gmane.org@lists.openwall.com Wed May 17 11:05:11 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1dAutK-00076E-Ho for gllmg-musl@m.gmane.org; Wed, 17 May 2017 11:05:10 +0200 Original-Received: (qmail 7513 invoked by uid 550); 17 May 2017 09:05:13 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 7495 invoked from network); 17 May 2017 09:05:12 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fripost.org; h= in-reply-to:content-disposition:content-type:content-type :mime-version:references:message-id:subject:subject:from:from :date:date; s=20140703; t=1495011901; x=1496826302; bh=njONntaNz ejN+Pa604NTrKRzA6btarpIwLL62UN49e8=; b=x7tV77roJ96RYHkK35KgXIEiN YvLhza1zTvsed9EhI0p1Q1oXi8+L4ZA9o3s4VNBEchXmXrzz1an4APCPB1wVZ7jt K13FQS6wFQXNrTAOlKRZwTObrz6h/aqwsIVPTSPZAahn8eaXF3WJlO80l8jfRA4T bUMnIHzNVuzBVEV14I= X-Virus-Scanned: Debian amavisd-new at fripost.org Content-Disposition: inline In-Reply-To: Xref: news.gmane.org gmane.linux.lib.musl.general:11330 Archived-At: 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[0] when > calling the dynamic linker to load a program. ... > I'd like to retain whatever was actually typed on the command line (in this > case, set argv[0] to "app"), since many apps look at argv[0] to change > behavior, ie - gzip vs gunzip. > > I tried seeing if there was some switch I could pass to the linker, etc - > as far as I can tell, there's no easy way to do this. Set argv[0] 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. There is imho hardly any incentive to put such functionalty into the loader. I say this even though we are dependent here on such tricks, to work around programs which insist on guessing things when not asked to. Regards, Rune