#define Pmsg12(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) p_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
#define Pmsg13(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13) p_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13)
#define Pmsg14(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14) p_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14)
+#define Pmsg15(lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15) p_msg(__FILE__,__LINE__,lvl,msg,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15)
/** Daemon Error Messages that are delivered according to the message resource */
uint32_t MaxVolJobs; /* Max Jobs on Volume */
uint32_t MaxVolFiles; /* Max files on Volume */
int32_t Recycle; /* recycle yes/no */
- int32_t Protected; /* Protected yes/no */
+ int32_t Protected; /* Protected yes/no */
int32_t UseProtect; /* Use Protected feature yes/no */
+ int32_t VolEncrypted; /* Volume is encrypted */
int32_t Slot; /* slot in changer */
int32_t Enabled; /* 0=disabled, 1=enabled, 2=archived */
int32_t InChanger; /* Volume currently in changer */
Comment BLOB,
Protected TINYINT DEFAULT 0,
UseProtect TINYINT DEFAULT 0,
+ VolEncrypted TINYINT DEFAULT 0,
PRIMARY KEY(MediaId),
UNIQUE (VolumeName(128)),
INDEX (PoolId),
comment text,
protected smallint default 0,
useprotect smallint default 0,
+ volencrypted smallint default 0,
primary key (mediaid)
);
Comment TEXT,
Protected TINYINT DEFAULT 0,
UseProtect TINYINT DEFAULT 0,
+ VolEncrypted TINYINT DEFAULT 0,
PRIMARY KEY(MediaId)
);
"VolStatus,Slot,VolBytes,InChanger,VolReadTime,VolWriteTime,VolType,"
"VolParts,VolCloudParts,LastPartBytes,"
"EndFile,EndBlock,LabelType,StorageId,DeviceId,LocationId,"
-"ScratchPoolId,RecyclePoolId,Enabled,ActionOnPurge,CacheRetention,UseProtect,Protected)"
+"ScratchPoolId,RecyclePoolId,Enabled,ActionOnPurge,CacheRetention,UseProtect,"
+"Protected,VolEncrypted)"
"VALUES ('%s','%s',0,%lu,%s,%s,%ld,%s,%s,%lu,%lu,'%s',%ld,%s,%ld,%s,%s,%ld,"
- "%ld,%ld,'%s',%ld,%ld,%ld,%s,%s,%s,%s,%s,%ld,%ld,%s,%ld,%ld)",
+ "%ld,%ld,'%s',%ld,%ld,%ld,%s,%s,%s,%s,%s,%ld,%ld,%s,%ld,%ld,%ld)",
esc_name,
esc_mtype, mr->PoolId,
edit_uint64(mr->MaxVolBytes,ed1),
edit_int64(mr->LocationId, ed11),
edit_int64(mr->ScratchPoolId, ed12),
edit_int64(mr->RecyclePoolId, ed13),
- mr->Enabled,
+ mr->Enabled,
mr->ActionOnPurge,
edit_uint64(mr->CacheRetention, ed14),
mr->UseProtect,
- mr->Protected
+ mr->Protected,
+ mr->VolEncrypted
);
"LabelType,LabelDate,StorageId,"
"Enabled,LocationId,RecycleCount,InitialWrite,"
"ScratchPoolId,RecyclePoolId,VolReadTime,VolWriteTime,ActionOnPurge,CacheRetention "
+ "VolEncrypted "
"FROM Media WHERE PoolId=%s AND MediaType='%s' "
" AND (VolStatus IN ('Full', 'Append', 'Used') OR (VolStatus IN ('Recycle', 'Purged', 'Used') AND Recycle=1)) "
" AND Enabled=1 "
+ " AND VolEncrypted=%d "
"ORDER BY LastWritten LIMIT 1",
- edit_int64(mr->PoolId, ed1), esc_type);
+ edit_int64(mr->PoolId, ed1), esc_type, mr->VolEncrypted);
item = 1;
} else {
POOL_MEM changer(PM_FNAME);
"EndFile,EndBlock,VolType,VolParts,VolCloudParts,LastPartBytes,"
"LabelType,LabelDate,StorageId,"
"Enabled,LocationId,RecycleCount,InitialWrite,"
- "ScratchPoolId,RecyclePoolId,VolReadTime,VolWriteTime,ActionOnPurge,CacheRetention "
+ "ScratchPoolId,RecyclePoolId,VolReadTime,VolWriteTime,ActionOnPurge,CacheRetention,"
+ "VolEncrypted "
"FROM Media WHERE PoolId=%s AND MediaType='%s' AND Enabled=1 "
"AND VolStatus='%s' "
+ "AND VolEncrypted=%d "
"%s "
"%s "
"%s "
"%s LIMIT %d",
edit_int64(mr->PoolId, ed1), esc_type,
- esc_status,
+ esc_status, mr->VolEncrypted,
voltype.c_str(),
changer.c_str(), exclude.c_str(), order, item);
}
mr->VolWriteTime = str_to_int64(row[39]);
mr->ActionOnPurge = str_to_int64(row[40]);
mr->CacheRetention = str_to_int64(row[41]);
+ mr->VolEncrypted = str_to_int64(row[42]);
sql_free_result();
"EndFile,EndBlock,VolType,VolParts,VolCloudParts,LastPartBytes,"
"LabelType,LabelDate,StorageId,"
"Enabled,LocationId,RecycleCount,InitialWrite,"
- "ScratchPoolId,RecyclePoolId,VolReadTime,VolWriteTime,ActionOnPurge,CacheRetention,Pool.Name,Protected,UseProtect "
- "FROM Media JOIN Pool USING (PoolId) WHERE MediaId=%s",
+ "ScratchPoolId,RecyclePoolId,VolReadTime,VolWriteTime,ActionOnPurge,"
+ "CacheRetention,Pool.Name,Protected,UseProtect,VolEncrypted "
+ "FROM Media WHERE MediaId=%s",
edit_int64(mr->MediaId, ed1));
} else { /* find by name */
bdb_escape_string(jcr, esc, mr->VolumeName, strlen(mr->VolumeName));
"EndFile,EndBlock,VolType,VolParts,VolCloudParts,LastPartBytes,"
"LabelType,LabelDate,StorageId,"
"Enabled,LocationId,RecycleCount,InitialWrite,"
- "ScratchPoolId,RecyclePoolId,VolReadTime,VolWriteTime,ActionOnPurge,CacheRetention,Pool.Name,Protected,UseProtect "
- "FROM Media JOIN Pool USING (PoolId) WHERE VolumeName='%s'", esc);
+ "ScratchPoolId,RecyclePoolId,VolReadTime,VolWriteTime,ActionOnPurge,"
+ "CacheRetention,Pool.Name,Protected,UseProtect,VolEncrypted "
+ "FROM Media WHERE VolumeName='%s'", esc);
}
if (QueryDB(jcr, cmd)) {
mr->ActionOnPurge = str_to_int32(row[43]);
mr->CacheRetention = str_to_int64(row[44]);
bstrncpy(mr->Pool, row[45], sizeof(mr->Pool));
- mr->Protected = str_to_int64(row[45]);
- mr->UseProtect = str_to_int64(row[46]);
+ mr->Protected = str_to_int64(row[46]);
+ mr->UseProtect = str_to_int64(row[47]);
+ mr->VolEncrypted = str_to_int64(row[48]);
ok = true;
}
"EndFile,EndBlock,VolType,Media.LabelType,StorageId,DeviceId,"
"MediaAddressing,VolReadTime,VolWriteTime,"
"LocationId,RecycleCount,InitialWrite,Media.ScratchPoolId,Media.RecyclePoolId, "
- "Media.ActionOnPurge,%s AS ExpiresIn, Comment, Protected, UseProtect"
+ "Media.ActionOnPurge,%s AS ExpiresIn, Comment, Protected, UseProtect, VolEncrypted"
" FROM Media %s WHERE Media.VolumeName='%s' %s",
expiresin,
join,
"EndFile,EndBlock,VolType,Media.LabelType,StorageId,DeviceId,"
"MediaAddressing,VolReadTime,VolWriteTime,"
"LocationId,RecycleCount,InitialWrite,Media.ScratchPoolId,Media.RecyclePoolId, "
- "Media.ActionOnPurge,%s AS ExpiresIn, Comment, Protected, UseProtect"
+ "Media.ActionOnPurge,%s AS ExpiresIn, Comment, Protected, UseProtect, VolEncrypted"
" FROM Media %s WHERE Media.PoolId=%s %s ORDER BY MediaId",
expiresin,
join,
"LabelType=%d,StorageId=%s,PoolId=%s,VolRetention=%s,VolUseDuration=%s,"
"MaxVolJobs=%d,MaxVolFiles=%d,Enabled=%d,LocationId=%s,"
"ScratchPoolId=%s,RecyclePoolId=%s,RecycleCount=%d,Recycle=%d,"
- "ActionOnPurge=%d,CacheRetention=%s,EndBlock=%u,Protected=%d,UseProtect=%d"
+ "ActionOnPurge=%d,CacheRetention=%s,EndBlock=%u,Protected=%d,"
+ "UseProtect=%d,VolEncrypted=%d"
" WHERE VolumeName='%s'",
mr->VolJobs, mr->VolFiles, mr->VolBlocks,
edit_uint64(mr->VolBytes, ed1),
edit_uint64(mr->RecyclePoolId, ed15),
mr->RecycleCount,mr->Recycle, mr->ActionOnPurge,
edit_uint64(mr->CacheRetention, ed16),
- mr->EndBlock,mr->Protected,mr->UseProtect,
+ mr->EndBlock, mr->Protected, mr->UseProtect, mr->VolEncrypted,
esc_name);
Dmsg1(dbglevel1, "%s\n", cmd);
ALTER TABLE Media
MODIFY COLUMN Protected TINYINT DEFAULT 0,
- MODIFY COLUMN UseProtect TINYINT DEFAULT 0;
+ MODIFY COLUMN UseProtect TINYINT DEFAULT 0,
+ MODIFY COLUMN VolEncrypted TINYINT DEFAULT 0;
ALTER TABLE Object
ADD COLUMN FileIndex integer not null default 0,
ALTER TABLE Job ADD COLUMN StatusInfo text default '';
ATLER TABLE Job ADD COLUMN Encrypted int default 0;
-ALTER TABLE Media ADD COLUMN Protected smallint default 0;
-ALTER TABLE Media ADD COLUMN IsProtect smallint default 0;
+ALTER TABLE Media ADD COLUMN Protected smallint default 0;
+ALTER TABLE Media ADD COLUMN UseProtect smallint default 0;
+ALTER TABLE Media ADD COLUMN VolEncrypted smallint default 0;
INSERT INTO Events (EventsCode, EventsType, EventsTime, EventsDaemon, EventsSource, EventsRef, EventsText) VALUES
('DU0001', 'catalog_update', NOW(), '*SHELL*', 'update_bacula_tables', 'pid$$', 'Catalog schema was updated to 1026');
*/
/* Requests from the Storage daemon */
-static char Find_media[] = "CatReq JobId=%ld FindMedia=%d pool_name=%127s media_type=%127s vol_type=%d create=%d use_protect=%d\n";
+static char Find_media[] = "CatReq JobId=%ld FindMedia=%d pool_name=%127s media_type=%127s vol_type=%d create=%d use_protect=%d vol_encrypted=%d\n";
static char Get_Vol_Info[] = "CatReq JobId=%ld GetVolInfo VolName=%127s write=%d\n";
static char Update_media[] = "CatReq JobId=%ld UpdateMedia VolName=%s"
" VolErrors=%u VolWrites=%lld MaxVolBytes=%lld EndTime=%lld VolStatus=%10s"
" Slot=%d relabel=%d InChanger=%d VolReadTime=%llu VolWriteTime=%llu"
" VolFirstWritten=%lld VolType=%u VolParts=%d VolCloudParts=%d"
- " LastPartBytes=%lld Enabled=%d Recycle=%d Protected=%d UseProtect=%d\n";
+ " LastPartBytes=%lld Enabled=%d Recycle=%d Protected=%d UseProtect=%d VolEncrypted=%d\n";
static char FileEvent_add[] = "%c %d %127s %127s 0";
/* Full format when coming from the Verify Job */
" MaxVolJobs=%u MaxVolFiles=%u InChanger=%d VolReadTime=%s"
" VolWriteTime=%s EndFile=%u EndBlock=%u VolType=%u LabelType=%d"
" MediaId=%s ScratchPoolId=%s VolParts=%d VolCloudParts=%d"
- " LastPartBytes=%lld Enabled=%d MaxPoolBytes=%s PoolBytes=%s Recycle=%d Protected=%d UseProtect=%d\n";
+ " LastPartBytes=%lld Enabled=%d MaxPoolBytes=%s PoolBytes=%s Recycle=%d"
+ " Protected=%d UseProtect=%d VolEncrypted=%d\n";
static char OK_create[] = "1000 OK CreateJobMedia\n";
mr->Enabled,
edit_uint64(pr.MaxPoolBytes, ed11),
edit_uint64(pr.PoolBytes, ed12),
- mr->Recycle, mr->Protected, mr->UseProtect);
+ mr->Recycle, mr->Protected, mr->UseProtect, mr->VolEncrypted);
unbash_spaces(mr->VolumeName);
Dmsg2(100, "Vol Info for %s: %s", jcr->Job, sd->msg);
return stat;
utime_t VolFirstWritten;
utime_t VolLastWritten;
int n;
- int can_create=0, use_protect=0;
- int Enabled, Recycle, Protected, UseProtect;
+ int can_create=0, use_protect=0, vol_encrypted;
+ int Enabled, Recycle, Protected, UseProtect, VolEncrypted;
JobId_t JobId = 0;
STORE *wstore = jcr->store_mngr->get_wstore();
/*
* Find next appendable medium for SD
*/
- n = sscanf(bs->msg, Find_media, &JobId, &index, &pool_name, &mr.MediaType, &mr.VolType, &can_create, &use_protect);
- if (n == 7) {
+ n = sscanf(bs->msg, Find_media, &JobId, &index, &pool_name, &mr.MediaType,
+ &mr.VolType, &can_create, &use_protect, &vol_encrypted);
+ if (n == 8) {
POOL_MEM errmsg;
POOL_DBR pr;
bstrncpy(pr.Name, pool_name, sizeof(pr.Name));
mr.ScratchPoolId = pr.ScratchPoolId;
ok = find_next_volume_for_append(jcr, &mr, index,
can_create?fnv_create_vol : fnv_no_create_vol,
- fnv_prune, use_protect, errmsg);
+ fnv_prune, use_protect, vol_encrypted, errmsg);
Dmsg3(050, "find_media ok=%d idx=%d vol=%s\n", ok, index, mr.VolumeName);
} else {
/* Report problem finding pool */
&VolLastWritten, &sdmr.VolStatus, &sdmr.Slot, &label, &sdmr.InChanger,
&sdmr.VolReadTime, &sdmr.VolWriteTime, &VolFirstWritten,
&sdmr.VolType, &sdmr.VolParts, &sdmr.VolCloudParts,
- &sdmr.LastPartBytes, &Enabled, &Recycle, &Protected, &UseProtect);
- if (n == 29) {
+ &sdmr.LastPartBytes, &Enabled, &Recycle, &Protected, &UseProtect, &VolEncrypted);
+ if (n == 30) {
db_lock(jcr->db);
Dmsg3(400, "Update media %s oldStat=%s newStat=%s\n", sdmr.VolumeName,
mr.VolStatus, sdmr.VolStatus);
mr.VolParts = sdmr.VolParts;
mr.VolCloudParts = sdmr.VolCloudParts;
mr.LastPartBytes = sdmr.LastPartBytes;
- mr.Enabled = Enabled; /* byte assignment */
- mr.Recycle = Recycle; /* byte assignment */
- mr.Protected = Protected; /* byte assignment */
- mr.UseProtect = UseProtect; /* byte assignment */
+ mr.Enabled = Enabled; /* byte assignment */
+ mr.Recycle = Recycle; /* byte assignment */
+ mr.Protected = Protected; /* byte assignment */
+ mr.UseProtect = UseProtect; /* byte assignment */
+ mr.VolEncrypted = VolEncrypted; /* byte assignment */
bstrncpy(mr.VolStatus, sdmr.VolStatus, sizeof(mr.VolStatus));
mr.VolReadTime = sdmr.VolReadTime;
mr.VolWriteTime = sdmr.VolWriteTime;
* use_protect -- whether or not the device will mark the volume as protected (0 no, -1 don't know, 1 yes)
*/
int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, int index,
- bool create, bool prune, int use_protect, POOL_MEM &errmsg)
+ bool create, bool prune, int use_protect,
+ int vol_encrypted, POOL_MEM &errmsg)
{
int retry = 0;
bool ok;
STORE *store = jcr->store_mngr->get_wstore();
bstrncpy(mr->MediaType, store->media_type, sizeof(mr->MediaType));
- Dmsg7(dbglvl, "find_next_vol_for_append: JobId=%u PoolId=%d, MediaType=%s index=%d create=%d prune=%d protect=%d\n",
+ Dmsg8(dbglvl, "find_next_vol_for_append: JobId=%u PoolId=%d, MediaType=%s index=%d create=%d prune=%d protect=%d vol_encrypted=%d\n",
(uint32_t)jcr->JobId, (int)mr->PoolId, mr->MediaType, index,
- create, prune, use_protect);
+ create, prune, use_protect, vol_encrypted);
/*
* If we are using an Autochanger, restrict Volume
* search to the Autochanger on the first pass
/* Make sure we don't send two times the same volume in the same session */
set_volume_to_exclude_list(jcr, index, mr);
+ if (vol_encrypted == 1) {
+ mr->VolEncrypted = 1;
+ } else {
+ mr->VolEncrypted = 0;
+ }
+
/*
* Find the Next Volume for Append
*/
bool has_quota_reached(JCR *jcr);
void set_storageid_in_mr(STORE *store, MEDIA_DBR *mr);
int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, int index,
- bool create, bool purge, int use_worm, POOL_MEM &errmsg);
+ bool create, bool purge, int use_protect,
+ int vol_encrypted, POOL_MEM &errmsg);
bool has_volume_expired(JCR *jcr, MEDIA_DBR *mr);
void check_if_volume_valid_or_recyclable(JCR *jcr, MEDIA_DBR *mr, const char **reason);
bool get_scratch_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr,
uint64_t VolABytes = 0;
uint32_t VolType = 0;
int UseProtect = 0;
+ int VolEncrypted = 0;
STORE *wstore = ua->jcr->store_mngr->get_wstore();
if (!(sd=open_sd_bsock(ua))) {
while (bget_dirmsg(ua->jcr, sd, BSOCK_TYPE_SD) >= 0) {
ua->send_msg("%s", sd->msg);
- if (sscanf(sd->msg, "3000 OK label. VolBytes=%llu VolABytes=%lld VolType=%ld UseProtect=%d",
- &VolBytes, &VolABytes, &VolType, &UseProtect) == 4) {
+ if (sscanf(sd->msg, "3000 OK label. VolBytes=%llu VolABytes=%lld VolType=%ld UseProtect=%d VolEncrypted=%d",
+ &VolBytes, &VolABytes, &VolType, &UseProtect, &VolEncrypted) == 5) {
ok = true;
if (media_record_exists) { /* we update it */
mr->VolBytes = VolBytes;
mr->VolType = VolType;
mr->InChanger = mr->Slot > 0; /* if slot give assume in changer */
mr->UseProtect = UseProtect;
+ mr->VolEncrypted = VolEncrypted;
set_storageid_in_mr(wstore, mr);
if (!db_update_media_record(ua->jcr, ua->db, mr)) {
ua->error_msg("%s", db_strerror(ua->db));
mr->InChanger = mr->Slot > 0; /* if slot give assume in changer */
mr->Enabled = 1;
mr->UseProtect = UseProtect;
+ mr->VolEncrypted = VolEncrypted;
set_storageid_in_mr(wstore, mr);
if (db_create_media_record(ua->jcr, ua->db, mr)) {
ua->info_msg(_("Catalog record for Volume \"%s\", Slot %d successfully created.\n"),
get_job_storage(&store, job, run);
set_storageid_in_mr(store.store, &mr);
/* no need to set ScratchPoolId, since we use fnv_no_create_vol */
- if (!find_next_volume_for_append(jcr, &mr, 1, fnv_no_create_vol, fnv_prune, -1 /* no worm */, errmsg)) {
+ if (!find_next_volume_for_append(jcr, &mr, 1, fnv_no_create_vol, fnv_prune,
+ -1 /* no protect */, -1 /* vol_encrypted*/, errmsg)) {
ua->error_msg(_("Could not find next Volume for Job %s (Pool=%s, Level=%s).%s\n"),
job->name(), pr.Name, level_to_str(edl, sizeof(edl), run->level), errmsg.c_str());
} else {
} else {
Dmsg0(250, "call find_next_volume_for_append\n");
/* no need to set ScratchPoolId, since we use fnv_no_create_vol */
- ok = find_next_volume_for_append(jcr, &mr, 1, fnv_no_create_vol, fnv_no_prune, -1, tmp);
+ ok = find_next_volume_for_append(jcr, &mr, 1, fnv_no_create_vol, fnv_no_prune, -1, -1, tmp);
}
}
if (!ok) {
static const int dbglvl = 200;
/* Requests sent to the Director */
-static char Find_media[] = "CatReq JobId=%ld FindMedia=%d pool_name=%s media_type=%s vol_type=%d create=%d use_protect=%d\n";
+static char Find_media[] = "CatReq JobId=%ld FindMedia=%d pool_name=%s media_type=%s vol_type=%d create=%d use_protect=%d vol_encrypted=%d\n";
static char Get_Vol_Info[] = "CatReq JobId=%ld GetVolInfo VolName=%s write=%d\n";
static char Update_media[] = "CatReq JobId=%ld UpdateMedia VolName=%s"
" VolJobs=%u VolFiles=%u VolBlocks=%u VolBytes=%s VolABytes=%s"
" VolErrors=%u VolWrites=%u MaxVolBytes=%s EndTime=%s VolStatus=%s"
" Slot=%d relabel=%d InChanger=%d VolReadTime=%s VolWriteTime=%s"
" VolFirstWritten=%s VolType=%u VolParts=%d VolCloudParts=%d"
- " LastPartBytes=%lld Enabled=%d Recycle=%d Protected=%d UseProtect=%d\n";
+ " LastPartBytes=%lld Enabled=%d Recycle=%d Protected=%d UseProtect=%d VolEncrypted=%d\n";
static char Create_jobmedia[] = "CatReq JobId=%ld CreateJobMedia\n";
static char FileAttributes[] = "UpdCat JobId=%ld FileAttributes ";
" VolReadTime=%lld VolWriteTime=%lld EndFile=%lu EndBlock=%lu"
" VolType=%lu LabelType=%ld MediaId=%lld ScratchPoolId=%lld"
" VolParts=%d VolCloudParts=%d LastPartBytes=%lld Enabled=%d MaxPoolBytes=%lld PoolBytes=%lld Recycle=%d"
- " Protected=%d UseProtect=%d\n";
+ " Protected=%d UseProtect=%d VolEncrypted=%d\n";
static char OK_create[] = "1000 OK CreateJobMedia\n";
BSOCK *dir = jcr->dir_bsock;
VOLUME_CAT_INFO vol;
int n;
- int32_t Enabled, Recycle, Protected, UseProtect;
+ int32_t Enabled, Recycle, Protected, UseProtect, VolEncrypted;
int32_t InChanger;
dcr->setVolCatInfo(false);
&vol.EndFile, &vol.EndBlock, &vol.VolCatType,
&vol.LabelType, &vol.VolMediaId, &vol.VolScratchPoolId,
&vol.VolCatParts, &vol.VolCatCloudParts,
- &vol.VolLastPartBytes, &Enabled, &vol.MaxPoolBytes, &vol.PoolBytes, &Recycle, &Protected, &UseProtect);
+ &vol.VolLastPartBytes, &Enabled, &vol.MaxPoolBytes,
+ &vol.PoolBytes, &Recycle, &Protected, &UseProtect, &VolEncrypted);
Dmsg2(dbglvl, "<dird n=%d %s", n, dir->msg);
- if (n != 35) {
+ if (n != 36) {
Dmsg1(dbglvl, "get_volume_info failed: ERR=%s", dir->msg);
/*
* Note, we can get an error here either because there is
vol.VolRecycle = Recycle; /* bool in structure */
vol.Protected = Protected; /* bool in structure */
vol.UseProtect = UseProtect; /* bool in structure */
+ vol.VolEncrypted = VolEncrypted; /* bool in structure */
vol.is_valid = true;
vol.VolCatBytes = vol.VolCatAmetaBytes + vol.VolCatAdataBytes;
unbash_spaces(vol.VolCatName);
bash_spaces(dcr->media_type);
bash_spaces(dcr->pool_name);
dir->fsend(Find_media, jcr->JobId, vol_index, dcr->pool_name, dcr->media_type,
- dcr->dev->dev_type, can_create, dcr->dev->use_protect());
+ dcr->dev->dev_type, can_create, dcr->dev->use_protect(),
+ dcr->dev->use_volume_encryption());
unbash_spaces(dcr->media_type);
unbash_spaces(dcr->pool_name);
Dmsg1(dbglvl, ">dird %s", dir->msg);
Enabled,
Recycle,
vol.Protected,
- dev->use_protect()
+ dev->use_protect(),
+ vol.VolEncrypted
);
Dmsg1(100, ">dird %s", dir->msg);
/*
return false;
}
+int DEVICE::use_volume_encryption()
+{
+ return device->volume_encryption != ET_NONE;
+};
+
bool DEVICE::load_encryption_key(DCR *dcr, const char *operation,
const char *volume_name,
uint32_t *enc_cipher_key_size, unsigned char *enc_cipher_key,
{
enum { op_none, op_label, op_read };
bool ok = true; // No error
- if (!device->volume_encryption) {
+ Dmsg4(0, "load_encryption_key %s %s enc=%ld ver=%d\n", operation, volume_name, device->volume_encryption, VolHdr.BlockVer);
+ int op = op_none;
+ if (0 == strcmp(operation, "LABEL")) {
+ op = op_label;
+ } else if (0 == strcmp(operation, "READ")) {
+ op = op_read;
+ }
+ /* don't use encryption if volume encryption is not enable or we are reading
+ * (aka not recycling) a BB02 volume */
+ if (device->volume_encryption == ET_NONE || (op != op_label && VolHdr.BlockVer <= 2)) {
return ok;
}
JCR *jcr = dcr->jcr;
-// char *edit_device_codes(DCR *dcr, char *omsg, const char *imsg, const char *cmd)
POOLMEM *encrypt_program = get_pool_memory(PM_FNAME);
POOL_MEM results(PM_MESSAGE);
POOL_MEM err_msg(PM_MESSAGE);
POOL_MEM envv;
- int op = op_none;
- if (0 == strcmp(operation, "LABEL")) {
- op = op_label;
- } else if (0 == strcmp(operation, "READ")) {
- op = op_read;
- }
-
edit_device_codes(dcr, &encrypt_program, me->encryption_command, "load");
char *envp[5];
Mmsg(envv, "OPERATION=%s", operation);
bool InChanger; /* Set if vol in current magazine */
bool Protected; /* Set if the vol is Readonly, worm or immutable */
bool UseProtect; /* Set if the device can set the volume Readonly, worm or immutable */
+ bool VolEncrypted; /* Set if the volume is encrypted */
bool is_valid; /* set if this data is valid */
bool VolEnabled; /* set if volume enabled */
bool VolRecycle; /* set if volume can be recycled */
virtual int set_readonly(int fd, const char *vol_name) { errno=ENOSYS; return -1;};
virtual int set_atime(int fd, const char *vol_name, btime_t val) { errno=ENOSYS; return -1;};
virtual int use_protect() { return 0; };
+ virtual int use_volume_encryption();
virtual const char *print_type() = 0; /* in dev.c */
virtual const char *print_driver_type() { return "";};
virtual const char *print_full_type() { return print_type();};
} else {
type = 0;
}
- dir->fsend("3000 OK label. VolBytes=%lld VolABytes=%lld VolType=%d UseProtect=%d Volume=\"%s\" Device=%s\n",
+ dir->fsend("3000 OK label. VolBytes=%lld VolABytes=%lld VolType=%d UseProtect=%d VolEncrypted=%d Volume=\"%s\" Device=%s\n",
volCatBytes, dev->VolCatInfo.VolCatAdataBytes,
- type, dev->use_protect(), newname, dev->print_name());
+ type, dev->use_protect(), dev->use_volume_encryption(),
+ newname, dev->print_name());
break;
case VOL_TYPE_ERROR:
dir->fsend(_("3917 Failed to label Volume: ERR=%s\n"), dcr->jcr->errmsg);
VolCatInfo.VolLastPartBytes = 0;
VolCatInfo.VolCatType = 0; /* Will be set by dir_update_volume_info() */
VolCatInfo.UseProtect = use_protect();
+ VolCatInfo.VolEncrypted = use_volume_encryption();
if (recycle) {
VolCatInfo.VolCatMounts++;
VolCatInfo.VolCatRecycles++;
Enter(130);
ASSERT2(dev != NULL, "dev ptr is NULL");
-
+ dev->VolHdr.BlockVer = BLOCK_VER;
if (dev->is_aligned()) {
bstrncpy(dev->VolHdr.Id, BaculaMetaDataId, sizeof(dev->VolHdr.Id));
dev->VolHdr.VerNum = BaculaMetaDataVersion;
dev->VolHdr.LabelType = rec->FileIndex;
dev->VolHdr.LabelSize = rec->data_len;
-
+ dev->VolHdr.BlockVer = rec->BlockVer;
/* Unserialize the record into the Volume Header */
Dmsg2(100, "reclen=%d recdata=%s", rec->data_len, rec->data);
break;
}
- Pmsg14(-1, _("\nVolume Label:\n"
+ Pmsg15(-1, _("\nVolume Label:\n"
"Adata : %d\n"
"Id : %s"
"VerNo : %d\n"
"MediaType : %s\n"
"PoolType : %s\n"
"HostName : %s\n"
+"BlockVer : BB%02%d\n"
"EncCypherKeySize : %ld\n"
"MasterKeyIdSize : %ld\n"
""),
File, LabelType, VolHdr.LabelSize,
VolHdr.PoolName, VolHdr.MediaType,
VolHdr.PoolType, VolHdr.HostName,
- VolHdr.EncCypherKeySize, VolHdr.MasterKeyIdSize);
+ VolHdr.BlockVer, VolHdr.EncCypherKeySize, VolHdr.MasterKeyIdSize);
if (VolHdr.VerNum >= 11) {
char dt[50];
char Id[32]; /* Bacula Immortal ... */
uint32_t VerNum; /* Label version number */
-
+ int BlockVer; /* 1, 2 or .. from BB01, BB02 from the FIRST block */
/* VerNum <= 10 */
float64_t label_date; /* Date tape labeled */
float64_t label_time; /* Time tape labeled */