From owner-freebsd-hackers@FreeBSD.ORG Wed Dec 16 06:13:36 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5DD5F106566B for ; Wed, 16 Dec 2009 06:13:36 +0000 (UTC) (envelope-from eugen@eg.sd.rdtc.ru) Received: from eg.sd.rdtc.ru (eg.sd.rdtc.ru [62.231.161.221]) by mx1.freebsd.org (Postfix) with ESMTP id 258CC8FC08 for ; Wed, 16 Dec 2009 06:13:23 +0000 (UTC) Received: from eg.sd.rdtc.ru (localhost [127.0.0.1]) by eg.sd.rdtc.ru (8.14.3/8.14.3) with ESMTP id nBG6DD9K098821; Wed, 16 Dec 2009 13:13:14 +0700 (KRAT) (envelope-from eugen@eg.sd.rdtc.ru) Message-ID: <4B287A79.6090604@eg.sd.rdtc.ru> Date: Wed, 16 Dec 2009 13:13:13 +0700 From: Eugene Grosbein User-Agent: Thunderbird 2.0.0.23 (X11/20090918) MIME-Version: 1.0 To: Holger Kunst References: <4B265E27.8050906@moneyfitness.com> In-Reply-To: <4B265E27.8050906@moneyfitness.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailman-Approved-At: Wed, 16 Dec 2009 12:30:29 +0000 Cc: freebsd-hackers@freebsd.org Subject: Re: Email sent from "at" command going to the wrong account X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Dec 2009 06:13:36 -0000 Holger Kunst wrote: > Hi, > > The "at" command sends an email with the output of the scheduled job. > I've experienced inconsistent results when running jobs, receiving > emails in accounts not associated with the user currently logged in. > > To reproduce in FreeBSD 7.2-RELEASE-p2 > > Case #1 > login as user a (new shell through ssh) > echo "echo 1" | at now > --> user a will receive an email containing "1" - this is as expected > > Case #2 > login as user a (new shell through ssh) > login as user b > exit > echo "echo 1" | at now > --> user b will receive an email containing "1" - this is not as > expected, since I am user a again > > A look at the source for "at" reveals that "at" is getting the mailname > from getlogin(). Running a small test program that outputs getlogin(), > confirms the above behavior: A log-in and out of another account makes > getlogin() return that account's name, even though the shell has been > closed and we are back to the original shell and the original user a. > > Is this the intended behavior? Any hints would be appreciated. This is known long-standing bug. FreeBSD-4.9 was affected (may be earlier) and all versions after it: http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/61355 The PR has some kind of patch in the Audit-Trail. Eugene Grosbein