Alain Spineux [Tue, 15 Nov 2022 15:11:41 +0000 (16:11 +0100)]
Fix VolEncrypted in get_scratch_volume()
- get_scratch_volume() was not using the right VolEncrypted value for
the SQL query
- this fix tests :
failed 651s tests/copy-uncopied-test
failed 651s tests/copy-volume-test
failed 651s tests/next-vol-test
failed 69s tests/verify-data-test
failed 651s tests/scratchpool-pool-test
Alain Spineux [Mon, 7 Nov 2022 11:07:18 +0000 (12:07 +0100)]
Add VolumeEncrypted field to the catalog
- the goal is to not append encrypted data to volumes that that are not
encryption ready ( that are BB02 or have not been label with an
"encrypted" capable label )
Eric Bollengier [Tue, 8 Nov 2022 10:30:59 +0000 (11:30 +0100)]
Improve the bsock network errors display
- Put [error] codes in many messages
- Do not print error messages inside the BSOCK::connect/open calls
- Print error messages after a connect() depending of the context (UA/jcr)
- Network messages should not end up in JobId 0
- Fix incorrect socket usage after a console command error
Alain Spineux [Fri, 12 Aug 2022 09:45:13 +0000 (11:45 +0200)]
Fix sqlite query error in VF
- this fix don't modify the pgsql nor the mysql query, ONLY the sqlite
query, is modified. The code is duplicated and modified ONLY for sqlite,
- fix the "UNION": syntax error that come when running a VF
- the fix just remove the () and a useless "order by"
- I think this query could be used for pgsql & mysql too.
- tests/virtual-backup-test
12-Aug 11:38 127.0.0.1-dir JobId 8: Error: Query failed: SELECT Path, Filename, FileIndex, JobId, LStat, DeltaSeq , JobTDate FROM ((SELECT Path.Path, T1.Filename, T1.FileIndex, T1.JobId, LStat, DeltaSeq , JobTDate FROM ( SELECT FileId, Job.JobId AS JobId, FileIndex, File.PathId AS PathId,File.Filename AS Filename, LStat , File.DeltaSeq AS DeltaSeq,Job.JobTDate AS JobTDate FROM Job, File, (SELECT MAX(JobTDate) AS JobTDate, PathId, Filename, DeltaSeq FROM (SELECT JobTDate, PathId, Filename, DeltaSeq FROM File JOIN Job USING (JobId) WHERE File.JobId IN (1,2,3,4,5,6) UNION ALL SELECT JobTDate, PathId, Filename, DeltaSeq FROM BaseFiles JOIN File USING (FileId) JOIN Job ON (BaseJobId = Job.JobId) WHERE BaseFiles.JobId IN (1,2,3,4,5,6) ) AS tmp GROUP BY PathId, Filename, DeltaSeq ) AS T1 WHERE (Job.JobId IN ( SELECT DISTINCT BaseJobId FROM BaseFiles WHERE JobId IN (1,2,3,4,5,6)) OR Job.JobId IN (1,2,3,4,5,6)) AND T1.JobTDate = Job.JobTDate AND Job.JobId = File.JobId AND T1.PathId = File.PathId AND T1.Filename = File.Filename ) AS T1 JOIN Path ON (Path.PathId = T1.PathId) WHERE FileIndex > 0 ) UNION (SELECT ObjectName AS Path, PluginName AS Filename, FileIndex, JobId, '' AS LStat, 0 AS DeltaSeq , JobTDate FROM Job JOIN RestoreObject USING (JobId) WHERE JobId IN (1,2,3,4,5,6) ORDER BY JobTDate ASC, FileIndex ASC) ) AS U1 ORDER BY JobTDate, FileIndex ASC: ERR=near "UNION": syntax error
Alain Spineux [Thu, 6 Oct 2022 12:16:41 +0000 (14:16 +0200)]
New BB03 volume format: volume encryption & new 64bits checksum
- this is a 64bits XXHASH64 check that replace the 32bits
- The old crc32 location is used for a "block option" bit field
- use the block header option bit field to store information about
- if block checksum (XXH64) is used
- encryption is used
- if "this" block is encrypted (volume label are not)
- add encryption_command
- use the BlockNum for the IV
- new SD->Device->BlockEncryption directive to enable encryption
- the xxhas64 is in one block at the end of the header
- add documentation
- add a unittest for block_crypto, to show how to use it and do some basic
encrypte/decrypte
- 2 options bit in the block header
- BLKHOPT_ENCRYPT_VOL if the volume is encrypter
- BLKHOPT_ENCRYPT_BLOCK if THIS block is encrypted
- bsdjson can display the encryption type
- high level protocol between the sd_encryption_script and the SD
- use ENV to send the data
- use stdout/stdin to read the answere from the keymanager
- handle error reported by the script
- obfuscate data in the volume when needed (BlockEncryption = STRONG)
- support data spooling (don't encode data in the spool)
- support %V in edit_device_codes() but not used anymore, use environment
instead
- add support for a master key (store encoded version of the encryption key
and the key id of the masterkey)
- DEVICE::load_encryption_key() that call the keymanager
- Add new fields to volume label : EncCipherKey[Size] & MasterKeyId[Size]
- add int DEV_RECORD::BlockVer to know the volume version, in case we decode
the volume header and its extra fields
- add the NULL cipher only for testing purpose
- the XXHASH is always there in the block header event when not used (set to 0)
- the block header has a constant length
Alain Spineux [Tue, 2 Aug 2022 11:51:33 +0000 (13:51 +0200)]
Fix wrong length returned by base64_to_bin(), rewrite the function
- base64_to_bin() was handling the '=' padding char as data,
making the output longer when padding was used.
- If you had no padding, this was ok
- Or if you were knowing the length of the output to cut it at the right
length this was ok too
- The output buffer had to be a little longer too
- The function base64_init() has been removed and 'base64_map' is
initialized with a static table
- The function has been rewritten
- ignore spaces in the input (space, tab, newline), can be a multi-line input
- stop when a '\0', a '=' (padding) or srclen depending what is hit first
- return 0 when the output string is too short or invalid char are fount
in the output
- dest_size don't need to be bigger, the exact length is ok
- the output string is not ended with '\0', has it is supposed to be binary data
- The other usage of base64_to_bin() in the code have been fixed when needed
- Add plenty of test
==== Starting base64_test ... ====
OK test bin_to_base64
OK test bin_to_base64 content
OK test base64_to_bin
OK test base64_to_bin content
OK test base64 encode decode for multiple lengths
OK test base64 decode base64 with multiple spaces
OK test base64 buffer too small 1
OK test base64 buffer too small 2
OK test base64 padding YQ==
OK test base64 padding YQ=
OK test base64 padding YQ
OK test base64 padding YQ==
OK test base64 padding YQ=
OK test base64 padding YQ
OK test base64 truncated padding YQ== 3
OK test base64 truncated padding YQ== 2
OK test base64 invalid char 1
OK test base64 invalid char 2
OK test base64 invalid char 3
OK test base64 invalid char after the padding
OK Checking bin_to_base64 encoded length
OK Checking bin_to_base64 encoded data
OK Checking base64_to_bin decoded length
OK Checking base64_to_bin decoded data
OK Checking base64_to_bin decoded length - encoded
OK Checking base64_to_bin decoded data - encoded
OK Checking to_base64 encode length
OK Checking to_base64 encoded data
OK Checking from_base64 decoded data
OK Checking from_base64 decoded length
OK Checking from_base64 decoded data - encoded
OK Checking from_base64 decoded length - encoded
Alain Spineux [Tue, 1 Mar 2022 13:37:39 +0000 (14:37 +0100)]
tweak remove wrong definition of ser_block_header() from proto.h
- the definition of ser_block_header in proto.h is wrong
void ser_block_header(DEV_BLOCK *block);
- the right one is
uint32_t ser_block_header(DEV_BLOCK *block, bool do_checksum)
- the definition in proto.h is never used
Eric Bollengier [Tue, 20 Sep 2022 08:39:38 +0000 (10:39 +0200)]
Enhance .bvfs_ls_files() to support VirtualFull
In one Job, a single file can have multiple instances with delta_seq != 0.
We modify the queries to find the higest DeltaSeq for a file and return
the correct FileId.
Alain Spineux [Thu, 11 Aug 2022 12:11:32 +0000 (14:11 +0200)]
Optimize the split of the BSR
- When the BSR is split there is no need to remember for the volumes that
are in the previous part.
- Read the BSR in one pass and resetting the list of volumes is difficult
as we do the split in hindsight.
- Instead of modifying the list we remember when a volume has been
seen for the last time (the job_num) and to know if a volume matter
we compare it with the last_split_job_num that is the first job_num
of the list