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 <afsconfig.h>
11 #include <afs/param.h>
21 #include <sys/types.h>
24 #include <netinet/in.h>
25 #endif /* AFS_NT40_ENV */
28 #include <sys/statfs.h>
39 #include <afs/dirpath.h>
44 #include <rx/rx_globals.h>
46 #include <afs/cellconfig.h>
49 #include <afs/afsint.h>
54 Get the appropriate type of ubik client structure out from the system.
57 ugen_ClientInit(int noAuthFlag, char *confDir, char *cellName, afs_int32 sauth,
58 struct ubik_client **uclientp, int (*secproc) (),
59 char *funcName, afs_int32 gen_rxkad_level,
60 afs_int32 maxservers, char *serviceid, afs_int32 deadtime,
61 afs_uint32 server, afs_uint32 port, afs_int32 usrvid)
63 afs_int32 code, scIndex, i;
64 struct afsconf_cell info;
65 struct afsconf_dir *tdir;
66 struct ktc_principal sname;
67 struct ktc_token ttoken;
68 struct rx_securityClass *sc;
69 /* This must change if VLDB_MAXSERVERS becomes larger than MAXSERVERS */
70 static struct rx_connection *serverconns[MAXSERVERS];
75 fprintf(stderr, "%s: could not initialize rx.\n", funcName);
78 rx_SetRxDeadTime(deadtime);
80 if (sauth) { /* -localauth */
81 tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
84 "%s: Could not process files in configuration directory (%s).\n",
85 funcName, AFSDIR_SERVER_ETC_DIRPATH);
88 code = afsconf_ClientAuth(tdir, &sc, &scIndex); /* sets sc,scIndex */
92 "%s: Could not get security object for -localAuth\n",
97 afsconf_GetCellInfo(tdir, tdir->cellName, serviceid,
102 "%s: can't find cell %s's hosts in %s/%s\n",
103 funcName, cellName, AFSDIR_SERVER_ETC_DIRPATH,
104 AFSDIR_CELLSERVDB_FILE);
107 } else { /* not -localauth */
108 tdir = afsconf_Open(confDir);
111 "%s: Could not process files in configuration directory (%s).\n",
117 code = afsconf_GetLocalCell(tdir, cellstr, sizeof(cellstr));
120 "%s: can't get local cellname, check %s/%s\n",
121 funcName, confDir, AFSDIR_THISCELL_FILE);
128 afsconf_GetCellInfo(tdir, cellName, serviceid, &info);
131 "%s: can't find cell %s's hosts in %s/%s\n",
132 funcName, cellName, confDir, AFSDIR_CELLSERVDB_FILE);
135 if (noAuthFlag) /* -noauth */
137 else { /* not -noauth */
138 strcpy(sname.cell, info.name);
139 sname.instance[0] = 0;
140 strcpy(sname.name, "afs");
141 code = ktc_GetToken(&sname, &ttoken, sizeof(ttoken), NULL);
142 if (code) { /* did not get ticket */
144 "%s: Could not get afs tokens, running unauthenticated.\n",
147 } else { /* got a ticket */
149 if ((ttoken.kvno < 0) || (ttoken.kvno > 256)) {
151 "%s: funny kvno (%d) in ticket, proceeding\n",
152 funcName, ttoken.kvno);
159 sc = rxnull_NewClientSecurityObject();
162 sc = rxkad_NewClientSecurityObject(gen_rxkad_level,
164 ttoken.kvno, ttoken.ticketLen,
168 fprintf(stderr, "%s: unsupported security index %d\n",
177 if (secproc) /* tell UV module about default authentication */
178 (*secproc) (sc, scIndex);
180 serverconns[0] = rx_NewConnection(server, port,
181 usrvid, sc, scIndex);
183 if (info.numServers > maxservers) {
185 "%s: info.numServers=%d (> maxservers=%d)\n",
186 funcName, info.numServers, maxservers);
189 for (i = 0; i < info.numServers; i++) {
191 rx_NewConnection(info.hostAddr[i].sin_addr.s_addr,
192 info.hostAddr[i].sin_port, usrvid,
196 /* Are we just setting up connections, or is this really ubik stuff? */
199 code = ubik_ClientInit(serverconns, uclientp);
201 fprintf(stderr, "%s: ubik client init failed.\n", funcName);