Date: Thu, 11 Jan 1996 21:26:39 -0600 From: Dave Bodenstab <imdave@synet.net> To: questions@FreeBSD.org Subject: Re: (fwd) "at" problem Message-ID: <199601120326.VAA03933@base486>
next in thread | raw e-mail | index | archive | help
jgoerzen@complete.org (John Goerzen) wrote:
>
>When I am logged in as myself and su'd to root, I try issuing the following
>at command:
>
>at now + 3 minutes
>
>and then I enter:
>
>cat ~root/testfile.txt | mail -s test jgoerzen
>^D
>
>It appears to run fine. However, when atrun gets ahold of it and tries to
>run it, I get:
>
>Jan 10 16:25:01 complete atrun[5183]:
>Userid 0 mismatch name jgoerzen - aborting job c00d0dee1.00
>
>(line breaking added)
>
>Now I had originally logged in as jgoerzen (myself) and su'd to root. I
>have tried it using the syntax "su", "su -l", and by the suggestion of
>somebody on IRC, "su -". None worked. After running su, I have checked the
>relevant environment variables, and they all seem to be fine.
>
>Help appreciated.
>
>-- John Goerzen
Been there. Fixed it. That's what the source is for :-)
In /usr/src/libexec/atrun/atrun.c:
if (fscanf(stream, "#! /bin/sh\n# mail %8s %d", mailbuf, &send_mail) == 2)
{
mailname = mailbuf;
pentry = getpwnam(mailname);
if (pentry == NULL || pentry->pw_uid != uid) {
syslog(LOG_ERR,"Userid %lu mismatch name %s - aborting job %s",
(unsigned long) uid, mailname, filename);
exit(EXIT_FAILURE);
}
}
Thus, the problem is that the mailto uid does not match the uid running the
at job. Probably a security thing, so it probably shouldn't go into the
distributed source, but we can make a private fix...
So... from 2.0.5's 6/22/95 snap, /usr/src/usr.bin/at/at.c, we just make `at'
always use the effective uid to generate the at-job header:
*** 2.0 1995/08/20 18:26:26
--- 2.0.1.1 1995/08/20 18:27:19
***************
*** 271,290 ****
if((fp = fdopen(fdes, "w")) == NULL)
panic("Cannot reopen atjob file");
! /* Get the userid to mail to, first by trying getlogin(), which reads
! * /etc/utmp, then from LOGNAME, finally from getpwuid().
*/
! mailname = getlogin();
! if (mailname == NULL)
! mailname = getenv("LOGNAME");
!
! if ((mailname == NULL) || (mailname[0] == '\0')
! || (strlen(mailname) > 8) || (getpwnam(mailname)==NULL))
! {
! pass_entry = getpwuid(getuid());
! if (pass_entry != NULL)
! mailname = pass_entry->pw_name;
! }
if (atinput != (char *) NULL)
{
--- 271,283 ----
if((fp = fdopen(fdes, "w")) == NULL)
panic("Cannot reopen atjob file");
! /* Get the userid to mail to from getpwuid(geteuid()).
*/
! pass_entry = getpwuid(geteuid());
! if (pass_entry != NULL)
! mailname = pass_entry->pw_name;
! else
! mailname = "root";
if (atinput != (char *) NULL)
{
Dave Bodenstab
imdave@synet.net
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199601120326.VAA03933>
