| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
| |
* src/argparse.c (_gpgrt_argparse_internal_s): Add fields no_registry
and registry.
(initialize): Init them.
(emulated_registry_lookup): New.
(handle_meta_getenv): Use it.
* tests/etc/t-argparse.conf: Add a getreg meta command.
* tests/t-argparse.c (opt): Add a disable-akr command.
* tests/etc/Registry: New.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/strlist.c: Rename all functions to have a _gpgrt_strlist prefix.
(append_to_strlist2, strlist_length): Remove.
(_gpgrt_strlist_free): rtake care of the wipe flag.
(_gpgrt_strlist_add): Add a flags arg to use it for prepend and
append. Return an error on failure.
(_gpgrt_strlist_tokenize): Ditto.
(_gpgrt_strlist_copy): Chnage to return an error on failure.
(_gpgrt_strlist_pop): Ditto.
* src/Makefile.am (libgpg_error_la_SOURCES): Add strlist.c.
* src/argparse.c (trim_spaces): Move to ...
* src/stringutils.c (_gpgrt_trim_spaces): here and rename.
* src/visibility.c: Add wrappers for all exported functions.
* src/visibility.h: MArk exported functions as visisble.
* src/gpg-error.def.in: Export new functions
* src/gpg-error.vers: Ditto.
* src/gpg-error.h.in (GPGRT_STRLIST_APPEND): New.
(GPGRT_STRLIST_WIPE): New.
(gpgrt_strlist_free): New.
(gpgrt_strlist_add): New.
(gpgrt_strlist_tokenize): New.
(gpgrt_strlist_copy): New.
(gpgrt_strlist_rev): New.
(gpgrt_strlist_prev): New.
(gpgrt_strlist_last): New.
(gpgrt_strlist_pop): New.
(gpgrt_strlist_find): New.
(gpgrt_strlist_count): New inline function.
--
This is a modified set of function as used by gpg for ages. These are
quite useful functions and will be needed internally for some other
planned features. The idea is to make their counterparts in gnupg
wrapper around those new functions.
After we have moved the secure memory stuff from Libgcrypt to here we
can also implement a GPGRT_STRLICT_SECMEM flag to allow allocating
strings here ion secure memory. For now we only have the WIPE flag
which wipes the memory on free.
|
|
|
|
|
|
|
|
|
|
| |
* src/argparse.c (store_alias): Free NAME because it has ownerhip
here. Take care P is actually a pointer into NAME.
--
Note that aliases have never been implemented.
GnuPG-bug-id: 7105
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/argparse.c (struct _gpgrt_argparse_internal_s): Add forceeof
flag.
(initialize): Clear.
(_gpgrt_argparse): Clear.
(_gpgrt_argparse): Act upon.
--
Reported test case:
$ mkdir /etc/gnupg/gpg.conf
$ gpg --version
All other ways to force a read error will also exhibit the bug.
Debian-bug-id: 1068594
|
|
|
|
| |
* src/argparse.c (show_help): Adjust for command style options.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/gpg-error.h.in (ARGPARSE_FLAG_COMMAND): New.
* src/argparse.c (struct _gpgrt_argparse_internal_s): Add flags
explicit_cmd_mode, cmd_mode, and command_seen.
(initialize): Init them. Mark default commands as commands.
(handle_meta_command): New.
(handle_metacmd): Add "command-mode" and "-command-mode".
(find_long_option): Add arg only_commands.
(arg_parse): Factor some code out to ...
(handle_special_commands): new.
(arg_parse): Implement the command-mode.
* tests/t-argparse.c (main): Add some testing code.
--
GnuPG-bug-id: 6978
|
|
|
|
| |
--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/argparse.c (show_help): Do not translate the empty string.
--
PO files use the empty string for meta information. However, to mark
the end of the heder group we also use an empty string and that one
gets translated - boom. Example of this error:
[...]
-u, --local-user USER-ID [...]
Project-Id-Version: gnupg-2.3.0
Report-Msgid-Bugs-To: [email protected]
PO-Revision-Date: 2022-10-07 09:52+0200
Last-Translator: Werner Koch <[email protected]>
Language-Team: German <[email protected]>
Language: de
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Plural-Forms: nplurals=2; plural=n != 1;
:
(Auf der "man"-Seite ist eine volls[...]
|
|
|
|
|
|
|
|
|
| |
* src/argparse.c (show_version): It's no args.
(_gpgrt_log_get_fd, _gpgrt_log_get_stream): Likewise.
--
Signed-off-by: NIIBE Yutaka <[email protected]>
|
|
|
|
|
|
| |
* src/argparse.c (_gpgrt_argparse): Set attributes info flags
--
GnuPG-bug-id: 5799
|
|
|
|
|
|
|
| |
* src/argparse.c (get_var): Fix "_windows", add "_gpgrtversion" and
"strusageN".
(handle_meta_if): Avoid evaluating inactive branches.
* tests/t-argparse.conf: Add a few other outputs.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/argparse.c (struct variable_s): New.
(struct _gpgrt_argparse_internal_s): New fields expand, if_cond,
if_active and vartbl.
(deinitialize): Free vartbl.
(initialize): Clear new vars.
(get_var): New.
(substitute_vars): New.
(set_variable): New.
(handle_meta_if): New.
(handle_meta_let): New.
(handle_meta_getenv): New.
(handle_meta_echo): Re-implement in terms of variabale substitution.
(handle_meta_expand): New.
(handle_metacmd): Add new meta commands.
(_gpgrt_argparse): Expand values if enabled.
(_gpgrt_argparse): Take care of conditions.
(_gpgrt_argparser): Reset some state at the end of a file.
* tests/etc/t-argparse.conf: Adjust for changed system variables.
* tests/t-argparse.c (my_strusage): Add a value for a version test.
(main): Add new option "street".
* tests/t-argparse.conf: A couple if additions for the new conditions.
--
The whole thing is actually only for here for doing this
[let tkey HKLM\Foo\Bar\GnuPG:trusted-key-1]
[if $tkey]
trusted-key $tkey
[fi]
But we are hackers and tend to make things more complicated^Wflexible.
Documentation will be done eventually.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
| |
* src/w32-gettext.c: Include gpgrt.h instead gpg-error.h.
(utf8_to_wchar): Use underscored function.
(_gpg_w32_textdomain): Ditto.
--
|
|
|
|
|
| |
* src/argparse.c (_gpgrt_argparse): Entirely skip ignored sysconf
commands. Fix state transitions in the ignore case.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/argparse.c (_gpgrt_argparse): Factor some code out to ...
(prepare_arg_return): new.
(_gpgrt_argparse): No missing arg error in ignore sections.
--
Options in an [ignore] section do not anymore lead to an error if an
argument is missing. However, if the option is also in a force
section the error is thrown.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/gpg-error.h.in (gpgrt_access): New.
* src/gpg-error.vers. src/gpg-error.def.in: Add new function.
* src/sysutils.c (any8bitchar): New.
(_gpgrt_access): New.
* src/visibility.c (gpgrt_access): New.
* src/spawn-w32.c (_gpgrt_spawn_process_detached): Use it.
* src/argparse.c (try_versioned_conffile): Use it.
* tests/t-stringutils.c (check_access): New simple test.
--
This is basically a wrapper to allow handling of utf8 encoded file
names on Windows. This also fixes the case for versioned config files
in directories with non-ascii characters.
The new test needs to be run manually on Windows using a directory
with Unicode characters.
GnuPG-bug-id: 5098
|
|
|
|
| |
--
|
|
|
|
|
|
| |
* src/argparse.c (arg_parse): Avoid null dereference when ARGC is wrong.
Signed-off-by: NIIBE Yutaka <[email protected]>
|
|
|
|
|
|
|
|
| |
* src/argparse.c (ARGPARSE_FLAG__INITIALIZED): Make sure it is an
unsigned int.
--
GnuPG-bug-id: 5026
|
|
|
|
|
|
|
|
|
|
|
| |
* src/argparse.c (handle_meta_echo): Substitue some vars.
(handle_meta_user): Factor some code out to ...
(assure_username): new.
--
Yeah, that is not really needed but might sometimes be helpful.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
| |
* src/argparse.c (initialize): Clear username.
* src/sysutils.c (_gpgrt_getusername): Implement for Windows.
--
This also fixes a missing intialization
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/sysutils.c (_gpgrt_getusername): New.
* src/argparse.c (struct _gpgrt_argparse_internal_s): New flags user_*
and store the current user.
(initialize): Free new malloced field. Clear new flags.
(handle_meta_user): Implement.
(handle_metacmd): Implement user sections. Remove "group" meta
command.
(_gpgrt_argparse): Implement user sections.
(finish_read_sys): Reset new vars.
--
Implementing group would be somewhat complicated and it is doubtful
whether this really makes sense and is manageable for the admin.
Note that we have not yet implemented this for Windows.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
| |
* src/argparse.c (show_help): Do not print empty sections between
headers.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/gpg-error.h.in (ARGPARSE_OPT_HEADER): New.
(ARGPARSE_OPT_VERBATIM): New.
(ARGPARSE_verbatim): New.
(ARGPARSE_header): New.
* src/argparse.c (show_help): Implement them.
--
These two macros are useful for custom help screens. In contrast to
the ARGPARSE_group hack they do not need a short option number (we use
1 here as a surrogate) and not the "@" hack. Thus already translated
strings can be used. ARGPARSE_header further allows to specify a
symbolic name for the group and does some minor formatting. If such a
symbolic name is given --dump-option-table also emits this as a pseudo
option for consumption by GUIs which for example use tabs to group
options.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
| |
* src/argparse.c (initialize): Increase number of extra slots.
--
I should really buy the valgrind authors a beer.
Fixes-commit: db95feab16e32309a4bfb382827c495c2c49920c
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/argparse.c (initialize): Add new internal option.
(arg_parse): Implement that option.
(dump_option_table): New.
(show_help): Remove exit and let the caller call my_exit.
--
This options allows us to get a copy of the option table.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
| |
* src/argparse.c (writestrings): Use that function to match what we
are doing in flushstrings.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/gpg-error.h.in (ARGPARSE_FLAG_WITHATTR): New.
(ARGPARSE_ATTR_FORCE): New.
(ARGPARSE_ATTR_IGNORE): New.
(ARGPARSE_TYPE_MASK): Moved from argparse.c to here.
* src/argparse.c: Always use macros for constants.
(_gpgrt_argparse): Handle ARGPARSE_FLAG_WITHATTR.
(arg_parse): Ditto.
* tests/t-argparse.c (main): Add commented test case.
--
This is a ABI compatible hack to allow the ignore and force attributes
as well as to return which option has been ignored in a user file or
on the command line.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/argparse.c (opttable_t): Add new flags forced, ignore, and
explicit_ignore.
(struct _gpgrt_argparse_internal_s): Change flags to bitflags. Add
several flags to support meta commands.
(initialize): Clear them.
(handle_meta_user): Use the new verbose flag.
(handle_meta_force): Implement.
(handle_meta_ignore): Implement.
(handle_meta_echo): Support "-echo".
(handle_meta_verbose): New.
(handle_metacmd): New meta command verbose. Add always flag and move
the detection of unexpected meta commands to here.
(_gpgrt_argparse): Make use of the ignore and forced meta commands.
(finish_read_sys): New.
(_gpgrt_argparser): Support the verbose flag. Call finish_read_sys.
(arg_parse): Ignore non-explicit ignored and all forced options.
* tests/t-argparse.c (main): Fix printing of the ARGPARSE_CONFFILE
case. New option 'M'.
* tests/t-argparse.conf, tests/etc/t-argparse.conf: Various changes to
test the new meta commands.
--
For the command line we print a diagnostic if an ignored or forced
options is used. However, we do not ignore options which are only set
via [ignore-all]. The rationale for the latter is that an
administrator can't be be required to unignore all options used by all
modes, of say gpgme.
Documentation of the meta commands will for now be added to GnuPG.
GnuPG-bug-id: 4788
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
| |
* src/argparse.c (arg_parse): Fix it here.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/argparse.c (handle_meta_user): New stub.
(handle_meta_force): New stub.
(handle_meta_ignore): New stub.
(handle_meta_echo): New.
(handle_metacmd): New.
(_gpgrt_argparse): Call meta command handler.
--
GnuPG-bug-id: 4788
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/argparse.c (opttable_t): New.
(struct _gpgrt_argparse_internal_s): Use this instead of a ppointer to
gpgrt_opt_t.
(initialize): Copy options to the new tableand keep an original ordinal.
(_gpgrt_argparse): Adjust for changes.
(any_opt_conffile): Ditto.
(find_long_option): Ditto.
(arg_parse): Ditto.
(long_opt_strlen): Adjust args.
(cmp_ordtbl): New.
(show_help): Print using the ordinal numbers.
--
We will need to keep extra information along with the options. This
changes prepares this by using a copy of the user provided option
table. The only new info is the original ordinal number which will
allow us to eventually do a binary search on the options but still be
able to print the help in the user defined way.
GnuPG-bug-id: 4788
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/gpg-error.h.in (ARGPARSE_INVALID_META): New
(ARGPARSE_UNKNOWN_META, ARGPARSE_UNEXPECTED_META): New.
* src/argparse.c (struct _gpgrt_argparse_internal_s): Add flag
insysconfig.
(initialize): Init flag. Add error strings.
(_gpgrt_argparser): Set that flag.
(_gpgrt_argparse): Add parsing of meta commands.
* tests/etc/t-argparse.conf: Add some test cases.
* tests/t-argparse.conf: Ditto.
* tests/t-argparse.c (main): Die only after printing all warnings.
--
Noe that this is just the framework to add meta commands to the global
config file. We also need to get away from fixes test config files
and create them on the fly to that we are able to test also errors.
GnuPG-bug-id: 4788
|
|
|
|
|
|
| |
* src/argparse.c (_gpgrt_argparse): Fold common code.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/argparse.c (_gpgrt_argparse): Use enum for the states and
replace continue and break.
--
The use of continue and break in the endless loop if confusing due to
the size of the loop's body and because there are also inner for
loops with break. It is better to make things explicit by using goto.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/gpg-error.h.in (ARGPARSE_FLAG_USERVERS): New.
* src/argparse.c: Include unistd.h.
(try_versioned_conffile): New.
(_gpgrt_argparser): Use it.
--
This is neded to bring the versioned config files back to gpg.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
| |
* src/gpg-error.h.in (ARGPARSE_PERMISSION_ERROR): New.
* src/argparse.c (initialize): Add code to print this error.
--
We need this option to reject certain config files if we detect a
permission problem.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
| |
* src/argparse.c (PATHSEP_C, DIRSEP_C): New.
(is_absfname, is_twopartfname): New.
(_gpgrt_argparser): Allow for a two-part config name.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
| |
--
It is the GNU GPL, so print that and not jus the SPDX identifier.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
| |
* src/argparse.c (_gpgrt_argparser): Allow for empty argv. Also fix
memory leak.
--
This comes handy when rereading option files on SIGHUP, for example in
gpg-agent. There is no need to provide a dummy array.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/argparse.c (arg_parse): Always set opt_flags. New flag no_init.
(_gpgrt_argparse): Clear opt_flags at start.
(_gpgrt_argparser): Call arg_parse directly. Call arg_parse with
no_init set.
--
The no_init flag is a minor performance feature to by pass the
initialize function which has already been called by _gpgrt_argparser.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
| |
* src/argparse.c (ARGPARSE_FLAG__INITIALIZED): New.
(initialize): Use a flag bit to track the initialization state.
(_gpgrt_argparser): Clear some state on switching files.
--
Fixes-commit: 933eb9346a84c87f83f77d990be2f66e2f7b62e7
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* gpg-error.h.in (GPGRT_CONFDIR_USER, GPGRT_CONFDIR_SYS): New consts.
(ARGPARSE_FLAG_SYS, ARGPARSE_FLAG_USER, ARGPARSE_FLAG_VERBOSE)
(ARGPARSE_NO_CONFFILE, ARGPARSE_CONFFILE, ARGPARSE_OPT_CONFFILE): New
consts.
(ARGPARSE_conffile, ARGPARSE_noconffile): New macros.
(gpgrt_set_confdir): New func.
(gpgrt_argparser): New func.
* src/argparse.c (confdir): New var.
(enum argparser_states): New.
(struct _gpgrt_argparse_internal_s): Add a couple of new fields.
(initialize): Init them.
(any_opt_conffile): New.
(_gpgrt_argparser): New.
(_gpgrt_set_confdir): New.
* src/visibility.c (gpgrt_argparser): New.
(gpgrt_set_confdir): New.
* src/gpg-error.def.in, src/gpg-error.vers: Add those functions.
* tests/t-argparse.c (main): Reworked.
* tests/etc/t-argparse.conf: New file.
* tests/t-argparse.conf: New file.
--
gpgrt_argparser is a high level version of gpgrt_argparse. It handles
reading of configuration files internally and allows allows for a
global configuration file. The design is so that it minimizes the
work to replace the existing option parsing in gpg and friends by this
one and to allow global configuration files for them.
This is the just the basic code which should allow replacement of the
parsers. A forthcoming patch will implement flags for options given
in the global config file.
GnuPG-bug-id: 4788
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
| |
* src/gpg-error.c (main): Remove a log_debug.
--
Also a few typo fixes.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/gpg-error.h.in (ARGPARSE_end): Simplify.
* src/argparse.c (_gpgrt_argparse_internal_s): Add field opts.
(deinitialize): Release new field.
(initialize): Add arg opts and create a copy of the option list. Add
the internal options.
(_gpgrt_argparse): Rename arg opts to opts_orig and set new local var
opts. Adjust all references to opts.
(find_long_option): Adjust for chnaged type of OPTS. Re-indent.
(arg_parse): Remove internal option assignment. Rename arg opts to
opts_orig and set new local var opts. Adjust all references to opts.
(show_help): Adjust all references to opts.
--
The old ARGPARSE_end maro was a bit cumbersome and does not allow to
chnage the number of internal options. Thus this somewhat larger
chnage to keep the internal options out of the API.
Note that with this change the internal options now also work in a
option file and not just on the command line; that does not make much
sense but is probably less surprising.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
| |
--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/visibility.c (gpgrt_argparse): New.
(gpgrt_strusage): New.
(gpgrt_set_strusage): New.
(gpgrt_set_usage_outfnc): New.
(gpgrt_set_fixed_string_mapper): New.
* src/gpg-error.def.in, src/gpg-error.vers: Add new functions.
* src/gpg-error.h.in: Add ARGPARSE macros from the former argparse.h.
(gpgrt_argparse_t): New.
(gpgrt_opt_t): New.
* configure.ac (AH_BOTTOM): Request argparse macros.
* src/Makefile.am (libgpg_error_la_SOURCES): Add argparse.c.
* src/argparse.h: Remove.
* src/argparse.c: Revamp to fit into libgpg-error.
(_gpgrt_argparse): New.
(_gpgrt_usage): Rename from usage.
(_gpgrt_strusage): Rename from strusage. Define two new levels and
templates for three common licenses.
(_gpgrt_set_strusage): Rename from set_strusage.
(_gpgrt_set_usage_outfnc): New.
(_gpgrt_set_fixed_string_mapper): New.
* tests/t-argparse.c: New.
--
These functions are in use by GnuPG and other software for 20 years
and it makes sense to have them always available instead of copying
and maintaing the source in several projects. Note that there are
minor changes in the API compared to GnuPG.
Signed-off-by: Werner Koch <[email protected]>
|
|
--
|