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>
19 #include <sys/types.h>
22 #include <netinet/in.h>
23 #endif /* AFS_NT40_ENV */
26 #include <sys/statfs.h>
31 #include <afs/dirpath.h>
36 #include <rx/rx_globals.h>
38 #include <afs/cellconfig.h>
41 #include <afs/afsint.h>
45 * \brief Get the appropriate type of ubik client structure out from the system.
48 ugen_ClientInit(int noAuthFlag, const char *confDir, char *cellName, afs_int32 sauth,
49 struct ubik_client **uclientp,
50 int (*secproc) (struct rx_securityClass *, afs_int32),
51 char *funcName, afs_int32 gen_rxkad_level,
52 afs_int32 maxservers, char *serviceid, afs_int32 deadtime,
53 afs_uint32 server, afs_uint32 port, afs_int32 usrvid)
55 afs_int32 code, secFlags, i;
57 struct afsconf_cell info;
58 struct afsconf_dir *tdir;
59 struct rx_securityClass *sc;
60 /* This must change if VLDB_MAXSERVERS becomes larger than MAXSERVERS */
61 static struct rx_connection *serverconns[MAXSERVERS];
66 fprintf(stderr, "%s: could not initialize rx.\n", funcName);
69 rx_SetRxDeadTime(deadtime);
71 secFlags = AFSCONF_SECOPTS_FALLBACK_NULL;
73 secFlags |= AFSCONF_SECOPTS_LOCALAUTH;
74 confdir = AFSDIR_SERVER_ETC_DIRPATH;
76 confdir = AFSDIR_CLIENT_ETC_DIRPATH;
79 tdir = afsconf_Open(confdir);
82 "%s: Could not process files in configuration directory (%s).\n",
86 code = afsconf_GetCellInfo(tdir, tdir->cellName, serviceid, &info);
89 fprintf(stderr, "%s: can't find cell %s's hosts in %s/%s\n",
90 funcName, cellName, confdir, AFSDIR_CELLSERVDB_FILE);
93 code = afsconf_PickClientSecObj(tdir, secFlags, &info, tdir->cellName, &sc,
96 fprintf(stderr, "%s: can't create client security object", funcName);
99 if (scIndex == RX_SECIDX_NULL) {
101 "%s: Could not get afs tokens, running unauthenticated.\n",
107 if (secproc) /* tell UV module about default authentication */
108 (*secproc) (sc, scIndex);
110 serverconns[0] = rx_NewConnection(server, port,
111 usrvid, sc, scIndex);
113 if (info.numServers > maxservers) {
115 "%s: info.numServers=%d (> maxservers=%d)\n",
116 funcName, info.numServers, maxservers);
119 for (i = 0; i < info.numServers; i++) {
121 rx_NewConnection(info.hostAddr[i].sin_addr.s_addr,
122 info.hostAddr[i].sin_port, usrvid,
126 /* Are we just setting up connections, or is this really ubik stuff? */
129 code = ubik_ClientInit(serverconns, uclientp);
131 fprintf(stderr, "%s: ubik client init failed.\n", funcName);