Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Email sent from "at" command going to the wrong account

1 view
Skip to first unread message

Holger Kunst

unread,
Dec 14, 2009, 12:13:07 PM12/14/09
to freebsd...@freebsd.org
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.

Best regards,

Holger Kunst


_______________________________________________
freebsd...@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hacke...@freebsd.org"

Nate Eldredge

unread,
Dec 14, 2009, 12:21:02 PM12/14/09
to Holger Kunst, freebsd...@freebsd.org
On Mon, 14 Dec 2009, 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

How are you accomplishing this?

> 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.

--

Nate Eldredge
na...@thatsmathematics.com

Holger Kunst

unread,
Dec 15, 2009, 4:22:56 PM12/15/09
to freebsd...@freebsd.org
Nate,

Thank you for your reply,

On 12/14/2009 12:20 PM, Nate Eldredge wrote:
> On Mon, 14 Dec 2009, Holger Kunst wrote:
>
>> 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
>
> How are you accomplishing this?

login command from the shell: "login b", enter password

Best regards,

Holger

Eugene Grosbein

unread,
Dec 16, 2009, 7:30:56 AM12/16/09
to Holger Kunst, freebsd...@freebsd.org
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

0 new messages