summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMats O Jansson <maja@cvs.openbsd.org>1997-02-08 19:58:52 +0000
committerMats O Jansson <maja@cvs.openbsd.org>1997-02-08 19:58:52 +0000
commitd2c643953f30b661d97df2e254267f5c1bc5d587 (patch)
tree1bb16d6d31a24db2f6fe8415c6d1a8902f9152a9
parent3e72ad5a0fe2c0a4ae5f29b9f51986983690126d (diff)
Use much of the backed out code from 1.12. But remove use of mkstemp. -moj
-rw-r--r--usr.sbin/ypserv/ypxfr/ypxfr.c61
1 files changed, 31 insertions, 30 deletions
diff --git a/usr.sbin/ypserv/ypxfr/ypxfr.c b/usr.sbin/ypserv/ypxfr/ypxfr.c
index 80a237be61f..31d9b73b064 100644
--- a/usr.sbin/ypserv/ypxfr/ypxfr.c
+++ b/usr.sbin/ypserv/ypxfr/ypxfr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ypxfr.c,v 1.13 1997/02/07 09:24:03 deraadt Exp $ */
+/* $OpenBSD: ypxfr.c,v 1.14 1997/02/08 19:58:51 maja Exp $ */
/*
* Copyright (c) 1994 Mats O Jansson <moj@stacken.kth.se>
@@ -32,23 +32,25 @@
*/
#ifndef LINT
-static char rcsid[] = "$OpenBSD: ypxfr.c,v 1.13 1997/02/07 09:24:03 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: ypxfr.c,v 1.14 1997/02/08 19:58:51 maja Exp $";
#endif
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/socket.h>
+
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
-#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <sys/socket.h>
#include <netdb.h>
#include <rpc/rpc.h>
#include <rpc/xdr.h>
-/* #include <rpcsvc/yp_prot.h> */
#include <rpcsvc/ypclnt.h>
#include <rpcsvc/yp.h>
@@ -57,7 +59,7 @@ static char rcsid[] = "$OpenBSD: ypxfr.c,v 1.13 1997/02/07 09:24:03 deraadt Exp
#include "ypdb.h"
#include "ypdef.h"
-char *progname = "ypxfr";
+extern char *__progname;
DBM *db;
extern bool_t xdr_ypresp_all_seq();
@@ -70,7 +72,7 @@ ypxfr_foreach(status,keystr,keylen,valstr,vallen,data)
int status,keylen,vallen,*data;
char *keystr,*valstr;
{
- datum key,val;
+ datum key,val;
if (status == 2)
return(0);
@@ -95,7 +97,7 @@ char *domain;
char *map;
u_long *lordernum;
{
- char map_path[1024];
+ char map_path[MAXPATHLEN];
char order_key[] = YP_LAST_KEY;
char order[MAX_LAST_LEN+1];
struct stat finfo;
@@ -107,17 +109,18 @@ u_long *lordernum;
status = YPPUSH_SUCC;
- sprintf(map_path,"%s/%s",YP_DB_PATH,domain);
+ snprintf(map_path, sizeof map_path, "%s/%s",YP_DB_PATH,domain);
if (!((stat(map_path, &finfo) == 0) &&
((finfo.st_mode & S_IFMT) == S_IFDIR))) {
fprintf(stderr, "%s: domain %s not found locally\n",
- progname, domain);
+ __progname, domain);
status = YPPUSH_NODOM;
}
if(status > 0) {
- sprintf(map_path,"%s/%s/%s%s",YP_DB_PATH,domain,map,YPDB_SUFFIX);
+ snprintf(map_path, sizeof map_path, "%s/%s/%s%s",
+ YP_DB_PATH,domain,map,YPDB_SUFFIX);
if(!(stat(map_path, &finfo) == 0)) {
status = YPPUSH_NOMAP;
}
@@ -125,7 +128,8 @@ u_long *lordernum;
if(status > 0) {
- sprintf(map_path,"%s/%s/%s",YP_DB_PATH,domain,map);
+ snprintf(map_path, sizeof map_path, "%s/%s/%s",
+ YP_DB_PATH,domain,map);
db = ypdb_open(map_path, O_RDONLY, 0444);
if(db == NULL) {
status = YPPUSH_DBM;
@@ -189,9 +193,7 @@ char *domain;
char *map;
struct ypall_callback *incallback;
{
- u_long status;
-
- status = yp_all_host(client, domain, map, incallback);
+ (void)yp_all_host(client, domain, map, incallback);
}
@@ -204,7 +206,8 @@ char *temp_map;
DBM *db;
char db_temp[255];
- sprintf(db_temp,"%s/%s/%s",YP_DB_PATH,domain,temp_map);
+ snprintf(db_temp,sizeof db_temp, "%s/%s/%s",
+ YP_DB_PATH,domain,temp_map);
db = ypdb_open(db_temp, O_RDWR|O_CREAT, 0444);
@@ -219,10 +222,12 @@ char *domain;
char *map;
char *temp_map;
{
- char db_name[255],db_temp[255];
+ char db_name[MAXPATHLEN],db_temp[MAXPATHLEN];
- sprintf(db_name,"%s/%s/%s%s",YP_DB_PATH,domain,map,YPDB_SUFFIX);
- sprintf(db_temp,"%s/%s/%s%s",YP_DB_PATH,domain,temp_map,YPDB_SUFFIX);
+ snprintf(db_name, sizeof db_name, "%s/%s/%s%s",
+ YP_DB_PATH,domain,map,YPDB_SUFFIX);
+ snprintf(db_temp, sizeof db_temp, "%s/%s/%s%s",
+ YP_DB_PATH,domain,temp_map,YPDB_SUFFIX);
rename(db_temp,db_name);
return YPPUSH_SUCC;
@@ -232,9 +237,10 @@ int
unlink_db(domain,map,temp_map)
char *temp_map;
{
- char db_temp[255];
+ char db_temp[MAXPATHLEN];
- sprintf(db_temp,"%s/%s/%s%s",YP_DB_PATH,domain,temp_map,YPDB_SUFFIX);
+ snprintf(db_temp, sizeof db_temp, "%s/%s/%s%s",
+ YP_DB_PATH,domain,temp_map,YPDB_SUFFIX);
unlink(db_temp);
return YPPUSH_SUCC;
@@ -506,7 +512,7 @@ char *argv[];
if (usage) {
status = YPPUSH_BADARGS;
- (void)fprintf(stderr,"usage: %s [-cf] [-d domain] [-h host] [-s domain] [-C tid prog ipadd port] mapname\n",progname);
+ (void)fprintf(stderr,"usage: %s [-cf] [-d domain] [-h host] [-s domain] [-C tid prog ipadd port] mapname\n",__progname);
}
if (status > 0) {
@@ -571,14 +577,9 @@ char *argv[];
}
if (status == YPPUSH_SUCC) {
- int fd;
/* Create temporary db */
- fd = mkstemp(mapname);
- if (fd == -1)
- status = YPPUSH_DBM;
- else
- close(fd);
+ mktemp(mapname);
if (status > 0) {
db = create_db(domain,map,mapname);