aboutsummaryrefslogtreecommitdiffstats
path: root/src (unfollow)
Commit message (Collapse)AuthorFilesLines
2020-05-19syscfg: add 64-bit big-endian MIPS architecturedkg/fix-4952Daniel Kahn Gillmor2-0/+26
* src/syscfg/lock-obj-pub.mips64-unknown-linux-gnuabi64.h: new. * src/Makefile.am (lock_obj_pub): Add it. -- This information was dervied and reported by YunQiang Su <[email protected]>. GnuPG-bug-id: 4952 Debian-bug-id: 960161 Signed-off-by: Daniel Kahn Gillmor <[email protected]>
2020-04-09build: Use gen-lock-obj.sh script when possible.NIIBE Yutaka1-0/+7
* configure.ac (HAVE_GENERATED_LOCK_OBJ_H): New. * src/Makefile.am: Support HAVE_GENERATED_LOCK_OBJ_H. -- For cross build, when possible (currently for GNU/Linux), generate lock-obj-pub.native.h by the script. GnuPG-bug-id: 4774 Signed-off-by: NIIBE Yutaka <[email protected]>
2020-04-09build: Add a shell script to generate lock-obj-pub.h.NIIBE Yutaka1-0/+112
* src/gen-lock-obj.sh: New. Signed-off-by: NIIBE Yutaka <[email protected]>
2020-04-03core: Improve the echo and info meta commands of the arg parserWerner Koch1-9/+74
* 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]>
2020-04-03core: Implement meta command [user] also for WindowsWerner Koch2-2/+21
* 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]>
2020-04-03core: Implement meta command [user] for the arg parser.Werner Koch3-25/+106
* 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]>
2020-03-06core: Tweak the printing of headers in the --help output.Werner Koch2-8/+19
* src/argparse.c (show_help): Do not print empty sections between headers. Signed-off-by: Werner Koch <[email protected]>
2020-03-06core: Add features for pretty printing the helpWerner Koch2-7/+35
* 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]>
2020-03-03core: New function gpgrt_reallocarray.Werner Koch7-0/+63
* src/init.c (_gpgrt_reallocarray): New. * src/visibility.c (gpgrt_reallocarray): New. * src/gpg-error.vers, src/gpg-error.def.in: Add new function. * src/gpg-error.h.in: Add new interface. * tests/t-malloc.c: New. * tests/Makefile.am (TESTS): Add new test. -- Note that this function is different from the glibc function because it has an extra parameter which allows to clear the new elements. A realloc after a calloc with forgotten memset after it is a common source of error, thus we introduce this slightly different function. Signed-off-by: Werner Koch <[email protected]>
2020-03-03core: Fix allocation bug introduced with last commit.Werner Koch1-1/+3
* 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]>
2020-03-02core: New internal option --dump-option-table for argparser.Werner Koch1-3/+85
* 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]>
2020-03-02core: Replace fputs by es_fputs in argparser.Werner Koch1-1/+1
* src/argparse.c (writestrings): Use that function to match what we are doing in flushstrings. Signed-off-by: Werner Koch <[email protected]>
2020-03-02core: Allow returning of attributes from gpgrt_argparser.Werner Koch2-20/+60
* 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]>
2020-02-27core: Implement meta commands for the argparser.Werner Koch1-68/+189
* 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]>
2020-02-27indent: Fix indentation in an argparse.c functionWerner Koch1-85/+85
* src/argparse.c (arg_parse): Fix it here.
2020-02-26core: Add meta command handler stubs to argparse.c.Werner Koch1-1/+115
* 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]>
2020-02-26core: Prepare argparse.c to track additional info for options.Werner Koch1-105/+188
* 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]>
2020-02-25core: Add parser for meta commands to gpgrt_argparser.Werner Koch2-2/+74
* 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
2020-02-25core: Fold duplicated code from _gpgrt_argparse.Werner Koch1-82/+86
* src/argparse.c (_gpgrt_argparse): Fold common code. Signed-off-by: Werner Koch <[email protected]>
2020-02-25core: Improve readability of _gpgrt_argparse.Werner Koch1-41/+57
* 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]>
2020-02-25core: New flag ARGPARSE_FLAG_USERVERS to try versioned config files.Werner Koch2-20/+76
* 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]>
2020-02-25core: New pseudo option ARGPARSE_PERMISSION_ERROR.Werner Koch2-0/+5
* 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]>
2020-02-25w32: Fix exporting gpgrt_argparser.NIIBE Yutaka1-1/+1
* src/gpg-error.def.in (gpgrt_argparser): Fix typo. Signed-off-by: NIIBE Yutaka <[email protected]>
2020-02-22core: Extend the way a config file can be specified,Werner Koch1-8/+88
* 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]>
2020-02-20core: Change printed license names.Werner Koch1-3/+3
-- It is the GNU GPL, so print that and not jus the SPDX identifier. Signed-off-by: Werner Koch <[email protected]>
2020-02-20core: Skip cmdline parsing for no or an empty argv.Werner Koch1-4/+13
* 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]>
2020-02-19core: More fixes for the new option/argument parser.Werner Koch1-7/+18
* 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]>
2020-02-19core: Some fixes for the new option/argument parserWerner Koch1-8/+29
* 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]>
2020-02-18core: Add a high level option/argument parser.Werner Koch9-11/+426
* 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]>
2020-02-18core: Add gpgrt_fnameconcat and gpgrt_absfnameconcat.Werner Koch9-0/+318
* src/gpg-error.h.in (gpgrt_fnameconcat): New. (gpgrt_absfnameconcat): New. * src/visibility.c (gpgrt_fnameconcat, gpgrt_absfnameconcat): New. * src/stringutils.c: New file. (_gpgrt_vfnameconcat): New. (_gpgrt_fnameconcat, _gpgrt_absfnameconcat): New. * src/gpg-error.def.in: Add new functions. * src/gpg-error.vers: Ditto. * src/sysutils.c: Include pwd.h. (_gpgrt_getpwdir): New. * configure.ac: Test for pwd.h, getpwnam, getpwuid, and their _r variants. * src/Makefile.am (libgpg_error_la_SOURCES): Add new file. * tests/t-stringutils.c: New. * tests/t-common.h (xmalloc, xstrdup, xfree): New. (die): Kludge to avoid compiler warnings. -- The new functions are based on the code of make_filename from GnuPG. They have been written by me ages ago with only minor modifications by David Shaw. I re-license them from LGPL-3.0+ OR GPL-2.0+ to LGPL-2.1-or-later. Signed-off-by: Werner Koch <[email protected]>
2020-02-18w32: Support static link with -lws2_32.NIIBE Yutaka2-2/+3
* configure.ac (GPG_ERROR_CONFIG_LIBS_PRIVATE): New. * src/Makefile.am (socklibs): Use GPG_ERROR_CONFIG_LIBS_PRIVATE. * src/gpg-error.pc.in: Require @GPG_ERROR_CONFIG_LIBS_PRIVATE@. -- GnuPG-bug-id: 4623 Signed-off-by: NIIBE Yutaka <[email protected]>
2020-02-10logging: Also protect gpgrt_inc_errorcount against counter overflow.Werner Koch1-7/+5
* src/logging.c (_gpgrt_inc_errorcount): Protect against counter overflow. (_gpgrt_logv_internal): Use that function here so that we have only one check for counter overflow. -- We already had an overflow checking for log_error but not for the silent increment function. Signed-off-by: Werner Koch <[email protected]>
2020-02-06tools: Allow error symbol lookup w/o the GPG_ERR_ prefix.Werner Koch1-0/+71
* src/gpg-error.c (get_err_from_codesymbol): New. (main): Use it here. -- Saves lot of typing for example when looking up an error description using --desc. Signed-off-by: Werner Koch <[email protected]>
2020-02-06build: Always pass -no-undefined to libtool.Werner Koch1-3/+1
* src/Makefile.am: Remove no_undefined macro. -- This helps to build on Cygwin and does the right thing anyway because we do not have any dependencies in gpgrt. Thanks to Michael Haubenwaller to explain this and propose a patch. GnuPG-bug-id: 4474 Signed-off-by: Werner Koch <[email protected]>
2020-01-07build: Don't use -O0 which is not portable.NIIBE Yutaka1-1/+1
* src/Makefile.am (mkheader): Remove -O0 option. Signed-off-by: NIIBE Yutaka <[email protected]>
2019-12-13New error codes for SQLiteWerner Koch2-1/+48
* src/err-codes.h.in: Add GPG_ERR_SQL_ codes. * src/gpg-error.h.in (gpg_err_code_from_sqlite): New. Signed-off-by: Werner Koch <[email protected]>
2019-09-24Fix gpg-error.c for preprocessor use.NIIBE Yutaka1-4/+4
* src/gpg-error.c (main): Fix conditional compilation. -- Reported-by: Rey Abeleda <[email protected]> Signed-off-by: NIIBE Yutaka <[email protected]>
2019-09-18gpgrt_setenv: Define behavior when value=NULL.NIIBE Yutaka1-1/+1
* src/sysutils.c (_gpgrt_setenv): Avoid call with value=NULL. GnuPG-bug-id: 4698 Signed-off-by: NIIBE Yutaka <[email protected]>
2019-09-18logging: Fix the case of using socket_dir_cb which may return NULL.NIIBE Yutaka1-3/+4
* src/logging.c (fun_writer): Fix for socket_dir_cb. GnuPG-bug-id: 4698 Signed-off-by: NIIBE Yutaka <[email protected]>
2019-09-18estream: Care about erroneous case for stream close.NIIBE Yutaka1-10/+5
* src/estream.c (do_list_remove): Only access ITEM->NEXT when it's not null. GnuPG-bug-id: 4698 Signed-off-by: NIIBE Yutaka <[email protected]>
2019-09-10core: Fix broken strings (first letter missing)Werner Koch1-1/+1
src/err-codes.h.in (GPG_ERR_KEYBOXD): Add missing tabs. -- Fixes-commit: c6d9598a8572e7757504ddf53c01dcf611228143 Signed-off-by: Werner Koch <[email protected]>
2019-09-08estream: Fix dead assigniment.Werner Koch1-1/+0
* src/estream-printf.c (pr_string): Here. -- GnuPG-bug-id: 4698 Signed-off-by: Werner Koch <[email protected]>
2019-09-04gpgrt-config: Support Libs.private and Requires.private.NIIBE Yutaka1-0/+20
* src/gpgrt-config.in: Support Libs.private and Requires.private. Signed-off-by: NIIBE Yutaka <[email protected]>
2019-08-23estream: Fix gpgrt_poll at EOF.NIIBE Yutaka1-1/+1
* src/estream.c [HAVE_POLL_H] (_gpgrt_poll): Catch POLLHUP event for want_read. -- At EOF, here is a difference of semantics between poll(2) and select(2). For poll(2), detection of EOF is an event of POLLHUP, not POLLIN. Fixes-commit: a21a7de8c2cf986235382e7e04805744f6df116e Signed-off-by: NIIBE Yutaka <[email protected]>
2019-08-23estream: Fix gpgrt_poll to prevent waiting indefinitely for others.NIIBE Yutaka1-0/+3
* src/estream.c (_gpgrt_poll): Go to leave, when something is ready. Signed-off-by: NIIBE Yutaka <[email protected]>
2019-08-22estream: Fix poll condition.NIIBE Yutaka1-3/+4
* src/estream.c (_gpgrt_poll): Fix for want_oob. Signed-off-by: NIIBE Yutaka <[email protected]>
2019-08-05New error codes NO_KEYBOXD, KEYBOXD, NO_SERVICE, and SERVICE.Werner Koch1-0/+4
--
2019-07-25w32: Fix cast to internal fd.NIIBE Yutaka1-1/+1
* src/estream.c (tmpfd): Use intptr_t. Signed-off-by: NIIBE Yutaka <[email protected]>
2019-07-25estream: Fix IS_INVALID_FD.NIIBE Yutaka1-5/+1
* src/estream.c (IS_INVALID_FD): Simply compare to -1. -- Perhaps, when it was written at first, use of HANDLE was in mind. Now, we have different set of methods for Windows, and this macro is only for integer fd access, no need of ifdef/endif. Signed-off-by: NIIBE Yutaka <[email protected]>
2019-07-24w32: Fix HANDLE to internal fd conversion.NIIBE Yutaka1-6/+21
* src/spawn-w32.c (handle_to_fd): Use intptr_t type. -- See the section of _open_osfhandle in C Run-Time Library Reference. Signed-off-by: NIIBE Yutaka <[email protected]>