cmds.secrets.CompileTemplates: Fix conf line handling #138

Merged
Jan Lindemann merged 1 commit from jan/fix/20261012-cmds-secrets-compiletemplates-fix-conf-line-handling into master 2026-10-12 16:43:17 +02:00 AGit
Owner

cmds.secrets.CompileTemplates: Fix conf line handling

File attributes of the compiled output of jw-pkg secrets compile-templates can be specified via the # conf line atop a .jw-tmpl file, the parsing of that line is buggy, however.

Its mode is parsed as a decimal number unless it carries a leading zero, so mode=640 yields 640 decimal, 1200 octal, and the output file ends up without usable permissions. The same decimal parse applies to a conf line atop the .jw-secret of a target, whose attributes are honored the same way, and the --mode option of compile-templates passes its string value through to Attrs, whose mode is typed int, so a target without a conf line of its own crashes in _format_metadata().

Other than that, the # conf line itself should be removed from the compiled output, but isn't.

This commit makes the conf line handling correct:

  • _parse_attributes() parses the mode as octal, with or without a leading zero
  • _compile_one_template_file() drops the conf line from the compiled content
  • the --mode option is converted to an octal int by octal_mode() at the argument boundary

The integration test writes its conf line modes without leading zeros, expects the conf line gone from the compiled output, takes one target's mode from a conf line atop its .jw-secret, and passes a --mode that the conf lines override.

#### cmds.secrets.CompileTemplates: Fix conf line handling File attributes of the compiled output of `jw-pkg secrets compile-templates` can be specified via the # conf line atop a `.jw-tmpl` file, the parsing of that line is buggy, however. Its mode is parsed as a decimal number unless it carries a leading zero, so `mode=640` yields 640 decimal, 1200 octal, and the output file ends up without usable permissions. The same decimal parse applies to a conf line atop the `.jw-secret` of a target, whose attributes are honored the same way, and the `--mode` option of compile-templates passes its string value through to Attrs, whose mode is typed int, so a target without a conf line of its own crashes in `_format_metadata()`. Other than that, the # conf line itself should be removed from the compiled output, but isn't. This commit makes the conf line handling correct: - `_parse_attributes()` parses the mode as octal, with or without a leading zero - `_compile_one_template_file()` drops the conf line from the compiled content - the `--mode` option is converted to an octal int by `octal_mode()` at the argument boundary The integration test writes its conf line modes without leading zeros, expects the conf line gone from the compiled output, takes one target's mode from a conf line atop its `.jw-secret`, and passes a `--mode` that the conf lines override.
cmds.secrets.CompileTemplates: Fix conf line handling
Some checks failed
CI / Packaging - Kali Linux (pull_request) Failing after 9m25s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Failing after 5m24s
CI / Packaging test (pull_request) Has been cancelled
609b3dcf9d
File attributes of the compiled output of "jw-pkg secrets
compile-templates" can be specified via the # conf line atop a .jw-tmpl
file, the parsing of that line is buggy, however.

Its mode is parsed as a decimal number unless it carries a leading zero, so
"mode=640" yields 640 decimal, 1200 octal, and the output file ends up
without usable permissions.  The same decimal parse applies to a conf line atop
the .jw-secret of a target, whose attributes are honored the same way, and
the --mode option of compile-templates passes its string value through to
Attrs, whose mode is typed int, so a target without a conf line of its own
crashes in _format_metadata().

Other than that, the # conf line itself should be removed from the compiled
output, but isn't.

This commit makes the conf line handling correct:

- _parse_attributes() parses the mode as octal, with or without a leading
  zero
- _compile_one_template_file() drops the conf line from the compiled
  content
- the --mode option is converted to an octal int by octal_mode() at the
  argument boundary

The integration test writes its conf line modes without leading zeros,
expects the conf line gone from the compiled output, takes one target's
mode from a conf line atop its .jw-secret, and passes a --mode that the
conf lines override.

Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.1.0
Signed-off-by: Jan Lindemann <jan@janware.com>
Jan Lindemann scheduled this pull request to auto merge when all checks succeed 2026-10-12 10:37:23 +02:00
Jan Lindemann force-pushed jan/fix/20261012-cmds-secrets-compiletemplates-fix-conf-line-handling from 609b3dcf9d
Some checks failed
CI / Packaging - Kali Linux (pull_request) Failing after 9m25s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Failing after 5m24s
CI / Packaging test (pull_request) Has been cancelled
to 141dd0ac3c
All checks were successful
CI / Packaging - Kali Linux (pull_request) Successful in 4m23s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Successful in 5m46s
CI / Packaging test (pull_request) Successful in 0s
CI / Packaging - Kali Linux (push) Successful in 5m30s
CI / Packaging - OpenSUSE Tumbleweed (push) Successful in 5m35s
CI / Packaging test (push) Successful in 0s
2026-10-12 10:58:48 +02:00
Compare
Jan Lindemann scheduled this pull request to auto merge when all checks succeed 2026-10-12 16:35:05 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
janware/jw-pkg!138
No description provided.