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

Move check for UID 0 (i.e. root) to after the options parsing. #101

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Move check for UID 0 (i.e. root) to after the options parsing. #101

wants to merge 2 commits into from

Conversation

iainchesworth
Copy link

Under certain circumstances, options are evaluated after a UID == 0 (i.e. is root) check. That means that invalid options such as -c without a parameter would not be detected and the help screen displayed unless the user is root. Additionally long form options (e.g. --help vs. -h) are not supported nor are validation checks for parameters.

This pull request refactors the options parsing to use getopt_long() so that unknown options, missing parameters, and "long" options are all handled. Additionally, it moves the root check to after option parsing to that users don't have to be root to view the help screen.

Additionally, refactor the options parsing to use getopt() so that it can handle unknown options, missing parameters, and "long" options (i.e. --help vs. -h).
aqualinkd.c Outdated Show resolved Hide resolved
aqualinkd.c Outdated Show resolved Hide resolved
- Should count "-v" parameters for verbosity
- Extra short options incorrect added for long options

Additionally, added constants for the short options to reduce likelihood of flag typos.
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