Subject: bin/36644: vacation does not work if homedir not present
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: None <ef@math.uni-bonn.de>
List: netbsd-bugs
Date: 07/13/2007 13:05:01
>Number:         36644
>Category:       bin
>Synopsis:       vacation does not work if homedir not present
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Fri Jul 13 13:05:00 +0000 2007
>Originator:     Edgar Fuß
>Release:        NetBSD 4.0_BETA2
>Organization:
	Mathematisches Institut der Universität Bonn, Computerabteilung
>Description:
	The vacation command tries to chdir() to the account's home dir.
	This fails on a mail server where home directories are not mounted.
	It looks to me the failure can be (silently) ignored if both the
	database and message files are given as absolute paths.
>How-To-Repeat:
	run vacation for a user with no home directory.
>Fix:
The following patch ignores chdir() failure if both dbprefix and msgfile
are absolute paths. I hope this has no further implications on the invocation
of sendmail later.
Maybe you don't want to try the chdir() in the first place, e.g.
	if (dbprefix[0] != '/' && msgfile[0] != '/' && chdir(pw->pw_dir)) {
or want to log the failure at a lower level, e.g.
	if (chdir(pw->pw_dir)) {
		if (dbprefix[0] != '/' && msgfile[0] != '/')) {
 			syslog(LOG_INFO, "%s: no such directory %s.",
	 		    getprogname(), pw->pw_dir);
		} else {
 			syslog(LOG_ERR, "%s: no such directory %s.",
	 		    getprogname(), pw->pw_dir);
 			exit(1);
		}
	}
--- vacation.c.orig	2004-08-19 15:43:54.000000000 +0200
+++ vacation.c	2007-07-13 12:35:07.000000000 +0200
@@ -244,7 +244,7 @@
 		    getprogname(), *argv);
 		exit(1);
 	}
-	if (chdir(pw->pw_dir)) {
+	if (chdir(pw->pw_dir) && dbprefix[0] != '/' && msgfile[0] != '/') {
 		syslog(LOG_ERR, "%s: no such directory %s.",
 		    getprogname(), pw->pw_dir);
 		exit(1);