Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

introduce a preserve command line switch in debugfs 'rdump' command #8

Merged
merged 2 commits into from
Feb 14, 2024

Conversation

qkaiser
Copy link

@qkaiser qkaiser commented Feb 9, 2024

debugfs assumed the user wanted to preserve permissions and ownership when dumping a filesystem directory recursively with rdump. This is in opposition with the way the dump/dump_inode command has been designed, since it expose a -p command line switch to allow the end users to explicitly opt-in for permission and ownership preservation.

The inability to explicitly ask for permission and ownership preservation would get rdump to default to preservation, which is a problem when faced with filesystems having directories with the read flag set but not the execute flag set, since it would only allow to enumerate the directory content, but not see the inode details. Therefore getting debugfs in all kinds of issues trying to set ownership and permissions of files it can't see.

This fix introduce a 'preserve' (-p) flag in rdump command so that users can explicitly opt-in for it, and debugfs will default to a safer way of operation (no preserve).


Note: I also fixed some code to get it to build with modern clang, and formatted the code with clang-format because the code is unreadable otherwise.

@qkaiser qkaiser added the enhancement New feature or request label Feb 9, 2024
@qkaiser qkaiser self-assigned this Feb 9, 2024
@vlaci vlaci requested a review from orosam February 9, 2024 10:35
@vlaci
Copy link

vlaci commented Feb 9, 2024

We should decide if we want to reformat the code or not. If there are ever new upstream changes in this tool, it will be hell to rebase to. If we are to take the risk, we should first reformat the code, and implement the new functionality on top, so that functional changes are not mixed with formatting ones on the same base.
Personally, I am for to keep the code style as is.

@qkaiser
Copy link
Author

qkaiser commented Feb 9, 2024

@vlaci this is an excellent point, I'll rework the MR without formatting stuff so we're safe if we have to rebase on upstream in the future.

@qkaiser qkaiser force-pushed the fix-debugfs branch 3 times, most recently from ba671f1 to 5da34a8 Compare February 9, 2024 12:30
@qkaiser
Copy link
Author

qkaiser commented Feb 9, 2024

This MR now only contains changes to the code itself and no reformatting. Code changes stick to tabs rather than spaces since it's what was used originally.

debugfs/dump.c Outdated Show resolved Hide resolved
debugfs/dump.c Outdated Show resolved Hide resolved
debugfs/dump.c Outdated Show resolved Hide resolved
debugfs/dump.c Outdated Show resolved Hide resolved
debugfs/dump.c Show resolved Hide resolved
debugfs/dump.c Outdated Show resolved Hide resolved
debugfs/dump.c Show resolved Hide resolved
debugfs/dump.c Outdated Show resolved Hide resolved
rdump assumed the user wanted to preserve permissions and ownership when
dumping a filesystem directory recursively with 'rdump'. This is in
opposition with the way the 'dump' or 'dump_inode' command has been
designed, since it expose a '-p' command line switch to allow the end
users to explicitly opt-in for permission and ownership preservation.

The inability to explicitly ask for permission and ownership
preservation would get rdump to default to preservation, which is a
problem when faced with filesystems having directories with the read
flag but not the execute flag, since it would only allow to enumerate
the directory content, but not see the inode details. Therefore getting
debugfs in all kinds of issues trying to set ownership and permissions
of files it can't see.

This fix introduce a 'preserve' ('-p') flag in rdump command so that
users can explicitly opt-in for it, and debugfs will default to a safer
way of operation (no preserve).
Unused variable ext_written was reported by -Wunused-but-set-variable,
so it's now guarded by the same preprocessor guards that protects its
actual usage.

Function without prototypes are note allowed in C23.
@qkaiser qkaiser merged commit 1f0149e into master Feb 14, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants