Skip to content

Commit

Permalink
Fix file name for exported resources
Browse files Browse the repository at this point in the history
An exported bareos-fd director resource needs to have the name of the
director, and not of the client, for which it is generated.

Also package the directory used for exporting client resources:
/etc/bareos/bareos-dir-export/client/
  • Loading branch information
joergsteffens committed Aug 22, 2016
1 parent ecca82d commit ef0e212
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions debian/bareos-director.dirs
Expand Up @@ -13,4 +13,5 @@
/etc/bareos/bareos-dir.d/schedule
/etc/bareos/bareos-dir.d/storage
/etc/bareos/bareos-dir-export/
/etc/bareos/bareos-dir-export/client
/usr/lib/bareos
2 changes: 1 addition & 1 deletion src/dird/Makefile.in
Expand Up @@ -170,7 +170,7 @@ install: all
fi; \
done; \
done
$(MKDIR) ${DESTDIR}${confdir}/bareos-dir-export/bareos-fd.d/director/
$(MKDIR) ${DESTDIR}${confdir}/bareos-dir-export/client/
@if test -f ${DESTDIR}${scriptdir}/query.sql; then \
echo " ==> Saving existing query.sql to query.sql.old"; \
$(MV) -f ${DESTDIR}${scriptdir}/query.sql ${DESTDIR}${scriptdir}/query.sql.old; \
Expand Down
19 changes: 15 additions & 4 deletions src/dird/ua_configure.c
Expand Up @@ -216,29 +216,40 @@ static inline bool configure_create_fd_resource_string(POOL_MEM &resource, const
return true;
}

/*
* Create a bareos-fd director resource file
* that corresponds to our client definition.
*/
static inline bool configure_create_fd_resource(UAContext *ua, const char *clientname)
{
POOL_MEM resource(PM_MESSAGE);
POOL_MEM filename_tmp(PM_FNAME);
POOL_MEM filename(PM_FNAME);
POOL_MEM basedir(PM_FNAME);
POOL_MEM temp(PM_MESSAGE);
const char *dirname = NULL;
const bool error_if_exists = false;
const bool create_directories = true;

if (!configure_create_fd_resource_string(resource, clientname)) {
return false;
}

/*
* Get the path where the resource should get stored.
*/
basedir.bsprintf("bareos-dir-export/client/%s/bareos-fd.d", clientname);
if (!my_config->get_path_of_new_resource(filename, temp, basedir.c_str(), "director", clientname,
error_if_exists, create_directories)) {
dirname = GetNextRes(R_DIRECTOR, NULL)->name;
if (!my_config->get_path_of_new_resource(filename, temp, basedir.c_str(), "director",
dirname, error_if_exists, create_directories)) {
ua->error_msg("%s", temp.c_str());
return false;
} else {
filename_tmp.strcpy(temp);
}
filename_tmp.strcpy(temp);

/*
* Write resource to file.
*/
if (!configure_write_resource(filename.c_str(), "filedaemon-export", clientname, resource.c_str())) {
ua->error_msg("failed to write filedaemon config resource file\n");
return false;
Expand Down

0 comments on commit ef0e212

Please sign in to comment.