From 353451395bf3ca661bb520e825da93d58c2b81ef Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Sat, 29 Jun 2002 23:19:50 +0000 Subject: ansi --- sbin/mountd/mountd.c | 227 +++++++++++++++++---------------------------------- 1 file changed, 76 insertions(+), 151 deletions(-) (limited to 'sbin/mountd') diff --git a/sbin/mountd/mountd.c b/sbin/mountd/mountd.c index 9b9336d2913..7135e436eb0 100644 --- a/sbin/mountd/mountd.c +++ b/sbin/mountd/mountd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mountd.c,v 1.48 2002/06/09 08:13:08 todd Exp $ */ +/* $OpenBSD: mountd.c,v 1.49 2002/06/29 23:19:49 deraadt Exp $ */ /* $NetBSD: mountd.c,v 1.31 1996/02/18 11:57:53 fvdl Exp $ */ /* @@ -167,7 +167,7 @@ void free_dir(struct dirlist *); void free_exp(struct exportlist *); void free_grp(struct grouplist *); void free_host(struct hostlist *); -void new_exportlist(void); +void new_exportlist(int signo); void get_exportlist(void); int get_host(char *, struct grouplist *, struct grouplist *); int get_num(char *); @@ -185,7 +185,7 @@ void out_of_mem(void); void parsecred(char *, struct ucred *); int put_exlist(struct dirlist *, XDR *, struct dirlist *, int *); int scan_tree(struct dirlist *, in_addr_t); -void send_umntall(void); +void send_umntall(int signo); int umntall_each(caddr_t, struct sockaddr_in *); int xdr_dir(XDR *, char *); int xdr_explist(XDR *, caddr_t); @@ -227,9 +227,7 @@ volatile sig_atomic_t gotterm; * and "-n" to allow nonroot mount. */ int -main(argc, argv) - int argc; - char **argv; +main(int argc, char *argv[]) { SVCXPRT *udptransp, *tcptransp; FILE *pidfile; @@ -365,28 +363,25 @@ mountd_svc_run() * The mount rpc service */ void -mntsrv(rqstp, transp) - struct svc_req *rqstp; - SVCXPRT *transp; +mntsrv(struct svc_req *rqstp, SVCXPRT *transp) { + char rpcpath[RPCMNT_PATHLEN+1], dirpath[MAXPATHLEN]; + struct hostent *hp = NULL; struct exportlist *ep; - struct dirlist *dp; + sigset_t sighup_mask; + int defset, hostset; struct fhreturn fhr; - struct stat stb; + struct dirlist *dp; struct statfs fsb; - struct hostent *hp; + struct stat stb; in_addr_t saddr; u_short sport; - char rpcpath[RPCMNT_PATHLEN+1], dirpath[MAXPATHLEN]; long bad = 0; - int defset, hostset; - sigset_t sighup_mask; sigemptyset(&sighup_mask); sigaddset(&sighup_mask, SIGHUP); saddr = transp->xp_raddr.sin_addr.s_addr; sport = ntohs(transp->xp_raddr.sin_port); - hp = NULL; switch (rqstp->rq_proc) { case NULLPROC: if (!svc_sendreply(transp, xdr_void, NULL)) @@ -394,8 +389,7 @@ mntsrv(rqstp, transp) return; case RPCMNT_MOUNT: if (debug) - fprintf(stderr, - "Got mount request from %s\n", + fprintf(stderr, "Got mount request from %s\n", inet_ntoa(transp->xp_raddr.sin_addr)); if (sport >= IPPORT_RESERVED && resvport_only) { syslog(LOG_NOTICE, @@ -532,9 +526,7 @@ mntsrv(rqstp, transp) * Xdr conversion for a dirpath string */ int -xdr_dir(xdrsp, dirp) - XDR *xdrsp; - char *dirp; +xdr_dir(XDR *xdrsp, char *dirp) { return (xdr_string(xdrsp, &dirp, RPCMNT_PATHLEN)); } @@ -543,9 +535,7 @@ xdr_dir(xdrsp, dirp) * Xdr routine to generate file handle reply */ int -xdr_fhs(xdrsp, cp) - XDR *xdrsp; - caddr_t cp; +xdr_fhs(XDR *xdrsp, caddr_t cp) { struct fhreturn *fhrp = (struct fhreturn *)cp; long ok = 0, len, auth; @@ -571,13 +561,10 @@ xdr_fhs(xdrsp, cp) } int -xdr_mlist(xdrsp, cp) - XDR *xdrsp; - caddr_t cp; +xdr_mlist(XDR *xdrsp, caddr_t cp) { + int true = 1, false = 0; struct mountlist *mlp; - int true = 1; - int false = 0; char *strp; mlp = mlhead; @@ -601,13 +588,10 @@ xdr_mlist(xdrsp, cp) * Xdr conversion for export list */ int -xdr_explist(xdrsp, cp) - XDR *xdrsp; - caddr_t cp; +xdr_explist(XDR *xdrsp, caddr_t cp) { struct exportlist *ep; - int false = 0; - int putdef; + int false = 0, putdef; sigset_t sighup_mask; sigemptyset(&sighup_mask); @@ -637,17 +621,12 @@ errout: * directory paths. */ int -put_exlist(dp, xdrsp, adp, putdefp) - struct dirlist *dp; - XDR *xdrsp; - struct dirlist *adp; - int *putdefp; +put_exlist(struct dirlist *dp, XDR *xdrsp, struct dirlist *adp, + int *putdefp) { + int true = 1, false = 0, gotalldir = 0; struct grouplist *grp; struct hostlist *hp; - int true = 1; - int false = 0; - int gotalldir = 0; char *strp; if (dp) { @@ -702,7 +681,7 @@ char line[LINESIZ]; FILE *exp_file; void -new_exportlist() +new_exportlist(int signo) { gothup = 1; @@ -712,8 +691,11 @@ new_exportlist() * Get the export list */ void -get_exportlist() +get_exportlist(void) { + int len, has_host, exflags, got_nondir, dirplen = 0, num; + int lookup_failed, num_hosts, i, netgrp; + char *cp, *endcp, *dirp = NULL, *hst, *usr, *dom, savedc; struct exportlist *ep, *ep2; struct grouplist *grp, *tgrp; struct exportlist **epp; @@ -721,9 +703,6 @@ get_exportlist() struct statfs fsb, *fsp; struct hostent *hpe; struct ucred anon; - char *cp, *endcp, *dirp = NULL, *hst, *usr, *dom, savedc; - int len, has_host, exflags, got_nondir, dirplen = 0, num, i, netgrp; - int lookup_failed, num_hosts; /* * First, get rid of the old list @@ -1042,7 +1021,7 @@ nextline: * Allocate an export list element */ struct exportlist * -get_exp() +get_exp(void) { struct exportlist *ep; @@ -1072,9 +1051,7 @@ get_grp() * Clean up upon an error in get_exportlist(). */ void -getexp_err(ep, grp) - struct exportlist *ep; - struct grouplist *grp; +getexp_err(struct exportlist *ep, struct grouplist *grp) { struct grouplist *tgrp; @@ -1092,8 +1069,7 @@ getexp_err(ep, grp) * Search the export list for a matching fs. */ struct exportlist * -ex_search(fsid) - fsid_t *fsid; +ex_search(fsid_t *fsid) { struct exportlist *ep; @@ -1111,10 +1087,7 @@ ex_search(fsid) * Add a directory path to the list. */ char * -add_expdir(dpp, cp, len) - struct dirlist **dpp; - char *cp; - int len; +add_expdir(struct dirlist **dpp, char *cp, int len) { struct dirlist *dp; @@ -1133,11 +1106,8 @@ add_expdir(dpp, cp, len) * and update the entry for host. */ void -hang_dirp(dp, grp, ep, flags) - struct dirlist *dp; - struct grouplist *grp; - struct exportlist *ep; - int flags; +hang_dirp(struct dirlist *dp, struct grouplist *grp, struct exportlist *ep, + int flags) { struct hostlist *hp; struct dirlist *dp2; @@ -1174,11 +1144,8 @@ hang_dirp(dp, grp, ep, flags) * for the new directory or adding the new node. */ void -add_dlist(dpp, newdp, grp, flags) - struct dirlist **dpp; - struct dirlist *newdp; - struct grouplist *grp; - int flags; +add_dlist(struct dirlist **dpp, struct dirlist *newdp, struct grouplist *grp, + int flags) { struct dirlist *dp; struct hostlist *hp; @@ -1221,9 +1188,7 @@ add_dlist(dpp, newdp, grp, flags) * Search for a dirpath on the export point. */ struct dirlist * -dirp_search(dp, dirpath) - struct dirlist *dp; - char *dirpath; +dirp_search(struct dirlist *dp, char *dirpath) { int cmp; @@ -1243,11 +1208,7 @@ dirp_search(dp, dirpath) * Scan for a host match in a directory tree. */ int -chk_host(dp, saddr, defsetp, hostsetp) - struct dirlist *dp; - in_addr_t saddr; - int *defsetp; - int *hostsetp; +chk_host(struct dirlist *dp, in_addr_t saddr, int *defsetp, int *hostsetp) { struct hostlist *hp; struct grouplist *grp; @@ -1289,9 +1250,7 @@ chk_host(dp, saddr, defsetp, hostsetp) * Scan tree for a host that matches the address. */ int -scan_tree(dp, saddr) - struct dirlist *dp; - in_addr_t saddr; +scan_tree(struct dirlist *dp, in_addr_t saddr) { int defset, hostset; @@ -1310,8 +1269,7 @@ scan_tree(dp, saddr) * Traverse the dirlist tree and free it up. */ void -free_dir(dp) - struct dirlist *dp; +free_dir(struct dirlist *dp) { if (dp) { @@ -1328,16 +1286,11 @@ free_dir(dp) * -