Navigation Menu

Skip to content

Commit

Permalink
Implemented print of configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
pstorz authored and Marco van Wieringen committed Feb 17, 2015
1 parent 9fb8fc3 commit 961420f
Show file tree
Hide file tree
Showing 38 changed files with 2,265 additions and 1,196 deletions.
6 changes: 4 additions & 2 deletions src/console/console.c
Expand Up @@ -1309,11 +1309,13 @@ int main(int argc, char *argv[])
*/
if (cons) {
name = cons->hdr.name;
password = cons->password;
ASSERT(cons->password.encoding == p_encoding_md5);
password = cons->password.value;
tls_ctx = cons->tls_ctx;
} else {
name = "*UserAgent*";
password = dir->password;
ASSERT(dir->password.encoding == p_encoding_md5);
password = dir->password.value;
tls_ctx = dir->tls_ctx;
}

Expand Down
28 changes: 7 additions & 21 deletions src/console/console_conf.c
Expand Up @@ -82,7 +82,7 @@ static RES_ITEM cons_items[] = {
{ "rcfile", CFG_TYPE_DIR, ITEM(res_cons.rc_file), 0, 0, NULL },
{ "historyfile", CFG_TYPE_DIR, ITEM(res_cons.history_file), 0, 0, NULL },
{ "historylength", CFG_TYPE_PINT32, ITEM(res_cons.history_length), 0, CFG_ITEM_DEFAULT, "100" },
{ "password", CFG_TYPE_PASSWORD, ITEM(res_cons.password), 0, CFG_ITEM_REQUIRED, NULL },
{ "password", CFG_TYPE_MD5PASSWORD, ITEM(res_cons.password), 0, CFG_ITEM_REQUIRED, NULL },
{ "tlsauthenticate",CFG_TYPE_BOOL, ITEM(res_cons.tls_authenticate), 0, 0, NULL },
{ "tlsenable", CFG_TYPE_BOOL, ITEM(res_cons.tls_enable), 0, 0, NULL },
{ "tlsrequire", CFG_TYPE_BOOL, ITEM(res_cons.tls_require), 0, 0, NULL },
Expand All @@ -103,7 +103,7 @@ static RES_ITEM dir_items[] = {
{ "description", CFG_TYPE_STR, ITEM(res_dir.hdr.desc), 0, 0, NULL },
{ "dirport", CFG_TYPE_PINT32, ITEM(res_dir.DIRport), 0, CFG_ITEM_DEFAULT, DIR_DEFAULT_PORT },
{ "address", CFG_TYPE_STR, ITEM(res_dir.address), 0, 0, NULL },
{ "password", CFG_TYPE_PASSWORD, ITEM(res_dir.password), 0, CFG_ITEM_REQUIRED, NULL },
{ "password", CFG_TYPE_MD5PASSWORD, ITEM(res_dir.password), 0, CFG_ITEM_REQUIRED, NULL },
{ "tlsauthenticate",CFG_TYPE_BOOL, ITEM(res_dir.tls_enable), 0, 0, NULL },
{ "tlsenable", CFG_TYPE_BOOL, ITEM(res_dir.tls_enable), 0, 0, NULL },
{ "tlsrequire", CFG_TYPE_BOOL, ITEM(res_dir.tls_require), 0, 0, NULL },
Expand All @@ -122,8 +122,8 @@ static RES_ITEM dir_items[] = {
* It must have one item for each of the resources.
*/
RES_TABLE resources[] = {
{ "console", cons_items, R_CONSOLE },
{ "director", dir_items, R_DIRECTOR },
{ "console", cons_items, R_CONSOLE, sizeof(CONRES) },
{ "director", dir_items, R_DIRECTOR, sizeof(DIRRES) },
{ NULL, NULL, 0 }
};

Expand Down Expand Up @@ -250,7 +250,7 @@ void save_resource(int type, RES_ITEM *items, int pass)
{
URES *res;
int rindex = type - r_first;
int i, size;
int i;
int error = 0;

/*
Expand Down Expand Up @@ -296,24 +296,10 @@ void save_resource(int type, RES_ITEM *items, int pass)
return;
}

/* The following code is only executed during pass 1 */
switch (type) {
case R_CONSOLE:
size = sizeof(CONRES);
break;
case R_DIRECTOR:
size = sizeof(DIRRES);
break;
default:
printf(_("Unknown resource type %d\n"), type);
error = 1;
size = 1;
break;
}
/* Common */
if (!error) {
res = (URES *)malloc(size);
memcpy(res, &res_all, size);
res = (URES *)malloc(resources[rindex].size);
memcpy(res, &res_all, resources[rindex].size);
if (!res_head[rindex]) {
res_head[rindex] = (RES *)res; /* store first entry */
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/console/console_conf.h
Expand Up @@ -54,9 +54,9 @@ enum {
struct CONRES {
RES hdr;

char *password; /* UA server password */
char *rc_file; /* startup file */
char *history_file; /* command history file */
s_password password; /* UA server password */
uint32_t history_length; /* readline history length */
bool tls_authenticate; /* Authenticate with TLS */
bool tls_enable; /* Enable TLS on all connections */
Expand All @@ -79,7 +79,7 @@ struct DIRRES {

uint32_t DIRport; /* UA server port */
char *address; /* UA server address */
char *password; /* UA server password */
s_password password; /* UA server password */
bool tls_authenticate; /* Authenticate with TLS */
bool tls_enable; /* Enable TLS */
bool tls_require; /* Require TLS */
Expand Down
20 changes: 12 additions & 8 deletions src/dird/authenticate.c
Expand Up @@ -101,9 +101,10 @@ bool authenticate_storage_daemon(JCR *jcr, STORERES *store)
tls_local_need = BNET_TLS_REQUIRED;
}

auth_success = cram_md5_respond(sd, store->password, &tls_remote_need, &compatible);
ASSERT(store->password.encoding == p_encoding_md5);
auth_success = cram_md5_respond(sd, store->password.value, &tls_remote_need, &compatible);
if (auth_success) {
auth_success = cram_md5_challenge(sd, store->password, tls_local_need, compatible);
auth_success = cram_md5_challenge(sd, store->password.value, tls_local_need, compatible);
if (!auth_success) {
Dmsg1(dbglvl, "cram_challenge failed for %s\n", sd->who());
}
Expand Down Expand Up @@ -226,9 +227,10 @@ bool authenticate_file_daemon(JCR *jcr)
tls_local_need = BNET_TLS_REQUIRED;
}

auth_success = cram_md5_respond(fd, client->password, &tls_remote_need, &compatible);
ASSERT(client->password.encoding == p_encoding_md5);
auth_success = cram_md5_respond(fd, client->password.value, &tls_remote_need, &compatible);
if (auth_success) {
auth_success = cram_md5_challenge(fd, client->password, tls_local_need, compatible);
auth_success = cram_md5_challenge(fd, client->password.value, tls_local_need, compatible);
if (!auth_success) {
Dmsg1(dbglvl, "cram_auth failed for %s\n", fd->who());
}
Expand Down Expand Up @@ -361,8 +363,9 @@ bool authenticate_user_agent(UAContext *uac)
verify_list = me->tls_allowed_cns;
}

auth_success = cram_md5_challenge(ua, me->password, tls_local_need, compatible) &&
cram_md5_respond(ua, me->password, &tls_remote_need, &compatible);
ASSERT(me->password.encoding == p_encoding_md5);
auth_success = cram_md5_challenge(ua, me->password.value, tls_local_need, compatible) &&
cram_md5_respond(ua, me->password.value, &tls_remote_need, &compatible);
} else {
unbash_spaces(name);
cons = (CONRES *)GetResWithName(R_CONSOLE, name);
Expand All @@ -388,8 +391,9 @@ bool authenticate_user_agent(UAContext *uac)
verify_list = cons->tls_allowed_cns;
}

auth_success = cram_md5_challenge(ua, cons->password, tls_local_need, compatible) &&
cram_md5_respond(ua, cons->password, &tls_remote_need, &compatible);
ASSERT(cons->password.encoding == p_encoding_md5);
auth_success = cram_md5_challenge(ua, cons->password.value, tls_local_need, compatible) &&
cram_md5_respond(ua, cons->password.value, &tls_remote_need, &compatible);

if (auth_success) {
uac->cons = cons; /* save console resource pointer */
Expand Down
21 changes: 11 additions & 10 deletions src/dird/dbcheck.c
Expand Up @@ -60,9 +60,11 @@ static ID_LIST id_list;
static NAME_LIST name_list;
static char buf[20000];
static bool quit = false;
static CONFIG *config;
static const char *idx_tmp_name;

DIRRES *me = NULL; /* Our Global resource */
CONFIG *my_config = NULL; /* Our Global config */

#define MAX_ID_LIST_LEN 10000000

/*
Expand Down Expand Up @@ -185,8 +187,8 @@ int main (int argc, char *argv[])
if (argc > 0) {
Pmsg0(0, _("Warning skipping the additional parameters for working directory/dbname/user/password/host.\n"));
}
config = new_config_parser();
parse_dir_config(config, configfile, M_ERROR_TERM);
my_config = new_config_parser();
parse_dir_config(my_config, configfile, M_ERROR_TERM);
LockRes();
foreach_res(catalog, R_CATALOG) {
if (catalogname && bstrcmp(catalog->hdr.name, catalogname)) {
Expand All @@ -206,27 +208,26 @@ int main (int argc, char *argv[])
}
exit(1);
} else {
DIRRES *director;
LockRes();
director = (DIRRES *)GetNextRes(R_DIRECTOR, NULL);
me = (DIRRES *)GetNextRes(R_DIRECTOR, NULL);
UnlockRes();
if (!director) {
if (!me) {
Pmsg0(0, _("Error no Director resource defined.\n"));
exit(1);
}
set_working_directory(director->working_directory);
set_working_directory(me->working_directory);

/*
* Print catalog information and exit (-B)
*/
if (print_catalog) {
print_catalog_details(catalog, director->working_directory);
print_catalog_details(catalog, me->working_directory);
exit(0);
}

db_name = catalog->db_name;
user = catalog->db_user;
password = catalog->db_password;
password = catalog->db_password.value;
dbhost = catalog->db_address;
db_driver = catalog->db_driver;
if (dbhost && dbhost[0] == 0) {
Expand Down Expand Up @@ -349,7 +350,7 @@ static void print_catalog_details(CATRES *catalog, const char *working_dir)
catalog->db_driver,
catalog->db_name,
catalog->db_user,
catalog->db_password,
catalog->db_password.value,
catalog->db_address,
catalog->db_port,
catalog->db_socket,
Expand Down
19 changes: 14 additions & 5 deletions src/dird/dird.c
Expand Up @@ -621,7 +621,12 @@ static bool check_resources()
}
}

if (me->optimize_for_size && me->optimize_for_speed) {
/*
* When the user didn't force use we optimize for size.
*/
if (!me->optimize_for_size && !me->optimize_for_speed) {
me->optimize_for_size = true;
} else if (me->optimize_for_size && me->optimize_for_speed) {
Jmsg(NULL, M_FATAL, 0, _("Cannot optimize for speed and size define only one in %s\n"), configfile);
OK = false;
}
Expand Down Expand Up @@ -1071,9 +1076,13 @@ static bool initialize_sql_pooling(void)
CATRES *catalog;

foreach_res(catalog, R_CATALOG) {
if (!db_sql_pool_initialize(catalog->db_driver, catalog->db_name, catalog->db_user,
catalog->db_password, catalog->db_address,
catalog->db_port, catalog->db_socket,
if (!db_sql_pool_initialize(catalog->db_driver,
catalog->db_name,
catalog->db_user,
catalog->db_password.value,
catalog->db_address,
catalog->db_port,
catalog->db_socket,
catalog->disable_batch_insert,
catalog->pooling_min_connections,
catalog->pooling_max_connections,
Expand Down Expand Up @@ -1112,7 +1121,7 @@ static bool check_catalog(cat_op mode)
catalog->db_driver,
catalog->db_name,
catalog->db_user,
catalog->db_password,
catalog->db_password.value,
catalog->db_address,
catalog->db_port,
catalog->db_socket,
Expand Down

0 comments on commit 961420f

Please sign in to comment.