From owner-freebsd-questions@FreeBSD.ORG Sat Aug 4 20:13:41 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5FA9B16A419 for ; Sat, 4 Aug 2007 20:13:41 +0000 (UTC) (envelope-from fbsd06@mlists.homeunix.com) Received: from mxout-03.mxes.net (mxout-03.mxes.net [216.86.168.178]) by mx1.freebsd.org (Postfix) with ESMTP id 4591F13C45A for ; Sat, 4 Aug 2007 20:13:41 +0000 (UTC) (envelope-from fbsd06@mlists.homeunix.com) Received: from gumby.homeunix.com. (unknown [87.81.140.128]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.mxes.net (Postfix) with ESMTP id B4C165197B for ; Sat, 4 Aug 2007 16:13:37 -0400 (EDT) Date: Sat, 4 Aug 2007 21:13:34 +0100 From: RW To: freebsd-questions@freebsd.org Message-ID: <20070804211334.782c37ff@gumby.homeunix.com.> In-Reply-To: <20070804182307.GD77822@dan.emsphone.com> References: <20070804190634.69234e1e@gumby.homeunix.com.> <20070804182307.GD77822@dan.emsphone.com> X-Mailer: Claws Mail 2.10.0 (GTK+ 2.10.14; i386-portbld-freebsd6.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: How does Sendmail know how it was invoked? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Aug 2007 20:13:41 -0000 On Sat, 4 Aug 2007 13:23:07 -0500 Dan Nelson wrote: > In the last episode (Aug 04), RW said: > > mailwrapper checks to see how it was invoked and then looks up the > > appropriate command in mailer.conf. All of the entries in > > mailer.conf point to /usr/libexec/sendmail/sendmail, so how does > > that binary know what it's supposed to do. > > The kernel passes the executable name to the running process along > with the rest of the commandline arguments. If you run "ls -l /tmp", > for example, the ls binary gets "ls", "-l", and "/tmp" as its > arguments. See around line 360 of src/contrib/sendmail/src/main.c. > Yes, I understand that. When you type mailq, mailwrapper's argv[0] will contain "mailq". but then mailwrapper looks-up mailq in mailer.conf and runs /usr/libexec/sendmail/sendmail. So when sendmail checks it's argv[0] I was assuming that it would see "sendmail". What I didn't get was that when a binary is executed from execve(), it's the parent program that sets the argv[0] seen by the child, and not the kernel.