diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-05-14 02:32:34 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-05-14 02:32:34 +0000 |
commit | 1e76c9c90ca3bced88306f8c721148abb28c9b7b (patch) | |
tree | a5f1c29c22bb7b11b3ca4386e3157afc5b278ea2 /usr.sbin/ypserv | |
parent | 98137f511493da4a56a3a935538bd9c05c825660 (diff) |
knf
Diffstat (limited to 'usr.sbin/ypserv')
-rw-r--r-- | usr.sbin/ypserv/makedbm/makedbm.c | 30 | ||||
-rw-r--r-- | usr.sbin/ypserv/mknetid/mknetid.c | 35 | ||||
-rw-r--r-- | usr.sbin/ypserv/stdethers/stdethers.c | 16 | ||||
-rw-r--r-- | usr.sbin/ypserv/stdhosts/stdhosts.c | 20 | ||||
-rw-r--r-- | usr.sbin/ypserv/yppush/yppush.c | 7 | ||||
-rw-r--r-- | usr.sbin/ypserv/ypserv/ypserv_proc.c | 8 | ||||
-rw-r--r-- | usr.sbin/ypserv/ypxfr/ypxfr.c | 9 |
7 files changed, 55 insertions, 70 deletions
diff --git a/usr.sbin/ypserv/makedbm/makedbm.c b/usr.sbin/ypserv/makedbm/makedbm.c index 7afbe919cd6..e81b676043b 100644 --- a/usr.sbin/ypserv/makedbm/makedbm.c +++ b/usr.sbin/ypserv/makedbm/makedbm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: makedbm.c,v 1.23 2003/07/18 22:58:56 david Exp $ */ +/* $OpenBSD: makedbm.c,v 1.24 2005/05/14 02:32:32 deraadt Exp $ */ /* * Copyright (c) 1994-97 Mats O Jansson <moj@stacken.kth.se> @@ -27,7 +27,7 @@ */ #ifndef LINT -static const char rcsid[] = "$OpenBSD: makedbm.c,v 1.23 2003/07/18 22:58:56 david Exp $"; +static const char rcsid[] = "$OpenBSD: makedbm.c,v 1.24 2005/05/14 02:32:32 deraadt Exp $"; #endif #include <stdio.h> @@ -52,17 +52,17 @@ extern char *__progname; /* from crt0.o */ static int read_line(FILE *fp, char *buf, int size) { - int done; - - done = 0; + int done = 0; do { while (fgets(buf, size, fp)) { int len = strlen(buf); + done += len; if (len > 1 && buf[len-2] == '\\' && buf[len-1] == '\n') { int ch; + buf += len - 2; size -= len - 2; *buf = '\n'; buf[1] = '\0'; @@ -77,7 +77,6 @@ read_line(FILE *fp, char *buf, int size) } } } while (size > 0 && !feof(fp)); - return done; } @@ -97,7 +96,7 @@ add_record(DBM *db, char *str1, char *str2, int check) return; /* already there */ } - val.dptr = str2; + val.dptr = str2; val.dsize = strlen(str2); status = ypdb_store(db, key, val, YPDB_INSERT); @@ -165,15 +164,12 @@ create_database(char *infile, char *database, char *yp_input_file, FILE *data_file; char data_line[4096]; /* XXX: DB bsize = 4096 in ypdb.c */ char myname[MAXHOSTNAMELEN]; - int line_no = 0; - int len; - char *p, *k, *v; - char *slash; + int line_no = 0, len; + char *p, *k, *v, *slash; DBM *new_db; static char mapname[] = "ypdbXXXXXXXXXX"; - char db_mapname[MAXPATHLEN], db_outfile[MAXPATHLEN], - db_tempname[MAXPATHLEN]; - char empty_str[] = ""; + char db_mapname[MAXPATHLEN], db_outfile[MAXPATHLEN]; + char db_tempname[MAXPATHLEN], empty_str[] = ""; if (strcmp(infile,"-") == 0) { data_file = stdin; @@ -236,7 +232,7 @@ create_database(char *infile, char *database, char *yp_input_file, p = (char *) &data_line; - k = p; /* save start of key */ + k = p; /* save start of key */ while (!isspace(*p)) { /* find first "space" */ if (lflag && isupper(*p)) /* if force lower case */ *p = tolower(*p); /* fix it */ @@ -305,8 +301,8 @@ main(int argc, char *argv[]) { int aflag, uflag, bflag, lflag, sflag, Uflag; char *yp_input_file, *yp_output_file; - char *yp_master_name,*yp_domain_name; - char *infile,*outfile; + char *yp_master_name, *yp_domain_name; + char *infile, *outfile; int ch; extern int optind; diff --git a/usr.sbin/ypserv/mknetid/mknetid.c b/usr.sbin/ypserv/mknetid/mknetid.c index 50a606c41cf..b2d1e7e13be 100644 --- a/usr.sbin/ypserv/mknetid/mknetid.c +++ b/usr.sbin/ypserv/mknetid/mknetid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mknetid.c,v 1.12 2003/07/15 06:10:46 deraadt Exp $ */ +/* $OpenBSD: mknetid.c,v 1.13 2005/05/14 02:32:32 deraadt Exp $ */ /* * Copyright (c) 1996 Mats O Jansson <moj@stacken.kth.se> @@ -27,7 +27,7 @@ */ #ifndef LINT -static const char rcsid[] = "$OpenBSD: mknetid.c,v 1.12 2003/07/15 06:10:46 deraadt Exp $"; +static const char rcsid[] = "$OpenBSD: mknetid.c,v 1.13 2005/05/14 02:32:32 deraadt Exp $"; #endif #include <sys/param.h> @@ -90,10 +90,12 @@ read_line(FILE *fp, char *buf, int size) do { while (fgets(buf, size, fp)) { int len = strlen(buf); + done += len; if (len > 1 && buf[len-2] == '\\' && buf[len-1] == '\n') { int ch; + buf += len - 2; size -= len - 2; *buf = '\n'; buf[1] = '\0'; @@ -175,9 +177,8 @@ add_group(char *username, char *gid) if (strcmp(username, u->usr_name) == 0) { if (g != u->usr_gid) { u->gid_count++; - if (u->gid_count < NGROUPS) { - u->gid[u->gid_count]=atoi(gid); - } + if (u->gid_count < NGROUPS) + u->gid[u->gid_count] = atoi(gid); } u = htail[idx]; } @@ -188,10 +189,8 @@ add_group(char *username, char *gid) static void read_passwd(FILE *pfile, char *fname) { - char line[1024]; - int line_no = 0; - int len, colon; - char *p, *k, *u, *g; + char line[1024], *p, *k, *u, *g; + int line_no = 0, len, colon; while (read_line(pfile, line, sizeof(line))) { line_no++; @@ -277,10 +276,8 @@ isgsep(char ch) static void read_group(FILE *gfile, char *fname) { - char line[2048]; - int line_no = 0; - int len, colon; - char *p, *k, *u, *g; + char line[2048], *p, *k, *u, *g; + int line_no = 0, len, colon; while (read_line(gfile, line, sizeof(line))) { line_no++; @@ -395,10 +392,8 @@ print_passwd_group(int qflag, char *domain) static void print_hosts(FILE *pfile, char *fname, char *domain) { - char line[1024]; - int line_no = 0; - int len; - char *p, *k, *u; + char line[1024], *p, *k, *u; + int line_no = 0, len; while (read_line(pfile, line, sizeof(line))) { line_no++; @@ -448,10 +443,8 @@ print_hosts(FILE *pfile, char *fname, char *domain) static void print_netid(FILE *mfile, char *fname) { - char line[1024]; - int line_no = 0; - int len; - char *p, *k, *u; + char line[1024], *p, *k, *u; + int line_no = 0, len; while (read_line(mfile, line, sizeof(line))) { line_no++; diff --git a/usr.sbin/ypserv/stdethers/stdethers.c b/usr.sbin/ypserv/stdethers/stdethers.c index 5faf4dadc48..70b5fbe7a01 100644 --- a/usr.sbin/ypserv/stdethers/stdethers.c +++ b/usr.sbin/ypserv/stdethers/stdethers.c @@ -1,4 +1,4 @@ -/* $OpenBSD: stdethers.c,v 1.12 2005/03/28 06:19:58 tedu Exp $ */ +/* $OpenBSD: stdethers.c,v 1.13 2005/05/14 02:32:33 deraadt Exp $ */ /* * Copyright (c) 1995 Mats O Jansson <moj@stacken.kth.se> @@ -27,7 +27,7 @@ */ #ifndef LINT -static const char rcsid[] = "$OpenBSD: stdethers.c,v 1.12 2005/03/28 06:19:58 tedu Exp $"; +static const char rcsid[] = "$OpenBSD: stdethers.c,v 1.13 2005/05/14 02:32:33 deraadt Exp $"; #endif #include <sys/types.h> @@ -138,21 +138,20 @@ main(int argc, char *argv[]) * Check if we have the whole line */ if (data_line[len-1] != '\n') { - if (argc == 2) { + if (argc == 2) fprintf(stderr, "line %d in \"%s\" is too long", line_no, argv[1]); - } else { + else fprintf(stderr, "line %d in \"stdin\" is too long", line_no); - } } else data_line[len-1] = '\0'; p = (char *) &data_line; - k = p; /* save start of key */ + k = p; /* save start of key */ while (!isspace(*p)) /* find first "space" */ p++; while (isspace(*p)) /* move over "space" */ @@ -162,13 +161,12 @@ main(int argc, char *argv[]) while (*p != '\0') /* find end of string */ p++; - if (ether_line(data_line, ð_addr, hostname) == 0) { + if (ether_line(data_line, ð_addr, hostname) == 0) fprintf(stdout, "%s\t%s\n", NTOA(ð_addr), hostname); - } else { + else fprintf(stderr, "stdethers: ignoring line %d: \"%s\"\n", line_no, data_line); - } } return(0); } diff --git a/usr.sbin/ypserv/stdhosts/stdhosts.c b/usr.sbin/ypserv/stdhosts/stdhosts.c index 14e97efbea0..90003af500f 100644 --- a/usr.sbin/ypserv/stdhosts/stdhosts.c +++ b/usr.sbin/ypserv/stdhosts/stdhosts.c @@ -1,4 +1,4 @@ -/* $OpenBSD: stdhosts.c,v 1.13 2005/05/14 02:30:40 deraadt Exp $ */ +/* $OpenBSD: stdhosts.c,v 1.14 2005/05/14 02:32:33 deraadt Exp $ */ /* * Copyright (c) 1994 Mats O Jansson <moj@stacken.kth.se> @@ -27,7 +27,7 @@ */ #ifndef LINT -static const char rcsid[] = "$OpenBSD: stdhosts.c,v 1.13 2005/05/14 02:30:40 deraadt Exp $"; +static const char rcsid[] = "$OpenBSD: stdhosts.c,v 1.14 2005/05/14 02:32:33 deraadt Exp $"; #endif #include <sys/types.h> @@ -40,21 +40,25 @@ static const char rcsid[] = "$OpenBSD: stdhosts.c,v 1.13 2005/05/14 02:30:40 der #include <ctype.h> #include <err.h> -static int read_line(FILE *fp, char *buf, int size) +static int +read_line(FILE *fp, char *buf, int size) { int done = 0; do { while (fgets(buf, size, fp)) { int len = strlen(buf); + done += len; if (len > 1 && buf[len-2] == '\\' && buf[len-1] == '\n') { int ch; + buf += len - 2; size -= len - 2; *buf = '\n'; buf[1] = '\0'; + /* * Skip leading white space on next line */ @@ -72,12 +76,10 @@ static int read_line(FILE *fp, char *buf, int size) int main(int argc, char *argv[]) { - FILE *data_file; - char data_line[1024]; - int line_no = 0; - int len; - char *p, *k, *v; + char data_line[1024], *p, *k, *v; + int line_no = 0, len; struct in_addr host_addr; + FILE *data_file; if (argc > 2) { fprintf(stderr, "usage: stdhosts [file]\n"); @@ -113,7 +115,7 @@ main(int argc, char *argv[]) data_line[len-1] = '\0'; p = (char *) &data_line; - k = p; /* save start of key */ + k = p; /* save start of key */ while (!isspace(*p)) /* find first "space" */ p++; while (isspace(*p)) /* replace space with <NUL> */ diff --git a/usr.sbin/ypserv/yppush/yppush.c b/usr.sbin/ypserv/yppush/yppush.c index d449cf514fc..8798c75a72c 100644 --- a/usr.sbin/ypserv/yppush/yppush.c +++ b/usr.sbin/ypserv/yppush/yppush.c @@ -1,4 +1,4 @@ -/* $OpenBSD: yppush.c,v 1.21 2003/07/15 06:10:46 deraadt Exp $ */ +/* $OpenBSD: yppush.c,v 1.22 2005/05/14 02:32:33 deraadt Exp $ */ /* * Copyright (c) 1995 Mats O Jansson <moj@stacken.kth.se> @@ -27,7 +27,7 @@ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: yppush.c,v 1.21 2003/07/15 06:10:46 deraadt Exp $"; +static const char rcsid[] = "$OpenBSD: yppush.c,v 1.22 2005/05/14 02:32:33 deraadt Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -150,11 +150,10 @@ push(int inlen, char *indata) char host[MAXHOSTNAMELEN]; CLIENT *client; SVCXPRT *transp; - int sock = RPC_ANYSOCK; + int sock = RPC_ANYSOCK, status; u_int prog; bool_t sts = 0; pid_t pid; - int status; struct rusage res; snprintf(host, sizeof host, "%*.*s" ,inlen ,inlen, indata); diff --git a/usr.sbin/ypserv/ypserv/ypserv_proc.c b/usr.sbin/ypserv/ypserv/ypserv_proc.c index 53753e4a63c..1d588a73dab 100644 --- a/usr.sbin/ypserv/ypserv/ypserv_proc.c +++ b/usr.sbin/ypserv/ypserv/ypserv_proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ypserv_proc.c,v 1.23 2003/07/15 06:10:46 deraadt Exp $ */ +/* $OpenBSD: ypserv_proc.c,v 1.24 2005/05/14 02:32:33 deraadt Exp $ */ /* * Copyright (c) 1994 Mats O Jansson <moj@stacken.kth.se> @@ -27,7 +27,7 @@ */ #ifndef LINT -static const char rcsid[] = "$OpenBSD: ypserv_proc.c,v 1.23 2003/07/15 06:10:46 deraadt Exp $"; +static const char rcsid[] = "$OpenBSD: ypserv_proc.c,v 1.24 2005/05/14 02:32:33 deraadt Exp $"; #endif #include <rpc/rpc.h> @@ -660,7 +660,7 @@ ypoldproc_first_1_svc(yprequest *argp, struct svc_req *rqstp) strchr(argp->ypfirst_req_map, '/')) goto bail; res.yp_resptype = YPFIRST_RESPTYPE; - res.ypfirst_resp_valptr = res.ypfirst_resp_keyptr = ""; + res.ypfirst_resp_valptr = res.ypfirst_resp_keyptr = ""; res.ypfirst_resp_valsize = res.ypfirst_resp_keysize = 0; if (argp->yp_reqtype != YPREQ_NOKEY) { @@ -708,7 +708,7 @@ ypoldproc_next_1_svc(yprequest *argp, struct svc_req *rqstp) strchr(argp->ypnext_req_map, '/')) goto bail; res.yp_resptype = YPNEXT_RESPTYPE; - res.ypnext_resp_valptr = res.ypnext_resp_keyptr = ""; + res.ypnext_resp_valptr = res.ypnext_resp_keyptr = ""; res.ypnext_resp_valsize = res.ypnext_resp_keysize = 0; if (argp->yp_reqtype != YPNEXT_REQTYPE) { diff --git a/usr.sbin/ypserv/ypxfr/ypxfr.c b/usr.sbin/ypserv/ypxfr/ypxfr.c index b5aab324b3a..aed13268cd6 100644 --- a/usr.sbin/ypserv/ypxfr/ypxfr.c +++ b/usr.sbin/ypserv/ypxfr/ypxfr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ypxfr.c,v 1.32 2004/07/08 06:20:46 matthieu Exp $ */ +/* $OpenBSD: ypxfr.c,v 1.33 2005/05/14 02:32:33 deraadt Exp $ */ /* * Copyright (c) 1994 Mats O Jansson <moj@stacken.kth.se> @@ -27,7 +27,7 @@ */ #ifndef LINT -static const char rcsid[] = "$OpenBSD: ypxfr.c,v 1.32 2004/07/08 06:20:46 matthieu Exp $"; +static const char rcsid[] = "$OpenBSD: ypxfr.c,v 1.33 2005/05/14 02:32:33 deraadt Exp $"; #endif #include <sys/types.h> @@ -213,14 +213,11 @@ add_order(DBM *db, u_int32_t ordernum) static int add_master(CLIENT *client, char *domain, char *map, DBM *db) { - char keystr[] = YP_MASTER_KEY, *master; + char keystr[] = YP_MASTER_KEY, *master = NULL; datum key, val; int status; - master = NULL; - /* Get MASTER */ - status = yp_master_host(client, domain, map, &master); if (master != NULL) { |