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>
25 #include <sys/types.h>
27 #include <afs/cellconfig.h>
32 #include <afs/kauth.h>
33 #include <afs/afsutil.h>
36 File servers in NW byte order.
40 afs_int32 server_id[256];
42 struct ubik_client *client;
47 afs_int32 *ViceIds_val;
54 afs_int32 *IPAddrs_val;
58 struct ubik_dbase *VL_dbase;
59 struct afsconf_dir *vldb_confdir;
60 struct kadstats dynamic_statistics;
61 struct rx_securityClass *junk;
63 #include <sys/socket.h>
64 #include <netinet/in.h>
65 #include <arpa/inet.h>
67 extern int VL_GetAddrs();
69 afs_int32 InvalidateCache(as)
70 struct cmd_syndesc *as;
74 struct rx_connection *conn;
79 afs_int32 spare2,spare3;
92 /* make sure something there */
94 if( !as->parms[0].items && !as->parms[1].items)
96 printf("Use -help flag for list of optional argmuments\n");
102 for(i=0,u=as->parms[0].items;i<255 && u;++i,u=u->next)
104 code=util_GetInt32(u->data,&id[i]);
107 printf("Fatal error: bad conversion to long for %s\n",u->data);
116 /* get IP addresses, convert to NW byte order */
118 for(i=0,u=as->parms[1].items;i<255 && u;++i,u=u->next)
119 ip[i]=inet_addr(u->data);
125 for(i=0;i<server_count;++i)
127 conn=rx_NewConnection(server_id[i],htonl(port),1,
131 printf("Informational: could not connect to \
132 file server %lx\n",server_id[i]);
136 /* invalidate the cache */
138 code=RXAFS_FlushCPS(conn,&vid,&ipa,spare1,&spare2,&spare3);
141 May get spurious error codes in case server is
142 down or is reported by VLDB as a file server
143 even though it is not configured as such in the
148 printf("Informational: failed to invalidate \
149 file server %lx cache code = %ld\n",server_id[i],code);
151 rx_DestroyConnection(conn);
157 Obtain list of file servers as known to VLDB. These may
158 not actually be configured as file servers in the cell.
161 afs_int32 ListServers()
164 struct rx_connection *conn;
165 struct rx_call *call;
171 struct VLCallBack spare3;
176 /* get list of file servers in NW byte order */
177 memset(&addrs, 0, sizeof(addrs));
178 memset(&spare3, 0, sizeof(spare3));
179 code=ubik_Call(VL_GetAddrs,client,0,Handle,spare2,&spare3,
180 &server_count,&addrs);
183 printf("Fatal error: could not get list of \
187 server_count=ntohl(server_count);
189 for(i=0,p=addrs.bulkaddrs_val;i<server_count;++i,++p)
196 afs_int32 GetServerList()
205 printf("There are %d file servers in the cell\n\n",server_count);
207 for(i=0;i<server_count;++i)
209 hostutil_GetNameByINet(server_id[i]));
216 User enters lists of:
218 1. AFS user ids - say from "pts exam username".
219 2. IP addresses - say from /etc/hosts (no wildcards).
221 Command is executed in user's cell.
224 static MyBeforeProc(as, arock)
225 struct cmd_syndesc *as;
227 register char *tcell = NULL;
229 struct afsconf_dir *tdir;
230 struct afsconf_cell info;
231 struct rx_connection *serverconns[MAXSERVERS];
232 register afs_int32 code, i;
233 register afs_int32 sauth;
235 sprintf(confdir,"%s",AFSDIR_CLIENT_ETC_DIRPATH);
236 /* setup to talk to servers */
239 printf("Warning: could not initialize network communication.\n");
241 junk=rxnull_NewClientSecurityObject();
242 tdir=afsconf_Open(confdir);
244 printf("Warning: could not get cell configuration.\n");
246 if (as->parms[2].items) /* if -cell specified */
247 tcell = as->parms[2].items->data;
248 code = afsconf_GetCellInfo(tdir, tcell, AFSCONF_VLDBSERVICE,&info);
249 if (info.numServers > MAXSERVERS)
250 printf("Warning: could not init cell info.\n");
252 for(i=0;i<info.numServers;++i)
253 serverconns[i]=rx_NewConnection(info.hostAddr[i].sin_addr.s_addr,
254 info.hostAddr[i].sin_port,
255 USER_SERVICE_ID, junk, 0);
256 for (;i < MAXSERVERS; ++i) {
257 serverconns[i] = (struct rx_connection *)0;
259 code=ubik_ClientInit(serverconns,&client);
261 printf("Warning: could not initialize RPC interface.\n");
265 int main (argc, argv)
270 struct cmd_syndesc *ts;
274 struct sigaction nsa;
276 sigemptyset(&nsa.sa_mask);
277 nsa.sa_handler = SIG_DFL;
278 nsa.sa_flags = SA_FULLDUMP;
279 sigaction(SIGSEGV, &nsa, NULL);
283 Look in /usr/vice/etc (client side database).
285 cmd_SetBeforeProc(MyBeforeProc, NULL);
287 ts = cmd_CreateSyntax("initcmd"/*"invalidatecache"*/,InvalidateCache,0,
288 "invalidate server ACL cache");
289 cmd_AddParm(ts,"-id",CMD_LIST,CMD_OPTIONAL,"user identifier");
290 cmd_AddParm(ts,"-ip",CMD_LIST,CMD_OPTIONAL,"IP address");
291 cmd_CreateAlias(ts,"ic");
292 cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
294 ts = cmd_CreateSyntax("listservers",GetServerList,0,
295 "list servers in the cell");
296 cmd_CreateAlias(ts,"ls");
298 code = cmd_Dispatch(argc,argv);