-/*
- *
- * Bacula Director -- migrate.c -- responsible for doing
- * migration jobs.
- *
- * Kern Sibbald, September MMIV
- *
- * Basic tasks done here:
- * Open DB and create records for this job.
- * Open Message Channel with Storage daemon to tell him a job will be starting.
- * Open connection with Storage daemon and pass him commands
- * to do the backup.
- * When the Storage daemon finishes the job, update the DB.
- *
- * Version $Id$
- */
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2004-2006 Free Software Foundation Europe e.V.
+ Copyright (C) 2004-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.
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
+/*
+ *
+ * Bacula Director -- migrate.c -- responsible for doing
+ * migration jobs.
+ *
+ * Kern Sibbald, September MMIV
+ *
+ * Basic tasks done here:
+ * Open DB and create records for this job.
+ * Open Message Channel with Storage daemon to tell him a job will be starting.
+ * Open connection with Storage daemon and pass him commands
+ * to do the backup.
+ * When the Storage daemon finishes the job, update the DB.
+ *
+ * Version $Id$
+ */
#include "bacula.h"
#include "dird.h"
*/
static int get_job_to_migrate(JCR *jcr)
{
- char ed1[30];
+ char ed1[30], ed2[30];
POOL_MEM query(PM_MESSAGE);
JobId_t JobId;
DBId_t MediaId = 0;
ctx.count = 0;
/* Find count of bytes from Jobs */
Mmsg(query, sql_job_bytes, mid.list);
+ Dmsg1(dbglevel, "Jobbytes query: %s\n", query.c_str());
if (!db_sql_query(jcr->db, query.c_str(), db_int64_handler, (void *)&ctx)) {
Jmsg(jcr, M_FATAL, 0, _("SQL failed. ERR=%s\n"), db_strerror(jcr->db));
goto bail_out;
}
pool_bytes -= ctx.value;
- Dmsg1(dbglevel, "Job bytes=%d\n", (int)ctx.value);
- Dmsg2(dbglevel, "lowbytes=%d pool=%d\n", (int)jcr->rpool->MigrationLowBytes,
- (int)pool_bytes);
+ Dmsg1(dbglevel, "Total migrate Job bytes=%s\n", edit_int64(ctx.value, ed1));
+ Dmsg2(dbglevel, "lowbytes=%s poolafter=%s\n",
+ edit_int64(jcr->rpool->MigrationLowBytes, ed1),
+ edit_int64(pool_bytes, ed2));
if (pool_bytes <= (int64_t)jcr->rpool->MigrationLowBytes) {
Dmsg0(dbglevel, "We should be done.\n");
break;
}
}
- Dmsg2(dbglevel, "Pool Occupancy ids=%d JobIds=%s\n", jids.count, jids.list);
-
+ /* Transfer jids to ids, where the jobs list is expected */
+ ids.count = jids.count;
+ pm_strcpy(ids.list, jids.list);
+ Dmsg2(dbglevel, "Pool Occupancy ids=%d JobIds=%s\n", ids.count, ids.list);
break;
case MT_POOL_TIME:
do_a_command(ua, ua->cmd);
}
if (!ua->quit) {
- if (acl_access_ok(ua, Command_ACL, "messages", 8)) {
+ if (console_msg_pending && acl_access_ok(ua, Command_ACL, "messages", 8)) {
if (ua->auto_display_messages) {
pm_strcpy(ua->cmd, "messages");
qmessagescmd(ua, ua->cmd);
ua->user_notified_msg_pending = false;
} else if (!ua->gui && !ua->user_notified_msg_pending && console_msg_pending) {
- bsendmsg(ua, _("You have messages.\n"));
+ if (ua->api) {
+ user->signal(BNET_MESSAGES_PENDING);
+ } else {
+ bsendmsg(ua, _("You have messages.\n"));
+ }
ua->user_notified_msg_pending = true;
}
}
*/
static int save_file(FF_PKT *ff_pkt, void *vjcr, bool top_level)
{
- int stat, data_stream;
+ int stat, data_stream;
+ int rtnstat = 0;
DIGEST *digest = NULL;
DIGEST *signing_digest = NULL;
int digest_stream = STREAM_NONE;
+ SIGNATURE *sig = NULL;
+ uint8_t *buf = NULL;
bool has_file_data = false;
// TODO landonf: Allow the user to specify the digest algorithm
#ifdef HAVE_SHA2
Jmsg(jcr, M_NOTSAVED, 0, _("%s signature digest initialization failed\n"),
stream_to_ascii(signing_algorithm));
jcr->Errors++;
- return 1;
+ goto good_rtn;
}
}
if (!set_prog(&ff_pkt->bfd, ff_pkt->reader, jcr)) {
Jmsg(jcr, M_FATAL, 0, _("Python reader program \"%s\" not found.\n"),
ff_pkt->reader);
- return 0;
+ goto bail_out;
}
}
/* Send attributes -- must be done after binit() */
if (!encode_and_send_attributes(jcr, ff_pkt, data_stream)) {
- return 0;
+ goto bail_out;
}
/*
stop_thread_timer(tid);
tid = NULL;
}
- return 1;
+ goto good_rtn;
}
if (tid) {
stop_thread_timer(tid);
stat = send_data(jcr, data_stream, ff_pkt, digest, signing_digest);
bclose(&ff_pkt->bfd);
if (!stat) {
- return 0;
+ goto bail_out;
}
}
if (is_bopen(&ff_pkt->bfd)) {
bclose(&ff_pkt->bfd);
}
- return 1;
+ goto good_rtn;
}
flags = ff_pkt->flags;
ff_pkt->flags &= ~(FO_GZIP|FO_SPARSE);
ff_pkt->flags = flags;
bclose(&ff_pkt->bfd);
if (!stat) {
- return 0;
+ goto bail_out;
}
}
if (ff_pkt->flags & FO_ACL) {
/* Read access ACLs for files, dirs and links */
if (!read_and_send_acl(jcr, BACL_TYPE_ACCESS, STREAM_UNIX_ATTRIBUTES_ACCESS_ACL)) {
- return 0;
+ goto bail_out;
}
/* Directories can have default ACLs too */
if (ff_pkt->type == FT_DIREND && (BACL_CAP & BACL_CAP_DEFAULTS_DIR)) {
if (!read_and_send_acl(jcr, BACL_TYPE_DEFAULT, STREAM_UNIX_ATTRIBUTES_DEFAULT_ACL)) {
- return 0;
+ goto bail_out;
}
}
}
/* Terminate the signing digest and send it to the Storage daemon */
if (signing_digest) {
- SIGNATURE *sig;
uint32_t size = 0;
- uint8_t *buf;
if ((sig = crypto_sign_new()) == NULL) {
Jmsg(jcr, M_FATAL, 0, _("Failed to allocate memory for stream signature.\n"));
- return 0;
+ goto bail_out;
}
if (crypto_sign_add_signer(sig, signing_digest, jcr->pki_keypair) == false) {
Jmsg(jcr, M_FATAL, 0, _("An error occurred while signing the stream.\n"));
- return 0;
+ goto bail_out;
}
/* Get signature size */
if (crypto_sign_encode(sig, NULL, &size) == false) {
Jmsg(jcr, M_FATAL, 0, _("An error occurred while signing the stream.\n"));
- return 0;
+ goto bail_out;
}
/* Allocate signature data buffer */
buf = (uint8_t *)malloc(size);
if (!buf) {
- crypto_sign_free(sig);
- return 0;
+ goto bail_out;
}
/* Encode signature data */
if (crypto_sign_encode(sig, buf, &size) == false) {
Jmsg(jcr, M_FATAL, 0, _("An error occurred while signing the stream.\n"));
- return 0;
+ goto bail_out;
}
/* Send our header */
sd->msglen = size;
bnet_send(sd);
bnet_sig(sd, BNET_EOD); /* end of checksum */
-
- crypto_digest_free(signing_digest);
- crypto_sign_free(sig);
- free(buf);
+ goto good_rtn;
}
/* Terminate any digest and send it to Storage daemon and the Director */
bnet_send(sd);
bnet_sig(sd, BNET_EOD); /* end of checksum */
}
+ }
+
+good_rtn:
+ rtnstat = 1; /* good return */
+bail_out:
+ if (digest) {
crypto_digest_free(digest);
}
-
- return 1;
+ if (signing_digest) {
+ crypto_digest_free(signing_digest);
+ }
+ if (sig) {
+ crypto_sign_free(sig);
+ }
+ if (buf) {
+ free(buf);
+ }
+ return rtnstat;
}
/*
if (digest_file(jcr, ff_pkt, digest) != 0) {
jcr->Errors++;
- return 1;
+ goto good_rtn;
}
if (crypto_digest_finalize(digest, (uint8_t *)md, &size)) {
free(digest_buf);
}
-
- crypto_digest_free(digest);
}
}
+good_rtn:
+ if (digest) {
+ crypto_digest_free(digest);
+ }
return 1;
}
BNET_INVALID_CMD = -13, /* Invalid command sent */
BNET_CMD_FAILED = -14, /* Command failed */
BNET_CMD_OK = -15, /* Command succeeded */
- BNET_CMD_BEGIN = -16 /* Start command execution */
+ BNET_CMD_BEGIN = -16, /* Start command execution */
+ BNET_MESSAGES_PENDING = 17, /* Messages pending */
+ BNET_SERVER_READY = 18 /* Server ready and waiting */
};
#define BNET_SETBUF_READ 1 /* Arg for bnet_set_buffer_size */
#############################################################################
# Makefile for building: bat
-# Generated by qmake (2.01a) (Qt 4.2.1) on: Mon Mar 5 09:37:46 2007
+# Generated by qmake (2.01a) (Qt 4.2.1) on: Mon Mar 5 17:45:21 2007
# Project: bat.pro
# Template: app
# Command: /usr/bin/qmake -unix -o Makefile bat.pro
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
+ Copyright (C) 2007-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.
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
-
/*
* Version $Id$
*
* Console Class
*
- * Kern Sibbald, January MMVI
+ * Kern Sibbald, January MMVII
*
*/
treeWidget->expandItem(topItem);
readSettings();
+ /* Check for messages every 5 seconds */
+// m_timer = new QTimer(this);
+// QWidget::connect(m_timer, SIGNAL(timeout()), this, SLOT(poll_messages()));
+// m_timer->start(5000);
}
+void Console::poll_messages()
+{
+ m_messages_pending = true;
+}
+
/* Terminate any open socket */
void Console::terminate()
{
m_sock->close();
m_sock = NULL;
}
+ m_timer->stop();
}
/*
void Console::status_dir()
{
write_dir("status dir\n");
+ displayToPrompt();
}
/*
break;
}
app->processEvents();
+// if (m_api_set && m_messages_pending) {
+// write_dir(".messages");
+// m_messages_pending = false;
+// }
}
stat = m_sock->recv();
if (stat >= 0) {
}
switch (m_sock->msglen) {
+ case BNET_SERVER_READY:
+// if (m_api_set && m_messages_pending) {
+// write_dir(".messages");
+// m_messages_pending = false;
+// }
+ m_at_prompt = true;
+ continue;
+ case BNET_MESSAGES_PENDING:
+ m_messages_pending = true;
+ continue;
case BNET_CMD_BEGIN:
m_at_prompt = false;
continue;
(void)fd;
if (commDebug) Pmsg0(000, "read_dir\n");
- stat = read();
- if (stat >= 0) {
+ while ((stat = read()) >= 0) {
display_text(msg());
}
}
#ifndef _CONSOLE_H_
#define _CONSOLE_H_
-
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
+ Copyright (C) 2007-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.
QStringList type_list;
QStringList level_list;
+
public slots:
void connect(void);
void read_dir(int fd);
int write(QString msg);
void status_dir(void);
void set_font(void);
+ void poll_messages(void);
private:
QTextEdit *m_textEdit;
QTextCursor *m_cursor;
QTreeWidgetItem *m_consoleItem;
bool m_api_set;
+ bool m_messages_pending;
+ QTimer *m_timer;
};
#endif /* _CONSOLE_H_ */
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
+ Copyright (C) 2007-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.
/*
* Label Dialog class
*
- * Kern Sibbald, February MMVI
+ * Kern Sibbald, February MMVII
*
*/
labelDialog::labelDialog(Console *console)
{
+ m_console = console;
setupUi(this);
storageCombo->addItems(console->storage_list);
poolCombo->addItems(console->pool_list);
scmd = QString("label volume=\"%1\" pool=\"%2\" storage=\"%3\" slot=%4\n")
.arg(volumeName->text()).arg(storageCombo->currentText())
.arg(poolCombo->currentText()).arg(slotSpin->value());
- printf(scmd.toUtf8().data());
+ m_console->write_dir(scmd.toUtf8().data());
+ m_console->displayToPrompt();
delete this;
+ mainWin->resetFocus();
}
void labelDialog::reject()
printf("Rejected\n");
this->hide();
delete this;
+ mainWin->resetFocus();
}
+/*
+ Bacula® - The Network Backup Solution
+
+ Copyright (C) 2007-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 plus additions
+ that are listed 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.
+*/
+/*
+ * Kern Sibbald, February MMVII
+ */
#ifndef _LABEL_H_
#define _LABEL_H_
public:
labelDialog(Console *console);
-public slots:
+private slots:
void accept();
void reject();
private:
-
+ Console *m_console;
};
#endif /* _LABEL_H_ */
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
+ Copyright (C) 2007-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.
/*
* Run Dialog class
*
- * Kern Sibbald, February MMVI
+ * Kern Sibbald, February MMVII
*
* $Id$
*/
#include "bat.h"
#include "run.h"
+/*
+ * Setup all the combo boxes and display the dialog
+ */
runDialog::runDialog(Console *console)
{
QDateTime dt;
storageCombo->currentText().toUtf8().data(),
prioritySpin->value());
-// m_console->write(cmd);
+ m_console->write_dir(cmd);
m_console->display_text(cmd);
+ m_console->displayToPrompt();
delete this;
+ mainWin->resetFocus();
}
mainWin->set_status(" Canceled");
this->hide();
delete this;
+ mainWin->resetFocus();
}
+/*
+ * Called here when the jobname combo box is changed.
+ * We load the default values for the new job in the
+ * other combo boxes.
+ */
void runDialog::job_name_change(int index)
{
job_defaults job_defs;
General:
05Mar07
+kes More bat implementation.
+kes File migrate bug with Pool Occupancy using mediaid instead
+ of jobids. Fixes bug #795.
+kes Fix orphaned buffers in filed backup and verify due to
+ crypto buffers not freed during errors. Fixes bug #789.
kes Extend new GUI api code to tree commands.
kes Ensure that tree and dot commands check console ACLs.
kes Permit marking directory with trailing slash.