summaryrefslogtreecommitdiffstats
path: root/contrib/amd/hlfsd
diff options
context:
space:
mode:
authormbr <mbr@FreeBSD.org>2003-09-02 15:27:38 +0000
committermbr <mbr@FreeBSD.org>2003-09-02 15:27:38 +0000
commit7d0df748b4c59651751f156e408f856a02073b69 (patch)
tree4674a9f108ae4334ed6a61634f703f67f6533f4d /contrib/amd/hlfsd
parent532be24b7ef077cdfe0129dee60ab1f934c24181 (diff)
downloadFreeBSD-src-7d0df748b4c59651751f156e408f856a02073b69.zip
FreeBSD-src-7d0df748b4c59651751f156e408f856a02073b69.tar.gz
Virgin import of AMD (am-utils) 20030828 (6.0.9)
Diffstat (limited to 'contrib/amd/hlfsd')
-rw-r--r--contrib/amd/hlfsd/.cvsignore1
-rw-r--r--contrib/amd/hlfsd/hlfsd.88
-rw-r--r--contrib/amd/hlfsd/hlfsd.c43
-rw-r--r--contrib/amd/hlfsd/hlfsd.h9
-rw-r--r--contrib/amd/hlfsd/homedir.c121
-rw-r--r--contrib/amd/hlfsd/nfs_prot_svc.c4
-rw-r--r--contrib/amd/hlfsd/stubs.c41
7 files changed, 152 insertions, 75 deletions
diff --git a/contrib/amd/hlfsd/.cvsignore b/contrib/amd/hlfsd/.cvsignore
new file mode 100644
index 0000000..70845e0
--- /dev/null
+++ b/contrib/amd/hlfsd/.cvsignore
@@ -0,0 +1 @@
+Makefile.in
diff --git a/contrib/amd/hlfsd/hlfsd.8 b/contrib/amd/hlfsd/hlfsd.8
index 0c1f2c3..cdf69e8 100644
--- a/contrib/amd/hlfsd/hlfsd.8
+++ b/contrib/amd/hlfsd/hlfsd.8
@@ -1,5 +1,5 @@
.\"
-.\" Copyright (c) 1997-2001 Erez Zadok
+.\" Copyright (c) 1997-2003 Erez Zadok
.\" Copyright (c) 1989 Jan-Simon Pendry
.\" Copyright (c) 1989 Imperial College of Science, Technology & Medicine
.\" Copyright (c) 1989 The Regents of the University of California.
@@ -36,7 +36,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: hlfsd.8,v 1.3.2.1 2001/01/10 03:23:35 ezk Exp $
+.\" $Id: hlfsd.8,v 1.3.2.4 2003/03/16 01:47:00 ezk Exp $
.\"
.\" HLFSD was written at Columbia University Computer Science Department, by
.\" Erez Zadok <ezk@cs.columbia.edu> and Alexander Dupuy <dupuy@smarts.com>
@@ -94,7 +94,7 @@ The directory will be created if it doesn't already exist. The symbolic link wi
.I subdir
appended to it. If not specified,
.I subdir
-defaults to
+defaults to
.BR .hlfsdir .
This directory will also be created if it does not already exist.
.LP
@@ -229,7 +229,7 @@ Force
.B hlfsd
to run on systems that cannot turn off the NFS attribute-cache. Use of
this option on those systems is discouraged, as it may result in loss
-or misdelivery of mail. The option is ignored on systems that can turn
+or mis-delivery of mail. The option is ignored on systems that can turn
off the attribute-cache.
.TP
.BI \-D " log-options"
diff --git a/contrib/amd/hlfsd/hlfsd.c b/contrib/amd/hlfsd/hlfsd.c
index 8e5e83f..0eaa7ec 100644
--- a/contrib/amd/hlfsd/hlfsd.c
+++ b/contrib/amd/hlfsd/hlfsd.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2001 Erez Zadok
+ * Copyright (c) 1997-2003 Erez Zadok
* Copyright (c) 1989 Jan-Simon Pendry
* Copyright (c) 1989 Imperial College of Science, Technology & Medicine
* Copyright (c) 1989 The Regents of the University of California.
@@ -38,7 +38,7 @@
*
* %W% (Berkeley) %G%
*
- * $Id: hlfsd.c,v 1.7.2.2 2001/01/10 03:23:35 ezk Exp $
+ * $Id: hlfsd.c,v 1.7.2.7 2002/12/27 22:45:08 ezk Exp $
*
* HLFSD was written at Columbia University Computer Science Department, by
* Erez Zadok <ezk@cs.columbia.edu> and Alexander Dupuy <dupuy@cs.columbia.edu>
@@ -263,12 +263,12 @@ main(int argc, char *argv[])
* Terminate if did not ask to forcecache (-C) and hlfsd would not be able
* to set the minimum cache intervals.
*/
-#if !defined(MNT2_NFS_OPT_ACREGMIN) && !defined(MNT2_NFS_OPT_NOAC) && !defined(HAVE_FIELD_NFS_ARGS_T_ACREGMIN)
+#if !defined(MNT2_NFS_OPT_ACREGMIN) && !defined(MNT2_NFS_OPT_NOAC) && !defined(HAVE_NFS_ARGS_T_ACREGMIN)
if (!forcecache) {
fprintf(stderr, "%s: will not be able to turn off attribute caches.\n", am_get_progname());
exit(1);
}
-#endif /* !defined(MNT2_NFS_OPT_ACREGMIN) && !defined(MNT2_NFS_OPT_NOAC) && !defined(HAVE_FIELD_NFS_ARGS_T_ACREGMIN) */
+#endif /* !defined(MNT2_NFS_OPT_ACREGMIN) && !defined(MNT2_NFS_OPT_NOAC) && !defined(HAVE_NFS_ARGS_T_ACREGMIN) */
switch (argc - optind) {
@@ -420,7 +420,7 @@ main(int argc, char *argv[])
#ifdef HAVE_SIGACTION
sa.sa_handler = proceed;
- sa.sa_flags = 0;
+ sa.sa_flags = SA_RESTART;
sigemptyset(&(sa.sa_mask));
sigaddset(&(sa.sa_mask), SIGUSR2);
sigaction(SIGUSR2, &sa, NULL);
@@ -433,7 +433,7 @@ main(int argc, char *argv[])
#ifdef HAVE_SIGACTION
sa.sa_handler = reaper;
- sa.sa_flags = 0;
+ sa.sa_flags = SA_RESTART;
sigemptyset(&(sa.sa_mask));
sigaddset(&(sa.sa_mask), SIGCHLD);
sigaction(SIGCHLD, &sa, NULL);
@@ -685,7 +685,7 @@ hlfsd_init(void)
*/
#ifdef HAVE_SIGACTION
sa.sa_handler = reload;
- sa.sa_flags = 0;
+ sa.sa_flags = SA_RESTART;
sigemptyset(&(sa.sa_mask));
sigaddset(&(sa.sa_mask), SIGALRM);
sigaddset(&(sa.sa_mask), SIGHUP);
@@ -701,7 +701,7 @@ hlfsd_init(void)
*/
#ifdef HAVE_SIGACTION
sa.sa_handler = cleanup;
- sa.sa_flags = 0;
+ sa.sa_flags = SA_RESTART;
sigemptyset(&(sa.sa_mask));
sigaddset(&(sa.sa_mask), SIGTERM);
sigaction(SIGTERM, &sa, NULL);
@@ -714,7 +714,7 @@ hlfsd_init(void)
*/
#ifdef HAVE_SIGACTION
sa.sa_handler = interlock;
- sa.sa_flags = 0;
+ sa.sa_flags = SA_RESTART;
sigemptyset(&(sa.sa_mask));
sigaddset(&(sa.sa_mask), SIGCHLD);
sigaction(SIGCHLD, &sa, NULL);
@@ -731,7 +731,7 @@ hlfsd_init(void)
# else /* not defined(DEBUG) || defined(DEBUG_PRINT) */
sa.sa_handler = SIG_IGN;
# endif /* not defined(DEBUG) || defined(DEBUG_PRINT) */
- sa.sa_flags = 0;
+ sa.sa_flags = SA_RESTART;
sigemptyset(&(sa.sa_mask));
sigaddset(&(sa.sa_mask), SIGUSR1);
sigaction(SIGUSR1, &sa, NULL);
@@ -850,16 +850,16 @@ cleanup(int signum)
amuDebug(D_DAEMON)
#endif /* DEBUG */
if (getpid() != masterpid)
- return;
+ return;
#ifdef DEBUG
amuDebug(D_DAEMON)
#endif /* DEBUG */
if (fork() != 0) {
- masterpid = 0;
- am_set_mypid();
- return;
- }
+ masterpid = 0;
+ am_set_mypid();
+ return;
+ }
am_set_mypid();
for (;;) {
@@ -934,17 +934,8 @@ fatal(char *mess)
strcpy(lessmess, mess);
lessmess[messlen - 4] = '\0';
- if (errno < sys_nerr)
- fprintf(stderr, "%s: %s: %s\n", am_get_progname(), lessmess,
-#ifdef HAVE_STRERROR
- strerror(errno)
-#else /* not HAVE_STRERROR */
- sys_errlist[errno]
-#endif /* not HAVE_STRERROR */
- );
- else
- fprintf(stderr, "%s: %s: Error %d\n",
- am_get_progname(), lessmess, errno);
+ fprintf(stderr, "%s: %s: %s\n",
+ am_get_progname(), lessmess, strerror(errno));
}
}
plog(XLOG_FATAL, "%s", mess);
diff --git a/contrib/amd/hlfsd/hlfsd.h b/contrib/amd/hlfsd/hlfsd.h
index c0e9fa9..bce4631 100644
--- a/contrib/amd/hlfsd/hlfsd.h
+++ b/contrib/amd/hlfsd/hlfsd.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2001 Erez Zadok
+ * Copyright (c) 1997-2003 Erez Zadok
* Copyright (c) 1989 Jan-Simon Pendry
* Copyright (c) 1989 Imperial College of Science, Technology & Medicine
* Copyright (c) 1989 The Regents of the University of California.
@@ -38,7 +38,7 @@
*
* %W% (Berkeley) %G%
*
- * $Id: hlfsd.h,v 1.4.2.2 2001/01/12 22:47:21 ro Exp $
+ * $Id: hlfsd.h,v 1.4.2.6 2002/12/27 22:45:08 ezk Exp $
*
* HLFSD was written at Columbia University Computer Science Department, by
* Erez Zadok <ezk@cs.columbia.edu> and Alexander Dupuy <dupuy@cs.columbia.edu>
@@ -52,7 +52,7 @@
* MACROS AND CONSTANTS:
*/
-#define HLFSD_VERSION "hlfsd 1.1 (1993-2001)"
+#define HLFSD_VERSION "hlfsd 1.2 (1993-2002)"
#define PERS_SPOOLMODE 0755
#define OPEN_SPOOLMODE 01777
#define DOTSTRING "."
@@ -138,7 +138,7 @@ extern SVCXPRT *nfs_program_2_transp; /* For quick_reply() */
extern SVCXPRT *nfsxprt;
extern char *alt_spooldir;
extern char *home_subdir;
-extern char *homedir(int);
+extern char *homedir(int, int);
extern char *mailbox(int, char *);
extern char *passwdfile;
extern char *slinkname;
@@ -147,7 +147,6 @@ extern gid_t hlfs_gid;
extern int cache_interval;
extern int noverify;
extern int serverpid;
-extern int sys_nerr;
extern int untab_index(char *username);
extern am_nfs_fh *root_fhp;
extern am_nfs_fh root;
diff --git a/contrib/amd/hlfsd/homedir.c b/contrib/amd/hlfsd/homedir.c
index e17418e..91431bf 100644
--- a/contrib/amd/hlfsd/homedir.c
+++ b/contrib/amd/hlfsd/homedir.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2001 Erez Zadok
+ * Copyright (c) 1997-2003 Erez Zadok
* Copyright (c) 1989 Jan-Simon Pendry
* Copyright (c) 1989 Imperial College of Science, Technology & Medicine
* Copyright (c) 1989 The Regents of the University of California.
@@ -38,7 +38,7 @@
*
* %W% (Berkeley) %G%
*
- * $Id: homedir.c,v 1.5.2.1 2001/01/10 03:23:36 ezk Exp $
+ * $Id: homedir.c,v 1.5.2.10 2002/12/27 22:45:08 ezk Exp $
*
* HLFSD was written at Columbia University Computer Science Department, by
* Erez Zadok <ezk@cs.columbia.edu> and Alexander Dupuy <dupuy@cs.columbia.edu>
@@ -67,34 +67,31 @@ static uid2home_t *lastchild;
static uid2home_t *pwtab;
static void delay(uid2home_t *, int);
static void table_add(int, const char *, const char *);
+static char mboxfile[MAXPATHLEN];
+static char *root_home; /* root's home directory */
/* GLOBAL FUNCTIONS */
char *homeof(char *username);
int uidof(char *username);
/* GLOBALS VARIABLES */
-char mboxfile[MAXPATHLEN];
username2uid_t *untab; /* user name table */
-
/*
* Return the home directory pathname for the user with uid "userid".
*/
char *
-homedir(int userid)
+homedir(int userid, int groupid)
{
static char linkval[MAXPATHLEN + 1];
static struct timeval tp;
uid2home_t *found;
char *homename;
struct stat homestat;
+ int old_groupid, old_userid;
clock_valid = 0; /* invalidate logging clock */
- if ((int) userid == 0) { /* force superuser to use "/" as home */
- sprintf(linkval, "/%s", home_subdir);
- return linkval;
- }
if ((found = plt_search(userid)) == (uid2home_t *) NULL) {
return alt_spooldir; /* use alt spool for unknown uid */
}
@@ -104,7 +101,10 @@ homedir(int userid)
found->last_status = 1;
return alt_spooldir; /* use alt spool for / or rel. home */
}
- sprintf(linkval, "%s/%s", homename, home_subdir);
+ if ((int) userid == 0) /* force all uid 0 to use root's home */
+ sprintf(linkval, "%s/%s", root_home, home_subdir);
+ else
+ sprintf(linkval, "%s/%s", homename, home_subdir);
if (noverify) {
found->last_status = 0;
@@ -113,9 +113,9 @@ homedir(int userid)
/*
* To optimize hlfsd, we don't actually check the validity of the
- * symlink if it has been in checked in the last N seconds. It is
+ * symlink if it has been checked in the last N seconds. It is
* very likely that the link, machine, and filesystem are still
- * valid, as long as N is small. But if N ls large, that may not be
+ * valid, as long as N is small. But if N is large, that may not be
* true. That's why the default N is 5 minutes, but we allow the
* user to override this value via a command line option. Note that
* we do not update the last_access_time each time it is accessed,
@@ -143,13 +143,33 @@ homedir(int userid)
amuDebug(D_FORK) {
#endif /* DEBUG */
/* fork child to process request if none in progress */
- if (found->child && kill(found->child, 0))
+ if (found->child && kill(found->child, 0) < 0)
found->child = 0;
if (found->child)
delay(found, 5); /* wait a bit if in progress */
- if (found->child) { /* better safe than sorry - maybe */
- found->last_status = 1;
+
+#if defined(DEBUG) && defined(HAVE_WAITPID)
+ if (found->child) {
+ /* perhaps it's a child we lost count of? let's wait on it */
+ int status, child;
+ if ((child = waitpid((pid_t) found->child, &status, WNOHANG)) > 0) {
+ plog(XLOG_ERROR, "found lost child %d", child);
+ found->child = 0;
+ if (WIFEXITED(status))
+ found->last_status = WEXITSTATUS(status);
+ else if (WIFSIGNALED(status))
+ found->last_status = -WTERMSIG(status);
+ else {
+ plog(XLOG_ERROR, "unknown child exit status (%d) ???", status);
+ found->last_status = 255;
+ }
+ }
+ }
+#endif /* DEBUG && HAVE_WAITPID */
+
+ if (found->child) {
+ found->last_status = 1; /* better safe than sorry - maybe */
return alt_spooldir;
}
if ((found->child = fork()) < 0) {
@@ -183,21 +203,28 @@ homedir(int userid)
*
*/
am_set_mypid(); /* for logging routines */
- if (seteuid(userid) < 0) {
+ if ((old_groupid = setgid(groupid)) < 0) {
+ plog(XLOG_WARNING, "could not setgid to %d: %m", groupid);
+ return linkval;
+ }
+ if ((old_userid = seteuid(userid)) < 0) {
plog(XLOG_WARNING, "could not seteuid to %d: %m", userid);
+ setgid(old_groupid);
return linkval;
}
if (hlfsd_stat(linkval, &homestat) < 0) {
if (errno == ENOENT) { /* make the spool dir if possible */
/* don't use recursive mkdirs here */
if (mkdir(linkval, PERS_SPOOLMODE) < 0) {
- seteuid(0);
+ seteuid(old_userid);
+ setgid(old_groupid);
plog(XLOG_WARNING, "can't make directory %s: %m", linkval);
return alt_spooldir;
}
/* fall through to testing the disk space / quota */
} else { /* the home dir itself must not exist then */
- seteuid(0);
+ seteuid(old_userid);
+ setgid(old_groupid);
plog(XLOG_WARNING, "bad link to %s: %m", linkval);
return alt_spooldir;
}
@@ -212,11 +239,13 @@ homedir(int userid)
* We are still seteuid to the user at this point.
*/
if (hlfsd_diskspace(linkval) < 0) {
- seteuid(0);
+ seteuid(old_userid);
+ setgid(old_groupid);
plog(XLOG_WARNING, "no more space in %s: %m", linkval);
return alt_spooldir;
} else {
- seteuid(0);
+ seteuid(old_userid);
+ setgid(old_groupid);
return linkval;
}
}
@@ -294,30 +323,55 @@ interlock(int signum)
int child;
uid2home_t *lostchild;
int status;
+ int max_errors = 10; /* avoid infinite loops */
#ifdef HAVE_WAITPID
- while ((child = waitpid((pid_t) -1, &status, WNOHANG)) > 0) {
+ while ((child = waitpid((pid_t) -1, &status, WNOHANG)) != 0) {
#else /* not HAVE_WAITPID */
- while ((child = wait3(&status, WNOHANG, (struct rusage *) 0)) > 0) {
+ while ((child = wait3(&status, WNOHANG, (struct rusage *) 0)) != 0) {
#endif /* not HAVE_WAITPID */
+ if (child < 0) {
+ plog(XLOG_WARNING, "waitpid/wait3: %m");
+ if (--max_errors > 0)
+ continue;
+ else
+ break;
+ }
+
/* high chances this was the last child forked */
if (lastchild && lastchild->child == child) {
lastchild->child = 0;
if (WIFEXITED(status))
lastchild->last_status = WEXITSTATUS(status);
+ else if (WIFSIGNALED(status))
+ lastchild->last_status = -WTERMSIG(status);
+ else {
+ plog(XLOG_ERROR, "unknown child exit status (%d) ???", status);
+ lastchild->last_status = 255;
+ }
lastchild = (uid2home_t *) NULL;
} else {
/* and if not, we have to search for it... */
+ int found = 0;
for (lostchild = pwtab; lostchild < &pwtab[cur_pwtab_num]; lostchild++) {
if (lostchild->child == child) {
+ lostchild->child = 0;
if (WIFEXITED(status))
lostchild->last_status = WEXITSTATUS(status);
- lostchild->child = 0;
+ else if (WIFSIGNALED(status))
+ lostchild->last_status = -WTERMSIG(status);
+ else {
+ plog(XLOG_ERROR, "unknown child exit status (%d) ???", status);
+ lostchild->last_status = 255;
+ }
+ found = 1;
break;
}
}
+ if (!found)
+ plog(XLOG_ERROR, "no record of child %d found???", child);
}
}
}
@@ -410,7 +464,6 @@ mailbox(int uid, char *username)
static int
plt_compare_fxn(const voidp x, const voidp y)
-
{
uid2home_t *i = (uid2home_t *) x;
uid2home_t *j = (uid2home_t *) y;
@@ -559,6 +612,18 @@ plt_init(void)
hlfsd_setpwent(); /* prepare to read passwd entries */
while ((pent_p = hlfsd_getpwent()) != (struct passwd *) NULL) {
table_add(pent_p->pw_uid, pent_p->pw_dir, pent_p->pw_name);
+ if (STREQ("root", pent_p->pw_name)) {
+ int len;
+ if (root_home)
+ XFREE(root_home);
+ root_home = strdup(pent_p->pw_dir);
+ len = strlen(root_home);
+ /* remove any trailing '/' chars from root's home (even if just one) */
+ while (len > 0 && root_home[len - 1] == '/') {
+ len--;
+ root_home[len] = '\0';
+ }
+ }
}
hlfsd_endpwent();
@@ -567,6 +632,9 @@ plt_init(void)
qsort((char *) untab, cur_pwtab_num, sizeof(username2uid_t),
unt_compare_fxn);
+ if (!root_home)
+ root_home = strdup("");
+
plog(XLOG_INFO, "password map read and sorted");
}
@@ -609,6 +677,9 @@ plt_reset(void)
}
cur_pwtab_num = 0; /* zero current size */
+ if (root_home)
+ XFREE(root_home);
+
return 0; /* resetting ok */
}
@@ -734,7 +805,7 @@ plt_print(int signum)
#else /* not HAVE_MKSTEMP */
mktemp(dumptmp);
if (!dumptmp) {
- plot(XLOG_ERROR, "cannot create temporary dump file");
+ plog(XLOG_ERROR, "cannot create temporary dump file");
return;
}
dumpfd = open(dumptmp, O_RDONLY);
diff --git a/contrib/amd/hlfsd/nfs_prot_svc.c b/contrib/amd/hlfsd/nfs_prot_svc.c
index 26cead4..9583753 100644
--- a/contrib/amd/hlfsd/nfs_prot_svc.c
+++ b/contrib/amd/hlfsd/nfs_prot_svc.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2001 Erez Zadok
+ * Copyright (c) 1997-2003 Erez Zadok
* Copyright (c) 1989 Jan-Simon Pendry
* Copyright (c) 1989 Imperial College of Science, Technology & Medicine
* Copyright (c) 1989 The Regents of the University of California.
@@ -38,7 +38,7 @@
*
* %W% (Berkeley) %G%
*
- * $Id: nfs_prot_svc.c,v 1.4.2.2 2001/01/12 23:29:01 ro Exp $
+ * $Id: nfs_prot_svc.c,v 1.4.2.4 2002/12/27 22:45:09 ezk Exp $
*
*/
diff --git a/contrib/amd/hlfsd/stubs.c b/contrib/amd/hlfsd/stubs.c
index 2d9b341..a65772e 100644
--- a/contrib/amd/hlfsd/stubs.c
+++ b/contrib/amd/hlfsd/stubs.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2001 Erez Zadok
+ * Copyright (c) 1997-2003 Erez Zadok
* Copyright (c) 1989 Jan-Simon Pendry
* Copyright (c) 1989 Imperial College of Science, Technology & Medicine
* Copyright (c) 1989 The Regents of the University of California.
@@ -38,7 +38,7 @@
*
* %W% (Berkeley) %G%
*
- * $Id: stubs.c,v 1.5.2.2 2001/01/10 03:23:36 ezk Exp $
+ * $Id: stubs.c,v 1.5.2.6 2002/12/27 22:45:09 ezk Exp $
*
* HLFSD was written at Columbia University Computer Science Department, by
* Erez Zadok <ezk@cs.columbia.edu> and Alexander Dupuy <dupuy@cs.columbia.edu>
@@ -123,6 +123,11 @@ nfsproc_getattr_2_svc(am_nfs_fh *argp, struct svc_req *rqstp)
un_fattr.na_mtime = startup;
}
+ if (getcreds(rqstp, &uid, &gid, nfsxprt) < 0) {
+ res.ns_status = NFSERR_STALE;
+ return &res;
+ }
+
if (eq_fh(argp, &root)) {
res.ns_status = NFS_OK;
res.ns_u.ns_attr_u = rootfattr;
@@ -134,19 +139,19 @@ nfsproc_getattr_2_svc(am_nfs_fh *argp, struct svc_req *rqstp)
* values cache. It forces the last-modified time of the symlink to be
* current. It is not needed if the O/S has an nfs flag to turn off the
* symlink-cache at mount time (such as Irix 5.x and 6.x). -Erez.
+ *
+ * Additionally, Linux currently ignores the nt_useconds field,
+ * so we must update the nt_seconds field every time.
*/
- if (++slinkfattr.na_mtime.nt_useconds == 0)
- ++slinkfattr.na_mtime.nt_seconds;
+ if (uid != slinkfattr.na_uid) {
+ slinkfattr.na_mtime.nt_seconds++;
+ slinkfattr.na_uid = uid;
+ }
#endif /* not MNT2_NFS_OPT_SYMTTL */
res.ns_status = NFS_OK;
res.ns_u.ns_attr_u = slinkfattr;
} else {
-
- if (getcreds(rqstp, &uid, &gid, nfsxprt) < 0) {
- res.ns_status = NFSERR_STALE;
- return &res;
- }
if (gid != hlfs_gid) {
res.ns_status = NFSERR_STALE;
} else {
@@ -210,6 +215,11 @@ nfsproc_lookup_2_svc(nfsdiropargs *argp, struct svc_req *rqstp)
return &res;
}
+ if (getcreds(rqstp, &uid, &gid, nfsxprt) < 0) {
+ res.dr_status = NFSERR_NOENT;
+ return &res;
+ }
+
if (eq_fh(&argp->da_fhandle, &root)) {
if (argp->da_name[0] == '.' &&
(argp->da_name[1] == '\0' ||
@@ -228,9 +238,14 @@ nfsproc_lookup_2_svc(nfsdiropargs *argp, struct svc_req *rqstp)
* values cache. It forces the last-modified time of the symlink to be
* current. It is not needed if the O/S has an nfs flag to turn off the
* symlink-cache at mount time (such as Irix 5.x and 6.x). -Erez.
+ *
+ * Additionally, Linux currently ignores the nt_useconds field,
+ * so we must update the nt_seconds field every time.
*/
- if (++slinkfattr.na_mtime.nt_useconds == 0)
- ++slinkfattr.na_mtime.nt_seconds;
+ if (uid != slinkfattr.na_uid) {
+ slinkfattr.na_mtime.nt_seconds++;
+ slinkfattr.na_uid = uid;
+ }
#endif /* not MNT2_NFS_OPT_SYMTTL */
res.dr_u.dr_drok_u.drok_fhandle = slink;
res.dr_u.dr_drok_u.drok_attributes = slinkfattr;
@@ -238,7 +253,7 @@ nfsproc_lookup_2_svc(nfsdiropargs *argp, struct svc_req *rqstp)
return &res;
}
- if (getcreds(rqstp, &uid, &gid, nfsxprt) < 0 || gid != hlfs_gid) {
+ if (gid != hlfs_gid) {
res.dr_status = NFSERR_NOENT;
return &res;
}
@@ -292,7 +307,7 @@ nfsproc_readlink_2_svc(am_nfs_fh *argp, struct svc_req *rqstp)
res.rlr_status = NFS_OK;
if (groupid == hlfs_gid) {
res.rlr_u.rlr_data_u = DOTSTRING;
- } else if (!(res.rlr_u.rlr_data_u = path_val = homedir(userid))) {
+ } else if (!(res.rlr_u.rlr_data_u = path_val = homedir(userid, groupid))) {
/*
* parent process (fork in homedir()) continues
* processing, by getting a NULL returned as a
OpenPOWER on IntegriCloud