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>
17 # include <sys/statfs.h>
20 #include <afs/dirpath.h>
24 #include <rx/rx_globals.h>
26 #include <afs/cellconfig.h>
29 #include <afs/afsint.h>
33 internal_client_init(struct afsconf_dir *dir, struct afsconf_cell *info,
34 int secFlags, struct ubik_client **uclientp,
35 int (*secproc) (struct rx_securityClass *, afs_int32),
36 int maxservers, const char *serviceid, int deadtime,
37 afs_uint32 server, afs_uint32 port, afs_int32 usrvid)
41 struct rx_securityClass *sc;
42 /* This must change if VLDB_MAXSERVERS becomes larger than MAXSERVERS */
43 static struct rx_connection *serverconns[MAXSERVERS];
46 progname = getprogname();
48 progname = "<unknown>";
52 fprintf(stderr, "%s: could not initialize rx.\n", progname);
55 rx_SetRxDeadTime(deadtime);
57 code = afsconf_PickClientSecObj(dir, secFlags, info, NULL, &sc,
60 fprintf(stderr, "%s: can't create client security object", progname);
64 if (scIndex == RX_SECIDX_NULL && !(secFlags & AFSCONF_SECOPTS_NOAUTH)) {
66 "%s: Could not get afs tokens, running unauthenticated.\n",
70 if (secproc) /* tell UV module about default authentication */
71 (*secproc) (sc, scIndex);
74 serverconns[0] = rx_NewConnection(server, port,
77 if (info->numServers > maxservers) {
79 "%s: info.numServers=%d (> maxservers=%d)\n",
80 progname, info->numServers, maxservers);
83 for (i = 0; i < info->numServers; i++) {
84 if (!info->hostAddr[i].sin_port && port)
85 info->hostAddr[i].sin_port = port;
87 rx_NewConnection(info->hostAddr[i].sin_addr.s_addr,
88 info->hostAddr[i].sin_port, usrvid,
92 /* Are we just setting up connections, or is this really ubik stuff? */
95 code = ubik_ClientInit(serverconns, uclientp);
97 fprintf(stderr, "%s: ubik client init failed.\n", progname);
105 ugen_ClientInitCell(struct afsconf_dir *dir, struct afsconf_cell *info,
106 int secFlags, struct ubik_client **uclientp,
107 int maxservers, const char *serviceid, int deadtime)
109 return internal_client_init(dir, info, secFlags, uclientp, NULL,
110 maxservers, serviceid, deadtime, 0, 0,
115 internal_client_init_dir(const char *confDir, char *cellName, int secFlags,
116 struct ubik_client **uclientp,
117 int (*secproc) (struct rx_securityClass *, afs_int32),
118 afs_int32 maxservers, char *serviceid, afs_int32 deadtime,
119 afs_uint32 server, afs_uint32 port, afs_int32 usrvid)
122 const char *progname;
123 struct afsconf_dir *dir;
124 struct afsconf_cell info;
126 progname = getprogname();
127 if (progname == NULL)
128 progname = "<unknown>";
131 confDir = AFSDIR_CLIENT_ETC_DIRPATH;
133 dir = afsconf_Open(confDir);
136 "%s: Could not process files in configuration directory (%s).\n",
141 if (cellName == NULL)
142 cellName = dir->cellName;
144 code = afsconf_GetCellInfo(dir, cellName, serviceid, &info);
147 fprintf(stderr, "%s: can't find cell %s's hosts in %s/%s\n",
148 progname?progname:"<unknown>", cellName, confDir,
149 AFSDIR_CELLSERVDB_FILE);
153 code = internal_client_init(dir, &info, secFlags, uclientp, secproc,
154 maxservers, serviceid, deadtime, server,
163 ugen_ClientInitServer(const char *confDir, char *cellName, int secFlags,
164 struct ubik_client **uclientp, int maxservers,
165 char *serviceid, int deadtime, afs_uint32 server,
169 return internal_client_init_dir(confDir, cellName, secFlags, uclientp,
170 NULL, maxservers, serviceid, deadtime,
171 server, port, USER_SERVICE_ID);
175 ugen_ClientInitFlags(const char *confDir, char *cellName, int secFlags,
176 struct ubik_client **uclientp,
177 int (*secproc) (struct rx_securityClass *, afs_int32),
178 int maxservers, char *serviceid, int deadtime)
180 return internal_client_init_dir(confDir, cellName, secFlags, uclientp,
181 secproc, maxservers, serviceid, deadtime,
182 0, 0, USER_SERVICE_ID);
186 * \brief Get the appropriate type of ubik client structure out from the system.
189 ugen_ClientInit(int noAuthFlag, const char *confDir, char *cellName, afs_int32 sauth,
190 struct ubik_client **uclientp,
191 int (*secproc) (struct rx_securityClass *, afs_int32),
192 char *funcName, afs_int32 gen_rxkad_level,
193 afs_int32 maxservers, char *serviceid, afs_int32 deadtime,
194 afs_uint32 server, afs_uint32 port, afs_int32 usrvid)
198 secFlags = AFSCONF_SECOPTS_FALLBACK_NULL;
200 secFlags |= AFSCONF_SECOPTS_LOCALAUTH;
201 confDir = AFSDIR_SERVER_ETC_DIRPATH;
204 secFlags |= AFSCONF_SECOPTS_ALWAYSENCRYPT;
207 secFlags |= AFSCONF_SECOPTS_NOAUTH;
209 return internal_client_init_dir(confDir, cellName, secFlags, uclientp,
210 secproc, maxservers, serviceid, deadtime,
211 server, port, usrvid);