summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/rpc.lockd/handles.c21
-rw-r--r--usr.sbin/rpc.lockd/lockd.c145
-rw-r--r--usr.sbin/rpc.lockd/lockd.h15
-rw-r--r--usr.sbin/rpc.lockd/procs.c788
-rw-r--r--usr.sbin/rpc.lockd/test.c195
5 files changed, 498 insertions, 666 deletions
diff --git a/usr.sbin/rpc.lockd/handles.c b/usr.sbin/rpc.lockd/handles.c
index abe9c0bff0c..ae3dd84cb4f 100644
--- a/usr.sbin/rpc.lockd/handles.c
+++ b/usr.sbin/rpc.lockd/handles.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: handles.c,v 1.2 1997/08/10 21:06:39 millert Exp $ */
+/* $OpenBSD: handles.c,v 1.3 1997/09/17 23:09:35 deraadt Exp $ */
/*
* Copyright (c) 1995
@@ -48,13 +48,12 @@
*/
-typedef struct fdinfo
-{
- int fd; /* The file descriptor itself */
- int ref_count; /* Count of hosts using the fd - fd is */
- /* closed when this reaches zero */
- ino_t inode_no; /* The inode number of this file. */
- dev_t device; /* device on which the file lives. */
- struct fdinfo *next; /* Chain of FdInfo structures */
- struct fdinfo *prev;
-} FdInfo;
+typedef struct fdinfo {
+ int fd; /* The file descriptor itself */
+ int ref_count; /* Count of hosts using the fd - fd is */
+ /* closed when this reaches zero */
+ ino_t inode_no; /* The inode number of this file. */
+ dev_t device; /* device on which the file lives. */
+ struct fdinfo *next; /* Chain of FdInfo structures */
+ struct fdinfo *prev;
+} FdInfo;
diff --git a/usr.sbin/rpc.lockd/lockd.c b/usr.sbin/rpc.lockd/lockd.c
index 7aa1b9d9b87..51aac43f0b6 100644
--- a/usr.sbin/rpc.lockd/lockd.c
+++ b/usr.sbin/rpc.lockd/lockd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lockd.c,v 1.3 1997/08/10 21:06:40 millert Exp $ */
+/* $OpenBSD: lockd.c,v 1.4 1997/09/17 23:09:36 deraadt Exp $ */
/*
* Copyright (c) 1995
@@ -33,89 +33,92 @@
*
*/
-
-/* main() function for NFS lock daemon. Most of the code in this */
-/* file was generated by running rpcgen /usr/include/rpcsvc/nlm_prot.x */
-/* The actual program logic is in the file procs.c */
+#include <sys/param.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <rpc/rpc.h>
+#include <rpc/pmap_clnt.h>
+#include <rpcsvc/sm_inter.h>
+#include "nlm_prot.h"
+#include <arpa/inet.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <stdlib.h>
+#include <string.h>
+#include <netdb.h>
#include "lockd.h"
extern void nlm_prog_1 __P((struct svc_req, register SVCXPRT));
extern void nlm_prog_3 __P((struct svc_req, register SVCXPRT));
-int debug_level = 0; /* Zero means no debugging syslog() calls */
+int debug_level = 0; /* Zero means no debugging syslog() calls */
-#if 1
-int _rpcsvcdirty;
-#endif
+int _rpcsvcdirty;
int
main(argc, argv)
- int argc;
- char **argv;
+ int argc;
+ char **argv;
{
- SVCXPRT *transp;
-
- if (argc > 1)
- {
- if (strncmp(argv[1], "-d", 2))
- {
- fprintf(stderr, "Usage: rpc.lockd [-d [<debuglevel>]]\n");
- exit(1);
- }
- if (argc > 2) debug_level = atoi(argv[2]);
- else debug_level = atoi(argv[1] + 2);
- /* Ensure at least some debug if -d with no specified level */
- if (!debug_level) debug_level = 1;
- }
-
- (void)pmap_unset(NLM_PROG, NLM_VERS);
- (void)pmap_unset(NLM_PROG, NLM_VERSX);
+ SVCXPRT *transp;
- transp = svcudp_create(RPC_ANYSOCK);
- if (transp == NULL)
- {
- (void)fprintf(stderr, "cannot create udp service.\n");
- exit(1);
- }
- if (!svc_register(transp, NLM_PROG, NLM_VERS, (void (*)())nlm_prog_1, IPPROTO_UDP))
- {
- (void)fprintf(stderr, "unable to register (NLM_PROG, NLM_VERS, udp).\n");
- exit(1);
- }
- if (!svc_register(transp, NLM_PROG, NLM_VERSX, (void (*)())nlm_prog_3, IPPROTO_UDP))
- {
- (void)fprintf(stderr, "unable to register (NLM_PROG, NLM_VERSX, udp).\n");
- exit(1);
- }
+ if (argc > 1) {
+ if (strncmp(argv[1], "-d", 2)) {
+ fprintf(stderr, "Usage: rpc.lockd [-d debuglevel]\n");
+ exit(1);
+ }
+ if (argc > 2)
+ debug_level = atoi(argv[2]);
+ else
+ debug_level = atoi(argv[1] + 2);
+ if (!debug_level)
+ debug_level = 1;
+ }
+ (void) pmap_unset(NLM_PROG, NLM_VERS);
+ (void) pmap_unset(NLM_PROG, NLM_VERSX);
- transp = svctcp_create(RPC_ANYSOCK, 0, 0);
- if (transp == NULL)
- {
- (void)fprintf(stderr, "cannot create tcp service.\n");
- exit(1);
- }
- if (!svc_register(transp, NLM_PROG, NLM_VERS, (void (*)())nlm_prog_1, IPPROTO_TCP))
- {
- (void)fprintf(stderr, "unable to register (NLM_PROG, NLM_VERS, tcp).\n");
- exit(1);
- }
- if (!svc_register(transp, NLM_PROG, NLM_VERSX, (void (*)())nlm_prog_3, IPPROTO_TCP))
- {
- (void)fprintf(stderr, "unable to register (NLM_PROG, NLM_VERSX, tcp).\n");
- exit(1);
- }
+ transp = svcudp_create(RPC_ANYSOCK);
+ if (transp == NULL) {
+ fprintf(stderr, "cannot create udp service.\n");
+ exit(1);
+ }
+ if (!svc_register(transp, NLM_PROG, NLM_VERS,
+ (void (*) ()) nlm_prog_1, IPPROTO_UDP)) {
+ fprintf(stderr, "unable to register (NLM_PROG, NLM_VERS, udp).\n");
+ exit(1);
+ }
+ if (!svc_register(transp, NLM_PROG, NLM_VERSX,
+ (void (*) ()) nlm_prog_3, IPPROTO_UDP)) {
+ fprintf(stderr, "unable to register (NLM_PROG, NLM_VERSX, udp).\n");
+ exit(1);
+ }
+ transp = svctcp_create(RPC_ANYSOCK, 0, 0);
+ if (transp == NULL) {
+ fprintf(stderr, "cannot create tcp service.\n");
+ exit(1);
+ }
+ if (!svc_register(transp, NLM_PROG, NLM_VERS,
+ (void (*) ()) nlm_prog_1, IPPROTO_TCP)) {
+ fprintf(stderr, "unable to register (NLM_PROG, NLM_VERS, tcp).\n");
+ exit(1);
+ }
+ if (!svc_register(transp, NLM_PROG, NLM_VERSX,
+ (void (*) ()) nlm_prog_3, IPPROTO_TCP)) {
+ fprintf(stderr, "unable to register (NLM_PROG, NLM_VERSX, tcp).\n");
+ exit(1);
+ }
- /* Note that it is NOT sensible to run this program from inetd - the */
- /* protocol assumes that it will run immediately at boot time. */
- if (daemon(0,0)) {
- perror("cannot fork");
- exit(1);
- }
- openlog("rpc.lockd", 0, LOG_DAEMON);
- if (debug_level) syslog(LOG_INFO, "Starting, debug level %d", debug_level);
- else syslog(LOG_INFO, "Starting");
+ if (daemon(0, 0)) {
+ perror("cannot fork");
+ exit(1);
+ }
+ openlog("rpc.lockd", 0, LOG_DAEMON);
+ if (debug_level)
+ syslog(LOG_INFO, "Starting, debug level %d", debug_level);
+ else
+ syslog(LOG_INFO, "Starting");
- svc_run(); /* Should never return */
- exit(1);
+ svc_run();
+ exit(1);
}
diff --git a/usr.sbin/rpc.lockd/lockd.h b/usr.sbin/rpc.lockd/lockd.h
index 50f9c57b9a0..154089c9d04 100644
--- a/usr.sbin/rpc.lockd/lockd.h
+++ b/usr.sbin/rpc.lockd/lockd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: lockd.h,v 1.2 1997/08/10 21:06:40 millert Exp $ */
+/* $OpenBSD: lockd.h,v 1.3 1997/09/17 23:09:37 deraadt Exp $ */
/*
* Copyright (c) 1995
@@ -33,17 +33,4 @@
*
*/
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <rpc/rpc.h>
-#include <rpc/pmap_clnt.h>
-#include <syslog.h>
-#include <rpcsvc/sm_inter.h> /* protocol to talk to rpc.statd */
-#include "nlm_prot.h" /* The protocol we are implementing */
-
-
-/* global variables ------------------------------------------------------- */
extern int debug_level;
diff --git a/usr.sbin/rpc.lockd/procs.c b/usr.sbin/rpc.lockd/procs.c
index 5114c193aa6..354e343c834 100644
--- a/usr.sbin/rpc.lockd/procs.c
+++ b/usr.sbin/rpc.lockd/procs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: procs.c,v 1.6 1997/08/10 21:06:40 millert Exp $ */
+/* $OpenBSD: procs.c,v 1.7 1997/09/17 23:09:38 deraadt Exp $ */
/*
* Copyright (c) 1995
@@ -33,558 +33,404 @@
*
*/
-
-
-#include "lockd.h"
-
-#include <sys/param.h> /* for MAXHOSTNAMELEN */
+#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <rpc/rpc.h>
+#include <rpc/pmap_clnt.h>
+#include <rpcsvc/sm_inter.h>
+#include "nlm_prot.h"
#include <arpa/inet.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <stdlib.h>
+#include <string.h>
#include <netdb.h>
+#include "lockd.h"
-#define CLIENT_CACHE_SIZE 64 /* No. of client sockets cached */
-#define CLIENT_CACHE_LIFETIME 120 /* In seconds */
-
-
-/* log_from_addr ----------------------------------------------------------- */
-/*
- Purpose: Log name of function called and source address
- Returns: Nothing
- Notes: Extracts the source address from the transport handle
- passed in as part of the called procedure specification
-*/
+#define CLIENT_CACHE_SIZE 64 /* No. of client sockets cached */
+#define CLIENT_CACHE_LIFETIME 120 /* In seconds */
-static void log_from_addr(char *fun_name, struct svc_req *req)
+static void
+log_from_addr(fun_name, req)
+ char *fun_name;
+ struct svc_req *req;
{
- struct sockaddr_in *addr;
- struct hostent *host;
- char hostname_buf[MAXHOSTNAMELEN];
-
- addr = svc_getcaller(req->rq_xprt);
- host = gethostbyaddr((char *)&(addr->sin_addr), addr->sin_len, AF_INET);
- if (host)
- {
- strncpy(hostname_buf, host->h_name, sizeof(hostname_buf) -1);
- hostname_buf[sizeof(hostname_buf) -1] = '\0';
- }
- else /* No hostname available - print raw address */
- {
- strcpy(hostname_buf, inet_ntoa(addr->sin_addr));
- }
-
- syslog(LOG_DEBUG, "%s from %s", fun_name, hostname_buf);
+ struct sockaddr_in *addr;
+ struct hostent *host;
+ char hostname_buf[MAXHOSTNAMELEN];
+
+ addr = svc_getcaller(req->rq_xprt);
+ host = gethostbyaddr((char *) &(addr->sin_addr), addr->sin_len, AF_INET);
+ if (host) {
+ strncpy(hostname_buf, host->h_name, sizeof(hostname_buf) - 1);
+ hostname_buf[sizeof(hostname_buf) - 1] = '\0';
+ } else
+ strcpy(hostname_buf, inet_ntoa(addr->sin_addr));
+ syslog(LOG_DEBUG, "%s from %s", fun_name, hostname_buf);
}
-/* get_client -------------------------------------------------------------- */
-/*
- Purpose: Get a CLIENT* for making RPC calls to lockd on given host
- Returns: CLIENT* pointer, from clnt_udp_create, or NULL if error
- Notes: Creating a CLIENT* is quite expensive, involving a
- conversation with the remote portmapper to get the
- port number. Since a given client is quite likely
- to make several locking requests in succession, it is
- desirable to cache the created CLIENT*.
-
- Since we are using UDP rather than TCP, there is no cost
- to the remote system in keeping these cached indefinitely.
- Unfortunately there is a snag: if the remote system
- reboots, the cached portmapper results will be invalid,
- and we will never detect this since all of the xxx_msg()
- calls return no result - we just fire off a udp packet
- and hope for the best.
-
- We solve this by discarding cached values after two
- minutes, regardless of whether they have been used
- in the meanwhile (since a bad one might have been used
- plenty of times, as the host keeps retrying the request
- and we keep sending the reply back to the wrong port).
-
- Given that the entries will always expire in the order
- that they were created, there is no point in a LRU
- algorithm for when the cache gets full - entries are
- always re-used in sequence.
-*/
-
static CLIENT *clnt_cache_ptr[CLIENT_CACHE_SIZE];
-static long clnt_cache_time[CLIENT_CACHE_SIZE]; /* time entry created */
+static long clnt_cache_time[CLIENT_CACHE_SIZE]; /* time entry created */
static struct in_addr clnt_cache_addr[CLIENT_CACHE_SIZE];
static int clnt_cache_next_to_use = 0;
-static CLIENT *get_client(struct sockaddr_in *host_addr)
+static CLIENT *
+get_client(host_addr)
+ struct sockaddr_in *host_addr;
{
- CLIENT *client;
- int sock_no;
- struct timeval retry_time, time_now;
- int i;
-
- gettimeofday(&time_now, NULL);
-
- /* Search for the given client in the cache, zapping any expired */
- /* entries that we happen to notice in passing. */
- for (i = 0; i < CLIENT_CACHE_SIZE; i++)
- {
- client = clnt_cache_ptr[i];
- if (client &&
- ((clnt_cache_time[i] + CLIENT_CACHE_LIFETIME) < time_now.tv_sec))
- {
- /* Cache entry has expired. */
- if (debug_level > 3) syslog(LOG_DEBUG, "Expired CLIENT* in cache");
- clnt_cache_time[i] = 0L;
- clnt_destroy(client);
- clnt_cache_ptr[i] = NULL;
- client = NULL;
- }
-
- if (client && !memcmp(&clnt_cache_addr[i], &host_addr->sin_addr,
- sizeof(struct in_addr)))
- {
- /* Found it! */
- if (debug_level > 3) syslog(LOG_DEBUG, "Found CLIENT* in cache");
- return (client);
- }
- }
-
- /* Not found in cache. Free the next entry if it is in use */
- if (clnt_cache_ptr[clnt_cache_next_to_use])
- {
- clnt_destroy(clnt_cache_ptr[clnt_cache_next_to_use]);
- clnt_cache_ptr[clnt_cache_next_to_use] = NULL;
- }
-
- /* Create the new client handle */
-
- sock_no = RPC_ANYSOCK;
- retry_time.tv_sec = 5;
- retry_time.tv_usec = 0;
- host_addr->sin_port = 0; /* Force consultation with portmapper */
- client = clntudp_create(host_addr, NLM_PROG, NLM_VERS, retry_time, &sock_no);
- if (!client)
- {
- syslog(LOG_ERR, clnt_spcreateerror("clntudp_create"));
- syslog(LOG_ERR, "Unable to return result to %s",
- inet_ntoa(host_addr->sin_addr));
- return NULL;
- }
-
- /* Success - update the cache entry */
- clnt_cache_ptr[clnt_cache_next_to_use] = client;
- clnt_cache_addr[clnt_cache_next_to_use] = host_addr->sin_addr;
- clnt_cache_time[clnt_cache_next_to_use] = time_now.tv_sec;
- if (++clnt_cache_next_to_use > CLIENT_CACHE_SIZE)
- clnt_cache_next_to_use = 0;
-
- /* Disable the default timeout, so we can specify our own in calls */
- /* to clnt_call(). [note that the timeout is a different concept */
- /* from the retry period set in clnt_udp_create() above.] */
- retry_time.tv_sec = -1;
- retry_time.tv_usec = -1;
- clnt_control(client, CLSET_TIMEOUT, &retry_time);
-
- if (debug_level > 3) syslog(LOG_DEBUG, "Created CLIENT* for %s",
- inet_ntoa(host_addr->sin_addr));
- return client;
+ CLIENT *client;
+ int sock_no, i;
+ struct timeval retry_time, time_now;
+
+ gettimeofday(&time_now, NULL);
+
+ /* Search for the given client in the cache, zapping any expired */
+ /* entries that we happen to notice in passing. */
+ for (i = 0; i < CLIENT_CACHE_SIZE; i++) {
+ client = clnt_cache_ptr[i];
+ if (client &&
+ ((clnt_cache_time[i] + CLIENT_CACHE_LIFETIME) < time_now.tv_sec)) {
+ /* Cache entry has expired. */
+ if (debug_level > 3)
+ syslog(LOG_DEBUG, "Expired CLIENT* in cache");
+ clnt_cache_time[i] = 0L;
+ clnt_destroy(client);
+ clnt_cache_ptr[i] = NULL;
+ client = NULL;
+ }
+ if (client && !memcmp(&clnt_cache_addr[i], &host_addr->sin_addr,
+ sizeof(struct in_addr))) {
+ /* Found it! */
+ if (debug_level > 3)
+ syslog(LOG_DEBUG, "Found CLIENT* in cache");
+ return (client);
+ }
+ }
+
+ /* Not found in cache. Free the next entry if it is in use */
+ if (clnt_cache_ptr[clnt_cache_next_to_use]) {
+ clnt_destroy(clnt_cache_ptr[clnt_cache_next_to_use]);
+ clnt_cache_ptr[clnt_cache_next_to_use] = NULL;
+ }
+
+ sock_no = RPC_ANYSOCK;
+ retry_time.tv_sec = 5;
+ retry_time.tv_usec = 0;
+ host_addr->sin_port = 0;
+ client = clntudp_create(host_addr, NLM_PROG, NLM_VERS, retry_time, &sock_no);
+ if (!client) {
+ syslog(LOG_ERR, clnt_spcreateerror("clntudp_create"));
+ syslog(LOG_ERR, "Unable to return result to %s",
+ inet_ntoa(host_addr->sin_addr));
+ return (NULL);
+ }
+ clnt_cache_ptr[clnt_cache_next_to_use] = client;
+ clnt_cache_addr[clnt_cache_next_to_use] = host_addr->sin_addr;
+ clnt_cache_time[clnt_cache_next_to_use] = time_now.tv_sec;
+ if (++clnt_cache_next_to_use > CLIENT_CACHE_SIZE)
+ clnt_cache_next_to_use = 0;
+
+ retry_time.tv_sec = -1;
+ retry_time.tv_usec = -1;
+ clnt_control(client, CLSET_TIMEOUT, &retry_time);
+
+ if (debug_level > 3)
+ syslog(LOG_DEBUG, "Created CLIENT* for %s",
+ inet_ntoa(host_addr->sin_addr));
+ return (client);
}
-/* transmit_result --------------------------------------------------------- */
-/*
- Purpose: Transmit result for nlm_xxx_msg pseudo-RPCs
- Returns: Nothing - we have no idea if the datagram got there
- Notes: clnt_call() will always fail (with timeout) as we are
- calling it with timeout 0 as a hack to just issue a datagram
- without expecting a result
-*/
-
-static void transmit_result(int opcode, nlm_res *result, struct svc_req *req)
+static void
+transmit_result(opcode, result, req)
+ int opcode;
+ nlm_res *result;
+ struct svc_req *req;
{
- static char dummy;
- struct sockaddr_in *addr;
- CLIENT *cli;
- int success;
- struct timeval timeo;
-
- addr = svc_getcaller(req->rq_xprt);
- if ((cli = get_client(addr)))
- {
- timeo.tv_sec = 0; /* No timeout - not expecting response */
- timeo.tv_usec = 0;
-
- success = clnt_call(cli, opcode, xdr_nlm_res, result, xdr_void,
- &dummy, timeo);
-
- if (debug_level > 2) syslog(LOG_DEBUG, "clnt_call returns %d\n", success);
- }
+ static char dummy;
+ struct sockaddr_in *addr;
+ CLIENT *cli;
+ int success;
+ struct timeval timeo;
+
+ addr = svc_getcaller(req->rq_xprt);
+ if ((cli = get_client(addr))) {
+ timeo.tv_sec = 0;
+ timeo.tv_usec = 0;
+
+ success = clnt_call(cli, opcode, xdr_nlm_res, result, xdr_void,
+ &dummy, timeo);
+ if (debug_level > 2)
+ syslog(LOG_DEBUG, "clnt_call returns %d\n", success);
+ }
}
-/* ------------------------------------------------------------------------- */
-/*
- Functions for Unix<->Unix locking (ie. monitored locking, with rpc.statd
- involved to ensure reclaim of locks after a crash of the "stateless"
- server.
-
- These all come in two flavours - nlm_xxx() and nlm_xxx_msg().
- The first are standard RPCs with argument and result.
- The nlm_xxx_msg() calls implement exactly the same functions, but
- use two pseudo-RPCs (one in each direction). These calls are NOT
- standard use of the RPC protocol in that they do not return a result
- at all (NB. this is quite different from returning a void result).
- The effect of this is to make the nlm_xxx_msg() calls simple unacknowledged
- datagrams, requiring higher-level code to perform retries.
-
- Despite the disadvantages of the nlm_xxx_msg() approach (some of which
- are documented in the comments to get_client() above), this is the
- interface used by all current commercial NFS implementations
- [Solaris, SCO, AIX etc.]. This is presumed to be because these allow
- implementations to continue using the standard RPC libraries, while
- avoiding the block-until-result nature of the library interface.
-
- No client implementations have been identified so far that make use
- of the true RPC version (early SunOS releases would be a likely candidate
- for testing).
-*/
-
-
-/* nlm_test ---------------------------------------------------------------- */
-/*
- Purpose: Test whether a specified lock would be granted if requested
- Returns: nlm_granted (or error code)
- Notes:
-*/
-
-nlm_testres *nlm_test_1_svc(nlm_testargs *arg, struct svc_req *rqstp)
+nlm_testres *
+nlm_test_1_svc(arg, rqstp)
+ nlm_testargs *arg;
+ struct svc_req *rqstp;
{
- static nlm_testres res;
- if (debug_level) log_from_addr("nlm_test", rqstp);
-
- /* Copy the cookie from the argument into the result. Note that this */
- /* is slightly hazardous, as the structure contains a pointer to a */
- /* malloc()ed buffer that will get freed by the caller. However, the */
- /* main function transmits the result before freeing the argument */
- /* so it is in fact safe. */
- res.cookie = arg->cookie;
- res.stat.stat = nlm_granted;
- return (&res);
+ static nlm_testres res;
+
+ if (debug_level)
+ log_from_addr("nlm_test", rqstp);
+ res.cookie = arg->cookie;
+ res.stat.stat = nlm_granted;
+ return (&res);
}
-void *nlm_test_msg_1_svc(nlm_testargs *arg, struct svc_req *rqstp)
+void *
+nlm_test_msg_1_svc(arg, rqstp)
+ nlm_testargs *arg;
+ struct svc_req *rqstp;
{
- nlm_testres res;
- static char dummy;
- struct sockaddr_in *addr;
- CLIENT *cli;
- int success;
- struct timeval timeo;
-
- if (debug_level) log_from_addr("nlm_test_msg", rqstp);
-
- res.cookie = arg->cookie;
- res.stat.stat = nlm_granted;
-
- /* nlm_test has different result type to the other operations, so */
- /* can't use transmit_result() in this case */
- addr = svc_getcaller(rqstp->rq_xprt);
- if ((cli = get_client(addr)))
- {
- timeo.tv_sec = 0; /* No timeout - not expecting response */
- timeo.tv_usec = 0;
-
- success = clnt_call(cli, NLM_TEST_RES, xdr_nlm_testres, &res, xdr_void,
- &dummy, timeo);
-
- if (debug_level > 2) syslog(LOG_DEBUG, "clnt_call returns %d\n", success);
- }
- return (NULL);
+ nlm_testres res;
+ static char dummy;
+ struct sockaddr_in *addr;
+ CLIENT *cli;
+ int success;
+ struct timeval timeo;
+
+ if (debug_level)
+ log_from_addr("nlm_test_msg", rqstp);
+
+ res.cookie = arg->cookie;
+ res.stat.stat = nlm_granted;
+
+ addr = svc_getcaller(rqstp->rq_xprt);
+ if ((cli = get_client(addr))) {
+ timeo.tv_sec = 0;
+ timeo.tv_usec = 0;
+ success = clnt_call(cli, NLM_TEST_RES, xdr_nlm_testres, &res, xdr_void,
+ &dummy, timeo);
+ if (debug_level > 2)
+ syslog(LOG_DEBUG, "clnt_call returns %d\n", success);
+ }
+ return (NULL);
}
-/* nlm_lock ---------------------------------------------------------------- */
-/*
- Purposes: Establish a lock
- Returns: granted, denied or blocked
- Notes: *** grace period support missing
-*/
-
-nlm_res *nlm_lock_1_svc(nlm_lockargs *arg, struct svc_req *rqstp)
+nlm_res *
+nlm_lock_1_svc(arg, rqstp)
+ nlm_lockargs *arg;
+ struct svc_req *rqstp;
{
- static nlm_res res;
- if (debug_level) log_from_addr("nlm_lock", rqstp);
+ static nlm_res res;
- /* copy cookie from arg to result. See comment in nlm_test_1() */
- res.cookie = arg->cookie;
-
- res.stat.stat = nlm_granted;
- return (&res);
+ if (debug_level)
+ log_from_addr("nlm_lock", rqstp);
+ res.cookie = arg->cookie;
+ res.stat.stat = nlm_granted;
+ return (&res);
}
-void *nlm_lock_msg_1_svc(nlm_lockargs *arg, struct svc_req *rqstp)
+void *
+nlm_lock_msg_1_svc(arg, rqstp)
+ nlm_lockargs *arg;
+ struct svc_req *rqstp;
{
- static nlm_res res;
-
- if (debug_level) log_from_addr("nlm_lock_msg", rqstp);
-
- res.cookie = arg->cookie;
- res.stat.stat = nlm_granted;
- transmit_result(NLM_LOCK_RES, &res, rqstp);
-
- return (NULL);
+ static nlm_res res;
+
+ if (debug_level)
+ log_from_addr("nlm_lock_msg", rqstp);
+ res.cookie = arg->cookie;
+ res.stat.stat = nlm_granted;
+ transmit_result(NLM_LOCK_RES, &res, rqstp);
+ return (NULL);
}
-/* nlm_cancel -------------------------------------------------------------- */
-/*
- Purpose: Cancel a blocked lock request
- Returns: granted or denied
- Notes:
-*/
-
-nlm_res *nlm_cancel_1_svc(nlm_cancargs *arg, struct svc_req *rqstp)
+nlm_res *
+nlm_cancel_1_svc(arg, rqstp)
+ nlm_cancargs *arg;
+ struct svc_req *rqstp;
{
- static nlm_res res;
- if (debug_level) log_from_addr("nlm_cancel", rqstp);
+ static nlm_res res;
- /* copy cookie from arg to result. See comment in nlm_test_1() */
- res.cookie = arg->cookie;
-
- /* Since at present we never return 'nlm_blocked', there can never be */
- /* a lock to cancel, so this call always fails. */
- res.stat.stat = nlm_denied;
- return (&res);
+ if (debug_level)
+ log_from_addr("nlm_cancel", rqstp);
+ res.cookie = arg->cookie;
+ res.stat.stat = nlm_denied;
+ return (&res);
}
-void *nlm_cancel_msg_1_svc(nlm_cancargs *arg, struct svc_req *rqstp)
+void *
+nlm_cancel_msg_1_svc(arg, rqstp)
+ nlm_cancargs *arg;
+ struct svc_req *rqstp;
{
- static nlm_res res;
- if (debug_level) log_from_addr("nlm_cancel_msg", rqstp);
-
- res.cookie = arg->cookie;
- /* Since at present we never return 'nlm_blocked', there can never be */
- /* a lock to cancel, so this call always fails. */
- res.stat.stat = nlm_denied;
- transmit_result(NLM_CANCEL_RES, &res, rqstp);
- return (NULL);
+ static nlm_res res;
+
+ if (debug_level)
+ log_from_addr("nlm_cancel_msg", rqstp);
+ res.cookie = arg->cookie;
+ res.stat.stat = nlm_denied;
+ transmit_result(NLM_CANCEL_RES, &res, rqstp);
+ return (NULL);
}
-/* nlm_unlock -------------------------------------------------------------- */
-/*
- Purpose: Release an existing lock
- Returns: Always granted, unless during grace period
- Notes: "no such lock" error condition is ignored, as the
- protocol uses unreliable UDP datagrams, and may well
- re-try an unlock that has already succeeded.
-*/
-
-nlm_res *nlm_unlock_1_svc(nlm_unlockargs *arg, struct svc_req *rqstp)
+nlm_res *
+nlm_unlock_1_svc(arg, rqstp)
+ nlm_unlockargs *arg;
+ struct svc_req *rqstp;
{
- static nlm_res res;
- if (debug_level) log_from_addr("nlm_unlock", rqstp);
+ static nlm_res res;
- res.stat.stat= nlm_granted;
- res.cookie = arg->cookie;
-
- return (&res);
+ if (debug_level)
+ log_from_addr("nlm_unlock", rqstp);
+ res.stat.stat = nlm_granted;
+ res.cookie = arg->cookie;
+ return (&res);
}
-void *nlm_unlock_msg_1_svc(nlm_unlockargs *arg, struct svc_req *rqstp)
+void *
+nlm_unlock_msg_1_svc(arg, rqstp)
+ nlm_unlockargs *arg;
+ struct svc_req *rqstp;
{
- static nlm_res res;
- if (debug_level) log_from_addr("nlm_unlock_msg", rqstp);
-
- res.stat.stat = nlm_granted;
- res.cookie = arg->cookie;
-
- transmit_result(NLM_UNLOCK_RES, &res, rqstp);
- return (NULL);
+ static nlm_res res;
+
+ if (debug_level)
+ log_from_addr("nlm_unlock_msg", rqstp);
+ res.stat.stat = nlm_granted;
+ res.cookie = arg->cookie;
+ transmit_result(NLM_UNLOCK_RES, &res, rqstp);
+ return (NULL);
}
-/* ------------------------------------------------------------------------- */
-/*
- Client-side pseudo-RPCs for results. Note that for the client there
- are only nlm_xxx_msg() versions of each call, since the 'real RPC'
- version returns the results in the RPC result, and so the client
- does not normally receive incoming RPCs.
-
- The exception to this is nlm_granted(), which is genuinely an RPC
- call from the server to the client - a 'call-back' in normal procedure
- call terms.
-*/
-
-/* nlm_granted ------------------------------------------------------------- */
-/*
- Purpose: Receive notification that formerly blocked lock now granted
- Returns: always success ('granted')
- Notes:
-*/
-
-nlm_res *nlm_granted_1_svc(nlm_testargs *arg, struct svc_req *rqstp)
+nlm_res *
+nlm_granted_1_svc(arg, rqstp)
+ nlm_testargs *arg;
+ struct svc_req *rqstp;
{
- static nlm_res res;
- if (debug_level) log_from_addr("nlm_granted", rqstp);
-
- /* copy cookie from arg to result. See comment in nlm_test_1() */
- res.cookie = arg->cookie;
+ static nlm_res res;
- res.stat.stat = nlm_granted;
- return (&res);
+ if (debug_level)
+ log_from_addr("nlm_granted", rqstp);
+ res.cookie = arg->cookie;
+ res.stat.stat = nlm_granted;
+ return (&res);
}
-void *nlm_granted_msg_1_svc(nlm_testargs *arg, struct svc_req *rqstp)
+void *
+nlm_granted_msg_1_svc(arg, rqstp)
+ nlm_testargs *arg;
+ struct svc_req *rqstp;
{
- nlm_res res;
- if (debug_level) log_from_addr("nlm_granted_msg", rqstp);
-
- res.cookie = arg->cookie;
- res.stat.stat = nlm_granted;
- transmit_result(NLM_GRANTED_RES, &res, rqstp);
- return (NULL);
+ nlm_res res;
+
+ if (debug_level)
+ log_from_addr("nlm_granted_msg", rqstp);
+ res.cookie = arg->cookie;
+ res.stat.stat = nlm_granted;
+ transmit_result(NLM_GRANTED_RES, &res, rqstp);
+ return (NULL);
}
-/* nlm_test_res ------------------------------------------------------------ */
-/*
- Purpose: Accept result from earlier nlm_test_msg() call
- Returns: Nothing
-*/
-
-void *nlm_test_res_1_svc(nlm_testres *arg, struct svc_req *rqstp)
+void *
+nlm_test_res_1_svc(arg, rqstp)
+ nlm_testres *arg;
+ struct svc_req *rqstp;
{
- if (debug_level) log_from_addr("nlm_test_res", rqstp);
- return (NULL);
+ if (debug_level)
+ log_from_addr("nlm_test_res", rqstp);
+ return (NULL);
}
-/* nlm_lock_res ------------------------------------------------------------ */
-/*
- Purpose: Accept result from earlier nlm_lock_msg() call
- Returns: Nothing
-*/
-
-void *nlm_lock_res_1_svc(nlm_res *arg, struct svc_req *rqstp)
+void *
+nlm_lock_res_1_svc(arg, rqstp)
+ nlm_res *arg;
+ struct svc_req *rqstp;
{
- if (debug_level) log_from_addr("nlm_lock_res", rqstp);
+ if (debug_level)
+ log_from_addr("nlm_lock_res", rqstp);
- return (NULL);
+ return (NULL);
}
-/* nlm_cancel_res ---------------------------------------------------------- */
-/*
- Purpose: Accept result from earlier nlm_cancel_msg() call
- Returns: Nothing
-*/
-
-void *nlm_cancel_res_1_svc(nlm_res *arg, struct svc_req *rqstp)
+void *
+nlm_cancel_res_1_svc(arg, rqstp)
+ nlm_res *arg;
+ struct svc_req *rqstp;
{
- if (debug_level) log_from_addr("nlm_cancel_res", rqstp);
- return (NULL);
+ if (debug_level)
+ log_from_addr("nlm_cancel_res", rqstp);
+ return (NULL);
}
-/* nlm_unlock_res ---------------------------------------------------------- */
-/*
- Purpose: Accept result from earlier nlm_unlock_msg() call
- Returns: Nothing
-*/
-
-void *nlm_unlock_res_1_svc(nlm_res *arg, struct svc_req *rqstp)
+void *
+nlm_unlock_res_1_svc(arg, rqstp)
+ nlm_res *arg;
+ struct svc_req *rqstp;
{
- if (debug_level) log_from_addr("nlm_unlock_res", rqstp);
- return (NULL);
+ if (debug_level)
+ log_from_addr("nlm_unlock_res", rqstp);
+ return (NULL);
}
-/* nlm_granted_res --------------------------------------------------------- */
-/*
- Purpose: Accept result from earlier nlm_granted_msg() call
- Returns: Nothing
-*/
-
-void *nlm_granted_res_1_svc(nlm_res *arg, struct svc_req *rqstp)
+void *
+nlm_granted_res_1_svc(arg, rqstp)
+ nlm_res *arg;
+ struct svc_req *rqstp;
{
- if (debug_level) log_from_addr("nlm_granted_res", rqstp);
- return (NULL);
+ if (debug_level)
+ log_from_addr("nlm_granted_res", rqstp);
+ return (NULL);
}
-/* ------------------------------------------------------------------------- */
-/*
- Calls for PCNFS locking (aka non-monitored locking, no involvement
- of rpc.statd).
-
- These are all genuine RPCs - no nlm_xxx_msg() nonsense here.
-*/
-
-
-/* nlm_share --------------------------------------------------------------- */
-/*
- Purpose: Establish a DOS-style lock
- Returns: success or failure
- Notes: Blocking locks are not supported - client is expected
- to retry if required.
-*/
-
-nlm_shareres *nlm_share_3_svc(nlm_shareargs *arg, struct svc_req *rqstp)
+nlm_shareres *
+nlm_share_3_svc(arg, rqstp)
+ nlm_shareargs *arg;
+ struct svc_req *rqstp;
{
- static nlm_shareres res;
- if (debug_level) log_from_addr("nlm_share", rqstp);
-
- res.cookie = arg->cookie;
- res.stat = nlm_granted;
- res.sequence = 1234356; /* X/Open says this field is ignored? */
- return (&res);
+ static nlm_shareres res;
+
+ if (debug_level)
+ log_from_addr("nlm_share", rqstp);
+ res.cookie = arg->cookie;
+ res.stat = nlm_granted;
+ res.sequence = 1234356; /* X/Open says this field is ignored? */
+ return (&res);
}
-/* nlm_unshare ------------------------------------------------------------ */
-/*
- Purpose: Release a DOS-style lock
- Returns: nlm_granted, unless in grace period
- Notes:
-*/
-
-nlm_shareres *nlm_unshare_3_svc(nlm_shareargs *arg, struct svc_req *rqstp)
+nlm_shareres *
+nlm_unshare_3_svc(arg, rqstp)
+ nlm_shareargs *arg;
+ struct svc_req *rqstp;
{
- static nlm_shareres res;
- if (debug_level) log_from_addr("nlm_unshare", rqstp);
-
- res.cookie = arg->cookie;
- res.stat = nlm_granted;
- res.sequence = 1234356; /* X/Open says this field is ignored? */
- return (&res);
+ static nlm_shareres res;
+
+ if (debug_level)
+ log_from_addr("nlm_unshare", rqstp);
+ res.cookie = arg->cookie;
+ res.stat = nlm_granted;
+ res.sequence = 1234356; /* X/Open says this field is ignored? */
+ return (&res);
}
-/* nlm_nm_lock ------------------------------------------------------------ */
-/*
- Purpose: non-monitored version of nlm_lock()
- Returns: as for nlm_lock()
- Notes: These locks are in the same style as the standard nlm_lock,
- but the rpc.statd should not be called to establish a
- monitor for the client machine, since that machine is
- declared not to be running a rpc.statd, and so would not
- respond to the statd protocol.
-*/
-
-nlm_res *nlm_nm_lock_3_svc(nlm_lockargs *arg, struct svc_req *rqstp)
+nlm_res *
+nlm_nm_lock_3_svc(arg, rqstp)
+ nlm_lockargs *arg;
+ struct svc_req *rqstp;
{
- static nlm_res res;
- if (debug_level) log_from_addr("nlm_nm_lock", rqstp);
+ static nlm_res res;
- /* copy cookie from arg to result. See comment in nlm_test_1() */
- res.cookie = arg->cookie;
- res.stat.stat = nlm_granted;
- return (&res);
+ if (debug_level)
+ log_from_addr("nlm_nm_lock", rqstp);
+ res.cookie = arg->cookie;
+ res.stat.stat = nlm_granted;
+ return (&res);
}
-/* nlm_free_all ------------------------------------------------------------ */
-/*
- Purpose: Release all locks held by a named client
- Returns: Nothing
- Notes: Potential denial of service security problem here - the
- locks to be released are specified by a host name, independent
- of the address from which the request has arrived.
- Should probably be rejected if the named host has been
- using monitored locks.
-*/
-
-void *nlm_free_all_3_svc(nlm_notify *arg, struct svc_req *rqstp)
+void *
+nlm_free_all_3_svc(arg, rqstp)
+ nlm_notify *arg;
+ struct svc_req *rqstp;
{
- static char dummy;
+ static char dummy;
- if (debug_level) log_from_addr("nlm_free_all", rqstp);
- return (&dummy);
+ if (debug_level)
+ log_from_addr("nlm_free_all", rqstp);
+ return (&dummy);
}
-
-
diff --git a/usr.sbin/rpc.lockd/test.c b/usr.sbin/rpc.lockd/test.c
index 9d484f5e020..f177bafe763 100644
--- a/usr.sbin/rpc.lockd/test.c
+++ b/usr.sbin/rpc.lockd/test.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: test.c,v 1.2 1997/08/10 21:06:41 millert Exp $ */
+/* $OpenBSD: test.c,v 1.3 1997/09/17 23:09:39 deraadt Exp $ */
#include <rpc/rpc.h>
#include <rpcsvc/nlm_prot.h>
@@ -6,10 +6,10 @@
/*static char sccsid[] = "from: @(#)nlm_prot.x 1.8 87/09/21 Copyr 1987 Sun Micro";*/
/*static char sccsid[] = "from: * @(#)nlm_prot.x 2.1 88/08/01 4.0 RPCSRC";*/
static char rcsid[] = "nlm_prot.x,v 1.1 1994/08/04 19:01:48 wollman Exp";
-#endif /* not lint */
+#endif /* not lint */
/* Default timeout can be changed using clnt_control() */
-static struct timeval TIMEOUT = { 0, 0 };
+static struct timeval TIMEOUT = {0, 0};
nlm_testres *
nlm_test_1(argp, clnt)
@@ -18,7 +18,7 @@ nlm_test_1(argp, clnt)
{
static nlm_testres res;
- bzero((char *)&res, sizeof(res));
+ bzero((char *) &res, sizeof(res));
if (clnt_call(clnt, NLM_TEST, xdr_nlm_testargs, argp, xdr_nlm_testres, &res, TIMEOUT) != RPC_SUCCESS) {
return (NULL);
}
@@ -34,7 +34,7 @@ nlm_lock_1(argp, clnt)
enum clnt_stat st;
static nlm_res res;
- bzero((char *)&res, sizeof(res));
+ bzero((char *) &res, sizeof(res));
if (st = clnt_call(clnt, NLM_LOCK, xdr_nlm_lockargs, argp, xdr_nlm_res, &res, TIMEOUT) != RPC_SUCCESS) {
printf("clnt_call returns %d\n", st);
clnt_perror(clnt, "humbug");
@@ -51,7 +51,7 @@ nlm_cancel_1(argp, clnt)
{
static nlm_res res;
- bzero((char *)&res, sizeof(res));
+ bzero((char *) &res, sizeof(res));
if (clnt_call(clnt, NLM_CANCEL, xdr_nlm_cancargs, argp, xdr_nlm_res, &res, TIMEOUT) != RPC_SUCCESS) {
return (NULL);
}
@@ -66,7 +66,7 @@ nlm_unlock_1(argp, clnt)
{
static nlm_res res;
- bzero((char *)&res, sizeof(res));
+ bzero((char *) &res, sizeof(res));
if (clnt_call(clnt, NLM_UNLOCK, xdr_nlm_unlockargs, argp, xdr_nlm_res, &res, TIMEOUT) != RPC_SUCCESS) {
return (NULL);
}
@@ -81,7 +81,7 @@ nlm_granted_1(argp, clnt)
{
static nlm_res res;
- bzero((char *)&res, sizeof(res));
+ bzero((char *) &res, sizeof(res));
if (clnt_call(clnt, NLM_GRANTED, xdr_nlm_testargs, argp, xdr_nlm_res, &res, TIMEOUT) != RPC_SUCCESS) {
return (NULL);
}
@@ -89,154 +89,154 @@ nlm_granted_1(argp, clnt)
}
-void *
+void *
nlm_test_msg_1(argp, clnt)
struct nlm_testargs *argp;
CLIENT *clnt;
{
static char res;
- bzero((char *)&res, sizeof(res));
+ bzero((char *) &res, sizeof(res));
if (clnt_call(clnt, NLM_TEST_MSG, xdr_nlm_testargs, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) {
return (NULL);
}
- return ((void *)&res);
+ return ((void *) &res);
}
-void *
+void *
nlm_lock_msg_1(argp, clnt)
struct nlm_lockargs *argp;
CLIENT *clnt;
{
static char res;
- bzero((char *)&res, sizeof(res));
+ bzero((char *) &res, sizeof(res));
if (clnt_call(clnt, NLM_LOCK_MSG, xdr_nlm_lockargs, argp, xdr_void, NULL, TIMEOUT) != RPC_SUCCESS) {
clnt_perror(clnt, "nlm_lock_msg_1");
return (NULL);
}
- return ((void *)&res);
+ return ((void *) &res);
}
-void *
+void *
nlm_cancel_msg_1(argp, clnt)
struct nlm_cancargs *argp;
CLIENT *clnt;
{
static char res;
- bzero((char *)&res, sizeof(res));
+ bzero((char *) &res, sizeof(res));
if (clnt_call(clnt, NLM_CANCEL_MSG, xdr_nlm_cancargs, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) {
return (NULL);
}
- return ((void *)&res);
+ return ((void *) &res);
}
-void *
+void *
nlm_unlock_msg_1(argp, clnt)
struct nlm_unlockargs *argp;
CLIENT *clnt;
{
static char res;
- bzero((char *)&res, sizeof(res));
+ bzero((char *) &res, sizeof(res));
if (clnt_call(clnt, NLM_UNLOCK_MSG, xdr_nlm_unlockargs, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) {
return (NULL);
}
- return ((void *)&res);
+ return ((void *) &res);
}
-void *
+void *
nlm_granted_msg_1(argp, clnt)
struct nlm_testargs *argp;
CLIENT *clnt;
{
static char res;
- bzero((char *)&res, sizeof(res));
+ bzero((char *) &res, sizeof(res));
if (clnt_call(clnt, NLM_GRANTED_MSG, xdr_nlm_testargs, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) {
return (NULL);
}
- return ((void *)&res);
+ return ((void *) &res);
}
-void *
+void *
nlm_test_res_1(argp, clnt)
nlm_testres *argp;
CLIENT *clnt;
{
static char res;
- bzero((char *)&res, sizeof(res));
+ bzero((char *) &res, sizeof(res));
if (clnt_call(clnt, NLM_TEST_RES, xdr_nlm_testres, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) {
return (NULL);
}
- return ((void *)&res);
+ return ((void *) &res);
}
-void *
+void *
nlm_lock_res_1(argp, clnt)
nlm_res *argp;
CLIENT *clnt;
{
static char res;
- bzero((char *)&res, sizeof(res));
+ bzero((char *) &res, sizeof(res));
if (clnt_call(clnt, NLM_LOCK_RES, xdr_nlm_res, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) {
return (NULL);
}
- return ((void *)&res);
+ return ((void *) &res);
}
-void *
+void *
nlm_cancel_res_1(argp, clnt)
nlm_res *argp;
CLIENT *clnt;
{
static char res;
- bzero((char *)&res, sizeof(res));
+ bzero((char *) &res, sizeof(res));
if (clnt_call(clnt, NLM_CANCEL_RES, xdr_nlm_res, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) {
return (NULL);
}
- return ((void *)&res);
+ return ((void *) &res);
}
-void *
+void *
nlm_unlock_res_1(argp, clnt)
nlm_res *argp;
CLIENT *clnt;
{
static char res;
- bzero((char *)&res, sizeof(res));
+ bzero((char *) &res, sizeof(res));
if (clnt_call(clnt, NLM_UNLOCK_RES, xdr_nlm_res, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) {
return (NULL);
}
- return ((void *)&res);
+ return ((void *) &res);
}
-void *
+void *
nlm_granted_res_1(argp, clnt)
nlm_res *argp;
CLIENT *clnt;
{
static char res;
- bzero((char *)&res, sizeof(res));
+ bzero((char *) &res, sizeof(res));
if (clnt_call(clnt, NLM_GRANTED_RES, xdr_nlm_res, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) {
return (NULL);
}
- return ((void *)&res);
+ return ((void *) &res);
}
@@ -247,7 +247,7 @@ nlm_share_3(argp, clnt)
{
static nlm_shareres res;
- bzero((char *)&res, sizeof(res));
+ bzero((char *) &res, sizeof(res));
if (clnt_call(clnt, NLM_SHARE, xdr_nlm_shareargs, argp, xdr_nlm_shareres, &res, TIMEOUT) != RPC_SUCCESS) {
return (NULL);
}
@@ -262,7 +262,7 @@ nlm_unshare_3(argp, clnt)
{
static nlm_shareres res;
- bzero((char *)&res, sizeof(res));
+ bzero((char *) &res, sizeof(res));
if (clnt_call(clnt, NLM_UNSHARE, xdr_nlm_shareargs, argp, xdr_nlm_shareres, &res, TIMEOUT) != RPC_SUCCESS) {
return (NULL);
}
@@ -277,7 +277,7 @@ nlm_nm_lock_3(argp, clnt)
{
static nlm_res res;
- bzero((char *)&res, sizeof(res));
+ bzero((char *) &res, sizeof(res));
if (clnt_call(clnt, NLM_NM_LOCK, xdr_nlm_lockargs, argp, xdr_nlm_res, &res, TIMEOUT) != RPC_SUCCESS) {
return (NULL);
}
@@ -285,80 +285,77 @@ nlm_nm_lock_3(argp, clnt)
}
-void *
+void *
nlm_free_all_3(argp, clnt)
nlm_notify *argp;
CLIENT *clnt;
{
static char res;
- bzero((char *)&res, sizeof(res));
+ bzero((char *) &res, sizeof(res));
if (clnt_call(clnt, NLM_FREE_ALL, xdr_nlm_notify, argp, xdr_void, &res, TIMEOUT) != RPC_SUCCESS) {
return (NULL);
}
- return ((void *)&res);
+ return ((void *) &res);
}
-int main(int argc, char **argv)
+int
+main(int argc, char **argv)
{
- CLIENT *cli;
- nlm_res res_block;
- nlm_res *out;
- nlm_lockargs arg;
- struct timeval tim;
-
- printf("Creating client for host %s\n", argv[1]);
- cli = clnt_create(argv[1], NLM_PROG, NLM_VERS, "udp");
- if (!cli)
- {
- printf("Failed to create client\n");
- exit(1);
- }
-
-
- clnt_control(cli, CLGET_TIMEOUT, &tim);
- printf("Default timeout was %d.%d\n", tim.tv_sec, tim.tv_usec);
- tim.tv_usec = -1;
- tim.tv_sec = -1;
- clnt_control(cli, CLSET_TIMEOUT, &tim);
- clnt_control(cli, CLGET_TIMEOUT, &tim);
- printf("timeout now %d.%d\n", tim.tv_sec, tim.tv_usec);
-
-
- arg.cookie.n_len = 4;
- arg.cookie.n_bytes = "hello";
- arg.block = 0;
- arg.exclusive = 0;
- arg.reclaim = 0;
- arg.state = 0x1234;
- arg.alock.caller_name = "localhost";
- arg.alock.fh.n_len = 32;
- arg.alock.fh.n_bytes = "\x04\x04\x02\x00\x01\x00\x00\x00\x0c\x00\x00\x00\xff\xff\xff\xd0\x16\x00\x00\x5b\x7c\xff\xff\xff\xec\x2f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x19\x54\xef\xbf\xd7\x94";
- arg.alock.oh.n_len = 8;
- arg.alock.oh.n_bytes = "\x00\x00\x02\xff\xff\xff\xd3";
- arg.alock.svid = 0x5678;
- arg.alock.l_offset = 0;
- arg.alock.l_len = 100;
-
- res_block.stat.stat = nlm_granted;
- res_block.cookie.n_bytes = "hello";
- res_block.cookie.n_len = 5;
+ CLIENT *cli;
+ nlm_res res_block;
+ nlm_res *out;
+ nlm_lockargs arg;
+ struct timeval tim;
+
+ printf("Creating client for host %s\n", argv[1]);
+ cli = clnt_create(argv[1], NLM_PROG, NLM_VERS, "udp");
+ if (!cli) {
+ printf("Failed to create client\n");
+ exit(1);
+ }
+ clnt_control(cli, CLGET_TIMEOUT, &tim);
+ printf("Default timeout was %d.%d\n", tim.tv_sec, tim.tv_usec);
+ tim.tv_usec = -1;
+ tim.tv_sec = -1;
+ clnt_control(cli, CLSET_TIMEOUT, &tim);
+ clnt_control(cli, CLGET_TIMEOUT, &tim);
+ printf("timeout now %d.%d\n", tim.tv_sec, tim.tv_usec);
+
+
+ arg.cookie.n_len = 4;
+ arg.cookie.n_bytes = "hello";
+ arg.block = 0;
+ arg.exclusive = 0;
+ arg.reclaim = 0;
+ arg.state = 0x1234;
+ arg.alock.caller_name = "localhost";
+ arg.alock.fh.n_len = 32;
+ arg.alock.fh.n_bytes = "\x04\x04\x02\x00\x01\x00\x00\x00\x0c\x00\x00\x00\xff\xff\xff\xd0\x16\x00\x00\x5b\x7c\xff\xff\xff\xec\x2f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x19\x54\xef\xbf\xd7\x94";
+ arg.alock.oh.n_len = 8;
+ arg.alock.oh.n_bytes = "\x00\x00\x02\xff\xff\xff\xd3";
+ arg.alock.svid = 0x5678;
+ arg.alock.l_offset = 0;
+ arg.alock.l_len = 100;
+
+ res_block.stat.stat = nlm_granted;
+ res_block.cookie.n_bytes = "hello";
+ res_block.cookie.n_len = 5;
#if 0
- if (nlm_lock_res_1(&res_block, cli)) printf("Success!\n");
- else printf("Fail\n");
+ if (nlm_lock_res_1(&res_block, cli))
+ printf("Success!\n");
+ else
+ printf("Fail\n");
#else
- if (out = nlm_lock_msg_1(&arg, cli))
- {
- printf("Success!\n");
- printf("out->stat = %d", out->stat);
- }
- else
- {
- printf("Fail\n");
- }
+ if (out = nlm_lock_msg_1(&arg, cli)) {
+ printf("Success!\n");
+ printf("out->stat = %d", out->stat);
+ } else {
+ printf("Fail\n");
+ }
#endif
- return 0;
+ return 0;
}