1*8bae5d40Schristos /* $NetBSD: get_args.c,v 1.1.1.3 2015/01/17 16:34:15 christos Exp $ */
2a53f50b9Schristos
3a53f50b9Schristos /*
4*8bae5d40Schristos * Copyright (c) 1997-2014 Erez Zadok
5a53f50b9Schristos * Copyright (c) 1990 Jan-Simon Pendry
6a53f50b9Schristos * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
7a53f50b9Schristos * Copyright (c) 1990 The Regents of the University of California.
8a53f50b9Schristos * All rights reserved.
9a53f50b9Schristos *
10a53f50b9Schristos * This code is derived from software contributed to Berkeley by
11a53f50b9Schristos * Jan-Simon Pendry at Imperial College, London.
12a53f50b9Schristos *
13a53f50b9Schristos * Redistribution and use in source and binary forms, with or without
14a53f50b9Schristos * modification, are permitted provided that the following conditions
15a53f50b9Schristos * are met:
16a53f50b9Schristos * 1. Redistributions of source code must retain the above copyright
17a53f50b9Schristos * notice, this list of conditions and the following disclaimer.
18a53f50b9Schristos * 2. Redistributions in binary form must reproduce the above copyright
19a53f50b9Schristos * notice, this list of conditions and the following disclaimer in the
20a53f50b9Schristos * documentation and/or other materials provided with the distribution.
21*8bae5d40Schristos * 3. Neither the name of the University nor the names of its contributors
22a53f50b9Schristos * may be used to endorse or promote products derived from this software
23a53f50b9Schristos * without specific prior written permission.
24a53f50b9Schristos *
25a53f50b9Schristos * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26a53f50b9Schristos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27a53f50b9Schristos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28a53f50b9Schristos * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29a53f50b9Schristos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30a53f50b9Schristos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31a53f50b9Schristos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32a53f50b9Schristos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33a53f50b9Schristos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34a53f50b9Schristos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35a53f50b9Schristos * SUCH DAMAGE.
36a53f50b9Schristos *
37a53f50b9Schristos *
38a53f50b9Schristos * File: am-utils/amd/get_args.c
39a53f50b9Schristos *
40a53f50b9Schristos */
41a53f50b9Schristos
42a53f50b9Schristos /*
43a53f50b9Schristos * Argument decode
44a53f50b9Schristos */
45a53f50b9Schristos
46a53f50b9Schristos #ifdef HAVE_CONFIG_H
47a53f50b9Schristos # include <config.h>
48a53f50b9Schristos #endif /* HAVE_CONFIG_H */
49a53f50b9Schristos #include <am_defs.h>
50a53f50b9Schristos #include <amd.h>
51a53f50b9Schristos
52a53f50b9Schristos /* include auto-generated version file */
53a53f50b9Schristos #include <build_version.h>
54a53f50b9Schristos
55a53f50b9Schristos char *amu_conf_file = "/etc/amd.conf"; /* default amd configuration file */
56a53f50b9Schristos char *conf_tag = NULL; /* default conf file tags to use */
57a53f50b9Schristos int usage = 0;
58a53f50b9Schristos int use_conf_file = 0; /* default don't use amd.conf file */
59a53f50b9Schristos char *mnttab_file_name = NULL; /* symbol must be available always */
60a53f50b9Schristos
61a53f50b9Schristos
62a53f50b9Schristos /*
63a53f50b9Schristos * Return the version string (dynamic buffer)
64a53f50b9Schristos */
65a53f50b9Schristos char *
get_version_string(void)66a53f50b9Schristos get_version_string(void)
67a53f50b9Schristos {
68a53f50b9Schristos char *vers = NULL;
69a53f50b9Schristos char tmpbuf[1024];
70a53f50b9Schristos char *wire_buf;
71a53f50b9Schristos int wire_buf_len = 0;
72a53f50b9Schristos size_t len; /* max allocated length (to avoid buf overflow) */
73a53f50b9Schristos
74a53f50b9Schristos /*
75a53f50b9Schristos * First get dynamic string listing all known networks.
76a53f50b9Schristos * This could be a long list, if host has lots of interfaces.
77a53f50b9Schristos */
78a53f50b9Schristos wire_buf = print_wires();
79a53f50b9Schristos if (wire_buf)
80a53f50b9Schristos wire_buf_len = strlen(wire_buf);
81a53f50b9Schristos
82a53f50b9Schristos len = 2048 + wire_buf_len;
83a53f50b9Schristos vers = xmalloc(len);
84a53f50b9Schristos xsnprintf(vers, len, "%s\n%s\n%s\n%s\n",
85*8bae5d40Schristos "Copyright (c) 1997-2014 Erez Zadok",
86a53f50b9Schristos "Copyright (c) 1990 Jan-Simon Pendry",
87a53f50b9Schristos "Copyright (c) 1990 Imperial College of Science, Technology & Medicine",
88a53f50b9Schristos "Copyright (c) 1990 The Regents of the University of California.");
89a53f50b9Schristos xsnprintf(tmpbuf, sizeof(tmpbuf), "%s version %s (build %d).\n",
90a53f50b9Schristos PACKAGE_NAME, PACKAGE_VERSION, AMU_BUILD_VERSION);
91a53f50b9Schristos xstrlcat(vers, tmpbuf, len);
92a53f50b9Schristos xsnprintf(tmpbuf, sizeof(tmpbuf), "Report bugs to %s.\n", PACKAGE_BUGREPORT);
93a53f50b9Schristos xstrlcat(vers, tmpbuf, len);
94a53f50b9Schristos xsnprintf(tmpbuf, sizeof(tmpbuf), "Configured by %s@%s on date %s.\n",
95a53f50b9Schristos USER_NAME, HOST_NAME, CONFIG_DATE);
96a53f50b9Schristos xstrlcat(vers, tmpbuf, len);
97a53f50b9Schristos xsnprintf(tmpbuf, sizeof(tmpbuf), "Built by %s@%s on date %s.\n",
98a53f50b9Schristos BUILD_USER, BUILD_HOST, BUILD_DATE);
99a53f50b9Schristos xstrlcat(vers, tmpbuf, len);
100a53f50b9Schristos xsnprintf(tmpbuf, sizeof(tmpbuf), "cpu=%s (%s-endian), arch=%s, karch=%s.\n",
101a53f50b9Schristos cpu, endian, gopt.arch, gopt.karch);
102a53f50b9Schristos xstrlcat(vers, tmpbuf, len);
103a53f50b9Schristos xsnprintf(tmpbuf, sizeof(tmpbuf), "full_os=%s, os=%s, osver=%s, vendor=%s, distro=%s.\n",
104a53f50b9Schristos gopt.op_sys_full, gopt.op_sys, gopt.op_sys_ver, gopt.op_sys_vendor, DISTRO_NAME);
105a53f50b9Schristos xstrlcat(vers, tmpbuf, len);
106a53f50b9Schristos xsnprintf(tmpbuf, sizeof(tmpbuf), "domain=%s, host=%s, hostd=%s.\n",
107a53f50b9Schristos hostdomain, am_get_hostname(), hostd);
108a53f50b9Schristos xstrlcat(vers, tmpbuf, len);
109a53f50b9Schristos
110a53f50b9Schristos xstrlcat(vers, "Map support for: ", len);
111a53f50b9Schristos mapc_showtypes(tmpbuf, sizeof(tmpbuf));
112a53f50b9Schristos xstrlcat(vers, tmpbuf, len);
113a53f50b9Schristos xstrlcat(vers, ".\nAMFS: ", len);
114a53f50b9Schristos ops_showamfstypes(tmpbuf, sizeof(tmpbuf));
115a53f50b9Schristos xstrlcat(vers, tmpbuf, len);
116a53f50b9Schristos xstrlcat(vers, ", inherit.\nFS: ", len); /* hack: "show" that we support type:=inherit */
117a53f50b9Schristos ops_showfstypes(tmpbuf, sizeof(tmpbuf));
118a53f50b9Schristos xstrlcat(vers, tmpbuf, len);
119a53f50b9Schristos
120a53f50b9Schristos /* append list of networks if available */
121a53f50b9Schristos if (wire_buf) {
122a53f50b9Schristos xstrlcat(vers, wire_buf, len);
123a53f50b9Schristos XFREE(wire_buf);
124a53f50b9Schristos }
125a53f50b9Schristos
126a53f50b9Schristos return vers;
127a53f50b9Schristos }
128a53f50b9Schristos
129a53f50b9Schristos
130a53f50b9Schristos static void
show_usage(void)131a53f50b9Schristos show_usage(void)
132a53f50b9Schristos {
133a53f50b9Schristos fprintf(stderr,
134a53f50b9Schristos "Usage: %s [-nprvHS] [-a mount_point] [-c cache_time] [-d domain]\n\
135a53f50b9Schristos \t[-k kernel_arch] [-l logfile%s\n\
136a53f50b9Schristos \t[-t timeout.retrans] [-w wait_timeout] [-A arch] [-C cluster_name]\n\
137a53f50b9Schristos \t[-o op_sys_ver] [-O op_sys_name]\n\
138a53f50b9Schristos \t[-F conf_file] [-T conf_tag]", am_get_progname(),
139a53f50b9Schristos #ifdef HAVE_SYSLOG
140a53f50b9Schristos # ifdef LOG_DAEMON
141a53f50b9Schristos "|\"syslog[:facility]\"]"
142a53f50b9Schristos # else /* not LOG_DAEMON */
143a53f50b9Schristos "|\"syslog\"]"
144a53f50b9Schristos # endif /* not LOG_DAEMON */
145a53f50b9Schristos #else /* not HAVE_SYSLOG */
146a53f50b9Schristos "]"
147a53f50b9Schristos #endif /* not HAVE_SYSLOG */
148a53f50b9Schristos );
149a53f50b9Schristos
150a53f50b9Schristos #ifdef HAVE_MAP_NIS
151a53f50b9Schristos fputs(" [-y nis-domain]\n", stderr);
152a53f50b9Schristos #else /* not HAVE_MAP_NIS */
153a53f50b9Schristos fputc('\n', stderr);
154a53f50b9Schristos #endif /* HAVE_MAP_NIS */
155a53f50b9Schristos
156a53f50b9Schristos show_opts('x', xlog_opt);
157a53f50b9Schristos #ifdef DEBUG
158a53f50b9Schristos show_opts('D', dbg_opt);
159a53f50b9Schristos #endif /* DEBUG */
160a53f50b9Schristos fprintf(stderr, "\t[directory mapname [-map_options]] ...\n");
161a53f50b9Schristos }
162a53f50b9Schristos
163a53f50b9Schristos
164a53f50b9Schristos void
get_args(int argc,char * argv[])165a53f50b9Schristos get_args(int argc, char *argv[])
166a53f50b9Schristos {
167a53f50b9Schristos int opt_ch, i;
168a53f50b9Schristos FILE *fp = stdin;
169a53f50b9Schristos char getopt_arguments[] = "+nprvSa:c:d:k:l:o:t:w:x:y:C:D:F:T:O:HA:";
170a53f50b9Schristos char *getopt_args;
171a53f50b9Schristos int print_version = 0; /* 1 means we should print version info */
172a53f50b9Schristos
173a53f50b9Schristos #ifdef HAVE_GNU_GETOPT
174a53f50b9Schristos getopt_args = getopt_arguments;
175a53f50b9Schristos #else /* ! HAVE_GNU_GETOPT */
176a53f50b9Schristos getopt_args = &getopt_arguments[1];
177a53f50b9Schristos #endif /* HAVE_GNU_GETOPT */
178a53f50b9Schristos
179a53f50b9Schristos /* if no arguments were passed, try to use /etc/amd.conf file */
180a53f50b9Schristos if (argc <= 1)
181a53f50b9Schristos use_conf_file = 1;
182a53f50b9Schristos
183a53f50b9Schristos while ((opt_ch = getopt(argc, argv, getopt_args)) != -1)
184a53f50b9Schristos switch (opt_ch) {
185a53f50b9Schristos
186a53f50b9Schristos case 'a':
187a53f50b9Schristos if (*optarg != '/') {
188a53f50b9Schristos fprintf(stderr, "%s: -a option must begin with a '/'\n",
189a53f50b9Schristos am_get_progname());
190a53f50b9Schristos exit(1);
191a53f50b9Schristos }
192a53f50b9Schristos gopt.auto_dir = optarg;
193a53f50b9Schristos break;
194a53f50b9Schristos
195a53f50b9Schristos case 'c':
196a53f50b9Schristos gopt.am_timeo = atoi(optarg);
197a53f50b9Schristos if (gopt.am_timeo <= 0)
198a53f50b9Schristos gopt.am_timeo = AM_TTL;
199a53f50b9Schristos break;
200a53f50b9Schristos
201a53f50b9Schristos case 'd':
202a53f50b9Schristos gopt.sub_domain = optarg;
203a53f50b9Schristos break;
204a53f50b9Schristos
205a53f50b9Schristos case 'k':
206a53f50b9Schristos gopt.karch = optarg;
207a53f50b9Schristos break;
208a53f50b9Schristos
209a53f50b9Schristos case 'l':
210a53f50b9Schristos gopt.logfile = optarg;
211a53f50b9Schristos break;
212a53f50b9Schristos
213a53f50b9Schristos case 'n':
214a53f50b9Schristos gopt.flags |= CFM_NORMALIZE_HOSTNAMES;
215a53f50b9Schristos break;
216a53f50b9Schristos
217a53f50b9Schristos case 'o':
218a53f50b9Schristos gopt.op_sys_ver = optarg;
219a53f50b9Schristos break;
220a53f50b9Schristos
221a53f50b9Schristos case 'p':
222a53f50b9Schristos gopt.flags |= CFM_PRINT_PID;
223a53f50b9Schristos break;
224a53f50b9Schristos
225a53f50b9Schristos case 'r':
226a53f50b9Schristos gopt.flags |= CFM_RESTART_EXISTING_MOUNTS;
227a53f50b9Schristos break;
228a53f50b9Schristos
229a53f50b9Schristos case 't':
230a53f50b9Schristos /* timeo.retrans (also affects toplvl mounts) */
231a53f50b9Schristos {
232a53f50b9Schristos char *dot = strchr(optarg, '.');
233a53f50b9Schristos int i;
234a53f50b9Schristos if (dot)
235a53f50b9Schristos *dot = '\0';
236a53f50b9Schristos if (*optarg) {
237a53f50b9Schristos for (i=0; i<AMU_TYPE_MAX; ++i)
238a53f50b9Schristos gopt.amfs_auto_timeo[i] = atoi(optarg);
239a53f50b9Schristos }
240a53f50b9Schristos if (dot) {
241a53f50b9Schristos for (i=0; i<AMU_TYPE_MAX; ++i)
242a53f50b9Schristos gopt.amfs_auto_retrans[i] = atoi(dot + 1);
243a53f50b9Schristos *dot = '.';
244a53f50b9Schristos }
245a53f50b9Schristos }
246a53f50b9Schristos break;
247a53f50b9Schristos
248a53f50b9Schristos case 'v':
249a53f50b9Schristos /*
250a53f50b9Schristos * defer to print version info after every variable had been
251a53f50b9Schristos * initialized.
252a53f50b9Schristos */
253a53f50b9Schristos print_version++;
254a53f50b9Schristos break;
255a53f50b9Schristos
256a53f50b9Schristos case 'w':
257a53f50b9Schristos gopt.am_timeo_w = atoi(optarg);
258a53f50b9Schristos if (gopt.am_timeo_w <= 0)
259a53f50b9Schristos gopt.am_timeo_w = AM_TTL_W;
260a53f50b9Schristos break;
261a53f50b9Schristos
262a53f50b9Schristos case 'x':
263a53f50b9Schristos usage += switch_option(optarg);
264a53f50b9Schristos break;
265a53f50b9Schristos
266a53f50b9Schristos case 'y':
267a53f50b9Schristos #ifdef HAVE_MAP_NIS
268a53f50b9Schristos gopt.nis_domain = optarg;
269a53f50b9Schristos #else /* not HAVE_MAP_NIS */
270a53f50b9Schristos plog(XLOG_USER, "-y: option ignored. No NIS support available.");
271a53f50b9Schristos #endif /* not HAVE_MAP_NIS */
272a53f50b9Schristos break;
273a53f50b9Schristos
274a53f50b9Schristos case 'A':
275a53f50b9Schristos gopt.arch = optarg;
276a53f50b9Schristos break;
277a53f50b9Schristos
278a53f50b9Schristos case 'C':
279a53f50b9Schristos gopt.cluster = optarg;
280a53f50b9Schristos break;
281a53f50b9Schristos
282a53f50b9Schristos case 'D':
283a53f50b9Schristos #ifdef DEBUG
284a53f50b9Schristos usage += debug_option(optarg);
285a53f50b9Schristos #else /* not DEBUG */
286a53f50b9Schristos fprintf(stderr, "%s: not compiled with DEBUG option -- sorry.\n",
287a53f50b9Schristos am_get_progname());
288a53f50b9Schristos #endif /* not DEBUG */
289a53f50b9Schristos break;
290a53f50b9Schristos
291a53f50b9Schristos case 'F':
292a53f50b9Schristos amu_conf_file = optarg;
293a53f50b9Schristos use_conf_file = 1;
294a53f50b9Schristos break;
295a53f50b9Schristos
296a53f50b9Schristos case 'H':
297a53f50b9Schristos show_usage();
298a53f50b9Schristos exit(1);
299a53f50b9Schristos break;
300a53f50b9Schristos
301a53f50b9Schristos case 'O':
302a53f50b9Schristos gopt.op_sys = optarg;
303a53f50b9Schristos break;
304a53f50b9Schristos
305a53f50b9Schristos case 'S':
306a53f50b9Schristos gopt.flags &= ~CFM_PROCESS_LOCK; /* turn process locking off */
307a53f50b9Schristos break;
308a53f50b9Schristos
309a53f50b9Schristos case 'T':
310a53f50b9Schristos conf_tag = optarg;
311a53f50b9Schristos break;
312a53f50b9Schristos
313a53f50b9Schristos default:
314a53f50b9Schristos usage = 1;
315a53f50b9Schristos break;
316a53f50b9Schristos }
317a53f50b9Schristos
318a53f50b9Schristos /*
319a53f50b9Schristos * amd.conf file: if not command-line arguments were used, or if -F was
320a53f50b9Schristos * specified, then use that amd.conf file. If the file cannot be opened,
321a53f50b9Schristos * abort amd. If it can be found, open it, parse it, and then close it.
322a53f50b9Schristos */
323a53f50b9Schristos if (use_conf_file && amu_conf_file) {
324a53f50b9Schristos fp = fopen(amu_conf_file, "r");
325a53f50b9Schristos if (!fp) {
326a53f50b9Schristos char buf[128];
327a53f50b9Schristos xsnprintf(buf, sizeof(buf), "Amd configuration file (%s)",
328a53f50b9Schristos amu_conf_file);
329a53f50b9Schristos perror(buf);
330a53f50b9Schristos exit(1);
331a53f50b9Schristos }
332a53f50b9Schristos conf_in = fp;
333a53f50b9Schristos conf_parse();
334a53f50b9Schristos fclose(fp);
335a53f50b9Schristos if (process_all_regular_maps() != 0)
336a53f50b9Schristos exit(1);
337a53f50b9Schristos }
338a53f50b9Schristos
339a53f50b9Schristos #ifdef DEBUG
340a53f50b9Schristos usage += switch_option("debug");
341a53f50b9Schristos /* initialize debug options */
342a53f50b9Schristos if (!debug_flags)
343a53f50b9Schristos debug_flags = D_CONTROL; /* CONTROL = "daemon,amq,fork" */
344a53f50b9Schristos #endif /* DEBUG */
345a53f50b9Schristos
346a53f50b9Schristos /* log information regarding amd.conf file */
347a53f50b9Schristos if (use_conf_file && amu_conf_file)
348a53f50b9Schristos plog(XLOG_INFO, "using configuration file %s", amu_conf_file);
349a53f50b9Schristos
350a53f50b9Schristos #ifdef HAVE_MAP_LDAP
351a53f50b9Schristos /* ensure that if ldap_base is specified, that also ldap_hostports is */
352a53f50b9Schristos if (gopt.ldap_hostports && !gopt.ldap_base) {
353a53f50b9Schristos fprintf(stderr, "must specify both ldap_hostports and ldap_base\n");
354a53f50b9Schristos exit(1);
355a53f50b9Schristos }
356a53f50b9Schristos #endif /* HAVE_MAP_LDAP */
357a53f50b9Schristos
358a53f50b9Schristos if (usage) {
359a53f50b9Schristos show_usage();
360a53f50b9Schristos exit(1);
361a53f50b9Schristos }
362a53f50b9Schristos
363a53f50b9Schristos while (optind <= argc - 2) {
364a53f50b9Schristos char *dir = argv[optind++];
365a53f50b9Schristos char *map = argv[optind++];
366a53f50b9Schristos char *opts = "";
367a53f50b9Schristos if (argv[optind] && *argv[optind] == '-')
368a53f50b9Schristos opts = &argv[optind++][1];
369a53f50b9Schristos
370a53f50b9Schristos root_newmap(dir, opts, map, NULL);
371a53f50b9Schristos }
372a53f50b9Schristos
373a53f50b9Schristos if (optind == argc) {
374a53f50b9Schristos /*
375a53f50b9Schristos * Append domain name to hostname.
376a53f50b9Schristos * sub_domain overrides hostdomain
377a53f50b9Schristos * if given.
378a53f50b9Schristos */
379a53f50b9Schristos if (gopt.sub_domain)
380a53f50b9Schristos hostdomain = gopt.sub_domain;
381a53f50b9Schristos if (*hostdomain == '.')
382a53f50b9Schristos hostdomain++;
383a53f50b9Schristos xstrlcat(hostd, ".", sizeof(hostd));
384a53f50b9Schristos xstrlcat(hostd, hostdomain, sizeof(hostd));
385a53f50b9Schristos
386a53f50b9Schristos #ifdef MOUNT_TABLE_ON_FILE
387a53f50b9Schristos if (amuDebug(D_MTAB))
388a53f50b9Schristos if (gopt.debug_mtab_file)
389a53f50b9Schristos mnttab_file_name = gopt.debug_mtab_file; /* user supplied debug mtab path */
390a53f50b9Schristos else
391a53f50b9Schristos mnttab_file_name = DEBUG_MNTTAB_FILE; /* default debug mtab path */
392a53f50b9Schristos else
393a53f50b9Schristos mnttab_file_name = MNTTAB_FILE_NAME;
394a53f50b9Schristos #else /* not MOUNT_TABLE_ON_FILE */
395a53f50b9Schristos if (amuDebug(D_MTAB))
396a53f50b9Schristos dlog("-D mtab option ignored");
397a53f50b9Schristos # ifdef MNTTAB_FILE_NAME
398a53f50b9Schristos mnttab_file_name = MNTTAB_FILE_NAME;
399a53f50b9Schristos # endif /* MNTTAB_FILE_NAME */
400a53f50b9Schristos #endif /* not MOUNT_TABLE_ON_FILE */
401a53f50b9Schristos
402a53f50b9Schristos /*
403a53f50b9Schristos * If the kernel architecture was not specified
404a53f50b9Schristos * then use the machine architecture.
405a53f50b9Schristos */
406a53f50b9Schristos if (gopt.karch == NULL)
407a53f50b9Schristos gopt.karch = gopt.arch;
408a53f50b9Schristos
409a53f50b9Schristos if (gopt.cluster == NULL)
410a53f50b9Schristos gopt.cluster = hostdomain;
411a53f50b9Schristos
412a53f50b9Schristos /* sanity checking, normalize values just in case (toplvl too) */
413a53f50b9Schristos for (i=0; i<AMU_TYPE_MAX; ++i) {
414a53f50b9Schristos if (gopt.amfs_auto_timeo[i] == 0)
415a53f50b9Schristos gopt.amfs_auto_timeo[i] = AMFS_AUTO_TIMEO;
416a53f50b9Schristos if (gopt.amfs_auto_retrans[i] == 0)
417a53f50b9Schristos gopt.amfs_auto_retrans[i] = AMFS_AUTO_RETRANS(i);
418a53f50b9Schristos if (gopt.amfs_auto_retrans[i] == 0)
419a53f50b9Schristos gopt.amfs_auto_retrans[i] = 3; /* under very unusual circumstances, could be zero */
420a53f50b9Schristos }
421a53f50b9Schristos }
422a53f50b9Schristos
423a53f50b9Schristos /* finally print version string and exit, if asked for */
424a53f50b9Schristos if (print_version) {
425a53f50b9Schristos fputs(get_version_string(), stderr);
426a53f50b9Schristos exit(0);
427a53f50b9Schristos }
428a53f50b9Schristos
429a53f50b9Schristos if (switch_to_logfile(gopt.logfile, orig_umask,
430a53f50b9Schristos (gopt.flags & CFM_TRUNCATE_LOG)) != 0)
431a53f50b9Schristos plog(XLOG_USER, "Cannot switch logfile");
432a53f50b9Schristos
433a53f50b9Schristos return;
434a53f50b9Schristos }
435