From owner-freebsd-questions Sat Feb 15 09:34:09 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id JAA05954 for questions-outgoing; Sat, 15 Feb 1997 09:34:09 -0800 (PST) Received: from squirrel.tgsoft.com (squirrel.tgsoft.com [207.167.64.183]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id JAA05912 for ; Sat, 15 Feb 1997 09:34:00 -0800 (PST) Received: (from thompson@localhost) by squirrel.tgsoft.com (8.8.3/8.6.12) id JAA13816; Sat, 15 Feb 1997 09:34:44 -0800 (PST) Date: Sat, 15 Feb 1997 09:34:44 -0800 (PST) Message-Id: <199702151734.JAA13816@squirrel.tgsoft.com> From: mark thompson To: freebsd-questions@freebsd.com Subject: at Sender: owner-questions@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk I sometimes like to write at scripts that resubmit themselves, perhaps one day later (sometimes this is cooler than using cron). This doesn't work on FreeBSD 2.1.6 (at least on my system) because the resubmitted script starts out with: #! /bin/sh # mail root 0 and the code in atrun.c does this: 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); } } and pukes because 'root' is not my name. I looked at at.c: /* 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; } obviously, getlogin is succeeding, because LOGNAME is set correctly in the at job. atrun.c does not do a setlogin. Should it? -mark --HAA13697.856020498/squirrel.tgsoft.com-- ------- End of forwarded message -------