aboutsummaryrefslogtreecommitdiffstats
path: root/common (unfollow)
Commit message (Collapse)AuthorFilesLines
2021-11-18common,w32: New function read_w32_reg_string.Werner Koch3-18/+74
* common/w32-reg.c (read_w32_reg_string): New. * common/t-w32-reg.c (test_read_registry): Add another test.
2021-11-18gpg,gpgsm: Add option --min-rsa-length.Werner Koch2-8/+27
* common/compliance.c (min_compliant_rsa_length): New. (gnupg_pk_is_compliant): Take in account. (gnupg_pk_is_allowed): Ditto. (gnupg_set_compliance_extra_info): New. * g10/gpg.c (oMinRSALength): New. (opts): Add --min-rsa-length. (main): Set value. * g10/options.h (opt): Add field min_rsa_length. * sm/gpgsm.c (oMinRSALength): New. (opts): Add --min-rsa-length. (main): Set value. * sm/gpgsm.h (opt): Add field min_rsa_length.
2021-11-02common: Support MYPROC_SELF_EXE for SolarisWerner Koch2-1/+3
* common/homedir.c (MYPROC_SELF_EXE): Add case for SunOS. -- GnuPG-bug-id: 5671
2021-11-02common: Silence warning from unix_rootdir on systems w/o /procWerner Koch1-4/+6
* common/homedir.c (unix_rootdir): Silence diagnostic in the common case. (MYPROC_SELF_EXE): Support NetBSD. -- GnuPG-bug-id: 5656
2021-11-02common: Respect gpgconf.ctl when looking up translationsIngo Klöcker1-3/+3
* common/i18n.c (i18n_init): Use gnupg_localedir() instead of LOCALEDIR. (i18n_localegettext): Ditto. * tools/gpgconf-comp.c (my_dgettext): Ditto. -- On Unix, gnupg_localedir() returns the locale directory relative to the root directory of the gnupg installation if specified in the gpgconf.ctl. Otherwise, it returns the built-in LOCALEDIR. GnuPG-bug-id: 5999
2021-11-02common: Support gpgconf.ctl also for BSDs.Werner Koch1-10/+25
* common/homedir.c (MYPROC_SELF_EXE): New. (unix_rootdir): Use it here. Also support GNUPG_BUILD_ROOT as fallback. -- In addition this adds a fallback method for AIX etc which do not have an easy way to get the info.
2021-11-02common: Add keyword sysconfdir to the optional gpgconf.ctl file.Werner Koch1-18/+69
* common/homedir.c (unix_rootdir): Add arg want_sysconfdir. (gnupg_sysconfdir): Return it. -- Our regression test suite has the problem that we can't disable the use of the global config files or test them using the regualr binaries. This new keyword will allow us to overcome the problem.
2021-11-02common: Support a gpgconf.ctl file under Unix.Werner Koch1-17/+252
* common/homedir.c (unix_rootdir): New. (gnupg_bindir): Use it. (gnupg_libexecdir): Use it. (gnupg_libdir): Use it. (gnupg_datadir): Use it. (gnupg_localedir): Use it. -- This feature is useful for building and using an AppImage version of gnupg and probably also for some other use cases. GnuPG-bug-id: 5999 Here is a sample gpgconf.ctl file --8<---------------cut here---------------start------------->8--- # gpgconf.ctl # # This file is used to change the directories where the gpg components # are installed. It does not change the configuration directories. # The file is expected in the same directory as gpgconf. The physical # installation directories are evaluated and no symlinks. Blank lines # and lines starting with pound signed are ignored. No errors are # printed for unknown keywords or commands. The only defined key for # now is "rootdir" which must be followed by one optional space, an # equal sign, and the value for the root directory. Environment # variables are substituted in standard shell manner, the final value # must start with a slash, trailing slashed are stripped. rootdir = $APPDIR/gnupg --8<---------------cut here---------------end--------------->8---
2021-11-02common: New function substitute_envvars.Werner Koch3-0/+206
* common/stringhelp.c (substitute_envvars): New. Based on code in gpg-connect-agent. * common/t-stringhelp.c: Include sysutils.h. (test_substitute_envvars): New. -- GnuPG-bug-id: 5599
2021-11-02common,w32: Do not always print "Garbled console data" warning.Werner Koch1-2/+8
* common/init.c (_init_common_subsystems): Silence message. --
2021-10-06dirmngr: New option --ignore-certWerner Koch1-1/+2
* dirmngr/dirmngr.h (struct fingerprint_list_s): Add field binlen. (opt): Add field ignored_certs. * dirmngr/dirmngr.c: Add option --ignore-cert (parse_rereadable_options): Handle that option. (parse_ocsp_signer): Rename to ... (parse_fingerprint_item): this and add two args. * dirmngr/certcache.c (put_cert): Ignore all to be igored certs. Change callers to handle the new error return. -- This option is useful as a workaround in case we ill run into other chain validation errors like what we fixed in GnuPG-bug-id: 5639 Backported-from-master: 4b3e9a44b58e74b3eb4a59f88ee017fe7483a17d
2021-09-13common: New envvar GNUPG_EXEC_DEBUG_FLAGS.Werner Koch1-4/+16
* common/exechelp-w32.c (gnupg_spawn_process_detached): Silence breakaway messages and turn them again into debug messages.
2021-08-27common: Fix put_membuf.NIIBE Yutaka1-1/+4
* common/membuf.c (put_membuf): Allow NULL for the second arg. -- Cherry-picked from master commit of: f271c6916469c0054c143adb4cee0588866a2a61 There has been such a use case in keybox-blob.c. Signed-off-by: NIIBE Yutaka <[email protected]>
2021-08-26common: Fix get_signal_name for GNU/Linux.NIIBE Yutaka1-1/+3
* common/signal.c (get_signal_name): Use sigdescr_np if available. * configure.ac: Check the function. -- Backport master commit of: c4ba712736ddeda66055567874d573e79d22666b GnuPG-bug-id: 5568 Signed-off-by: NIIBE Yutaka <[email protected]>
2021-08-20common: New function decode_c_string.Werner Koch2-0/+77
* common/miscellaneous.c (decode_c_string): New. -- This is basically a copy from the code we use in gpgme and gpa. Signed-off-by: Werner Koch <[email protected]> (cherry picked from commit 6ecedd0b25b6b1a33be63b99f2a8256370000521)
2021-08-20wkd: Fix client issue with leading or trailing spaces in user-ids.Werner Koch4-16/+194
* common/recsel.c (recsel_parse_expr): Add flag -t. * common/stringhelp.c (strtokenize): Factor code out to do_strtokenize. (strtokenize_nt): New. (do_strtokenize): Add arg trim to support the strtokenize_nt. * common/t-stringhelp.c (test_strtokenize_nt): New test cases. * tools/wks-util.c (wks_list_key): Use strtokenize_nt and the recsel flag -t. -- This fixes a bug with user ids with leading spaces because: wks-client lists all mail addresses from the key and matches them to the requested mail address. If there are several user-ids all with the same mail address wks-client picks one of them and then extracts exactly that user id. However, here it does not match by the mail address but by the full user-id so that we can be sure that there will be only one user-id in the final key. The filter built expression unfortunately strips leading blanks but requires a verbatim match. Thus it won't find the user id again and errors out. The new -t flag and a non-trimming strtokenize solves the problem. Signed-off-by: Werner Koch <[email protected]>
2021-08-18common,w32: Replace log_debug by log_info for InProcessJobsWerner Koch1-3/+3
* common/exechelp-w32.c (gnupg_spawn_process_detached): Use log_info.
2021-08-17w32: Move socketdir to LOCAL_APPDATAWerner Koch4-75/+158
* common/homedir.c (is_gnupg_default_homedir): Use standard_homedir instead of the constant which makes a difference on Windows. (_gnupg_socketdir_internal) [W32]: Move the directory to LOCAL_APPDATA. (gnupg_cachedir): Remove unsued function. * common/sysutils.c (gnupg_rmdir): New. * tools/gpgconf.c (main): s/rmdir/gnupg_rmdir/. -- That is actually a more correct directory than APPDATA. This fixes a problem with installations where the APPDATA is non a network drive and the resulting socket filename is truncated in our socket helper function (because we use sockaddr also for our local socket emulation on Windows). LOCAL_APPDATA is expected to be on the local box and thus in the majority of cases the resulting socket file name will be short enough. GnuPG-bug-id: 5537 Signed-off-by: Werner Koch <[email protected]> Backport-from-master: 0802cbb59b21e06e16b4fd8596934c5565e7f659
2021-08-16common: Pass XDG_SESSION_TYPE and QT_QPA_PLATFORM envvars to pinentryIngo Klöcker1-0/+5
* common/session-env.c (stdenvnames): Add XDG_SESSION_TYPE and QT_QPA_PLATFORM. -- On Unix systems (except Darwin), Qt uses those two environment variables additionally to DISPLAY and WAYLAND_DISPLAY to figure out whether to use X11 or Wayland. For example, QT_QPA_PLATFORM needs to be set to "wayland" to make Qt use Wayland on Gnome. GnuPG-bug-id: 3659
2021-06-22tests: Cope with broken Libgcrypt versionsWerner Koch1-11/+27
* common/t-sexputil.c (test_ecc_uncompress): Ignore unknwon curve errors. -- For unknown reasons some versions of Fedora or RHEL provide a patched version of Libgcrypt with Brainpool support removed. We better ignore this error because it is a regression in 2.2.28 although that older versions could not used Brainpool keys. GnuPG-bug-id: 5502 Signed-off-by: Werner Koch <[email protected]>
2021-06-22w32: Add fallback in case the Windows console can't cope with Unicode.Werner Koch1-4/+18
* common/ttyio.c (w32_write_console): Fallback to WriteConsoleA on error. -- To test this switch the Windows Console to "legacy mode" set LANG=de gpg --card-edit and enter an invalid command. The response contains an Umlaut and old Windows versions (and the legacy console) don't have a proper font installed for this. Without this patch this runs into a log_fatal error. The mitigation we implement is to fallback to WriteConsoleA, that is accepting wrong encoding and to print a note about the problem. GnuPG-bug-id: 5491
2021-06-10gpg: Partial fix for Unicode problem in output files.Werner Koch1-1/+1
* g10/openfile.c (overwrite_filep): Use gnupg_access. -- As said, this is just an obvious but partial fix. We need to review things for the output module. Signed-off-by: Werner Koch <[email protected]>
2021-06-08w32: Change spawn functions to use Unicode version of CreateProcess.Werner Koch1-47/+98
* common/exechelp-w32.c (gnupg_spawn_process): Change to use CreateProcessW. (gnupg_spawn_process_fd): Ditto. (gnupg_spawn_process_detached): Ditto. * g10/exec.c (w32_system): Ditto. -- GnuPG-bug-id: 4398 We do not use this weirdo CREATE_UNICODE_ENVIRONMENT flag because it does not make any sense to have non-ASCII names in the environment. I can't imagine why this should be used at all and rationale for this API features is, well, sparse. (cherry picked from commit cf2f6d8a3f0594c03c383b4989a3041e9c4536d7)
2021-06-08common,w32: Breakaway detached childs when in jobAndre Heinecke1-0/+45
* common/exechelp-w32.c (gnupg_spawn_process_detached): Add CREATE_BREAKAWAY_FROM_JOB creation flag if required. -- When the gpg process is assigned to a W32 "Job" the child processes are killed once the Job is finished. As we want our detached processes to linger e.g. gpg-agent the breakaway flag is required in that case. GnuPG-Bug-Id: T4333 Thanks to Jan Echternach for reporting this and providing a patch. Signed-off-by: Andre Heinecke <[email protected]> (cherry picked from commit 03df28b18b92b3fd3d2ba1000903c088dc5b0fcf)
2021-06-08w32: Always use Unicode for console input and output.Werner Koch1-0/+11
* common/init.c (_init_common_subsystems) [W32]: Set the codepage to UTF-8 for input and putput. Switch gettext to UTF-8. * g10/gpg.c (utf8_strings) [W32]: Make sure this is always set. -- With this patch the former patch to use ReadConsoleW and WriteConsoleW in ttyio.c are kind of superfluous because the ANSI version of these functions are also able to read/write UTF-8 directly given the console code page has been set correctly. However, this seems to work only with recent versions of Windows-10. GnuPG-bug-id: 4365 (cherry picked from commit 8c41b8aac3efb78178fe1eaf52d8d1bbc44941a8) Removed changes for "gpgconf --show-codepages" of the original patch.
2021-06-08w32: Free memory allocated by new function w32_write_console.Werner Koch1-0/+1
* common/ttyio.c (w32_write_console): Free buffer. -- (cherry picked from commit 31b708e268ebb725307856865f34a61670a35586)
2021-06-08common,w32: Allow Unicode input and output with the console.Werner Koch1-31/+73
* common/ttyio.c (do_get) [W32]: Use ReadConsoleW. (w32_write_console): New. (tty_printf, tty_fprintf) [W32]: Use new function. -- Note that due this change fixed stings (i.e. gettext translations) printed to the console will not be rendered correctly unless "chcp 65001" has been used. This needs to be fixed by followup patch. GnuPG-bug-id: 4365 (cherry picked from commit f165c8a737cc968554c9d78932c69869456108ff)
2021-06-08common: Re-indent ttyio.c and remove EMX, RISCOS, and CE supportWerner Koch1-310/+274
* common/ttyio.c: Remove cruft like EMX and RISCOS support. Translate a few strings. Re-indent. -- Backported-from-master: 8622f53994249d8fb49a488cfe480ffbeb8cbfba
2021-06-08common: Rename w32-misc.c to w32-cmdline.cWerner Koch3-4/+4
* common/w32-misc.c: Rename to .... * common/w32-cmdline.c: this. * common/Makefile.am: Adjust. -- (cherry picked from commit 7262d602d802c4a3840097d5de217fcfb9728b49)
2021-06-08common,w32: Implement globing of command line args.Werner Koch6-18/+380
* common/w32-misc.c [W32]: Include windows.h (struct add_arg_s): New. (add_arg): New. (glob_arg): New. (parse_cmdstring): Add arg argvflags and set it. (w32_parse_commandline): Add arg r_itemsalloced. Add globing. * common/init.c (prepare_w32_commandline): Mark glob created items as leaked. * common/t-w32-cmdline.c : Include windows.h (test_all): Add simple glob test for Unix. (main): Add manual test mode for Windows. * common/xasprintf.c (xtryreallocarray): New. -- GnuPG-bug-id: 4398 Backported-from-master: 089c9439674e8ecbc64f0ba924e6fb447bbc2b9d)
2021-06-08common,w32: Refine the command line parsing for \ in quotes.Werner Koch2-6/+33
* common/t-w32-cmdline.c (test_all): Add new test cases. * common/w32-misc.c (strip_one_arg): Add arg endquote. (parse_cmdstring): Take care of backslashes in quotes. -- I found some new test vectors from Microsoft. (cherry picked from commit 20c60076866904187a09393de596deef286116f8)
2021-06-08common: First take on handling Unicode command line args.Werner Koch5-6/+459
* common/w32-misc.c: New. * common/t-w32-cmdline.c: New. * common/init.c: Include w32help.h. (prepare_w32_commandline): New. (_init_common_subsystems) [W32]: Call prepare_w32_commandline. * common/Makefile.am (common_sources) [W32]: Add w32-misc.c (module_tests): Add t-w32-cmdline (t_w32_cmdline_LDADD): New. -- The rules for the command line parser are not cleary specified - if at all. See the comment in t-w32-cmdline.c. We can't use the mingw version because that would require to change all argv handling to be wchar_t and that only for Windows. That would be too ugly. Parsing the command line into argv by us is much easier and we can do that only if needed - i.e. if globing is required (we are prepared for this) or a non-ASCII character has been encountered. This way we keep things stable and only fix the currently not working Unicode problem. GnuPG-bug-id: 4398 (cherry picked from commit deb6c94362c0f179de1cac18707aad2f51a21e10)
2021-06-02sm: Support AES-GCM decryption.Werner Koch1-1/+2
* sm/gpgsm.c (main): Use gpgrt_fcancel on decryption error if gpgrt supports this. * sm/decrypt.c (decrypt_gcm_filter): New. (gpgsm_decrypt): Use this filter if requested. Check authtag. * common/compliance.c (gnupg_cipher_is_allowed): Allow GCM for gpgsm in consumer (decrypt) de-vs mode. -- Backported-from-master: 4980fb3c6dde8c1dda975e8a36d6086c8456a631 We allow GCM in de-vs mode for decryption although this has not been evaluation. It is decryption and thus no serious harm may happen. Signed-off-by: Werner Koch <[email protected]>
2021-05-26gpg,sm: Simplify keyserver spec parsing.Werner Koch2-74/+0
* common/keyserver.h: Remove. * sm/gpgsm.h (struct keyserver_spec): Remove. (opt): Change keyserver to a strlist_t. * sm/gpgsm.c (keyserver_list_free): Remove. (parse_keyserver_line): Remove. (main): Store keyserver in an strlist. * sm/call-dirmngr.c (prepare_dirmngr): Adjust for the strlist. Avoid an ambiguity in dirmngr by adding a prefix if needed. * g10/options.h (struct keyserver_spec): Move definition from keyserver.h to here. Remove most fields. * g10/keyserver.c (free_keyserver_spec): Adjust. (cmp_keyserver_spec): Adjust. (parse_keyserver_uri): Simplify. (keyidlist): Remove fakev3 arg which does not make any sense because we don't even support v3 keys. -- We now rely on the dirmngr to parse the keyserver specs. Thus a bad specification will not be caught immediately. However, even before that dirmngr had stricter tests. Signed-off-by: Werner Koch <[email protected]>
2021-05-20common: Avoid double-freeJakub Jelen1-0/+1
* common/name-value.c (do_nvc_parse): reset to null after ownership change -- Signed-off-by: Jakub Jelen <[email protected]> GnuPG-bug-id: 5393
2021-05-17sm: Support decryption of password based encryption (pwri)Werner Koch2-0/+17
* sm/decrypt.c (string_from_gcry_buffer): New. (pwri_parse_pbkdf2): New. (pwri_decrypt): New. (prepare_decryption): Support pwri. (gpgsm_decrypt): Test for PWRI. Move IS_DE_VS flag to DFPARM. * common/sexputil.c (cipher_mode_to_string): New. -- Note that this is not finished because we need to implement a password callback. For now "abc" is used as passwort. Latest libksba is also required to return the required info. Signed-off-by: Werner Koch <[email protected]> Backported-from-master: 02029f9eab87e9fd667829dfb083846275576398 Note that this change also prints the used algorithm and shows some existsing diagnostics only in verbose mode. Signed-off-by: Werner Koch <[email protected]>
2021-05-03common: Fix gnupg_wait_processes, by skipping invalid PID.NIIBE Yutaka1-1/+6
* common/exechelp-posix.c (gnupg_wait_processes): Skip invalid PID. -- Signed-off-by: NIIBE Yutaka <[email protected]> (cherry picked from commit d82dae5d2229a30dbc78aadc4d544d30dac76a1c)
2021-04-29common: Extend the openpgp_curve_to_oid function.Werner Koch3-4/+13
* common/openpgp-oid.c (openpgp_curve_to_oid): Add optional arg R_NBITS. Change all callers. -- In particular for ed25519 and cv25519 it is quite useful to have an ability to get the required algorithm. (cherry picked from commit 24095101a5069f15a9aea7512498ac436a76814a)
2021-04-29common: New module to compute openpgp fingerprintsWerner Koch3-0/+306
* common/openpgp-fpr.c: New. * common/Makefile.am (common_sources): Add it. -- This function is targeted to handle keys on smartcards. Signed-off-by: Werner Koch <[email protected]> (cherry picked from commit 2f2bdd9c0894eb43f719da8b529b4c7a46f742a0) Signed-off-by: Werner Koch <[email protected]>
2021-04-29common: New function to uncompress an ECC public key.Werner Koch3-1/+593
* common/sexputil.c (ec2os): New. (uncompress_ecc_q_in_canon_sexp): New. * common/t-sexputil.c (fail2): new. (test_ecc_uncompress): New. (main): Run new test. -- Signed-off-by: Werner Koch <[email protected]> (cherry picked from commit 935765b451aadc63fbba763a4a00f4efa0254436)
2021-04-29common: New function cmp_canon_sexp.Werner Koch4-2/+200
* common/sexputil.c (cmp_canon_sexp): New. (cmp_canon_sexp_def_tcmp): New. * common/t-sexputil.c (test_cmp_canon_sexp): Add a simple test. -- To be used to fix GnuPG-bug-id: 5061 Signed-off-by: Werner Koch <[email protected]> (cherry picked from commit b6ba6a79ce9336f1b53f16f3d1190dd009fb166e)
2021-04-29scd: Extend iso7816_select_pathWerner Koch1-0/+2
* scd/iso7816.c (iso7816_select_path): Add arg top_fd. * scd/app-nks.c (do_readkey): Adjust for this change (select_ef_by_path: Ditto. * common/tlv.h: Include membuf.h. -- Including membuf.h is just for easier backporting. In 2.3 it is actually required in tlv.h but in 2.2 we right now only use it indirect.
2021-04-01common: Make the compliance check more robust.Werner Koch1-16/+60
* common/compliance.c (get_compliance_cache): New. (gnupg_rng_is_compliant): Use per mode cache. (gnupg_gcrypt_is_compliant): Ditto. -- This addresses the problem tha the check might be called with different compliance values and thus it should return the corresponding cached result. Signed-off-by: Werner Koch <[email protected]> Backported from 2.3. Added PGP6 support which was removed from 2.3.
2021-03-02common: New function dotlock_is_locked.Werner Koch2-4/+19
* common/dotlock.c (dotlock_is_locked): New. (dotlock_take): Set locked flag also in disabled mode. No more warning if the lock has already been taken. (dotlock_release): Clear locked flag also in disabled mode. No more warning if the lock has not been taken. -- This allow to use dotlock_take and dotlock_release even if they have already been called. Before this changes this worked too but a diagnostic was printed.
2021-02-17common: Fix compiler warningWerner Koch1-1/+1
--
2021-01-28Include the library version in the compliance checks.Werner Koch2-15/+64
* common/compliance.c (gnupg_gcrypt_is_compliant): New. (gnupg_rng_is_compliant): Also check library version. * g10/mainproc.c (proc_encrypted): Use new function. (check_sig_and_print): Ditto. * sm/decrypt.c (gpgsm_decrypt): Ditto. * sm/encrypt.c (gpgsm_encrypt): Ditto. * sm/verify.c (gpgsm_verify): Ditto -- This will eventually allow us to declare Libgcrypt 1.9 to be de-vs compliant. GnuPG can use this information then for its own checks. As of now GnuPG tests the version of the used library but that is a bit cumbersome to maintain. Signed-off-by: Werner Koch <[email protected]> (cherry picked from commit 90c514868ff5fcf6d39490d4874ac3a31ba9e85f)
2021-01-11Update copyright notices.Werner Koch1-1/+1
--
2021-01-11gpg,w32: Fix gnupg_remove.Werner Koch3-1/+132
* common/sysutils.c (map_w32_to_errno): New. (gnupg_w32_set_errno): New. (gnupg_remove) [w32]: Set ERRNO -- To support Unicode gnupg_remove was changed to use DeleteFileW and not properly tested because the code was alreadt used in Windows CE. However, ERRNO was not set and thus Dirmngr failed due to if (!gnupg_remove (fname)) log_info (_("removed stale te[...] file '%s'\n"), fname); else if (errno != ENOENT) { err = gpg_error_from_syserror (); log_error (_("problem remov[...] file '%s': %s\n"), fname, gpg_strerror (err)); goto leave; } GnuPG-bug-id: 5230 (cherry picked from commit b6967d31912912ad3c0a2ff6bf6eb9822a194562)
2020-12-21common: Remove superfluous debug output from dotlock.c.Werner Koch1-2/+0
* common/dotlock.c (dotlock_create_unix): Remove debug output. -- This was left over from developement about 10 years ago. Exhibits itself when using sshfs. GnuPG-bug-id: 5193
2020-12-21common: Fix the "ignore" meta command in argparse.cWerner Koch3-36/+122
* src/argparse.c (gnupg_argparse): Factor some code out to ... (prepare_arg_return): new. (gnupg_argparse): No missing arg error in ignore sections. * common/sysutils.c: Include pwd.h. (gnupg_getusername): New. -- 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. This is a port of the fix from libgpg-error. Also fixes the username fixme.