diff options
author | gpalmer <gpalmer@FreeBSD.org> | 1995-04-19 12:24:08 +0000 |
---|---|---|
committer | gpalmer <gpalmer@FreeBSD.org> | 1995-04-19 12:24:08 +0000 |
commit | 0ff5903c59102c69837dc4317ea80fe6d8a12450 (patch) | |
tree | 5e46bed068739ad2e43122e7cd641e2de384eba3 /usr.sbin | |
parent | c2e217461cd110c5fd5468a5165daf3d99eb9e69 (diff) | |
download | FreeBSD-src-0ff5903c59102c69837dc4317ea80fe6d8a12450.zip FreeBSD-src-0ff5903c59102c69837dc4317ea80fe6d8a12450.tar.gz |
Bugfixes :
- in mount_portal.c: included catching of SIGHUP to get portald to
re-read the config file.
- in mount_portal.c: in SIGCHLD handler the return values checked from
waitpid were wrong. Note. this routine was written correclty according
to the manual page for 4.4BSD, but waitpid does not exhibit this
behaviour. It is not returning 0 when WNOHANG is specified. I havent
checked this properly.
- in mount_portal.c: initialized the fdset for the select properly.
- in mount_portal.c: corrected poor casting in the select.
- in mount_portal.c: changed a break; to exit (0); so that the
children die after doing the hard work, this stops the select: bad
file descriptor messages.
- in pt_file.c: the kernel passes kernel style open flags to the
portal code which aren't compatible with "normal" O_ flags. I have
adjusted these in pt_file.c. In general I think the portal fs code
and portal_cred structure need changing to pass to the portald
the right style of flags _and_ the permissions.
- in pt_tcp.c: a few mistakes in typing of the socket structures,
getservbyname returns the port number as an int but sockaddr wants
the port number as an u_short.
- in pt_tcp.c: someone wrote this on a VAX/Sun whatever and forget
about byte ordering!! I've included a few htons about the place.
- in all the above I have sprinkled a few more debugging printf's.
Submitted by: "Duncan McL Barclay" <dmlb@ohm.york.ac.uk
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/mount_portalfs/mount_portalfs.c | 20 | ||||
-rw-r--r-- | usr.sbin/mount_portalfs/pt_file.c | 6 | ||||
-rw-r--r-- | usr.sbin/mount_portalfs/pt_tcp.c | 16 |
3 files changed, 33 insertions, 9 deletions
diff --git a/usr.sbin/mount_portalfs/mount_portalfs.c b/usr.sbin/mount_portalfs/mount_portalfs.c index 862027f..23098d2 100644 --- a/usr.sbin/mount_portalfs/mount_portalfs.c +++ b/usr.sbin/mount_portalfs/mount_portalfs.c @@ -46,6 +46,7 @@ static char sccsid[] = "@(#)mount_portal.c 8.4 (Berkeley) 3/27/94"; #include <sys/param.h> #include <sys/wait.h> +#include <sys/time.h> #include <sys/socket.h> #include <sys/un.h> #include <sys/syslog.h> @@ -72,6 +73,12 @@ static void usage __P((void)); static sig_atomic_t readcf; /* Set when SIGHUP received */ +static void sighup(sig) +int sig; +{ + readcf ++; +} + static void sigchld(sig) int sig; { @@ -79,8 +86,11 @@ int sig; while ((pid = waitpid((pid_t) -1, (int *) 0, WNOHANG)) > 0) ; + /* wrtp - waitpid _doesn't_ return 0 when no children! */ +#ifdef notdef if (pid < 0) syslog(LOG_WARNING, "waitpid: %s", strerror(errno)); +#endif } int @@ -149,6 +159,7 @@ main(argc, argv) (void) unlink(un.sun_path); if (bind(so, (struct sockaddr *) &un, sizeof(un)) < 0) err(1, NULL); + (void) unlink(un.sun_path); (void) listen(so, 5); @@ -185,6 +196,7 @@ main(argc, argv) readcf = 1; signal(SIGCHLD, sigchld); + signal(SIGHUP, sighup); /* * Just loop waiting for new connections and activating them @@ -201,6 +213,9 @@ main(argc, argv) * Check whether we need to re-read the configuration file */ if (readcf) { +#ifdef DEBUG + printf ("re-reading configuration file\n"); +#endif readcf = 0; conf_read(&q, conf); continue; @@ -211,8 +226,9 @@ main(argc, argv) * Will get EINTR if a signal has arrived, so just * ignore that error code */ + FD_ZERO(&fdset); FD_SET(so, &fdset); - rc = select(so+1, &fdset, (void *) 0, (void *) 0, (void *) 0); + rc = select(so+1, &fdset, (fd_set *) 0, (fd_set *) 0, (struct timeval *) 0); if (rc < 0) { if (errno == EINTR) continue; @@ -251,7 +267,7 @@ main(argc, argv) case 0: (void) close(so); activate(&q, so2); - break; + exit(0); /* stupid errors.... tidied up... wrtp*/ default: (void) close(so2); break; diff --git a/usr.sbin/mount_portalfs/pt_file.c b/usr.sbin/mount_portalfs/pt_file.c index 929f261..a9cd2ca3 100644 --- a/usr.sbin/mount_portalfs/pt_file.c +++ b/usr.sbin/mount_portalfs/pt_file.c @@ -36,7 +36,7 @@ * * @(#)pt_file.c 8.2 (Berkeley) 3/27/94 * - * $Id: pt_file.c,v 1.1.1.1 1994/05/26 06:34:34 rgrimes Exp $ + * $Id: pt_file.c,v 1.2 1994/09/19 13:52:38 ache Exp $ */ #include <stdio.h> @@ -69,6 +69,7 @@ int *fdp; #ifdef DEBUG printf("path = %s, uid = %d, gid = %d\n", pbuf, pcr->pcr_uid, pcr->pcr_groups[0]); + printf ("fflag = %x, oflag = %x\n", pcr->pcr_flag, (pcr->pcr_flag)-1); #endif for (i = 0; i < pcr->pcr_ngroups; i++) @@ -80,7 +81,8 @@ int *fdp; if (seteuid(pcr->pcr_uid) < 0) return (errno); - fd = open(pbuf, O_RDWR|O_CREAT, 0666); + /* dmb convert kernel flags to oflags, see <fcntl.h> */ + fd = open(pbuf, (pcr->pcr_flag)-1, 0777); if (fd < 0) error = errno; else diff --git a/usr.sbin/mount_portalfs/pt_tcp.c b/usr.sbin/mount_portalfs/pt_tcp.c index 18a53ce..11f1453 100644 --- a/usr.sbin/mount_portalfs/pt_tcp.c +++ b/usr.sbin/mount_portalfs/pt_tcp.c @@ -36,7 +36,7 @@ * * @(#)pt_tcp.c 8.3 (Berkeley) 3/27/94 * - * $Id: pt_tcp.c,v 1.1 1992/05/25 21:43:09 jsp Exp jsp $ + * $Id: pt_tcp.c,v 1.1.1.1 1994/05/26 06:34:34 rgrimes Exp $ */ #include <stdio.h> @@ -77,7 +77,7 @@ int *fdp; struct in_addr **ipp; struct in_addr *ip[2]; struct in_addr ina; - int s_port; + u_short s_port; int priv = 0; struct sockaddr_in sain; @@ -117,15 +117,21 @@ int *fdp; ip[1] = 0; ipp = ip; } +#ifdef DEBUG + printf ("inet address for %s is %s\n", host, inet_ntoa(*ipp[0])); +#endif sp = getservbyname(port, "tcp"); - if (sp != 0) - s_port = sp->s_port; + if (sp != NULL) + s_port = (u_short)sp->s_port; else { - s_port = atoi(port); + s_port = htons ((u_short)strtol (port, (char**)NULL, 10)); if (s_port == 0) return (EINVAL); } +#ifdef DEBUG + printf ("port number for %s is %d\n", port, s_port); +#endif bzero(&sain, sizeof(sain)); sain.sin_len = sizeof(sain); |