Fix seinfo argument parsing when policy path follows query options#157
Merged
pebenito merged 1 commit intoSELinuxProject:mainfrom Oct 2, 2025
Merged
Conversation
Signed-off-by: Pranav Lawate <pran.lawate@gmail.com>
4e07800 to
a33a2e3
Compare
pebenito
approved these changes
Oct 2, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When we run commands with flags/options that can optionally take argument value like -t, -r, etc. along with policy file. It breaks the behavior because the entire policy file path is wrongly taken as value for the argument before it.
seinfo -t /path/to/policy.33 -> will take /path/to/policy.33 as string argument for -t and show 0 results, when it should show all types without any string argument filtering from the policy.
The workaround is
seinfo /path/to/policy.33 -t
I have added a fix to ensure the we check the argument followed by any of the args in 'queries' when args.policy is not detected already. Then verify the next argument is a valid path , if yes then add it to args.policy otherwise it's an argument value. Since there are not args which actually take a path, my fix should work properly.
I have tested it for -t with policy, without policy , with value and policy, with value and no policy. Similarly have tested -r and -a for all 4 combinations.