Skip to content

Commit

Permalink
Merge branch 'bareos-15.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco van Wieringen committed Dec 31, 2015
2 parents 6865c90 + 406b4ca commit 0ed68c1
Show file tree
Hide file tree
Showing 17 changed files with 273 additions and 168 deletions.
3 changes: 3 additions & 0 deletions src/dird/dird.c
Expand Up @@ -1041,6 +1041,9 @@ static bool check_resources()
if (me->secure_erase_cmdline) {
set_secure_erase_cmdline(me->secure_erase_cmdline);
}
if (me->log_date_format) {
set_log_date_format(me->log_date_format);
}
}

bail_out:
Expand Down
4 changes: 4 additions & 0 deletions src/dird/dird_conf.c
Expand Up @@ -148,6 +148,7 @@ static RES_ITEM dir_items[] = {
{ "AuditEvents", CFG_TYPE_AUDIT, ITEM(res_dir.audit_events), 0, 0, NULL, "14.2.0-", NULL },
{ "SecureEraseCommand", CFG_TYPE_STR, ITEM(res_dir.secure_erase_cmdline), 0, 0, NULL, "15.2.1-",
"Specify command that will be called when bareos unlinks files." },
{ "LogDateFormat", CFG_TYPE_STR, ITEM(res_dir.log_date_format), 0, 0, NULL, NULL, NULL },
{ NULL, 0, { 0 }, 0, 0, NULL, NULL, NULL }
};

Expand Down Expand Up @@ -2393,6 +2394,9 @@ void free_resource(RES *sres, int type)
if (res->res_dir.secure_erase_cmdline) {
free(res->res_dir.secure_erase_cmdline);
}
if (res->res_dir.log_date_format) {
free(res->res_dir.log_date_format);
}
break;
case R_DEVICE:
case R_COUNTER:
Expand Down
1 change: 1 addition & 0 deletions src/dird/dird_conf.h
Expand Up @@ -146,6 +146,7 @@ class DIRRES: public BRSRES {
uint32_t stats_collect_interval; /* Statistics collect interval in seconds */
char *verid; /* Custom Id to print in version command */
char *secure_erase_cmdline; /* Cmdline to execute to perform secure erase of file */
char *log_date_format; /* Date format to use in generic logging messages */
s_password keyencrkey; /* Key Encryption Key */
};

Expand Down
3 changes: 3 additions & 0 deletions src/filed/filed.c
Expand Up @@ -603,6 +603,9 @@ static bool check_resources()
if (me->secure_erase_cmdline) {
set_secure_erase_cmdline(me->secure_erase_cmdline);
}
if (me->log_date_format) {
set_log_date_format(me->log_date_format);
}
}

return OK;
Expand Down
4 changes: 4 additions & 0 deletions src/filed/filed_conf.c
Expand Up @@ -123,6 +123,7 @@ static RES_ITEM cli_items[] = {
{ "LmdbThreshold", CFG_TYPE_PINT32, ITEM(res_client.lmdb_threshold), 0, 0, NULL, NULL, NULL },
{ "SecureEraseCommand", CFG_TYPE_STR, ITEM(res_client.secure_erase_cmdline), 0, 0, NULL, "15.2.1-",
"Specify command that will be called when bareos unlinks files." },
{ "LogDateFormat", CFG_TYPE_STR, ITEM(res_client.log_date_format), 0, 0, NULL, NULL, NULL },
{ NULL, 0, { 0 }, 0, 0, NULL, NULL, NULL }
};

