summaryrefslogtreecommitdiffstats
path: root/contrib/amd/hlfsd
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/amd/hlfsd')
-rw-r--r--contrib/amd/hlfsd/hlfsd.821
-rw-r--r--contrib/amd/hlfsd/hlfsd.c51
-rw-r--r--contrib/amd/hlfsd/hlfsd.h8
-rw-r--r--contrib/amd/hlfsd/homedir.c28
-rw-r--r--contrib/amd/hlfsd/nfs_prot_svc.c8
-rw-r--r--contrib/amd/hlfsd/stubs.c27
6 files changed, 62 insertions, 81 deletions
diff --git a/contrib/amd/hlfsd/hlfsd.8 b/contrib/amd/hlfsd/hlfsd.8
index a750320..3f3fe9f 100644
--- a/contrib/amd/hlfsd/hlfsd.8
+++ b/contrib/amd/hlfsd/hlfsd.8
@@ -1,5 +1,5 @@
.\"
-.\" Copyright (c) 1997-2006 Erez Zadok
+.\" Copyright (c) 1997-2014 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.
@@ -16,11 +16,7 @@
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgment:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 3. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
@@ -36,9 +32,10 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: hlfsd.8,v 1.11.2.1 2006/01/02 18:48:25 ezk Exp $
.\" $FreeBSD$
.\"
+.\" File: am-utils/hlfsd/hlfsd.8
+.\"
.\" HLFSD was written at Columbia University Computer Science Department, by
.\" Erez Zadok <ezk@cs.columbia.edu> and Alexander Dupuy <dupuy@smarts.com>
.\" It is distributed under the same terms and conditions as AMD.
@@ -330,14 +327,16 @@ symbolic link returned by
points if it is unable to verify the that
user's home directory is accessible.
.El
-.Sh SEE ALSO
-.Xr mail 1 ,
+.SH "SEE ALSO"
+.Xr mail1 ,
.Xr getgrent 3 ,
.Xr getpwent 3 ,
+.Xr mnttab 4 ,
+.Xr passwd 4 ,
.Xr mtab 5 ,
-.Xr passwd 5 ,
.Xr amd 8 ,
-.Xr cron 8 ,
+.Xr automount 8 ,
+.Xr cron8 ,
.Xr mount 8 ,
.Xr sendmail 8 ,
.Xr umount 8
diff --git a/contrib/amd/hlfsd/hlfsd.c b/contrib/amd/hlfsd/hlfsd.c
index 8703f59..686bb63 100644
--- a/contrib/amd/hlfsd/hlfsd.c
+++ b/contrib/amd/hlfsd/hlfsd.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2006 Erez Zadok
+ * Copyright (c) 1997-2014 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.
@@ -16,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgment:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -82,7 +78,7 @@ char *alt_spooldir = ALT_SPOOLDIR;
char *home_subdir = HOME_SUBDIR;
char *logfile = DEFAULT_LOGFILE;
char *passwdfile = NULL; /* alternate passwd file to use */
-char *slinkname = 0;
+char *slinkname = NULL;
char hostname[MAXHOSTNAMELEN + 1] = "localhost";
u_int cache_interval = DEFAULT_CACHE_INTERVAL;
gid_t hlfs_gid = (gid_t) INVALIDID;
@@ -102,6 +98,7 @@ char *mnttab_file_name = NULL;
/* forward declarations */
void hlfsd_going_down(int rc);
+void fatalerror(char *str);
static void
@@ -260,9 +257,6 @@ main(int argc, char *argv[])
opterrs++;
}
- /* set some default debugging options */
- if (xlog_level_init == ~0)
- switch_option("");
/* need my pid before any dlog/plog */
am_set_mypid();
#ifdef DEBUG
@@ -312,7 +306,11 @@ main(int argc, char *argv[])
}
/* get hostname for logging and open log before we reset umask */
- gethostname(hostname, sizeof(hostname));
+ if (gethostname(hostname, sizeof(hostname)) == -1) {
+ fprintf(stderr, "%s: gethostname failed \"%s\".\n",
+ am_get_progname(), strerror(errno));
+ exit(1);
+ }
hostname[sizeof(hostname) - 1] = '\0';
if ((dot = strchr(hostname, '.')) != NULL)
*dot = '\0';
@@ -418,11 +416,8 @@ main(int argc, char *argv[])
/*
* Register hlfsd as an nfs service with the portmapper.
*/
-#ifdef HAVE_TRANSPORT_TYPE_TLI
- ret = create_nfs_service(&soNFS, &nfs_port, &nfsxprt, nfs_program_2);
-#else /* not HAVE_TRANSPORT_TYPE_TLI */
- ret = create_nfs_service(&soNFS, &nfs_port, &nfsxprt, nfs_program_2);
-#endif /* not HAVE_TRANSPORT_TYPE_TLI */
+ ret = create_nfs_service(&soNFS, &nfs_port, &nfsxprt, nfs_program_2,
+ NFS_VERSION);
if (ret != 0)
fatal("cannot create NFS service");
@@ -450,10 +445,10 @@ main(int argc, char *argv[])
#endif /* not HAVE_SIGACTION */
/*
- * In the parent, if -D daemon, we don't need to
+ * In the parent, if -D nodaemon, we don't need to
* set this signal handler.
*/
- if (!amuDebug(D_DAEMON)) {
+ if (amuDebug(D_DAEMON)) {
s = -99;
while (stoplight != SIGUSR2) {
plog(XLOG_INFO, "parent waits for child to setup (stoplight=%d)", stoplight);
@@ -628,10 +623,10 @@ main(int argc, char *argv[])
plog(XLOG_INFO, "hlfsd ready to serve");
/*
- * If asked not to fork a daemon (-D daemon), then hlfsd_init()
+ * If asked not to fork a daemon (-D nodaemon), then hlfsd_init()
* will not run svc_run. We must start svc_run here.
*/
- if (amuDebug(D_DAEMON)) {
+ if (!amuDebug(D_DAEMON)) {
plog(XLOG_DEBUG, "starting no-daemon debugging svc_run");
svc_run();
}
@@ -656,9 +651,9 @@ hlfsd_init(void)
hlfsd_init_filehandles();
/*
- * If not -D daemon then we must fork.
+ * If -D daemon then we must fork.
*/
- if (!amuDebug(D_DAEMON))
+ if (amuDebug(D_DAEMON))
child = fork();
if (child < 0)
@@ -745,17 +740,17 @@ hlfsd_init(void)
# endif /* not defined(DEBUG) || defined(DEBUG_PRINT) */
#endif /* not HAVE_SIGACTION */
- if (setitimer(ITIMER_REAL, &reloadinterval, (struct itimerval *) 0) < 0)
+ if (setitimer(ITIMER_REAL, &reloadinterval, (struct itimerval *) NULL) < 0)
fatal("setitimer: %m");
clocktime(&startup);
/*
- * If not -D daemon, then start serving here in the child,
- * and the parent will exit. But if -D daemon, then
+ * If -D daemon, then start serving here in the child,
+ * and the parent will exit. But if -D nodaemon, then
* skip this code and make sure svc_run is entered elsewhere.
*/
- if (!amuDebug(D_DAEMON)) {
+ if (amuDebug(D_DAEMON)) {
/*
* Dissociate from the controlling terminal
*/
@@ -839,7 +834,7 @@ cleanup(int signum)
struct stat stbuf;
int umount_result;
- if (!amuDebug(D_DAEMON)) {
+ if (amuDebug(D_DAEMON)) {
if (getpid() != masterpid)
return;
@@ -865,7 +860,7 @@ cleanup(int signum)
break;
}
- if (!amuDebug(D_DAEMON)) {
+ if (amuDebug(D_DAEMON)) {
plog(XLOG_INFO, "cleanup(): killing processes and terminating");
kill(masterpid, SIGKILL);
kill(serverpid, SIGKILL);
diff --git a/contrib/amd/hlfsd/hlfsd.h b/contrib/amd/hlfsd/hlfsd.h
index ed136b6..d5eefed 100644
--- a/contrib/amd/hlfsd/hlfsd.h
+++ b/contrib/amd/hlfsd/hlfsd.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2006 Erez Zadok
+ * Copyright (c) 1997-2014 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.
@@ -16,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgment:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/contrib/amd/hlfsd/homedir.c b/contrib/amd/hlfsd/homedir.c
index fb4720c..6792b70 100644
--- a/contrib/amd/hlfsd/homedir.c
+++ b/contrib/amd/hlfsd/homedir.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2006 Erez Zadok
+ * Copyright (c) 1997-2014 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.
@@ -16,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgment:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -133,9 +129,10 @@ homedir(int userid, int groupid)
}
/*
- * only run this forking code if did not ask for -D fork
+ * Only run this forking code if ask for -D fork (default).
+ * Disable forking using -D nofork.
*/
- if (!amuDebug(D_FORK)) {
+ if (amuDebug(D_FORK)) {
/* fork child to process request if none in progress */
if (found->child && kill(found->child, 0))
found->child = 0;
@@ -265,13 +262,14 @@ delay(uid2home_t *found, int secs)
{
struct timeval tv;
- dlog("delaying on child %ld for %d seconds", (long) found->child, secs);
+ if (found)
+ dlog("delaying on child %ld for %d seconds", (long) found->child, secs);
tv.tv_usec = 0;
do {
tv.tv_sec = secs;
- if (select(0, 0, 0, 0, &tv) == 0)
+ if (select(0, NULL, NULL, NULL, &tv) == 0)
break;
} while (--secs && found->child);
}
@@ -292,7 +290,7 @@ interlock(int signum)
#ifdef HAVE_WAITPID
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 *) NULL)) > 0) {
#endif /* not HAVE_WAITPID */
/* high chances this was the last child forked */
@@ -559,7 +557,7 @@ plt_init(void)
int len;
if (root_home)
XFREE(root_home);
- root_home = strdup(pent_p->pw_dir);
+ root_home = xstrdup(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] == '/') {
@@ -576,7 +574,7 @@ plt_init(void)
unt_compare_fxn);
if (!root_home)
- root_home = strdup("");
+ root_home = xstrdup("");
plog(XLOG_INFO, "password map read and sorted");
}
@@ -671,14 +669,14 @@ table_add(u_int u, const char *h, const char *n)
}
/* add new password entry */
- pwtab[cur_pwtab_num].home = strdup(h);
+ pwtab[cur_pwtab_num].home = xstrdup(h);
pwtab[cur_pwtab_num].child = 0;
pwtab[cur_pwtab_num].last_access_time = 0;
pwtab[cur_pwtab_num].last_status = 0; /* assume best: used homedir */
pwtab[cur_pwtab_num].uid = u;
/* add new userhome entry */
- untab[cur_pwtab_num].username = strdup(n);
+ untab[cur_pwtab_num].username = xstrdup(n);
/* just a second pointer */
pwtab[cur_pwtab_num].uname = untab[cur_pwtab_num].username;
diff --git a/contrib/amd/hlfsd/nfs_prot_svc.c b/contrib/amd/hlfsd/nfs_prot_svc.c
index 8cea0dc..babaa84 100644
--- a/contrib/amd/hlfsd/nfs_prot_svc.c
+++ b/contrib/amd/hlfsd/nfs_prot_svc.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2006 Erez Zadok
+ * Copyright (c) 1997-2014 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.
@@ -16,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgment:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/contrib/amd/hlfsd/stubs.c b/contrib/amd/hlfsd/stubs.c
index becf402..ec2d974 100644
--- a/contrib/amd/hlfsd/stubs.c
+++ b/contrib/amd/hlfsd/stubs.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2006 Erez Zadok
+ * Copyright (c) 1997-2014 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.
@@ -16,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgment:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -137,7 +133,7 @@ nfsproc_getattr_2_svc(am_nfs_fh *argp, struct svc_req *rqstp)
clocktime(&rootfattr.na_mtime);
rootfattr.na_uid = uid;
}
-#endif
+#endif /* 0 */
res.ns_status = NFS_OK;
res.ns_u.ns_attr_u = rootfattr;
} else if (eq_fh(argp, &slink)) {
@@ -241,7 +237,7 @@ nfsproc_lookup_2_svc(nfsdiropargs *argp, struct svc_req *rqstp)
clocktime(&rootfattr.na_mtime);
rootfattr.na_uid = uid;
}
-#endif
+#endif /* 0 */
res.dr_u.dr_drok_u.drok_fhandle = root;
res.dr_u.dr_drok_u.drok_attributes = rootfattr;
res.dr_status = NFS_OK;
@@ -307,7 +303,7 @@ nfsproc_readlink_2_svc(am_nfs_fh *argp, struct svc_req *rqstp)
uid_t userid = (uid_t) INVALIDID;
gid_t groupid = hlfs_gid + 1; /* anything not hlfs_gid */
int retval = 0;
- char *path_val = (char *) NULL;
+ char *path_val = NULL;
char *username;
static uid_t last_uid = (uid_t) INVALIDID;
@@ -328,7 +324,7 @@ nfsproc_readlink_2_svc(am_nfs_fh *argp, struct svc_req *rqstp)
* processing, by getting a NULL returned as a
* "special". Child returns result.
*/
- return (nfsreadlinkres *) NULL;
+ return NULL;
}
} else { /* check if asked for user mailbox */
@@ -375,14 +371,15 @@ nfsproc_readlink_2_svc(am_nfs_fh *argp, struct svc_req *rqstp)
retval = 0;
/*
- * If asked for -D fork, then must return the value,
+ * If asked for -D nofork, then must return the value,
* NOT exit, or else the main hlfsd server exits.
+ * If -D fork (default), then we do want to exit from the process.
* Bug: where is that status information being collected?
*/
if (amuDebug(D_FORK))
+ exit(retval);
+ else
return &res;
-
- exit(retval);
}
@@ -480,7 +477,7 @@ nfsreaddirres *
nfsproc_readdir_2_svc(nfsreaddirargs *argp, struct svc_req *rqstp)
{
static nfsreaddirres res;
- static nfsentry slinkent = {SLINKID, 0, {SLINKCOOKIE}};
+ static nfsentry slinkent = {SLINKID, NULL, {SLINKCOOKIE}};
static nfsentry dotdotent = {ROOTID, "..", {DOTDOTCOOKIE}, &slinkent};
static nfsentry dotent = {ROOTID, ".", {DOTCOOKIE}, &dotdotent};
@@ -503,7 +500,7 @@ nfsproc_readdir_2_svc(nfsreaddirargs *argp, struct svc_req *rqstp)
res.rdr_u.rdr_reply_u.dl_entries = &slinkent;
break;
case SLINKCOOKIE:
- res.rdr_u.rdr_reply_u.dl_entries = (nfsentry *) 0;
+ res.rdr_u.rdr_reply_u.dl_entries = (nfsentry *) NULL;
break;
}
res.rdr_u.rdr_reply_u.dl_eof = TRUE;
OpenPOWER on IntegriCloud