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>
33 #include <afs/dirpath.h>
38 #include <rx/rx_globals.h>
40 #include <afs/cellconfig.h>
43 #include <afs/afsint.h>
47 Get the appropriate type of ubik client structure out from the system.
50 ugen_ClientInit(int noAuthFlag, char *confDir, char *cellName, afs_int32 sauth,
51 struct ubik_client **uclientp, int (*secproc) (),
52 char *funcName, afs_int32 gen_rxkad_level,
53 afs_int32 maxservers, char *serviceid, afs_int32 deadtime,
54 afs_uint32 server, afs_uint32 port, afs_int32 usrvid)
56 afs_int32 code, scIndex, i;
57 struct afsconf_cell info;
58 struct afsconf_dir *tdir;
59 struct ktc_principal sname;
60 struct ktc_token ttoken;
61 struct rx_securityClass *sc;
62 /* This must change if VLDB_MAXSERVERS becomes larger than MAXSERVERS */
63 static struct rx_connection *serverconns[MAXSERVERS];
68 fprintf(stderr, "%s: could not initialize rx.\n", funcName);
71 rx_SetRxDeadTime(deadtime);
73 if (sauth) { /* -localauth */
74 tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
77 "%s: Could not process files in configuration directory (%s).\n",
78 funcName, AFSDIR_SERVER_ETC_DIRPATH);
81 code = afsconf_ClientAuth(tdir, &sc, &scIndex); /* sets sc,scIndex */
85 "%s: Could not get security object for -localAuth\n",
90 afsconf_GetCellInfo(tdir, tdir->cellName, serviceid,
95 "%s: can't find cell %s's hosts in %s/%s\n",
96 funcName, cellName, AFSDIR_SERVER_ETC_DIRPATH,
97 AFSDIR_CELLSERVDB_FILE);
100 } else { /* not -localauth */
101 tdir = afsconf_Open(confDir);
104 "%s: Could not process files in configuration directory (%s).\n",
110 code = afsconf_GetLocalCell(tdir, cellstr, sizeof(cellstr));
113 "%s: can't get local cellname, check %s/%s\n",
114 funcName, confDir, AFSDIR_THISCELL_FILE);
121 afsconf_GetCellInfo(tdir, cellName, serviceid, &info);
124 "%s: can't find cell %s's hosts in %s/%s\n",
125 funcName, cellName, confDir, AFSDIR_CELLSERVDB_FILE);
128 if (noAuthFlag) /* -noauth */
130 else { /* not -noauth */
131 strcpy(sname.cell, info.name);
132 sname.instance[0] = 0;
133 strcpy(sname.name, "afs");
134 code = ktc_GetToken(&sname, &ttoken, sizeof(ttoken), NULL);
135 if (code) { /* did not get ticket */
137 "%s: Could not get afs tokens, running unauthenticated.\n",
140 } else { /* got a ticket */
142 if ((ttoken.kvno < 0) || (ttoken.kvno > 256)) {
144 "%s: funny kvno (%d) in ticket, proceeding\n",
145 funcName, ttoken.kvno);
152 sc = rxnull_NewClientSecurityObject();
155 sc = rxkad_NewClientSecurityObject(gen_rxkad_level,
157 ttoken.kvno, ttoken.ticketLen,
161 fprintf(stderr, "%s: unsupported security index %d\n",
170 if (secproc) /* tell UV module about default authentication */
171 (*secproc) (sc, scIndex);
173 serverconns[0] = rx_NewConnection(server, port,
174 usrvid, sc, scIndex);
176 if (info.numServers > maxservers) {
178 "%s: info.numServers=%d (> maxservers=%d)\n",
179 funcName, info.numServers, maxservers);
182 for (i = 0; i < info.numServers; i++) {
184 rx_NewConnection(info.hostAddr[i].sin_addr.s_addr,
185 info.hostAddr[i].sin_port, usrvid,
189 /* Are we just setting up connections, or is this really ubik stuff? */
192 code = ubik_ClientInit(serverconns, uclientp);
194 fprintf(stderr, "%s: ubik client init failed.\n", funcName);