aboutsummaryrefslogtreecommitdiffstats
path: root/src/posix-io.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* core: Don't keep using deprecated ath_ API.NIIBE Yutaka2022-04-051-9/+15
| | | | | | | | | | | | | | | | | * src/posix-io.c: Don't include ath.h. (_gpgme_io_read): Call read directly. (_gpgme_io_write): Call write directly. (_gpgme_io_waitpid): Call waitpid directly. (_gpgme_io_select_select): Call select directly. (_gpgme_io_recvmsg): Call recvmsg directly. (_gpgme_io_sendmsg): Call sendmsg directly. (_gpgme_io_connect): Call connect directly. * src/assuan-support.c: Don't include ath.h. (my_waitpid): Call waitpid directly. -- Signed-off-by: NIIBE Yutaka <[email protected]>
* posix: Use poll instead, when available, removing use of select.NIIBE Yutaka2021-11-251-2/+123
| | | | | | | | | | | | | * configure.ac (HAVE_POLL_H): Add the check. * src/ath.c [!HAVE_POLL_H] (ath_select): Enable conditionally. * src/posix-io.c [HAVE_POLL_H] (_gpgme_io_select_poll): Use poll. * tests/gpg/t-cancel.c [HAVE_POLL_H] (do_select): Use poll. * tests/gpg/t-eventloop.c [HAVE_POLL_H] (do_select): Use poll. -- GnuPG-bug-id: 2385 Signed-off-by: NIIBE Yutaka <[email protected]>
* core: Support closefrom also for glibc.Jiri Kucera2021-07-271-1/+1
| | | | | | | | | | * src/posix-io.c (_gpgme_io_spawn): Use glibc's closefrom. -- Since 2.34, glibc introduces closefrom (the implementation follows *BSD standard). Signed-off-by: Werner Koch <[email protected]>
* core: Add commented debug helper to posix-io.c.Werner Koch2019-06-061-21/+71
| | | | | | | | | | * src/posix-io.c (_gpgme_is_fd_valid): New out-commented function. -- This code is sometimes useful to track down invalid file descriptors. We keep it commented in the code. Signed-off-by: Werner Koch <[email protected]>
* core: Improve the debug messages even more.Werner Koch2019-06-051-26/+26
| | | | | | | | | | | | | | | * src/debug.c (_gpgme_debug): Add arg LINE. Chnage all callers. (_gpgme_debug_begin): Remove. * src/debug.h (TRACE_SEQ): Use the LINE arg of _gpgme_debug. -- This includes chnages to always print fds in decimal as weel as tweaking the TARCE_SEQ function to make use of the new machinery. The standard 'tag' can now always be NULL and no tag information will be printed. Signed-off-by: Werner Koch <[email protected]>
* core: Protect the trace macros for fun and profit.Werner Koch2018-11-161-1/+2
| | | | | | | | * src/debug.h: Protect macros using. (_trace_err, _trace_sysres, _trace_syserr): New helper inline functions. Signed-off-by: Werner Koch <[email protected]>
* core: Fix format string errors in trace macrosWerner Koch2018-11-161-4/+4
| | | | | | -- Signed-off-by: Werner Koch <[email protected]>
* core: Simplify the trace maros by using variadics.Werner Koch2018-11-161-23/+23
| | | | | | | | | | | | | | | | * src/debug.h (TRACE_BEG, TRACE_LOG, TRACE_SUC): Use variadic macros and remove the TRACE_BEG1 et al. Change all users to always pass a format string. (TRACE): Ditto. * src/debug.c (_gpgme_debugf): New. * configure.ac <GCC>: Add -Wno-format-zero-length. -- This makes it easier for use to enable format checks. The zero-length format is required to allow for an empty format due to the comman problematic of __VA_ARGS__. Signed-off-by: Werner Koch <[email protected]>
* Add SPDX identifiers to most source filesWerner Koch2018-11-161-17/+18
| | | | | | -- Signed-off-by: Werner Koch <[email protected]>
* core: Print a dump of the I/O data only at level 8.Werner Koch2018-11-021-4/+4
| | | | | | | | | | | | * src/debug.h (TRACE_SUC3): New. (TRACE_LOGBUFX): New. * src/posix-io.c: Use TRACE_LOGBUFX instead of TRACE_LOGBUF. * src/w32-glib-io.c: Ditto. -- This will also be changed for w32-io as part of another commit. Signed-off-by: Werner Koch <[email protected]>
* core: use getdents64 syscall on linux instead of getdents.Daniel Kahn Gillmor2017-10-121-7/+8
| | | | | | | | | | | | * src/posix-io.c (get_max_fds): use getdents64 instead of getdents. -- getdents64 was introduced in linux 2.4, so it should be widely available. some Linux architectures which post-date 2.4 (e.g. arm64) appear to not have getdents at all, so it's probably better to use the more modern interface. Signed-off-by: Daniel Kahn Gillmor <[email protected]>
* core: Allow disabling the use of SYS_getdents for Linux.Werner Koch2017-10-041-6/+8
| | | | | | | | * configure.ac (USE_LINUX_GETDENTS): New ac_define. Add option --disable-linux-getdents. * src/posix-io.c: Make use of USE_LINUX_GETDENTS. Signed-off-by: Werner Koch <[email protected]>
* core: Restore get_max_fds optimization on LinuxColin Watson2017-10-041-33/+66
| | | | | | | | | | | | | | | | | * src/posix-io.c (get_max_fds): Restore Linux optimization, this time using open/getdents/close rather than opendir/readdir/closedir. -- opendir/readdir/closedir may allocate/free memory, and aren't required to do so in an async-signal-safe way. On the other hand, opening /proc/self/fd directly and iterating over it using getdents is safe. (getdents is not strictly speaking documented to be async-signal-safe because it's not in POSIX. However, the Linux implementation is essentially just a souped-up read. Python >= 3.2.3 makes the same assumption.) Signed-off-by: Colin Watson <[email protected]>
* FreeBSD's closefrom(2) does not return errorsPietro Cerutti2017-04-031-2/+2
|
* core: Optimize fork/exec for *BSD and Solaris.Werner Koch2017-02-031-12/+36
| | | | | | | * configure.ac (closefrom): Add to ac_check_funcs. * src/posix-io.c (_gpgme_io_spawn): Use closefrom. Signed-off-by: Werner Koch <[email protected]>
* core: Fix possible deadlock due to get_max_fds.Werner Koch2017-02-031-31/+37
| | | | | | | * src/posix-io.c (get_max_fds): Do not use the Linux optimization. -- Signed-off-by: Werner Koch <[email protected]>
* doc: Replace http: by https: in core source files.Werner Koch2016-11-161-1/+1
| | | | | | -- Signed-off-by: Werner Koch <[email protected]>
* core: Use better error code when using select with a too high fd.Werner Koch2016-11-101-2/+2
| | | | | | | | | | | | | | | * src/posix-io.c (_gpgme_io_select): Return EMFILE instead of EBADF. -- Also EBADF seem more correct, EMFILE (Too man open files) gives a clearer message to the user that there are somehow too many files open. The problem can be exhibited by running lots of threads, We should eventually move to poll but that would be a large change and so we better fix it with the planned migration of the I/O subsystem to libgpgrt (currently known as libgpg-error). Signed-off-by: Werner Koch <[email protected]>
* core: Use const char * where appropriate.Werner Koch2016-09-131-1/+1
| | | | Signed-off-by: Werner Koch <[email protected]>
* core: Make sure FD_SET is not used with an out of range fd.Werner Koch2016-06-141-0/+12
| | | | | | | * src/posix-io.c (_gpgme_io_select): Check for FD out of range. -- Signed-off-by: Werner Koch <[email protected]>
* Speedup closing of fds before exec.Werner Koch2016-05-271-7/+47
| | | | | | | | * src/posix-io.c [__linux__]: Include dirent.h. (get_max_fds) [__linux__]: Try to figure out the highest used fd. -- Signed-off-by: Werner Koch <[email protected]>
* Fix possible _SC_OPEN_MAX max problem on AIX.Werner Koch2016-01-151-0/+13
| | | | | | | | * src/posix-io.c [HAVE_STDINT_H]: Include stdint.h. (get_max_fds): Limit returned value for too high values. -- Signed-off-by: Werner Koch <[email protected]>
* Fix possible zombie processes.Werner Koch2014-04-151-3/+14
| | | | | | | | | * src/posix-io.c (_gpgme_io_waitpid): Protect waitpid agains EINTR. (_gpgme_io_dup): Likewise. (_gpgme_io_connect): Likewise. -- GnuPG-bug-id: 1630
* Make use of internal iospawn flags more flexible.Werner Koch2014-04-101-2/+0
| | | | | | | | | | | | | * src/priv-io.h (IOSPAWN_FLAG_DETACHED): New. Renumber the others. * src/w32-io.c (_gpgme_io_spawn): Use DETACHED_PROCESS process only if IOSPAWN_FLAG_DETACHED is given. * src/w32-qt-io.cpp (_gpgme_io_spawn): Ditto. * src/w32-glib-io.c (_gpgme_io_spawn): Ditto. * src/assuan-support.c (my_spawn): Pass IOSPAWN_FLAG_DETACHED flags. * src/dirinfo.c (read_gpgconf_dirs): Ditto. * src/engine-gpg.c (start): Ditto. * src/engine-gpgconf.c (gpgconf_read, gpgconf_write): Ditto. * src/version.c (_gpgme_get_program_version): Ditto.
* Make sure a spawned process has all standard fds connected.Werner Koch2014-04-101-33/+18
| | | | | | | | | | | * src/posix-io.c (_gpgme_io_spawn): dup /dev/null also to unsued stdout. -- Better be sure that stdout of a spawned process is connected to stdout so that the process does not run into a write error if it writes to stdout. AFAICS we always use a connected stdout; thus this is only for correctness.
* Remove all trailing whitespace from source filesWerner Koch2012-09-251-13/+13
| | | | | -- Command used: sed -i 's,[ \t]*$,,' FILE
* More include guards.Werner Koch2010-11-031-1/+3
| | | | | | Provide access for Wince. Install dummy sehmap.h
* First take on changes to allow building with MSC for W32CE.Werner Koch2010-11-021-3/+6
| | | | | Fixed regression in plain W32 build.
* Changed the close notify implementaion to allow for more than 256 fds.Werner Koch2010-02-171-21/+74
| | | | | We should write a test case for it, though.
* 2009-11-10 Marcus Brinkmann <[email protected]>Marcus Brinkmann2009-11-101-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * configure.ac: Activate UIServer if FD passing is enabled and Assuan is available. m4/ 2009-11-10 Marcus Brinkmann <[email protected]> * libassuan.m4: Fix LIBASSUAN_VERSION. src/ 2009-11-10 Marcus Brinkmann <[email protected]> * Makefile.am (uiserver_components): New variable. (main_sources): Add it. * ops.h, key.c (_gpgme_key_append_name): Take CONVERT argument, implement it. Adjust callers. (gpgme_key_from_uid): New function. * gpgme.h.in (gpgme_protocol_t): Add GPGME_PROTOCOL_DEFAULT. (gpgme_encrypt_flags_t): Add GPGME_ENCRYPT_PREPARE, GPGME_ENCRYPT_EXPECT_SIGN. (gpgme_set_sub_protocol, gpgme_key_from_uid): New functions. * libgpgme.vers, gpgme.def: Add new functions. * gpgme.c (gpgme_set_protocol): Add UIServer protocol. (gpgme_set_sub_protocol): New function. (gpgme_get_protocol_name): Add UIServer and default protocol. * assuan-support.c: Return correct error values, implement socketpair for POSIX. * priv-io.h, posix-io.c, w32-io.c, w32-glib-io.c, w32-qt-io.cpp (_gpgme_io_spawn): Add ATFORK and ATFORKVALUE arguments. Implement it for POSIX. Adjust all callers. * engine.h, engine-backend.h (_gpgme_engine_set_protocol) (_gpgme_engine_op_decrypt_verify): New prototypes. Adjust all users. * engine.c (engine_ops, gpgme_get_engine_info): Add UIServer engine. (_gpgme_engine_set_protocol, _gpgme_engine_op_decrypt_verify): New function. * decrypt-verify.c (decrypt_verify_start): Call _gpgme_engine_op_decrypt_verify. * util.h, posix-util.c, w32-util.c (_gpgme_get_uiserver_socket_path): New function. * engine-gpgsm.c (gpgsm_set_fd): Fix _gpgme_io_pipe invocation. * gpgme-tool.c: Some support for UIServer protocol. * engine-uiserver.c: New file.
* 2009-11-05 Marcus Brinkmann <[email protected]>Marcus Brinkmann2009-11-051-1/+2
| | | | | | | | | * priv-io.h (IOSPAWN_FLAG_NOCLOSE): New flag. * w32-io.c (_gpgme_io_spawn): Implement this flag. * posix-io.c (_gpgme_io_spawn): Likewise. * w32-glib-io.c (_gpgme_io_spawn): Likewise. * assuan-support.c (my_spawn): Set this flag.
* 2009-11-04 Marcus Brinkmann <[email protected]>Marcus Brinkmann2009-11-041-1/+1
| | | | | | | | | | | | | | | | | | | | * ath.h (ath_self): New prototype. Include <stdint.h> * ath.c, ath-pth.c, ath-pthread.c (ath_self): New function. * debug.h: Rewrite most macros to beautify debug output. (_gpgme_debug_buffer): Remove tagname and tag argument. (_gpgme_debug_frame_begin, _gpgme_debug_frame_end): New prototypes. * debug.c: Include <time.h>. Don't include assuan.h. (frame_nr, FRAME_NR): New thread-specific variable and macro. (debug_init): Do not initialize assuan. Call _gpgme_debug after initialization instead using printf directly. (_gpgme_debug): Do not call debug_init (we now ensure proper initialization by user). Add timestamp and thread/process ID. (_gpgme_debug_buffer): Do not take tagname and tag argument. (_gpgme_debug_frame_begin, _gpgme_debug_frame_end): New functions. * version.c (gpgme_check_version_internal, gpgme_check_version): Fix debug string. Do not initialize assuan. * posix-io.c (get_max_fds): Use 0 not NULL (nicer debug output).
* 2009-10-20 Marcus Brinkmann <[email protected]>Marcus Brinkmann2009-10-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * configure.ac: Replace internal libassuan by external libassuan. * m4/libassuan.m4: New file. * Makefile.am (assuan): Remove variable. (SUBDIRS): Remove ${assuan}. * assuan/: Removed. src/ 2009-10-20 Marcus Brinkmann <[email protected]> * Makefile.am (assuan_cppflags, assuan_libobjs): Removed. (gpgsm_components): Move engine-assuan.c to ... (assuan_components): ... this new variable. (main_sources): Add this new variable. (AM_CPPFLAGS): Remove $(assuan_cppflags). (AM_CFLAGS): Add @LIBASSUAN_CFLAGS@. (libgpgme_la_DEPENDENCIES, libgpgme_pth_la_DEPENDENCIES) (libgpgme_glib_la_DEPENDENCIES, libgpgme_qt_la_DEPENDENCIES) (libgpgme_pthread_la_DEPENDENCIES): Remove $(assuan_libobjs). (libgpgme_la_LIBADD, libgpgme_pth_la_LIBADD) (libgpgme_glib_la_LIBADD, libgpgme_qt_la_LIBADD)) (libgpgme_pthread_la_LIBADD): Replace $(assuan_libobjs) by @LIBASSUAN_LIBS@. * priv-io.h [!HAVE_W32_SYSTEM]: Declare _gpgme_io_recvmsg, _gpgme_io_sendmsg, _gpgme_io_waitpid. * engine-backend.h: Define with [ENABLE_ASSUAN] instead of [ENABLE_GPGSM]. * posix-io.c (_gpgme_io_waitpid): Make non-static. * util.h (ENABLE_ASSUAN): Declar _gpgme_assuan_system_hooks, _gpgme_assuan_malloc_hooks, _gpgme_assuan_log_cb. * engine-gpgsm.c: Don't map assuan error codes. Use assuan_release instead of assuan_disconnect. (map_assuan_error): Remove function. (gpgsm_new): Use new assuan context interface. * engine-assuan.c: Use assuan_release instead of assuan_disconnect. (llass_new): Use new assuan context interface.
* Improved W32 SetForegroundWindow hacks.Werner Koch2009-06-121-1/+4
|
* 2009-04-15 Marcus Brinkmann <[email protected]>Marcus Brinkmann2009-04-151-0/+28
| | | | | | * posix-io.c (_gpgme_io_socket, _gpgme_io_connect): New functions. * w32-io.c (_gpgme_io_connect): Fix stupid error.
* 008-11-03 Marcus Brinkmann <[email protected]>Marcus Brinkmann2008-11-031-0/+655
* configure.ac: Replace gpgme paths with src. * gpgme: Move to ... * src: ... this new directory. assuan/ 2008-11-03 Marcus Brinkmann <[email protected]> * Makefile.am (INCLUDES): Replace gpgme path with src. tests/ 2008-11-03 Marcus Brinkmann <[email protected]> * gpgsm/Makefile.am (INCLUDES, LDADD): Replace gpgme path with src. * gpg/Makefile.am (INCLUDES, LDADD, t_thread1_LDADD): Likewise. * Makefile.am (LDADD): Likewise.