Skip to content

Terminate generated sudoers entries with a newline - #228

Open
qorud02 wants to merge 3 commits into
stfc:feature/latest-ltsfrom
qorud02:fix-sudoers-line-terminators
Open

qorud02 wants to merge 3 commits into
stfc:feature/latest-ltsfrom
qorud02:fix-sudoers-line-terminators

Conversation

@qorud02

@qorud02 qorud02 commented Oct 1, 2026 •

Copy link
Copy Markdown

Both sudoers files written by the image builder omit their final line terminator. The sudo-rs parser used by Ubuntu 26.04 rejects them with missing line terminator at end of file, as reported in #211.

Append a newline to the Ansible copy.content values for /etc/sudoers.d/cloud and /etc/sudoers.d/cloud-team-user. The sudo rules and file modes stay the same.

Fixes #211.

Validation:

  • Decoded the actual YAML task contents, including the nested block, and checked both generated files end in a newline. This check fails on the original task values and passes after the change; both modes remain 0440.
  • Extracted visudo-rs 0.2.13 from the official Ubuntu 26.04 sudo-rs 0.2.13-0ubuntu1.2 amd64 package without installing it, then ran it on Ubuntu 24.04 WSL with glibc 2.39 as the unprivileged nobody user (UID 65534). Both original files exit 1 with syntax error: missing line terminator at end of file. Both patched files exit 0 with parsed OK and empty stderr.
  • Ubuntu 24.04's C visudo 1.9.15p5 accepts both original and patched files, confirming why the earlier C-parser check did not reproduce the reported error.
  • git diff --check passes.

The version-specific check above executes the Ubuntu 26.04 packaged parser, not a full Ubuntu 26.04 VM or image build. A full image build was not run.

Prepared with AI assistance; the diff was reviewed and the checks above were executed locally.

@qorud02
qorud02 requested a review from khalford as a code owner October 1, 2026 16:38
@khalford
khalford force-pushed the 0.4.X branch 2 times, most recently from cf56afd to 8201b71 Compare October 2, 2026 10:28
@qorud02
qorud02 force-pushed the fix-sudoers-line-terminators branch from ea4decc to e2943a8 Compare October 2, 2026 10:41
@khalford

khalford commented Oct 2, 2026

Copy link
Copy Markdown
Member

Please set the target branch to feature/latest-lts

@qorud02
qorud02 changed the base branch from 0.4.X to feature/latest-lts October 2, 2026 12:38
@khalford

khalford commented Oct 2, 2026

Copy link
Copy Markdown
Member

We just need to build this to confirm it works. Otherwise it looks good to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants