Skip to content

feat: update run0edit to v0.4.3 w/ support for immutable flag#1055

Merged
RoyalOughtness merged 9 commits intosecureblue:livefrom
HastD:run0edit-update
May 19, 2025
Merged

feat: update run0edit to v0.4.3 w/ support for immutable flag#1055
RoyalOughtness merged 9 commits intosecureblue:livefrom
HastD:run0edit-update

Conversation

@HastD
Copy link
Copy Markdown
Collaborator

@HastD HastD commented May 15, 2025

The new version of run0edit checks for the immutable flag on the file to be edited (or the directory if the file doesn't exist), and if so, asks the user whether to temporarily remove it to edit/create the file. This makes editing immutable files less error-prone, as the immutable flag is only removed for the brief window necessary to overwrite the file contents and reapplied immediately afterward; the script also compares the file contents after the immutable flag has been reapplied to ensure it was not modified by another program during that window.

There are also miscellaneous improvements to the script's argument handling, which now parses arguments in a more conventional way and accepts both --help and --version arguments, and the inner privileged script has been refactored to reduce code duplication.

The new version of `run0edit` checks for the immutable flag on the file
to be edited, and if so, asks the user whether to temporarily remove it
to edit the file. This makes editing immutable files less error-prone,
as the immutable flag is only removed for the brief window necessary to
overwrite the file contents and reapplied immediately afterward; the
script also compares the file contents after the immutable flag has been
reapplied to ensure it was not modified by another program during that
window.

Signed-off-by: Daniel Hast <[email protected]>
@HastD HastD requested a review from RoyalOughtness as a code owner May 15, 2025 01:25
HastD and others added 2 commits May 15, 2025 17:05
* Handle immutable flag on directory.
* Check for read-only filesystems to error out earlier.
@HastD HastD changed the title feat: update run0edit to v0.4.0 w/ support for immutable flag feat: update run0edit to v0.4.1 w/ support for immutable flag May 15, 2025
HastD added 2 commits May 17, 2025 22:40
No change to script functionality with this commit, but single-quotes no
longer need to be avoided in the inner script since it's wrapped in a
heredoc.
@HastD HastD changed the title feat: update run0edit to v0.4.1 w/ support for immutable flag feat: update run0edit to v0.4.3 w/ support for immutable flag May 18, 2025
@HastD
Copy link
Copy Markdown
Collaborator Author

HastD commented May 18, 2025

Just FYI, I refactored the script so that, in the run0edit repo, the main script and inner (privileged) script are now in separate files and are merged into the final run0edit script by a (very simple) Python script, build.py.

So, you may find it easier to review the inner script at https://github.com/HastD/run0edit/blob/main/run0edit-inner.sh since it has proper syntax highlighting—the run0edit file in this PR is produced simply by substituting the contents of run0edit-inner.sh into run0edit-main.sh in the appropriate place and applying the patch at run0edit-secureblue.patch (which doesn't make any changes to the inner script anyway).

@RoyalOughtness RoyalOughtness merged commit 0b10ac7 into secureblue:live May 19, 2025
15 of 16 checks passed
@HastD HastD deleted the run0edit-update branch May 19, 2025 22:31
RoyalOughtness pushed a commit to RoyalOughtness/secureblue-dev that referenced this pull request Aug 4, 2025
…blue#1055)

* feat: update run0edit to v0.4.0 w/ support for immutable flag

The new version of `run0edit` checks for the immutable flag on the file
to be edited, and if so, asks the user whether to temporarily remove it
to edit the file. This makes editing immutable files less error-prone,
as the immutable flag is only removed for the brief window necessary to
overwrite the file contents and reapplied immediately afterward; the
script also compares the file contents after the immutable flag has been
reapplied to ensure it was not modified by another program during that
window.

Signed-off-by: Daniel Hast <[email protected]>

* fix: handle case where lsattr gives error

* feat(run0edit): update to v0.4.1

* Handle immutable flag on directory.
* Check for read-only filesystems to error out earlier.

* improve control flow & message wording

* refactor how inner script is substituted into main script

No change to script functionality with this commit, but single-quotes no
longer need to be avoided in the inner script since it's wrapped in a
heredoc.

* split out duplicated code into functions

* simplify read-only filesystem check, reduce code duplication

---------

Signed-off-by: Daniel Hast <[email protected]>
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.

3 participants