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.8.4.2.2.2.2.4.2.3 2005/09/21 19:04:22 jrjackson Exp $
30 * a little wrapper to extract config variables for shell scripts
34 #include "genversion.h"
37 #define HOSTNAME_INSTANCE "host_inst"
39 int main P((int argc, char **argv));
41 static struct build_info {
45 { "VERSION", "" }, /* must be [0] */
46 { "AMANDA_DEBUG_DAYS", "" }, /* must be [1] */
47 { "TICKET_LIFETIME", "" }, /* must be [2] */
50 { "sbindir", sbindir },
51 { "libexecdir", libexecdir },
53 { "AMANDA_TMPDIR", AMANDA_TMPDIR },
54 { "CONFIG_DIR", CONFIG_DIR },
56 { "DEFAULT_SERVER", DEFAULT_SERVER },
57 { "DEFAULT_CONFIG", DEFAULT_CONFIG },
58 { "DEFAULT_TAPE_SERVER", DEFAULT_TAPE_SERVER },
59 { "DEFAULT_TAPE_DEVICE", DEFAULT_TAPE_SERVER },
60 { "CLIENT_LOGIN", CLIENT_LOGIN },
63 #if defined(BUILT_DATE)
68 #if defined(BUILT_MACH)
79 #if defined(AMANDA_DBGDIR)
84 #if defined(DEV_PREFIX)
89 #if defined(RDEV_PREFIX)
133 #if defined(SAMBA_CLIENT)
143 #if defined(COMPRESS_PATH)
148 #if defined(UNCOMPRESS_PATH)
153 #if defined(GNUTAR_LISTED_INCREMENTAL_DIR)
154 GNUTAR_LISTED_INCREMENTAL_DIR
157 { "GNUTAR_LISTED_INCREMENTAL_DIR",
158 #if defined(GNUTAR_LISTED_INCREMENTAL_DIR)
159 GNUTAR_LISTED_INCREMENTAL_DIR
164 #if defined(AIX_BACKUP)
169 #if defined(AIX_TAPEIO)
174 #if defined(DUMP_RETURNS_1)
180 #if defined(USE_POSIX_FCNTL)
182 #elif defined(USE_FLOCK)
184 #elif defined(USE_LOCKF)
186 #elif defined(USE_LNLOCK)
194 #if defined(STATFS_BSD)
199 #if defined(STATFS_OSF1)
204 #if defined(STATFS_ULTRIX)
209 #if defined(ASSERTIONS)
214 #if defined(DEBUG_CODE)
219 #if defined(BSD_SECURITY)
224 #if defined(USE_AMANDAHOSTS)
229 #if defined(USE_RUNDUMP)
234 #if defined(FORCE_USERID)
238 { "USE_VERSION_SUFFIXES",
239 #if defined(USE_VERSION_SUFFIXES)
244 #if defined(HAVE_GZIP)
250 #if defined(KRB4_SECURITY)
254 { "SERVER_HOST_PRINCIPLE",
255 #if defined(KRB4_SECURITY)
256 SERVER_HOST_PRINCIPLE
259 { "SERVER_HOST_INSTANCE",
260 #if defined(KRB4_SECURITY)
264 { "SERVER_HOST_KEY_FILE",
265 #if defined(KRB4_SECURITY)
269 { "CLIENT_HOST_PRINCIPLE",
270 #if defined(KRB4_SECURITY)
271 CLIENT_HOST_PRINCIPLE
274 { "CLIENT_HOST_INSTANCE",
275 #if defined(KRB4_SECURITY)
279 { "CLIENT_HOST_KEY_FILE",
280 #if defined(KRB4_SECURITY)
286 #if defined(COMPRESS_SUFFIX)
290 { "COMPRESS_FAST_OPT",
291 #if defined(COMPRESS_FAST_OPT)
295 { "COMPRESS_BEST_OPT",
296 #if defined(COMPRESS_BEST_OPT)
301 #if defined(UNCOMPRESS_OPT)
314 unsigned long malloc_hist_1, malloc_size_1;
315 unsigned long malloc_hist_2, malloc_size_2;
320 char number[NUM_STR_SIZE];
324 malloc_size_1 = malloc_inuse(&malloc_hist_1);
326 if((pgm = strrchr(argv[0], '/')) == NULL) {
334 fprintf(stderr, "Usage: %s [config] <parmname>\n", pgm);
339 config_name = stralloc(argv[1]);
340 config_dir = vstralloc(CONFIG_DIR, "/", config_name, "/", NULL);
343 char my_cwd[STR_SIZE];
345 if (getcwd(my_cwd, sizeof(my_cwd)) == NULL) {
346 error("cannot determine current working directory");
348 config_dir = stralloc2(my_cwd, "/");
349 if ((config_name = strrchr(my_cwd, '/')) != NULL) {
350 config_name = stralloc(config_name + 1);
358 * Fill in the build values that need runtime help.
360 build_info[0].value = stralloc(version());
361 #if defined(AMANDA_DEBUG_DAYS)
362 i = AMANDA_DEBUG_DAYS;
366 ap_snprintf(number, sizeof(number), "%ld", (long)i);
367 build_info[1].value = stralloc(number);
368 #if defined(KRB4_SECURITY)
373 ap_snprintf(number, sizeof(number), "%ld", (long)i);
374 build_info[2].value = stralloc(number);
379 if(strncmp(parmname, p, sizeof(p) - 1) == 0) {
383 t = stralloc(parmname + sizeof(p) - 1);
384 for(i = 0; (s = build_info[i].symbol) != NULL; i++) {
385 if(strcasecmp(s, t) == 0) {
392 result = build_info[i].value;
393 result = stralloc(result ? result : "");
399 } else if(strncmp(parmname, p, sizeof(p) - 1) == 0) {
403 if((pname = strrchr(parmname + sizeof(p) - 1, '/')) == NULL) {
404 pname = parmname + sizeof(p) - 1;
410 if((dbname = dbfn()) == NULL) {
411 result = stralloc("/dev/null");
413 result = stralloc(dbname);
416 * Note that we deliberately do *not* call dbclose to prevent
417 * the end line from being added to the file.
423 } else if(strncmp(parmname, p, sizeof(p) - 1) == 0) {
428 t = stralloc(parmname + sizeof(p) - 1);
429 if((dbname = strchr(t, ':')) == NULL) {
430 error("cannot parse %s", parmname);
433 if((pname = strrchr(t, '/')) == NULL) {
440 dbreopen(dbname, NULL);
442 result = stralloc(dbname);
446 conffile = stralloc2(config_dir, CONFFILE_NAME);
447 if(read_conffile(conffile)) {
448 error("errors processing config file \"%s\"", conffile);
451 result = getconf_byname(parmname);
454 result = stralloc("BUGGY");
455 fprintf(stderr, "%s: no such parameter \"%s\"\n",
456 get_pname(), parmname);
465 for(i = 0; i < 3; i++) {
466 amfree(build_info[i].value);
469 malloc_size_2 = malloc_inuse(&malloc_hist_2);
471 if(malloc_size_1 != malloc_size_2) {
472 malloc_list(fileno(stderr), malloc_hist_1, malloc_hist_2);