Fixed short options missing from getopt option strings - #6262
Fixed short options missing from getopt option strings#6262claude[bot] wants to merge 10 commits into
Conversation
|
|
|
@cf-bottom jenkins, please |
|
Sure, I triggered a build: Jenkins: https://ci.cfengine.com/job/pr-pipeline/14561/ Packages: http://buildcache.cfengine.com/packages/testing-pr/jenkins-pr-pipeline-14561/ |
|
Testing with current nightly (before these changes). It is correct that |
|
|
The --version long option worked, but the advertised -V short form was rejected as an unknown option because 'V' was missing from the getopt option string. The case 'V' handler already existed. Changelog: Fixed cf-check -V (--version) short option
'1' had no option table entry and no switch case, so -1 fell through to the generic usage error. It is a leftover from a removed undocumented alias for -F; --once/-O supersedes it. Changelog: none
'S' had no option table entry and no switch case, so -S fell through to the generic usage error. It is a leftover from the --syntax option removed in 2008. Changelog: none
The long options --tls-version and --ciphers worked, but their advertised short forms -t and -c were rejected as unknown options because they were missing from the getopt option string. Both take a required argument and both already have switch case handlers. Changelog: Fixed cf-net -t (--tls-version) and -c (--ciphers) short options
…tring Neither had an option table entry or a switch case: -S fell through to the generic usage error (leftover from the removed --syntax option), and -i silently swallowed an argument before erroring out. The deliberate deprecated -r error shim is left untouched. Changelog: none
…tring Neither had an option table entry or a switch case: -q silently swallowed an argument before failing with the generic usage error (leftover from --query, which moved to cf-hub in 2013), and -S fell through to the same error (vestigial since 2008). Changelog: none
The -K short option already worked (it sets ignore_locks) but had no option table entry, so it had no long form and was missing from --help and man output. This adds the --no-lock long option and hint, matching cf-agent, cf-execd, cf-serverd and cf-monitord. Changelog: Added --no-lock long option to cf-runagent, matching the existing -K short option
The --verbose, --inform and --log-level long options worked and their short forms are advertised in help and man output, but -v, -I and -g were rejected as unknown options because they were missing from the getopt option string. Also removed the stray 'e' left over from the removed --encrypt option. Changelog: Fixed cf-secret -v (--verbose), -g (--log-level) and -I (--inform) short options
The option table declares --ld-library-path as required_argument, but the option string had a bare 'L', so '-L <path>' left optarg NULL (dereferenced unconditionally) and the path behind as a stray positional argument. Also removed the stray 'S' left over from the --syntax option removed in 2008. Changelog: Fixed cf-serverd -L (--ld-library-path) to accept its argument
The --report long option worked and -r is advertised in help output, but the short form was rejected because 'r' was missing from the getopt option string. Also removed the orphan 'f:' left behind when --file/-f was renamed to --report/-r. Changelog: none
6dad0f1 to
9bad591
Compare
|
@cf-bottom jenkins, please |
|
Alright, I triggered a build: Jenkins: https://ci.cfengine.com/job/pr-pipeline/14562/ Packages: http://buildcache.cfengine.com/packages/testing-pr/jenkins-pr-pipeline-14562/ |
Requested by Ole Herman · Slack thread
Several documented short options were silently rejected because their characters were missing from the
getopt_long()option strings, and several option strings still carried characters for options removed years ago. After this PR:cf-check -V,cf-net -t/-c,cf-secret -v/-g/-I,cf-testd -r.cf-serverd -L <path>(--ld-library-path) now receives its argument instead of a NULLoptarg(which was dereferenced unconditionally) and a stray positional argument.-1in cf-execd,-Sin cf-monitord/cf-promises/cf-runagent/cf-serverd, and the vestigial argument-takingq:/i:/f:in cf-runagent/cf-promises/cf-testd) no longer swallow arguments or die with an unhelpful generic usage error — they are now reported as ordinary unrecognized options.cf-runagentgains a--no-locklong option for its existing, working, previously help-invisible-K, matching cf-agent, cf-execd, cf-serverd and cf-monitord.How
One commit per component:
cf-check/cf-check.c+hMg:dvI→+hMVg:dvI-V(--version) was advertised and handled but rejectedcf-execd/cf-execd.c1-Falias; no table entry, no casecf-monitord/cf-monitord.cS--syntax, removed 2008cf-net/cf-net.ct:c:-t(--tls-version) and-c(--ciphers) advertised and handled but rejectedcf-promises/cf-promises.cSand vestigiali:--syntaxleftover;-iswallowed an argument then erroredcf-runagent/cf-runagent.cq:and strayS--querymoved to cf-hub in 2013;-Svestigial since 2008cf-runagent/cf-runagent.c{"no-lock", no_argument, 0, 'K'}+ matching HINTS entry-Kworked but had no long form and was absent from--help/mancf-secret/cf-secret.chMedk:o:H:→hMdvIg:k:o:H:-v/-I/-gadvertised and handled but rejected;eleft over from removed--encryptcf-serverd/cf-serverd-functions.cL→L:, removed strayS--ld-library-pathisrequired_argumentbut got NULLoptarg;--syntaxleftovercf-testd/cf-testd.cf:, addedr:--file/-fwas renamed to--report/-rwithout updating the option stringNotes
getopt_long()call site, prompted by the cf-hub-ibug fixed in cfengine/nova#2671.-Mman-page generation hook shared by all daemons (used bydocs/manpages/Makefile.am), and cf-promises' deliberate deprecated-rerror shim.--help/man output and git history before fixing. The pre-existing duplicateV/baregin cf-execd's option string and the duplicateg:in cf-promises' were left untouched to keep the diff minimal.