X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fstored%2Fstored_conf.c;h=2f00de4b58abb062e57084692f38b2da2241caad;hb=eeeb98532770101aa2b310ac43c9379316c447ce;hp=90979fb3eaa266eff4c9cffb13660851e96b8cd3;hpb=06f295c818e9b9506a2617877a78e331196ba92b;p=bacula%2Fbacula diff --git a/bacula/src/stored/stored_conf.c b/bacula/src/stored/stored_conf.c index 90979fb3ea..2f00de4b58 100644 --- a/bacula/src/stored/stored_conf.c +++ b/bacula/src/stored/stored_conf.c @@ -5,24 +5,18 @@ * * 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 as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. + modify it under the terms of the GNU General Public License + version 2 as amended 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 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., 59 Temple Place - Suite 330, Boston, - MA 02111-1307, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + the file LICENSE for additional details. */ @@ -57,14 +51,23 @@ 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}, - {"requiressl", store_yesno,ITEM(res_store.require_ssl), 1, ITEM_DEFAULT, 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}, {"heartbeatinterval", store_time, ITEM(res_store.heartbeat_interval), 0, ITEM_DEFAULT, 0}, + {"tlsenable", store_yesno, ITEM(res_store.tls_enable), 1, 0, 0}, + {"tlsrequire", store_yesno, ITEM(res_store.tls_require), 1, 0, 0}, + {"tlsverifypeer", store_yesno, 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}, {NULL, NULL, 0, 0, 0, 0} }; @@ -74,8 +77,16 @@ 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}, - {"enablessl", store_yesno, ITEM(res_dir.enable_ssl), 1, ITEM_DEFAULT, 0}, {"monitor", store_yesno, ITEM(res_dir.monitor), 1, ITEM_DEFAULT, 0}, + {"tlsenable", store_yesno, ITEM(res_dir.tls_enable), 1, 0, 0}, + {"tlsrequire", store_yesno, ITEM(res_dir.tls_require), 1, 0, 0}, + {"tlsverifypeer", store_yesno, 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}, {NULL, NULL, 0, 0, 0, 0} }; @@ -104,6 +115,9 @@ static RES_ITEM dev_items[] = { {"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}, + {"requiresmount", store_yesno, ITEM(res_dev.cap_bits), CAP_REQMOUNT, ITEM_DEFAULT, 0}, + {"offlineonunmount", store_yesno, ITEM(res_dev.cap_bits), CAP_OFFLINEUNMOUNT, ITEM_DEFAULT, 0}, + {"autoselect", store_yesno, 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}, @@ -112,7 +126,6 @@ static RES_ITEM dev_items[] = { {"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}, {"minimumblocksize", store_pint, ITEM(res_dev.min_block_size), 0, 0, 0}, {"maximumblocksize", store_pint, ITEM(res_dev.max_block_size), 0, 0, 0}, @@ -124,7 +137,6 @@ 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}, @@ -139,8 +151,8 @@ static RES_ITEM changer_items[] = { {"name", store_name, ITEM(res_changer.hdr.name), 0, ITEM_REQUIRED, 0}, {"description", store_str, ITEM(res_changer.hdr.desc), 0, 0, 0}, {"device", store_alist_res, ITEM(res_changer.device), R_DEVICE, ITEM_REQUIRED, 0}, - {"changerdevice", store_strname, ITEM(res_changer.changer_name), 0, 0, 0}, - {"changercommand", store_strname, ITEM(res_changer.changer_command), 0, 0, 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} }; @@ -169,14 +181,14 @@ RES_TABLE resources[] = { 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; @@ -187,36 +199,43 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm break; case R_STORAGE: sendit(sock, "Storage: name=%s SDaddr=%s SDport=%d SDDport=%d HB=%s\n", - res->res_store.hdr.name, - NPRT(get_first_address(res->res_store.sdaddrs, buf, sizeof(buf))), - get_first_port_host_order(res->res_store.sdaddrs), - get_first_port_host_order(res->res_store.sddaddrs), - edit_utime(res->res_store.heartbeat_interval, buf, sizeof(buf))); - foreach_dlist(p, res->res_store.sdaddrs) { - sendit(sock, " SDaddr=%s SDport=%d\n", - p->get_address(buf, sizeof(buf)), p->get_port_host_order()); - } - foreach_dlist(p, res->res_store.sddaddrs) { - sendit(sock, " SDDaddr=%s SDDport=%d\n", - p->get_address(buf, sizeof(buf)), p->get_port_host_order()); - } + res->res_store.hdr.name, + NPRT(get_first_address(res->res_store.sdaddrs, buf, sizeof(buf))), + get_first_port_host_order(res->res_store.sdaddrs), + get_first_port_host_order(res->res_store.sddaddrs), + edit_utime(res->res_store.heartbeat_interval, buf, sizeof(buf))); + if (res->res_store.sdaddrs) { + foreach_dlist(p, res->res_store.sdaddrs) { + sendit(sock, " SDaddr=%s SDport=%d\n", + p->get_address(buf, sizeof(buf)), p->get_port_host_order()); + } + } + if (res->res_store.sddaddrs) { + foreach_dlist(p, res->res_store.sddaddrs) { + sendit(sock, " SDDaddr=%s SDDport=%d\n", + p->get_address(buf, sizeof(buf)), p->get_port_host_order()); + } + } break; case R_DEVICE: sendit(sock, "Device: name=%s MediaType=%s Device=%s LabelType=%d\n", 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=%d min_bs=%d max_bs=%d chgr_wait=%d\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); + } bstrncpy(buf, " ", sizeof(buf)); if (res->res_dev.cap_bits & CAP_EOF) { bstrncat(buf, "CAP_EOF ", sizeof(buf)); @@ -257,12 +276,18 @@ 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; case R_AUTOCHANGER: DEVRES *dev; - sendit(sock, "Changer: name=%s Changer_devname=%s Changer_cmd=%s\n", + sendit(sock, "Changer: name=%s Changer_devname=%s\n Changer_cmd=%s\n", res->res_changer.hdr.name, res->res_changer.changer_name, res->res_changer.changer_command); foreach_alist(dev, res->res_changer.device) { @@ -319,6 +344,27 @@ void free_resource(RES *sres, int type) if (res->res_dir.address) { free(res->res_dir.address); } + if (res->res_dir.tls_ctx) { + free_tls_context(res->res_dir.tls_ctx); + } + if (res->res_dir.tls_ca_certfile) { + free(res->res_dir.tls_ca_certfile); + } + if (res->res_dir.tls_ca_certdir) { + free(res->res_dir.tls_ca_certdir); + } + if (res->res_dir.tls_certfile) { + free(res->res_dir.tls_certfile); + } + if (res->res_dir.tls_keyfile) { + free(res->res_dir.tls_keyfile); + } + if (res->res_dir.tls_dhfile) { + free(res->res_dir.tls_dhfile); + } + if (res->res_dir.tls_allowed_cns) { + delete res->res_dir.tls_allowed_cns; + } break; case R_AUTOCHANGER: if (res->res_changer.changer_name) { @@ -327,6 +373,10 @@ void free_resource(RES *sres, int type) if (res->res_changer.changer_command) { free(res->res_changer.changer_command); } + if (res->res_changer.device) { + delete res->res_changer.device; + } + break; case R_STORAGE: if (res->res_store.sdaddrs) { free_addresses(res->res_store.sdaddrs); @@ -343,6 +393,30 @@ void free_resource(RES *sres, int type) if (res->res_store.subsys_directory) { free(res->res_store.subsys_directory); } + if (res->res_store.scripts_directory) { + free(res->res_store.scripts_directory); + } + if (res->res_store.tls_ctx) { + free_tls_context(res->res_store.tls_ctx); + } + if (res->res_store.tls_ca_certfile) { + free(res->res_store.tls_ca_certfile); + } + if (res->res_store.tls_ca_certdir) { + free(res->res_store.tls_ca_certdir); + } + if (res->res_store.tls_certfile) { + free(res->res_store.tls_certfile); + } + if (res->res_store.tls_keyfile) { + free(res->res_store.tls_keyfile); + } + if (res->res_store.tls_dhfile) { + free(res->res_store.tls_dhfile); + } + if (res->res_store.tls_allowed_cns) { + delete res->res_store.tls_allowed_cns; + } break; case R_DEVICE: if (res->res_dev.media_type) { @@ -390,7 +464,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 */ @@ -435,30 +509,50 @@ void save_resource(int type, RES_ITEM *items, int pass) * record. */ if (pass == 2) { + DEVRES *dev; + int errstat; switch (type) { /* Resources not containing a resource */ - case R_DIRECTOR: case R_DEVICE: case R_MSGS: break; /* 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); + } + res->res_dir.tls_allowed_cns = res_all.res_dir.tls_allowed_cns; + 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; + res->res_store.tls_allowed_cns = res_all.res_store.tls_allowed_cns; 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 */ res->res_changer.device = res_all.res_changer.device; + /* + * Now update each device in this resource to point back + * to the changer resource. + */ + foreach_alist(dev, res->res_changer.device) { + dev->changer_res = (AUTOCHANGER *)&res->res_changer; + } + 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)); + } break; default: - printf("Unknown resource type %d\n", type); + printf(_("Unknown resource type %d\n"), type); error = 1; break; } @@ -493,7 +587,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;