2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afs/vldbint.h>
12 #include <afsconfig.h>
13 #include <afs/param.h>
26 #include <sys/types.h>
28 #include <afs/cellconfig.h>
33 #include <afs/kauth.h>
34 #include <afs/afsutil.h>
37 File servers in NW byte order.
41 afs_int32 server_id[256];
43 struct ubik_client *client;
47 afs_int32 *ViceIds_val;
52 afs_int32 *IPAddrs_val;
55 struct ubik_dbase *VL_dbase;
56 struct afsconf_dir *vldb_confdir;
57 struct kadstats dynamic_statistics;
58 struct rx_securityClass *junk;
60 #include <sys/socket.h>
61 #include <netinet/in.h>
62 #include <arpa/inet.h>
64 extern int VL_GetAddrs();
68 struct cmd_syndesc *as;
72 struct rx_connection *conn;
74 afs_int32 port = 7000;
77 afs_int32 spare2, spare3;
90 /* make sure something there */
92 if (!as->parms[0].items && !as->parms[1].items) {
93 printf("Use -help flag for list of optional argmuments\n");
99 for (i = 0, u = as->parms[0].items; i < 255 && u; ++i, u = u->next) {
100 code = util_GetInt32(u->data, &id[i]);
102 printf("Fatal error: bad conversion to long for %s\n", u->data);
109 vid.ViceIds_val = id;
111 /* get IP addresses, convert to NW byte order */
113 for (i = 0, u = as->parms[1].items; i < 255 && u; ++i, u = u->next)
114 ip[i] = inet_addr(u->data);
118 ipa.IPAddrs_val = ip;
120 for (i = 0; i < server_count; ++i) {
121 conn = rx_NewConnection(server_id[i], htonl(port), 1, junk, 0);
123 printf("Informational: could not connect to \
124 file server %lx\n", server_id[i]);
128 /* invalidate the cache */
130 code = RXAFS_FlushCPS(conn, &vid, &ipa, spare1, &spare2, &spare3);
133 * May get spurious error codes in case server is
134 * down or is reported by VLDB as a file server
135 * even though it is not configured as such in the
140 printf("Informational: failed to invalidate \
141 file server %lx cache code = %ld\n", server_id[i], code);
143 rx_DestroyConnection(conn);
149 Obtain list of file servers as known to VLDB. These may
150 not actually be configured as file servers in the cell.
157 struct rx_connection *conn;
158 struct rx_call *call;
162 afs_int32 base, index;
164 afs_int32 Handle = 0;
165 afs_int32 spare2 = 0;
166 struct VLCallBack spare3;
168 bulkaddrs addrs, m_addrs;
169 ListAddrByAttributes m_attrs;
170 afs_int32 m_unique, m_nentries;
173 /* get list of file servers in NW byte order */
174 memset(&addrs, 0, sizeof(addrs));
175 memset(&spare3, 0, sizeof(spare3));
177 ubik_Call(VL_GetAddrs, client, 0, Handle, spare2, &spare3,
178 &server_count, &addrs);
180 printf("Fatal error: could not get list of file servers\n");
184 for (i = 0, p = addrs.bulkaddrs_val; i < server_count; ++i, ++p) {
185 if (((*p & 0xff000000) == 0xff000000) && ((*p) & 0xffff)) {
186 if ((base >= 0) && (base <= VL_MAX_ADDREXTBLKS) && (index >= 1)
187 && (index <= VL_MHSRV_PERBLK)) {
188 m_attrs.Mask = VLADDR_INDEX;
189 m_attrs.index = (base * VL_MHSRV_PERBLK) + index;
191 m_addrs.bulkaddrs_val = 0;
192 m_addrs.bulkaddrs_len = 0;
194 ubik_Call(VL_GetAddrsU, client, 0, &m_attrs, &m_uuid,
195 &m_unique, &m_nentries, &m_addrs);
199 m_addrp = (afs_int32 *) m_addrs.bulkaddrs_val;
200 for (j = 0; j < m_nentries; j++, m_addrp++) {
201 server_id[i] = *m_addrp;
202 *m_addrp = htonl(*m_addrp);
203 printf("host %s\n", hostutil_GetNameByINet(*p));
209 printf("host %s\n", hostutil_GetNameByINet(*p));
221 code = ListServers();
225 printf("There are %d file servers in the cell\n\n", server_count);
227 for (i = 0; i < server_count; ++i)
228 printf("%s\n", hostutil_GetNameByINet(server_id[i]));
235 User enters lists of:
237 1. AFS user ids - say from "pts exam username".
238 2. IP addresses - say from /etc/hosts (no wildcards).
240 Command is executed in user's cell.
244 MyBeforeProc(as, arock)
245 struct cmd_syndesc *as;
248 register char *tcell = NULL;
250 struct afsconf_dir *tdir;
251 struct afsconf_cell info;
252 struct rx_connection *serverconns[MAXSERVERS];
253 register afs_int32 code, i;
254 register afs_int32 sauth;
256 sprintf(confdir, "%s", AFSDIR_CLIENT_ETC_DIRPATH);
257 /* setup to talk to servers */
260 printf("Warning: could not initialize network communication.\n");
262 junk = rxnull_NewClientSecurityObject();
263 tdir = afsconf_Open(confdir);
265 printf("Warning: could not get cell configuration.\n");
267 if (as->parms[2].items) /* if -cell specified */
268 tcell = as->parms[2].items->data;
269 code = afsconf_GetCellInfo(tdir, tcell, AFSCONF_VLDBSERVICE, &info);
270 if (info.numServers > MAXSERVERS)
271 printf("Warning: could not init cell info.\n");
273 for (i = 0; i < info.numServers; ++i)
275 rx_NewConnection(info.hostAddr[i].sin_addr.s_addr,
276 info.hostAddr[i].sin_port, USER_SERVICE_ID, junk,
278 for (; i < MAXSERVERS; ++i) {
279 serverconns[i] = (struct rx_connection *)0;
281 code = ubik_ClientInit(serverconns, &client);
283 printf("Warning: could not initialize RPC interface.\n");
293 struct cmd_syndesc *ts;
297 struct sigaction nsa;
299 sigemptyset(&nsa.sa_mask);
300 nsa.sa_handler = SIG_DFL;
301 nsa.sa_flags = SA_FULLDUMP;
302 sigaction(SIGSEGV, &nsa, NULL);
306 * Look in /usr/vice/etc (client side database).
308 cmd_SetBeforeProc(MyBeforeProc, NULL);
310 ts = cmd_CreateSyntax("initcmd" /*"invalidatecache" */ , InvalidateCache,
311 0, "invalidate server ACL cache");
312 cmd_AddParm(ts, "-id", CMD_LIST, CMD_OPTIONAL, "user identifier");
313 cmd_AddParm(ts, "-ip", CMD_LIST, CMD_OPTIONAL, "IP address");
314 cmd_CreateAlias(ts, "ic");
315 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
317 ts = cmd_CreateSyntax("listservers", GetServerList, 0,
318 "list servers in the cell");
319 cmd_CreateAlias(ts, "ls");
321 code = cmd_Dispatch(argc, argv);