X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=server-src%2Famtrmlog.c;h=01193e832b8be4bc184c51bb32d01d552f717dd9;hb=HEAD;hp=5afef3b0028714cd3b825baa6928ddc5b6213c93;hpb=12179dea039515c06168c0037d048566a3f623de;p=debian%2Famanda diff --git a/server-src/amtrmlog.c b/server-src/amtrmlog.c index 5afef3b..01193e8 100644 --- a/server-src/amtrmlog.c +++ b/server-src/amtrmlog.c @@ -1,6 +1,7 @@ /* * Amanda, The Advanced Maryland Automatic Network Disk Archiver * Copyright (c) 1991-1998 University of Maryland at College Park + * Copyright (c) 2007-2012 Zmanda, Inc. All Rights Reserved. * All Rights Reserved. * * Permission to use, copy, modify, distribute, and sell this software and its @@ -33,14 +34,10 @@ #include "amanda.h" #include "arglist.h" -#ifdef HAVE_NETINET_IN_SYSTM_H -#include -#endif #include "conffile.h" #include "diskfile.h" #include "tapefile.h" #include "find.h" -#include "version.h" int amtrmidx_debug = 0; @@ -64,13 +61,25 @@ main( char *logname = NULL; struct stat stat_log; struct stat stat_old; - char *conffile; char *conf_diskfile; char *conf_tapelist; char *conf_logdir; int dumpcycle; - int new_argc, my_argc; - char **new_argv, **my_argv; + config_overrides_t *cfg_ovr = NULL; + + if (argc > 1 && argv && argv[1] && g_str_equal(argv[1], "--version")) { + printf("amtrmlog-%s\n", VERSION); + return (0); + } + + /* + * Configure program for internationalization: + * 1) Only set the message locale for now. + * 2) Set textdomain for all amanda related programs to "amanda" + * We don't want to be forced to support dozens of message catalogs. + */ + setlocale(LC_MESSAGES, "C"); + textdomain("amanda"); safe_fd(-1, 0); safe_cd(); @@ -80,58 +89,43 @@ main( /* Don't die when child closes pipe */ signal(SIGPIPE, SIG_IGN); - parse_server_conf(argc, argv, &new_argc, &new_argv); - my_argc = new_argc; - my_argv = new_argv; + cfg_ovr = extract_commandline_config_overrides(&argc, &argv); - if (my_argc > 1 && strcmp(my_argv[1], "-t") == 0) { + if (argc > 1 && strcmp(argv[1], "-t") == 0) { amtrmidx_debug = 1; - my_argc--; - my_argv++; + argc--; + argv++; } - if (my_argc < 2) { - fprintf(stderr, "Usage: %s [-t] [-o configoption]*\n", my_argv[0]); + if (argc < 2) { + g_fprintf(stderr, _("Usage: %s [-t] [-o configoption]*\n"), argv[0]); return 1; } dbopen(DBG_SUBDIR_SERVER); - dbprintf(("%s: version %s\n", my_argv[0], version())); + dbprintf(_("%s: version %s\n"), argv[0], VERSION); - config_name = my_argv[1]; + set_config_overrides(cfg_ovr); + config_init(CONFIG_INIT_EXPLICIT_NAME, argv[1]); - config_dir = vstralloc(CONFIG_DIR, "/", config_name, "/", NULL); - conffile = stralloc2(config_dir, CONFFILE_NAME); - if (read_conffile(conffile)) { - error("errors processing amanda config file \"%s\"", conffile); - /*NOTREACHED*/ - } - amfree(conffile); + conf_diskfile = config_dir_relative(getconf_str(CNF_DISKFILE)); + read_diskfile(conf_diskfile, &diskl); + amfree(conf_diskfile); - dbrename(config_name, DBG_SUBDIR_SERVER); + if (config_errors(NULL) >= CFGERR_WARNINGS) { + config_print_errors(); + if (config_errors(NULL) >= CFGERR_ERRORS) { + g_critical(_("errors processing config file")); + } + } - report_bad_conf_arg(); + check_running_as(RUNNING_AS_DUMPUSER); - conf_diskfile = getconf_str(CNF_DISKFILE); - if (*conf_diskfile == '/') { - conf_diskfile = stralloc(conf_diskfile); - } else { - conf_diskfile = stralloc2(config_dir, conf_diskfile); - } - if (read_diskfile(conf_diskfile, &diskl) < 0) { - error("could not load disklist \"%s\"", conf_diskfile); - /*NOTREACHED*/ - } - amfree(conf_diskfile); + dbrename(get_config_name(), DBG_SUBDIR_SERVER); - conf_tapelist = getconf_str(CNF_TAPELIST); - if (*conf_tapelist == '/') { - conf_tapelist = stralloc(conf_tapelist); - } else { - conf_tapelist = stralloc2(config_dir, conf_tapelist); - } + conf_tapelist = config_dir_relative(getconf_str(CNF_TAPELIST)); if (read_tapelist(conf_tapelist)) { - error("could not load tapelist \"%s\"", conf_tapelist); + error(_("could not load tapelist \"%s\""), conf_tapelist); /*NOTREACHED*/ } amfree(conf_tapelist); @@ -146,36 +140,33 @@ main( /* determine how many log to keep */ no_keep = getconf_int(CNF_TAPECYCLE) * 2; - dbprintf(("Keeping %d log file%s\n", no_keep, (no_keep == 1) ? "" : "s")); + dbprintf(plural(_("Keeping %d log file\n"), + _("Keeping %d log files\n"), no_keep), + no_keep); - conf_logdir = getconf_str(CNF_LOGDIR); - if (*conf_logdir == '/') { - conf_logdir = stralloc(conf_logdir); - } else { - conf_logdir = stralloc2(config_dir, conf_logdir); - } + conf_logdir = config_dir_relative(getconf_str(CNF_LOGDIR)); olddir = vstralloc(conf_logdir, "/oldlog", NULL); - if (mkpdir(olddir, 02700, (uid_t)-1, (gid_t)-1) != 0) { - error("could not create parents of %s: %s", olddir, strerror(errno)); + if (mkpdir(olddir, 0700, (uid_t)-1, (gid_t)-1) != 0) { + error(_("could not create parents of %s: %s"), olddir, strerror(errno)); /*NOTREACHED*/ } - if (mkdir(olddir, 02700) != 0 && errno != EEXIST) { - error("could not create %s: %s", olddir, strerror(errno)); + if (mkdir(olddir, 0700) != 0 && errno != EEXIST) { + error(_("could not create %s: %s"), olddir, strerror(errno)); /*NOTREACHED*/ } if (stat(olddir,&stat_old) == -1) { - error("can't stat oldlog directory \"%s\": %s", olddir, strerror(errno)); + error(_("can't stat oldlog directory \"%s\": %s"), olddir, strerror(errno)); /*NOTREACHED*/ } if (!S_ISDIR(stat_old.st_mode)) { - error("Oldlog directory \"%s\" is not a directory", olddir); + error(_("Oldlog directory \"%s\" is not a directory"), olddir); /*NOTREACHED*/ } if ((dir = opendir(conf_logdir)) == NULL) { - error("could not open log directory \"%s\": %s", conf_logdir,strerror(errno)); + error(_("could not open log directory \"%s\": %s"), conf_logdir,strerror(errno)); /*NOTREACHED*/ } while ((adir=readdir(dir)) != NULL) { @@ -204,7 +195,7 @@ main( newfile = newvstralloc(newfile, olddir, "/", adir->d_name, NULL); if (rename(oldfile,newfile) != 0) { - error("could not rename \"%s\" to \"%s\": %s", + error(_("could not rename \"%s\" to \"%s\": %s"), oldfile, newfile, strerror(errno)); /*NOTREACHED*/ } @@ -220,12 +211,9 @@ main( amfree(oldfile); amfree(newfile); amfree(olddir); - amfree(config_dir); amfree(conf_logdir); clear_tapelist(); free_disklist(&diskl); - free_new_argv(new_argc, new_argv); - free_server_config(); dbclose();