2 * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3 * Copyright (c) 1991-1998 University of Maryland at College Park
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of U.M. not be used in advertising or
11 * publicity pertaining to distribution of the software without specific,
12 * written prior permission. U.M. makes no representations about the
13 * suitability of this software for any purpose. It is provided "as is"
14 * without express or implied warranty.
16 * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
18 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 * Author: James da Silva, Systems Design and Analysis Group
24 * Computer Science Department
25 * University of Maryland at College Park
28 * $Id: getconf.c,v 1.18 2006/01/14 04:37:19 paddy_s Exp $
30 * a little wrapper to extract config variables for shell scripts
34 #include "genversion.h"
37 int main P((int argc, char **argv));
39 static struct build_info {
43 { "VERSION", "" }, /* must be [0] */
44 { "AMANDA_DEBUG_DAYS", "" }, /* must be [1] */
45 { "TICKET_LIFETIME", "" }, /* must be [2] */
48 { "sbindir", sbindir },
49 { "libexecdir", libexecdir },
51 { "AMANDA_TMPDIR", AMANDA_TMPDIR },
52 { "CONFIG_DIR", CONFIG_DIR },
54 { "DEFAULT_SERVER", DEFAULT_SERVER },
55 { "DEFAULT_CONFIG", DEFAULT_CONFIG },
56 { "DEFAULT_TAPE_SERVER", DEFAULT_TAPE_SERVER },
57 { "DEFAULT_TAPE_DEVICE", DEFAULT_TAPE_SERVER },
58 { "CLIENT_LOGIN", CLIENT_LOGIN },
61 #if defined(BUILT_DATE)
66 #if defined(BUILT_MACH)
77 #if defined(AMANDA_DBGDIR)
82 #if defined(DEV_PREFIX)
87 #if defined(RDEV_PREFIX)
131 #if defined(SAMBA_CLIENT)
141 #if defined(COMPRESS_PATH)
146 #if defined(UNCOMPRESS_PATH)
151 #if defined(GNUTAR_LISTED_INCREMENTAL_DIR)
152 GNUTAR_LISTED_INCREMENTAL_DIR
155 { "GNUTAR_LISTED_INCREMENTAL_DIR",
156 #if defined(GNUTAR_LISTED_INCREMENTAL_DIR)
157 GNUTAR_LISTED_INCREMENTAL_DIR
162 #if defined(AIX_BACKUP)
167 #if defined(AIX_TAPEIO)
172 #if defined(DUMP_RETURNS_1)
178 #if defined(USE_POSIX_FCNTL)
180 #elif defined(USE_FLOCK)
182 #elif defined(USE_LOCKF)
184 #elif defined(USE_LNLOCK)
192 #if defined(STATFS_BSD)
197 #if defined(STATFS_OSF1)
202 #if defined(STATFS_ULTRIX)
207 #if defined(ASSERTIONS)
212 #if defined(DEBUG_CODE)
217 #if defined(BSD_SECURITY)
222 #if defined(USE_AMANDAHOSTS)
227 #if defined(USE_RUNDUMP)
232 #if defined(FORCE_USERID)
236 { "USE_VERSION_SUFFIXES",
237 #if defined(USE_VERSION_SUFFIXES)
242 #if defined(HAVE_GZIP)
248 #if defined(KRB4_SECURITY)
252 { "SERVER_HOST_PRINCIPLE",
253 #if defined(KRB4_SECURITY)
254 SERVER_HOST_PRINCIPLE
257 { "SERVER_HOST_INSTANCE",
258 #if defined(KRB4_SECURITY)
262 { "SERVER_HOST_KEY_FILE",
263 #if defined(KRB4_SECURITY)
267 { "CLIENT_HOST_PRINCIPLE",
268 #if defined(KRB4_SECURITY)
269 CLIENT_HOST_PRINCIPLE
272 { "CLIENT_HOST_INSTANCE",
273 #if defined(KRB4_SECURITY)
277 { "CLIENT_HOST_KEY_FILE",
278 #if defined(KRB4_SECURITY)
284 #if defined(COMPRESS_SUFFIX)
288 { "COMPRESS_FAST_OPT",
289 #if defined(COMPRESS_FAST_OPT)
293 { "COMPRESS_BEST_OPT",
294 #if defined(COMPRESS_BEST_OPT)
299 #if defined(UNCOMPRESS_OPT)
312 unsigned long malloc_hist_1, malloc_size_1;
313 unsigned long malloc_hist_2, malloc_size_2;
318 char number[NUM_STR_SIZE];
322 malloc_size_1 = malloc_inuse(&malloc_hist_1);
324 if((pgm = strrchr(argv[0], '/')) == NULL) {
331 /* Don't die when child closes pipe */
332 signal(SIGPIPE, SIG_IGN);
335 fprintf(stderr, "Usage: %s [config] <parmname>\n", pgm);
340 config_name = stralloc(argv[1]);
341 config_dir = vstralloc(CONFIG_DIR, "/", config_name, "/", NULL);
344 char my_cwd[STR_SIZE];
346 if (getcwd(my_cwd, sizeof(my_cwd)) == NULL) {
347 error("cannot determine current working directory");
349 config_dir = stralloc2(my_cwd, "/");
350 if ((config_name = strrchr(my_cwd, '/')) != NULL) {
351 config_name = stralloc(config_name + 1);
359 * Fill in the build values that need runtime help.
361 build_info[0].value = stralloc(version());
362 #if defined(AMANDA_DEBUG_DAYS)
363 i = AMANDA_DEBUG_DAYS;
367 snprintf(number, sizeof(number), "%ld", (long)i);
368 build_info[1].value = stralloc(number);
369 #if defined(KRB4_SECURITY)
374 snprintf(number, sizeof(number), "%ld", (long)i);
375 build_info[2].value = stralloc(number);
380 if(strncmp(parmname, p, sizeof(p) - 1) == 0) {
384 t = stralloc(parmname + sizeof(p) - 1);
385 for(i = 0; (s = build_info[i].symbol) != NULL; i++) {
386 if(strcasecmp(s, t) == 0) {
393 result = build_info[i].value;
394 result = stralloc(result ? result : "");
400 } else if(strncmp(parmname, p, sizeof(p) - 1) == 0) {
404 if((pname = strrchr(parmname + sizeof(p) - 1, '/')) == NULL) {
405 pname = parmname + sizeof(p) - 1;
411 if((dbname = dbfn()) == NULL) {
412 result = stralloc("/dev/null");
414 result = stralloc(dbname);
417 * Note that we deliberately do *not* call dbclose to prevent
418 * the end line from being added to the file.
424 } else if(strncmp(parmname, p, sizeof(p) - 1) == 0) {
429 t = stralloc(parmname + sizeof(p) - 1);
430 if((dbname = strchr(t, ':')) == NULL) {
431 error("cannot parse %s", parmname);
434 if((pname = strrchr(t, '/')) == NULL) {
441 dbreopen(dbname, NULL);
443 result = stralloc(dbname);
447 conffile = stralloc2(config_dir, CONFFILE_NAME);
448 if(read_conffile(conffile)) {
449 error("errors processing config file \"%s\"", conffile);
452 result = getconf_byname(parmname);
455 result = stralloc("BUGGY");
456 fprintf(stderr, "%s: no such parameter \"%s\"\n",
457 get_pname(), parmname);
466 for(i = 0; i < 3; i++) {
467 amfree(build_info[i].value);
470 malloc_size_2 = malloc_inuse(&malloc_hist_2);
472 if(malloc_size_1 != malloc_size_2) {
473 malloc_list(fileno(stderr), malloc_hist_1, malloc_hist_2);