Skip to content

Commit

Permalink
caformat: change definition of CA_FORMAT_DEFAULT a bit
Browse files Browse the repository at this point in the history
So far, CA_FORMAT_DEFAULT wasn't normalized, because the NODUMP bit was
both marked for serialization and masked for file exclusion handling.
Let's fix this.

Let's also add a quick test so that this is verified always.
  • Loading branch information
poettering committed Feb 13, 2018
1 parent 32dc1a5 commit 864b346
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/caformat.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ enum {
CA_FORMAT_WITH_QUOTA_PROJID,

CA_FORMAT_DEFAULT = /* The default set of flags */
CA_FORMAT_WITH_BEST|
(CA_FORMAT_WITH_BEST & ~CA_FORMAT_WITH_FLAG_NODUMP)|
CA_FORMAT_EXCLUDE_NODUMP|
CA_FORMAT_EXCLUDE_FILE|
CA_FORMAT_SHA512_256,
Expand Down
5 changes: 5 additions & 0 deletions test/test-feature-flags.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ int main(int argc, char *argv[]) {
assert_se(ca_feature_flags_normalize(CA_FORMAT_FEATURE_FLAGS_MAX, &normalized) >= 0);
assert_se((normalized & CA_FORMAT_WITH_MASK) == (CA_FORMAT_WITH_BEST & ~CA_FORMAT_WITH_FLAG_NODUMP));

assert_se(ca_feature_flags_are_normalized(CA_FORMAT_WITH_BEST) > 0);
assert_se(ca_feature_flags_are_normalized(CA_FORMAT_WITH_UNIX) > 0);
assert_se(ca_feature_flags_are_normalized(CA_FORMAT_WITH_FAT) > 0);
assert_se(ca_feature_flags_are_normalized(CA_FORMAT_DEFAULT) > 0);

for (i = 0; i < sizeof(uint64_t) * 8; i++) {
uint64_t flag = UINT64_C(1) << i, flag2;
_cleanup_free_ char *s = NULL;
Expand Down

0 comments on commit 864b346

Please sign in to comment.