X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fstored%2Fstored_conf.c;h=877c4a51d87323570ea95167c8f50f046175ad08;hb=bc9b9b481e86991abd879d30aa03b64b4c68d578;hp=b3dea456bc6ac5e0daf8b8138448536b0c1c02c0;hpb=6dd6165a8cb1bb13fd022c57294c40ed3558f692;p=bacula%2Fbacula diff --git a/bacula/src/stored/stored_conf.c b/bacula/src/stored/stored_conf.c index b3dea456bc..877c4a51d8 100644 --- a/bacula/src/stored/stored_conf.c +++ b/bacula/src/stored/stored_conf.c @@ -1,3 +1,30 @@ +/* + Bacula® - The Network Backup Solution + + Copyright (C) 2000-2007 Free Software Foundation Europe e.V. + + The main author of Bacula is Kern Sibbald, with contributions from + many others, a complete list can be found in the file AUTHORS. + This program is Free Software; you can redistribute it and/or + modify it under the terms of version two of the GNU General Public + License as published by the Free Software Foundation and included + in the file LICENSE. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + + Bacula® is a registered trademark of John Walker. + The licensor of Bacula is the Free Software Foundation Europe + (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, + Switzerland, email:ftf@fsfeurope.org. +*/ /* * Configuration file parser for Bacula Storage daemon * @@ -5,27 +32,10 @@ * * Version $Id$ */ -/* - Copyright (C) 2000-2005 Kern Sibbald - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - version 2 as ammended with additional clauses defined in the - file LICENSE in the main source directory. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - the file LICENSE for additional details. - - */ #include "bacula.h" #include "stored.h" -extern int debug_level; - - /* First and last resource ids */ int r_first = R_FIRST; int r_last = R_LAST; @@ -34,10 +44,18 @@ RES **res_head = sres_head; /* Forward referenced subroutines */ +static void store_devtype(LEX *lc, RES_ITEM *item, int index, int pass); + /* We build the current resource here statically, * then move it to dynamic memory */ +#if defined(_MSC_VER) +extern "C" { // work around visual compiler mangling variables + URES res_all; +} +#else URES res_all; +#endif int res_all_size = sizeof(res_all); /* Definition of records permitted within each @@ -51,26 +69,27 @@ static RES_ITEM store_items[] = { {"description", store_str, ITEM(res_dir.hdr.desc), 0, 0, 0}, {"sdaddress", store_addresses_address, ITEM(res_store.sdaddrs), 0, ITEM_DEFAULT, 9103}, {"sdaddresses", store_addresses, ITEM(res_store.sdaddrs), 0, ITEM_DEFAULT, 9103}, - {"messages", store_res, ITEM(res_store.messages), 0, R_MSGS, 0}, + {"messages", store_res, ITEM(res_store.messages), R_MSGS, 0, 0}, {"sdport", store_addresses_port, ITEM(res_store.sdaddrs), 0, ITEM_DEFAULT, 9103}, {"workingdirectory", store_dir, ITEM(res_store.working_directory), 0, ITEM_REQUIRED, 0}, {"piddirectory", store_dir, ITEM(res_store.pid_directory), 0, ITEM_REQUIRED, 0}, {"subsysdirectory", store_dir, ITEM(res_store.subsys_directory), 0, 0, 0}, + {"plugindirectory", store_dir, ITEM(res_store.plugin_directory), 0, 0, 0}, {"scriptsdirectory", store_dir, ITEM(res_store.scripts_directory), 0, 0, 0}, - {"maximumconcurrentjobs", store_pint, ITEM(res_store.max_concurrent_jobs), 0, ITEM_DEFAULT, 10}, + {"maximumconcurrentjobs", store_pint, ITEM(res_store.max_concurrent_jobs), 0, ITEM_DEFAULT, 20}, {"heartbeatinterval", store_time, ITEM(res_store.heartbeat_interval), 0, ITEM_DEFAULT, 0}, -#ifdef HAVE_TLS - {"tlsenable", store_yesno, ITEM(res_store.tls_enable), 1, ITEM_DEFAULT, 0}, - {"tlsrequire", store_yesno, ITEM(res_store.tls_require), 1, ITEM_DEFAULT, 0}, - {"tlsverifypeer", store_yesno, ITEM(res_store.tls_verify_peer), 1, ITEM_DEFAULT, 0}, + {"tlsauthenticate", store_bool, ITEM(res_store.tls_authenticate), 0, 0, 0}, + {"tlsenable", store_bool, ITEM(res_store.tls_enable), 0, 0, 0}, + {"tlsrequire", store_bool, ITEM(res_store.tls_require), 0, 0, 0}, + {"tlsverifypeer", store_bool, ITEM(res_store.tls_verify_peer), 1, ITEM_DEFAULT, 1}, {"tlscacertificatefile", store_dir, ITEM(res_store.tls_ca_certfile), 0, 0, 0}, {"tlscacertificatedir", store_dir, ITEM(res_store.tls_ca_certdir), 0, 0, 0}, {"tlscertificate", store_dir, ITEM(res_store.tls_certfile), 0, 0, 0}, {"tlskey", store_dir, ITEM(res_store.tls_keyfile), 0, 0, 0}, {"tlsdhfile", store_dir, ITEM(res_store.tls_dhfile), 0, 0, 0}, {"tlsallowedcn", store_alist_str, ITEM(res_store.tls_allowed_cns), 0, 0, 0}, -#endif /* HAVE_TLS */ - {NULL, NULL, 0, 0, 0, 0} + {"clientconnectwait", store_time, ITEM(res_store.client_wait), 0, ITEM_DEFAULT, 30 * 60}, + {NULL, NULL, {0}, 0, 0, 0} }; @@ -79,57 +98,58 @@ static RES_ITEM dir_items[] = { {"name", store_name, ITEM(res_dir.hdr.name), 0, ITEM_REQUIRED, 0}, {"description", store_str, ITEM(res_dir.hdr.desc), 0, 0, 0}, {"password", store_password, ITEM(res_dir.password), 0, ITEM_REQUIRED, 0}, - {"monitor", store_yesno, ITEM(res_dir.monitor), 1, ITEM_DEFAULT, 0}, -#ifdef HAVE_TLS - {"tlsenable", store_yesno, ITEM(res_dir.tls_enable), 1, ITEM_DEFAULT, 0}, - {"tlsrequire", store_yesno, ITEM(res_dir.tls_require), 1, ITEM_DEFAULT, 0}, - {"tlsverifypeer", store_yesno, ITEM(res_dir.tls_verify_peer), 1, ITEM_DEFAULT, 0}, + {"monitor", store_bool, ITEM(res_dir.monitor), 0, 0, 0}, + {"tlsauthenticate", store_bool, ITEM(res_dir.tls_authenticate), 0, 0, 0}, + {"tlsenable", store_bool, ITEM(res_dir.tls_enable), 0, 0, 0}, + {"tlsrequire", store_bool, ITEM(res_dir.tls_require), 0, 0, 0}, + {"tlsverifypeer", store_bool, ITEM(res_dir.tls_verify_peer), 1, ITEM_DEFAULT, 1}, {"tlscacertificatefile", store_dir, ITEM(res_dir.tls_ca_certfile), 0, 0, 0}, {"tlscacertificatedir", store_dir, ITEM(res_dir.tls_ca_certdir), 0, 0, 0}, {"tlscertificate", store_dir, ITEM(res_dir.tls_certfile), 0, 0, 0}, {"tlskey", store_dir, ITEM(res_dir.tls_keyfile), 0, 0, 0}, {"tlsdhfile", store_dir, ITEM(res_dir.tls_dhfile), 0, 0, 0}, {"tlsallowedcn", store_alist_str, ITEM(res_dir.tls_allowed_cns), 0, 0, 0}, -#endif /* HAVE_TLS */ - {NULL, NULL, 0, 0, 0, 0} + {NULL, NULL, {0}, 0, 0, 0} }; /* Device definition */ static RES_ITEM dev_items[] = { - {"name", store_name, ITEM(res_dev.hdr.name), 0, ITEM_REQUIRED, 0}, - {"description", store_str, ITEM(res_dir.hdr.desc), 0, 0, 0}, - {"mediatype", store_strname,ITEM(res_dev.media_type), 0, ITEM_REQUIRED, 0}, - {"archivedevice", store_strname,ITEM(res_dev.device_name), 0, ITEM_REQUIRED, 0}, - {"hardwareendoffile", store_yesno, ITEM(res_dev.cap_bits), CAP_EOF, ITEM_DEFAULT, 1}, - {"hardwareendofmedium", store_yesno, ITEM(res_dev.cap_bits), CAP_EOM, ITEM_DEFAULT, 1}, - {"backwardspacerecord", store_yesno, ITEM(res_dev.cap_bits), CAP_BSR, ITEM_DEFAULT, 1}, - {"backwardspacefile", store_yesno, ITEM(res_dev.cap_bits), CAP_BSF, ITEM_DEFAULT, 1}, - {"bsfateom", store_yesno, ITEM(res_dev.cap_bits), CAP_BSFATEOM, ITEM_DEFAULT, 0}, - {"twoeof", store_yesno, ITEM(res_dev.cap_bits), CAP_TWOEOF, ITEM_DEFAULT, 0}, - {"forwardspacerecord", store_yesno, ITEM(res_dev.cap_bits), CAP_FSR, ITEM_DEFAULT, 1}, - {"forwardspacefile", store_yesno, ITEM(res_dev.cap_bits), CAP_FSF, ITEM_DEFAULT, 1}, - {"fastforwardspacefile", store_yesno, ITEM(res_dev.cap_bits), CAP_FASTFSF, ITEM_DEFAULT, 1}, - {"removablemedia", store_yesno, ITEM(res_dev.cap_bits), CAP_REM, ITEM_DEFAULT, 1}, - {"randomaccess", store_yesno, ITEM(res_dev.cap_bits), CAP_RACCESS, 0, 0}, - {"automaticmount", store_yesno, ITEM(res_dev.cap_bits), CAP_AUTOMOUNT, ITEM_DEFAULT, 0}, - {"labelmedia", store_yesno, ITEM(res_dev.cap_bits), CAP_LABEL, ITEM_DEFAULT, 0}, - {"alwaysopen", store_yesno, ITEM(res_dev.cap_bits), CAP_ALWAYSOPEN, ITEM_DEFAULT, 1}, - {"autochanger", store_yesno, ITEM(res_dev.cap_bits), CAP_AUTOCHANGER, ITEM_DEFAULT, 0}, - {"closeonpoll", store_yesno, ITEM(res_dev.cap_bits), CAP_CLOSEONPOLL, ITEM_DEFAULT, 0}, - {"blockpositioning", store_yesno, ITEM(res_dev.cap_bits), CAP_POSITIONBLOCKS, ITEM_DEFAULT, 1}, - {"usemtiocget", store_yesno, ITEM(res_dev.cap_bits), CAP_MTIOCGET, ITEM_DEFAULT, 1}, - {"checklabels", store_yesno, ITEM(res_dev.cap_bits), CAP_CHECKLABELS, ITEM_DEFAULT, 0}, - {"autoselect", store_yesno, ITEM(res_dev.autoselect), 1, ITEM_DEFAULT, 1}, + {"name", store_name, ITEM(res_dev.hdr.name), 0, ITEM_REQUIRED, 0}, + {"description", store_str, ITEM(res_dir.hdr.desc), 0, 0, 0}, + {"mediatype", store_strname,ITEM(res_dev.media_type), 0, ITEM_REQUIRED, 0}, + {"devicetype", store_devtype,ITEM(res_dev.dev_type), 0, 0, 0}, + {"archivedevice", store_strname,ITEM(res_dev.device_name), 0, ITEM_REQUIRED, 0}, + {"hardwareendoffile", store_bit, ITEM(res_dev.cap_bits), CAP_EOF, ITEM_DEFAULT, 1}, + {"hardwareendofmedium", store_bit, ITEM(res_dev.cap_bits), CAP_EOM, ITEM_DEFAULT, 1}, + {"backwardspacerecord", store_bit, ITEM(res_dev.cap_bits), CAP_BSR, ITEM_DEFAULT, 1}, + {"backwardspacefile", store_bit, ITEM(res_dev.cap_bits), CAP_BSF, ITEM_DEFAULT, 1}, + {"bsfateom", store_bit, ITEM(res_dev.cap_bits), CAP_BSFATEOM, ITEM_DEFAULT, 0}, + {"twoeof", store_bit, ITEM(res_dev.cap_bits), CAP_TWOEOF, ITEM_DEFAULT, 0}, + {"forwardspacerecord", store_bit, ITEM(res_dev.cap_bits), CAP_FSR, ITEM_DEFAULT, 1}, + {"forwardspacefile", store_bit, ITEM(res_dev.cap_bits), CAP_FSF, ITEM_DEFAULT, 1}, + {"fastforwardspacefile", store_bit, ITEM(res_dev.cap_bits), CAP_FASTFSF, ITEM_DEFAULT, 1}, + {"removablemedia", store_bit, ITEM(res_dev.cap_bits), CAP_REM, ITEM_DEFAULT, 1}, + {"randomaccess", store_bit, ITEM(res_dev.cap_bits), CAP_RACCESS, 0, 0}, + {"automaticmount", store_bit, ITEM(res_dev.cap_bits), CAP_AUTOMOUNT, ITEM_DEFAULT, 0}, + {"labelmedia", store_bit, ITEM(res_dev.cap_bits), CAP_LABEL, ITEM_DEFAULT, 0}, + {"alwaysopen", store_bit, ITEM(res_dev.cap_bits), CAP_ALWAYSOPEN, ITEM_DEFAULT, 1}, + {"autochanger", store_bit, ITEM(res_dev.cap_bits), CAP_AUTOCHANGER, ITEM_DEFAULT, 0}, + {"closeonpoll", store_bit, ITEM(res_dev.cap_bits), CAP_CLOSEONPOLL, ITEM_DEFAULT, 0}, + {"blockpositioning", store_bit, ITEM(res_dev.cap_bits), CAP_POSITIONBLOCKS, ITEM_DEFAULT, 1}, + {"usemtiocget", store_bit, ITEM(res_dev.cap_bits), CAP_MTIOCGET, ITEM_DEFAULT, 1}, + {"checklabels", store_bit, ITEM(res_dev.cap_bits), CAP_CHECKLABELS, ITEM_DEFAULT, 0}, + {"requiresmount", store_bit, ITEM(res_dev.cap_bits), CAP_REQMOUNT, ITEM_DEFAULT, 0}, + {"offlineonunmount", store_bit, ITEM(res_dev.cap_bits), CAP_OFFLINEUNMOUNT, ITEM_DEFAULT, 0}, + {"autoselect", store_bit, ITEM(res_dev.autoselect), 1, ITEM_DEFAULT, 1}, {"changerdevice", store_strname,ITEM(res_dev.changer_name), 0, 0, 0}, {"changercommand", store_strname,ITEM(res_dev.changer_command), 0, 0, 0}, {"alertcommand", store_strname,ITEM(res_dev.alert_command), 0, 0, 0}, - {"maximumchangerwait", store_pint, ITEM(res_dev.max_changer_wait), 0, ITEM_DEFAULT, 5 * 60}, - {"maximumopenwait", store_pint, ITEM(res_dev.max_open_wait), 0, ITEM_DEFAULT, 5 * 60}, + {"maximumchangerwait", store_time, ITEM(res_dev.max_changer_wait), 0, ITEM_DEFAULT, 5 * 60}, + {"maximumopenwait", store_time, ITEM(res_dev.max_open_wait), 0, ITEM_DEFAULT, 5 * 60}, {"maximumopenvolumes", store_pint, ITEM(res_dev.max_open_vols), 0, ITEM_DEFAULT, 1}, {"maximumnetworkbuffersize", store_pint, ITEM(res_dev.max_network_buffer_size), 0, 0, 0}, {"volumepollinterval", store_time, ITEM(res_dev.vol_poll_interval), 0, 0, 0}, - {"offlineonunmount", store_yesno, ITEM(res_dev.cap_bits), CAP_OFFLINEUNMOUNT, ITEM_DEFAULT, 0}, - {"maximumrewindwait", store_pint, ITEM(res_dev.max_rewind_wait), 0, ITEM_DEFAULT, 5 * 60}, + {"maximumrewindwait", store_time, ITEM(res_dev.max_rewind_wait), 0, ITEM_DEFAULT, 5 * 60}, {"minimumblocksize", store_pint, ITEM(res_dev.min_block_size), 0, 0, 0}, {"maximumblocksize", store_pint, ITEM(res_dev.max_block_size), 0, 0, 0}, {"maximumvolumesize", store_size, ITEM(res_dev.max_volume_size), 0, 0, 0}, @@ -140,14 +160,13 @@ static RES_ITEM dev_items[] = { {"maximumjobspoolsize", store_size, ITEM(res_dev.max_job_spool_size), 0, 0, 0}, {"driveindex", store_pint, ITEM(res_dev.drive_index), 0, 0, 0}, {"maximumpartsize", store_size, ITEM(res_dev.max_part_size), 0, ITEM_DEFAULT, 0}, - {"requiresmount", store_yesno, ITEM(res_dev.cap_bits), CAP_REQMOUNT, ITEM_DEFAULT, 0}, {"mountpoint", store_strname,ITEM(res_dev.mount_point), 0, 0, 0}, {"mountcommand", store_strname,ITEM(res_dev.mount_command), 0, 0, 0}, {"unmountcommand", store_strname,ITEM(res_dev.unmount_command), 0, 0, 0}, {"writepartcommand", store_strname,ITEM(res_dev.write_part_command), 0, 0, 0}, {"freespacecommand", store_strname,ITEM(res_dev.free_space_command), 0, 0, 0}, {"labeltype", store_label, ITEM(res_dev.label_type), 0, 0, 0}, - {NULL, NULL, 0, 0, 0, 0} + {NULL, NULL, {0}, 0, 0, 0} }; /* Autochanger definition */ @@ -157,11 +176,11 @@ static RES_ITEM changer_items[] = { {"device", store_alist_res, ITEM(res_changer.device), R_DEVICE, ITEM_REQUIRED, 0}, {"changerdevice", store_strname, ITEM(res_changer.changer_name), 0, ITEM_REQUIRED, 0}, {"changercommand", store_strname, ITEM(res_changer.changer_command), 0, ITEM_REQUIRED, 0}, - {NULL, NULL, 0, 0, 0, 0} + {NULL, NULL, {0}, 0, 0, 0} }; -// {"mountanonymousvolumes", store_yesno, ITEM(res_dev.cap_bits), CAP_ANONVOLS, ITEM_DEFAULT, 0}, +// {"mountanonymousvolumes", store_bit, ITEM(res_dev.cap_bits), CAP_ANONVOLS, ITEM_DEFAULT, 0}, /* Message resource */ @@ -178,21 +197,63 @@ RES_TABLE resources[] = { {NULL, NULL, 0} }; +/* + * Device types + * + * device type device code = token + */ +struct s_kw { + const char *name; + int token; +}; +static s_kw dev_types[] = { + {"file", B_FILE_DEV}, + {"tape", B_TAPE_DEV}, + {"dvd", B_DVD_DEV}, + {"fifo", B_FIFO_DEV}, + {"vtl", B_VTL_DEV}, + {NULL, 0} +}; + + +/* + * Store Device Type (File, FIFO, Tape, DVD) + * + */ +static void store_devtype(LEX *lc, RES_ITEM *item, int index, int pass) +{ + int token, i; + + token = lex_get_token(lc, T_NAME); + /* Store the label pass 2 so that type is defined */ + for (i=0; dev_types[i].name; i++) { + if (strcasecmp(lc->str, dev_types[i].name) == 0) { + *(int *)(item->value) = dev_types[i].token; + i = 0; + break; + } + } + if (i != 0) { + scan_err1(lc, _("Expected a Device Type keyword, got: %s"), lc->str); + } + scan_to_eol(lc); + set_bit(index, res_all.hdr.item_present); +} /* Dump contents of resource */ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fmt, ...), void *sock) { URES *res = (URES *)reshdr; - char buf[MAXSTRING]; + char buf[1000]; int recurse = 1; IPADDR *p; if (res == NULL) { sendit(sock, _("Warning: no \"%s\" resource (%d) defined.\n"), res_to_str(type), type); return; } - sendit(sock, "dump_resource type=%d\n", type); + sendit(sock, _("dump_resource type=%d\n"), type); if (type < 0) { /* no recursion */ type = - type; recurse = 0; @@ -226,16 +287,16 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm res->res_dev.hdr.name, res->res_dev.media_type, res->res_dev.device_name, res->res_dev.label_type); - sendit(sock, " rew_wait=%d min_bs=%d max_bs=%d\n", + sendit(sock, " rew_wait=%" lld " min_bs=%d max_bs=%d chgr_wait=%" lld "\n", res->res_dev.max_rewind_wait, res->res_dev.min_block_size, - res->res_dev.max_block_size); + res->res_dev.max_block_size, res->res_dev.max_changer_wait); sendit(sock, " max_jobs=%d max_files=%" lld " max_size=%" lld "\n", res->res_dev.max_volume_jobs, res->res_dev.max_volume_files, res->res_dev.max_volume_size); sendit(sock, " max_file_size=%" lld " capacity=%" lld "\n", res->res_dev.max_file_size, res->res_dev.volume_capacity); - sendit(sock, " spool_directory=%s\n", NPRT(res->res_dev.spool_directory)); - sendit(sock, " max_spool_size=%" lld " max_job_spool_size=%" lld "\n", + sendit(sock, " spool_directory=%s\n", NPRT(res->res_dev.spool_directory)); + sendit(sock, " max_spool_size=%" lld " max_job_spool_size=%" lld "\n", res->res_dev.max_spool_size, res->res_dev.max_job_spool_size); if (res->res_dev.changer_res) { sendit(sock, " changer=%p\n", res->res_dev.changer_res); @@ -280,6 +341,12 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm if (res->res_dev.cap_bits & CAP_CHECKLABELS) { bstrncat(buf, "CAP_CHECKLABELS ", sizeof(buf)); } + if (res->res_dev.cap_bits & CAP_REQMOUNT) { + bstrncat(buf, "CAP_REQMOUNT ", sizeof(buf)); + } + if (res->res_dev.cap_bits & CAP_OFFLINEUNMOUNT) { + bstrncat(buf, "CAP_OFFLINEUNMOUNT ", sizeof(buf)); + } bstrncat(buf, "\n", sizeof(buf)); sendit(sock, buf); break; @@ -342,7 +409,6 @@ void free_resource(RES *sres, int type) if (res->res_dir.address) { free(res->res_dir.address); } -#ifdef HAVE_TLS if (res->res_dir.tls_ctx) { free_tls_context(res->res_dir.tls_ctx); } @@ -364,7 +430,6 @@ void free_resource(RES *sres, int type) if (res->res_dir.tls_allowed_cns) { delete res->res_dir.tls_allowed_cns; } -#endif /* HAVE_TLS */ break; case R_AUTOCHANGER: if (res->res_changer.changer_name) { @@ -396,7 +461,6 @@ void free_resource(RES *sres, int type) if (res->res_store.scripts_directory) { free(res->res_store.scripts_directory); } -#ifdef HAVE_TLS if (res->res_store.tls_ctx) { free_tls_context(res->res_store.tls_ctx); } @@ -418,7 +482,6 @@ void free_resource(RES *sres, int type) if (res->res_store.tls_allowed_cns) { delete res->res_store.tls_allowed_cns; } -#endif /* HAVE_TLS */ break; case R_DEVICE: if (res->res_dev.media_type) { @@ -466,7 +529,7 @@ void free_resource(RES *sres, int type) res = NULL; break; default: - Dmsg1(0, "Unknown resource type %d\n", type); + Dmsg1(0, _("Unknown resource type %d\n"), type); break; } /* Common stuff again -- free the resource, recurse to next one */ @@ -522,24 +585,20 @@ void save_resource(int type, RES_ITEM *items, int pass) /* Resources containing a resource or an alist */ case R_DIRECTOR: if ((res = (URES *)GetResWithName(R_DIRECTOR, res_all.res_dir.hdr.name)) == NULL) { - Emsg1(M_ERROR_TERM, 0, "Cannot find Director resource \"%s\"\n", res_all.res_dir.hdr.name); + Emsg1(M_ERROR_TERM, 0, _("Cannot find Director resource %s\n"), res_all.res_dir.hdr.name); } -#ifdef HAVE_TLS res->res_dir.tls_allowed_cns = res_all.res_dir.tls_allowed_cns; -#endif break; case R_STORAGE: if ((res = (URES *)GetResWithName(R_STORAGE, res_all.res_dir.hdr.name)) == NULL) { - Emsg1(M_ERROR_TERM, 0, "Cannot find Storage resource \"%s\"\n", res_all.res_dir.hdr.name); + Emsg1(M_ERROR_TERM, 0, _("Cannot find Storage resource %s\n"), res_all.res_dir.hdr.name); } res->res_store.messages = res_all.res_store.messages; -#ifdef HAVE_TLS res->res_store.tls_allowed_cns = res_all.res_store.tls_allowed_cns; -#endif break; case R_AUTOCHANGER: if ((res = (URES *)GetResWithName(type, res_all.res_changer.hdr.name)) == NULL) { - Emsg1(M_ERROR_TERM, 0, "Cannot find AutoChanger resource %s\n", + Emsg1(M_ERROR_TERM, 0, _("Cannot find AutoChanger resource %s\n"), res_all.res_changer.hdr.name); } /* we must explicitly copy the device alist pointer */ @@ -554,11 +613,11 @@ void save_resource(int type, RES_ITEM *items, int pass) if ((errstat = pthread_mutex_init(&res->res_changer.changer_mutex, NULL)) != 0) { berrno be; Jmsg1(NULL, M_ERROR_TERM, 0, _("Unable to init mutex: ERR=%s\n"), - be.strerror(errstat)); + be.bstrerror(errstat)); } break; default: - printf("Unknown resource type %d\n", type); + printf(_("Unknown resource type %d\n"), type); error = 1; break; } @@ -593,7 +652,7 @@ void save_resource(int type, RES_ITEM *items, int pass) size = sizeof(AUTOCHANGER); break; default: - printf("Unknown resource type %d\n", type); + printf(_("Unknown resource type %d\n"), type); error = 1; size = 1; break; @@ -605,16 +664,17 @@ void save_resource(int type, RES_ITEM *items, int pass) if (!res_head[rindex]) { res_head[rindex] = (RES *)res; /* store first entry */ } else { - RES *next; + RES *next, *last; /* Add new res to end of chain */ - for (next=res_head[rindex]; next->next; next=next->next) { + for (last=next=res_head[rindex]; next; next=next->next) { + last = next; if (strcmp(next->name, res->res_dir.hdr.name) == 0) { Emsg2(M_ERROR_TERM, 0, _("Attempt to define second \"%s\" resource named \"%s\" is not permitted.\n"), resources[rindex].name, res->res_dir.hdr.name); } } - next->next = (RES *)res; + last->next = (RES *)res; Dmsg2(90, "Inserting %s res: %s\n", res_to_str(type), res->res_dir.hdr.name); }