Expand Down Expand Up @@ -365,6 +366,9 @@ void free_resource(RES *sres, int type)
if (res->res_client.secure_erase_cmdline) {
free(res->res_client.secure_erase_cmdline);
}
if (res->res_client.log_date_format) {
free(res->res_client.log_date_format);
}
break;
case R_MSGS:
if (res->res_msgs.mail_cmd) {
Expand Down
3 changes: 2 additions & 1 deletion src/filed/filed_conf.h
Expand Up @@ -116,7 +116,8 @@ class CLIENTRES : public BRSRES {
alist *allowed_job_cmds; /* Only allow the following Job commands to be executed */
TLS_CONTEXT *tls_ctx; /* Shared TLS Context */
char *verid; /* Custom Id to print in version command */
char *secure_erase_cmdline; /* Cmdline to execute to perform secure erase of file */
char *secure_erase_cmdline; /* Cmdline to execute to perform secure erase of file */
char *log_date_format; /* Date format to use in generic logging messages */
uint64_t max_bandwidth_per_job; /* Bandwidth limitation (global) */
};

Expand Down
2 changes: 0 additions & 2 deletions src/include/jcr.h
Expand Up @@ -443,8 +443,6 @@ class JCR {
uint32_t FileIndex; /* Last FileIndex processed */
utime_t MaxRunSchedTime; /* Max run time in seconds from Initial Scheduled time */
POOLMEM *fname; /* Name to put into catalog */
POOLMEM *component_fname; /* Component info file name */
FILE *component_fd; /* Component info file desc */
JOB_DBR jr; /* Job DB record for current job */
JOB_DBR previous_jr; /* Previous job database record */
JCR *mig_jcr; /* JCR for migration/copy job */
Expand Down
5 changes: 5 additions & 0 deletions src/lib/compression.c
Expand Up @@ -833,6 +833,11 @@ void cleanup_compression(JCR *jcr)

}
#else
const char *cmprs_algo_to_text(uint32_t compression_algorithm)
{
return "Unknown";
}

bool setup_compression_buffers(JCR *jcr,
bool compatible,
uint32_t compression_algorithm,
Expand Down
32 changes: 21 additions & 11 deletions src/lib/message.c
Expand Up @@ -74,8 +74,9 @@ void setup_tsd_key();
* Allow only one thread to tweak d->fd at a time
*/
static pthread_mutex_t fides_mutex = PTHREAD_MUTEX_INITIALIZER;
static MSGSRES *daemon_msgs; /* global messages */
static char *catalog_db = NULL; /* database type */
static MSGSRES *daemon_msgs; /* Global messages */
static char *catalog_db = NULL; /* Database type */
static const char *log_date_format = "%d-%b %H:%M";
static void (*message_callback)(int type, char *msg) = NULL;
static FILE *trace_fd = NULL;
#if defined(HAVE_WIN32)
Expand Down Expand Up @@ -148,10 +149,9 @@ static void delivery_error(const char *fmt,...)

pool_buf = get_pool_memory(PM_EMSG);

bstrftime_ny(dt, sizeof(dt), time(NULL));
bstrftime(dt, sizeof(dt), time(NULL), log_date_format);
bstrncat(dt, " ", sizeof(dt));
dtlen = strlen(dt);
dt[dtlen++] = ' ';
dt[dtlen] = 0;

i = Mmsg(pool_buf, "%s Message delivery ERROR: ", dt);

Expand Down Expand Up @@ -363,7 +363,7 @@ void init_console_msg(const char *wd)
if (fd == -1) {
berrno be;
Emsg2(M_ERROR_TERM, 0, _("Could not open console message file %s: ERR=%s\n"),
con_fname, be.bstrerror());
con_fname, be.bstrerror());
}
if (lseek(fd, 0, SEEK_END) > 0) {
console_msg_pending = 1;
Expand All @@ -373,12 +373,12 @@ void init_console_msg(const char *wd)
if (!con_fd) {
berrno be;
Emsg2(M_ERROR, 0, _("Could not open console message file %s: ERR=%s\n"),
con_fname, be.bstrerror());
con_fname, be.bstrerror());
}
if (rwl_init(&con_lock) != 0) {
berrno be;
Emsg1(M_ERROR_TERM, 0, _("Could not get con mutex: ERR=%s\n"),
be.bstrerror());
be.bstrerror());
}
}

Expand Down Expand Up @@ -844,6 +844,7 @@ void dispatch_message(JCR *jcr, int type, utime_t mtime, char *msg)
MSGSRES *msgs;
BPIPE *bpipe;
const char *mode;
bool dt_set = false;

Dmsg2(850, "Enter dispatch_message type=%d msg=%s", type, msg);

Expand All @@ -856,15 +857,16 @@ void dispatch_message(JCR *jcr, int type, utime_t mtime, char *msg)
if (mtime == 0) {
mtime = time(NULL);
}

if (mtime == 1) {
*dt = 0;
dtlen = 0;
mtime = time(NULL); /* get time for SQL log */
} else {
bstrftime_ny(dt, sizeof(dt), mtime);
bstrftime(dt, sizeof(dt), mtime, log_date_format);
bstrncat(dt, " ", sizeof(dt));
dtlen = strlen(dt);
dt[dtlen++] = ' ';
dt[dtlen] = 0;
dt_set = true;
}

/*
Expand Down Expand Up @@ -1869,3 +1871,11 @@ void q_msg(const char *file, int line, JCR *jcr, int type, utime_t mtime, const

Qmsg(jcr, type, mtime, "%s", buf.c_str());
}

/*
* Set gobal date format used for log messages.
*/
void set_log_date_format(const char *format)
{
log_date_format = format;
}
1 change: 1 addition & 0 deletions src/lib/message.h
Expand Up @@ -165,6 +165,7 @@ void Jmsg(JCR *jcr, int type, utime_t mtime, const char *fmt,...);
void Qmsg(JCR *jcr, int type, utime_t mtime, const char *fmt,...);
bool get_trace(void);
const char *get_basename(const char *pathname);
void set_log_date_format(const char *format);

typedef bool (*db_log_insert_func)(JCR *jcr, utime_t mtime, char *msg);
extern DLL_IMP_EXP db_log_insert_func p_db_log_insert;
Expand Down
10 changes: 4 additions & 6 deletions src/lib/passphrase.c
Expand Up @@ -45,13 +45,12 @@
* in the length argument. The returned argument should be
* freed by the caller.
*/
char *generate_crypto_passphrase(int length)
char *generate_crypto_passphrase(uint16_t length)
{
#ifdef HAVE_GNUTLS
int error;
#endif
int c;
int vc_len, cnt;
uint16_t vc_len, cnt, c;
char *passphrase;
unsigned char *rand_bytes;
char valid_chars[] = "abcdefghijklmnopqrstuvwxyz"
Expand Down Expand Up @@ -115,10 +114,9 @@ char *generate_crypto_passphrase(int length)
* in the length argument. The returned argument should be
* freed by the caller.
*/
char *generate_crypto_passphrase(int length)
char *generate_crypto_passphrase(uint16_t length)
{
char c;
int vc_len, cnt;
uint16_t vc_len, cnt, c;
int *rand_bytes;
char *passphrase;
char valid_chars[] = "abcdefghijklmnopqrstuvwxyz"
Expand Down
2 changes: 1 addition & 1 deletion src/lib/protos.h
Expand Up @@ -285,7 +285,7 @@ void set_db_type(const char *name);
void register_message_callback(void msg_callback(int type, char *msg));

/* passphrase.c */
char *generate_crypto_passphrase(int length);
char *generate_crypto_passphrase(uint16_t length);

/* path_list.c */
htable *path_list_init();
Expand Down

0 comments on commit 0ed68c1

Please sign in to comment.