From owner-freebsd-questions@FreeBSD.ORG Sat Aug 4 20:48:25 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 D275316A419 for ; Sat, 4 Aug 2007 20:48:25 +0000 (UTC) (envelope-from don.hinton@vanderbilt.edu) Received: from mailgate05.smtp.vanderbilt.edu (mailgate05.smtp.Vanderbilt.Edu [129.59.1.206]) by mx1.freebsd.org (Postfix) with ESMTP id A53EB13C461 for ; Sat, 4 Aug 2007 20:48:25 +0000 (UTC) (envelope-from don.hinton@vanderbilt.edu) Received: from smtp10.smtp.vanderbilt.edu (smtp10.smtp.Vanderbilt.Edu [129.59.1.11]) by mailgate05.smtp.vanderbilt.edu (8.13.8/8.13.8) with ESMTP id l74KmMJx016940 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sat, 4 Aug 2007 15:48:22 -0500 Received: from smtp10.smtp.vanderbilt.edu (localhost [127.0.0.1]) by smtp10.smtp.vanderbilt.edu (8.12.11/8.12.11/VU-3.7.9C+d3.7.9) with ESMTP id l74KmM7H013481; Sat, 4 Aug 2007 15:48:22 -0500 (CDT) Received: from [192.168.0.3] (c-69-245-3-33.hsd1.tn.comcast.net [69.245.3.33]) by smtp10.smtp.vanderbilt.edu (8.12.11/8.12.11/VU-3.7.9.3B+d3.7.9) with ESMTP id l74KmMEh013478 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 4 Aug 2007 15:48:22 -0500 (CDT) From: Don Hinton Organization: ISIS To: freebsd-questions@freebsd.org Date: Sat, 4 Aug 2007 15:48:11 -0500 User-Agent: KMail/1.9.7 References: <20070804190634.69234e1e@gumby.homeunix.com.> <20070804182307.GD77822@dan.emsphone.com> <20070804211334.782c37ff@gumby.homeunix.com.> In-Reply-To: <20070804211334.782c37ff@gumby.homeunix.com.> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200708041548.11996.don.hinton@vanderbilt.edu> X-Proofpoint-Virus-Version: vendor=fsecure engine=4.65.5502:2.3.11, 1.2.37, 4.0.164 definitions=2007-08-03_06:2007-07-30, 2007-08-03, 2007-08-03 signatures=0 X-PPS: No, score=0 Cc: RW 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:48:25 -0000 On Saturday 04 August 2007 15:13:34 RW wrote: > 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. Sorry, I should have paid closer attention to your question and actually looked at the code to see what they were doing in this specific case. They original args, including argv[0], are passed as args parameter to execve. So from the perspective of the called application, the original argv[0] is now argv[1]. Take a look at how mailwrapper.c uses the arglist structure. http://www.freebsd.org/cgi/cvsweb.cgi/src/usr.sbin/mailwrapper/mailwrapper.c?rev=1.11;content-type=text%2Fplain hth... don > > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to > "freebsd-questions-unsubscribe@freebsd.org" -- Don Hinton or Institute for Software Integrated Systems (ISIS), Vanderbilt University tel: 615.480.5667 or 615.870.9728