| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/name-value.c: New.
* tests/t-name-value.c: New.
* src/gpg-error.def.in: Add new functions.
* src/gpg-error.h.in: Ditto.
* src/gpg-error.vers: Ditto.
* src/visibility.c: Ditto.
* src/visibility.h: Ditto.
--
These new functions were originally added to GnuPG taken from current
GnuPG master. The license has been changed from (LGPL-3.0-or-later OR
GPL-2.0-or-later) to LGPL-2.1-or-later: Everything was written by me
or employees/contractors of g10 Code GmbH. The private key handling
has been removed because that would require Libgcrypt functions. Some
functions are changed.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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/gpg-error.def.in: Rename to gpgrt_spawn_actions_set_env_rev.
* src/gpg-error.h.in: Likewise.
* src/gpg-error.vers: Likewise.
* src/gpgrt-int.h: Likewise.
* src/spawn-posix.c: Likewise.
* src/spawn-w32.c: Likewise.
* src/visibility.c: Likewise.
* src/visibility.h: Likewise.
* tests/t-spawn.c (run_test): Use gpgrt_spawn_actions_set_env_rev.
--
Fixes-commit: 1860f6407f834b681c21f67db7236eaad161524c
GnuPG-bug-id: 7307
Signed-off-by: NIIBE Yutaka <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/gpg-error.def.in (gpgrt_spawn_actions_set_envchange): New.
* src/gpg-error.vers (gpgrt_spawn_actions_set_envchange): New.
* src/gpg-error.h.in (gpgrt_spawn_actions_set_envchange): New.
* src/gpgrt-int.h (_gpgrt_spawn_actions_set_envchange): New.
* src/spawn-posix.c (struct gpgrt_spawn_actions): New field ENVCHANGE.
(prepare_environ): New.
(my_exec): Take care of ENVCHANGE.
(_gpgrt_spawn_actions_set_envchange): New.
* src/spawn-w32.c (struct gpgrt_spawn_actions): New field ENVCHANGE.
(prepare_env_block): New.
(_gpgrt_spawn_actions_set_envchange): New.
(spawn_detached, _gpgrt_process_spawn): Take care of ENVCHANGE.
* src/visibility.c (gpgrt_spawn_actions_set_envchange): New.
* src/visibility.h (gpgrt_spawn_actions_set_envchange): New.
* tests/Makefile.am (TESTS): Add t-spawn.
* tests/t-spawn.c: New.
--
GnuPG-bug-id: 7307
Signed-off-by: NIIBE Yutaka <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/gpg-error.def.in: Update.
* src/gpg-error.h.in: Add declarations.
* src/gpg-error.vers: Update.
* src/visibility.c: Update.
* src/visibility.h: Update.
--
Signed-off-by: NIIBE Yutaka <[email protected]>
|
|
|
|
|
|
| |
--
Signed-off-by: NIIBE Yutaka <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/gpg-error.def.in: Update.
* src/gpg-error.vers: Update.
* src/gpg-error.h.in: Add declarations.
* src/visibility.c: Add implementations.
* src/visibility.h: Expose them.
--
GnuPG-bug-id: 6249
Signed-off-by: NIIBE Yutaka <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/gpgrt-int.h (_gpgrt_spawn_actions_set_envvars)
[HAVE_W32_SYSTEM]: Assume use with GetEnvironmentStrings.
(_gpgrt_spawn_actions_set_environ) [!HAVE_W32_SYSTEM]:
New.
* src/spawn-posix.c: Follow the change.
* src/spawn-w32.c: Can specify envvars now.
--
Signed-off-by: NIIBE Yutaka <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/gpg-error.h.in (@define:struct_spawn_cb_arg@): Remove.
(gpgrt_spawn_actions_t): New.
(@define:spawn_actions_functions@): New.
* src/gpgrt-int.h (_gpgrt_spawn_actions_new)
(_gpgrt_spawn_actions_release, _gpgrt_spawn_actions_set_envvars)
(_gpgrt_spawn_actions_set_redirect): New.
[HAVE_W32_SYSTEM] (_gpgrt_spawn_actions_set_inherit_handles): New.
[!HAVE_W32_SYSTEM] (_gpgrt_spawn_actions_set_inherit_fds)
(_gpgrt_spawn_actions_set_atfork): New.
(_gpgrt_process_spawn): Use gpgrt_spawn_actions_t.
(_gpgrt_spawn_helper): Remove.
* src/mkheader.c: Emit gpgrt_spawn_actions_* definition.
* src/spawn-posix.c(_gpgrt_spawn_actions_new)
(_gpgrt_spawn_actions_release, _gpgrt_spawn_actions_set_envvars)
(_gpgrt_spawn_actions_set_redirect)
(_gpgrt_spawn_actions_set_inherit_fds)
(_gpgrt_spawn_actions_set_atfork): New.
(spawn_detached, _gpgrt_process_spawn): Use gpgrt_spawn_actions_t.
(_gpgrt_spawn_helper): Remove.
* src/spawn-w32.c: Ditto, with
_gpgrt_spawn_actions_set_inherit_handles, but no
_gpgrt_spawn_actions_set_atfork.
--
GnuPG-bug-id: 6249
Signed-off-by: NIIBE Yutaka <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/gpg-error.h.in (@define:gpgrt_process_t@): Remove.
(@define:struct_spawn_cb_arg@): New.
(enum gpgrt_process_requests): New.
(GPGRT_PROCESS_DETACHED, GPGRT_PROCESS_STDIN_PIPE)
(GPGRT_PROCESS_STDOUT_PIPE, GPGRT_PROCESS_STDERR_PIPE)
(GPGRT_PROCESS_STDINOUT_SOCKETPAIR, GPGRT_PROCESS_STDIN_KEEP)
(GPGRT_PROCESS_STDOUT_KEEP, GPGRT_PROCESS_STDERR_KEEP)
(GPGRT_PROCESS_STDFDS_SETTING, GPGRT_PROCESS_STREAM_NONBLOCK):
New.
* src/gpgrt-int.h (_gpgrt_process_spawn, _gpgrt_process_terminate)
(_gpgrt_process_get_fds, _gpgrt_process_get_streams)
(_gpgrt_process_ctl, _gpgrt_process_wait, _gpgrt_process_release)
(_gpgrt_process_wait_list, _gpgrt_spawn_helper): New.
* src/mkheader.c: Emit definition of struct_spawn_cb_arg.
* src/spawn-posix.c (_gpgrt_process_spawn, _gpgrt_process_terminate)
(_gpgrt_process_get_fds, _gpgrt_process_get_streams)
(_gpgrt_process_ctl, _gpgrt_process_wait, _gpgrt_process_release)
(_gpgrt_process_wait_list, _gpgrt_spawn_helper): New.
* src/spawn-w32.c: Ditto.
--
GnuPG-bug-id: 6249
Signed-off-by: NIIBE Yutaka <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/gpg-error.h.in (gpgrt_add_post_log_func): New.
* src/gpg-error.vers: Add new function
* src/gpg-error.def.in: Ditto.
* src/visibility.c (gpgrt_add_post_log_func): New.
* src/logging.c (struct post_log_func_item_s): New.
(post_log_func_list): New.
(_gpgrt_add_post_log_func): new.
(run_post_log_funcs): New.
(_gpgrt_logv_internal): Call for fatal and bug log levels.
--
This is required in case an application or library needs to do do some
quick cleanups after a log_fatal.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/gpgrt-int.h (struct _gpgrt_stream_internal): Add field "wipe".
* src/estream.c (mem_free2): New.
(struct estream_cookie_mem): Add flag "wipe".
(func_mem_create): Add arg wipe.
(func_mem_destroy): Wipe.
(X_WIPE): New.
(parse_mode): Parse "wipe" mode flag.
(init_stream_obj): Set it.
(do_close): Wipe internal struct with its static buffers.
(doreadline): Pass wipe mode along to help buffer.
(_gpgrt_mopen): Pass wipe mode.
(_gpgrt_fopenmem): Ditto.
--
GnuPG-bug-id: 6954
This is likely not complete but should wipe out buffers allocated by
fopenmem.
|
|
|
|
|
|
|
|
|
|
|
| |
* src/init.c (_gpgrt_wipememory): New.
* src/visibility.c (gpgrt_wipememory): New.
* src/visibility.h: Add it.
* src/gpg-error.def.in: Ditto.
* src/gpg-error.vers: Ditto.
--
GnuPG-bug-id: 6954
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* configure.ac (AC_FUNC_FORK): No use.
* src/gpg-error.h.in (@define:gpgrt_process_t@): New.
(@define:pid_t@): Remove.
(gpgrt_spawn_process, gpgrt_spawn_process_fd): Use gpgrt_process_t.
(gpgrt_wait_process, gpgrt_wait_processes): Likewise.
(gpgrt_kill_process, gpgrt_release_process): Likewise.
* src/gpgrt-int.h (_gpgrt_spawn_process): Likewise.
(_gpgrt_spawn_process_fd): Likewise.
(_gpgrt_wait_process, _gpgrt_wait_processes): Likewise.
(_gpgrt_kill_process, _gpgrt_release_process): Likewise.
* src/mkheader.c (write_special): Handle @define:gpgrt_process_t@.
Remove handling of @define:pid_t@.
* src/spawn-posix.c (_gpgrt_spawn_process): Use gpgrt_process_t.
(_gpgrt_spawn_process_fd): Likewise.
(_gpgrt_wait_process, _gpgrt_wait_processes): Likewise.
(_gpgrt_kill_process, _gpgrt_release_process): Likewise.
* src/spawn-w32.c (_gpgrt_spawn_process): Use gpgrt_process_t.
(_gpgrt_spawn_process_fd): Likewise.
(_gpgrt_wait_process, _gpgrt_wait_processes): Likewise.
(_gpgrt_kill_process, _gpgrt_release_process): Likewise.
--
GnuPG-bug-id: 6249
Signed-off-by: NIIBE Yutaka <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/gpg-error.def.in (gpgrt_close_all_fds): New.
* src/gpg-error.vers (gpgrt_close_all_fds): New.
* src/gpg-error.h.in (GPGRT_SPAWN_INHERIT_FILE): New.
(gpgrt_spawn_process_fd): SPAWN_CB having return value.
* src/gpgrt-int.h (_gpgrt_spawn_process_fd): SPAWN_CB change.
* src/spawn-posix.c (_gpgrt_close_all_fds): Rename from close_all_fds,
and export it.
(do_exec): Support the case not closing fds.
(_gpgrt_spawn_process_fd): Handle return value of SPAWN_CB to
determine closing all fds or not.
* src/spawn-w32.c (_gpgrt_spawn_process_fd): Run SPAWN_CB.
(_gpgrt_close_all_fds): New.
* src/visibility.c (gpgrt_close_all_fds): New.
* src/visibility.h (gpgrt_close_all_fds): New.
--
Now, we have the API of gpgrt_spawn_process_fd for POSIX and Windows.
Giving portable semantics for spawning a process is difficult, and it
is still difficult for users to writing a function for SPAWN_CB with
portability, but gpgrt_spawn_process_fd gives the feature of spawning
a process.
GnuPG-bug-id: 6249
Signed-off-by: NIIBE Yutaka <[email protected]>
|
|
|
|
|
|
| |
--
Signed-off-by: NIIBE Yutaka <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/gpg-error.h.in (gpgrt_spawn_process): Remove PREEXEC argument.
(gpgrt_spawn_process_fd): Add AFTER_FORK_CB and AFTER_FORK_CB_ARG.
* src/gpgrt-int.h (_gpgrt_spawn_process): Remove PREEXEC argument.
(_gpgrt_spawn_process_fd): Add AFTER_FORK_CB and AFTER_FORK_CB_ARG.
* src/spawn-posix.c (do_exec): Remove PREEXEC argument.
(_gpgrt_spawn_process): Remove PREEXEC argument.
(_gpgrt_spawn_process_fd): Add AFTER_FORK_CB and AFTER_FORK_CB_ARG.
(_gpgrt_spawn_process_detached): Follow the change of do_exec.
* src/spawn-w32.c (_gpgrt_spawn_process): Remove PREEXEC argument.
(_gpgrt_spawn_process_fd): Add AFTER_FORK_CB and AFTER_FORK_CB_ARG.
* src/visibility.c (gpgrt_spawn_process): Remove PREEXEC argument.
(gpgrt_spawn_process_fd): Add AFTER_FORK_CB and AFTER_FORK_CB_ARG.
--
GnuPG-bug-id: 6249
Signed-off-by: NIIBE Yutaka <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/gpg-error.h.in (GPGRT_SPAWN_KEEP_STDIN): New.
(GPGRT_SPAWN_KEEP_STDOUT, GPGRT_SPAWN_KEEP_STDERR): New.
* src/gpgrt-int.h: Add comment.
* src/spawn-posix.c (do_exec): Add the argument FLAGS.
(_gpgrt_spawn_process): Add FLAGS.
(_gpgrt_spawn_process_fd): Follow the change.
(_gpgrt_spawn_process_detached): Likewise.
* src/spawn-w32.c (_gpgrt_spawn_process): Handle FLAGS.
--
This commit imports GnuPG master commit of:
6d6438a361d25f3b269f702e017f5e39fd1f5c38
GnuPG-bug-id: 6249
Signed-off-by: NIIBE Yutaka <[email protected]>
|
|
|
|
|
|
|
|
|
| |
* src/gpgrt-int.h: Remove extra.
* src/visibility.h: Likewise.
--
Signed-off-by: NIIBE Yutaka <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* contrib/*: Remove.
* Makefile.am: Remove contrib.
* autogen.sh: Remove Windows CE support.
* configure.ac (have_w32ce_system): Remove.
* src/Makefile.am [HAVE_W32CE_SYSTEM] (extra_cppflags): Remove.
(gpg_extra_headers): Remove.
(EXTRA_DIST): Remove mkw32errmap.c and w32ce-add.h
(BUILT_SOURCES): Remove mkw32errmap.map.c.
(tmp_files): Remove mkw32errmap.tab.h mkw32errmap.map.c
(CLEANFILES): Likewise.
* src/estream-printf.c [HAVE_W32CE_SYSTEM]: Remove.
* src/estream.c [HAVE_W32CE_SYSTEM]: Remove.
* src/gpg-error.def.in [HAVE_W32CE_SYSTEM]: Remove.
* src/gpgrt-int.h: Fix comment.
* src/init.c [HAVE_W32CE_SYSTEM]: Remove.
* src/init.h [HAVE_W32CE_SYSTEM]: Remove.
* src/mkheader.c: Remove Windows CE support.
* src/mkw32errmap.c, src/w32ce-add.h: Remove.
* src/spawn-posix.c [HAVE_W32CE_SYSTEM]: Remove.
* src/spawn-w32.c [HAVE_W32CE_SYSTEM]: Remove.
* src/sysutils.c [HAVE_W32CE_SYSTEM]: Remove.
* src/w32-estream.c [HAVE_W32CE_SYSTEM]: Remove.
* src/w32-reg.c [HAVE_W32CE_SYSTEM]: Remove.
* tests/Makefile.am [HAVE_W32CE_SYSTEM]: Remove.
--
GnuPG-bug-id: 5912
Signed-off-by: NIIBE Yutaka <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/mkheader.c (write_special): Support @SOCKET_t@ substitution.
* src/gpgrt-int.h (gpgrt_stream_backend_kind_t): Add BACKEND_SOCK.
* src/gpg-error.h.in (struct _gpgrt_syshd): Use @SOCKET_t@.
* src/estream.c [HAVE_W32_SYSTEM] (estream_cookie_sock_t): New.
[HAVE_W32_SYSTEM] (func_sock_create, func_sock_read): New.
[HAVE_W32_SYSTEM] (func_sock_write, func_sock_seek): New.
[HAVE_W32_SYSTEM] (func_sock_destroy, func_sock_ioctl): New.
[HAVE_W32_SYSTEM] (estream_functions_sock, do_sockopen): New.
[HAVE_W32_SYSTEM] (do_sysopen): Call do_sockopen.
--
Signed-off-by: NIIBE Yutaka <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/sysutils.c (any8bitchar): Remove.
(_gpgrt_fname_to_wchar): New.
(_gpgrt_mkdir): Use instead of plain utf8 conversion.
(_gpgrt_access): Reimplement using GetFileAttributesW so that long
files names are supported.
* src/estream.c (_gpgrt_w32_get_last_err_code): New.
(func_file_create_w32): New.
(_gpgrt_fopen): Handle the "sysopen" mode flag. Support mapping of
/dev/null.
(_gpgrt_freopen): Support mapping of /dev/null.
* src/w32-gettext.c (load_domain): Allow long file names.
* src/visibility.c (gpgrt_free_wchar): Make function public.
(gpgrt_fname_to_wchar): Ditto.
(gpgrt_utf8_to_wchar): Ditto.
(gpgrt_wchar_to_utf8): Ditto.
* src/w32-add.h (gpgrt_free_wchar): New prototype.
(gpgrt_fname_to_wchar): Ditto.
(gpgrt_utf8_to_wchar): Ditto.
(gpgrt_wchar_to_utf8): Ditto.
* src/gpg-error.def.in: Add them here too.
|
|
|
|
|
|
|
|
|
|
| |
* src/w32-reg.c (_gpgrt_w32_reg_query_string): Allow abbreviated root
names.
(_gpgrt_w32_reg_get_string): New.
--
This should eventually be made public. Noet that we have a copy in
gnupg.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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/protos.h: New.
* src/Makefile.am (libgpg_error_la_SOURCES): Add file.
* src/gpgrt-int.h: Include protos.h.
* src/sysutils.c (_gpgrt_mkdir) [W32]: Make UTF-8 aware.
(_gpgrt_chdir) [W32]: Ditto.
* src/w32-gettext.c: Include protos.h.
(utf8_to_wchar): Allow for strings.
(_gpgrt_utf8_to_wchar): New.
(_gpgrt_free_wchar): New.
* src/estream.c (map_w32_to_errno): Add more error codes.
(_gpgrt_w32_set_errno): New.
(any8bitchar) [W32]: New helper.
(func_file_create) [W32]: Convert file name and use _wopen.
--
GnuPG-bug-id: 4083
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/estream.c (do_close): Add arg 'cancel_mode' and chnage all
callers.
(_gpgrt_fcancel): New.
* src/gpg-error.def.in, src/gpg-error.vers: Add function.
* src/visibility.c (gpgrt_fcancel): New.
* src/gpg-error.h.in (gpgrt_fcancel): New.
--
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/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]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.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]>
|
|
|
|
|
|
| |
* src/gpgrt-int.h (struct _gpgrt_b64state): Use unsigned for bit flags.
Signed-off-by: NIIBE Yutaka <[email protected]>
|
|
|
|
|
|
|
|
| |
* src/gpgrt-int.h (BUFFER_BLOCK_SIZE) [W32]: Increase from 512 to 8k.
* src/w32-estream.c (READBUF_SIZE, WRITEBUF_SIZE): Increase from 4k to
8k.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
| |
* src/gpgrt-int.h (_gpgrt_functions_w32_pollable): Declare with extern
so that strict toolchains don't get confused.
--
GnuPG-bug-id: 4356
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/init.c (emergency_cleanup_list): New gloabl var.
(_gpgrt_add_emergency_cleanup): New.
(_gpgrt_abort): New. Repalce all calls to abort by this. Also replace
all assert by either log_assert or a stderr output followed by a
_gpgrt_abort.
(run_emergency_cleanup): New.
* src/visibility.c (gpgrt_add_emergency_cleanup): New public API.
(gpgrt_abort): New public API.
--
Libgcrypt uses its own assert function which makes sure to terminate
the secure memory. This is safe as log as an assert is triggered
internally in Libgcrypt. GnuPG runs emergency cleanup handlers right
before log_fatal etc to tell Libgcrypt to terminate the secure memory.
With the move of the logging function to gpgrt in gnupg 2.3 this did
not anymore. Thus we now provide a mechanism in gpgrt to do right
that. Eventually Libgcrypt can also make use of this.
What this does not handle are calls to abort or failed asserts in
external libraries or in libc. We can't do anything about it in a
library because a library may not setup signal handlers.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
| |
* src/gpgrt-int.h: First undef snprintf.
--
GnuPG-bug-id: 4285
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/gpg-error.h.in (gpgrt_string_filter_t): New type.
(gpgrt_fprintf_sf, gpgrt_fprintf_sf_unlocked): New.
* src/gpg-error.vers, src/gpg-error.def.in: Add them.
* src/visibility.c (gpgrt_fprintf_sf): New.
(gpgrt_fprintf_sf_unlocked): New.
* src/estream-printf.c (pr_string): Add and use args sf, sfvalue and
string_no.
(do_format): Add args sf and sfvalue. Keep a string format counter.
(_gpgrt_estream_format): Add args sf and sfvalue. Change all callers
to provide NULL for them.
* src/estream.c (_gpgrt_vfprintf_unlocked, _gpgrt_vfprintf): Add sf
and sfvalue and adjust all callers.
(do_print_stream): Ditto.
* tests/t-printf.c (stream_to_string): New.
(struct sfstate_s): New.
(string_filter): New.
(check_fprintf_sf): New.
(main): Call new test.
--
The actual reason to implement these functions is to enhance the
internal logging function with a filter to sanitized strings so that
control values or other things can be quoted.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/gpg-error.h.in (gpgrt_ftruncate, es_ftruncate): New.
* src/gpg-error.def.in, src/gpg-error.vers: Add gpgrt_ftruncate.
* src/visibility.c (gpgrt_ftruncate): new.
* src/gpgrt-int.h (COOKIE_IOCTL_TRUNCATE): New.
* src/estream.c (func_mem_ioctl): Support new internal IOCTL.
(_gpgrt_ftruncate): New.
--
Right now the ftruncate works only on memory streams. Can easily be
added to other stream times.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/gpg-error.h.in: New API gpgrt_cmp_version.
* src/visibility.c (gpgrt_cmp_version): New wrapper.
* src/version.c (parse_version_string): Revamped.
(do_cmp_version): New.
(_gpgrt_cmp_version): New.
(_gpg_error_check_version): Re-implemented using the new func.
* tests/t-version.c: Include t-common.h.
(t_gpgrt_cmp_version): New test.
(main): Run new test. Change test for new version number to require a
2 level number.
--
We have implementations of very similar functions in all out libs.
Thus it makes sense to provide a generic version. This version is
actually derived from the ftp-indexer.c we use for the gnupg
website (see the gnupg-doc repo).
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/b64enc.c: Change to fit into libgpg-error.
* src/Makefile.am: Add b64enc.c
* src/b64dec.c: Use xtrymalloc etc. Always use gpg_err_code_t.
(_gpgrt_b64dec_start): Set decoder flag
(_gpgrt_b64dec_finish): Check for conflict.
(_gpgrt_b64state): Move to ...
* src/gpgrt-int.h: here. Add new fields.
* src/visibility.c (gpgrt_b64enc_start): New.
(gpgrt_b64enc_write): New.
(gpgrt_b64enc_finish): New.
* src/gpg-error.vers, src/gpg-error.def.in: Add new functions.
* src/gpg-error.h.in: Ditto.
* src/visibility.h: Ditto.
* tests/t-b64dec.c: Remove.
* tests/t-b64.c: New.
* tests/Makefile.am (TESTS): Replace t-b64dec by t-b64.
--
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
| |
* src/visibility.c (gpgrt_usage): New.
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]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/estream.c (_gpgrt_set_syscall_clamp)
(_gpgrt_get_syscall_clamp): Move to ...
* src/syscall-clamp.c: new file.
(_gpgrt_pre_syscall, _gpgrt_post_syscall): New.
* src/Makefile.am (libgpg_error_la_SOURCES): Add that file.
* src/estream.c: Replace the syscall wrapper with the new functions.
* src/posix-lock.c: Ditto.
* src/w32-lock.c: Ditto.
* src/posix-thread.c: Ditto.
* src/w32-thread.c: Ditto.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/gpg-error.h.in (GPGRT_SPAWN_NONBLOCK): New const.
(GPGRT_SPAWN_RUN_ASFW): New const.
(GPGRT_SPAWN_DETACHED): New const.
(gpgrt_make_pipe): New function.
(gpgrt_create_pipe): New macro.
(gpgrt_create_inbound_pipe): New macro.
(gpgrt_create_outbound_pipe): New macro.
(gpgrt_spawn_process): New function.
(gpgrt_spawn_process_fd): New function.
(gpgrt_spawn_process_detached): New function.
(gpgrt_wait_process): New function.
(gpgrt_wait_processes): New function.
(gpgrt_kill_process): New function.
(gpgrt_release_process): New function.
* src/gpg-error.def.in, src/gpg-error.vers: Add new functions.
* src/visibility.c, src/visibility.h: Add wrappers for new functions.
* src/spawn-posix.c: Rework to better fit the use in gpgrt. Rename
all public function with a _gpgrt prefix.
* src/spawn-w32.c: Ditto.
* src/gpgrt-int.h: Likewise.
* src/Makefile.am (arch_sources): Add spawn-posix.c and spawn-w32.c.
* src/w32-add.h: Add pid_t typedef as a temporary hack.
* configure.ac: Check for signal.h and getrlimit.
(AC_FUNC_FORK): New.
--
This does build but porting the tests and further changes are
required. Don't assume that the API for the new fucntions is stable.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/spawn-posix.c: New. Taken from GnuPG's exechelp-posix.c.
* src/spawn-w32.c: New. Taken from GnuPG's exechelp-w32.c.
* src/gpgrt-int.h: Include prototypes from GnuPG's exechelp.h.
--
The original files were under (LGPL-3.0+ OR GPL-2.0+) and have
entirely been written by g10 Code employees. Being the responsible
person at g10 Code, I endorse the license change to LGPL-2.1.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/gpg-error.h.in (gpgrt_sentenv, gpgrt_mkdir, gpgrt_chdir): Change
return type to gpg_err_code_t.
* src/sysutils.c (_gpgrt_setenv): Implement that.
(_gpgrt_mkdir): Ditto.
(_gpgrt_chdir): Ditto.
* gpgscm/ffi.c (do_setenv, do_mkdir): Adjust for this change.
--
The functions are already a bit different and thus it is useful to let
them return a gpg-error style error code and don't let the user
implement that for each call.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/gpg-error.h.in (gpgrt_mkdir, gpgrt_chdir, gpgrt_getcwd): New.
* src/visibility.c, src/visibility.h: Add wrappers.
* src/gpg-error.vers, src/gpg-error.def.in: Add them.
* src/sysutils.c (modestr_to_mode): New.
(_gpgrt_mkdir, _gpgrt_chdir, _gpgrt_getcwd): New.
* m4/gnupg-misc.m4: New.
* m4/Makefile.am (EXTRA_DIST): Add new M4 file.
* configure.ac: Call new GNUPG_FUNC_MKDIR_TAKES_ONE_ARG.
(AC_CHECK_FUNCS): Add stat.
--
The code has been taken from GnuPG. _gpgrt_mkdir was originally
written by me as gnupg_mkdir and here relicensed to LGPLv2.1+.
_gpgrt_getcwd was originally written by in 2007 and also here
relicensed to LGPLv2.1. The new M4 macro was also written by me for
use in in GnuPG; it has been taken from GnUPG's acinclude.m4, moved to
its own file here, and relicensed to FSFULLR.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/gpg-error.h.in (gpgrt_getenv, gpgrt_setenv): New.
(gpgrt_unsetenv): New macro.
* src/gpg-error.vers, src/gpg-error.def.in: Add them.
* src/visibility.c (gpgrt_getenv, gpgrt_setenv): New.
* src/visibility.h: Add them.
* src/sysutils.c: Include string.h and on Windows windows.h.
(_gpgrt_getenv): New.
(_gpgrt_setenv): New.
--
These functions are wrappers to cope with Windows problems. The code
is similar to what we have in GnuPG but not identical.
Requires better testing.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/w32-reg.c: New.
* src/w32-add.h: Add gpgrt_w32_reg_query_string.
* src/visibility.c (gpgrt_w32_reg_query_string): New wrapper.
* src/gpg-error.def.in: Add gpgrt_w32_reg_query_string.
* configure.ac (ac_check_funcs): Add stpcpy.
* src/Makefile.am (arch_sources): Add w32-reg.c
(socklibs): New.
(libgpg_error_la_LIBADD): Add socklibs.
* src/gpgrt-int.h (xfree, xtrymalloc, xtrycalloc)
(xtryrealloc): New internal macros.
(_gpgrt_stpcpy, stpcpy): New replacement fucntion and macro.
* src/logging.c (_gpgrt_logv_internal): Use new registry query
function and add standard registry key.
--
This also fixes the build failure on Widnwos for logging.c.
The code for gpgrt_w32_reg_query_string has been taken from the
function read_w32_registry_string in w32-utils.c in the GPGME package.
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/visibility.c (gpgrt_strdup): New API fucntion.
(gpgrt_strconcat): New API fucntion.
* src/visibility.h: Add corresponding macros.
* src/gpg-error.def.in: Add them.
* src/gpg-error.vers: Add them.
* src/gpgrt-int.h (DIM): New macro.
* src/init.c (_gpgrt_strdup): New.
(_gpgrt_strconcat_core): New.
(_gpgrt_strconcat): New.
--
Signed-off-by: Werner Koch <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/visibility.c (gpgrt_realloc): New API function.
(gpgrt_malloc): New API function.
(gpgrt_calloc): New API function.
* src/visibility.h: Add corresponding macros.
* src/gpg-error.def.in: Add them.
* src/gpg-error.vers: Add them.
* src/init.c (_gpgrt_calloc): New.
* src/gpg-error.h.in: Add prototypes.
Signed-off-by: Werner Koch <[email protected]>
|