summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ypserv
diff options
context:
space:
mode:
authorwpaul <wpaul@FreeBSD.org>1996-05-31 16:01:51 +0000
committerwpaul <wpaul@FreeBSD.org>1996-05-31 16:01:51 +0000
commit7db7b1cde125e2f1b07ce515a44386287ffe20e3 (patch)
tree09d1229ceb91ce3fd14b2705728d76c9b2ed0f9f /usr.sbin/ypserv
parentd4c70b6e6444ede1b94fe2e860bc791d28cd0604 (diff)
downloadFreeBSD-src-7db7b1cde125e2f1b07ce515a44386287ffe20e3.zip
FreeBSD-src-7db7b1cde125e2f1b07ce515a44386287ffe20e3.tar.gz
Small touch-ups -- no functional changes.
Fix some comments to reflect reality (in some cases I made changes to code but not to the comments). Change some instances of 'inline' to '__inline' to pacify gcc -ansi -pedantic. Use rcsid strings more consistently. Make 'oldaddr' static in yp_access(). Use strcpy()/strcat() in yp_open_db_cache() instead of snprintf(). (Seems to be a little faster this way.)
Diffstat (limited to 'usr.sbin/ypserv')
-rw-r--r--usr.sbin/ypserv/Makefile.yp6
-rw-r--r--usr.sbin/ypserv/yp_access.c4
-rw-r--r--usr.sbin/ypserv/yp_dblookup.c33
-rw-r--r--usr.sbin/ypserv/yp_dnslookup.c6
-rw-r--r--usr.sbin/ypserv/yp_error.c6
-rw-r--r--usr.sbin/ypserv/yp_main.c11
-rw-r--r--usr.sbin/ypserv/yp_server.c8
7 files changed, 40 insertions, 34 deletions
diff --git a/usr.sbin/ypserv/Makefile.yp b/usr.sbin/ypserv/Makefile.yp
index bcb06d7..0d85712 100644
--- a/usr.sbin/ypserv/Makefile.yp
+++ b/usr.sbin/ypserv/Makefile.yp
@@ -1,7 +1,7 @@
#
# Makefile for the NIS databases
#
-# $Id: Makefile.yp,v 1.2 1996/04/13 21:17:57 wpaul Exp wpaul $
+# $Id: Makefile.yp,v 1.4 1996/04/28 04:38:46 wpaul Exp $
#
# This Makefile should only be run on the NIS master server of a domain.
# All updated maps will be pushed to all NIS slave servers listed in the
@@ -146,8 +146,8 @@ mail.aliases: $(ALIASES)
@$(MV) $(TMP) $@
@$(DBLOAD) -c
@$(NEWALIASES)
- @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
- @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
+ @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
+ @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
ypservers: $(YPSERVERS)
diff --git a/usr.sbin/ypserv/yp_access.c b/usr.sbin/ypserv/yp_access.c
index 7bd3d32..24ee81c0 100644
--- a/usr.sbin/ypserv/yp_access.c
+++ b/usr.sbin/ypserv/yp_access.c
@@ -52,7 +52,7 @@
#endif
#ifndef lint
-static const char rcsid[] = "$Id: yp_access.c,v 1.1 1996/04/13 07:27:13 wpaul Exp $";
+static const char rcsid[] = "$Id: yp_access.c,v 1.7 1996/04/28 04:38:47 wpaul Exp $";
#endif
extern int debug;
@@ -213,7 +213,7 @@ int yp_access(map, rqstp)
{
struct sockaddr_in *rqhost;
int status = 0;
- unsigned long oldaddr;
+ static unsigned long oldaddr = 0;
#ifndef TCP_WRAPPER
struct securenet *tmp;
#endif
diff --git a/usr.sbin/ypserv/yp_dblookup.c b/usr.sbin/ypserv/yp_dblookup.c
index 0cffdb3..76370f4 100644
--- a/usr.sbin/ypserv/yp_dblookup.c
+++ b/usr.sbin/ypserv/yp_dblookup.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: yp_dblookup.c,v 1.7 1996/04/27 17:50:18 wpaul Exp wpaul $
+ * $Id: yp_dblookup.c,v 1.9 1996/05/01 02:33:52 wpaul Exp $
*
*/
#include <stdio.h>
@@ -46,6 +46,10 @@
#include <rpcsvc/yp.h>
#include "yp_extern.h"
+#ifndef lint
+static const char rcsid[] = "$Id: yp_dblookup.c,v 1.9 1996/05/01 02:33:52 wpaul Exp $";
+#endif
+
int ypdb_debug = 0;
int yp_errno = YP_TRUE;
@@ -85,7 +89,11 @@ void yp_init_dbs()
return;
}
-static inline void yp_flush(i)
+/*
+ * Zorch a single entry in the dbent table and release
+ * all its resources.
+ */
+static __inline void yp_flush(i)
register int i;
{
(void)(dbs[i]->dbp->close)(dbs[i]->dbp);
@@ -101,8 +109,6 @@ static inline void yp_flush(i)
/*
* Close all databases and erase all database names.
- * Don't free the memory allocated for each DB entry though: we
- * can just reuse it later.
*/
void yp_flush_all()
{
@@ -122,15 +128,13 @@ void yp_flush_all()
* a new entry when all our slots are already filled, we have to kick
* out the entry in the last slot to make room.
*/
-static inline void yp_add_db(dbp, name, size)
+static __inline void yp_add_db(dbp, name, size)
DB *dbp;
char *name;
int size;
{
register int i;
register struct dbent *tmp;
- static int count = 0;
-
tmp = dbs[LASTDB];
@@ -147,15 +151,9 @@ static inline void yp_add_db(dbp, name, size)
}
/*
- * Add the new entry. We allocate memory for the dbent
- * structure if we need it. We shoudly only end up calling
- * malloc(2) MAXDB times. Once all the slots are filled, we
- * hold onto the memory and recycle it.
+ * Allocate a new entry.
*/
if (dbs[0] == NULL) {
- count++;
- if (ypdb_debug)
- yp_error("allocating new DB member (%d)", count);
dbs[0] = (struct dbent *)malloc(sizeof(struct dbent));
bzero((char *)dbs[0], sizeof(struct dbent));
}
@@ -192,9 +190,10 @@ static inline void yp_add_db(dbp, name, size)
* array so that it will be easier to find if another request for
* the same database comes in later.
*/
-static inline DB *yp_find_db(name, key, size)
+static __inline DB *yp_find_db(name, key, size)
char *name;
char *key;
+ int size;
{
register int i, j;
register struct dbent *tmp;
@@ -237,7 +236,9 @@ DB *yp_open_db_cache(domain, map, key, size)
DB *dbp = NULL;
char buf[MAXPATHLEN + 2];
- snprintf(buf, sizeof(buf), "%s/%s", domain, map);
+ strcpy(buf, domain);
+ strcat(buf, "/");
+ strcat(buf, map);
if ((dbp = yp_find_db((char *)&buf, key, size)) != NULL) {
return(dbp);
diff --git a/usr.sbin/ypserv/yp_dnslookup.c b/usr.sbin/ypserv/yp_dnslookup.c
index a3d4b7a..c578d6b 100644
--- a/usr.sbin/ypserv/yp_dnslookup.c
+++ b/usr.sbin/ypserv/yp_dnslookup.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: yp_dnslookup.c,v 1.4 1995/12/07 05:01:34 wpaul Exp $
+ * $Id: yp_dnslookup.c,v 1.2 1996/05/01 02:37:46 wpaul Exp $
*/
/*
@@ -53,6 +53,10 @@
#include <arpa/inet.h>
#include "yp_extern.h"
+#ifndef lint
+static const char rcsid[] = "$Id: yp_dnslookup.c,v 1.2 1996/05/01 02:37:46 wpaul Exp $";
+#endif
+
extern struct hostent *_gethostbydnsname __P(( char * ));
extern struct hostent *_gethostbydnsaddr __P(( const char *, int, int ));
diff --git a/usr.sbin/ypserv/yp_error.c b/usr.sbin/ypserv/yp_error.c
index 81ba529..0dac2f5 100644
--- a/usr.sbin/ypserv/yp_error.c
+++ b/usr.sbin/ypserv/yp_error.c
@@ -34,13 +34,17 @@
* error logging/reporting facilities
* stolen from /usr/libexec/mail.local via ypserv
*
- * $Id: yp_error.c,v 1.1.1.1 1995/12/16 20:54:17 wpaul Exp $
+ * $Id: yp_error.c,v 1.3 1996/05/01 02:36:34 wpaul Exp $
*/
#include <stdio.h>
#include <sys/types.h>
#include <syslog.h>
+#ifndef lint
+static const char rcsid[] = "$Id: yp_error.c,v 1.3 1996/05/01 02:36:34 wpaul Exp $";
+#endif
+
int debug;
extern int _rpcpmstart;
diff --git a/usr.sbin/ypserv/yp_main.c b/usr.sbin/ypserv/yp_main.c
index c4f9275..4d57d19 100644
--- a/usr.sbin/ypserv/yp_main.c
+++ b/usr.sbin/ypserv/yp_main.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: yp_main.c,v 1.2 1996/04/21 21:33:40 wpaul Exp $
+ * $Id: yp_main.c,v 1.3 1996/05/01 02:39:34 wpaul Exp wpaul $
*/
/*
@@ -58,6 +58,7 @@
#include <unistd.h>
#include <rpc/rpc.h>
#include <errno.h>
+#include <err.h>
#ifndef SIG_PF
#define SIG_PF void(*)(int)
@@ -65,7 +66,7 @@
#define _RPCSVC_CLOSEDOWN 120
#ifndef lint
-static char rcsid[] = "$Id: yp_main.c,v 1.2 1996/04/21 21:33:40 wpaul Exp $";
+static const char rcsid[] = "$Id: yp_main.c,v 1.3 1996/05/01 02:39:34 wpaul Exp wpaul $";
#endif /* not lint */
int _rpcpmstart; /* Started by a port monitor ? */
static int _rpcfdtype;
@@ -107,6 +108,7 @@ yp_svc_run()
#endif /* def FD_SETSIZE */
extern int forked;
int pid;
+ int fd_setsize = _rpc_dtablesize();
/* Establish the identity of the parent ypserv process. */
pid = getpid();
@@ -117,7 +119,7 @@ yp_svc_run()
#else
readfds = svc_fds;
#endif /* def FD_SETSIZE */
- switch (select(_rpc_dtablesize(), &readfds, NULL, NULL,
+ switch (select(fd_setsize, &readfds, NULL, NULL,
(struct timeval *)0)) {
case -1:
if (errno == EINTR) {
@@ -246,8 +248,7 @@ main(argc, argv)
} else {
if (!debug) {
if (daemon(0,0)) {
- perror("cannot fork");
- exit(1);
+ err(1,"cannot fork");
}
openlog(progname, LOG_PID, LOG_DAEMON);
}
diff --git a/usr.sbin/ypserv/yp_server.c b/usr.sbin/ypserv/yp_server.c
index 27a1279..f32a983 100644
--- a/usr.sbin/ypserv/yp_server.c
+++ b/usr.sbin/ypserv/yp_server.c
@@ -45,7 +45,7 @@
#include <rpc/rpc.h>
#ifndef lint
-static char rcsid[] = "$Id: yp_server.c,v 1.5 1996/04/26 04:35:53 wpaul Exp wpaul $";
+static const char rcsid[] = "$Id: yp_server.c,v 1.9 1996/04/28 04:38:52 wpaul Exp $";
#endif /* not lint */
int forked = 0;
@@ -54,10 +54,6 @@ DB *spec_dbp = NULL; /* Special global DB handle for ypproc_all. */
char *master_string = "YP_MASTER_NAME";
char *order_string = "YP_LAST_MODIFIED";
-#define YP_ALL_TIMEOUT 10
-
-static int yp_all_timed_out = 0;
-
/*
* NIS v2 support. This is where most of the action happens.
*/
@@ -646,7 +642,7 @@ static struct ypmaplist *yp_maplist_create(domain)
!S_ISREG(statbuf.st_mode))
continue;
if ((cur = (struct ypmaplist *)
- malloc(sizeof(struct ypmaplist))) < 0) {
+ malloc(sizeof(struct ypmaplist))) == NULL) {
yp_error("malloc() failed: %s",strerror(errno));
closedir(dird);
yp_maplist_free(yp_maplist);
OpenPOWER on IntegriCloud