nfsrevoke.c (192811) | nfsrevoke.c (193070) |
---|---|
1/*- 2 * Copyright (c) 2009 Rick Macklem, University of Guelph 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 12 unchanged lines hidden (view full) --- 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 24 * SUCH DAMAGE. 25 * 26 */ 27 28#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2009 Rick Macklem, University of Guelph 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 12 unchanged lines hidden (view full) --- 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 24 * SUCH DAMAGE. 25 * 26 */ 27 28#include <sys/cdefs.h> |
29__FBSDID("$FreeBSD: head/usr.sbin/nfsrevoke/nfsrevoke.c 192811 2009-05-26 15:19:04Z rmacklem $"); | 29__FBSDID("$FreeBSD: head/usr.sbin/nfsrevoke/nfsrevoke.c 193070 2009-05-29 22:19:45Z delphij $"); |
30 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> --- 14 unchanged lines hidden (view full) --- 52#include <limits.h> 53#include <paths.h> 54#include <signal.h> 55#include <stdio.h> 56#include <stdlib.h> 57#include <string.h> 58#include <unistd.h> 59 | 30 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> --- 14 unchanged lines hidden (view full) --- 52#include <limits.h> 53#include <paths.h> 54#include <signal.h> 55#include <stdio.h> 56#include <stdlib.h> 57#include <string.h> 58#include <unistd.h> 59 |
60void usage(void); 61extern int errno; | 60static void usage(void); |
62 63int 64main(int argc, char **argv) 65{ 66 char *cp; 67 u_char val; 68 int cnt, even; | 61 62int 63main(int argc, char **argv) 64{ 65 char *cp; 66 u_char val; 67 int cnt, even; |
69 struct nfsd_clid revoke; | 68 struct nfsd_clid revoke_handle; |
70 71 if (modfind("nfsd") < 0) 72 errx(1, "nfsd not loaded - self terminating"); 73 if (argc != 2) 74 usage(); 75 cnt = 0; 76 cp = argv[1]; 77 if (strlen(cp) % 2) 78 even = 0; 79 else 80 even = 1; 81 val = 0; 82 while (*cp) { | 69 70 if (modfind("nfsd") < 0) 71 errx(1, "nfsd not loaded - self terminating"); 72 if (argc != 2) 73 usage(); 74 cnt = 0; 75 cp = argv[1]; 76 if (strlen(cp) % 2) 77 even = 0; 78 else 79 even = 1; 80 val = 0; 81 while (*cp) { |
83 if (*cp >= '0' & *cp <= '9') | 82 if (*cp >= '0' && *cp <= '9') |
84 val += (u_char)(*cp - '0'); 85 else if (*cp >= 'A' && *cp <= 'F') 86 val += ((u_char)(*cp - 'A')) + 0xa; 87 else if (*cp >= 'a' && *cp <= 'f') 88 val += ((u_char)(*cp - 'a')) + 0xa; 89 else 90 errx(1, "Non hexadecimal digit in %s", argv[1]); 91 if (even) { 92 val <<= 4; 93 even = 0; 94 } else { | 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; 88 else 89 errx(1, "Non hexadecimal digit in %s", argv[1]); 90 if (even) { 91 val <<= 4; 92 even = 0; 93 } else { |
95 revoke.nclid_id[cnt++] = val; | 94 revoke_handle.nclid_id[cnt++] = val; |
96 if (cnt > NFSV4_OPAQUELIMIT) 97 errx(1, "Clientid %s, loo long", argv[1]); 98 val = 0; 99 even = 1; 100 } 101 cp++; 102 } 103 104 /* 105 * Do the revocation system call. 106 */ | 95 if (cnt > NFSV4_OPAQUELIMIT) 96 errx(1, "Clientid %s, loo long", argv[1]); 97 val = 0; 98 even = 1; 99 } 100 cp++; 101 } 102 103 /* 104 * Do the revocation system call. 105 */ |
107 revoke.nclid_idlen = cnt; | 106 revoke_handle.nclid_idlen = cnt; |
108#ifdef DEBUG | 107#ifdef DEBUG |
109 printf("Idlen=%d\n", revoke.nclid_idlen); 110 for (cnt = 0; cnt < revoke.nclid_idlen; cnt++) 111 printf("%02x", revoke.nclid_id[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]); |
112 printf("\n"); 113#else | 111 printf("\n"); 112#else |
114 if (nfssvc(NFSSVC_ADMINREVOKE, &revoke) < 0) | 113 if (nfssvc(NFSSVC_ADMINREVOKE, &revoke_handle) < 0) |
115 err(1, "Admin revoke failed"); 116#endif 117} 118 | 114 err(1, "Admin revoke failed"); 115#endif 116} 117 |
119void | 118static void |
120usage(void) 121{ 122 123 errx(1, "Usage: nfsrevoke <ClientID>"); 124} | 119usage(void) 120{ 121 122 errx(1, "Usage: nfsrevoke <ClientID>"); 123} |