" -u <user> userid to <user>\n"
" -v verbose user messages\n"
" -? print this message.\n"
- "\n"), 2000, "", VERSION, BDATE);
+ "\n"), 2000, BDEMO, VERSION, BDATE);
exit(1);
}
char *uid = NULL;
char *gid = NULL;
+ device_default_open_mode = omd_write;
+
start_heap = sbrk(0);
setlocale(LC_ALL, "");
bindtextdomain("bacula", LOCALEDIR);
/* Sanity checks */
if (TAPE_BSIZE % B_DEV_BSIZE != 0 || TAPE_BSIZE / B_DEV_BSIZE == 0) {
- Jmsg2(NULL, M_ABORT, 0, _("Tape block size (%d) not multiple of system size (%d)\n"),
+ Emsg2(M_ABORT, 0, _("Tape block size (%d) not multiple of system size (%d)\n"),
TAPE_BSIZE, B_DEV_BSIZE);
}
if (TAPE_BSIZE != (1 << (ffs(TAPE_BSIZE)-1))) {
- Jmsg1(NULL, M_ABORT, 0, _("Tape block size (%d) is not a power of 2\n"), TAPE_BSIZE);
+ Emsg1(M_ABORT, 0, _("Tape block size (%d) is not a power of 2\n"), TAPE_BSIZE);
}
while ((ch = getopt(argc, argv, "c:d:fg:mpPstu:v?Ti")) != -1) {
Jmsg((JCR *)NULL, M_ERROR_TERM, 0, _("Please correct configuration file: %s\n"), configfile);
}
+ if (crypto_check_fips(me->require_fips) < 0) {
+ Jmsg((JCR *)NULL, M_ERROR_TERM, 0, _("Unable to set FIPS mode\n"));
+ }
+
init_reservations_lock();
if (test_config) {
create_volume_lists(); /* do before device_init */
if (pthread_create(&thid, NULL, device_initialization, NULL) != 0) {
berrno be;
- Jmsg1(NULL, M_ABORT, 0, _("Unable to create thread. ERR=%s\n"), be.bstrerror());
+ Emsg1(M_ABORT, 0, _("Unable to create thread. ERR=%s\n"), be.bstrerror());
}
start_watchdog(); /* start watchdog thread */
start_collector_threads(); /* start collector thread for every Collector resource */
+ /* Keep track of important events */
+ events_send_msg(NULL, "SD0001", EVENTS_TYPE_DAEMON, "*Daemon*",
+ (intptr_t)get_first_port_host_order(me->sdaddrs),
+ "Storage startup");
+
/* Single server used for Director and File daemon */
server_tid = pthread_self();
server_tid_valid = true;
/* tls_require implies tls_enable */
if (store->tls_require) {
if (have_tls) {
- store->tls_enable = true;
+ if (store->tls_certfile || store->tls_keyfile) {
+ store->tls_enable = true;
+ }
} else {
Jmsg(NULL, M_FATAL, 0, _("TLS required but not configured in Bacula.\n"));
OK = false;
}
/* If everything is well, attempt to initialize our per-resource TLS context */
- if (OK && (tls_needed || store->tls_require)) {
+ if (OK && tls_needed) {
/* Initialize TLS context:
* Args: CA certfile, CA certdir, Certfile, Keyfile,
* Keyfile PEM Callback, Keyfile CB Userdata, DHfile, Verify Peer */
OK = false;
}
}
+ store->psk_ctx = new_psk_context(NULL); /* shared key generated by DIR */
+ /* In this case, we have TLS Require=Yes and TLS not setup and no PSK */
+ if (OK && tls_needed == false && store->tls_require) {
+ if (!store->psk_ctx) {
+ Jmsg(NULL, M_FATAL, 0, _("Failed to initialize TLS PSK context for Storage \"%s\" in %s.\n"),
+ store->hdr.name, configfile);
+ OK = false;
+ }
+ }
}
foreach_res(director, R_DIRECTOR) {
/* tls_require implies tls_enable */
if (director->tls_require) {
- director->tls_enable = true;
+ if (director->tls_certfile || director->tls_keyfile) {
+ director->tls_enable = true;
+ }
}
tls_needed = director->tls_enable || director->tls_authenticate;
}
/* If everything is well, attempt to initialize our per-resource TLS context */
- if (OK && (tls_needed || director->tls_require)) {
+ if (OK && tls_needed) {
/* Initialize TLS context:
* Args: CA certfile, CA certdir, Certfile, Keyfile,
* Keyfile PEM Callback, Keyfile CB Userdata, DHfile, Verify Peer */
OK = false;
}
}
+ director->psk_ctx = new_psk_context(director->password);
+ /* In this case, we have TLS Require=Yes and TLS not setup and no PSK */
+ if (OK && (tls_needed == false && director->tls_require)) {
+ if (!director->psk_ctx) {
+ Jmsg(NULL, M_FATAL, 0, _("Failed to initialize TLS PSK context for Director \"%s\" in %s.\n"),
+ director->hdr.name, configfile);
+ OK = false;
+ }
+ }
}
foreach_res(changer, R_AUTOCHANGER) {
}
}
+ CLOUD *cloud;
+ /* TODO: Can use a table */
+ foreach_res(cloud, R_CLOUD) {
+ if (cloud->driver_type == C_S3_DRIVER ||
+ cloud->driver_type == C_FILE_DRIVER)
+ {
+ if (cloud->host_name == NULL) {
+ Jmsg(NULL, M_FATAL, 0,
+ _("Failed to initialize Cloud. Hostname not defined for Cloud \"%s\"\n"),
+ cloud->hdr.name);
+ OK = false;
+ }
+ }
+ if (cloud->driver_type == C_WAS_DRIVER ||
+ cloud->driver_type == C_S3_DRIVER)
+ {
+ if (cloud->access_key == NULL) {
+ Jmsg(NULL, M_FATAL, 0,
+ _("Failed to initialize Cloud. AccessKey not set for Cloud \"%s\"\n"),
+ cloud->hdr.name);
+ OK = false;
+ }
+ if (cloud->secret_key == NULL) {
+ Jmsg(NULL, M_FATAL, 0,
+ _("Failed to initialize Cloud. SecretKey not set for Cloud \"%s\"\n"),
+ cloud->hdr.name);
+ OK = false;
+ }
+ }
+ }
+
+#ifdef SD_DEDUP_SUPPORT
+ DEDUPRES *dedup;
+ foreach_res(dedup, R_DEDUP) {
+ if (dedup->driver_type == D_LEGACY_DRIVER)
+ {
+ if (dedup->dedup_dir == NULL) {
+ Jmsg(NULL, M_FATAL, 0,
+ _("Failed to initialize Dedup. DedupDirectory not defined for Dedup \"%s\"\n"),
+ dedup->hdr.name);
+ OK = false;
+ }
+ }
+ }
+#endif
+
if (OK) {
OK = init_autochangers();
}
}
/* Exclude any name with ., .., not my_name or containing a space */
if (strcmp(dname.c_str(), ".") == 0 || strcmp(dname.c_str(), "..") == 0 ||
- strncmp(dname.c_str(), my_name, my_name_len) != 0) {
+ strncmp(dname.c_str(), my_name, my_name_len) != 0) {
Dmsg1(500, "Skipped: %s\n", dname.c_str());
continue;
}
free_pool_memory(basename);
}
+void dbg_print_devices(FILE *fp)
+{
+ DEVRES *device;
+ foreach_res(device, R_DEVICE) {
+ if (device->dev) {
+ device->dev->dbg_print(fp);
+ }
+ }
+}
+
/*
* Here we attempt to init and open each device. This is done
* once at startup in a separate thread.
jcr->dcr = dcr = new_dcr(jcr, NULL, dev);
generate_plugin_event(jcr, bsdEventDeviceInit, dcr);
+ /* Keep track of important events */
+ events_send_msg(jcr, "SD0002", EVENTS_TYPE_DAEMON, "*Daemon*",
+ get_first_port_host_order(me->sdaddrs),
+ "Device initialization %s", device->hdr.name);
+
if (device->control_name && stat(device->control_name, &statp) < 0) {
berrno be;
Jmsg2(jcr, M_ERROR_TERM, 0, _("Unable to stat ControlDevice %s: ERR=%s\n"),
dev->print_name());
}
- if (device->min_block_size > device->max_block_size) {
- Jmsg1(jcr, M_ERROR_TERM, 0, _("MaximumBlockSize must be greater or equal than MinimumBlockSize for Device \"%s\"\n"),
- dev->print_name());
- }
-
#ifdef HAVE_WIN32
if (device->cap_bits & CAP_SYNCONCLOSE) {
- device->cap_bits &= ~CAP_SYNCONCLOSE; /* Clear bit not used on Windows */
+ device->cap_bits &= ~CAP_SYNCONCLOSE; /* Not available on windows */
}
#endif
/*
}
UnlockRes();
+#ifndef HAVE_WIN32
+ dbg_add_hook(dbg_print_devices);
+#endif
#ifdef xxx
if (jcr->dcr) {
{
static bool in_here = false;
DEVRES *device;
+ DEDUPRES *dedup;
JCR *jcr;
if (in_here) { /* prevent loops */
delete_pid_file(me->pid_directory,
"bacula-sd", get_first_port_host_order(me->sdaddrs));
}
+
+ /* Keep track of important events */
+ events_send_msg(NULL, "SD0003", EVENTS_TYPE_DAEMON, "*Daemon*",
+ get_first_port_host_order(me->sdaddrs),
+ "Storage shutdown");
}
Dmsg1(200, "In terminate_stored() sig=%d\n", sig);
Dmsg2(10, "No dev structure %s %s\n", device->hdr.name, device->device_name);
}
}
+
+ foreach_res(dedup, R_DEDUP) {
+ if (dedup->dedupengine) {
+ dedup->dedupengine = NULL; // Should have been closed by the last device
+ } else {
+ Dmsg1(10, "No dev Dedupengine structure %s\n", dedup->hdr.name);
+ }
+ }
+
if (server_tid_valid) {
server_tid_valid = false;
bnet_stop_thread_server(server_tid);