2 * Copyright (c) 2009 Rick Macklem, University of Guelph
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 #include <sys/cdefs.h>
29 __FBSDID("$FreeBSD$");
31 #include <sys/param.h>
32 #include <sys/linker.h>
33 #include <sys/module.h>
34 #include <sys/mount.h>
35 #include <sys/socket.h>
36 #include <sys/sysctl.h>
37 #include <sys/vnode.h>
39 #include <netinet/in.h>
41 #include <nfs/nfssvc.h>
43 #include <fs/nfs/rpcv2.h>
44 #include <fs/nfs/nfsproto.h>
45 #include <fs/nfs/nfskpiport.h>
46 #include <fs/nfs/nfs.h>
60 static void usage(void);
63 main(int argc, char **argv)
68 struct nfsd_clid revoke_handle;
70 if (modfind("nfsd") < 0)
71 errx(1, "nfsd not loaded - self terminating");
82 if (*cp >= '0' && *cp <= '9')
83 val += (u_char)(*cp - '0');
84 else if (*cp >= 'A' && *cp <= 'F')
85 val += ((u_char)(*cp - 'A')) + 0xa;
86 else if (*cp >= 'a' && *cp <= 'f')
87 val += ((u_char)(*cp - 'a')) + 0xa;
89 errx(1, "Non hexadecimal digit in %s", argv[1]);
94 revoke_handle.nclid_id[cnt++] = val;
95 if (cnt > NFSV4_OPAQUELIMIT)
96 errx(1, "Clientid %s, loo long", argv[1]);
104 * Do the revocation system call.
106 revoke_handle.nclid_idlen = cnt;
108 printf("Idlen=%d\n", revoke_handle.nclid_idlen);
109 for (cnt = 0; cnt < revoke_handle.nclid_idlen; cnt++)
110 printf("%02x", revoke_handle.nclid_id[cnt]);
113 if (nfssvc(NFSSVC_ADMINREVOKE, &revoke_handle) < 0)
114 err(1, "Admin revoke failed");
122 errx(1, "Usage: nfsrevoke <ClientID>");