From cvs at cvs.gnupg.org Wed Jul 4 11:13:04 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 04 Jul 2007 11:13:04 +0200 Subject: [svn] w32pth - r5 - trunk Message-ID: Author: wk Date: 2007-07-04 11:12:35 +0200 (Wed, 04 Jul 2007) New Revision: 5 Modified: trunk/ChangeLog trunk/Makefile.am trunk/Makefile.in trunk/README trunk/configure.ac trunk/w32-pth.c Log: Major rewrite of the event stuff. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-06-29 18:38:00 UTC (rev 4) +++ trunk/ChangeLog 2007-07-04 09:12:35 UTC (rev 5) @@ -1,3 +1,11 @@ +2007-07-04 Werner Koch + + * w32-pth.c: Major rewrite of the event stuff. + +2007-07-03 Werner Koch + + * Makefile.am (libw32pth_la_LIBADD): Use ws2_32 instead of wsock32. + 2007-06-29 Werner Koch * w32-pth.c (pth_event_add): Remove. @@ -4,8 +12,8 @@ (pth_event_concat): Correctly implement as a ring. (do_pth_wait): Fixed bug which let us wait only on the first event. More or less rewrote it. - (do_pth_event_occurred): removed and repalced by direct call to - theSTATUS field of the event. + (do_pth_event_occurred): Removed and repalced by direct call to + the STATUS field of the event. (pth_event_status): Changed implementation to accommodate the changed do_pth_wait. (pth_event_status): Ditto. Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2007-06-29 18:38:00 UTC (rev 4) +++ trunk/Makefile.am 2007-07-04 09:12:35 UTC (rev 5) @@ -53,7 +53,7 @@ -version-info \ @W32PTH_LT_CURRENT@:@W32PTH_LT_REVISION@:@W32PTH_LT_AGE@ libw32pth_la_DEPENDENCIES = $(w32pth_deps) -libw32pth_la_LIBADD = @LTLIBOBJS@ -lwsock32 +libw32pth_la_LIBADD = @LTLIBOBJS@ -lws2_32 libw32pth_la_SOURCES = w32-pth.c pth.h Modified: trunk/Makefile.in =================================================================== --- trunk/Makefile.in 2007-06-29 18:38:00 UTC (rev 4) +++ trunk/Makefile.in 2007-07-04 09:12:35 UTC (rev 5) @@ -261,7 +261,7 @@ @W32PTH_LT_CURRENT@:@W32PTH_LT_REVISION@:@W32PTH_LT_AGE@ libw32pth_la_DEPENDENCIES = $(w32pth_deps) -libw32pth_la_LIBADD = @LTLIBOBJS@ -lwsock32 +libw32pth_la_LIBADD = @LTLIBOBJS@ -lws2_32 libw32pth_la_SOURCES = w32-pth.c pth.h all: config.h $(MAKE) $(AM_MAKEFLAGS) all-am Modified: trunk/README =================================================================== --- trunk/README 2007-06-29 18:38:00 UTC (rev 4) +++ trunk/README 2007-07-04 09:12:35 UTC (rev 5) @@ -10,11 +10,7 @@ It is currently limited to what GnuPG 2.0 requires. -Thing we need to implement: - pth_select_ev - EV is currently ignored. - - Missing stuff: PTH_MODE_STATIC is known but ignored. Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-06-29 18:38:00 UTC (rev 4) +++ trunk/configure.ac 2007-07-04 09:12:35 UTC (rev 5) @@ -146,6 +146,7 @@ AC_CHECK_SIZEOF(unsigned int) AC_CHECK_SIZEOF(unsigned long) +AC_CHECK_SIZEOF(long long) # To be used in pth-config W32PTH_CONFIG_LIBS="-lw32pth" Modified: trunk/w32-pth.c =================================================================== --- trunk/w32-pth.c 2007-06-29 18:38:00 UTC (rev 4) +++ trunk/w32-pth.c 2007-07-04 09:12:35 UTC (rev 5) @@ -51,7 +51,11 @@ #error TRUE or FALSE defined to wrong values #endif +#if SIZEOF_LONG_LONG != 8 +#error long long is not 64 bit +#endif + /* States whether this module has been initialized. */ static int pth_initialized; @@ -68,7 +72,15 @@ /* Mutex to make sure only one thread is running. */ static CRITICAL_SECTION pth_shd; -/* Events are store in a double linked event ring. */ +/* Object used by update_fdarray. */ +struct fdarray_item_s +{ + int fd; + long netevents; +}; + + +/* Pth events are store in a double linked event ring. */ struct pth_event_s { struct pth_event_s *next; @@ -81,7 +93,6 @@ struct { int *rc; - int nfd; fd_set *rfds; fd_set *wfds; fd_set *efds; @@ -141,11 +152,143 @@ return "libw32pth"; } +static char * +w32_strerror (char *strerr, size_t strerrsize) +{ + if (strerrsize > 1) + FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, (int)GetLastError (), + MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), + strerr, strerrsize, NULL); + return strerr; +} +static char * +wsa_strerror (char *strerr, size_t strerrsize) +{ + if (strerrsize > 1) + FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, (int)WSAGetLastError (), + MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), + strerr, strerrsize, NULL); + return strerr; +} + + +/* Create a manual resetable event object useable in WFMO. */ +static HANDLE +create_event (void) +{ + SECURITY_ATTRIBUTES sa; + HANDLE h, h2; + char strerr[256]; + + memset (&sa, 0, sizeof sa); + sa.bInheritHandle = TRUE; + sa.lpSecurityDescriptor = NULL; + sa.nLength = sizeof sa; + h = CreateEvent (&sa, TRUE, FALSE, NULL); + if (!h) + { + if (DBG_ERROR) + fprintf (stderr, "%s: CreateEvent failed: %s\n", + log_get_prefix (NULL), + w32_strerror (strerr, sizeof strerr)); + return NULL; + } + if (!DuplicateHandle (GetCurrentProcess(), h, + GetCurrentProcess(), &h2, + EVENT_MODIFY_STATE|SYNCHRONIZE, FALSE, 0 ) ) + { + if (DBG_ERROR) + fprintf (stderr, "%s: " + "setting synchronize for event object %p failed: %s\n", + log_get_prefix (NULL), h, + w32_strerror (strerr, sizeof strerr)); + CloseHandle (h); + return NULL; + } + CloseHandle (h); + if (DBG_INFO) + { + fprintf (stderr, "%s: CreateEvent(%p) succeeded\n", + log_get_prefix (NULL), h2); + } + return h2; +} + + +static void +set_event (HANDLE h) +{ + char strerr[256]; + + if (!SetEvent (h)) + { + if (DBG_ERROR) + fprintf (stderr, "%s: SetEvent(%p) failed: %s\n", + log_get_prefix (NULL), h, + w32_strerror (strerr, sizeof strerr)); + } + else if (DBG_INFO) + { + fprintf (stderr, "%s: SetEvent(%p) succeeded\n", + log_get_prefix (NULL), h); + } +} + +static void +reset_event (HANDLE h) +{ + char strerr[256]; + + if (!ResetEvent (h)) + { + if (DBG_ERROR) + fprintf (stderr, "%s: ResetEvent(%p) failed: %s\n", + log_get_prefix (NULL), h, + w32_strerror (strerr, sizeof strerr)); + } + else if (DBG_INFO) + { + fprintf (stderr, "%s: ResetEvent(%p) succeeded\n", + log_get_prefix (NULL), h); + } +} + + + +/* Create a timer event. */ +static HANDLE +create_timer (void) +{ + SECURITY_ATTRIBUTES sa; + HANDLE h; + char strerr[256]; + + memset (&sa, 0, sizeof sa); + sa.bInheritHandle = TRUE; + sa.lpSecurityDescriptor = NULL; + sa.nLength = sizeof sa; + h = CreateWaitableTimer (&sa, TRUE, NULL); + if (!h) + { + if (DBG_ERROR) + fprintf (stderr, "%s: CreateWaitableTimer failed: %s\n", + log_get_prefix (NULL), + w32_strerror (strerr, sizeof strerr)); + return NULL; + } + if (DBG_INFO) + { + fprintf (stderr, "%s: CreateWaitableTimer(%p) succeeded\n", + log_get_prefix (NULL), h); + } + return h; +} + + int pth_init (void) { - SECURITY_ATTRIBUTES sa; WSADATA wsadat; const char *s; @@ -162,14 +305,11 @@ InitializeCriticalSection (&pth_shd); if (pth_signo_ev) CloseHandle (pth_signo_ev); - memset (&sa, 0, sizeof sa); - sa.bInheritHandle = TRUE; - sa.lpSecurityDescriptor = NULL; - sa.nLength = sizeof sa; - pth_signo_ev = CreateEvent (&sa, TRUE, FALSE, NULL); + + pth_signo_ev = create_event (); if (!pth_signo_ev) return FALSE; - + pth_initialized = 1; EnterCriticalSection (&pth_shd); return TRUE; @@ -193,17 +333,6 @@ } -static char * -w32_strerror (char *strerr, size_t strerrsize) -{ - if (strerrsize > 1) - FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, (int)GetLastError (), - MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), - strerr, strerrsize, NULL); - return strerr; -} - - static void enter_pth (const char *function) { @@ -365,12 +494,33 @@ return n; } +static void +show_event_ring (const char *text, pth_event_t ev) +{ + pth_event_t r; + if (!ev) + { + fprintf (stderr, "show_event_ring(%s): No ring\n", text); + return; + } + + r = ev; + do + { + fprintf (stderr, "show_event_ring(%s): type=%d r=%p prev=%p next=%p\n", + text, r->u_type, r, r->prev, r->next); + } + while (r=r->next, r != ev); +} + + + int pth_select_ev (int nfd, fd_set *rfds, fd_set *wfds, fd_set *efds, const struct timeval *timeout, pth_event_t ev_extra) { - int rc; + int rc, sel_rc; pth_event_t ev; pth_event_t ev_time = NULL; int selected; @@ -378,7 +528,7 @@ implicit_init (); enter_pth (__FUNCTION__); - ev = do_pth_event (PTH_EVENT_SELECT, &rc, nfd, rfds, wfds, efds); + ev = do_pth_event (PTH_EVENT_SELECT, &sel_rc, nfd, rfds, wfds, efds); if (!ev) { leave_pth (__FUNCTION__); @@ -406,14 +556,22 @@ } while (!rc); - if (ev_extra) - pth_event_isolate (ev_extra); + pth_event_isolate (ev); if (timeout) pth_event_isolate (ev_time); + if (DBG_INFO) + { + show_event_ring ("ev ", ev); + show_event_ring ("ev_time ", ev_time); + show_event_ring ("ev_extra", ev_extra); + } + /* Fixme: We should check whether select failed and return EBADF in this case. */ selected = (ev && ev->status == PTH_STATUS_OCCURRED); + if (selected) + rc = sel_rc; if (timeout && (ev_time && ev_time->status == PTH_STATUS_OCCURRED)) { selected = 1; @@ -906,19 +1064,47 @@ return FALSE; } /* Fixme: We can keep only track of one signal at a time. */ - SetEvent (pth_signo_ev); + set_event (pth_signo_ev); if (DBG_INFO) fprintf (stderr, "%s: sig_handler=%d\n", log_get_prefix (NULL), pth_signo); return TRUE; } +/* Helper to build an fdarray. */ +static int +build_fdarray (struct fdarray_item_s *fdarray, int nfdarray, + fd_set *fds, long netevents) +{ + int i, j, fd; + + if (fds) + for (i=0; i < fds->fd_count; i++) + { + fd = fds->fd_array[i]; + for (j=0; j < nfdarray; j++) + if (fdarray[j].fd == fd) + { + fdarray[j].netevents |= netevents; + break; + } + if (!(j < nfdarray) && nfdarray < FD_SETSIZE) + { + fdarray[nfdarray].fd = fd; + fdarray[nfdarray].netevents = netevents; + nfdarray++; + } + } + return nfdarray; +} + + static pth_event_t do_pth_event_body (unsigned long spec, va_list arg) { - SECURITY_ATTRIBUTES sa; + char strerr[256]; pth_event_t ev; - int rc; + int i, rc; if ((spec & (PTH_MODE_CHAIN|PTH_MODE_REUSE))) { @@ -934,6 +1120,17 @@ ev = calloc (1, sizeof *ev); if (!ev) return NULL; + ev->next = ev; + ev->prev = ev; + if ((spec & PTH_EVENT_TIME)) + ev->hd = create_timer (); + else + ev->hd = create_event (); + if (!ev->hd) + { + free (ev); + return NULL; + } /* We don't support static yet but we need to consume the argument. */ @@ -952,7 +1149,8 @@ ev->u_type = PTH_EVENT_SIGS; ev->u.sig.set = va_arg (arg, struct sigset_s *); ev->u.sig.signo = va_arg (arg, int *); - rc = SetConsoleCtrlHandler (sig_handler, TRUE); + /* The signal handler is disabled for now. */ + rc = 0/*SetConsoleCtrlHandler (sig_handler, TRUE)*/; if (DBG_INFO) fprintf (stderr, "%s: pth_event: sigs rc=%d\n", log_get_prefix (NULL), rc); @@ -982,27 +1180,35 @@ } else if (spec & PTH_EVENT_SELECT) { + struct fdarray_item_s fdarray[FD_SETSIZE]; + int nfdarray; + ev->u_type = PTH_EVENT_SELECT; ev->u.sel.rc = va_arg (arg, int *); - ev->u.sel.nfd = va_arg (arg, int); + (void)va_arg (arg, int); /* Ignored. */ ev->u.sel.rfds = va_arg (arg, fd_set *); ev->u.sel.wfds = va_arg (arg, fd_set *); ev->u.sel.efds = va_arg (arg, fd_set *); - } + nfdarray = 0; + nfdarray = build_fdarray (fdarray, nfdarray, + ev->u.sel.rfds, (FD_READ|FD_ACCEPT) ); + nfdarray = build_fdarray (fdarray, nfdarray, + ev->u.sel.wfds, (FD_WRITE) ); + nfdarray = build_fdarray (fdarray, nfdarray, + ev->u.sel.efds, (FD_OOB|FD_CLOSE) ); - /* Create an Event which needs to be manually reset. */ - memset (&sa, 0, sizeof sa); - sa.bInheritHandle = TRUE; - sa.lpSecurityDescriptor = NULL; - sa.nLength = sizeof sa; - ev->hd = CreateEvent (&sa, TRUE, FALSE, NULL); - if (!ev->hd) - { - free (ev); - return NULL; + for (i=0; i < nfdarray; i++) + { + if (WSAEventSelect (fdarray[i].fd, ev->hd, fdarray[i].netevents)) + { + if (DBG_ERROR) + fprintf (stderr, + "%s: pth_event: WSAEventSelect(%d[%d]) failed: %s\n", + log_get_prefix (NULL), i, fdarray[i].fd, + wsa_strerror (strerr, sizeof strerr)); + } + } } - ev->next = ev; - ev->prev = ev; return ev; } @@ -1050,7 +1256,7 @@ implicit_init (); ev = head; - last = head->next; + last = ev->next; va_start (ap, head); while ( (next = va_arg (ap, pth_event_t))) { @@ -1105,6 +1311,9 @@ } + + + static void * launch_thread (void *arg) { @@ -1311,49 +1520,22 @@ wait_for_fd (ev->u.fd, ev->flags & PTH_UNTIL_FD_READABLE, 3600); if (DBG_INFO) fprintf (stderr, "%s: wait_fd_thread: exit.\n", log_get_prefix (NULL)); - SetEvent (ev->hd); + set_event (ev->hd); ExitThread (0); return NULL; } -static void * -wait_timer_thread (void * ctx) -{ - pth_event_t ev = ctx; - int n = ev->u.tv.tv_sec*1000; - Sleep (n); - SetEvent (ev->hd); - if (DBG_INFO) - fprintf (stderr, "%s: wait_timer_thread: exit.\n", log_get_prefix (NULL)); - ExitThread (0); - return NULL; -} - -static void * -wait_select_thread (void * ctx) -{ - pth_event_t ev = ctx; - - *ev->u.sel.rc = select (ev->u.sel.nfd, - ev->u.sel.rfds, ev->u.sel.wfds, ev->u.sel.efds,NULL); - SetEvent (ev->hd); - if (DBG_INFO) - fprintf (stderr, "%s: wait_select_thread: exit.\n", log_get_prefix (NULL)); - ExitThread (0); - return NULL; -} - - static int do_pth_wait (pth_event_t ev) { + char strerr[256]; HANDLE waitbuf[MAXIMUM_WAIT_OBJECTS/2]; pth_event_t evarray[MAXIMUM_WAIT_OBJECTS/2]; HANDLE threadlist[MAXIMUM_WAIT_OBJECTS/2]; DWORD n; - int pos, idx, threadlistidx, i; + int pos, idx, thlstidx, i; pth_event_t r; if (!ev) @@ -1378,7 +1560,7 @@ /* Prepare all events which requires to launch helper threads for some types. This creates an array of handles which are lates passed to WFMO. */ - pos = threadlistidx = 0; + pos = thlstidx = 0; r = ev; do { @@ -1388,35 +1570,44 @@ if (DBG_INFO) fprintf (stderr, "pth_wait: add signal event\n"); /* Register the global signal event. */ - evarray[pos] = ev; + evarray[pos] = r; waitbuf[pos++] = pth_signo_ev; break; case PTH_EVENT_FD: if (DBG_INFO) fprintf (stderr, "pth_wait: spawn wait_fd_thread\n"); - evarray[pos] = ev; - waitbuf[pos] = spawn_helper_thread (wait_fd_thread, r); - threadlist[threadlistidx++] = waitbuf[pos]; - pos++; + evarray[pos] = r; + waitbuf[pos++] = r->hd; + threadlist[thlstidx++] = spawn_helper_thread (wait_fd_thread, r); break; case PTH_EVENT_TIME: if (DBG_INFO) - fprintf (stderr, "pth_wait: spawn wait_timer_thread\n"); - evarray[pos] = ev; - waitbuf[pos] = spawn_helper_thread (wait_timer_thread, r); - threadlist[threadlistidx++] = waitbuf[pos]; - pos++; + fprintf (stderr, "pth_wait: adding timer event\n"); + { + LARGE_INTEGER ll; + + ll.QuadPart = - (r->u.tv.tv_sec * 10000000ll + + r->u.tv.tv_usec * 10); + if (!SetWaitableTimer (r->hd, &ll, 0, NULL, NULL, FALSE)) + { + if (DBG_ERROR) + fprintf (stderr,"%s: %s: SetWaitableTimer failed: %s\n", + log_get_prefix (NULL), __func__, + w32_strerror (strerr, sizeof strerr)); + return -1; + } + evarray[pos] = r; + waitbuf[pos++] = r->hd; + } break; case PTH_EVENT_SELECT: if (DBG_INFO) - fprintf (stderr, "pth_wait: spawn wait_select_thread.\n"); - evarray[pos] = ev; - waitbuf[pos] = spawn_helper_thread (wait_select_thread, r); - threadlist[threadlistidx++] = waitbuf[pos]; - pos++; + fprintf (stderr, "pth_wait: adding select event\n"); + evarray[pos] = r; + waitbuf[pos++] = r->hd; break; case PTH_EVENT_MUTEX: @@ -1429,9 +1620,19 @@ while ( r != ev ); if (DBG_INFO) - fprintf (stderr, "%s: pth_wait: WFMO n=%d\n", log_get_prefix (NULL), pos); + { + fprintf (stderr, "%s: pth_wait: WFMO n=%d\n", + log_get_prefix (NULL), pos); + for (i=0; i < pos; i++) + fprintf (stderr, "%s: pth_wait: %d=%p\n", + log_get_prefix (NULL), i, waitbuf[i]); + } n = WaitForMultipleObjects (pos, waitbuf, FALSE, INFINITE); - for (i=0; i < threadlistidx; i++) + /* FIXME: We need to cancel all threads or keep them in a list so + that they are reused if we need to wait on the same event again. + Hmmm, that is all bullshit: We need to write a real + scheduler. */ + for (i=0; i < thlstidx; i++) CloseHandle (threadlist[i]); if (DBG_INFO) fprintf (stderr, "%s: pth_wait: WFMO returned %ld\n", @@ -1443,14 +1644,112 @@ /* At least one object has been signaled. Walk over all events with an assigned handle and update the status. We start at N which indicates the lowest signaled event. */ - for (count = 0, idx = n; idx < pos; idx++) - if (idx == n || WaitForSingleObject (waitbuf[idx], 0) == WAIT_OBJECT_0) + for (count = 0, idx = 0; idx < pos; idx++) + if (WaitForSingleObject (evarray[idx]->hd, 0) == WAIT_OBJECT_0) { - ResetEvent (evarray[idx]->hd); - evarray[idx]->status = PTH_STATUS_OCCURRED; + r = evarray[idx]; + + if (DBG_INFO) + fprintf (stderr, "%s: pth_wait: setting %d ev=%p\n", + __func__, idx, r); + r->status = PTH_STATUS_OCCURRED; count++; - if (evarray[idx]->u_type == PTH_EVENT_SIGS) - *(evarray[idx]->u.sig.signo) = pth_signo; + switch (r->u_type) + { + case PTH_EVENT_SIGS: + *(r->u.sig.signo) = pth_signo; + break; + case PTH_EVENT_SELECT: + { + struct fdarray_item_s fdarray[FD_SETSIZE]; + int nfdarray; + WSANETWORKEVENTS ne; + int ntotal = 0; + unsigned long val; + + nfdarray = 0; + nfdarray = build_fdarray (fdarray, nfdarray, + ev->u.sel.rfds, 0 ); + nfdarray = build_fdarray (fdarray, nfdarray, + ev->u.sel.wfds, 0 ); + nfdarray = build_fdarray (fdarray, nfdarray, + ev->u.sel.efds, 0 ); + + if (r->u.sel.rfds) + FD_ZERO (r->u.sel.rfds); + if (r->u.sel.wfds) + FD_ZERO (r->u.sel.wfds); + if (r->u.sel.efds) + FD_ZERO (r->u.sel.efds); + for (i=0; i < nfdarray; i++) + { + if (WSAEnumNetworkEvents (fdarray[i].fd, NULL, &ne)) + { + if (DBG_ERROR) + fprintf (stderr, + "%s: pth_wait: " + "WSAEnumNetworkEvents(%d[%d]) failed: %s\n", + log_get_prefix (NULL), i, fdarray[i].fd, + wsa_strerror (strerr, sizeof strerr)); + continue; + } + + if (r->u.sel.rfds + && (ne.lNetworkEvents & (FD_READ|FD_ACCEPT))) + { + FD_SET (fdarray[i].fd, r->u.sel.rfds); + ntotal++; + } + if (r->u.sel.wfds + && (ne.lNetworkEvents & (FD_WRITE))) + { + FD_SET (fdarray[i].fd, r->u.sel.wfds); + ntotal++; + } + if (r->u.sel.efds + && (ne.lNetworkEvents & (FD_OOB|FD_CLOSE))) + { + FD_SET (fdarray[i].fd, r->u.sel.efds); + ntotal++; + } + + /* Set the socket back to blocking mode. */ + /* Fixme: Do thsi only if the socket was in + blocking mode. */ + if (WSAEventSelect (fdarray[i].fd, NULL, 0)) + { + if (DBG_ERROR) + fprintf (stderr, + "%s: pth_wait: WSAEventSelect(%d[%d]-clear)" + " failed: %s\n", + log_get_prefix (NULL), i, fdarray[i].fd, + wsa_strerror (strerr, sizeof strerr)); + } + + val = 0; + if (ioctlsocket (fdarray[i].fd, FIONBIO, &val) + == SOCKET_ERROR) + { + if (DBG_ERROR) + fprintf (stderr, + "%s: pth_wait: ioctlsocket(%d[%d])" + " failed: %s\n", + log_get_prefix (NULL), i, fdarray[i].fd, + wsa_strerror (strerr, sizeof strerr)); + } + + + } + *r->u.sel.rc = ntotal; + } + break; + } + + /* We don't reset Timer events and I don't know whether + resetEvent will work at all. SetWaitableTimer resets + the timer. */ + if (r->u_type != PTH_EVENT_TIME) + reset_event (evarray[idx]->hd); } if (DBG_INFO) fprintf (stderr, "%s: pth_wait: %d events have been signalled\n", @@ -1527,7 +1826,7 @@ { Sleep (2000); - SetEvent (((pth_event_t)c)->hd); + set_event (((pth_event_t)c)->hd); fprintf (stderr, "\n\nhallo!.\n"); pth_exit (NULL); return NULL; From cvs at cvs.gnupg.org Wed Jul 4 11:34:59 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 04 Jul 2007 11:34:59 +0200 Subject: [svn] GnuPG - r4527 - in trunk: . agent jnlib scd Message-ID: Author: wk Date: 2007-07-04 11:34:28 +0200 (Wed, 04 Jul 2007) New Revision: 4527 Modified: trunk/ChangeLog trunk/agent/ChangeLog trunk/agent/Makefile.am trunk/agent/agent.h trunk/agent/call-pinentry.c trunk/agent/command.c trunk/agent/gpg-agent.c trunk/configure.ac trunk/jnlib/ChangeLog trunk/jnlib/argparse.c trunk/scd/ChangeLog trunk/scd/command.c trunk/scd/scdaemon.c Log: A bunch of minor changes for Windows. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-06-26 13:48:44 UTC (rev 4526) +++ trunk/ChangeLog 2007-07-04 09:34:28 UTC (rev 4527) @@ -1,3 +1,7 @@ +2007-07-03 Werner Koch + + * configure.ac [W32]: Use ws2_32 instead of wsock32. + 2007-06-25 Werner Koch * gl/mkdtemp.c (gen_tempname) [MKDIR_TAKES_ONE_ARG]: Avoid Modified: trunk/agent/ChangeLog =================================================================== --- trunk/agent/ChangeLog 2007-06-26 13:48:44 UTC (rev 4526) +++ trunk/agent/ChangeLog 2007-07-04 09:34:28 UTC (rev 4527) @@ -1,3 +1,25 @@ +2007-07-04 Werner Koch + + * gpg-agent.c (TIMERTICK_INTERVAL): New. + +2007-07-03 Werner Koch + + * gpg-agent.c (handle_connections): Do not use FD_SETSIZE for + select but compute the correct number. + +2007-07-02 Werner Koch + + * command.c (cmd_reloadagent) [W32]: New. + (register_commands) [W32]: New command RELOADAGENT. + + * Makefile.am (gpg_agent_SOURCES): Remove w32main.c and w32main.h. + (gpg_agent_res_ldflags): Remove icon file as we don't have a + proper icon yet. + * gpg-agent.c (main): do not include w32main.h. Remove all calls + to w32main.c. + (agent_sighup_action): New. + (handle_signal): Use it. + 2007-06-26 Werner Koch * gpg-agent.c (create_directories) [W32]: Made it work. Modified: trunk/agent/Makefile.am =================================================================== --- trunk/agent/Makefile.am 2007-06-26 13:48:44 UTC (rev 4526) +++ trunk/agent/Makefile.am 2007-07-04 09:34:28 UTC (rev 4527) @@ -23,7 +23,7 @@ libexec_PROGRAMS = gpg-protect-tool gpg-preset-passphrase noinst_PROGRAMS = $(TESTS) -EXTRA_DIST = gpg-agent.ico gpg-agent-resource.rc +# EXTRA_DIST = gpg-agent.ico gpg-agent-resource.rc AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/common -I$(top_srcdir)/intl @@ -47,25 +47,21 @@ call-scd.c \ learncard.c -if HAVE_W32_SYSTEM -gpg_agent_SOURCES += w32main.c w32main.h -endif - common_libs = ../jnlib/libjnlib.a $(libcommon) ../gl/libgnu.a commonpth_libs = ../jnlib/libjnlib.a $(libcommonpth) ../gl/libgnu.a pwquery_libs = ../common/libsimple-pwquery.a -if HAVE_W32_SYSTEM -.rc.o: - $(WINDRES) `echo $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) | \ - sed -e 's/-I/--include-dir /g;s/-D/--define /g'` -i $< -o $@ - -gpg_agent_res_ldflags = -Wl,gpg-agent-resource.o -Wl,--subsystem,windows -gpg_agent_res_deps = gpg-agent-resource.o -else +#if HAVE_W32_SYSTEM +#.rc.o: +# $(WINDRES) `echo $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) | \ +# sed -e 's/-I/--include-dir /g;s/-D/--define /g'` -i $< -o $@ +# +#gpg_agent_res_ldflags = -Wl,gpg-agent-resource.o -Wl,--subsystem,windows +#gpg_agent_res_deps = gpg-agent-resource.o +#else gpg_agent_res_ldflags = gpg_agent_res_deps = -endif +#endif gpg_agent_CFLAGS = $(AM_CFLAGS) $(LIBASSUAN_PTH_CFLAGS) $(PTH_CFLAGS) Modified: trunk/agent/agent.h =================================================================== --- trunk/agent/agent.h 2007-06-26 13:48:44 UTC (rev 4526) +++ trunk/agent/agent.h 2007-07-04 09:34:28 UTC (rev 4527) @@ -190,6 +190,7 @@ void agent_exit (int rc) JNLIB_GCC_A_NR; /* Also implemented in other tools */ const char *get_agent_socket_name (void); const char *get_agent_ssh_socket_name (void); +void agent_sighup_action (void); /*-- command.c --*/ gpg_error_t agent_write_status (ctrl_t ctrl, const char *keyword, ...); Modified: trunk/agent/call-pinentry.c =================================================================== --- trunk/agent/call-pinentry.c 2007-06-26 13:48:44 UTC (rev 4526) +++ trunk/agent/call-pinentry.c 2007-07-04 09:34:28 UTC (rev 4527) @@ -225,7 +225,7 @@ pgmname++; /* OS X needs the entire file name in argv[0], so that it can locate - the resource bundle. For other systems we stick to the the usual + the resource bundle. For other systems we stick to the usual convention of supplying only the name of the program. */ #ifdef __APPLE__ argv[0] = opt.pinentry_program; Modified: trunk/agent/command.c =================================================================== --- trunk/agent/command.c 2007-06-26 13:48:44 UTC (rev 4526) +++ trunk/agent/command.c 2007-07-04 09:34:28 UTC (rev 4527) @@ -1323,6 +1323,17 @@ ctrl->server_local->stopme = 1; return 0; } + +/* RELOADAGENT + + As signals are inconvenient under Windows, we provide this command + to allow reloading of the configuration. */ +static int +cmd_reloadagent (assuan_context_t ctx, char *line) +{ + agent_sighup_action (); + return 0; +} #endif /*HAVE_W32_SYSTEM*/ @@ -1506,6 +1517,7 @@ { "UPDATESTARTUPTTY", cmd_updatestartuptty }, #ifdef HAVE_W32_SYSTEM { "KILLAGENT", cmd_killagent }, + { "RELOADAGENT", cmd_reloadagent }, #endif { "GETINFO", cmd_getinfo }, { NULL } Modified: trunk/agent/gpg-agent.c =================================================================== --- trunk/agent/gpg-agent.c 2007-06-26 13:48:44 UTC (rev 4526) +++ trunk/agent/gpg-agent.c 2007-07-04 09:34:28 UTC (rev 4527) @@ -48,7 +48,6 @@ #include "sysutils.h" #ifdef HAVE_W32_SYSTEM # include "../jnlib/w32-afunix.h" -# include "w32main.h" #endif #include "setenv.h" @@ -171,6 +170,14 @@ #define MAX_CACHE_TTL_SSH (120*60) /* 2 hours */ #define MIN_PASSPHRASE_LEN (8) +/* The timer tick used for housekeeping stuff. For Windows we use a + longer period as the SetWaitableTimer seems to signal earlier than + the 2 seconds. */ +#ifdef HAVE_W32_SYSTEM +#define TIMERTICK_INTERVAL (4) +#else +#define TIMERTICK_INTERVAL (2) /* Seconds. */ +#endif /* flag to indicate that a shutdown was requested */ static int shutdown_pending; @@ -408,16 +415,9 @@ } -/* The main entry point. For W32 another name is used as the real - entry points needs to be named WinMain and is defined in - w32main.c. */ -#ifdef HAVE_W32_SYSTEM +/* The main entry point. */ int -w32_main (int argc, char **argv ) -#else -int main (int argc, char **argv ) -#endif { ARGPARSE_ARGS pargs; int orig_argc; @@ -851,7 +851,6 @@ #ifdef HAVE_W32_SYSTEM pid = getpid (); printf ("set GPG_AGENT_INFO=%s;%lu;1\n", socket_name, (ulong)pid); - w32_setup_taskbar (); #else /*!HAVE_W32_SYSTEM*/ pid = fork (); if (pid == (pid_t)-1) @@ -1430,6 +1429,17 @@ } +/* A global fucntion which allows us to call the reload stuff from + other palces too. This is only used when build for W32. */ +void +agent_sighup_action (void) +{ + agent_flush_cache (); + reread_configuration (); + agent_reload_trustlist (); +} + + static void handle_signal (int signo) { @@ -1439,9 +1449,7 @@ case SIGHUP: log_info ("SIGHUP received - " "re-reading configuration and flushing cache\n"); - agent_flush_cache (); - reread_configuration (); - agent_reload_trustlist (); + agent_sighup_action (); break; case SIGUSR1: @@ -1545,6 +1553,7 @@ fd_set fdset, read_fdset; int ret; int fd; + int nfd; tattr = pth_attr_new(); pth_attr_set (tattr, PTH_ATTR_JOINABLE, 0); @@ -1562,24 +1571,25 @@ pth_sigmask (SIG_UNBLOCK, &sigs, NULL); ev = pth_event (PTH_EVENT_SIGS, &sigs, &signo); #else - ev = NULL; - signo = 0; + sigs = 0; + ev = pth_event (PTH_EVENT_SIGS, &sigs, &signo); #endif time_ev = NULL; FD_ZERO (&fdset); FD_SET (listen_fd, &fdset); + nfd = listen_fd; if (listen_fd_ssh != -1) - FD_SET (listen_fd_ssh, &fdset); + { + FD_SET (listen_fd_ssh, &fdset); + if (listen_fd_ssh > nfd) + nfd = listen_fd_ssh; + } for (;;) { sigset_t oldsigs; -#ifdef HAVE_W32_SYSTEM - w32_poll_events (); -#endif - if (shutdown_pending) { if (pth_ctrl (PTH_CTRL_GETTHREADS) == 1) @@ -1596,7 +1606,8 @@ /* Create a timeout event if needed. */ if (!time_ev) - time_ev = pth_event (PTH_EVENT_TIME, pth_timeout (2, 0)); + time_ev = pth_event (PTH_EVENT_TIME, + pth_timeout (TIMERTICK_INTERVAL, 0)); /* POSIX says that fd_set should be implemented as a structure, thus a simple assignment is fine to copy the entire set. */ @@ -1604,7 +1615,7 @@ if (time_ev) pth_event_concat (ev, time_ev, NULL); - ret = pth_select_ev (FD_SETSIZE, &read_fdset, NULL, NULL, NULL, ev); + ret = pth_select_ev (nfd+1, &read_fdset, NULL, NULL, NULL, ev); if (time_ev) pth_event_isolate (time_ev); @@ -1643,8 +1654,8 @@ /* We now might create new threads and because we don't want any - signals - we are handling here - to be delivered to a new - thread. Thus we need to block those signals. */ + signals (as we are handling them here) to be delivered to a + new thread. Thus we need to block those signals. */ pth_sigmask (SIG_BLOCK, &sigs, &oldsigs); if (FD_ISSET (listen_fd, &read_fdset)) Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-06-26 13:48:44 UTC (rev 4526) +++ trunk/configure.ac 2007-07-04 09:34:28 UTC (rev 4527) @@ -1160,7 +1160,7 @@ # requiring any network stuff but linking to code in libcommon which # tracks in winsock stuff (e.g. init_common_subsystems. if test "$have_w32_system" = yes; then - W32SOCKLIBS="-lwsock32" + W32SOCKLIBS="-lws2_32" NETLIBS="${NETLIBS} ${W32SOCKLIBS}" fi Modified: trunk/jnlib/ChangeLog =================================================================== --- trunk/jnlib/ChangeLog 2007-06-26 13:48:44 UTC (rev 4526) +++ trunk/jnlib/ChangeLog 2007-07-04 09:34:28 UTC (rev 4527) @@ -1,3 +1,9 @@ +2007-07-01 Werner Koch + + * argparse.c (strusage): Use id 10 for the license string; + default to GPL3+. Change long note to version 3 or later. + (show_version): Print the license info. + 2007-06-19 Werner Koch * Makefile.am: Add support for regression tests. Modified: trunk/jnlib/argparse.c =================================================================== --- trunk/jnlib/argparse.c 2007-06-26 13:48:44 UTC (rev 4526) +++ trunk/jnlib/argparse.c 2007-07-04 09:34:28 UTC (rev 4527) @@ -844,64 +844,71 @@ static void show_version() { - const char *s; - int i; - /* version line */ - fputs(strusage(11), stdout); - if( (s=strusage(12)) ) - printf(" (%s)", s ); - printf(" %s\n", strusage(13) ); - /* additional version lines */ - for(i=20; i < 30; i++ ) - if( (s=strusage(i)) ) - printf("%s\n", s ); - /* copyright string */ - if( (s=strusage(14)) ) - printf("%s\n", s ); - /* copying conditions */ - if( (s=strusage(15)) ) - fputs(s, stdout); - /* thanks */ - if( (s=strusage(18)) ) - fputs(s, stdout); - /* additional program info */ - for(i=30; i < 40; i++ ) - if( (s=strusage(i)) ) - fputs (s, stdout); - fflush(stdout); + const char *s; + int i; + + /* Version line. */ + fputs (strusage (11), stdout); + if ((s=strusage (12))) + printf (" (%s)", s ); + printf (" %s\n", strusage (13) ); + /* Additional version lines. */ + for (i=20; i < 30; i++) + if ((s=strusage (i))) + printf ("%s\n", s ); + /* Copyright string. */ + if( (s=strusage (14)) ) + printf("%s\n", s ); + /* Licence string. */ + if( (s=strusage (10)) ) + printf("%s\n", s ); + /* Copying conditions. */ + if ( (s=strusage(15)) ) + fputs (s, stdout); + /* Thanks. */ + if ((s=strusage(18))) + fputs (s, stdout); + /* Additional program info. */ + for (i=30; i < 40; i++ ) + if ( (s=strusage (i)) ) + fputs (s, stdout); + fflush(stdout); } void -usage( int level ) +usage (int level) { - if( !level ) { - fprintf(stderr,"%s %s; %s\n", strusage(11), strusage(13), - strusage(14) ); - fflush(stderr); + if (!level) + { + fprintf(stderr,"%s %s; %s\n", strusage(11), strusage(13), strusage (14)); + fflush (stderr); } - else if( level == 1 ) { - fputs(strusage(40),stderr); - exit(2); + else if (level == 1) + { + fputs (strusage (40), stderr); + exit (2); } - else if( level == 2 ) { - puts(strusage(41)); - exit(0); + else if (level == 2) + { + puts (strusage(41)); + exit (0); } } /* Level - * 0: Copyright String auf stderr ausgeben - * 1: Kurzusage auf stderr ausgeben und beenden - * 2: Langusage auf stdout ausgeben und beenden - * 11: name of program - * 12: optional name of package which includes this program. + * 0: Print copyright string to stderr + * 1: Print a short usage hint to stderr and terminate + * 2: Print a long usage hint to stdout and terminate + * 10: Return license info string + * 11: Return the name of the program + * 12: Return optional name of package which includes this program. * 13: version string * 14: copyright string * 15: Short copying conditions (with LFs) * 16: Long copying conditions (with LFs) * 17: Optional printable OS name - * 18: Optional thanks list (with LFs) + * 18: Optional thanks list (with LFs) * 19: Bug report info *20..29: Additional lib version strings. *30..39: Additional program info (with LFs) @@ -917,26 +924,27 @@ return p; switch( level ) { + case 10: p = ("License GPLv2+: GNU GPL version 2 or later " + ""); + break; case 11: p = "foo"; break; case 13: p = "0.0"; break; case 14: p = "Copyright (C) 2007 Free Software Foundation, Inc."; break; case 15: p = -"This program comes with ABSOLUTELY NO WARRANTY.\n" -"This is free software, and you are welcome to redistribute it\n" -"under certain conditions. See the file COPYING for details.\n"; break; +"This is free software: you are free to change and redistribute it.\n" +"There is NO WARRANTY, to the extent permitted by law.\n"; + break; case 16: p = "This is free software; you can redistribute it and/or modify\n" "it under the terms of the GNU General Public License as published by\n" -"the Free Software Foundation; either version 2 of the License, or\n" +"the Free Software Foundation; either version 3 of the License, or\n" "(at your option) any later version.\n\n" "It is distributed in the hope that it will be useful,\n" "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" "GNU General Public License for more details.\n\n" "You should have received a copy of the GNU General Public License\n" -"along with this program; if not, write to the Free Software\n" -"Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,\n" -"USA.\n"; +"along with this software. If not, see .\n"; break; case 40: /* short and long usage */ case 41: p = ""; break; Modified: trunk/scd/ChangeLog =================================================================== --- trunk/scd/ChangeLog 2007-06-26 13:48:44 UTC (rev 4526) +++ trunk/scd/ChangeLog 2007-07-04 09:34:28 UTC (rev 4527) @@ -1,3 +1,12 @@ +2007-07-04 Werner Koch + + * command.c (cmd_getinfo): New subcommand "version". + + * scdaemon.c (TIMERTICK_INTERVAL): New. + (handle_connections) [W32]: Enable a dummy sigs event. + (handle_connections): Use a proper count for select and not + FD_SETSIZE. + 2007-06-21 Werner Koch * scdaemon.h (ctrl_t): Remove. It is now declared in ../common/util.h. Modified: trunk/scd/command.c =================================================================== --- trunk/scd/command.c 2007-06-26 13:48:44 UTC (rev 4526) +++ trunk/scd/command.c 2007-07-04 09:34:28 UTC (rev 4527) @@ -1402,6 +1402,8 @@ Multi purpose command to return certain information. Supported values of WHAT are: + version - Return the version of the program. + socket_name - Return the name of the socket. status - Return the status of the current slot (in the future, may @@ -1420,8 +1422,13 @@ { int rc = 0; - if (!strcmp (line, "socket_name")) + if (!strcmp (line, "version")) { + const char *s = VERSION; + rc = assuan_send_data (ctx, s, strlen (s)); + } + else if (!strcmp (line, "socket_name")) + { const char *s = scd_get_socket_name (); if (s) Modified: trunk/scd/scdaemon.c =================================================================== --- trunk/scd/scdaemon.c 2007-06-26 13:48:44 UTC (rev 4526) +++ trunk/scd/scdaemon.c 2007-07-04 09:34:28 UTC (rev 4527) @@ -150,7 +150,16 @@ #define DEFAULT_PCSC_DRIVER "libpcsclite.so" #endif +/* The timer tick used for housekeeping stuff. For Windows we use a + longer period as the SetWaitableTimer seems to signal earlier than + the 2 seconds. */ +#ifdef HAVE_W32_SYSTEM +#define TIMERTICK_INTERVAL (4) +#else +#define TIMERTICK_INTERVAL (2) /* Seconds. */ +#endif + /* Flag to indicate that a shutdown was requested. */ static int shutdown_pending; @@ -280,7 +289,7 @@ FILE *configfp = NULL; char *configname = NULL; const char *shell; - unsigned configlineno; + unsigned int configlineno; int parse_debug = 0; const char *debug_level = NULL; int default_config =1; @@ -1040,6 +1049,7 @@ fd_set fdset, read_fdset; int ret; int fd; + int nfd; tattr = pth_attr_new(); pth_attr_set (tattr, PTH_ATTR_JOINABLE, 0); @@ -1055,13 +1065,18 @@ pth_sigmask (SIG_UNBLOCK, &sigs, NULL); ev = pth_event (PTH_EVENT_SIGS, &sigs, &signo); #else - ev = NULL; + sigs = 0; + ev = pth_event (PTH_EVENT_SIGS, &sigs, &signo); #endif time_ev = NULL; FD_ZERO (&fdset); + nfd = 0; if (listen_fd != -1) - FD_SET (listen_fd, &fdset); + { + FD_SET (listen_fd, &fdset); + nfd = listen_fd; + } for (;;) { @@ -1081,7 +1096,8 @@ /* Create a timeout event if needed. */ if (!time_ev) - time_ev = pth_event (PTH_EVENT_TIME, pth_timeout (2, 0)); + time_ev = pth_event (PTH_EVENT_TIME, + pth_timeout (TIMERTICK_INTERVAL, 0)); /* POSIX says that fd_set should be implemented as a structure, thus a simple assignment is fine to copy the entire set. */ @@ -1089,7 +1105,7 @@ if (time_ev) pth_event_concat (ev, time_ev, NULL); - ret = pth_select_ev (FD_SETSIZE, &read_fdset, NULL, NULL, NULL, ev); + ret = pth_select_ev (nfd+1, &read_fdset, NULL, NULL, NULL, ev); if (time_ev) pth_event_isolate (time_ev); From cvs at cvs.gnupg.org Wed Jul 4 11:35:23 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 04 Jul 2007 11:35:23 +0200 Subject: [svn] assuan - r240 - in trunk: . src Message-ID: Author: wk Date: 2007-07-04 11:34:54 +0200 (Wed, 04 Jul 2007) New Revision: 240 Modified: trunk/ChangeLog trunk/autogen.sh trunk/configure.ac trunk/src/ChangeLog trunk/src/assuan-defs.h trunk/src/assuan-handler.c trunk/src/assuan-logging.c Log: A couple of Changes for Windows Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-06-15 11:05:31 UTC (rev 239) +++ trunk/ChangeLog 2007-07-04 09:34:54 UTC (rev 240) @@ -1,3 +1,12 @@ +2007-07-03 Werner Koch + + * configure.ac (NETLIBS): Use ws2_32 instead of wsock32. + +2007-06-15 Werner Koch + + * autogen.sh: Use = and not == in test to be POSIXly correct. + Change shell back to /bin/sh. + 2007-06-15 Marcus Brinkmann * autogen.sh: Require bash. Modified: trunk/autogen.sh =================================================================== --- trunk/autogen.sh 2007-06-15 11:05:31 UTC (rev 239) +++ trunk/autogen.sh 2007-07-04 09:34:54 UTC (rev 240) @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # Run this to generate all the initial makefiles, etc. # # Copyright (C) 2003 g10 Code GmbH @@ -31,7 +31,7 @@ DIE=no FORCE= -if test "$1" == "--force"; then +if test x"$1" = x"--force"; then FORCE=" --force" shift fi Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-06-15 11:05:31 UTC (rev 239) +++ trunk/configure.ac 2007-07-04 09:34:54 UTC (rev 240) @@ -154,7 +154,7 @@ fi LIBASSUAN_CONFIG_EXTRA_LIBS= if test "$have_w32_system" = yes; then - LIBASSUAN_CONFIG_EXTRA_LIBS="$LIBASSUAN_CONFIG_EXTRA_LIBS -lwsock32" + LIBASSUAN_CONFIG_EXTRA_LIBS="$LIBASSUAN_CONFIG_EXTRA_LIBS -lws2_32" fi if test x"$NETLIBS" != x; then LIBASSUAN_CONFIG_EXTRA_LIBS="$LIBASSUAN_CONFIG_EXTRA_LIBS $NETLIBS" Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2007-06-15 11:05:31 UTC (rev 239) +++ trunk/src/ChangeLog 2007-07-04 09:34:54 UTC (rev 240) @@ -1,3 +1,10 @@ +2007-06-18 Werner Koch + + * assuan-logging.c (load_libgpg_error, _assuan_gpg_strerror_r) + (_assuan_gpg_strsource): New. + * assuan-handler.c (process_request) [W32]: Use these new + functions for human understable error codes. + 2007-06-12 Werner Koch * assuan-io.c (_assuan_simple_read): Hack to allow reading from a Modified: trunk/src/assuan-defs.h =================================================================== --- trunk/src/assuan-defs.h 2007-06-15 11:05:31 UTC (rev 239) +++ trunk/src/assuan-defs.h 2007-07-04 09:34:54 UTC (rev 240) @@ -261,6 +261,8 @@ #ifdef HAVE_W32_SYSTEM const char *_assuan_w32_strerror (int ec); #define w32_strerror(e) _assuan_w32_strerror ((e)) +int _assuan_gpg_strerror_r (unsigned int err, char *buf, size_t buflen); +const char *_assuan_gpg_strsource (unsigned int err); #endif /*HAVE_W32_SYSTEM*/ Modified: trunk/src/assuan-handler.c =================================================================== --- trunk/src/assuan-handler.c 2007-06-15 11:05:31 UTC (rev 239) +++ trunk/src/assuan-handler.c 2007-07-04 09:34:54 UTC (rev 240) @@ -509,7 +509,24 @@ { const char *text = ctx->err_no == rc? ctx->err_str:NULL; -#if defined(__GNUC__) && defined(__ELF__) +#if defined(HAVE_W32_SYSTEM) + unsigned int source, code; + char ebuf[50]; + const char *esrc; + + source = ((rc >> 24) & 0xff); + code = (rc & 0x00ffffff); + if (source + && !_assuan_gpg_strerror_r (rc, ebuf, sizeof ebuf) + && (esrc=_assuan_gpg_strsource (rc))) + { + /* Assume this is an libgpg-error. */ + sprintf (errline, "ERR %d %.50s <%.30s>%s%.100s", + rc, ebuf, esrc, + text? " - ":"", text?text:""); + } + else +#elif defined(__GNUC__) && defined(__ELF__) /* If we have weak symbol support we try to use the error strings from libgpg-error without creating a dependency. They are used for debugging purposes only, so there is no @@ -526,7 +543,7 @@ __attribute__ ((weak)); const char *gpg_strsource (unsigned int err) __attribute__ ((weak)); -#if !defined(HAVE_W32_SYSTEM) && __GNUC__ < 3 +#if __GNUC__ < 3 #pragma weak gpg_strerror_r #pragma weak gpg_strsource #endif Modified: trunk/src/assuan-logging.c =================================================================== --- trunk/src/assuan-logging.c 2007-06-15 11:05:31 UTC (rev 239) +++ trunk/src/assuan-logging.c 2007-07-04 09:34:54 UTC (rev 240) @@ -1,5 +1,5 @@ /* assuan-logging.c - Default logging function. - * Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. + * Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc. * * This file is part of Assuan. * @@ -238,4 +238,51 @@ strerr, sizeof (strerr)-1, NULL); return strerr; } + +static int (*my_strerror_r) (unsigned int err, char *buf, size_t buflen); +static const char * (*my_strsource) (unsigned int err); + +static int +load_libgpg_error (void) +{ + /* This code is not race free but suitable for our purpose. */ + static volatile int initialized; + void *handle; + + if (initialized) + return (my_strerror_r && my_strsource)? 0:-1; + handle = LoadLibrary ("libgpg-error-0.dll"); + if (handle) + { + void *foo, *bar; + foo = GetProcAddress (handle, "gpg_strerror_r"); + bar = GetProcAddress (handle, "gpg_strsource"); + if (foo && bar) + { + my_strerror_r = foo; + my_strsource = bar; + } + else + CloseHandle (handle); + } + initialized = 1; + return 0; +} + +int +_assuan_gpg_strerror_r (unsigned int err, char *buf, size_t buflen) +{ + if (load_libgpg_error ()) + return -1; + return my_strerror_r (err, buf, buflen); +} + + +const char * +_assuan_gpg_strsource (unsigned int err) +{ + if (load_libgpg_error ()) + return NULL; + return my_strsource (err); +} #endif /*HAVE_W32_SYSTEM*/ From cvs at cvs.gnupg.org Wed Jul 4 14:15:17 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 04 Jul 2007 14:15:17 +0200 Subject: [svn] ksba - r277 - tags Message-ID: Author: wk Date: 2007-07-04 14:14:49 +0200 (Wed, 04 Jul 2007) New Revision: 277 Added: tags/libksba-1.0.2/ Log: From cvs at cvs.gnupg.org Wed Jul 4 21:58:16 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Wed, 04 Jul 2007 21:58:16 +0200 Subject: [svn] assuan - r241 - trunk/src Message-ID: Author: marcus Date: 2007-07-04 21:57:47 +0200 (Wed, 04 Jul 2007) New Revision: 241 Modified: trunk/src/ChangeLog trunk/src/assuan-connect.c trunk/src/assuan-defs.h trunk/src/assuan-io-pth.c trunk/src/assuan.h Log: 2007-07-04 Marcus Brinkmann Change _WIN32 to HAVE_W32_SYSTEM for consistency. * assuan-defs.h (struct assuan_context_s): Have full peercred structure even if not HAVE_SO_PEERCRED, but not if HAVE_W32_SYSTEM. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2007-07-04 09:34:54 UTC (rev 240) +++ trunk/src/ChangeLog 2007-07-04 19:57:47 UTC (rev 241) @@ -1,3 +1,11 @@ +2007-07-04 Marcus Brinkmann + + Change _WIN32 to HAVE_W32_SYSTEM for consistency. + + * assuan-defs.h (struct assuan_context_s): Have full peercred + structure even if not HAVE_SO_PEERCRED, but not if + HAVE_W32_SYSTEM. + 2007-06-18 Werner Koch * assuan-logging.c (load_libgpg_error, _assuan_gpg_strerror_r) Modified: trunk/src/assuan-connect.c =================================================================== --- trunk/src/assuan-connect.c 2007-07-04 09:34:54 UTC (rev 240) +++ trunk/src/assuan-connect.c 2007-07-04 19:57:47 UTC (rev 241) @@ -62,7 +62,7 @@ /* Return user credentials. PID, UID and GID amy be gived as NULL if you are not interested in this value. For getting the pid of the peer the assuan_get_pid is usually better suited. */ -#ifndef _WIN32 +#ifndef HAVE_W32_SYSTEM assuan_error_t assuan_get_peercred (assuan_context_t ctx, pid_t *pid, uid_t *uid, gid_t *gid) { @@ -78,4 +78,4 @@ *gid = ctx->peercred.gid; return 0; } -#endif /*_WIN32*/ +#endif /* HAVE_W32_SYSTEM */ Modified: trunk/src/assuan-defs.h =================================================================== --- trunk/src/assuan-defs.h 2007-07-04 09:34:54 UTC (rev 240) +++ trunk/src/assuan-defs.h 2007-07-04 19:57:47 UTC (rev 241) @@ -140,14 +140,14 @@ int listen_fd; /* The fd we are listening on (used by socket servers) */ int connected_fd; /* helper */ +#ifndef HAVE_W32_SYSTEM struct { - int valid; /* Whether this structure has valid information. */ -#ifdef HAVE_SO_PEERCRED + int valid; /* Whether this structure has valid information. */ pid_t pid; /* The pid of the peer. */ uid_t uid; /* The uid of the peer. */ gid_t gid; /* The gid of the peer. */ -#endif /*HAVE_SO_PEERCRED*/ } peercred; +#endif /* HAVE_W32_SYSTEM */ /* Used for Unix domain sockets. */ struct sockaddr_un myaddr; @@ -284,7 +284,7 @@ ssize_t _assuan_simple_read (assuan_context_t ctx, void *buffer, size_t size); ssize_t _assuan_simple_write (assuan_context_t ctx, const void *buffer, size_t size); -#ifdef _WIN32 +#ifdef HAVE_W32_SYSTEM int _assuan_simple_sendmsg (assuan_context_t ctx, void *msg); int _assuan_simple_recvmsg (assuan_context_t ctx, void *msg); #else Modified: trunk/src/assuan-io-pth.c =================================================================== --- trunk/src/assuan-io-pth.c 2007-07-04 09:34:54 UTC (rev 240) +++ trunk/src/assuan-io-pth.c 2007-07-04 19:57:47 UTC (rev 241) @@ -65,7 +65,7 @@ return pth_write (ctx->outbound.fd, buffer, size); } -#ifdef _WIN32 +#ifdef HAVE_W32_SYSTEM int _assuan_simple_sendmsg (assuan_context_t ctx, void *msg) #else @@ -106,7 +106,7 @@ #endif } -#ifdef _WIN32 +#ifdef HAVE_W32_SYSTEM int _assuan_simple_recvmsg (assuan_context_t ctx, void *msg) #else Modified: trunk/src/assuan.h =================================================================== --- trunk/src/assuan.h 2007-07-04 09:34:54 UTC (rev 240) +++ trunk/src/assuan.h 2007-07-04 19:57:47 UTC (rev 241) @@ -425,7 +425,7 @@ /*-- assuan-connect.c --*/ void assuan_disconnect (assuan_context_t ctx); pid_t assuan_get_pid (assuan_context_t ctx); -#ifndef _WIN32 +#ifndef HAVE_W32_SYSTEM assuan_error_t assuan_get_peercred (assuan_context_t ctx, pid_t *pid, uid_t *uid, gid_t *gid); #endif From cvs at cvs.gnupg.org Wed Jul 4 22:03:07 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Wed, 04 Jul 2007 22:03:07 +0200 Subject: [svn] gpgme - r1219 - trunk Message-ID: Author: marcus Date: 2007-07-04 22:02:38 +0200 (Wed, 04 Jul 2007) New Revision: 1219 Modified: trunk/ChangeLog trunk/configure.ac Log: 2007-07-04 Marcus Brinkmann * autogen.sh: Use = not == in test. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-06-29 14:41:35 UTC (rev 1218) +++ trunk/ChangeLog 2007-07-04 20:02:38 UTC (rev 1219) @@ -1,3 +1,7 @@ +2007-07-04 Marcus Brinkmann + + * autogen.sh: Use = not == in test. + 2007-03-05 Werner Koch Released 1.1.4. Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-06-29 14:41:35 UTC (rev 1218) +++ trunk/configure.ac 2007-07-04 20:02:38 UTC (rev 1219) @@ -538,6 +538,22 @@ [Defined if descriptor passing is enabled and supported]) AM_CONDITIONAL(USE_DESCRIPTOR_PASSING, test "$use_descriptor_passing" = "yes") +# Assuan check for the getsockopt SO_PEERCRED +AC_MSG_CHECKING(for SO_PEERCRED) +AC_CACHE_VAL(assuan_cv_sys_so_peercred, + [AC_TRY_COMPILE([#include ], + [struct ucred cr; + int cl = sizeof cr; + getsockopt (1, SOL_SOCKET, SO_PEERCRED, &cr, &cl);], + assuan_cv_sys_so_peercred=yes, + assuan_cv_sys_so_peercred=no) + ]) +AC_MSG_RESULT($assuan_cv_sys_so_peercred) +if test $assuan_cv_sys_so_peercred = yes; then + AC_DEFINE(HAVE_SO_PEERCRED, 1, + [Defined if SO_PEERCRED is supported (Linux specific)]) +fi + # End of assuan checks. AM_CONDITIONAL(BUILD_COMPLUS, test "$component_system" = "COM+") From cvs at cvs.gnupg.org Wed Jul 4 22:04:09 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Wed, 04 Jul 2007 22:04:09 +0200 Subject: [svn] gpgme - r1220 - in trunk: . assuan Message-ID: Author: marcus Date: 2007-07-04 22:03:39 +0200 (Wed, 04 Jul 2007) New Revision: 1220 Modified: trunk/ChangeLog trunk/assuan/ChangeLog trunk/assuan/README.1st trunk/assuan/assuan-client.c trunk/assuan/assuan-connect.c trunk/assuan/assuan-defs.h trunk/assuan/assuan-handler.c trunk/assuan/assuan-io.c trunk/assuan/assuan-logging.c trunk/assuan/assuan-pipe-connect.c trunk/assuan/assuan-pipe-server.c trunk/assuan/assuan-socket-server.c trunk/assuan/assuan-uds.c trunk/assuan/assuan.h trunk/autogen.sh Log: 2007-07-04 Marcus Brinkmann * assuan/: Update files to 2007-07-04 version of assuan. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-07-04 20:02:38 UTC (rev 1219) +++ trunk/ChangeLog 2007-07-04 20:03:39 UTC (rev 1220) @@ -1,5 +1,7 @@ 2007-07-04 Marcus Brinkmann + * assuan/: Update files to 2007-07-04 version of assuan. + * autogen.sh: Use = not == in test. 2007-03-05 Werner Koch Modified: trunk/assuan/ChangeLog =================================================================== --- trunk/assuan/ChangeLog 2007-07-04 20:02:38 UTC (rev 1219) +++ trunk/assuan/ChangeLog 2007-07-04 20:03:39 UTC (rev 1220) @@ -1,3 +1,71 @@ +2007-07-04 Marcus Brinkmann + + Change _WIN32 to HAVE_W32_SYSTEM for consistency. + + * assuan-defs.h (struct assuan_context_s): Have full peercred + structure even if not HAVE_SO_PEERCRED, but not if + HAVE_W32_SYSTEM. + +2007-06-18 Werner Koch + + * assuan-logging.c (load_libgpg_error, _assuan_gpg_strerror_r) + (_assuan_gpg_strsource): New. + * assuan-handler.c (process_request) [W32]: Use these new + functions for human understable error codes. + +2007-06-12 Werner Koch + + * assuan-io.c (_assuan_simple_read): Hack to allow reading from a + socket. + (_assuan_simple_write): Likewise. + +2007-06-11 Werner Koch + + * assuan-io-pth.c (_assuan_simple_read, _assuan_simple_write): Use + pth versions also for W32. + +2007-05-29 Werner Koch + + * assuan-io-pth.c: Include sys/socket.h only if available. Remove + double inclusion of sys/wait.h + + * assuan-pipe-connect.c (build_w32_commandline): Make ARGV const. + + * assuan-pipe-server.c (is_valid_socket) [W32]: Do not define. + + * assuan-socket-server.c [W32]: Include ws2tcpip.h to define + socklen_t. + * assuan-defs.h (struct assuan_context_s): Define most peercred + members only if we can really set them. + (_assuan_simple_sendmsg, _assuan_simple_recvmsg) [W32]: Use a + different prototype. + * assuan.h (assuan_get_peercred) [W32]: Do not define. + * assuan-io.c (_assuan_simple_sendmsg, _assuan_simple_recvmsg) + [w32]: Use another prototype. + +2007-05-09 Werner Koch + + * libassuan.m4: Print found version on success. + +2007-05-01 Werner Koch + + * assuan-uds.c (uds_reader): Cast void ptr for arithmetics. + Reported by Peter O'Gorman. + +2006-12-03 Marcus Brinkmann + + * assuan-handler.c (assuan_command_parse_fd): Also allow white + space after FD. + +2006-12-02 Marcus Brinkmann + + * assuan-uds.c (uds_reader): Return 0 if recvmsg returns 0. + +2006-12-01 Marcus Brinkmann + + * assuan-client.c (assuan_transact): Also translate some of the + legacy error codes. + 2006-11-22 Werner Koch * assuan-handler.c (fun1_cookie_write, fun2_cookie_write): New. @@ -328,21 +396,107 @@ * assuan-buffer.c (assuan_write_line): If the line is longer than the maximum line length, bail out early. +2004-04-21 Werner Koch + + * assuan-socket-server.c (accept_connection_bottom): Save the pid + of the peer if it is available. + * assuan-socket-connect.c (assuan_socket_connect): Do not save the + dummy SERVED_PID arg. + * assuan-pipe-connect.c (do_finish): Don't wait if the pid is 0. + (assuan_pipe_connect2): Store the parents pid in the environment + of the child. + * assuan-pipe-server.c (assuan_init_pipe_server): Initialize the + peer's pid from the environment. + * assuan-connect.c (assuan_get_pid): Do not return 0 as a PID. + 2004-04-19 Werner Koch - * assuan-socket-connect.c: Include sys/types.h - * assuan-socket-server.c: Ditto + * assuan-socket-server.c, assuan-socket-connect.c: Includes + sys/types.h. Reported by Michael Nottebrock. * assuan-domain-connect.c: Ditto. +2004-04-13 Werner Koch + + * assuan-util.c (_assuan_log_print_buffer): Relaxed quoting. + (_assuan_log_sanitized_string): Ditto. + +2004-03-14 Werner Koch + + * assuan-handler.c: Include . Reported by Bernd Kuhls. + 2004-02-18 Werner Koch + * libassuan-config.in: Ignore setting of --prefix. + * assuan-handler.c (assuan_get_data_fp): Fail with ENOSYS if we can't implement this. +2004-02-15 Werner Koch + + * memrchr.c (memrchr): Fixed implementation. Taken from gpgme. + 2004-02-13 Werner Koch - * assuan-domain-connect.c: Removed the unneeded alloca.h + * assuan-domain-connect.c: Removed the unneeded alloca.h. +2004-01-24 Werner Koch + + * assuan-pipe-connect.c (assuan_pipe_connect2): New as an + extension of assuan_pipe_connect. Made the latter call this one. + +2004-01-14 Werner Koch + + * assuan-buffer.c (_assuan_cookie_write_data): Return the + requested size to indicate successful operation. Fixes a spurious + bug we previously fixed using fflush(). + +2003-12-22 Werner Koch + + * assuan.h (ASSUAN_Locale_Problem): Added. + * assuan-errors.c (assuan_strerror): Ditto. + +2003-12-18 Werner Koch + + * assuan.h (AssuanCommand): Clarified that these are now + deprecated and actually useless. + (assuan_error_t): Clarified and added ASSUAN_USER_ERROR_FIRST, + ASSUAN_USER_ERROR_LAST. + +2003-12-16 Werner Koch + + * assuan-buffer.c: Changed formatting of the debug output prefix. + * assuan-util.c (assuan_set_log_stream): Set global log stream if + it has not been done yet. + * assuan-logging.c (_assuan_set_default_log_stream): New. + (assuan_set_assuan_log_prefix): New. + +2003-12-11 Werner Koch + + * funopen.c (_assuan_funopen): Renamed from funopen, to keep the + name space clean and avoid duplicate definitions if another + library uses the same replacement. + * assuan-defs.h (funopen): Renamed prototype and add a macro. + +2003-12-08 Werner Koch + + * TODO: Removed. + +2003-11-12 Werner Koch + + * assuan-handler.c (process_request): Kludge to print better error + messages for gpg-error enabled programs. + +2003-11-06 Werner Koch + + * assuan.h (assuan_context_t): New. Should be used in favor of + ASSUAN_CONTEXT. + (assuan_error_t): New. To be used instead of AssuanError. + +2003-11-11 Moritz Schulte + + * assuan-socket-connect.c (assuan_socket_connect): Fix computation + of socket address length. + 2003-08-13 Werner Koch * assuan-inquire.c (assuan_inquire): Increase length of cmdbuf to @@ -818,7 +972,7 @@ * assuan-defs.h: Add space in the context for this. - Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright 2001, 2002, 2006 Free Software Foundation, Inc. This file is free software; as a special exception the author gives unlimited permission to copy and/or distribute it, with or without Modified: trunk/assuan/README.1st =================================================================== --- trunk/assuan/README.1st 2007-07-04 20:02:38 UTC (rev 1219) +++ trunk/assuan/README.1st 2007-07-04 20:03:39 UTC (rev 1220) @@ -23,6 +23,9 @@ namespace. It also wraps all system functions that are wrapped by GNU Pth to _gpgme wrappers. +* assuan-io-pth.c + We don't need this file as GPGME doesn't use sendmsg and recvmsg. + If it would, we would need to pick up the W32 implementation. Copyright 2004 g10 Code GmbH Modified: trunk/assuan/assuan-client.c =================================================================== --- trunk/assuan/assuan-client.c 2007-07-04 20:02:38 UTC (rev 1219) +++ trunk/assuan/assuan-client.c 2007-07-04 20:03:39 UTC (rev 1220) @@ -164,7 +164,7 @@ rc = atoi (line); if (rc > 0 && rc < 100) rc = _assuan_error (ASSUAN_Server_Fault); - else if (rc > 0 && rc <= 128) + else if (rc > 0 && rc <= 405) rc = _assuan_error (rc); } else if (okay == 2) Modified: trunk/assuan/assuan-connect.c =================================================================== --- trunk/assuan/assuan-connect.c 2007-07-04 20:02:38 UTC (rev 1219) +++ trunk/assuan/assuan-connect.c 2007-07-04 20:03:39 UTC (rev 1220) @@ -62,6 +62,7 @@ /* Return user credentials. PID, UID and GID amy be gived as NULL if you are not interested in this value. For getting the pid of the peer the assuan_get_pid is usually better suited. */ +#ifndef HAVE_W32_SYSTEM assuan_error_t assuan_get_peercred (assuan_context_t ctx, pid_t *pid, uid_t *uid, gid_t *gid) { @@ -77,3 +78,4 @@ *gid = ctx->peercred.gid; return 0; } +#endif /* HAVE_W32_SYSTEM */ Modified: trunk/assuan/assuan-defs.h =================================================================== --- trunk/assuan/assuan-defs.h 2007-07-04 20:02:38 UTC (rev 1219) +++ trunk/assuan/assuan-defs.h 2007-07-04 20:03:39 UTC (rev 1220) @@ -140,12 +140,14 @@ int listen_fd; /* The fd we are listening on (used by socket servers) */ int connected_fd; /* helper */ +#ifndef HAVE_W32_SYSTEM struct { - int valid; /* Whether this structure has valid information. */ + int valid; /* Whether this structure has valid information. */ pid_t pid; /* The pid of the peer. */ uid_t uid; /* The uid of the peer. */ gid_t gid; /* The gid of the peer. */ } peercred; +#endif /* HAVE_W32_SYSTEM */ /* Used for Unix domain sockets. */ struct sockaddr_un myaddr; @@ -259,6 +261,8 @@ #ifdef HAVE_W32_SYSTEM const char *_assuan_w32_strerror (int ec); #define w32_strerror(e) _assuan_w32_strerror ((e)) +int _assuan_gpg_strerror_r (unsigned int err, char *buf, size_t buflen); +const char *_assuan_gpg_strsource (unsigned int err); #endif /*HAVE_W32_SYSTEM*/ @@ -280,8 +284,13 @@ ssize_t _assuan_simple_read (assuan_context_t ctx, void *buffer, size_t size); ssize_t _assuan_simple_write (assuan_context_t ctx, const void *buffer, size_t size); +#ifdef HAVE_W32_SYSTEM +int _assuan_simple_sendmsg (assuan_context_t ctx, void *msg); +int _assuan_simple_recvmsg (assuan_context_t ctx, void *msg); +#else ssize_t _assuan_simple_sendmsg (assuan_context_t ctx, struct msghdr *msg); ssize_t _assuan_simple_recvmsg (assuan_context_t ctx, struct msghdr *msg); +#endif /*-- assuan-socket.c --*/ int _assuan_close (int fd); Modified: trunk/assuan/assuan-handler.c =================================================================== --- trunk/assuan/assuan-handler.c 2007-07-04 20:02:38 UTC (rev 1219) +++ trunk/assuan/assuan-handler.c 2007-07-04 20:03:39 UTC (rev 1220) @@ -142,8 +142,8 @@ { char *endp; - if ( (strncmp (line, "FD", 2) && strncmp (line, "fd", 2)) - || (line[2] != '=' && line[2] != '\0')) + if ((strncmp (line, "FD", 2) && strncmp (line, "fd", 2)) + || (line[2] != '=' && line[2] != '\0' && !spacep(&line[2]))) return set_error (ctx, Syntax_Error, "FD[=] expected"); line += 2; if (*line == '=') @@ -509,7 +509,24 @@ { const char *text = ctx->err_no == rc? ctx->err_str:NULL; -#if defined(__GNUC__) && defined(__ELF__) +#if defined(HAVE_W32_SYSTEM) + unsigned int source, code; + char ebuf[50]; + const char *esrc; + + source = ((rc >> 24) & 0xff); + code = (rc & 0x00ffffff); + if (source + && !_assuan_gpg_strerror_r (rc, ebuf, sizeof ebuf) + && (esrc=_assuan_gpg_strsource (rc))) + { + /* Assume this is an libgpg-error. */ + sprintf (errline, "ERR %d %.50s <%.30s>%s%.100s", + rc, ebuf, esrc, + text? " - ":"", text?text:""); + } + else +#elif defined(__GNUC__) && defined(__ELF__) /* If we have weak symbol support we try to use the error strings from libgpg-error without creating a dependency. They are used for debugging purposes only, so there is no @@ -526,7 +543,7 @@ __attribute__ ((weak)); const char *gpg_strsource (unsigned int err) __attribute__ ((weak)); -#if !defined(HAVE_W32_SYSTEM) && __GNUC__ < 3 +#if __GNUC__ < 3 #pragma weak gpg_strerror_r #pragma weak gpg_strsource #endif Modified: trunk/assuan/assuan-io.c =================================================================== --- trunk/assuan/assuan-io.c 2007-07-04 20:02:38 UTC (rev 1219) +++ trunk/assuan/assuan-io.c 2007-07-04 20:03:39 UTC (rev 1220) @@ -25,7 +25,9 @@ #include #include -#include +#ifdef HAVE_SYS_SOCKET_H +# include +#endif #include #include #ifdef HAVE_W32_SYSTEM @@ -49,18 +51,69 @@ ssize_t _assuan_simple_read (assuan_context_t ctx, void *buffer, size_t size) { +#ifdef HAVE_W32_SYSTEM + /* Due to the peculiarities of the W32 API we can't use read for a + network socket and thus we try to use recv first and fallback to + read if recv detects that it is not a network socket. */ + int n; + + n = recv (ctx->inbound.fd, buffer, size, 0); + if (n == -1 && WSAGetLastError () == WSAENOTSOCK) + { + DWORD nread = 0; + + n = ReadFile ((HANDLE)ctx->inbound.fd, buffer, size, &nread, NULL); + if (!n) + { + errno = EIO; /* FIXME: We should have a proper mapping. */ + n = -1; + } + else + n = (int)nread; + } + return n; +#else /*!HAVE_W32_SYSTEM*/ return read (ctx->inbound.fd, buffer, size); +#endif /*!HAVE_W32_SYSTEM*/ } ssize_t _assuan_simple_write (assuan_context_t ctx, const void *buffer, size_t size) { +#ifdef HAVE_W32_SYSTEM + /* Due to the peculiarities of the W32 API we can't use write for a + network socket and thus we try to use send first and fallback to + write if send detects that it is not a network socket. */ + int n; + + n = send (ctx->outbound.fd, buffer, size, 0); + if (n == -1 && WSAGetLastError () == WSAENOTSOCK) + { + DWORD nwrite; + + n = WriteFile ((HANDLE)ctx->outbound.fd, buffer, size, &nwrite, NULL); + if (!n) + { + errno = EIO; /* FIXME: We should have a proper mapping. */ + n = -1; + } + else + n = (int)nwrite; + } + return n; +#else /*!HAVE_W32_SYSTEM*/ return write (ctx->outbound.fd, buffer, size); +#endif /*!HAVE_W32_SYSTEM*/ } +#ifdef HAVE_W32_SYSTEM +int +_assuan_simple_sendmsg (assuan_context_t ctx, void *msg) +#else ssize_t _assuan_simple_sendmsg (assuan_context_t ctx, struct msghdr *msg) +#endif { #ifdef HAVE_W32_SYSTEM return _assuan_error (ASSUAN_Not_Implemented); @@ -73,8 +126,13 @@ } +#ifdef HAVE_W32_SYSTEM +int +_assuan_simple_recvmsg (assuan_context_t ctx, void *msg) +#else ssize_t _assuan_simple_recvmsg (assuan_context_t ctx, struct msghdr *msg) +#endif { #ifdef HAVE_W32_SYSTEM return _assuan_error (ASSUAN_Not_Implemented); Modified: trunk/assuan/assuan-logging.c =================================================================== --- trunk/assuan/assuan-logging.c 2007-07-04 20:02:38 UTC (rev 1219) +++ trunk/assuan/assuan-logging.c 2007-07-04 20:03:39 UTC (rev 1220) @@ -1,5 +1,5 @@ /* assuan-logging.c - Default logging function. - * Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. + * Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc. * * This file is part of Assuan. * @@ -238,4 +238,51 @@ strerr, sizeof (strerr)-1, NULL); return strerr; } + +static int (*my_strerror_r) (unsigned int err, char *buf, size_t buflen); +static const char * (*my_strsource) (unsigned int err); + +static int +load_libgpg_error (void) +{ + /* This code is not race free but suitable for our purpose. */ + static volatile int initialized; + void *handle; + + if (initialized) + return (my_strerror_r && my_strsource)? 0:-1; + handle = LoadLibrary ("libgpg-error-0.dll"); + if (handle) + { + void *foo, *bar; + foo = GetProcAddress (handle, "gpg_strerror_r"); + bar = GetProcAddress (handle, "gpg_strsource"); + if (foo && bar) + { + my_strerror_r = foo; + my_strsource = bar; + } + else + CloseHandle (handle); + } + initialized = 1; + return 0; +} + +int +_assuan_gpg_strerror_r (unsigned int err, char *buf, size_t buflen) +{ + if (load_libgpg_error ()) + return -1; + return my_strerror_r (err, buf, buflen); +} + + +const char * +_assuan_gpg_strsource (unsigned int err) +{ + if (load_libgpg_error ()) + return NULL; + return my_strsource (err); +} #endif /*HAVE_W32_SYSTEM*/ Modified: trunk/assuan/assuan-pipe-connect.c =================================================================== --- trunk/assuan/assuan-pipe-connect.c 2007-07-04 20:02:38 UTC (rev 1219) +++ trunk/assuan/assuan-pipe-connect.c 2007-07-04 20:03:39 UTC (rev 1220) @@ -554,7 +554,7 @@ /* Build a command line for use with W32's CreateProcess. On success CMDLINE gets the address of a newly allocated string. */ static int -build_w32_commandline (char * const *argv, char **cmdline) +build_w32_commandline (const char * const *argv, char **cmdline) { int i, n; const char *s; Modified: trunk/assuan/assuan-pipe-server.c =================================================================== --- trunk/assuan/assuan-pipe-server.c 2007-07-04 20:02:38 UTC (rev 1219) +++ trunk/assuan/assuan-pipe-server.c 2007-07-04 20:03:39 UTC (rev 1220) @@ -92,6 +92,7 @@ /* Returns true if atoi(S) denotes a valid socket. */ +#ifndef HAVE_W32_SYSTEM static int is_valid_socket (const char *s) { @@ -101,6 +102,7 @@ return 0; return S_ISSOCK (buf.st_mode); } +#endif /*!HAVE_W32_SYSTEM*/ int Modified: trunk/assuan/assuan-socket-server.c =================================================================== --- trunk/assuan/assuan-socket-server.c 2007-07-04 20:02:38 UTC (rev 1219) +++ trunk/assuan/assuan-socket-server.c 2007-07-04 20:03:39 UTC (rev 1220) @@ -25,13 +25,19 @@ #include #include #include -#ifndef HAVE_W32_SYSTEM -#include -#include +#ifdef HAVE_W32_SYSTEM +# include +# if HAVE_SYS_SOCKET_H +# include +# elif HAVE_WS2TCPIP_H +# include +# endif #else -#include +# include +# include #endif + #include "assuan-defs.h" static struct assuan_io io = { _assuan_simple_read, Modified: trunk/assuan/assuan-uds.c =================================================================== --- trunk/assuan/assuan-uds.c 2007-07-04 20:02:38 UTC (rev 1219) +++ trunk/assuan/assuan-uds.c 2007-07-04 20:03:39 UTC (rev 1220) @@ -111,6 +111,8 @@ len = _assuan_simple_recvmsg (ctx, &msg); if (len < 0) return -1; + if (len == 0) + return 0; ctx->uds.buffersize = len; ctx->uds.bufferoffset = 0; @@ -150,7 +152,7 @@ if (len > buflen) /* We have more than the user requested. */ len = buflen; - memcpy (buf, ctx->uds.buffer + ctx->uds.bufferoffset, len); + memcpy (buf, (char*)ctx->uds.buffer + ctx->uds.bufferoffset, len); ctx->uds.buffersize -= len; assert (ctx->uds.buffersize >= 0); ctx->uds.bufferoffset += len; Modified: trunk/assuan/assuan.h =================================================================== --- trunk/assuan/assuan.h 2007-07-04 20:02:38 UTC (rev 1219) +++ trunk/assuan/assuan.h 2007-07-04 20:03:39 UTC (rev 1220) @@ -460,8 +460,10 @@ /*-- assuan-connect.c --*/ void assuan_disconnect (assuan_context_t ctx); pid_t assuan_get_pid (assuan_context_t ctx); +#ifndef HAVE_W32_SYSTEM assuan_error_t assuan_get_peercred (assuan_context_t ctx, pid_t *pid, uid_t *uid, gid_t *gid); +#endif /*-- assuan-client.c --*/ assuan_error_t Modified: trunk/autogen.sh =================================================================== --- trunk/autogen.sh 2007-07-04 20:02:38 UTC (rev 1219) +++ trunk/autogen.sh 2007-07-04 20:03:39 UTC (rev 1220) @@ -31,7 +31,7 @@ DIE=no FORCE= -if test "$1" == "--force"; then +if test "$1" = "--force"; then FORCE=" --force" shift fi From cvs at cvs.gnupg.org Wed Jul 4 23:07:57 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Wed, 04 Jul 2007 23:07:57 +0200 Subject: [svn] gpgme - r1221 - in trunk: . assuan gpgme Message-ID: Author: marcus Date: 2007-07-04 23:07:27 +0200 (Wed, 04 Jul 2007) New Revision: 1221 Modified: trunk/ChangeLog trunk/assuan/Makefile.am trunk/assuan/assuan.h trunk/gpgme/gpgme.h Log: 2007-07-04 Marcus Brinkmann * assuan/Makefile.am (INCLUDES): Include $(top_srcdir)/gpgme. * assuan/assuan.h: Include instead of trying to duplicate the definitions. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-07-04 20:03:39 UTC (rev 1220) +++ trunk/ChangeLog 2007-07-04 21:07:27 UTC (rev 1221) @@ -1,5 +1,9 @@ 2007-07-04 Marcus Brinkmann + * assuan/Makefile.am (INCLUDES): Include $(top_srcdir)/gpgme. * + assuan/assuan.h: Include instead of trying to duplicate + the definitions. + * assuan/: Update files to 2007-07-04 version of assuan. * autogen.sh: Use = not == in test. Modified: trunk/assuan/Makefile.am =================================================================== --- trunk/assuan/Makefile.am 2007-07-04 20:03:39 UTC (rev 1220) +++ trunk/assuan/Makefile.am 2007-07-04 21:07:27 UTC (rev 1221) @@ -20,7 +20,7 @@ ## Process this file with automake to produce Makefile.in EXTRA_DIST = mkerrors -INCLUDES = -I.. -I$(top_srcdir)/include +INCLUDES = -I.. -I$(top_srcdir)/gpgme BUILT_SOURCES = assuan-errors.c MOSTLYCLEANFILES = assuan-errors.c Modified: trunk/assuan/assuan.h =================================================================== --- trunk/assuan/assuan.h 2007-07-04 20:03:39 UTC (rev 1220) +++ trunk/assuan/assuan.h 2007-07-04 21:07:27 UTC (rev 1221) @@ -61,23 +61,12 @@ #define _ASSUAN_USE_DOUBLE_FORK #ifdef _ASSUAN_IN_GPGME_BUILD_ASSUAN +#include + int _gpgme_io_read (int fd, void *buffer, size_t count); int _gpgme_io_write (int fd, const void *buffer, size_t count); -ssize_t _gpgme_ath_waitpid (pid_t pid, int *status, int options); -#ifdef HAVE_W32_SYSTEM -int _gpgme_ath_accept (int s, void *addr, int *length_ptr); -#else /*!HAVE_W32_SYSTEM*/ -struct sockaddr; -struct msghdr; -ssize_t _gpgme_ath_select (int nfd, fd_set *rset, fd_set *wset, fd_set *eset, - struct timeval *timeout); -int _gpgme_ath_accept (int s, struct sockaddr *addr, socklen_t *length_ptr); -int _gpgme_ath_connect (int s, struct sockaddr *addr, socklen_t length); -int _gpgme_ath_sendmsg (int s, const struct msghdr *msg, int flags); -int _gpgme_ath_recvmsg (int s, struct msghdr *msg, int flags); int _gpgme_io_sendmsg (int sock, const struct msghdr *msg, int flags); int _gpgme_io_recvmsg (int sock, struct msghdr *msg, int flags); -#endif /*!HAVE_W32_SYSTEM*/ #define read _gpgme_io_read #define write _gpgme_io_write Modified: trunk/gpgme/gpgme.h =================================================================== --- trunk/gpgme/gpgme.h 2007-07-04 20:03:39 UTC (rev 1220) +++ trunk/gpgme/gpgme.h 2007-07-04 21:07:27 UTC (rev 1221) @@ -72,7 +72,7 @@ AM_PATH_GPGME macro) check that this header matches the installed library. Warning: Do not edit the next line. configure will do that for you! */ -#define GPGME_VERSION "1.1.5-cvs1213" +#define GPGME_VERSION "1.1.5-cvs1219" From cvs at cvs.gnupg.org Thu Jul 5 00:14:40 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Thu, 05 Jul 2007 00:14:40 +0200 Subject: [svn] GnuPG - r4529 - trunk/tools Message-ID: Author: marcus Date: 2007-07-05 00:14:08 +0200 (Thu, 05 Jul 2007) New Revision: 4529 Modified: trunk/tools/ChangeLog trunk/tools/symcryptrun.c Log: 2007-07-05 Marcus Brinkmann * symcryptrun.c (confucius_get_pass): Define orig_codeset if [ENABLE_NLS], not [HAVE_LANGINFO_CODESET]. Modified: trunk/tools/ChangeLog =================================================================== --- trunk/tools/ChangeLog 2007-07-04 19:49:40 UTC (rev 4528) +++ trunk/tools/ChangeLog 2007-07-04 22:14:08 UTC (rev 4529) @@ -1,3 +1,8 @@ +2007-07-05 Marcus Brinkmann + + * symcryptrun.c (confucius_get_pass): Define orig_codeset if + [ENABLE_NLS], not [HAVE_LANGINFO_CODESET]. + 2007-06-26 Werner Koch * gpgconf-comp.c (key_matches_user_or_group) [W32]: Implement user Modified: trunk/tools/symcryptrun.c =================================================================== --- trunk/tools/symcryptrun.c 2007-07-04 19:49:40 UTC (rev 4528) +++ trunk/tools/symcryptrun.c 2007-07-04 22:14:08 UTC (rev 4529) @@ -424,7 +424,7 @@ { int err; char *pw; -#ifdef HAVE_LANGINFO_CODESET +#ifdef ENABLE_NLS char *orig_codeset = NULL; #endif From cvs at cvs.gnupg.org Thu Jul 5 00:24:55 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Thu, 05 Jul 2007 00:24:55 +0200 Subject: [svn] GnuPG - r4530 - trunk Message-ID: Author: marcus Date: 2007-07-05 00:24:26 +0200 (Thu, 05 Jul 2007) New Revision: 4530 Modified: trunk/ChangeLog trunk/configure.ac Log: 2007-07-05 Marcus Brinkmann * configure.ac: Invoke AM_LANGINFO_CODESET. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-07-04 22:14:08 UTC (rev 4529) +++ trunk/ChangeLog 2007-07-04 22:24:26 UTC (rev 4530) @@ -1,3 +1,7 @@ +2007-07-05 Marcus Brinkmann + + * configure.ac: Invoke AM_LANGINFO_CODESET. + 2007-07-04 Werner Koch * Makefile.am (AUTOMAKE_OPTIONS): Add no-dist-gzip. Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-07-04 22:14:08 UTC (rev 4529) +++ trunk/configure.ac 2007-07-04 22:24:26 UTC (rev 4530) @@ -893,6 +893,8 @@ AC_SUBST(POSUB) fi +# We use HAVE_LANGINFO_CODESET in a couple of places. +AM_LANGINFO_CODESET # # SELinux support From cvs at cvs.gnupg.org Thu Jul 5 20:39:31 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 05 Jul 2007 20:39:31 +0200 Subject: [svn] assuan - r243 - tags Message-ID: Author: wk Date: 2007-07-05 20:39:02 +0200 (Thu, 05 Jul 2007) New Revision: 243 Added: tags/libassuan-1.0.2/ Log: Tagged Release Copied: tags/libassuan-1.0.2 (from rev 242, trunk) From cvs at cvs.gnupg.org Thu Jul 5 20:45:23 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 05 Jul 2007 20:45:23 +0200 Subject: [svn] w32pth - r6 - trunk Message-ID: Author: wk Date: 2007-07-05 20:44:55 +0200 (Thu, 05 Jul 2007) New Revision: 6 Modified: trunk/AUTHORS trunk/ChangeLog trunk/NEWS trunk/configure.ac Log: From cvs at cvs.gnupg.org Thu Jul 5 20:53:05 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 05 Jul 2007 20:53:05 +0200 Subject: [svn] w32pth - r7 - / Message-ID: Author: wk Date: 2007-07-05 20:52:36 +0200 (Thu, 05 Jul 2007) New Revision: 7 Added: tags/ Log: From cvs at cvs.gnupg.org Thu Jul 5 20:53:46 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 05 Jul 2007 20:53:46 +0200 Subject: [svn] w32pth - r8 - tags Message-ID: Author: wk Date: 2007-07-05 20:53:18 +0200 (Thu, 05 Jul 2007) New Revision: 8 Added: tags/w32pth-2.0.0/ Log: Tagged release Copied: tags/w32pth-2.0.0 (from rev 7, trunk) From cvs at cvs.gnupg.org Thu Jul 5 21:00:19 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 05 Jul 2007 21:00:19 +0200 Subject: [svn] GnuPG - r4532 - trunk Message-ID: Author: wk Date: 2007-07-05 20:59:50 +0200 (Thu, 05 Jul 2007) New Revision: 4532 Modified: trunk/ChangeLog trunk/NEWS trunk/configure.ac Log: Prearing a release Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-07-05 16:58:19 UTC (rev 4531) +++ trunk/ChangeLog 2007-07-05 18:59:50 UTC (rev 4532) @@ -1,5 +1,7 @@ 2007-07-05 Werner Koch + Released 2.0.5. + * configure.ac: Require libassuan 1.0.2. 2007-07-05 Marcus Brinkmann Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2007-07-05 16:58:19 UTC (rev 4531) +++ trunk/NEWS 2007-07-05 18:59:50 UTC (rev 4532) @@ -1,4 +1,4 @@ -Noteworthy changes in version 2.0.5 +Noteworthy changes in version 2.0.5 (2007-07-05) ------------------------------------------------ * Switched license to GPLv3. Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-07-05 16:58:19 UTC (rev 4531) +++ trunk/configure.ac 2007-07-05 18:59:50 UTC (rev 4532) @@ -25,7 +25,7 @@ # Set my_issvn to "yes" for non-released code. Remember to run an # "svn up" and "autogen.sh" right before creating a distribution. m4_define([my_version], [2.0.5]) -m4_define([my_issvn], [yes]) +m4_define([my_issvn], [no]) m4_define([svn_revision], m4_esyscmd([echo -n $( (svn info 2>/dev/null \ From cvs at cvs.gnupg.org Thu Jul 5 22:11:41 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 05 Jul 2007 22:11:41 +0200 Subject: [svn] GnuPG - r4533 - in trunk: agent scd sm tools Message-ID: Author: wk Date: 2007-07-05 22:11:11 +0200 (Thu, 05 Jul 2007) New Revision: 4533 Modified: trunk/agent/Makefile.am trunk/scd/Makefile.am trunk/sm/ChangeLog trunk/sm/Makefile.am trunk/tools/Makefile.am Log: Last minute Makefile library reordering for the sake of non-GNU systems. Modified: trunk/agent/Makefile.am =================================================================== --- trunk/agent/Makefile.am 2007-07-05 18:59:50 UTC (rev 4532) +++ trunk/agent/Makefile.am 2007-07-05 20:11:11 UTC (rev 4533) @@ -45,8 +45,8 @@ call-scd.c \ learncard.c -common_libs = ../jnlib/libjnlib.a $(libcommon) ../gl/libgnu.a -commonpth_libs = ../jnlib/libjnlib.a $(libcommonpth) ../gl/libgnu.a +common_libs = $(libcommon) ../jnlib/libjnlib.a ../gl/libgnu.a +commonpth_libs = $(libcommonpth) ../jnlib/libjnlib.a ../gl/libgnu.a pwquery_libs = ../common/libsimple-pwquery.a #if HAVE_W32_SYSTEM Modified: trunk/scd/Makefile.am =================================================================== --- trunk/scd/Makefile.am 2007-07-05 18:59:50 UTC (rev 4532) +++ trunk/scd/Makefile.am 2007-07-05 20:11:11 UTC (rev 4533) @@ -42,7 +42,7 @@ app.c app-common.h app-help.c $(card_apps) -scdaemon_LDADD = ../jnlib/libjnlib.a $(libcommonpth) ../gl/libgnu.a \ +scdaemon_LDADD = $(libcommonpth) ../jnlib/libjnlib.a ../gl/libgnu.a \ $(LIBGCRYPT_LIBS) $(KSBA_LIBS) $(LIBASSUAN_PTH_LIBS) $(PTH_LIBS) \ $(LIBUSB_LIBS) $(GPG_ERROR_LIBS) \ $(LIBINTL) $(DL_LIBS) $(NETLIBS) $(LIBICONV) Modified: trunk/sm/ChangeLog =================================================================== --- trunk/sm/ChangeLog 2007-07-05 18:59:50 UTC (rev 4532) +++ trunk/sm/ChangeLog 2007-07-05 20:11:11 UTC (rev 4533) @@ -1,3 +1,7 @@ +2007-07-05 Werner Koch + + * Makefile.am (common_libs): Changed order of libs. + 2007-07-04 Werner Koch * certchain.c (check_cert_policy): Remove extra checks for Modified: trunk/sm/Makefile.am =================================================================== --- trunk/sm/Makefile.am 2007-07-05 18:59:50 UTC (rev 4532) +++ trunk/sm/Makefile.am 2007-07-05 20:11:11 UTC (rev 4533) @@ -52,8 +52,8 @@ qualified.c -common_libs = ../jnlib/libjnlib.a ../kbx/libkeybox.a \ - $(libcommon) ../gl/libgnu.a +common_libs = $(libcommon) ../jnlib/libjnlib.a ../kbx/libkeybox.a \ + ../gl/libgnu.a gpgsm_LDADD = $(common_libs) ../common/libgpgrl.a \ $(LIBGCRYPT_LIBS) $(KSBA_LIBS) $(LIBASSUAN_LIBS) \ Modified: trunk/tools/Makefile.am =================================================================== --- trunk/tools/Makefile.am 2007-07-05 18:59:50 UTC (rev 4532) +++ trunk/tools/Makefile.am 2007-07-05 20:11:11 UTC (rev 4533) @@ -48,7 +48,7 @@ noinst_PROGRAMS = clean-sat mk-tdata make-dns-cert gpgsplit -common_libs = ../jnlib/libjnlib.a $(libcommon) ../gl/libgnu.a +common_libs = $(libcommon) ../jnlib/libjnlib.a ../gl/libgnu.a pwquery_libs = ../common/libsimple-pwquery.a gpgsplit_LDADD = $(common_libs) \ From cvs at cvs.gnupg.org Thu Jul 5 22:25:05 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 05 Jul 2007 22:25:05 +0200 Subject: [svn] GnuPG - r4534 - tags Message-ID: Author: wk Date: 2007-07-05 22:24:36 +0200 (Thu, 05 Jul 2007) New Revision: 4534 Added: tags/gnupg-2.0.5/ Log: Released the GPLv3 version Copied: tags/gnupg-2.0.5 (from rev 4533, trunk) From cvs at cvs.gnupg.org Thu Jul 5 22:29:44 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 05 Jul 2007 22:29:44 +0200 Subject: [svn] GnuPG - r4535 - trunk Message-ID: Author: wk Date: 2007-07-05 22:29:14 +0200 (Thu, 05 Jul 2007) New Revision: 4535 Modified: trunk/NEWS trunk/configure.ac Log: Post release updates Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2007-07-05 20:24:36 UTC (rev 4534) +++ trunk/NEWS 2007-07-05 20:29:14 UTC (rev 4535) @@ -1,3 +1,7 @@ +Noteworthy changes in version 2.0.6 +------------------------------------------------ + + Noteworthy changes in version 2.0.5 (2007-07-05) ------------------------------------------------ Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-07-05 20:24:36 UTC (rev 4534) +++ trunk/configure.ac 2007-07-05 20:29:14 UTC (rev 4535) @@ -24,8 +24,8 @@ # Remember to change the version number immediately *after* a release. # Set my_issvn to "yes" for non-released code. Remember to run an # "svn up" and "autogen.sh" right before creating a distribution. -m4_define([my_version], [2.0.5]) -m4_define([my_issvn], [no]) +m4_define([my_version], [2.0.6]) +m4_define([my_issvn], [yes]) m4_define([svn_revision], m4_esyscmd([echo -n $( (svn info 2>/dev/null \ From cvs at cvs.gnupg.org Fri Jul 6 14:51:59 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 06 Jul 2007 14:51:59 +0200 Subject: [svn] pinentry - r162 - trunk Message-ID: Author: wk Date: 2007-07-06 14:51:28 +0200 (Fri, 06 Jul 2007) New Revision: 162 Modified: trunk/ChangeLog trunk/NEWS trunk/autogen.sh trunk/config.guess trunk/config.sub trunk/configure.ac Log: Preparing a release. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-06-27 16:50:22 UTC (rev 161) +++ trunk/ChangeLog 2007-07-06 12:51:28 UTC (rev 162) @@ -1,3 +1,13 @@ +2007-07-06 Werner Koch + + Released 0.7.3. + + * config.sub, config.guess: Updated from current Savannah CVS. + +2007-06-27 Werner Koch + + * w32/main.c: Revamped the SetFocus stuff. It is all not that easy. + 2007-06-26 Werner Koch * w32/Makefile.am (pinentry_w32_LDFLAGS): Add -mconsole again. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2007-06-27 16:50:22 UTC (rev 161) +++ trunk/NEWS 2007-07-06 12:51:28 UTC (rev 162) @@ -1,4 +1,4 @@ -Noteworthy changes in version 0.7.3 +Noteworthy changes in version 0.7.3 (2007-07-06) ------------------------------------------------ * New command MESSAGE and --one-button compatibility option to @@ -10,7 +10,9 @@ * New option --colors=FG,BG,SO to set the colors for the curses pinentry. - * Pinentry-w32 does now work. + * Pinentry-w32 does now basicaly work. It needs some finishing + though. For example the buttons should resize themself according + to the size of the text. Noteworthy changes in version 0.7.2 (2005-01-27) Modified: trunk/autogen.sh =================================================================== --- trunk/autogen.sh 2007-06-27 16:50:22 UTC (rev 161) +++ trunk/autogen.sh 2007-07-06 12:51:28 UTC (rev 162) @@ -90,7 +90,7 @@ --host=${host} --build=${build} \ --disable-pinentry-gtk \ --disable-pinentry-gtk2 \ - --disable-pinentry-qt + --disable-pinentry-qt "$@" rc=$? exit $rc Modified: trunk/config.guess =================================================================== --- trunk/config.guess 2007-06-27 16:50:22 UTC (rev 161) +++ trunk/config.guess 2007-07-06 12:51:28 UTC (rev 162) @@ -1,9 +1,10 @@ #! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, +# Inc. -timestamp='2004-08-13' +timestamp='2007-05-17' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -17,13 +18,15 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. + # Originally written by Per Bothner . # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. @@ -53,7 +56,7 @@ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO @@ -66,11 +69,11 @@ while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) - echo "$timestamp" ; exit 0 ;; + echo "$timestamp" ; exit ;; --version | -v ) - echo "$version" ; exit 0 ;; + echo "$version" ; exit ;; --help | --h* | -h ) - echo "$usage"; exit 0 ;; + echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. @@ -104,7 +107,7 @@ trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; @@ -123,7 +126,7 @@ ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ;' +esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi at noc.rutgers.edu 1994-08-24) @@ -158,6 +161,7 @@ arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; + sh5el) machine=sh5le-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched @@ -196,55 +200,23 @@ # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" - exit 0 ;; - amd64:OpenBSD:*:*) - echo x86_64-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - amiga:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - cats:OpenBSD:*:*) - echo arm-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - hp300:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - luna88k:OpenBSD:*:*) - echo m88k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mac68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - macppc:OpenBSD:*:*) - echo powerpc-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme88k:OpenBSD:*:*) - echo m88k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvmeppc:OpenBSD:*:*) - echo powerpc-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - sgi:OpenBSD:*:*) - echo mips64-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - sun3:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; + exit ;; *:OpenBSD:*:*) - echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} - exit 0 ;; + exit ;; + *:SolidBSD:*:*) + echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + exit ;; macppc:MirBSD:*:*) - echo powerppc-unknown-mirbsd${UNAME_RELEASE} - exit 0 ;; + echo powerpc-unknown-mirbsd${UNAME_RELEASE} + exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} - exit 0 ;; + exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) @@ -297,37 +269,43 @@ # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - exit 0 ;; + exit ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix - exit 0 ;; + exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 - exit 0 ;; + exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 - exit 0;; + exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos - exit 0 ;; + exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos - exit 0 ;; + exit ;; *:OS/390:*:*) echo i370-ibm-openedition - exit 0 ;; + exit ;; + *:z/VM:*:*) + echo s390-ibm-zvmoe + exit ;; *:OS400:*:*) echo powerpc-ibm-os400 - exit 0 ;; + exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} - exit 0;; + exit ;; + arm:riscos:*:*|arm:RISCOS:*:*) + echo arm-unknown-riscos + exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp - exit 0;; + exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee at wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then @@ -335,32 +313,32 @@ else echo pyramid-pyramid-bsd fi - exit 0 ;; + exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 - exit 0 ;; + exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 - exit 0 ;; - DRS?6000:UNIX_SV:4.2*:7*) + exit ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in - sparc) echo sparc-icl-nx7 && exit 0 ;; + sparc) echo sparc-icl-nx7; exit ;; esac ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; + exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - i86pc:SunOS:5.*:*) + exit ;; + i86pc:SunOS:5.*:* | ix86xen:SunOS:5.*:*) echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; + exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; + exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) @@ -369,10 +347,10 @@ esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit 0 ;; + exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} - exit 0 ;; + exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 @@ -384,10 +362,10 @@ echo sparc-sun-sunos${UNAME_RELEASE} ;; esac - exit 0 ;; + exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} - exit 0 ;; + exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor @@ -398,40 +376,40 @@ # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; + exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; + exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; + exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} - exit 0 ;; + exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} - exit 0 ;; + exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} - exit 0 ;; + exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} - exit 0 ;; + exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} - exit 0 ;; + exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 - exit 0 ;; + exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} - exit 0 ;; + exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} - exit 0 ;; + exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} - exit 0 ;; + exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c @@ -455,32 +433,33 @@ exit (-1); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c \ - && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ - && exit 0 + $CC_FOR_BUILD -o $dummy $dummy.c && + dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`$dummy $dummyarg` && + { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} - exit 0 ;; + exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax - exit 0 ;; + exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax - exit 0 ;; + exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax - exit 0 ;; + exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix - exit 0 ;; + exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 - exit 0 ;; + exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 - exit 0 ;; + exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 - exit 0 ;; + exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` @@ -496,29 +475,29 @@ else echo i586-dg-dgux${UNAME_RELEASE} fi - exit 0 ;; + exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 - exit 0 ;; + exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 - exit 0 ;; + exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 - exit 0 ;; + exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd - exit 0 ;; + exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit 0 ;; + exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix - exit 0 ;; + exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` @@ -526,7 +505,7 @@ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} - exit 0 ;; + exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build @@ -541,14 +520,18 @@ exit(0); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 - echo rs6000-ibm-aix3.2.5 + if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + then + echo "$SYSTEM_NAME" + else + echo rs6000-ibm-aix3.2.5 + fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi - exit 0 ;; + exit ;; *:AIX:*:[45]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then @@ -562,28 +545,28 @@ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit 0 ;; + exit ;; *:AIX:*:*) echo rs6000-ibm-aix - exit 0 ;; + exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 - exit 0 ;; + exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit 0 ;; # report: romp-ibm BSD 4.3 + exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx - exit 0 ;; + exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 - exit 0 ;; + exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd - exit 0 ;; + exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 - exit 0 ;; + exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in @@ -645,9 +628,19 @@ esac if [ ${HP_ARCH} = "hppa2.0w" ] then - # avoid double evaluation of $set_cc_for_build - test -n "$CC_FOR_BUILD" || eval $set_cc_for_build - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null + eval $set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + grep __LP64__ >/dev/null then HP_ARCH="hppa2.0w" else @@ -655,11 +648,11 @@ fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit 0 ;; + exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} - exit 0 ;; + exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c @@ -687,152 +680,182 @@ exit (0); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 + $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 - exit 0 ;; + exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd - exit 0 ;; + exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd - exit 0 ;; + exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix - exit 0 ;; + exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf - exit 0 ;; + exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf - exit 0 ;; + exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi - exit 0 ;; + exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites - exit 0 ;; + exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd - exit 0 ;; + exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi - exit 0 ;; + exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd - exit 0 ;; + exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd - exit 0 ;; + exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd - exit 0 ;; + exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; + exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' - exit 0 ;; + exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; + exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; + exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; + exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; + exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit 0 ;; + exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit 0 ;; + exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit 0 ;; + exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} - exit 0 ;; + exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} - exit 0 ;; + exit ;; *:FreeBSD:*:*) - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit 0 ;; + case ${UNAME_MACHINE} in + pc98) + echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + amd64) + echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + *) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + esac + exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin - exit 0 ;; - i*:MINGW*:*) + exit ;; + *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 - exit 0 ;; + exit ;; + i*:windows32*:*) + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 + exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 - exit 0 ;; - x86:Interix*:[34]*) - echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//' - exit 0 ;; + exit ;; + *:Interix*:[3456]*) + case ${UNAME_MACHINE} in + x86) + echo i586-pc-interix${UNAME_RELEASE} + exit ;; + EM64T | authenticamd) + echo x86_64-unknown-interix${UNAME_RELEASE} + exit ;; + esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks - exit 0 ;; + exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix - exit 0 ;; + exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin - exit 0 ;; + exit ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + echo x86_64-unknown-cygwin + exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin - exit 0 ;; + exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; + exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit 0 ;; + exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu - exit 0 ;; + exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix - exit 0 ;; + exit ;; arm*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; + exit ;; + avr32*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; cris:Linux:*:*) echo cris-axis-linux-gnu - exit 0 ;; + exit ;; + crisv32:Linux:*:*) + echo crisv32-axis-linux-gnu + exit ;; + frv:Linux:*:*) + echo frv-unknown-linux-gnu + exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; + exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; + exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; + exit ;; mips:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c @@ -849,8 +872,12 @@ #endif #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` - test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^CPU/{ + s: ::g + p + }'`" + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; mips64:Linux:*:*) eval $set_cc_for_build @@ -868,15 +895,22 @@ #endif #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` - test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^CPU/{ + s: ::g + p + }'`" + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; + or32:Linux:*:*) + echo or32-unknown-linux-gnu + exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu - exit 0 ;; + exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-gnu - exit 0 ;; + exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; @@ -890,7 +924,7 @@ objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} - exit 0 ;; + exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in @@ -898,25 +932,31 @@ PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac - exit 0 ;; + exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu - exit 0 ;; + exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux - exit 0 ;; + exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; + exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; + exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; + exit ;; + vax:Linux:*:*) + echo ${UNAME_MACHINE}-dec-linux-gnu + exit ;; x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu - exit 0 ;; + exit ;; + xtensa:Linux:*:*) + echo xtensa-unknown-linux-gnu + exit ;; i*86:Linux:*:*) # The BFD linker knows what the default object file format is, so # first see if it will tell us. cd to the root directory to prevent @@ -934,15 +974,15 @@ ;; a.out-i386-linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" - exit 0 ;; + exit ;; coff-i386) echo "${UNAME_MACHINE}-pc-linux-gnucoff" - exit 0 ;; + exit ;; "") # Either a pre-BFD a.out linker (linux-gnuoldld) or # one that does not give us useful --help. echo "${UNAME_MACHINE}-pc-linux-gnuoldld" - exit 0 ;; + exit ;; esac # Determine whether the default compiler is a.out or elf eval $set_cc_for_build @@ -959,7 +999,7 @@ LIBC=gnulibc1 # endif #else - #ifdef __INTEL_COMPILER + #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) LIBC=gnu #else LIBC=gnuaout @@ -969,16 +1009,23 @@ LIBC=dietlibc #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` - test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0 - test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^LIBC/{ + s: ::g + p + }'`" + test x"${LIBC}" != x && { + echo "${UNAME_MACHINE}-pc-linux-${LIBC}" + exit + } + test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; } ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 - exit 0 ;; + exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... @@ -986,27 +1033,27 @@ # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit 0 ;; + exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx - exit 0 ;; + exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop - exit 0 ;; + exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos - exit 0 ;; - i*86:syllable:*:*) + exit ;; + i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable - exit 0 ;; + exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) echo i386-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; + exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit 0 ;; + exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then @@ -1014,15 +1061,16 @@ else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi - exit 0 ;; - i*86:*:5:[78]*) + exit ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} - exit 0 ;; + exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi - exit 0 ;; + exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv - exit 0 ;; + exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv - exit 0 ;; + exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix - exit 0 ;; + exit ;; M68*:*:R3V[5678]*:*) - test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4.3${OS_REL} && exit 0 + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4 && exit 0 ;; + && { echo i486-ncr-sysv4; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; + exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 - exit 0 ;; + exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; + exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; + exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; + exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} - exit 0 ;; + exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 - exit 0 ;; + exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 - exit 0 ;; + exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` @@ -1114,69 +1162,81 @@ else echo ns32k-sni-sysv fi - exit 0 ;; + exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 - exit 0 ;; + exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 - exit 0 ;; + exit ;; *:*:*:FTX*) # From seanf at swdc.stratus.com. echo i860-stratus-sysv4 - exit 0 ;; + exit ;; + i*86:VOS:*:*) + # From Paul.Green at stratus.com. + echo ${UNAME_MACHINE}-stratus-vos + exit ;; *:VOS:*:*) # From Paul.Green at stratus.com. echo hppa1.1-stratus-vos - exit 0 ;; + exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} - exit 0 ;; + exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 - exit 0 ;; + exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi - exit 0 ;; + exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos - exit 0 ;; + exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos - exit 0 ;; + exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos - exit 0 ;; + exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} - exit 0 ;; + exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} - exit 0 ;; + exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} - exit 0 ;; + exit ;; + SX-7:SUPER-UX:*:*) + echo sx7-nec-superux${UNAME_RELEASE} + exit ;; + SX-8:SUPER-UX:*:*) + echo sx8-nec-superux${UNAME_RELEASE} + exit ;; + SX-8R:SUPER-UX:*:*) + echo sx8r-nec-superux${UNAME_RELEASE} + exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit 0 ;; + exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit 0 ;; + exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown case $UNAME_PROCESSOR in - *86) UNAME_PROCESSOR=i686 ;; unknown) UNAME_PROCESSOR=powerpc ;; esac echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} - exit 0 ;; + exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then @@ -1184,22 +1244,25 @@ UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} - exit 0 ;; + exit ;; *:QNX:*:4*) echo i386-pc-qnx - exit 0 ;; + exit ;; + NSE-?:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk${UNAME_RELEASE} + exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} - exit 0 ;; + exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux - exit 0 ;; + exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv - exit 0 ;; + exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} - exit 0 ;; + exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 @@ -1210,38 +1273,47 @@ UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 - exit 0 ;; + exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 - exit 0 ;; + exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex - exit 0 ;; + exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 - exit 0 ;; + exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 - exit 0 ;; + exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 - exit 0 ;; + exit ;; *:ITS:*:*) echo pdp10-unknown-its - exit 0 ;; + exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} - exit 0 ;; + exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit 0 ;; + exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in - A*) echo alpha-dec-vms && exit 0 ;; - I*) echo ia64-dec-vms && exit 0 ;; - V*) echo vax-dec-vms && exit 0 ;; - esac + A*) echo alpha-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; + *:XENIX:*:SysV) + echo i386-pc-xenix + exit ;; + i*86:skyos:*:*) + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + exit ;; + i*86:rdos:*:*) + echo ${UNAME_MACHINE}-pc-rdos + exit ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 @@ -1273,7 +1345,7 @@ #endif #if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix"); exit (0); + printf ("arm-acorn-riscix\n"); exit (0); #endif #if defined (hp300) && !defined (hpux) @@ -1362,11 +1434,12 @@ } EOF -$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0 +$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } # Convex versions that predate uname can use getsysinfo(1) @@ -1375,22 +1448,22 @@ case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd - exit 0 ;; + exit ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi - exit 0 ;; + exit ;; c34*) echo c34-convex-bsd - exit 0 ;; + exit ;; c38*) echo c38-convex-bsd - exit 0 ;; + exit ;; c4*) echo c4-convex-bsd - exit 0 ;; + exit ;; esac fi @@ -1401,7 +1474,9 @@ the operating system you are using. It is advised that you download the most up to date version of the config scripts from - ftp://ftp.gnu.org/pub/gnu/config/ + http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess +and + http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub If the version you run ($0) is already up to date, please send the following data and any information you think might be Modified: trunk/config.sub =================================================================== --- trunk/config.sub 2007-06-27 16:50:22 UTC (rev 161) +++ trunk/config.sub 2007-07-06 12:51:28 UTC (rev 162) @@ -1,9 +1,10 @@ #! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, +# Inc. -timestamp='2004-06-24' +timestamp='2007-06-28' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software @@ -21,14 +22,15 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. - +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. +# # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. + # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. # @@ -70,7 +72,7 @@ version="\ GNU config.sub ($timestamp) -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO @@ -83,11 +85,11 @@ while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) - echo "$timestamp" ; exit 0 ;; + echo "$timestamp" ; exit ;; --version | -v ) - echo "$version" ; exit 0 ;; + echo "$version" ; exit ;; --help | --h* | -h ) - echo "$usage"; exit 0 ;; + echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. @@ -99,7 +101,7 @@ *local*) # First pass through any local machine types. echo $1 - exit 0;; + exit ;; * ) break ;; @@ -118,8 +120,9 @@ # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in - nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \ - kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) + nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ + uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ + storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; @@ -170,6 +173,10 @@ -hiux*) os=-hiuxwe2 ;; + -sco6) + os=-sco5v6 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` @@ -186,6 +193,10 @@ # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; + -sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` @@ -230,14 +241,16 @@ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ - | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ + | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ + | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ - | fr30 | frv \ + | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ - | m32r | m32rle | m68000 | m68k | m88k | mcore \ + | m32c | m32r | m32rle | m68000 | m68k | m88k \ + | maxq | mb | microblaze | mcore | mep \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ @@ -246,6 +259,7 @@ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ @@ -254,20 +268,24 @@ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ + | mt \ | msp430 \ + | nios | nios2 \ | ns16k | ns32k \ - | openrisc | or32 \ + | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ - | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ + | score \ + | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ - | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv8 | sparcv9 | sparcv9b \ - | strongarm \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ + | spu | strongarm \ | tahoe | thumb | tic4x | tic80 | tron \ | v850 | v850e \ | we32k \ - | x86 | xscale | xstormy16 | xtensa \ + | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ | z8k) basic_machine=$basic_machine-unknown ;; @@ -278,6 +296,9 @@ ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; + ms1) + basic_machine=mt-unknown + ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and @@ -297,20 +318,20 @@ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* \ - | bs2000-* \ + | avr-* | avr32-* \ + | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ - | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ + | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ - | m32r-* | m32rle-* \ + | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | mcore-* \ + | m88110-* | m88k-* | maxq-* | mcore-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ @@ -319,6 +340,7 @@ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ + | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ @@ -327,24 +349,27 @@ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ + | mt-* \ | msp430-* \ + | nios-* | nios2-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ | romp-* | rs6000-* \ - | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ + | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ + | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ | tahoe-* | thumb-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tron-* \ | v850-* | v850e-* | vax-* \ | we32k-* \ - | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \ - | xtensa-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ + | xstormy16-* | xtensa-* \ | ymp-* \ | z8k-*) ;; @@ -450,13 +475,16 @@ basic_machine=craynv-cray os=-unicosmp ;; - cr16c) - basic_machine=cr16c-unknown + cr16) + basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; + crisv32 | crisv32-* | etraxfs*) + basic_machine=crisv32-axis + ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; @@ -486,6 +514,10 @@ basic_machine=m88k-motorola os=-sysv3 ;; + djgpp) + basic_machine=i586-pc + os=-msdosdjgpp + ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx @@ -651,6 +683,10 @@ basic_machine=i386-pc os=-mingw32 ;; + mingw32ce) + basic_machine=arm-unknown + os=-mingw32ce + ;; miniframe) basic_machine=m68000-convergent ;; @@ -676,6 +712,9 @@ basic_machine=i386-pc os=-msdos ;; + ms1-*) + basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` + ;; mvs) basic_machine=i370-ibm os=-mvs @@ -751,9 +790,8 @@ basic_machine=hppa1.1-oki os=-proelf ;; - or32 | or32-*) + openrisc | openrisc-*) basic_machine=or32-unknown - os=-coff ;; os400) basic_machine=powerpc-ibm @@ -784,6 +822,12 @@ pc532 | pc532-*) basic_machine=ns32k-pc532 ;; + pc98) + basic_machine=i386-pc + ;; + pc98-*) + basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; @@ -840,6 +884,10 @@ basic_machine=i586-unknown os=-pw32 ;; + rdos) + basic_machine=i386-pc + os=-rdos + ;; rom68k) basic_machine=m68k-rom68k os=-coff @@ -866,6 +914,10 @@ sb1el) basic_machine=mipsisa64sb1el-unknown ;; + sde) + basic_machine=mipsisa32-sde + os=-elf + ;; sei) basic_machine=mips-sei os=-seiux @@ -877,6 +929,9 @@ basic_machine=sh-hitachi os=-hms ;; + sh5el) + basic_machine=sh5le-unknown + ;; sh64) basic_machine=sh64-unknown ;; @@ -1026,6 +1081,10 @@ basic_machine=hppa1.1-winbond os=-proelf ;; + xbox) + basic_machine=i686-pc + os=-mingw32 + ;; xps | xps100) basic_machine=xps100-honeywell ;; @@ -1075,13 +1134,10 @@ we32k) basic_machine=we32k-att ;; - sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele) + sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; - sh64) - basic_machine=sh64-unknown - ;; - sparc | sparcv8 | sparcv9 | sparcv9b) + sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) @@ -1154,20 +1210,23 @@ | -aos* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ + | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \ + | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ + | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly*) + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ + | -skyos* | -haiku* | -rdos* | -toppers* | -drops*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) @@ -1185,7 +1244,7 @@ os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) @@ -1294,6 +1353,9 @@ -kaos*) os=-kaos ;; + -zvmoe) + os=-zvmoe + ;; -none) ;; *) @@ -1316,6 +1378,12 @@ # system, and we'll never get to this point. case $basic_machine in + score-*) + os=-elf + ;; + spu-*) + os=-elf + ;; *-acorn) os=-riscix1.2 ;; @@ -1325,9 +1393,9 @@ arm*-semi) os=-aout ;; - c4x-* | tic4x-*) - os=-coff - ;; + c4x-* | tic4x-*) + os=-coff + ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 @@ -1353,6 +1421,9 @@ m68*-cisco) os=-aout ;; + mep-*) + os=-elf + ;; mips*-cisco) os=-elf ;; @@ -1371,6 +1442,9 @@ *-be) os=-beos ;; + *-haiku) + os=-haiku + ;; *-ibm) os=-aix ;; @@ -1542,7 +1616,7 @@ esac echo $basic_machine$os -exit 0 +exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-06-27 16:50:22 UTC (rev 161) +++ trunk/configure.ac 2007-07-06 12:51:28 UTC (rev 162) @@ -24,7 +24,7 @@ # Remember to remove the "-cvs" suffix *before* a release and to bump the # version number immediately *after* a release and to re-append the suffix. -AC_INIT(pinentry, 0.7.3-cvs, [gpa-dev at gnupg.org]) +AC_INIT(pinentry, 0.7.3, [gnupg-devel at gnupg.org]) AM_CONFIG_HEADER(config.h) AC_CONFIG_SRCDIR(pinentry/pinentry.h) AM_INIT_AUTOMAKE($PACKAGE_NAME, $PACKAGE_VERSION) From cvs at cvs.gnupg.org Fri Jul 6 14:52:39 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 06 Jul 2007 14:52:39 +0200 Subject: [svn] pinentry - r163 - trunk Message-ID: Author: wk Date: 2007-07-06 14:52:11 +0200 (Fri, 06 Jul 2007) New Revision: 163 Modified: trunk/AUTHORS Log: From cvs at cvs.gnupg.org Fri Jul 6 14:53:52 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 06 Jul 2007 14:53:52 +0200 Subject: [svn] pinentry - r164 - trunk Message-ID: Author: wk Date: 2007-07-06 14:53:24 +0200 (Fri, 06 Jul 2007) New Revision: 164 Modified: trunk/AUTHORS Log: From cvs at cvs.gnupg.org Fri Jul 6 15:35:59 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 06 Jul 2007 15:35:59 +0200 Subject: [svn] pinentry - r165 - tags Message-ID: Author: wk Date: 2007-07-06 15:35:30 +0200 (Fri, 06 Jul 2007) New Revision: 165 Added: tags/pinentry-0.7.3/ Log: Tagged release Copied: tags/pinentry-0.7.3 (from rev 164, trunk) From cvs at cvs.gnupg.org Fri Jul 6 15:39:36 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 06 Jul 2007 15:39:36 +0200 Subject: [svn] pinentry - r166 - trunk Message-ID: Author: wk Date: 2007-07-06 15:39:05 +0200 (Fri, 06 Jul 2007) New Revision: 166 Modified: trunk/NEWS trunk/configure.ac Log: Post release updates. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2007-07-06 13:35:30 UTC (rev 165) +++ trunk/NEWS 2007-07-06 13:39:05 UTC (rev 166) @@ -1,3 +1,7 @@ +Noteworthy changes in version 0.7.4 +------------------------------------------------ + + Noteworthy changes in version 0.7.3 (2007-07-06) ------------------------------------------------ Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-07-06 13:35:30 UTC (rev 165) +++ trunk/configure.ac 2007-07-06 13:39:05 UTC (rev 166) @@ -24,7 +24,7 @@ # Remember to remove the "-cvs" suffix *before* a release and to bump the # version number immediately *after* a release and to re-append the suffix. -AC_INIT(pinentry, 0.7.3, [gnupg-devel at gnupg.org]) +AC_INIT(pinentry, 0.7.4-cvs, [gnupg-devel at gnupg.org]) AM_CONFIG_HEADER(config.h) AC_CONFIG_SRCDIR(pinentry/pinentry.h) AM_INIT_AUTOMAKE($PACKAGE_NAME, $PACKAGE_VERSION) From cvs at cvs.gnupg.org Sat Jul 7 01:37:05 2007 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Sat, 07 Jul 2007 01:37:05 +0200 Subject: [svn] GnuPG - r4537 - branches/STABLE-BRANCH-1-4/g10 Message-ID: Author: dshaw Date: 2007-07-07 01:36:33 +0200 (Sat, 07 Jul 2007) New Revision: 4537 Modified: branches/STABLE-BRANCH-1-4/g10/ChangeLog branches/STABLE-BRANCH-1-4/g10/encode.c Log: * encode.c (encode_crypt): Missed one call to setup_plaintext_name(). This is bug#809. Modified: branches/STABLE-BRANCH-1-4/g10/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/g10/ChangeLog 2007-07-06 14:55:40 UTC (rev 4536) +++ branches/STABLE-BRANCH-1-4/g10/ChangeLog 2007-07-06 23:36:33 UTC (rev 4537) @@ -1,3 +1,8 @@ +2007-07-06 David Shaw + + * encode.c (encode_crypt): Missed one call to + setup_plaintext_name(). This is bug#809. + 2007-06-12 David Shaw * sign.c (mk_notation_policy_etc): expect all sigs that this is Modified: branches/STABLE-BRANCH-1-4/g10/encode.c =================================================================== --- branches/STABLE-BRANCH-1-4/g10/encode.c 2007-07-06 14:55:40 UTC (rev 4536) +++ branches/STABLE-BRANCH-1-4/g10/encode.c 2007-07-06 23:36:33 UTC (rev 4537) @@ -557,22 +557,8 @@ if(use_symkey && (rc=write_symkey_enc(symkey_s2k,symkey_dek,cfx.dek,out))) goto leave; - if (!opt.no_literal) { - /* setup the inner packet */ - if( filename || opt.set_filename ) { - char *s = make_basename( opt.set_filename ? opt.set_filename - : filename, - iobuf_get_real_fname( inp ) ); - pt = xmalloc( sizeof *pt + strlen(s) - 1 ); - pt->namelen = strlen(s); - memcpy(pt->name, s, pt->namelen ); - xfree(s); - } - else { /* no filename */ - pt = xmalloc( sizeof *pt - 1 ); - pt->namelen = 0; - } - } + if (!opt.no_literal) + pt=setup_plaintext_name(filename,inp); if (!iobuf_is_pipe_filename (filename) && *filename && !opt.textmode ) { From cvs at cvs.gnupg.org Sun Jul 8 17:46:42 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Sun, 08 Jul 2007 17:46:42 +0200 Subject: [svn] gpgme - r1222 - in trunk: . assuan gpgme Message-ID: Author: marcus Date: 2007-07-08 17:46:10 +0200 (Sun, 08 Jul 2007) New Revision: 1222 Modified: trunk/ChangeLog trunk/assuan/ChangeLog trunk/assuan/Makefile.am trunk/assuan/assuan-connect.c trunk/assuan/assuan-defs.h trunk/assuan/assuan.h trunk/configure.ac trunk/gpgme/ChangeLog trunk/gpgme/engine-gpgsm.c trunk/gpgme/funopen.c Log: 2007-07-08 Marcus Brinkmann * configure.ac (GPGSM_DEFAULT) [*-mingw32*]: Initialize it. (HAVE_ASSUAN_H): Set to 1 if we have it. (funopen): Use AC_REPLACE_FUNCS. (USE_DESCRIPTOR_PASSING): Define to 1 if we have it. Do not define it at all if we don't. (NETLIBS) [have_w32_system]: Add -lws2_32. (DIRSEP_C, DIRSEP_S, EXPSEP_C, EXPSEP_S, PATHSEP_S) [HAVE_DOSISH_SYSTEM]: Remove definitions. * assuan/assuan.h (_assuan_funopen): Define to _gpgme_funopen. * assuan/funopen.c: Move to ../gpgme/funopen.c. * assuan/Makefile.am (libassuan_la_SOURCES): Remove funopen.c. assuan/ 2007-07-08 Marcus Brinkmann * assuan-defs.h (struct assuan_context_s): Have partial peercred structure even if HAVE_W32_SYSTEM, and have full peercred structure only if HAVE_SO_PEERCRED. * assuan-connect.c (assuan_get_peercred) [!HAVE_SO_PEERCRED]: Do not try to set PID, UID and GID. gpgme/ 2007-07-08 Marcus Brinkmann * engine-gpgsm.c [HAVE_W32_SYSTEM]: Enable the bunch of the file. * funopen.c (funopen): Rename to _gpgme_funopen. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-07-04 21:07:27 UTC (rev 1221) +++ trunk/ChangeLog 2007-07-08 15:46:10 UTC (rev 1222) @@ -1,3 +1,18 @@ +2007-07-08 Marcus Brinkmann + + * configure.ac (GPGSM_DEFAULT) [*-mingw32*]: Initialize it. + (HAVE_ASSUAN_H): Set to 1 if we have it. + (funopen): Use AC_REPLACE_FUNCS. + (USE_DESCRIPTOR_PASSING): Define to 1 if we have it. Do not + define it at all if we don't. + (NETLIBS) [have_w32_system]: Add -lws2_32. + (DIRSEP_C, DIRSEP_S, EXPSEP_C, EXPSEP_S, PATHSEP_S) + [HAVE_DOSISH_SYSTEM]: Remove definitions. + + * assuan/assuan.h (_assuan_funopen): Define to _gpgme_funopen. + * assuan/funopen.c: Move to ../gpgme/funopen.c. + * assuan/Makefile.am (libassuan_la_SOURCES): Remove funopen.c. + 2007-07-04 Marcus Brinkmann * assuan/Makefile.am (INCLUDES): Include $(top_srcdir)/gpgme. * Modified: trunk/assuan/ChangeLog =================================================================== --- trunk/assuan/ChangeLog 2007-07-04 21:07:27 UTC (rev 1221) +++ trunk/assuan/ChangeLog 2007-07-08 15:46:10 UTC (rev 1222) @@ -1,3 +1,11 @@ +2007-07-08 Marcus Brinkmann + + * assuan-defs.h (struct assuan_context_s): Have partial peercred + structure even if HAVE_W32_SYSTEM, and have full peercred + structure only if HAVE_SO_PEERCRED. + * assuan-connect.c (assuan_get_peercred) [!HAVE_SO_PEERCRED]: Do + not try to set PID, UID and GID. + 2007-07-04 Marcus Brinkmann Change _WIN32 to HAVE_W32_SYSTEM for consistency. Modified: trunk/assuan/Makefile.am =================================================================== --- trunk/assuan/Makefile.am 2007-07-04 21:07:27 UTC (rev 1221) +++ trunk/assuan/Makefile.am 2007-07-08 15:46:10 UTC (rev 1222) @@ -45,7 +45,6 @@ assuan-pipe-connect.c \ assuan-socket-connect.c \ assuan-uds.c \ - funopen.c \ assuan-io.c \ assuan-logging.c \ assuan-socket.c Modified: trunk/assuan/assuan-connect.c =================================================================== --- trunk/assuan/assuan-connect.c 2007-07-04 21:07:27 UTC (rev 1221) +++ trunk/assuan/assuan-connect.c 2007-07-08 15:46:10 UTC (rev 1222) @@ -59,10 +59,10 @@ } +#ifndef HAVE_W32_SYSTEM /* Return user credentials. PID, UID and GID amy be gived as NULL if you are not interested in this value. For getting the pid of the peer the assuan_get_pid is usually better suited. */ -#ifndef HAVE_W32_SYSTEM assuan_error_t assuan_get_peercred (assuan_context_t ctx, pid_t *pid, uid_t *uid, gid_t *gid) { @@ -70,12 +70,16 @@ return _assuan_error (ASSUAN_Invalid_Value); if (!ctx->peercred.valid) return _assuan_error (ASSUAN_General_Error); + +#ifdef HAVE_SO_PEERCRED if (pid) *pid = ctx->peercred.pid; if (uid) *uid = ctx->peercred.uid; if (gid) *gid = ctx->peercred.gid; +#endif + return 0; } #endif /* HAVE_W32_SYSTEM */ Modified: trunk/assuan/assuan-defs.h =================================================================== --- trunk/assuan/assuan-defs.h 2007-07-04 21:07:27 UTC (rev 1221) +++ trunk/assuan/assuan-defs.h 2007-07-08 15:46:10 UTC (rev 1222) @@ -140,14 +140,14 @@ int listen_fd; /* The fd we are listening on (used by socket servers) */ int connected_fd; /* helper */ -#ifndef HAVE_W32_SYSTEM struct { int valid; /* Whether this structure has valid information. */ +#ifdef HAVE_SO_PEERCRED pid_t pid; /* The pid of the peer. */ uid_t uid; /* The uid of the peer. */ gid_t gid; /* The gid of the peer. */ +#endif /* HAVE_SO_PEERCRED */ } peercred; -#endif /* HAVE_W32_SYSTEM */ /* Used for Unix domain sockets. */ struct sockaddr_un myaddr; Modified: trunk/assuan/assuan.h =================================================================== --- trunk/assuan/assuan.h 2007-07-04 21:07:27 UTC (rev 1221) +++ trunk/assuan/assuan.h 2007-07-08 15:46:10 UTC (rev 1222) @@ -185,6 +185,7 @@ #define _assuan_sock_bind _ASSUAN_PREFIX(_assuan_sock_bind) #define _assuan_sock_connect _ASSUAN_PREFIX(_assuan_sock_connect) +#define _assuan_funopen _gpgme_funopen #endif /*_ASSUAN_EXT_SYM_PREFIX*/ Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-07-04 21:07:27 UTC (rev 1221) +++ trunk/configure.ac 2007-07-08 15:46:10 UTC (rev 1222) @@ -123,8 +123,7 @@ have_dosish_system=yes have_w32_system=yes GPG_DEFAULT='c:\\gnupg\\gpg.exe' - # XXX Assuan is not supported in this configuration. - #GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe' + GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe' #component_system='COM+' ;; *) @@ -467,18 +466,17 @@ # FIXME: Only build if supported. AM_CONDITIONAL(BUILD_ASSUAN, test "$GPGSM" != "no") if test "$GPGSM" != "no"; then - AC_DEFINE(HAVE_ASSUAN_H, ,[Defined if we are building with assuan support.]) + AC_DEFINE(HAVE_ASSUAN_H, 1, + [Defined if we are building with assuan support.]) fi -# The assuan code uses funopen but it will also build without it. So -# test for it. Frankly, this is not required in gpgme, but thats the -# way we handle it in libassuan. +# Check for funopen AC_CHECK_FUNCS(funopen) if test $ac_cv_func_funopen != yes; then # No funopen but we can implement that in terms of fopencookie. AC_CHECK_FUNCS(fopencookie) if test $ac_cv_func_fopencookie = yes; then - AC_LIBOBJ([funopen]) + AC_REPLACE_FUNCS(funopen) else AC_MSG_WARN([ *** @@ -529,13 +527,10 @@ fi if test "$use_descriptor_passing" = "yes"; then - fd_passing=1 -else - fd_passing=0 +AC_DEFINE(USE_DESCRIPTOR_PASSING,1, + [Defined if descriptor passing is enabled and supported]) fi -AC_DEFINE_UNQUOTED(USE_DESCRIPTOR_PASSING, $fd_passing, - [Defined if descriptor passing is enabled and supported]) AM_CONDITIONAL(USE_DESCRIPTOR_PASSING, test "$use_descriptor_passing" = "yes") # Assuan check for the getsockopt SO_PEERCRED @@ -554,6 +549,10 @@ [Defined if SO_PEERCRED is supported (Linux specific)]) fi +if test "$have_w32_system" = yes; then + NETLIBS="-lws2_32 $NETLIBS" +fi + # End of assuan checks. AM_CONDITIONAL(BUILD_COMPLUS, test "$component_system" = "COM+") @@ -581,23 +580,11 @@ # Add a few constants to help porting to W32 AH_VERBATIM([SEPCONSTANTS], [ -/* Separators as used in file names and $PATH. Please note that the - string version must not contain more than one character because - the using code assumes strlen()==1 */ +/* Separators as used in $PATH. */ #ifdef HAVE_DOSISH_SYSTEM -#define DIRSEP_C '\\\\' -#define EXTSEP_C '.' -#define DIRSEP_S "\\\\" -#define EXTSEP_S "." #define PATHSEP_C ';' -#define PATHSEP_S ";" #else -#define DIRSEP_C '/' -#define EXTSEP_C '.' -#define DIRSEP_S "/" -#define EXTSEP_S "." #define PATHSEP_C ':' -#define PATHSEP_S ":" #endif ]) Modified: trunk/gpgme/ChangeLog =================================================================== --- trunk/gpgme/ChangeLog 2007-07-04 21:07:27 UTC (rev 1221) +++ trunk/gpgme/ChangeLog 2007-07-08 15:46:10 UTC (rev 1222) @@ -1,3 +1,8 @@ +2007-07-08 Marcus Brinkmann + + * engine-gpgsm.c [HAVE_W32_SYSTEM]: Enable the bunch of the file. + * funopen.c (funopen): Rename to _gpgme_funopen. + 2007-04-30 Marcus Brinkmann * engine-gpgsm.c (gpgsm_new): Fix error handling for ttyname_r. Modified: trunk/gpgme/engine-gpgsm.c =================================================================== --- trunk/gpgme/engine-gpgsm.c 2007-07-04 21:07:27 UTC (rev 1221) +++ trunk/gpgme/engine-gpgsm.c 2007-07-08 15:46:10 UTC (rev 1222) @@ -23,8 +23,6 @@ #include #endif -#ifndef HAVE_W32_SYSTEM - #include #include #include @@ -1749,5 +1747,3 @@ gpgsm_io_event, gpgsm_cancel }; - -#endif /*!HAVE_W32_SYSTEM*/ Modified: trunk/gpgme/funopen.c =================================================================== --- trunk/gpgme/funopen.c 2007-07-04 21:07:27 UTC (rev 1221) +++ trunk/gpgme/funopen.c 2007-07-08 15:46:10 UTC (rev 1222) @@ -24,19 +24,39 @@ #include + +/* Replacement for the *BSD function: + + FILE *funopen (void *cookie, + int (*readfn)(void *, char *, int), + int (*writefn)(void *, const char *, int), + fpos_t (*seekfn)(void *, fpos_t, int), + int (*closefn)(void *)); + + The functions to provide my either be NULL if not required or + similar to the unistd function with the exception of using the + cookie instead of the fiel descripor. +*/ + + #ifdef HAVE_FOPENCOOKIE FILE * -funopen(const void *cookie, cookie_read_function_t *readfn, - cookie_write_function_t *writefn, - cookie_seek_function_t *seekfn, - cookie_close_function_t *closefn) +_gpgme_funopen(void *cookie, + cookie_read_function_t *readfn, + cookie_write_function_t *writefn, + cookie_seek_function_t *seekfn, + cookie_close_function_t *closefn) { - cookie_io_functions_t io = { read: readfn, write: writefn, - seek: seekfn, close: closefn }; + cookie_io_functions_t io = { NULL }; - return fopencookie ((void *) cookie, - readfn ? (writefn ? "rw" : "r") - : (writefn ? "w" : ""), io); + io.read = readfn; + io.write = writefn; + io.seek = seekfn; + io.close = closefn; + + return fopencookie (cookie, + readfn ? ( writefn ? "rw" : "r" ) + : ( writefn ? "w" : ""), io); } #else #error No known way to implement funopen. From cvs at cvs.gnupg.org Sun Jul 8 17:48:35 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Sun, 08 Jul 2007 17:48:35 +0200 Subject: [svn] gpgme - r1223 - trunk Message-ID: Author: marcus Date: 2007-07-08 17:48:06 +0200 (Sun, 08 Jul 2007) New Revision: 1223 Modified: trunk/ChangeLog Log: Fix formatting. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-07-08 15:46:10 UTC (rev 1222) +++ trunk/ChangeLog 2007-07-08 15:48:06 UTC (rev 1223) @@ -15,8 +15,8 @@ 2007-07-04 Marcus Brinkmann - * assuan/Makefile.am (INCLUDES): Include $(top_srcdir)/gpgme. * - assuan/assuan.h: Include instead of trying to duplicate + * assuan/Makefile.am (INCLUDES): Include $(top_srcdir)/gpgme. + * assuan/assuan.h: Include instead of trying to duplicate the definitions. * assuan/: Update files to 2007-07-04 version of assuan. From cvs at cvs.gnupg.org Sun Jul 8 17:54:06 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Sun, 08 Jul 2007 17:54:06 +0200 Subject: [svn] assuan - r244 - trunk/src Message-ID: Author: marcus Date: 2007-07-08 17:53:35 +0200 (Sun, 08 Jul 2007) New Revision: 244 Modified: trunk/src/ChangeLog trunk/src/assuan-connect.c trunk/src/assuan-defs.h Log: 2007-07-08 Marcus Brinkmann * assuan-defs.h (struct assuan_context_s): Have full peercred structure for HAVE_SO_PEERCRED. * assuan-connect.c (assuan_get_peercred) [!HAVE_SO_PEERCRED]: Do not try to set PID, UID and GID. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2007-07-05 18:39:02 UTC (rev 243) +++ trunk/src/ChangeLog 2007-07-08 15:53:35 UTC (rev 244) @@ -1,3 +1,10 @@ +2007-07-08 Marcus Brinkmann + + * assuan-defs.h (struct assuan_context_s): Have full peercred + structure for HAVE_SO_PEERCRED. + * assuan-connect.c (assuan_get_peercred) [!HAVE_SO_PEERCRED]: Do + not try to set PID, UID and GID. + 2007-07-05 Werner Koch * assuan-defs.h (struct assuan_context_s): Have peercred.valid Modified: trunk/src/assuan-connect.c =================================================================== --- trunk/src/assuan-connect.c 2007-07-05 18:39:02 UTC (rev 243) +++ trunk/src/assuan-connect.c 2007-07-08 15:53:35 UTC (rev 244) @@ -57,10 +57,10 @@ } +#ifndef HAVE_W32_SYSTEM /* Return user credentials. PID, UID and GID amy be gived as NULL if you are not interested in this value. For getting the pid of the peer the assuan_get_pid is usually better suited. */ -#ifndef HAVE_W32_SYSTEM assuan_error_t assuan_get_peercred (assuan_context_t ctx, pid_t *pid, uid_t *uid, gid_t *gid) { @@ -68,12 +68,16 @@ return _assuan_error (ASSUAN_Invalid_Value); if (!ctx->peercred.valid) return _assuan_error (ASSUAN_General_Error); + +#ifdef HAVE_SO_PEERCRED if (pid) *pid = ctx->peercred.pid; if (uid) *uid = ctx->peercred.uid; if (gid) *gid = ctx->peercred.gid; +#endif + return 0; } #endif /* HAVE_W32_SYSTEM */ Modified: trunk/src/assuan-defs.h =================================================================== --- trunk/src/assuan-defs.h 2007-07-05 18:39:02 UTC (rev 243) +++ trunk/src/assuan-defs.h 2007-07-08 15:53:35 UTC (rev 244) @@ -5,7 +5,7 @@ * * Assuan is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 3 of + * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * Assuan is distributed in the hope that it will be useful, but @@ -14,7 +14,9 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, see . + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. */ #ifndef ASSUAN_DEFS_H @@ -140,11 +142,11 @@ struct { int valid; /* Whether this structure has valid information. */ -#ifndef HAVE_W32_SYSTEM +#ifdef HAVE_SO_PEERCRED pid_t pid; /* The pid of the peer. */ uid_t uid; /* The uid of the peer. */ gid_t gid; /* The gid of the peer. */ -#endif /* HAVE_W32_SYSTEM */ +#endif /* HAVE_SO_PEERCRED */ } peercred; /* Used for Unix domain sockets. */ From cvs at cvs.gnupg.org Sun Jul 8 18:00:36 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Sun, 08 Jul 2007 18:00:36 +0200 Subject: [svn] gpgme - r1224 - trunk/assuan Message-ID: Author: marcus Date: 2007-07-08 18:00:04 +0200 (Sun, 08 Jul 2007) New Revision: 1224 Removed: trunk/assuan/funopen.c Log: Really delete the file as announced in the ChangeLog. Deleted: trunk/assuan/funopen.c From cvs at cvs.gnupg.org Sun Jul 8 23:48:42 2007 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Sun, 08 Jul 2007 23:48:42 +0200 Subject: [svn] GnuPG - r4538 - branches/STABLE-BRANCH-1-4 Message-ID: Author: dshaw Date: 2007-07-08 23:48:11 +0200 (Sun, 08 Jul 2007) New Revision: 4538 Modified: branches/STABLE-BRANCH-1-4/ChangeLog branches/STABLE-BRANCH-1-4/configure.ac Log: * configure.ac: AM_PROG_CC_C_O is desired by automake 1.10 to do per-target builds (like we do in the keyserver dir), but exists in the currently-used 1.9.3 as well. Modified: branches/STABLE-BRANCH-1-4/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/ChangeLog 2007-07-06 23:36:33 UTC (rev 4537) +++ branches/STABLE-BRANCH-1-4/ChangeLog 2007-07-08 21:48:11 UTC (rev 4538) @@ -1,3 +1,9 @@ +2007-07-08 David Shaw + + * configure.ac: AM_PROG_CC_C_O is desired by automake 1.10 to do + per-target builds (like we do in the keyserver dir), but exists in + the currently-used 1.9.3 as well. + 2007-06-13 David Shaw * configure.ac: Add --enable-camellia. Disabled by default. Do Modified: branches/STABLE-BRANCH-1-4/configure.ac =================================================================== --- branches/STABLE-BRANCH-1-4/configure.ac 2007-07-06 23:36:33 UTC (rev 4537) +++ branches/STABLE-BRANCH-1-4/configure.ac 2007-07-08 21:48:11 UTC (rev 4538) @@ -508,6 +508,7 @@ AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir) AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir) AC_PROG_CC +AM_PROG_CC_C_O AC_PROG_CPP AC_PROG_RANLIB AC_CHECK_TOOL(AR, ar, :) From cvs at cvs.gnupg.org Mon Jul 9 09:37:11 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 09 Jul 2007 09:37:11 +0200 Subject: [svn] pinentry - r167 - in trunk: . doc gtk+-2 Message-ID: Author: wk Date: 2007-07-09 09:36:40 +0200 (Mon, 09 Jul 2007) New Revision: 167 Modified: trunk/ChangeLog trunk/THANKS trunk/configure.ac trunk/doc/pinentry.texi trunk/gtk+-2/pinentry-gtk-2.c Log: Applied fixes for bug 798. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-07-06 13:39:05 UTC (rev 166) +++ trunk/ChangeLog 2007-07-09 07:36:40 UTC (rev 167) @@ -1,3 +1,12 @@ +2007-07-09 Werner Koch + + * doc/pinentry.texi: Fixed direntry syntax. + + * configure.ac: Add --without-libcap. From the Gentoo patch archive. + + * gtk+-2/pinentry-gtk-2.c (create_window): Use expose-event + instead of map-event. From Alon Bar-Lev. + 2007-07-06 Werner Koch Released 0.7.3. Modified: trunk/THANKS =================================================================== --- trunk/THANKS 2007-07-06 13:39:05 UTC (rev 166) +++ trunk/THANKS 2007-07-09 07:36:40 UTC (rev 167) @@ -1,3 +1,4 @@ +Alon Bar-Lev alon.barlev at gmail.com Albrecht Dress albrecht.dress at arcor.de Alexander Zangerl az at snafu.priv.at Michael Nottebrock michaelnottebrock at gmx.net Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-07-06 13:39:05 UTC (rev 166) +++ trunk/configure.ac 2007-07-09 07:36:40 UTC (rev 167) @@ -116,11 +116,17 @@ GNUPG_CHECK_TYPEDEF(byte, HAVE_BYTE_TYPEDEF) GNUPG_CHECK_TYPEDEF(ulong, HAVE_ULONG_TYPEDEF) -AC_PATH_PROG(SETCAP, setcap, :, "$PATH:/sbin:/usr/sbin") -AC_CHECK_LIB(cap, cap_set_proc, [ - AC_DEFINE(USE_CAPABILITIES,1,[The capabilities support library is installed]) - LIBCAP=-lcap -]) +dnl Check for libcap +AC_ARG_WITH([libcap], AC_HELP_STRING([--without-libcap], + [Disable support for capabilities library])) + +if test "x$with_libcap" != "xno"; then + AC_PATH_PROG(SETCAP, setcap, :, "$PATH:/sbin:/usr/sbin") + AC_CHECK_LIB(cap, cap_set_proc, [ + AC_DEFINE(USE_CAPABILITIES,1,[The capabilities support library is installed]) + LIBCAP=-lcap + ]) +fi AC_SUBST(LIBCAP) dnl Modified: trunk/doc/pinentry.texi =================================================================== --- trunk/doc/pinentry.texi 2007-07-06 13:39:05 UTC (rev 166) +++ trunk/doc/pinentry.texi 2007-07-09 07:36:40 UTC (rev 167) @@ -62,7 +62,7 @@ @ifnottex @dircategory GNU Utilities @direntry -* pinentry:: Ask securely for a passphrase or PIN. +* pinentry: (pinentry). Ask securely for a passphrase or PIN. @end direntry This file documents the use and the internals of the @pinentry{}. Modified: trunk/gtk+-2/pinentry-gtk-2.c =================================================================== --- trunk/gtk+-2/pinentry-gtk-2.c 2007-07-06 13:39:05 UTC (rev 166) +++ trunk/gtk+-2/pinentry-gtk-2.c 2007-07-09 07:36:40 UTC (rev 167) @@ -207,10 +207,10 @@ if (!confirm_mode) { g_signal_connect (G_OBJECT (win), - pinentry->grab ? "map-event" : "focus-in-event", + pinentry->grab ? "expose-event" : "focus-in-event", G_CALLBACK (grab_keyboard), NULL); g_signal_connect (G_OBJECT (win), - pinentry->grab ? "unmap-event" : "focus-out-event", + pinentry->grab ? "no-expose-event" : "focus-out-event", G_CALLBACK (ungrab_keyboard), NULL); } gtk_window_add_accel_group (GTK_WINDOW (win), acc); From cvs at cvs.gnupg.org Mon Jul 9 15:08:20 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 09 Jul 2007 15:08:20 +0200 Subject: [svn] gpgme - r1225 - trunk Message-ID: Author: marcus Date: 2007-07-09 15:07:51 +0200 (Mon, 09 Jul 2007) New Revision: 1225 Modified: trunk/ChangeLog trunk/NEWS trunk/configure.ac Log: 2007-07-09 Marcus Brinkmann Released 1.1.5. * configure.ac (LIBGPGME_LT_REVISION): Bump for release. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-07-08 16:00:04 UTC (rev 1224) +++ trunk/ChangeLog 2007-07-09 13:07:51 UTC (rev 1225) @@ -1,3 +1,9 @@ +2007-07-09 Marcus Brinkmann + + Released 1.1.5. + + * configure.ac (LIBGPGME_LT_REVISION): Bump for release. + 2007-07-08 Marcus Brinkmann * configure.ac (GPGSM_DEFAULT) [*-mingw32*]: Initialize it. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2007-07-08 16:00:04 UTC (rev 1224) +++ trunk/NEWS 2007-07-09 13:07:51 UTC (rev 1225) @@ -1,7 +1,9 @@ -Noteworthy changes in version 1.1.5 (unreleased) +Noteworthy changes in version 1.1.5 (2007-07-09) ------------------------------------------------ + * Bug and portability fixes (mainly for W32). + Noteworthy changes in version 1.1.4 (2007-03-05) ------------------------------------------------ Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-07-08 16:00:04 UTC (rev 1224) +++ trunk/configure.ac 2007-07-09 13:07:51 UTC (rev 1225) @@ -37,7 +37,7 @@ # the configure script, so that a proper revision number for all files # is available when running a "make distcheck". m4_define(my_version, [1.1.5]) -m4_define(my_iscvs, yes) +#m4_define(my_iscvs, yes) AC_INIT([gpgme], my_version[]m4_ifdef([my_iscvs], [-cvs[]m4_translit( [$Revision$],[Ra-z $:])]), [bug-gpgme at gnupg.org]) @@ -52,7 +52,7 @@ # Subtract 2 from this value if you want to make the LFS transition an # ABI break. [Note to self: Remove this comment with the next regular break.] LIBGPGME_LT_AGE=6 -LIBGPGME_LT_REVISION=3 +LIBGPGME_LT_REVISION=4 # If the API is changed in an incompatible way: increment the next counter. GPGME_CONFIG_API_VERSION=1 From cvs at cvs.gnupg.org Mon Jul 9 15:19:57 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 09 Jul 2007 15:19:57 +0200 Subject: [svn] gpgme - r1226 - tags Message-ID: Author: marcus Date: 2007-07-09 15:19:26 +0200 (Mon, 09 Jul 2007) New Revision: 1226 Added: tags/gpgme-1.1.5/ Log: Tag release 1.1.5. Copied: tags/gpgme-1.1.5 (from rev 1225, trunk) From cvs at cvs.gnupg.org Mon Jul 9 15:23:00 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 09 Jul 2007 15:23:00 +0200 Subject: [svn] gpgme - r1227 - tags Message-ID: Author: marcus Date: 2007-07-09 15:22:31 +0200 (Mon, 09 Jul 2007) New Revision: 1227 Added: tags/gpgme-1.1.3/ Log: Tag release 1.1.3. Copied: tags/gpgme-1.1.3 (from rev 1211, trunk) From cvs at cvs.gnupg.org Mon Jul 9 15:45:36 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 09 Jul 2007 15:45:36 +0200 Subject: [svn] gpgme - r1228 - trunk Message-ID: Author: marcus Date: 2007-07-09 15:45:06 +0200 (Mon, 09 Jul 2007) New Revision: 1228 Modified: trunk/NEWS trunk/configure.ac Log: Post-release fixup. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2007-07-09 13:22:31 UTC (rev 1227) +++ trunk/NEWS 2007-07-09 13:45:06 UTC (rev 1228) @@ -1,3 +1,8 @@ +Noteworthy changes in version 1.1.6 (unreleased) +------------------------------------------------ + + + Noteworthy changes in version 1.1.5 (2007-07-09) ------------------------------------------------ Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-07-09 13:22:31 UTC (rev 1227) +++ trunk/configure.ac 2007-07-09 13:45:06 UTC (rev 1228) @@ -37,7 +37,7 @@ # the configure script, so that a proper revision number for all files # is available when running a "make distcheck". m4_define(my_version, [1.1.5]) -#m4_define(my_iscvs, yes) +m4_define(my_iscvs, yes) AC_INIT([gpgme], my_version[]m4_ifdef([my_iscvs], [-cvs[]m4_translit( [$Revision$],[Ra-z $:])]), [bug-gpgme at gnupg.org]) From cvs at cvs.gnupg.org Tue Jul 10 11:24:58 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 10 Jul 2007 11:24:58 +0200 Subject: [svn] GnuPG - r4540 - in trunk: . artwork common Message-ID: Author: wk Date: 2007-07-10 11:24:29 +0200 (Tue, 10 Jul 2007) New Revision: 4540 Modified: trunk/ChangeLog trunk/artwork/README trunk/common/ChangeLog trunk/common/t-gettime.c trunk/configure.ac Log: Typo fixes. iconv detection fix. Use the currect type in t-gettime. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-07-09 17:26:51 UTC (rev 4539) +++ trunk/ChangeLog 2007-07-10 09:24:29 UTC (rev 4540) @@ -1,3 +1,8 @@ +2007-07-09 Werner Koch + + * configure.ac (AM_ICONV): Check for it even when building without + NLS. + 2007-07-05 Werner Koch Released 2.0.5. Modified: trunk/artwork/README =================================================================== --- trunk/artwork/README 2007-07-09 17:26:51 UTC (rev 4539) +++ trunk/artwork/README 2007-07-10 09:24:29 UTC (rev 4540) @@ -3,7 +3,7 @@ gnupg-logo-new.svg Is the new logo from the logo context. - We actually use the upper riight one; the + We actually use the upper right one; the other elements may still be useful. gnupg-logo-new.eps Other versions. Modified: trunk/common/ChangeLog =================================================================== --- trunk/common/ChangeLog 2007-07-09 17:26:51 UTC (rev 4539) +++ trunk/common/ChangeLog 2007-07-10 09:24:29 UTC (rev 4540) @@ -1,3 +1,7 @@ +2007-07-09 Werner Koch + + * t-gettime.c (test_isotime2epoch): Use time_t and not u32. + 2007-07-05 Werner Koch * t-gettime.c: New. Modified: trunk/common/t-gettime.c =================================================================== --- trunk/common/t-gettime.c 2007-07-09 17:26:51 UTC (rev 4539) +++ trunk/common/t-gettime.c 2007-07-10 09:24:29 UTC (rev 4540) @@ -57,7 +57,7 @@ { NULL, 0 } }; int idx; - u32 val; + time_t val; gnupg_isotime_t tbuf; for (idx=0; array[idx].string; idx++) Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-07-09 17:26:51 UTC (rev 4539) +++ trunk/configure.ac 2007-07-10 09:24:29 UTC (rev 4540) @@ -868,13 +868,18 @@ # +# Checking for iconv +# +AM_ICONV + + +# # Check for gettext # AC_MSG_NOTICE([checking for gettext]) AM_PO_SUBDIRS AM_GNU_GETTEXT_VERSION([0.16.1]) if test "$try_gettext" = yes; then - AM_ICONV AM_GNU_GETTEXT([external],[need-ngettext]) # gettext requires some extra checks. These really should be part of From cvs at cvs.gnupg.org Tue Jul 10 18:07:21 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue, 10 Jul 2007 18:07:21 +0200 Subject: [svn] gpgme - r1229 - trunk/gpgme Message-ID: Author: marcus Date: 2007-07-10 18:06:44 +0200 (Tue, 10 Jul 2007) New Revision: 1229 Modified: trunk/gpgme/ChangeLog trunk/gpgme/engine-gpgsm.c trunk/gpgme/posix-io.c trunk/gpgme/priv-io.h trunk/gpgme/w32-glib-io.c trunk/gpgme/w32-io.c Log: 2007-07-10 Marcus Brinkmann * priv-io.h (_gpgme_io_dup): New prototype. * posix-io.c (_gpgme_io_dup): New function. * w32-io.c (_gpgme_io_dup): Likewise. * w32-glib-io.c (_gpgme_io_dup): Likewise. * engine-gpgsm.c (start): Use _gpgme_dup() instead of dup(). Modified: trunk/gpgme/ChangeLog =================================================================== --- trunk/gpgme/ChangeLog 2007-07-09 13:45:06 UTC (rev 1228) +++ trunk/gpgme/ChangeLog 2007-07-10 16:06:44 UTC (rev 1229) @@ -1,3 +1,11 @@ +2007-07-10 Marcus Brinkmann + + * priv-io.h (_gpgme_io_dup): New prototype. + * posix-io.c (_gpgme_io_dup): New function. + * w32-io.c (_gpgme_io_dup): Likewise. + * w32-glib-io.c (_gpgme_io_dup): Likewise. + * engine-gpgsm.c (start): Use _gpgme_dup() instead of dup(). + 2007-07-08 Marcus Brinkmann * engine-gpgsm.c [HAVE_W32_SYSTEM]: Enable the bunch of the file. Modified: trunk/gpgme/engine-gpgsm.c =================================================================== --- trunk/gpgme/engine-gpgsm.c 2007-07-09 13:45:06 UTC (rev 1228) +++ trunk/gpgme/engine-gpgsm.c 2007-07-10 16:06:44 UTC (rev 1229) @@ -988,7 +988,8 @@ status_fd and register/unregister it manually as needed, but this increases code duplication and is more complicated as we can not use the close notifications etc. */ - gpgsm->status_cb.fd = dup (fdlist[0]); + + gpgsm->status_cb.fd = _gpgme_io_dup (fdlist[0]); if (gpgsm->status_cb.fd < 0) return gpg_error_from_syserror (); Modified: trunk/gpgme/posix-io.c =================================================================== --- trunk/gpgme/posix-io.c 2007-07-09 13:45:06 UTC (rev 1228) +++ trunk/gpgme/posix-io.c 2007-07-10 16:06:44 UTC (rev 1229) @@ -495,3 +495,8 @@ } +int +_gpgme_io_dup (int fd) +{ + return dup (fd); +} Modified: trunk/gpgme/priv-io.h =================================================================== --- trunk/gpgme/priv-io.h 2007-07-09 13:45:06 UTC (rev 1228) +++ trunk/gpgme/priv-io.h 2007-07-10 16:06:44 UTC (rev 1229) @@ -64,4 +64,7 @@ line that the child process expects. */ int _gpgme_io_fd2str (char *buf, int buflen, int fd); +/* Like dup(). */ +int _gpgme_io_dup (int fd); + #endif /* IO_H */ Modified: trunk/gpgme/w32-glib-io.c =================================================================== --- trunk/gpgme/w32-glib-io.c 2007-07-09 13:45:06 UTC (rev 1228) +++ trunk/gpgme/w32-glib-io.c 2007-07-10 16:06:44 UTC (rev 1229) @@ -660,3 +660,11 @@ free (pollfds_map); return count; } + + +int +_gpgme_io_dup (int fd) +{ + return _dup (fd); +} + Modified: trunk/gpgme/w32-io.c =================================================================== --- trunk/gpgme/w32-io.c 2007-07-09 13:45:06 UTC (rev 1228) +++ trunk/gpgme/w32-io.c 2007-07-10 16:06:44 UTC (rev 1229) @@ -1140,6 +1140,25 @@ return snprintf (buf, buflen, "%d", fd); } + +int +_gpgme_io_dup (int fd) +{ + HANDLE handle = fd_to_handle (fd); + HANDLE new_handle = fd_to_handle (fd); + + /* For NT we have to set the sync flag. It seems that the only + * way to do it is by duplicating the handle. Tsss.. */ + if (!DuplicateHandle( GetCurrentProcess(), handle, + GetCurrentProcess(), &new_handle, + 0, FALSE, DUPLICATE_SAME_ACCESS)) + { + DEBUG1 ("** DuplicateHandle failed: ec=%d\n", (int) GetLastError()); + } + + return handle_to_fd (new_handle); +} + /* The following interface is only useful for GPGME Glib. */ From cvs at cvs.gnupg.org Thu Jul 12 12:06:56 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 12 Jul 2007 12:06:56 +0200 Subject: [svn] assuan - r245 - in trunk: . doc src Message-ID: Author: wk Date: 2007-07-12 12:06:26 +0200 (Thu, 12 Jul 2007) New Revision: 245 Modified: trunk/NEWS trunk/TODO trunk/configure.ac trunk/doc/ChangeLog trunk/doc/assuan.texi trunk/src/ChangeLog trunk/src/assuan-buffer.c trunk/src/assuan-defs.h trunk/src/assuan-handler.c trunk/src/assuan-io-pth.c trunk/src/assuan-io.c trunk/src/assuan-listen.c trunk/src/assuan-pipe-connect.c trunk/src/assuan-pipe-server.c trunk/src/assuan-socket-connect.c trunk/src/assuan-socket-server.c trunk/src/assuan-socket.c trunk/src/assuan-uds.c trunk/src/assuan.h Log: Introduced new type for better support of W32 HADNLES vs. file descriptors. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2007-07-08 15:53:35 UTC (rev 244) +++ trunk/NEWS 2007-07-12 10:06:26 UTC (rev 245) @@ -1,6 +1,14 @@ -Noteworthy changes in version 1.0.2 (2007-07-05) +Noteworthy changes in version 1.0.3 ------------------------------------------------ + * New type assuan_fd_t and constant ASSUAN_INVALID_FD for better W32 + support. it does not change teh semantics under Unix. Under W32 + all file descriptors are now guaranteed to be system handles. + + +Noteworthy changes in version 1.0.2 (2007-07-05 +------------------------------------------------ + * Changed license to LGPLv3. * New flag ASSUAN_CONFIDENTIAL to return the state of Modified: trunk/TODO =================================================================== --- trunk/TODO 2007-07-08 15:53:35 UTC (rev 244) +++ trunk/TODO 2007-07-12 10:06:26 UTC (rev 245) @@ -11,3 +11,6 @@ * XOPEN_SOURCE and snprintf See Peter O'Gorman's mail. + +* W32 +** Check what kind of fd we use with inbound.fd etc. \ No newline at end of file Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-07-08 15:53:35 UTC (rev 244) +++ trunk/configure.ac 2007-07-12 10:06:26 UTC (rev 245) @@ -24,8 +24,8 @@ # Remember to change the version number immediately *after* a release. # Set my_issvn to "yes" for non-released code. Remember to run an # "svn up" and "autogen.sh" right before creating a distribution. -m4_define([my_version], [1.0.2]) -m4_define([my_issvn], [no]) +m4_define([my_version], [1.0.3]) +m4_define([my_issvn], [yes]) m4_define([svn_revision], m4_esyscmd([echo -n $( (svn info 2>/dev/null \ || echo 'Revision: 0')|sed -n '/^Revision:/ {s/[^0-9]//gp;q;}')])) Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2007-07-08 15:53:35 UTC (rev 244) +++ trunk/doc/ChangeLog 2007-07-12 10:06:26 UTC (rev 245) @@ -1,3 +1,8 @@ +2007-07-12 Werner Koch + + * assuan.texi (Utilities): Document that under W32 we return a + system handle. + 2007-07-05 Werner Koch * lgpl.texi: New. Taken from COPYING.LIB and reformatted. @@ -36,7 +41,7 @@ * assuan.texi: Imported from newpg. - Copyright 2003 Free Software Foundation, Inc. + Copyright 2003, 2007 Free Software Foundation, Inc. This file is free software; as a special exception the author gives unlimited permission to copy and/or distribute it, with or without Modified: trunk/doc/assuan.texi =================================================================== --- trunk/doc/assuan.texi 2007-07-08 15:53:35 UTC (rev 244) +++ trunk/doc/assuan.texi 2007-07-12 10:06:26 UTC (rev 245) @@ -1207,6 +1207,12 @@ just @code{FD} it returns a file descriptor at @var{rfd}; this file descriptor needs to have been sent by the client right before using @code{assuan_sendfd}. + +On W32 systems the returned file descriptor is a system handle and not a +libc low level I/O file descriptor. Thus applications need to use + at code{_open_osfhandle} before they can pass this descriptor to standard +functions like @code{fdopen} or @code{dup}. + @end deftypefun @deftypefun int assuan_get_input_fd (@w{assuan_context_t @var{ctx}}) @@ -1331,6 +1337,9 @@ On success the number of active descriptors are returned. These active descriptors are then stored in @var{fdarray}. On error @code{-1} is returned; the most likely reason for this is a too small @var{fdarray}. + +Note that on W32 systems the returned file descriptor is a system handle +and not a libc low level I/O file descriptor. @end deftypefun Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2007-07-08 15:53:35 UTC (rev 244) +++ trunk/src/ChangeLog 2007-07-12 10:06:26 UTC (rev 245) @@ -1,3 +1,19 @@ +2007-07-12 Werner Koch + + * assuan.h (assuan_fd_t): New. + (ASSUAN_INVALID_FD): New. Use it everywhere. + * assuan-defs.h (SOCKET2HANDLE, HANDLE2SOCKET) [W32]: New. Use + them to cast descriptors for socket fucntions. + * assuan-pipe-connect.c (fd_to_handle, handle_to_fd): Remove + definition and all uses. + (pid_to_handle, handle_to_pid): Remove as they are ununsed. + * assuan-io.c (_assuan_simple_write, _assuan_simple_read) [W32]: + Make use of HANDLE2SOCKET. + * assuan-socket.c (_assuan_close) [W32]: Use CloseHandle and not + close. + * assuan-handler.c (assuan_get_active_fds) [W32]: Use + _get_osfhandle for the data fp. + 2007-07-08 Marcus Brinkmann * assuan-defs.h (struct assuan_context_s): Have full peercred Modified: trunk/src/assuan-buffer.c =================================================================== --- trunk/src/assuan-buffer.c 2007-07-08 15:53:35 UTC (rev 244) +++ trunk/src/assuan-buffer.c 2007-07-12 10:06:26 UTC (rev 245) @@ -135,7 +135,7 @@ if (ctx->log_fp) fprintf (ctx->log_fp, "%s[%u.%d] DBG: <- [Error: %s]\n", assuan_get_assuan_log_prefix (), - (unsigned int)getpid (), ctx->inbound.fd, + (unsigned int)getpid (), (int)ctx->inbound.fd, strerror (errno)); return _assuan_error (ASSUAN_Read_Error); } @@ -145,7 +145,7 @@ if (ctx->log_fp) fprintf (ctx->log_fp, "%s[%u.%d] DBG: <- [EOF]\n", assuan_get_assuan_log_prefix (), - (unsigned int)getpid (), ctx->inbound.fd); + (unsigned int)getpid (), (int)ctx->inbound.fd); return _assuan_error (-1); } @@ -189,7 +189,7 @@ { fprintf (ctx->log_fp, "%s[%u.%d] DBG: <- ", assuan_get_assuan_log_prefix (), - (unsigned int)getpid (), ctx->inbound.fd); + (unsigned int)getpid (), (int)ctx->inbound.fd); if (ctx->confidential) fputs ("[Confidential data not shown]", ctx->log_fp); else @@ -205,7 +205,7 @@ if (ctx->log_fp) fprintf (ctx->log_fp, "%s[%u.%d] DBG: <- [Invalid line]\n", assuan_get_assuan_log_prefix (), - (unsigned int)getpid (), ctx->inbound.fd); + (unsigned int)getpid (), (int)ctx->inbound.fd); *line = 0; ctx->inbound.linelen = 0; return _assuan_error (ctx->inbound.eof @@ -263,7 +263,7 @@ fprintf (ctx->log_fp, "%s[%u.%d] DBG: -> " "[supplied line too long -truncated]\n", assuan_get_assuan_log_prefix (), - (unsigned int)getpid (), ctx->inbound.fd); + (unsigned int)getpid (), (int)ctx->inbound.fd); if (prefixlen > 5) prefixlen = 5; if (len > ASSUAN_LINELENGTH - prefixlen - 2) @@ -279,7 +279,7 @@ { fprintf (ctx->log_fp, "%s[%u.%d] DBG: -> ", assuan_get_assuan_log_prefix (), - (unsigned int)getpid (), ctx->inbound.fd); + (unsigned int)getpid (), (int)ctx->inbound.fd); if (ctx->confidential) fputs ("[Confidential data not shown]", ctx->log_fp); else @@ -331,7 +331,7 @@ fprintf (ctx->log_fp, "%s[%u.%d] DBG: -> " "[supplied line contained a LF - truncated]\n", assuan_get_assuan_log_prefix (), - (unsigned int)getpid (), ctx->inbound.fd); + (unsigned int)getpid (), (int)ctx->inbound.fd); return _assuan_write_line (ctx, NULL, line, len); } @@ -396,7 +396,7 @@ { fprintf (ctx->log_fp, "%s[%u.%d] DBG: -> ", assuan_get_assuan_log_prefix (), - (unsigned int)getpid (), ctx->inbound.fd); + (unsigned int)getpid (), (int)ctx->inbound.fd); if (ctx->confidential) fputs ("[Confidential data not shown]", ctx->log_fp); @@ -452,7 +452,7 @@ { fprintf (ctx->log_fp, "%s[%u.%d] DBG: -> ", assuan_get_assuan_log_prefix (), - (unsigned int)getpid (), ctx->inbound.fd); + (unsigned int)getpid (), (int)ctx->inbound.fd); if (ctx->confidential) fputs ("[Confidential data not shown]", ctx->log_fp); else @@ -519,11 +519,11 @@ } assuan_error_t -assuan_sendfd (assuan_context_t ctx, int fd) +assuan_sendfd (assuan_context_t ctx, assuan_fd_t fd) { /* It is explicitly allowed to use (NULL, -1) as a runtime test to check whether descriptor passing is available. */ - if (!ctx && fd == -1) + if (!ctx && fd == ASSUAN_INVALID_FD) #ifdef USE_DESCRIPTOR_PASSING return 0; #else @@ -538,7 +538,7 @@ } assuan_error_t -assuan_receivefd (assuan_context_t ctx, int *fd) +assuan_receivefd (assuan_context_t ctx, assuan_fd_t *fd) { if (! ctx->io->receivefd) return set_error (ctx, Not_Implemented, Modified: trunk/src/assuan-defs.h =================================================================== --- trunk/src/assuan-defs.h 2007-07-08 15:53:35 UTC (rev 244) +++ trunk/src/assuan-defs.h 2007-07-12 10:06:26 UTC (rev 245) @@ -80,9 +80,9 @@ /* Routine to write to output_fd. */ ssize_t (*writefnc) (assuan_context_t, const void *, size_t); /* Send a file descriptor. */ - assuan_error_t (*sendfd) (assuan_context_t, int); + assuan_error_t (*sendfd) (assuan_context_t, assuan_fd_t); /* Receive a file descriptor. */ - assuan_error_t (*receivefd) (assuan_context_t, int *); + assuan_error_t (*receivefd) (assuan_context_t, assuan_fd_t *); }; @@ -111,7 +111,7 @@ FILE *log_fp; struct { - int fd; + assuan_fd_t fd; int eof; char line[LINELENGTH]; int linelen; /* w/o CR, LF - might not be the same as @@ -125,7 +125,7 @@ } inbound; struct { - int fd; + assuan_fd_t fd; struct { FILE *fp; char line[LINELENGTH]; @@ -137,8 +137,9 @@ int pipe_mode; /* We are in pipe mode, i.e. we can handle just one connection and must terminate then. */ pid_t pid; /* The pid of the peer. */ - int listen_fd; /* The fd we are listening on (used by socket servers) */ - int connected_fd; /* helper */ + assuan_fd_t listen_fd; /* The fd we are listening on (used by + socket servers) */ + assuan_fd_t connected_fd; /* helper */ struct { int valid; /* Whether this structure has valid information. */ @@ -162,7 +163,7 @@ int bufferoffset; /* Offset of start of buffer. */ int buffersize; /* Bytes buffered. */ - int pendingfds[5]; /* Array to save received descriptors. */ + assuan_fd_t pendingfds[5]; /* Array to save received descriptors. */ int pendingfdscount; /* Number of received descriptors. */ } uds; @@ -195,8 +196,8 @@ const char *line, size_t linelen); - int input_fd; /* set by INPUT command */ - int output_fd; /* set by OUTPUT command */ + assuan_fd_t input_fd; /* Set by the INPUT command. */ + assuan_fd_t output_fd; /* Set by the OUTPUT command. */ /* io routines. */ struct assuan_io *io; @@ -293,10 +294,11 @@ #endif /*-- assuan-socket.c --*/ -int _assuan_close (int fd); -int _assuan_sock_new (int domain, int type, int proto); -int _assuan_sock_bind (int sockfd, struct sockaddr *addr, int addrlen); -int _assuan_sock_connect (int sockfd, struct sockaddr *addr, int addrlen); +int _assuan_close (assuan_fd_t fd); +assuan_fd_t _assuan_sock_new (int domain, int type, int proto); +int _assuan_sock_bind (assuan_fd_t sockfd, struct sockaddr *addr, int addrlen); +int _assuan_sock_connect (assuan_fd_t sockfd, + struct sockaddr *addr, int addrlen); #ifdef HAVE_FOPENCOOKIE /* We have to implement funopen in terms of glibc's fopencookie. */ @@ -329,4 +331,13 @@ #define DIMof(type,member) DIM(((type *)0)->member) +#if HAVE_W32_SYSTEM +#define SOCKET2HANDLE(s) ((void *)(s)) +#define HANDLE2SOCKET(h) ((unsigned int)(h)) +#else +#define SOCKET2HANDLE(s) (s) +#define HANDLE2SOCKET(h) (h) +#endif + + #endif /*ASSUAN_DEFS_H*/ Modified: trunk/src/assuan-handler.c =================================================================== --- trunk/src/assuan-handler.c 2007-07-08 15:53:35 UTC (rev 244) +++ trunk/src/assuan-handler.c 2007-07-12 10:06:26 UTC (rev 245) @@ -135,8 +135,9 @@ return set_error (ctx, Not_Implemented, NULL); } + assuan_error_t -assuan_command_parse_fd (assuan_context_t ctx, char *line, int *rfd) +assuan_command_parse_fd (assuan_context_t ctx, char *line, assuan_fd_t *rfd) { char *endp; @@ -149,7 +150,13 @@ line ++; if (!digitp (*line)) return set_error (ctx, Syntax_Error, "number required"); +#ifdef HAVE_W32_SYSTEM + /* Fixme: For a W32/64bit system we will need to change the cast + and the conversion fucntion. */ + *rfd = (void*)strtoul (line, &endp, 10); +#else *rfd = strtoul (line, &endp, 10); +#endif /* Remove that argument so that a notify handler won't see it. */ memset (line, ' ', endp? (endp-line):strlen(line)); @@ -164,11 +171,13 @@ return assuan_receivefd (ctx, rfd); } + /* Format is INPUT FD= */ static int std_handler_input (assuan_context_t ctx, char *line) { - int rc, fd; + int rc; + assuan_fd_t fd; rc = assuan_command_parse_fd (ctx, line, &fd); if (rc) @@ -183,7 +192,8 @@ static int std_handler_output (assuan_context_t ctx, char *line) { - int rc, fd; + int rc; + assuan_fd_t fd; rc = assuan_command_parse_fd (ctx, line, &fd); if (rc) @@ -644,7 +654,7 @@ **/ int assuan_get_active_fds (assuan_context_t ctx, int what, - int *fdarray, int fdarraysize) + assuan_fd_t *fdarray, int fdarraysize) { int n = 0; @@ -653,15 +663,19 @@ if (!what) { - if (ctx->inbound.fd != -1) + if (ctx->inbound.fd != ASSUAN_INVALID_FD) fdarray[n++] = ctx->inbound.fd; } else { - if (ctx->outbound.fd != -1) + if (ctx->outbound.fd != ASSUAN_INVALID_FD) fdarray[n++] = ctx->outbound.fd; if (ctx->outbound.data.fp) +#ifdef HAVE_W32_SYSTEM + fdarray[n++] = (void*)_get_osfhandle (fileno (ctx->outbound.data.fp)); +#else fdarray[n++] = fileno (ctx->outbound.data.fp); +#endif } return n; Modified: trunk/src/assuan-io-pth.c =================================================================== --- trunk/src/assuan-io-pth.c 2007-07-08 15:53:35 UTC (rev 244) +++ trunk/src/assuan-io-pth.c 2007-07-12 10:06:26 UTC (rev 245) @@ -54,13 +54,15 @@ ssize_t _assuan_simple_read (assuan_context_t ctx, void *buffer, size_t size) { - return pth_read (ctx->inbound.fd, buffer, size); + /* Fixme: For W32 we ehsould better not cast the HANDLE type to int. + However, this requires changes in w32pth too. */ + return pth_read ((int)ctx->inbound.fd, buffer, size); } ssize_t _assuan_simple_write (assuan_context_t ctx, const void *buffer, size_t size) { - return pth_write (ctx->outbound.fd, buffer, size); + return pth_write ((int)ctx->outbound.fd, buffer, size); } #ifdef HAVE_W32_SYSTEM Modified: trunk/src/assuan-io.c =================================================================== --- trunk/src/assuan-io.c 2007-07-08 15:53:35 UTC (rev 244) +++ trunk/src/assuan-io.c 2007-07-12 10:06:26 UTC (rev 245) @@ -55,12 +55,12 @@ read if recv detects that it is not a network socket. */ int n; - n = recv (ctx->inbound.fd, buffer, size, 0); + n = recv (HANDLE2SOCKET(ctx->inbound.fd), buffer, size, 0); if (n == -1 && WSAGetLastError () == WSAENOTSOCK) { DWORD nread = 0; - n = ReadFile ((HANDLE)ctx->inbound.fd, buffer, size, &nread, NULL); + n = ReadFile (ctx->inbound.fd, buffer, size, &nread, NULL); if (!n) { errno = EIO; /* FIXME: We should have a proper mapping. */ @@ -84,12 +84,12 @@ write if send detects that it is not a network socket. */ int n; - n = send (ctx->outbound.fd, buffer, size, 0); + n = send (HANDLE2SOCKET(ctx->outbound.fd), buffer, size, 0); if (n == -1 && WSAGetLastError () == WSAENOTSOCK) { DWORD nwrite; - n = WriteFile ((HANDLE)ctx->outbound.fd, buffer, size, &nwrite, NULL); + n = WriteFile (ctx->outbound.fd, buffer, size, &nwrite, NULL); if (!n) { errno = EIO; /* FIXME: We should have a proper mapping. */ Modified: trunk/src/assuan-listen.c =================================================================== --- trunk/src/assuan-listen.c 2007-07-08 15:53:35 UTC (rev 244) +++ trunk/src/assuan-listen.c 2007-07-12 10:06:26 UTC (rev 245) @@ -114,17 +114,17 @@ -int +assuan_fd_t assuan_get_input_fd (assuan_context_t ctx) { - return ctx? ctx->input_fd : -1; + return ctx? ctx->input_fd : ASSUAN_INVALID_FD; } -int +assuan_fd_t assuan_get_output_fd (assuan_context_t ctx) { - return ctx? ctx->output_fd : -1; + return ctx? ctx->output_fd : ASSUAN_INVALID_FD; } @@ -133,10 +133,10 @@ assuan_error_t assuan_close_input_fd (assuan_context_t ctx) { - if (!ctx || ctx->input_fd == -1) + if (!ctx || ctx->input_fd == ASSUAN_INVALID_FD) return _assuan_error (ASSUAN_Invalid_Value); _assuan_close (ctx->input_fd); - ctx->input_fd = -1; + ctx->input_fd = ASSUAN_INVALID_FD; return 0; } @@ -145,11 +145,11 @@ assuan_error_t assuan_close_output_fd (assuan_context_t ctx) { - if (!ctx || ctx->output_fd == -1) + if (!ctx || ctx->output_fd == ASSUAN_INVALID_FD) return _assuan_error (ASSUAN_Invalid_Value); _assuan_close (ctx->output_fd); - ctx->output_fd = -1; + ctx->output_fd = ASSUAN_INVALID_FD; return 0; } Modified: trunk/src/assuan-pipe-connect.c =================================================================== --- trunk/src/assuan-pipe-connect.c 2007-07-08 15:53:35 UTC (rev 244) +++ trunk/src/assuan-pipe-connect.c 2007-07-12 10:06:26 UTC (rev 245) @@ -56,18 +56,7 @@ #define MAX_OPEN_FDS 20 #endif -#ifdef HAVE_W32_SYSTEM -/* We assume that a HANDLE can be represented by an int which should - be true for all i386 systems (HANDLE is defined as void *) and - these are the only systems for which Windows is available. Further - we assume that -1 denotes an invalid handle. */ -#define fd_to_handle(a) ((HANDLE)(a)) -#define handle_to_fd(a) ((int)(a)) -#define pid_to_handle(a) ((HANDLE)(a)) -#define handle_to_pid(a) ((int)(a)) -#endif /*HAVE_W32_SYSTEM*/ - /* This should be called to make sure that SIGPIPE gets ignored. */ static void fix_signals (void) @@ -120,25 +109,25 @@ static int do_finish (assuan_context_t ctx) { - if (ctx->inbound.fd != -1) + if (ctx->inbound.fd != ASSUAN_INVALID_FD) { _assuan_close (ctx->inbound.fd); if (ctx->inbound.fd == ctx->outbound.fd) - ctx->outbound.fd = -1; - ctx->inbound.fd = -1; + ctx->outbound.fd = ASSUAN_INVALID_FD; + ctx->inbound.fd = ASSUAN_INVALID_FD; } - if (ctx->outbound.fd != -1) + if (ctx->outbound.fd != ASSUAN_INVALID_FD) { _assuan_close (ctx->outbound.fd); - ctx->outbound.fd = -1; + ctx->outbound.fd = ASSUAN_INVALID_FD; } - if (ctx->pid != -1 && ctx->pid) + if (ctx->pid != (pid_t)(-1) && ctx->pid) { #ifndef HAVE_W32_SYSTEM #ifndef _ASSUAN_USE_DOUBLE_FORK if (!ctx->flags.no_waitpid) _assuan_waitpid (ctx->pid, NULL, 0); - ctx->pid = -1; + ctx->pid =(pid_t)(-1); #endif #endif /*!HAVE_W32_SYSTEM*/ } @@ -604,7 +593,7 @@ #ifdef HAVE_W32_SYSTEM /* Create pipe where one end end is inheritable. */ static int -create_inheritable_pipe (int filedes[2], int for_write) +create_inheritable_pipe (assuan_fd_t filedes[2], int for_write) { HANDLE r, w, h; SECURITY_ATTRIBUTES sec_attr; @@ -639,8 +628,8 @@ w = h; } - filedes[0] = handle_to_fd (r); - filedes[1] = handle_to_fd (w); + filedes[0] = r; + filedes[1] = w; return 0; } #endif /*HAVE_W32_SYSTEM*/ @@ -657,8 +646,8 @@ void *atforkvalue) { assuan_error_t err; - int rp[2]; - int wp[2]; + assuan_fd_t rp[2]; + assuan_fd_t wp[2]; char mypidstr[50]; char *cmdline; SECURITY_ATTRIBUTES sec_attr; @@ -693,8 +682,8 @@ if (create_inheritable_pipe (wp, 1)) { - CloseHandle (fd_to_handle (rp[0])); - CloseHandle (fd_to_handle (rp[1])); + CloseHandle (rp[0]); + CloseHandle (rp[1]); xfree (cmdline); return _assuan_error (ASSUAN_General_Error); } @@ -703,10 +692,10 @@ err = _assuan_new_context (ctx); if (err) { - CloseHandle (fd_to_handle (rp[0])); - CloseHandle (fd_to_handle (rp[1])); - CloseHandle (fd_to_handle (wp[0])); - CloseHandle (fd_to_handle (wp[1])); + CloseHandle (rp[0]); + CloseHandle (rp[1]); + CloseHandle (wp[0]); + CloseHandle (wp[1]); xfree (cmdline); return _assuan_error (ASSUAN_General_Error); } @@ -733,8 +722,8 @@ memset (&si, 0, sizeof si); si.cb = sizeof (si); si.dwFlags = STARTF_USESTDHANDLES; - si.hStdInput = fd_to_handle (wp[0]); - si.hStdOutput = fd_to_handle (rp[1]); + si.hStdInput = wp[0]; + si.hStdOutput = rp[1]; /* Dup stderr to /dev/null unless it is in the list of FDs to be passed to the child. */ @@ -753,10 +742,10 @@ if (nullfd == INVALID_HANDLE_VALUE) { _assuan_log_printf ("can't open `nul': %s\n", w32_strerror (-1)); - CloseHandle (fd_to_handle (rp[0])); - CloseHandle (fd_to_handle (rp[1])); - CloseHandle (fd_to_handle (wp[0])); - CloseHandle (fd_to_handle (wp[1])); + CloseHandle (rp[0]); + CloseHandle (rp[1]); + CloseHandle (wp[0]); + CloseHandle (wp[1]); xfree (cmdline); _assuan_release_context (*ctx); return -1; @@ -764,7 +753,7 @@ si.hStdError = nullfd; } else - si.hStdError = fd_to_handle (_get_osfhandle (fd)); + si.hStdError = (void*)_get_osfhandle (fd); /* Note: We inherit all handles flagged as inheritable. This seems @@ -787,10 +776,10 @@ )) { _assuan_log_printf ("CreateProcess failed: %s\n", w32_strerror (-1)); - CloseHandle (fd_to_handle (rp[0])); - CloseHandle (fd_to_handle (rp[1])); - CloseHandle (fd_to_handle (wp[0])); - CloseHandle (fd_to_handle (wp[1])); + CloseHandle (rp[0]); + CloseHandle (rp[1]); + CloseHandle (wp[0]); + CloseHandle (wp[1]); if (nullfd != INVALID_HANDLE_VALUE) CloseHandle (nullfd); xfree (cmdline); @@ -805,8 +794,8 @@ nullfd = INVALID_HANDLE_VALUE; } - CloseHandle (fd_to_handle (rp[1])); - CloseHandle (fd_to_handle (wp[0])); + CloseHandle (rp[1]); + CloseHandle (wp[0]); /* _assuan_log_printf ("CreateProcess ready: hProcess=%p hThread=%p" */ /* " dwProcessID=%d dwThreadId=%d\n", */ Modified: trunk/src/assuan-pipe-server.c =================================================================== --- trunk/src/assuan-pipe-server.c 2007-07-08 15:53:35 UTC (rev 244) +++ trunk/src/assuan-pipe-server.c 2007-07-12 10:06:26 UTC (rev 245) @@ -67,14 +67,14 @@ ctx = xtrycalloc (1, sizeof *ctx); if (!ctx) return _assuan_error (ASSUAN_Out_Of_Core); - ctx->input_fd = -1; - ctx->output_fd = -1; + ctx->input_fd = ASSUAN_INVALID_FD; + ctx->output_fd = ASSUAN_INVALID_FD; - ctx->inbound.fd = -1; - ctx->outbound.fd = -1; + ctx->inbound.fd = ASSUAN_INVALID_FD; + ctx->outbound.fd = ASSUAN_INVALID_FD; ctx->io = &io; - ctx->listen_fd = -1; + ctx->listen_fd = ASSUAN_INVALID_FD; /* Use the pipe server handler as a default. */ ctx->deinit_handler = deinit_pipe_server; ctx->accept_handler = accept_connection; @@ -119,11 +119,11 @@ #ifdef HAVE_W32_SYSTEM /* MS Windows has so many different types of handle that one needs to tranlsate them at many place forth and back. Also - make sure that the fiel descriptos are in binary mode. */ + make sure that the file descriptors are in binary mode. */ setmode (filedes[0], O_BINARY); setmode (filedes[1], O_BINARY); - ctx->inbound.fd = _get_osfhandle (filedes[0]); - ctx->outbound.fd = _get_osfhandle (filedes[1]); + ctx->inbound.fd = (void*)_get_osfhandle (filedes[0]); + ctx->outbound.fd = (void*)_get_osfhandle (filedes[1]); #else s = getenv ("_assuan_connection_fd"); if (s && *s && is_valid_socket (s) ) @@ -135,7 +135,8 @@ _assuan_init_uds_io (ctx); ctx->deinit_handler = _assuan_uds_deinit; } - else if (filedes && filedes[0] != -1 && filedes[1] != -1 ) + else if (filedes && filedes[0] != ASSUAN_INVALID_FD + && filedes[1] != ASSUAN_INVALID_FD ) { /* Standard pipe server. */ ctx->inbound.fd = filedes[0]; Modified: trunk/src/assuan-socket-connect.c =================================================================== --- trunk/src/assuan-socket-connect.c 2007-07-08 15:53:35 UTC (rev 244) +++ trunk/src/assuan-socket-connect.c 2007-07-12 10:06:26 UTC (rev 245) @@ -55,12 +55,12 @@ static int do_finish (assuan_context_t ctx) { - if (ctx->inbound.fd != -1) + if (ctx->inbound.fd != ASSUAN_INVALID_FD) { _assuan_close (ctx->inbound.fd); } - ctx->inbound.fd = -1; - ctx->outbound.fd = -1; + ctx->inbound.fd = ASSUAN_INVALID_FD; + ctx->outbound.fd = ASSUAN_INVALID_FD; return 0; } @@ -96,7 +96,7 @@ assuan_error_t err; assuan_context_t ctx; - int fd; + assuan_fd_t fd; struct sockaddr_un srvr_addr; size_t len; const char *s; @@ -124,7 +124,7 @@ ctx->finish_handler = do_finish; fd = _assuan_sock_new (PF_LOCAL, SOCK_STREAM, 0); - if (fd == -1) + if (fd == ASSUAN_INVALID_FD) { _assuan_log_printf ("can't create socket: %s\n", strerror (errno)); _assuan_release_context (ctx); @@ -138,7 +138,7 @@ len = SUN_LEN (&srvr_addr); - if (_assuan_sock_connect (fd, (struct sockaddr *) &srvr_addr, len) == -1) + if ( _assuan_sock_connect (fd, (struct sockaddr *) &srvr_addr, len) == -1 ) { _assuan_log_printf ("can't connect to `%s': %s\n", name, strerror (errno)); Modified: trunk/src/assuan-socket-server.c =================================================================== --- trunk/src/assuan-socket-server.c 2007-07-08 15:53:35 UTC (rev 244) +++ trunk/src/assuan-socket-server.c 2007-07-12 10:06:26 UTC (rev 245) @@ -45,7 +45,7 @@ static int accept_connection_bottom (assuan_context_t ctx) { - int fd = ctx->connected_fd; + assuan_fd_t fd = ctx->connected_fd; ctx->peercred.valid = 0; #ifdef HAVE_SO_PEERCRED @@ -87,12 +87,13 @@ static int accept_connection (assuan_context_t ctx) { - int fd; + assuan_fd_t fd; struct sockaddr_un clnt_addr; socklen_t len = sizeof clnt_addr; - fd = accept (ctx->listen_fd, (struct sockaddr*)&clnt_addr, &len ); - if (fd == -1) + fd = SOCKET2HANDLE(accept (HANDLE2SOCKET(ctx->listen_fd), + (struct sockaddr*)&clnt_addr, &len )); + if (fd == ASSUAN_INVALID_FD) { ctx->os_errno = errno; return _assuan_error (ASSUAN_Accept_Failed); @@ -105,12 +106,12 @@ static int finish_connection (assuan_context_t ctx) { - if (ctx->inbound.fd != -1) + if (ctx->inbound.fd != ASSUAN_INVALID_FD) { _assuan_close (ctx->inbound.fd); } - ctx->inbound.fd = -1; - ctx->outbound.fd = -1; + ctx->inbound.fd = ASSUAN_INVALID_FD; + ctx->outbound.fd = ASSUAN_INVALID_FD; return 0; } @@ -124,7 +125,7 @@ /* Initialize a server for the socket LISTEN_FD which has already be put into listen mode */ int -assuan_init_socket_server (assuan_context_t *r_ctx, int listen_fd) +assuan_init_socket_server (assuan_context_t *r_ctx, assuan_fd_t listen_fd) { return assuan_init_socket_server_ext (r_ctx, listen_fd, 0); } @@ -132,7 +133,7 @@ /* Initialize a server using the already accepted socket FD. This fucntion is deprecated. */ int -assuan_init_connected_socket_server (assuan_context_t *r_ctx, int fd) +assuan_init_connected_socket_server (assuan_context_t *r_ctx, assuan_fd_t fd) { return assuan_init_socket_server_ext (r_ctx, fd, 2); } @@ -143,7 +144,7 @@ 1 - FD has already been accepted. */ int -assuan_init_socket_server_ext (assuan_context_t *r_ctx, int fd, +assuan_init_socket_server_ext (assuan_context_t *r_ctx, assuan_fd_t fd, unsigned int flags) { assuan_context_t ctx; @@ -156,21 +157,21 @@ ctx->is_server = 1; if ((flags & 2)) ctx->pipe_mode = 1; /* We want a second accept to indicate EOF. */ - ctx->input_fd = -1; - ctx->output_fd = -1; + ctx->input_fd = ASSUAN_INVALID_FD; + ctx->output_fd = ASSUAN_INVALID_FD; - ctx->inbound.fd = -1; - ctx->outbound.fd = -1; + ctx->inbound.fd = ASSUAN_INVALID_FD; + ctx->outbound.fd = ASSUAN_INVALID_FD; if ((flags & 2)) { - ctx->listen_fd = -1; + ctx->listen_fd = ASSUAN_INVALID_FD; ctx->connected_fd = fd; } else { ctx->listen_fd = fd; - ctx->connected_fd = -1; + ctx->connected_fd = ASSUAN_INVALID_FD; } ctx->deinit_handler = (flags & 1)? _assuan_uds_deinit:deinit_socket_server; ctx->accept_handler = ((flags & 2) Modified: trunk/src/assuan-socket.c =================================================================== --- trunk/src/assuan-socket.c 2007-07-08 15:53:35 UTC (rev 244) +++ trunk/src/assuan-socket.c 2007-07-12 10:06:26 UTC (rev 245) @@ -41,20 +41,23 @@ #endif int -_assuan_close (int fd) +_assuan_close (assuan_fd_t fd) { #ifndef HAVE_W32_SYSTEM return close (fd); #else - int rc = closesocket (fd); + int rc = closesocket (HANDLE2SOCKET(fd)); if (rc && WSAGetLastError () == WSAENOTSOCK) - rc = close (fd); + rc = CloseHandle (fd); return rc; #endif } -int +/* Return a new socket. Note that under W32 we consider a socket the + same as an System Handle; all functions using such a handle know + about this dual use and act accordingly. */ +assuan_fd_t _assuan_sock_new (int domain, int type, int proto) { #ifndef HAVE_W32_SYSTEM @@ -62,13 +65,13 @@ #else if (domain == AF_UNIX || domain == AF_LOCAL) domain = AF_INET; - return socket (domain, type, proto); + return SOCKET2HANDLE(socket (domain, type, proto)); #endif } int -_assuan_sock_connect (int sockfd, struct sockaddr * addr, int addrlen) +_assuan_sock_connect (assuan_fd_t sockfd, struct sockaddr *addr, int addrlen) { #ifndef HAVE_W32_SYSTEM return connect (sockfd, addr, addrlen); @@ -86,7 +89,7 @@ fclose (fp); /* XXX: set errno in this case */ if (port < 0 || port > 65535) - return -1; + return -1; myaddr.sin_family = AF_INET; myaddr.sin_port = port; @@ -97,13 +100,13 @@ unaddr->sun_port = myaddr.sin_port; unaddr->sun_addr.s_addr = myaddr.sin_addr.s_addr; - return connect (sockfd, (struct sockaddr *)&myaddr, sizeof myaddr); + return connect (HANDLE2SOCKET(sockfd), (struct sockaddr *)&myaddr, sizeof myaddr); #endif } int -_assuan_sock_bind (int sockfd, struct sockaddr * addr, int addrlen) +_assuan_sock_bind (assuan_fd_t sockfd, struct sockaddr * addr, int addrlen) { #ifndef HAVE_W32_SYSTEM return bind (sockfd, addr, addrlen); @@ -120,10 +123,11 @@ myaddr.sin_family = AF_INET; myaddr.sin_addr.s_addr = htonl (INADDR_LOOPBACK); - rc = bind (sockfd, (struct sockaddr *)&myaddr, len); + rc = bind (HANDLE2SOCKET(sockfd), (struct sockaddr *)&myaddr, len); if (rc) return rc; - rc = getsockname (sockfd, (struct sockaddr *)&myaddr, &len); + rc = getsockname (HANDLE2SOCKET(sockfd), + (struct sockaddr *)&myaddr, &len); if (rc) return rc; unaddr = (struct sockaddr_un *)addr; @@ -140,7 +144,7 @@ return 0; } - return bind (sockfd, addr, addrlen); + return bind (HANDLE2SOCKET(sockfd), addr, addrlen); #endif } Modified: trunk/src/assuan-uds.c =================================================================== --- trunk/src/assuan-uds.c 2007-07-08 15:53:35 UTC (rev 244) +++ trunk/src/assuan-uds.c 2007-07-12 10:06:26 UTC (rev 245) @@ -141,7 +141,7 @@ #else /*HAVE_W32_SYSTEM*/ - len = recvfrom (ctx->inbound.fd, buf, buflen, 0, NULL, NULL); + len = recvfrom (HANDLE2SOCKET(ctx->inbound.fd), buf, buflen, 0, NULL, NULL); #endif /*HAVE_W32_SYSTEM*/ @@ -182,7 +182,7 @@ #else /*HAVE_W32_SYSTEM*/ int len; - len = sendto (ctx->outbound.fd, buf, buflen, 0, + len = sendto (HANDLE2SOCKET(ctx->outbound.fd), buf, buflen, 0, (struct sockaddr *)&ctx->serveraddr, sizeof (struct sockaddr_in)); #endif /*HAVE_W32_SYSTEM*/ @@ -191,7 +191,7 @@ static assuan_error_t -uds_sendfd (assuan_context_t ctx, int fd) +uds_sendfd (assuan_context_t ctx, assuan_fd_t fd) { #ifdef USE_DESCRIPTOR_PASSING struct msghdr msg; @@ -241,7 +241,7 @@ static assuan_error_t -uds_receivefd (assuan_context_t ctx, int *fd) +uds_receivefd (assuan_context_t ctx, assuan_fd_t *fd) { #ifdef USE_DESCRIPTOR_PASSING int i; Modified: trunk/src/assuan.h =================================================================== --- trunk/src/assuan.h 2007-07-08 15:53:35 UTC (rev 244) +++ trunk/src/assuan.h 2007-07-12 10:06:26 UTC (rev 245) @@ -337,6 +337,18 @@ typedef struct assuan_context_s *ASSUAN_CONTEXT _ASSUAN_DEPRECATED; #endif /*_ASSUAN_ONLY_GPG_ERRORS*/ +/* Because we use system handles and not libc low level file + descriptors on W32, we need to declare them as HANDLE (which + actually is a plain pointer). This is required to eventually + support 64 bits Windows systems. */ +#ifdef _WIN32 +typedef void * assuan_fd_t; +#define ASSUAN_INVALID_FD ((void*)(-1)) +#else +typedef int assuan_fd_t; +#define ASSUAN_INVALID_FD (-1) +#endif + /*-- assuan-handler.c --*/ int assuan_register_command (assuan_context_t ctx, const char *cmd_string, @@ -361,7 +373,7 @@ int assuan_process (assuan_context_t ctx); int assuan_process_next (assuan_context_t ctx); int assuan_get_active_fds (assuan_context_t ctx, int what, - int *fdarray, int fdarraysize); + assuan_fd_t *fdarray, int fdarraysize); FILE *assuan_get_data_fp (assuan_context_t ctx); @@ -372,15 +384,17 @@ /* Negotiate a file descriptor. If LINE contains "FD=N", returns N assuming a local file descriptor. If LINE contains "FD" reads a file descriptor via CTX and stores it in *RDF (the CTX must be - capable of passing file descriptors). */ + capable of passing file descriptors). Under W32 the returned FD is + a libc-type one. */ assuan_error_t assuan_command_parse_fd (assuan_context_t ctx, char *line, - int *rfd); + assuan_fd_t *rfd); + /*-- assuan-listen.c --*/ assuan_error_t assuan_set_hello_line (assuan_context_t ctx, const char *line); assuan_error_t assuan_accept (assuan_context_t ctx); -int assuan_get_input_fd (assuan_context_t ctx); -int assuan_get_output_fd (assuan_context_t ctx); +assuan_fd_t assuan_get_input_fd (assuan_context_t ctx); +assuan_fd_t assuan_get_output_fd (assuan_context_t ctx); assuan_error_t assuan_close_input_fd (assuan_context_t ctx); assuan_error_t assuan_close_output_fd (assuan_context_t ctx); @@ -390,10 +404,10 @@ void assuan_deinit_server (assuan_context_t ctx); /*-- assuan-socket-server.c --*/ -int assuan_init_socket_server (assuan_context_t *r_ctx, int listen_fd); +int assuan_init_socket_server (assuan_context_t *r_ctx, assuan_fd_t listen_fd); int assuan_init_connected_socket_server (assuan_context_t *r_ctx, - int fd) _ASSUAN_DEPRECATED; -int assuan_init_socket_server_ext (assuan_context_t *r_ctx, int fd, + assuan_fd_t fd) _ASSUAN_DEPRECATED; +int assuan_init_socket_server_ext (assuan_context_t *r_ctx, assuan_fd_t fd, unsigned int flags); /*-- assuan-pipe-connect.c --*/ @@ -460,8 +474,8 @@ /* The file descriptor must be pending before assuan_receivefd is called. This means that assuan_sendfd should be called *before* the trigger is sent (normally via assuan_write_line ("INPUT FD")). */ -assuan_error_t assuan_sendfd (assuan_context_t ctx, int fd); -assuan_error_t assuan_receivefd (assuan_context_t ctx, int *fd); +assuan_error_t assuan_sendfd (assuan_context_t ctx, assuan_fd_t fd); +assuan_error_t assuan_receivefd (assuan_context_t ctx, assuan_fd_t *fd); /*-- assuan-util.c --*/ void assuan_set_malloc_hooks ( void *(*new_alloc_func)(size_t n), From cvs at cvs.gnupg.org Thu Jul 12 17:25:52 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 12 Jul 2007 17:25:52 +0200 Subject: [svn] gpgme - r1230 - in trunk: . assuan doc gpgme tests tests/gpgsm Message-ID: Author: wk Date: 2007-07-12 17:25:20 +0200 (Thu, 12 Jul 2007) New Revision: 1230 Modified: trunk/assuan/ChangeLog trunk/assuan/assuan-io.c trunk/autogen.sh trunk/doc/ChangeLog trunk/doc/gpgme.texi trunk/gpgme/ChangeLog trunk/gpgme/gpgme.h trunk/gpgme/version.c trunk/tests/ChangeLog trunk/tests/gpgsm/t-support.h Log: Changes for W32 Modified: trunk/assuan/ChangeLog =================================================================== --- trunk/assuan/ChangeLog 2007-07-10 16:06:44 UTC (rev 1229) +++ trunk/assuan/ChangeLog 2007-07-12 15:25:20 UTC (rev 1230) @@ -1,3 +1,8 @@ +2007-07-12 Werner Koch + + * assuan-io.c (_assuan_simple_write, _assuan_simple_read): Map + ERROR_BROKEN_PIPE to EPIPE. + 2007-07-08 Marcus Brinkmann * assuan-defs.h (struct assuan_context_s): Have partial peercred Modified: trunk/assuan/assuan-io.c =================================================================== --- trunk/assuan/assuan-io.c 2007-07-10 16:06:44 UTC (rev 1229) +++ trunk/assuan/assuan-io.c 2007-07-12 15:25:20 UTC (rev 1230) @@ -65,7 +65,11 @@ n = ReadFile ((HANDLE)ctx->inbound.fd, buffer, size, &nread, NULL); if (!n) { - errno = EIO; /* FIXME: We should have a proper mapping. */ + switch (GetLastError()) + { + case ERROR_BROKEN_PIPE: errno = EPIPE; break; + default: errno = EIO; + } n = -1; } else @@ -94,7 +98,12 @@ n = WriteFile ((HANDLE)ctx->outbound.fd, buffer, size, &nwrite, NULL); if (!n) { - errno = EIO; /* FIXME: We should have a proper mapping. */ + switch (GetLastError ()) + { + case ERROR_BROKEN_PIPE: + case ERROR_NO_DATA: errno = EPIPE; break; + default: errno = EIO; break; + } n = -1; } else Modified: trunk/autogen.sh =================================================================== --- trunk/autogen.sh 2007-07-10 16:06:44 UTC (rev 1229) +++ trunk/autogen.sh 2007-07-12 15:25:20 UTC (rev 1230) @@ -80,7 +80,7 @@ ./configure --enable-maintainer-mode --prefix=${w32root} \ --host=i586-mingw32msvc --build=${build} \ - --with-gpg-error-prefix=${w32root} --without-gpgsm \ + --with-gpg-error-prefix=${w32root} \ --enable-shared --enable-static --enable-w32-glib \ PKG_CONFIG_LIBDIR="$w32root/lib/pkgconfig" Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2007-07-10 16:06:44 UTC (rev 1229) +++ trunk/doc/ChangeLog 2007-07-12 15:25:20 UTC (rev 1230) @@ -1,3 +1,8 @@ +2007-07-12 Werner Koch + + * gpgme.texi (Library Version Check): Add remark that the socket + layer will get initialized. + 2007-06-05 Marcus Brinkmann * gpgme.texi (Advanced Key Editing): New section. Modified: trunk/doc/gpgme.texi =================================================================== --- trunk/doc/gpgme.texi 2007-07-10 16:06:44 UTC (rev 1229) +++ trunk/doc/gpgme.texi 2007-07-12 15:25:20 UTC (rev 1230) @@ -572,8 +572,12 @@ version number. In either case, the function initializes some sub-systems, and for this reason alone it must be invoked early in your program, before you make use of the other functions in - at acronym{GPGME}. + at acronym{GPGME}. +As a side effect for W32 based systems, the socket layer will get +initialized. + + If @var{required_version} is @code{NULL}, the function returns a pointer to a statically allocated string containing the version number of the library. Modified: trunk/gpgme/ChangeLog =================================================================== --- trunk/gpgme/ChangeLog 2007-07-10 16:06:44 UTC (rev 1229) +++ trunk/gpgme/ChangeLog 2007-07-12 15:25:20 UTC (rev 1230) @@ -1,3 +1,8 @@ +2007-07-12 Werner Koch + + * version.c (do_subsystem_inits) [W32]: Make sure that the socket + system has been started. + 2007-07-10 Marcus Brinkmann * priv-io.h (_gpgme_io_dup): New prototype. Modified: trunk/gpgme/gpgme.h =================================================================== --- trunk/gpgme/gpgme.h 2007-07-10 16:06:44 UTC (rev 1229) +++ trunk/gpgme/gpgme.h 2007-07-12 15:25:20 UTC (rev 1230) @@ -72,7 +72,7 @@ AM_PATH_GPGME macro) check that this header matches the installed library. Warning: Do not edit the next line. configure will do that for you! */ -#define GPGME_VERSION "1.1.5-cvs1219" +#define GPGME_VERSION "1.1.5-cvs1228" Modified: trunk/gpgme/version.c =================================================================== --- trunk/gpgme/version.c 2007-07-10 16:06:44 UTC (rev 1229) +++ trunk/gpgme/version.c 2007-07-12 15:25:20 UTC (rev 1230) @@ -25,6 +25,9 @@ #include #include #include +#ifdef HAVE_W32_SYSTEM +#include +#endif #include "gpgme.h" #include "priv-io.h" @@ -41,7 +44,7 @@ must be done once at startup. We can not guarantee this using a lock, though, because the semaphore subsystem needs to be initialized itself before it can be used. So we expect that the - user performs the necessary syncrhonization. */ + user performs the necessary synchronization. */ static void do_subsystem_inits (void) { @@ -54,7 +57,15 @@ _gpgme_io_subsystem_init (); #ifdef HAVE_ASSUAN_H assuan_set_assuan_err_source (GPG_ERR_SOURCE_GPGME); -#endif +#ifdef HAVE_W32_SYSTEM + /* We need to make sure that the sockets are initialized. */ + { + WSADATA wsadat; + + WSAStartup (0x202, &wsadat); + } +#endif /*HAVE_W32_SYSTEM*/ +#endif /*HAVE_ASSUAN_H*/ done = 1; } Modified: trunk/tests/ChangeLog =================================================================== --- trunk/tests/ChangeLog 2007-07-10 16:06:44 UTC (rev 1229) +++ trunk/tests/ChangeLog 2007-07-12 15:25:20 UTC (rev 1230) @@ -1,3 +1,8 @@ +2007-07-12 Werner Koch + + * gpgsm/t-support.h (init_gpgme) [W32]: Do not init the locales as + the constants are not available. + 2007-02-26 Werner Koch * gpg/t-verify.c (double_plaintext_sig): New. Modified: trunk/tests/gpgsm/t-support.h =================================================================== --- trunk/tests/gpgsm/t-support.h 2007-07-10 16:06:44 UTC (rev 1229) +++ trunk/tests/gpgsm/t-support.h 2007-07-12 15:25:20 UTC (rev 1230) @@ -91,9 +91,11 @@ gpgme_error_t err; gpgme_check_version (NULL); +#ifndef HAVE_W32_SYSTEM setlocale (LC_ALL, ""); gpgme_set_locale (NULL, LC_CTYPE, setlocale (LC_CTYPE, NULL)); gpgme_set_locale (NULL, LC_MESSAGES, setlocale (LC_MESSAGES, NULL)); +#endif err = gpgme_engine_check_version (proto); fail_if_err (err); From cvs at cvs.gnupg.org Thu Jul 12 17:29:02 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 12 Jul 2007 17:29:02 +0200 Subject: [svn] GnuPG - r4541 - in trunk: common g10 sm Message-ID: Author: wk Date: 2007-07-12 17:28:30 +0200 (Thu, 12 Jul 2007) New Revision: 4541 Modified: trunk/common/ChangeLog trunk/common/sysutils.c trunk/common/sysutils.h trunk/g10/ChangeLog trunk/g10/gpg.c trunk/g10/gpgv.c trunk/sm/ChangeLog trunk/sm/gpgsm.c trunk/sm/server.c Log: Translate all file descriptors received from assuan. Modified: trunk/common/ChangeLog =================================================================== --- trunk/common/ChangeLog 2007-07-10 09:24:29 UTC (rev 4540) +++ trunk/common/ChangeLog 2007-07-12 15:28:30 UTC (rev 4541) @@ -1,3 +1,9 @@ +2007-07-12 Werner Koch + + * sysutils.h (gnupg_fd_t): New. + * sysutils.c (translate_sys2libc_fd): Use that type instead of int. + (translate_sys2libc_fd_int): New. + 2007-07-09 Werner Koch * t-gettime.c (test_isotime2epoch): Use time_t and not u32. Modified: trunk/common/sysutils.c =================================================================== --- trunk/common/sysutils.c 2007-07-10 09:24:29 UTC (rev 4540) +++ trunk/common/sysutils.c 2007-07-12 15:28:30 UTC (rev 4541) @@ -278,24 +278,36 @@ translates system file handles to libc file handles. FOR_WRITE gives the direction of the handle. */ int -translate_sys2libc_fd (int fd, int for_write) +translate_sys2libc_fd (gnupg_fd_t fd, int for_write) { #ifdef HAVE_W32_SYSTEM int x; + + if (fd == GNUPG_INVALID_FD) + return -1; - if (fd <= 2) - return fd; /* Do not do this for error, stdin, stdout, stderr. - (This also ignores an fd of -1.) */ - - x = _open_osfhandle (fd, for_write ? 1 : 0); + /* Note that _open_osfhandle is currently defined to take and return + a long. */ + x = _open_osfhandle ((long)fd, for_write ? 1 : 0); if (x == -1) log_error ("failed to translate osfhandle %p\n", (void *) fd); - else - { -/* log_info ("_open_osfhandle %p yields %d%s\n", */ -/* (void*)fd, x, for_write? " for writing":"" ); */ - fd = x; - } -#endif /* HAVE_W32_SYSTEM */ + return x; +#else /*!HAVE_W32_SYSTEM */ return fd; +#endif } + +/* This is the same as translate_sys2libc_fd but takes an integer + which is assumet to be such an system handle. */ +int +translate_sys2libc_fd_int (int fd, int for_write) +{ +#ifdef HAVE_W32_SYSTEM + if (fd <= 2) + return fd; /* Do not do this for error, stdin, stdout, stderr. */ + + return translate_sys2libc_fd ((void*)fd, for_write); +#else + return fd; +#endif +} Modified: trunk/common/sysutils.h =================================================================== --- trunk/common/sysutils.h 2007-07-10 09:24:29 UTC (rev 4540) +++ trunk/common/sysutils.h 2007-07-12 15:28:30 UTC (rev 4541) @@ -20,14 +20,29 @@ #ifndef GNUPG_COMMON_SYSUTILS_H #define GNUPG_COMMON_SYSUTILS_H +/* Because we use system handles and not libc low level file + descriptors on W32, we need to declare them as HANDLE (which + actually is a plain pointer). This is required to eventually + support 64 bits Windows systems. */ +#ifdef HAVE_W32_SYSTEM +typedef void *gnupg_fd_t; +#define GNUPG_INVALID_FD ((void*)(-1)) +#else +typedef int gnupg_fd_t; +#define GNUPG_INVALID_FD (-1) +#endif + + void trap_unaligned (void); int disable_core_dumps (void); int enable_core_dumps (void); const unsigned char *get_session_marker (size_t *rlen); /*int check_permissions (const char *path,int extension,int checkonly);*/ void gnupg_sleep (unsigned int seconds); -int translate_sys2libc_fd (int fd, int for_write); +int translate_sys2libc_fd (gnupg_fd_t fd, int for_write); +int translate_sys2libc_fd_int (int fd, int for_write); + #ifdef HAVE_W32_SYSTEM #include "../jnlib/w32help.h" Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2007-07-10 09:24:29 UTC (rev 4540) +++ trunk/g10/ChangeLog 2007-07-12 15:28:30 UTC (rev 4541) @@ -1,3 +1,9 @@ +2007-07-12 Werner Koch + + * gpg.c (main): Use translate_sys2libc_fd_int when passing an int + value. + * gpgv.c (main): Ditto. + 2007-07-05 Werner Koch * card-util.c (card_generate_subkey, card_store_subkey): Enable Modified: trunk/g10/gpg.c =================================================================== --- trunk/g10/gpg.c 2007-07-10 09:24:29 UTC (rev 4540) +++ trunk/g10/gpg.c 2007-07-12 15:28:30 UTC (rev 4541) @@ -2160,19 +2160,19 @@ case oDebugLevel: debug_level = pargs.r.ret_str; break; case oStatusFD: - set_status_fd( translate_sys2libc_fd (pargs.r.ret_int, 1) ); + set_status_fd( translate_sys2libc_fd_int (pargs.r.ret_int, 1) ); break; case oStatusFile: set_status_fd ( open_info_file (pargs.r.ret_str, 1) ); break; case oAttributeFD: - set_attrib_fd(translate_sys2libc_fd (pargs.r.ret_int, 1)); + set_attrib_fd(translate_sys2libc_fd_int (pargs.r.ret_int, 1)); break; case oAttributeFile: set_attrib_fd ( open_info_file (pargs.r.ret_str, 1) ); break; case oLoggerFD: - log_set_fd (translate_sys2libc_fd (pargs.r.ret_int, 1)); + log_set_fd (translate_sys2libc_fd_int (pargs.r.ret_int, 1)); break; case oLoggerFile: logfile = pargs.r.ret_str; @@ -2436,14 +2436,14 @@ set_passphrase_from_string(pargs.r.ret_str); break; case oPasswdFD: - pwfd = translate_sys2libc_fd (pargs.r.ret_int, 0); + pwfd = translate_sys2libc_fd_int (pargs.r.ret_int, 0); break; case oPasswdFile: pwfd = open_info_file (pargs.r.ret_str, 0); break; case oPasswdRepeat: opt.passwd_repeat=pargs.r.ret_int; break; case oCommandFD: - opt.command_fd = translate_sys2libc_fd (pargs.r.ret_int, 0); + opt.command_fd = translate_sys2libc_fd_int (pargs.r.ret_int, 0); break; case oCommandFile: opt.command_fd = open_info_file (pargs.r.ret_str, 0); Modified: trunk/g10/gpgv.c =================================================================== --- trunk/g10/gpgv.c 2007-07-10 09:24:29 UTC (rev 4540) +++ trunk/g10/gpgv.c 2007-07-12 15:28:30 UTC (rev 4541) @@ -154,7 +154,7 @@ case oKeyring: append_to_strlist( &nrings, pargs.r.ret_str); break; case oStatusFD: set_status_fd( pargs.r.ret_int ); break; case oLoggerFD: - log_set_fd (translate_sys2libc_fd (pargs.r.ret_int, 1)); + log_set_fd (translate_sys2libc_fd_int (pargs.r.ret_int, 1)); break; case oHomedir: opt.homedir = pargs.r.ret_str; break; case oIgnoreTimeConflict: opt.ignore_time_conflict = 1; break; Modified: trunk/sm/ChangeLog =================================================================== --- trunk/sm/ChangeLog 2007-07-10 09:24:29 UTC (rev 4540) +++ trunk/sm/ChangeLog 2007-07-12 15:28:30 UTC (rev 4541) @@ -1,3 +1,10 @@ +2007-07-12 Werner Koch + + * gpgsm.c (check_special_filename): Use translate_sys2libc_fd_int + when passing an int value. + * server.c (cmd_encrypt, cmd_decrypt, cmd_verify, cmd_import) + (cmd_export, cmd_message, cmd_genkey): Translate file descriptors. + 2007-07-05 Werner Koch * Makefile.am (common_libs): Changed order of libs. Modified: trunk/sm/gpgsm.c =================================================================== --- trunk/sm/gpgsm.c 2007-07-10 09:24:29 UTC (rev 4540) +++ trunk/sm/gpgsm.c 2007-07-12 15:28:30 UTC (rev 4541) @@ -1741,7 +1741,7 @@ for (i=0; isdigit (fname[i]); i++ ) ; if ( !fname[i] ) - return translate_sys2libc_fd (atoi (fname), for_write); + return translate_sys2libc_fd_int (atoi (fname), for_write); } return -1; } Modified: trunk/sm/server.c =================================================================== --- trunk/sm/server.c 2007-07-10 09:24:29 UTC (rev 4540) +++ trunk/sm/server.c 2007-07-12 15:28:30 UTC (rev 4541) @@ -29,6 +29,7 @@ #include #include "gpgsm.h" +#include "sysutils.h" #define set_error(e,t) assuan_set_error (ctx, gpg_error (e), (t)) @@ -409,14 +410,14 @@ FILE *out_fp; int rc; - inp_fd = assuan_get_input_fd (ctx); + inp_fd = translate_sys2libc_fd (assuan_get_input_fd (ctx), 0); if (inp_fd == -1) return set_error (GPG_ERR_ASS_NO_INPUT, NULL); - out_fd = assuan_get_output_fd (ctx); + out_fd = translate_sys2libc_fd (assuan_get_output_fd (ctx), 1); if (out_fd == -1) return set_error (GPG_ERR_ASS_NO_OUTPUT, NULL); - out_fp = fdopen ( dup(out_fd), "w"); + out_fp = fdopen (dup (out_fd), "w"); if (!out_fp) return set_error (GPG_ERR_ASS_GENERAL, "fdopen() failed"); @@ -460,14 +461,14 @@ FILE *out_fp; int rc; - inp_fd = assuan_get_input_fd (ctx); + inp_fd = translate_sys2libc_fd (assuan_get_input_fd (ctx), 0); if (inp_fd == -1) return set_error (GPG_ERR_ASS_NO_INPUT, NULL); - out_fd = assuan_get_output_fd (ctx); + out_fd = translate_sys2libc_fd (assuan_get_output_fd (ctx), 1); if (out_fd == -1) return set_error (GPG_ERR_ASS_NO_OUTPUT, NULL); - out_fp = fdopen ( dup(out_fd), "w"); + out_fp = fdopen (dup(out_fd), "w"); if (!out_fp) return set_error (GPG_ERR_ASS_GENERAL, "fdopen() failed"); rc = gpgsm_decrypt (ctrl, inp_fd, out_fp); @@ -496,8 +497,8 @@ { int rc; ctrl_t ctrl = assuan_get_pointer (ctx); - int fd = assuan_get_input_fd (ctx); - int out_fd = assuan_get_output_fd (ctx); + int fd = translate_sys2libc_fd (assuan_get_input_fd (ctx), 0); + int out_fd = translate_sys2libc_fd (assuan_get_output_fd (ctx), 1); FILE *out_fp = NULL; if (fd == -1) @@ -538,10 +539,10 @@ int detached; int rc; - inp_fd = assuan_get_input_fd (ctx); + inp_fd = translate_sys2libc_fd (assuan_get_input_fd (ctx), 0); if (inp_fd == -1) return set_error (GPG_ERR_ASS_NO_INPUT, NULL); - out_fd = assuan_get_output_fd (ctx); + out_fd = translate_sys2libc_fd (assuan_get_output_fd (ctx), 1); if (out_fd == -1) return set_error (GPG_ERR_ASS_NO_OUTPUT, NULL); @@ -575,7 +576,7 @@ { ctrl_t ctrl = assuan_get_pointer (ctx); int rc; - int fd = assuan_get_input_fd (ctx); + int fd = translate_sys2libc_fd (assuan_get_input_fd (ctx), 0); if (fd == -1) return set_error (GPG_ERR_ASS_NO_INPUT, NULL); @@ -653,7 +654,7 @@ } else { - int fd = assuan_get_output_fd (ctx); + int fd = translate_sys2libc_fd (assuan_get_output_fd (ctx), 1); FILE *out_fp; if (fd == -1) @@ -733,12 +734,14 @@ cmd_message (assuan_context_t ctx, char *line) { int rc; + assuan_fd_t sysfd; int fd; ctrl_t ctrl = assuan_get_pointer (ctx); - rc = assuan_command_parse_fd (ctx, line, &fd); + rc = assuan_command_parse_fd (ctx, line, &sysfd); if (rc) return rc; + fd = translate_sys2libc_fd (sysfd, 0); if (fd == -1) return set_error (GPG_ERR_ASS_NO_INPUT, NULL); ctrl->server_local->message_fd = fd; @@ -785,7 +788,7 @@ if (ctrl->server_local->list_to_output) { - int outfd = assuan_get_output_fd (ctx); + int outfd = translate_sys2libc_fd (assuan_get_output_fd (ctx), 1); if ( outfd == -1 ) return set_error (GPG_ERR_ASS_NO_OUTPUT, NULL); @@ -853,10 +856,10 @@ FILE *out_fp; int rc; - inp_fd = assuan_get_input_fd (ctx); + inp_fd = translate_sys2libc_fd (assuan_get_input_fd (ctx), 0); if (inp_fd == -1) return set_error (GPG_ERR_ASS_NO_INPUT, NULL); - out_fd = assuan_get_output_fd (ctx); + out_fd = translate_sys2libc_fd (assuan_get_output_fd (ctx), 1); if (out_fd == -1) return set_error (GPG_ERR_ASS_NO_OUTPUT, NULL); From cvs at cvs.gnupg.org Thu Jul 12 17:27:03 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 12 Jul 2007 17:27:03 +0200 Subject: [svn] assuan - r246 - trunk/src Message-ID: Author: wk Date: 2007-07-12 17:26:33 +0200 (Thu, 12 Jul 2007) New Revision: 246 Modified: trunk/src/ChangeLog trunk/src/assuan-io-pth.c trunk/src/assuan-io.c Log: Better error code mapping. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2007-07-12 10:06:26 UTC (rev 245) +++ trunk/src/ChangeLog 2007-07-12 15:26:33 UTC (rev 246) @@ -14,6 +14,9 @@ * assuan-handler.c (assuan_get_active_fds) [W32]: Use _get_osfhandle for the data fp. + * assuan-io.c (_assuan_simple_write): Return EPIPE on a closed pipe. + (_assuan_simple_read): Likewise + 2007-07-08 Marcus Brinkmann * assuan-defs.h (struct assuan_context_s): Have full peercred Modified: trunk/src/assuan-io-pth.c =================================================================== --- trunk/src/assuan-io-pth.c 2007-07-12 10:06:26 UTC (rev 245) +++ trunk/src/assuan-io-pth.c 2007-07-12 15:26:33 UTC (rev 246) @@ -54,7 +54,7 @@ ssize_t _assuan_simple_read (assuan_context_t ctx, void *buffer, size_t size) { - /* Fixme: For W32 we ehsould better not cast the HANDLE type to int. + /* Fixme: For W32 we should better not cast the HANDLE type to int. However, this requires changes in w32pth too. */ return pth_read ((int)ctx->inbound.fd, buffer, size); } Modified: trunk/src/assuan-io.c =================================================================== --- trunk/src/assuan-io.c 2007-07-12 10:06:26 UTC (rev 245) +++ trunk/src/assuan-io.c 2007-07-12 15:26:33 UTC (rev 246) @@ -63,7 +63,11 @@ n = ReadFile (ctx->inbound.fd, buffer, size, &nread, NULL); if (!n) { - errno = EIO; /* FIXME: We should have a proper mapping. */ + switch (GetLastError()) + { + case ERROR_BROKEN_PIPE: errno = EPIPE; break; + default: errno = EIO; + } n = -1; } else @@ -92,7 +96,12 @@ n = WriteFile (ctx->outbound.fd, buffer, size, &nwrite, NULL); if (!n) { - errno = EIO; /* FIXME: We should have a proper mapping. */ + switch (GetLastError ()) + { + case ERROR_BROKEN_PIPE: + case ERROR_NO_DATA: errno = EPIPE; break; + default: errno = EIO; break; + } n = -1; } else From cvs at cvs.gnupg.org Thu Jul 12 20:27:24 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Thu, 12 Jul 2007 20:27:24 +0200 Subject: [svn] gpgme - r1231 - in trunk/tests: . gpgsm Message-ID: Author: marcus Date: 2007-07-12 20:26:51 +0200 (Thu, 12 Jul 2007) New Revision: 1231 Modified: trunk/tests/ChangeLog trunk/tests/gpgsm/Makefile.am Log: 2007-07-12 Marcus Brinkmann * gpgsm/Makefile.am (key_id): Change := into =. Modified: trunk/tests/ChangeLog =================================================================== --- trunk/tests/ChangeLog 2007-07-12 15:25:20 UTC (rev 1230) +++ trunk/tests/ChangeLog 2007-07-12 18:26:51 UTC (rev 1231) @@ -1,3 +1,7 @@ +2007-07-12 Marcus Brinkmann + + * gpgsm/Makefile.am (key_id): Change := into =. + 2007-07-12 Werner Koch * gpgsm/t-support.h (init_gpgme) [W32]: Do not init the locales as Modified: trunk/tests/gpgsm/Makefile.am =================================================================== --- trunk/tests/gpgsm/Makefile.am 2007-07-12 15:25:20 UTC (rev 1230) +++ trunk/tests/gpgsm/Makefile.am 2007-07-12 18:26:51 UTC (rev 1231) @@ -38,7 +38,7 @@ # and needs a working pinentry. noinst_PROGRAMS = $(TESTS) t-genkey -key_id := 32100C27173EF6E9C4E9A25D3D69F86D37A4F939 +key_id = 32100C27173EF6E9C4E9A25D3D69F86D37A4F939 DISTCLEANFILES = pubring.kbx pubring.kbx~ gpgsm.conf trustlist.txt \ private-keys-v1.d/$(key_id).key random_seed From cvs at cvs.gnupg.org Thu Jul 12 20:55:17 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 12 Jul 2007 20:55:17 +0200 Subject: [svn] gpgme - r1233 - trunk/assuan Message-ID: Author: wk Date: 2007-07-12 20:54:45 +0200 (Thu, 12 Jul 2007) New Revision: 1233 Modified: trunk/assuan/ChangeLog trunk/assuan/assuan-handler.c trunk/assuan/assuan-socket.c Log: Minor fixes for W32 Modified: trunk/assuan/ChangeLog =================================================================== --- trunk/assuan/ChangeLog 2007-07-12 18:31:22 UTC (rev 1232) +++ trunk/assuan/ChangeLog 2007-07-12 18:54:45 UTC (rev 1233) @@ -1,5 +1,9 @@ 2007-07-12 Werner Koch + * assuan-handler.c (assuan_get_active_fds): Use get_osfhandle for + the data fp. + * assuan-socket.c (_assuan_close) [W32]: Use CloseHandle and not close. + * assuan-io.c (_assuan_simple_write, _assuan_simple_read): Map ERROR_BROKEN_PIPE to EPIPE. Modified: trunk/assuan/assuan-handler.c =================================================================== --- trunk/assuan/assuan-handler.c 2007-07-12 18:31:22 UTC (rev 1232) +++ trunk/assuan/assuan-handler.c 2007-07-12 18:54:45 UTC (rev 1233) @@ -663,7 +663,11 @@ if (ctx->outbound.fd != -1) fdarray[n++] = ctx->outbound.fd; if (ctx->outbound.data.fp) +#ifdef HAVE_W32_SYSTEM + fdarray[n++] = _get_osfhandle (fileno (ctx->outbound.data.fp)); +#else fdarray[n++] = fileno (ctx->outbound.data.fp); +#endif } return n; Modified: trunk/assuan/assuan-socket.c =================================================================== --- trunk/assuan/assuan-socket.c 2007-07-12 18:31:22 UTC (rev 1232) +++ trunk/assuan/assuan-socket.c 2007-07-12 18:54:45 UTC (rev 1233) @@ -50,7 +50,7 @@ #else int rc = closesocket (fd); if (rc && WSAGetLastError () == WSAENOTSOCK) - rc = close (fd); + rc = CloseHandle (fd); return rc; #endif } From cvs at cvs.gnupg.org Thu Jul 12 20:31:54 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Thu, 12 Jul 2007 20:31:54 +0200 Subject: [svn] gpgme - r1232 - trunk/gpgme Message-ID: Author: marcus Date: 2007-07-12 20:31:22 +0200 (Thu, 12 Jul 2007) New Revision: 1232 Modified: trunk/gpgme/ChangeLog trunk/gpgme/Makefile.am Log: 2007-07-12 Marcus Brinkmann * Makefile.am: Replace implicite rule by suffix rule. Add SUFFIXES for that. Modified: trunk/gpgme/ChangeLog =================================================================== --- trunk/gpgme/ChangeLog 2007-07-12 18:26:51 UTC (rev 1231) +++ trunk/gpgme/ChangeLog 2007-07-12 18:31:22 UTC (rev 1232) @@ -1,3 +1,8 @@ +2007-07-12 Marcus Brinkmann + + * Makefile.am: Replace implicite rule by suffix rule. Add + SUFFIXES for that. + 2007-07-12 Werner Koch * version.c (do_subsystem_inits) [W32]: Make sure that the socket Modified: trunk/gpgme/Makefile.am =================================================================== --- trunk/gpgme/Makefile.am 2007-07-12 18:26:51 UTC (rev 1231) +++ trunk/gpgme/Makefile.am 2007-07-12 18:31:22 UTC (rev 1232) @@ -1,4 +1,4 @@ - # Copyright (C) 2000 Werner Koch (dd9jn) +# Copyright (C) 2000 Werner Koch (dd9jn) # Copyright (C) 2001, 2002, 2003, 2004, 2005 g10 Code GmbH # # This file is part of GPGME. @@ -118,7 +118,9 @@ `echo $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) | \ sed -e 's/-I/--include-dir /g;s/-D/--define /g'` -%.lo : %.rc +.SUFFIXES: .rc .lo + +.rc.lo: $(LTRCCOMPILE) -i $< -o $@ gpgme_res = versioninfo.lo From cvs at cvs.gnupg.org Thu Jul 12 22:20:20 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Thu, 12 Jul 2007 22:20:20 +0200 Subject: [svn] gpgme - r1234 - trunk/gpgme Message-ID: Author: marcus Date: 2007-07-12 22:19:46 +0200 (Thu, 12 Jul 2007) New Revision: 1234 Modified: trunk/gpgme/Makefile.am Log: Fix last change. Modified: trunk/gpgme/Makefile.am =================================================================== --- trunk/gpgme/Makefile.am 2007-07-12 18:54:45 UTC (rev 1233) +++ trunk/gpgme/Makefile.am 2007-07-12 20:19:46 UTC (rev 1234) @@ -118,7 +118,7 @@ `echo $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) | \ sed -e 's/-I/--include-dir /g;s/-D/--define /g'` -.SUFFIXES: .rc .lo +SUFFIXES: .rc .lo .rc.lo: $(LTRCCOMPILE) -i $< -o $@ From cvs at cvs.gnupg.org Fri Jul 13 02:43:49 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Fri, 13 Jul 2007 02:43:49 +0200 Subject: [svn] gpgme - r1235 - in trunk: . assuan gpgme Message-ID: Author: marcus Date: 2007-07-13 02:43:17 +0200 (Fri, 13 Jul 2007) New Revision: 1235 Modified: trunk/ChangeLog trunk/assuan/README.1st trunk/assuan/assuan-io.c trunk/gpgme/ChangeLog trunk/gpgme/engine-gpgsm.c trunk/gpgme/posix-io.c trunk/gpgme/priv-io.h trunk/gpgme/rungpg.c trunk/gpgme/w32-glib-io.c trunk/gpgme/w32-io.c Log: 2007-07-13 Marcus Brinkmann * assuan/assuan-io.c (_assuan_simple_read, _assuan_simple_write): Always use read/write (which means _gpgme_io_read and _gpgme_io_write). gpgme/ 2007-07-13 Marcus Brinkmann * priv-io.h (_gpgme_io_set_close_notify): Change type of HANDLER to _gpgme_close_notify_handler. (_gpgme_close_notify_handler): New type. (_gpgme_io_dup): Remove prototype. * posix-io.c (notify_table, _gpgme_io_set_close_notify): Change type of HANDLER to _gpgme_close_notify_handler_t. (_gpgme_io_close): Do not close the FD if handler returns 0. (_gpgme_io_dup): Remove function. * w32-io.c (notify_table, _gpgme_io_set_close_notify, _gpgme_io_close): Change type of HANDLER to _gpgme_close_notify_handler_t. (_gpgme_io_close): Do not close the FD if handler returns 0. (_gpgme_io_dup): Remove function. * w32-glib-io.c (_gpgme_io_dup): Remove function. (_gpgme_io_set_close_notify, notify_table): Change type of HANDLER to _gpgme_close_notify_handler_t. (_gpgme_io_close): Do not close the FD if handler returns 0. * rungpg.c (close_notify_handler): Change return type to int, return 1. * engine-gpgsm.c (close_notify_handler): Change return type to int, return 0 for status FD and 1 for all other FDs. (start): Do not duplicate the status FD. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-07-12 20:19:46 UTC (rev 1234) +++ trunk/ChangeLog 2007-07-13 00:43:17 UTC (rev 1235) @@ -1,3 +1,9 @@ +2007-07-13 Marcus Brinkmann + + * assuan/assuan-io.c (_assuan_simple_read, _assuan_simple_write): + Always use read/write (which means _gpgme_io_read and + _gpgme_io_write). + 2007-07-09 Marcus Brinkmann Released 1.1.5. Modified: trunk/assuan/README.1st =================================================================== --- trunk/assuan/README.1st 2007-07-12 20:19:46 UTC (rev 1234) +++ trunk/assuan/README.1st 2007-07-13 00:43:17 UTC (rev 1235) @@ -27,8 +27,14 @@ We don't need this file as GPGME doesn't use sendmsg and recvmsg. If it would, we would need to pick up the W32 implementation. - Copyright 2004 g10 Code GmbH +* assuan-io.c +** _assuan_simple_read() and _assuan_simple_write() must always use + read()/write() (which actually translates to _gpgme_io_read() and + _gpgme_io_write()). + + Copyright 2004, 2007 g10 Code GmbH + This file is free software; as a special exception the author gives unlimited permission to copy and/or distribute it, with or without modifications, as long as this notice is preserved. Modified: trunk/assuan/assuan-io.c =================================================================== --- trunk/assuan/assuan-io.c 2007-07-12 20:19:46 UTC (rev 1234) +++ trunk/assuan/assuan-io.c 2007-07-13 00:43:17 UTC (rev 1235) @@ -51,7 +51,7 @@ ssize_t _assuan_simple_read (assuan_context_t ctx, void *buffer, size_t size) { -#ifdef HAVE_W32_SYSTEM +#if defined(HAVE_W32_SYSTEM) && !defined(_ASSUAN_IN_GPGME_BUILD_ASSUAN) /* Due to the peculiarities of the W32 API we can't use read for a network socket and thus we try to use recv first and fallback to read if recv detects that it is not a network socket. */ @@ -84,7 +84,7 @@ ssize_t _assuan_simple_write (assuan_context_t ctx, const void *buffer, size_t size) { -#ifdef HAVE_W32_SYSTEM +#if defined(HAVE_W32_SYSTEM) && !defined(_ASSUAN_IN_GPGME_BUILD_ASSUAN) /* Due to the peculiarities of the W32 API we can't use write for a network socket and thus we try to use send first and fallback to write if send detects that it is not a network socket. */ Modified: trunk/gpgme/ChangeLog =================================================================== --- trunk/gpgme/ChangeLog 2007-07-12 20:19:46 UTC (rev 1234) +++ trunk/gpgme/ChangeLog 2007-07-13 00:43:17 UTC (rev 1235) @@ -1,3 +1,28 @@ +2007-07-13 Marcus Brinkmann + + * priv-io.h (_gpgme_io_set_close_notify): Change type of HANDLER + to _gpgme_close_notify_handler. + (_gpgme_close_notify_handler): New type. + (_gpgme_io_dup): Remove prototype. + * posix-io.c (notify_table, _gpgme_io_set_close_notify): Change + type of HANDLER to _gpgme_close_notify_handler_t. + (_gpgme_io_close): Do not close the FD if handler returns 0. + (_gpgme_io_dup): Remove function. + * w32-io.c (notify_table, _gpgme_io_set_close_notify, + _gpgme_io_close): Change type of HANDLER to + _gpgme_close_notify_handler_t. + (_gpgme_io_close): Do not close the FD if handler returns 0. + (_gpgme_io_dup): Remove function. + * w32-glib-io.c (_gpgme_io_dup): Remove function. + (_gpgme_io_set_close_notify, notify_table): Change type of HANDLER + to _gpgme_close_notify_handler_t. + (_gpgme_io_close): Do not close the FD if handler returns 0. + * rungpg.c (close_notify_handler): Change return type to int, + return 1. + * engine-gpgsm.c (close_notify_handler): Change return type to + int, return 0 for status FD and 1 for all other FDs. + (start): Do not duplicate the status FD. + 2007-07-12 Marcus Brinkmann * Makefile.am: Replace implicite rule by suffix rule. Add Modified: trunk/gpgme/engine-gpgsm.c =================================================================== --- trunk/gpgme/engine-gpgsm.c 2007-07-12 20:19:46 UTC (rev 1234) +++ trunk/gpgme/engine-gpgsm.c 2007-07-13 00:43:17 UTC (rev 1235) @@ -112,7 +112,7 @@ } -static void +static int close_notify_handler (int fd, void *opaque) { engine_gpgsm_t gpgsm = opaque; @@ -124,6 +124,9 @@ (*gpgsm->io_cbs.remove) (gpgsm->status_cb.tag); gpgsm->status_cb.fd = -1; gpgsm->status_cb.tag = NULL; + /* We do not want to close the status FD, as it is controled by + Assuan. */ + return 0; } else if (gpgsm->input_cb.fd == fd) { @@ -146,6 +149,7 @@ gpgsm->message_cb.fd = -1; gpgsm->message_cb.tag = NULL; } + return 1; } @@ -983,20 +987,16 @@ if (nfds < 1) return gpg_error (GPG_ERR_GENERAL); /* FIXME */ - /* We duplicate the file descriptor, so we can close it without - disturbing assuan. Alternatively, we could special case - status_fd and register/unregister it manually as needed, but this - increases code duplication and is more complicated as we can not - use the close notifications etc. */ + /* We used to duplicate the file descriptor so that we do not + disturb Assuan. But this gets in the way of the Handle-to-Thread + mapping in w32-io.c, so instead we just share the file descriptor + *carefully*, by avoiding to close it ourselves (this is achieved by + returning 0 from the close_notify_handler for this descriptor). */ + gpgsm->status_cb.fd = fdlist[0]; - gpgsm->status_cb.fd = _gpgme_io_dup (fdlist[0]); - if (gpgsm->status_cb.fd < 0) - return gpg_error_from_syserror (); - if (_gpgme_io_set_close_notify (gpgsm->status_cb.fd, close_notify_handler, gpgsm)) { - close (gpgsm->status_cb.fd); gpgsm->status_cb.fd = -1; return gpg_error (GPG_ERR_GENERAL); } Modified: trunk/gpgme/posix-io.c =================================================================== --- trunk/gpgme/posix-io.c 2007-07-12 20:19:46 UTC (rev 1234) +++ trunk/gpgme/posix-io.c 2007-07-13 00:43:17 UTC (rev 1235) @@ -69,7 +69,7 @@ static struct { - void (*handler) (int,void*); + _gpgme_close_notify_handler_t handler; void *value; } notify_table[256]; @@ -139,6 +139,8 @@ int _gpgme_io_close (int fd) { + int really_close = 1; + if (fd == -1) return -1; /* First call the notify handler. */ @@ -147,18 +149,22 @@ { if (notify_table[fd].handler) { - notify_table[fd].handler (fd, notify_table[fd].value); + really_close = notify_table[fd].handler (fd, notify_table[fd].value); notify_table[fd].handler = NULL; notify_table[fd].value = NULL; } } /* Then do the close. */ - return close (fd); + if (really_close) + return close (fd); + + return 0; } int -_gpgme_io_set_close_notify (int fd, void (*handler)(int, void*), void *value) +_gpgme_io_set_close_notify (int fd, _gpgme_close_notify_handler_t handler, + void *value) { assert (fd != -1); @@ -493,10 +499,3 @@ errno = saved_errno; return nwritten; } - - -int -_gpgme_io_dup (int fd) -{ - return dup (fd); -} Modified: trunk/gpgme/priv-io.h =================================================================== --- trunk/gpgme/priv-io.h 2007-07-12 20:19:46 UTC (rev 1234) +++ trunk/gpgme/priv-io.h 2007-07-13 00:43:17 UTC (rev 1235) @@ -47,7 +47,8 @@ int _gpgme_io_write (int fd, const void *buffer, size_t count); int _gpgme_io_pipe (int filedes[2], int inherit_idx); int _gpgme_io_close (int fd); -int _gpgme_io_set_close_notify (int fd, void (*handler) (int, void *), +typedef int (*_gpgme_close_notify_handler_t) (int,void*); +int _gpgme_io_set_close_notify (int fd, _gpgme_close_notify_handler_t handler, void *value); int _gpgme_io_set_nonblocking (int fd); @@ -64,7 +65,4 @@ line that the child process expects. */ int _gpgme_io_fd2str (char *buf, int buflen, int fd); -/* Like dup(). */ -int _gpgme_io_dup (int fd); - #endif /* IO_H */ Modified: trunk/gpgme/rungpg.c =================================================================== --- trunk/gpgme/rungpg.c 2007-07-12 20:19:46 UTC (rev 1234) +++ trunk/gpgme/rungpg.c 2007-07-13 00:43:17 UTC (rev 1235) @@ -141,7 +141,7 @@ } -static void +static int close_notify_handler (int fd, void *opaque) { engine_gpg_t gpg = opaque; @@ -183,6 +183,7 @@ } } } + return 1; } /* If FRONT is true, push at the front of the list. Use this for Modified: trunk/gpgme/w32-glib-io.c =================================================================== --- trunk/gpgme/w32-glib-io.c 2007-07-12 20:19:46 UTC (rev 1234) +++ trunk/gpgme/w32-glib-io.c 2007-07-13 00:43:17 UTC (rev 1235) @@ -123,10 +123,11 @@ static struct { - void (*handler) (int,void*); + _gpgme_close_notify_handler_t handler; void *value; } notify_table[MAX_SLAFD]; + int _gpgme_io_read (int fd, void *buffer, size_t count) { @@ -270,6 +271,7 @@ _gpgme_io_close (int fd) { GIOChannel *chan; + int really_close = 1; if (fd < 0 || fd >= MAX_SLAFD) { @@ -281,29 +283,32 @@ DEBUG1 ("closing fd %d", fd); if (notify_table[fd].handler) { - notify_table[fd].handler (fd, notify_table[fd].value); + really_close = notify_table[fd].handler (fd, notify_table[fd].value); notify_table[fd].handler = NULL; notify_table[fd].value = NULL; } /* Then do the close. */ - chan = giochannel_table[fd]; - if (chan) + if (really_close) { - g_io_channel_shutdown (chan, 1, NULL); - g_io_channel_unref (chan); - giochannel_table[fd] = NULL; + chan = giochannel_table[fd]; + if (chan) + { + g_io_channel_shutdown (chan, 1, NULL); + g_io_channel_unref (chan); + giochannel_table[fd] = NULL; + } + else + _close (fd); } - else - _close (fd); - return 0; } int -_gpgme_io_set_close_notify (int fd, void (*handler)(int, void*), void *value) +_gpgme_io_set_close_notify (int fd, _gpgme_close_notify_handler_t handler, + void *value) { assert (fd != -1); @@ -660,11 +665,3 @@ free (pollfds_map); return count; } - - -int -_gpgme_io_dup (int fd) -{ - return _dup (fd); -} - Modified: trunk/gpgme/w32-io.c =================================================================== --- trunk/gpgme/w32-io.c 2007-07-12 20:19:46 UTC (rev 1234) +++ trunk/gpgme/w32-io.c 2007-07-13 00:43:17 UTC (rev 1235) @@ -55,11 +55,12 @@ #define MAX_READERS 20 #define MAX_WRITERS 20 -static struct { - int inuse; - int fd; - void (*handler)(int,void*); - void *value; +static struct +{ + int inuse; + int fd; + _gpgme_close_notify_handler_t handler; + void *value; } notify_table[256]; DEFINE_STATIC_LOCK (notify_table_lock); @@ -726,8 +727,9 @@ _gpgme_io_close ( int fd ) { int i; - void (*handler)(int, void*) = NULL; + _gpgme_close_notify_handler_t handler = NULL; void *value = NULL; + int really_close = 1; if ( fd == -1 ) return -1; @@ -738,7 +740,7 @@ LOCK (notify_table_lock); for ( i=0; i < DIM (notify_table); i++ ) { if (notify_table[i].inuse && notify_table[i].fd == fd) { - handler = notify_table[i].handler; + handler = notify_table[i].handler; value = notify_table[i].value; notify_table[i].handler = NULL; notify_table[i].value = NULL; @@ -748,9 +750,9 @@ } UNLOCK (notify_table_lock); if (handler) - handler (fd, value); + really_close = handler (fd, value); - if ( !CloseHandle (fd_to_handle (fd)) ) { + if ( really_close && !CloseHandle (fd_to_handle (fd)) ) { DEBUG2 ("CloseHandle for fd %d failed: ec=%d\n", fd, (int)GetLastError ()); return -1; @@ -760,7 +762,8 @@ } int -_gpgme_io_set_close_notify (int fd, void (*handler)(int, void*), void *value) +_gpgme_io_set_close_notify (int fd, _gpgme_close_notify_handler_t handler, + void *value) { int i; @@ -1140,25 +1143,6 @@ return snprintf (buf, buflen, "%d", fd); } - -int -_gpgme_io_dup (int fd) -{ - HANDLE handle = fd_to_handle (fd); - HANDLE new_handle = fd_to_handle (fd); - - /* For NT we have to set the sync flag. It seems that the only - * way to do it is by duplicating the handle. Tsss.. */ - if (!DuplicateHandle( GetCurrentProcess(), handle, - GetCurrentProcess(), &new_handle, - 0, FALSE, DUPLICATE_SAME_ACCESS)) - { - DEBUG1 ("** DuplicateHandle failed: ec=%d\n", (int) GetLastError()); - } - - return handle_to_fd (new_handle); -} - /* The following interface is only useful for GPGME Glib. */ From cvs at cvs.gnupg.org Fri Jul 13 03:57:32 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Fri, 13 Jul 2007 03:57:32 +0200 Subject: [svn] gpgme - r1236 - trunk/gpgme Message-ID: Author: marcus Date: 2007-07-13 03:57:02 +0200 (Fri, 13 Jul 2007) New Revision: 1236 Modified: trunk/gpgme/ChangeLog trunk/gpgme/engine-gpgsm.c trunk/gpgme/posix-io.c trunk/gpgme/priv-io.h trunk/gpgme/rungpg.c trunk/gpgme/w32-glib-io.c trunk/gpgme/w32-io.c Log: 2007-07-13 Marcus Brinkmann * Revert the "close_notify_handler" returns int stuff. Always close in the _gpgme_io_close implementations. * engine-gpgsm.c (status_handler): Try to terminate the connection in case of error. * w32-io.c (_gpgme_io_read): Return C->error_code in ERRNO. (_gpgme_io_write): Likewise. Modified: trunk/gpgme/ChangeLog =================================================================== --- trunk/gpgme/ChangeLog 2007-07-13 00:43:17 UTC (rev 1235) +++ trunk/gpgme/ChangeLog 2007-07-13 01:57:02 UTC (rev 1236) @@ -1,5 +1,12 @@ 2007-07-13 Marcus Brinkmann + * Revert the "close_notify_handler" returns int stuff. Always + close in the _gpgme_io_close implementations. + * engine-gpgsm.c (status_handler): Try to terminate the connection + in case of error. + * w32-io.c (_gpgme_io_read): Return C->error_code in ERRNO. + (_gpgme_io_write): Likewise. + * priv-io.h (_gpgme_io_set_close_notify): Change type of HANDLER to _gpgme_close_notify_handler. (_gpgme_close_notify_handler): New type. Modified: trunk/gpgme/engine-gpgsm.c =================================================================== --- trunk/gpgme/engine-gpgsm.c 2007-07-13 00:43:17 UTC (rev 1235) +++ trunk/gpgme/engine-gpgsm.c 2007-07-13 01:57:02 UTC (rev 1236) @@ -112,7 +112,7 @@ } -static int +static void close_notify_handler (int fd, void *opaque) { engine_gpgsm_t gpgsm = opaque; @@ -124,9 +124,6 @@ (*gpgsm->io_cbs.remove) (gpgsm->status_cb.tag); gpgsm->status_cb.fd = -1; gpgsm->status_cb.tag = NULL; - /* We do not want to close the status FD, as it is controled by - Assuan. */ - return 0; } else if (gpgsm->input_cb.fd == fd) { @@ -149,7 +146,6 @@ gpgsm->message_cb.fd = -1; gpgsm->message_cb.tag = NULL; } - return 1; } @@ -287,8 +283,6 @@ if (!gpgsm) return gpg_error (GPG_ERR_INV_VALUE); - if (gpgsm->status_cb.fd != -1) - _gpgme_io_close (gpgsm->status_cb.fd); if (gpgsm->input_cb.fd != -1) _gpgme_io_close (gpgsm->input_cb.fd); if (gpgsm->output_cb.fd != -1) @@ -827,6 +821,8 @@ err = gpg_error (GPG_ERR_GENERAL); DEBUG2 ("fd %d: ERR line - mapped to: %s\n", fd, err? gpg_strerror (err):"ok"); + /* Try our best to terminate the connection friendly. */ + assuan_write_line (gpgsm->assuan_ctx, "BYE"); } else if (linelen >= 2 && line[0] == 'O' && line[1] == 'K' @@ -846,7 +842,6 @@ gpgsm->colon.any = 0; err = gpgsm->colon.fnc (gpgsm->colon.fnc_value, NULL); } - _gpgme_io_close (gpgsm->status_cb.fd); DEBUG2 ("fd %d: OK line - final status: %s\n", fd, err? gpg_strerror (err):"ok"); return err; @@ -990,8 +985,7 @@ /* We used to duplicate the file descriptor so that we do not disturb Assuan. But this gets in the way of the Handle-to-Thread mapping in w32-io.c, so instead we just share the file descriptor - *carefully*, by avoiding to close it ourselves (this is achieved by - returning 0 from the close_notify_handler for this descriptor). */ + but leave it to Assuan to close it. */ gpgsm->status_cb.fd = fdlist[0]; if (_gpgme_io_set_close_notify (gpgsm->status_cb.fd, Modified: trunk/gpgme/posix-io.c =================================================================== --- trunk/gpgme/posix-io.c 2007-07-13 00:43:17 UTC (rev 1235) +++ trunk/gpgme/posix-io.c 2007-07-13 01:57:02 UTC (rev 1236) @@ -139,8 +139,6 @@ int _gpgme_io_close (int fd) { - int really_close = 1; - if (fd == -1) return -1; /* First call the notify handler. */ @@ -149,16 +147,13 @@ { if (notify_table[fd].handler) { - really_close = notify_table[fd].handler (fd, notify_table[fd].value); + notify_table[fd].handler (fd, notify_table[fd].value); notify_table[fd].handler = NULL; notify_table[fd].value = NULL; } } /* Then do the close. */ - if (really_close) - return close (fd); - - return 0; + return close (fd); } Modified: trunk/gpgme/priv-io.h =================================================================== --- trunk/gpgme/priv-io.h 2007-07-13 00:43:17 UTC (rev 1235) +++ trunk/gpgme/priv-io.h 2007-07-13 01:57:02 UTC (rev 1236) @@ -47,7 +47,7 @@ int _gpgme_io_write (int fd, const void *buffer, size_t count); int _gpgme_io_pipe (int filedes[2], int inherit_idx); int _gpgme_io_close (int fd); -typedef int (*_gpgme_close_notify_handler_t) (int,void*); +typedef void (*_gpgme_close_notify_handler_t) (int,void*); int _gpgme_io_set_close_notify (int fd, _gpgme_close_notify_handler_t handler, void *value); int _gpgme_io_set_nonblocking (int fd); Modified: trunk/gpgme/rungpg.c =================================================================== --- trunk/gpgme/rungpg.c 2007-07-13 00:43:17 UTC (rev 1235) +++ trunk/gpgme/rungpg.c 2007-07-13 01:57:02 UTC (rev 1236) @@ -141,7 +141,7 @@ } -static int +static void close_notify_handler (int fd, void *opaque) { engine_gpg_t gpg = opaque; @@ -183,7 +183,6 @@ } } } - return 1; } /* If FRONT is true, push at the front of the list. Use this for Modified: trunk/gpgme/w32-glib-io.c =================================================================== --- trunk/gpgme/w32-glib-io.c 2007-07-13 00:43:17 UTC (rev 1235) +++ trunk/gpgme/w32-glib-io.c 2007-07-13 01:57:02 UTC (rev 1236) @@ -271,7 +271,6 @@ _gpgme_io_close (int fd) { GIOChannel *chan; - int really_close = 1; if (fd < 0 || fd >= MAX_SLAFD) { @@ -283,24 +282,21 @@ DEBUG1 ("closing fd %d", fd); if (notify_table[fd].handler) { - really_close = notify_table[fd].handler (fd, notify_table[fd].value); + notify_table[fd].handler (fd, notify_table[fd].value); notify_table[fd].handler = NULL; notify_table[fd].value = NULL; } /* Then do the close. */ - if (really_close) + chan = giochannel_table[fd]; + if (chan) { - chan = giochannel_table[fd]; - if (chan) - { - g_io_channel_shutdown (chan, 1, NULL); - g_io_channel_unref (chan); - giochannel_table[fd] = NULL; - } - else - _close (fd); + g_io_channel_shutdown (chan, 1, NULL); + g_io_channel_unref (chan); + giochannel_table[fd] = NULL; } + else + _close (fd); return 0; } Modified: trunk/gpgme/w32-io.c =================================================================== --- trunk/gpgme/w32-io.c 2007-07-13 00:43:17 UTC (rev 1235) +++ trunk/gpgme/w32-io.c 2007-07-13 01:57:02 UTC (rev 1236) @@ -374,6 +374,7 @@ DEBUG2 ("fd %d: about to read %d bytes\n", fd, (int)count ); if ( !c ) { DEBUG0 ( "no reader thread\n"); + errno = EBADF; return -1; } if (c->eof_shortcut) { @@ -402,6 +403,7 @@ return 0; } DEBUG1 ("fd %d: read error", fd ); + errno = c->error_code; return -1; } @@ -631,11 +633,12 @@ _gpgme_debug (2, "fd %d: write `%.*s'\n", fd, (int) count, buffer); if ( !c ) { DEBUG0 ( "no writer thread\n"); + errno = EBADF; return -1; } LOCK (c->mutex); - if ( c->nbytes ) { /* bytes are pending for send */ + if ( !c->error && c->nbytes ) { /* bytes are pending for send */ /* Reset the is_empty event. Better safe than sorry. */ if (!ResetEvent (c->is_empty)) DEBUG1 ("ResetEvent failed: ec=%d", (int)GetLastError ()); @@ -650,6 +653,7 @@ if ( c->error) { UNLOCK (c->mutex); DEBUG1 ("fd %d: write error", fd ); + errno = c->error_code; return -1; } @@ -729,7 +733,6 @@ int i; _gpgme_close_notify_handler_t handler = NULL; void *value = NULL; - int really_close = 1; if ( fd == -1 ) return -1; @@ -750,9 +753,9 @@ } UNLOCK (notify_table_lock); if (handler) - really_close = handler (fd, value); + handler (fd, value); - if ( really_close && !CloseHandle (fd_to_handle (fd)) ) { + if ( !CloseHandle (fd_to_handle (fd)) ) { DEBUG2 ("CloseHandle for fd %d failed: ec=%d\n", fd, (int)GetLastError ()); return -1; From cvs at cvs.gnupg.org Fri Jul 13 16:47:43 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Fri, 13 Jul 2007 16:47:43 +0200 Subject: [svn] gpgme - r1237 - trunk/gpgme Message-ID: Author: marcus Date: 2007-07-13 16:47:07 +0200 (Fri, 13 Jul 2007) New Revision: 1237 Modified: trunk/gpgme/ChangeLog trunk/gpgme/data-compat.c trunk/gpgme/data-user.c trunk/gpgme/gpgme.c Log: 2007-07-13 Marcus Brinkmann * data-user.c (user_read, user_write, user_seek): Set errno and return -1 instead returning the error code directly. * data-compat.c (old_user_seek): Likewise. * gpgme.c (gpgme_sig_notation_add): Return error properly. Modified: trunk/gpgme/ChangeLog =================================================================== --- trunk/gpgme/ChangeLog 2007-07-13 01:57:02 UTC (rev 1236) +++ trunk/gpgme/ChangeLog 2007-07-13 14:47:07 UTC (rev 1237) @@ -1,5 +1,10 @@ 2007-07-13 Marcus Brinkmann + * data-user.c (user_read, user_write, user_seek): Set errno and + return -1 instead returning the error code directly. + * data-compat.c (old_user_seek): Likewise. + * gpgme.c (gpgme_sig_notation_add): Return error properly. + * Revert the "close_notify_handler" returns int stuff. Always close in the _gpgme_io_close implementations. * engine-gpgsm.c (status_handler): Try to terminate the connection Modified: trunk/gpgme/data-compat.c =================================================================== --- trunk/gpgme/data-compat.c 2007-07-13 01:57:02 UTC (rev 1236) +++ trunk/gpgme/data-compat.c 2007-07-13 14:47:07 UTC (rev 1237) @@ -167,7 +167,10 @@ { gpgme_error_t err; if (whence != SEEK_SET || offset) - return EINVAL; + { + errno = EINVAL; + return -1; + } err = (*dh->data.old_user.cb) (dh->data.old_user.handle, NULL, 0, NULL); if (err) return gpgme_error_to_errno (err); Modified: trunk/gpgme/data-user.c =================================================================== --- trunk/gpgme/data-user.c 2007-07-13 01:57:02 UTC (rev 1236) +++ trunk/gpgme/data-user.c 2007-07-13 14:47:07 UTC (rev 1237) @@ -32,7 +32,10 @@ user_read (gpgme_data_t dh, void *buffer, size_t size) { if (!dh->data.user.cbs->read) - return EBADF; + { + errno = EBADF; + return -1; + } return (*dh->data.user.cbs->read) (dh->data.user.handle, buffer, size); } @@ -42,7 +45,10 @@ user_write (gpgme_data_t dh, const void *buffer, size_t size) { if (!dh->data.user.cbs->write) - return EBADF; + { + errno = EBADF; + return -1; + } return (*dh->data.user.cbs->write) (dh->data.user.handle, buffer, size); } @@ -52,7 +58,10 @@ user_seek (gpgme_data_t dh, off_t offset, int whence) { if (!dh->data.user.cbs->seek) - return EBADF; + { + errno = EBADF; + return -1; + } return (*dh->data.user.cbs->seek) (dh->data.user.handle, offset, whence); } Modified: trunk/gpgme/gpgme.c =================================================================== --- trunk/gpgme/gpgme.c 2007-07-13 01:57:02 UTC (rev 1236) +++ trunk/gpgme/gpgme.c 2007-07-13 14:47:07 UTC (rev 1237) @@ -471,7 +471,7 @@ gpgme_sig_notation_t *lastp; if (!ctx) - gpg_error (GPG_ERR_INV_VALUE); + return gpg_error (GPG_ERR_INV_VALUE); if (name) flags |= GPGME_SIG_NOTATION_HUMAN_READABLE; From cvs at cvs.gnupg.org Mon Jul 16 11:54:17 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 16 Jul 2007 11:54:17 +0200 Subject: [svn] GnuPG - r4542 - in trunk: agent common sm Message-ID: Author: wk Date: 2007-07-16 11:53:47 +0200 (Mon, 16 Jul 2007) New Revision: 4542 Modified: trunk/agent/ChangeLog trunk/agent/call-pinentry.c trunk/agent/genkey.c trunk/common/ChangeLog trunk/common/estream.c trunk/common/exechelp.c trunk/common/simple-pwquery.c trunk/sm/ChangeLog trunk/sm/server.c Log: Properly close files opened by es_fopen. Allow setting of an empty passphrase. Assorted W32 changes. Modified: trunk/agent/ChangeLog =================================================================== --- trunk/agent/ChangeLog 2007-07-12 15:28:30 UTC (rev 4541) +++ trunk/agent/ChangeLog 2007-07-16 09:53:47 UTC (rev 4542) @@ -1,3 +1,10 @@ +2007-07-13 Werner Koch + + * genkey.c (check_passphrase_constraints): Require a confirmation + for an empty passphrase. + (agent_genkey, agent_protect_and_store): No need to repeat an + empty passphrase. + 2007-07-05 Werner Koch * call-scd.c (struct inq_needpin_s): New. @@ -89,7 +96,7 @@ * protect-tool.c (main) [W32]: Call pth_init. - * preset-passphrase.c (main) [W32]: Repalce the explicit Winsocket + * preset-passphrase.c (main) [W32]: Replace the explicit Winsocket init by a call to pth_init. * trustlist.c (initialize_module_trustlist): New. Modified: trunk/agent/call-pinentry.c =================================================================== --- trunk/agent/call-pinentry.c 2007-07-12 15:28:30 UTC (rev 4541) +++ trunk/agent/call-pinentry.c 2007-07-16 09:53:47 UTC (rev 4542) @@ -206,12 +206,22 @@ if (opt.verbose) log_info ("starting a new PIN Entry\n"); - + +#ifdef HAVE_W32_SYSTEM + fflush (stdout); + fflush (stderr); +#endif if (fflush (NULL)) { gpg_error_t tmperr = gpg_error (gpg_err_code_from_errno (errno)); log_error ("error flushing pending output: %s\n", strerror (errno)); + /* At least Windows XP fails here with EBADF. According to docs + and Wine an fflush(NULL) is the same as _flushall. However + the Wime implementaion does not flush stdin,stdout and stderr + - see above. Lets try to ignore the error. */ +#ifndef HAVE_W32_SYSTEM return unlock_pinentry (tmperr); +#endif } if (!opt.pinentry_program || !*opt.pinentry_program) Modified: trunk/agent/genkey.c =================================================================== --- trunk/agent/genkey.c 2007-07-12 15:28:30 UTC (rev 4541) +++ trunk/agent/genkey.c 2007-07-16 09:53:47 UTC (rev 4542) @@ -1,5 +1,5 @@ /* pksign.c - Generate a keypair - * Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. + * Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -102,6 +102,20 @@ return err; } + if (!*pw) + { + const char *desc = _("You have not entered a passphrase - " + "this is in general a bad idea!%0A" + "Please confirm that you do not want to " + "have any protection on your key."); + + err = agent_get_confirmation (ctrl, desc, + _("Yes, protection is not needed"), + _("Enter new passphrase")); + if (err) + return err; + } + return 0; } @@ -166,12 +180,15 @@ pi2->failed_tries = 0; goto next_try; } - rc = agent_askpin (ctrl, text2, NULL, NULL, pi2); - if (rc == -1) - { /* The re-entered one did not match and the user did not - hit cancel. */ - initial_errtext = _("does not match - try again"); - goto next_try; + if (pi->pin && *pi->pin) + { + rc = agent_askpin (ctrl, text2, NULL, NULL, pi2); + if (rc == -1) + { /* The re-entered one did not match and the user did not + hit cancel. */ + initial_errtext = _("does not match - try again"); + goto next_try; + } } } if (rc) @@ -284,12 +301,16 @@ pi2->failed_tries = 0; goto next_try; } - rc = agent_askpin (ctrl, text2, NULL, NULL, pi2); - if (rc == -1) - { /* The re-entered one did not match and the user did not - hit cancel. */ - initial_errtext = _("does not match - try again"); - goto next_try; + /* Unless the passphrase is empty, ask to confirm it. */ + if (pi->pin && *pi->pin) + { + rc = agent_askpin (ctrl, text2, NULL, NULL, pi2); + if (rc == -1) + { /* The re-entered one did not match and the user did not + hit cancel. */ + initial_errtext = _("does not match - try again"); + goto next_try; + } } } if (rc) Modified: trunk/common/ChangeLog =================================================================== --- trunk/common/ChangeLog 2007-07-12 15:28:30 UTC (rev 4541) +++ trunk/common/ChangeLog 2007-07-16 09:53:47 UTC (rev 4542) @@ -1,3 +1,7 @@ +2007-07-16 Werner Koch + + * estream.c (es_func_file_create): Clear NO_CLOSE flag. + 2007-07-12 Werner Koch * sysutils.h (gnupg_fd_t): New. Modified: trunk/common/estream.c =================================================================== --- trunk/common/estream.c 2007-07-12 15:28:30 UTC (rev 4541) +++ trunk/common/estream.c 2007-07-16 09:53:47 UTC (rev 4542) @@ -861,6 +861,7 @@ #endif file_cookie->fd = fd; + file_cookie->no_close = 0; *cookie = file_cookie; *filedes = fd; Modified: trunk/common/exechelp.c =================================================================== --- trunk/common/exechelp.c 2007-07-12 15:28:30 UTC (rev 4541) +++ trunk/common/exechelp.c 2007-07-16 09:53:47 UTC (rev 4542) @@ -358,10 +358,7 @@ if (x == -1) log_error ("failed to translate osfhandle %p\n", (void*)rp[0] ); else - { - log_debug ("_open_osfhandle %p yields %d\n", (void*)fd, x ); - *statusfile = fdopen (x, "r"); - } + *statusfile = fdopen (x, "r"); } if (!*statusfile) { Modified: trunk/common/simple-pwquery.c =================================================================== --- trunk/common/simple-pwquery.c 2007-07-12 15:28:30 UTC (rev 4541) +++ trunk/common/simple-pwquery.c 2007-07-16 09:53:47 UTC (rev 4542) @@ -327,9 +327,6 @@ { #ifdef SPWQ_USE_LOGGING log_error ( _("malformed GPG_AGENT_INFO environment variable\n")); - log_debug ( "a='%s'\n", infostr); - log_debug ( "a='%s'\n", strchr ( infostr, PATHSEP_C)); - log_debug ( "a=%td\n", (p-infostr)); #endif return SPWQ_NO_AGENT; } Modified: trunk/sm/ChangeLog =================================================================== --- trunk/sm/ChangeLog 2007-07-12 15:28:30 UTC (rev 4541) +++ trunk/sm/ChangeLog 2007-07-16 09:53:47 UTC (rev 4542) @@ -1,3 +1,8 @@ +2007-07-16 Werner Koch + + * server.c (cmd_message): Use gnupg_fd_t to avoid dependecy on + newer assuan versions. + 2007-07-12 Werner Koch * gpgsm.c (check_special_filename): Use translate_sys2libc_fd_int Modified: trunk/sm/server.c =================================================================== --- trunk/sm/server.c 2007-07-12 15:28:30 UTC (rev 4541) +++ trunk/sm/server.c 2007-07-16 09:53:47 UTC (rev 4542) @@ -734,7 +734,7 @@ cmd_message (assuan_context_t ctx, char *line) { int rc; - assuan_fd_t sysfd; + gnupg_fd_t sysfd; int fd; ctrl_t ctrl = assuan_get_pointer (ctx); From cvs at cvs.gnupg.org Mon Jul 16 16:34:09 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 16 Jul 2007 16:34:09 +0200 Subject: [svn] GnuPG - r4543 - trunk/tools Message-ID: Author: marcus Date: 2007-07-16 16:33:34 +0200 (Mon, 16 Jul 2007) New Revision: 4543 Modified: trunk/tools/ChangeLog trunk/tools/gpg-connect-agent.c Log: 2007-07-16 Marcus Brinkmann * gpg-connect-agent.c (main): Bail out if write fails. Modified: trunk/tools/ChangeLog =================================================================== --- trunk/tools/ChangeLog 2007-07-16 09:53:47 UTC (rev 4542) +++ trunk/tools/ChangeLog 2007-07-16 14:33:34 UTC (rev 4543) @@ -1,3 +1,7 @@ +2007-07-16 Marcus Brinkmann + + * gpg-connect-agent.c (main): Bail out if write fails. + 2007-07-05 Marcus Brinkmann * symcryptrun.c (confucius_get_pass): Define orig_codeset if Modified: trunk/tools/gpg-connect-agent.c =================================================================== --- trunk/tools/gpg-connect-agent.c 2007-07-16 09:53:47 UTC (rev 4542) +++ trunk/tools/gpg-connect-agent.c 2007-07-16 14:33:34 UTC (rev 4543) @@ -258,7 +258,6 @@ } - /* gpg-connect-agent's entry point. */ int main (int argc, char **argv) @@ -464,7 +463,7 @@ if (rc) { log_info (_("sending line failed: %s\n"), gpg_strerror (rc) ); - continue; + break; } if (*line == '#' || !*line) continue; /* Don't expect a response for a comment line. */ @@ -472,6 +471,12 @@ rc = read_and_print_response (ctx); if (rc) log_info (_("receiving line failed: %s\n"), gpg_strerror (rc) ); + + /* FIXME: If the last command was BYE or the server died for + some other reason, we won't notice until we get the next + input command. Probing the connection with a non-blocking + read could help to notice termination or other problems + early. */ } if (opt.verbose) From cvs at cvs.gnupg.org Mon Jul 16 19:26:40 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 16 Jul 2007 19:26:40 +0200 Subject: [svn] gpgme - r1238 - in trunk: . assuan gpgme Message-ID: Author: marcus Date: 2007-07-16 19:26:09 +0200 (Mon, 16 Jul 2007) New Revision: 1238 Modified: trunk/ChangeLog trunk/assuan/README.1st trunk/assuan/assuan-socket.c trunk/assuan/assuan.h trunk/gpgme/ChangeLog trunk/gpgme/engine-gpgsm.c trunk/gpgme/posix-io.c trunk/gpgme/priv-io.h trunk/gpgme/w32-glib-io.c trunk/gpgme/w32-io.c Log: 2007-07-16 Marcus Brinkmann * assuan/assuan-socket.c (_assuan_close): Always use close(). * assuan/assuan.h (_gpgme_io_close): New prototype. (close): New macro, define as _gpgme_io_close. gpgme/ 2007-07-16 Marcus Brinkmann * w32-io.c (struct reader_context_s, struct writer_context_s): New members REFCOUNT. (create_reader, create_writer): Initialize C->refcount to 1. (destroy_reader, destroy_writer): Only destroy if C->refcount drops to 0. (find_reader, find_writer, kill_reader, kill_writer): Beautify. * priv-io.h (_gpgme_io_dup): New prototype. * posix-io.c (_gpgme_io_dup): New function. * w32-io.c (_gpgme_io_dup): Likewise. * w32-glib-io.c (_gpgme_io_dup): Likewise. * engine-gpgsm.c (start): Reverting to version 2007-07-10. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-07-13 14:47:07 UTC (rev 1237) +++ trunk/ChangeLog 2007-07-16 17:26:09 UTC (rev 1238) @@ -1,3 +1,9 @@ +2007-07-16 Marcus Brinkmann + + * assuan/assuan-socket.c (_assuan_close): Always use close(). + * assuan/assuan.h (_gpgme_io_close): New prototype. + (close): New macro, define as _gpgme_io_close. + 2007-07-13 Marcus Brinkmann * assuan/assuan-io.c (_assuan_simple_read, _assuan_simple_write): Modified: trunk/assuan/README.1st =================================================================== --- trunk/assuan/README.1st 2007-07-13 14:47:07 UTC (rev 1237) +++ trunk/assuan/README.1st 2007-07-16 17:26:09 UTC (rev 1238) @@ -30,7 +30,8 @@ * assuan-io.c ** _assuan_simple_read() and _assuan_simple_write() must always use read()/write() (which actually translates to _gpgme_io_read() and - _gpgme_io_write()). + _gpgme_io_write()). _assuan_close must always() use close() (which + translates to _gpgme_io_close()). Copyright 2004, 2007 g10 Code GmbH Modified: trunk/assuan/assuan-socket.c =================================================================== --- trunk/assuan/assuan-socket.c 2007-07-13 14:47:07 UTC (rev 1237) +++ trunk/assuan/assuan-socket.c 2007-07-16 17:26:09 UTC (rev 1238) @@ -45,13 +45,13 @@ int _assuan_close (int fd) { -#ifndef HAVE_W32_SYSTEM - return close (fd); -#else +#if defined (HAVE_W32_SYSTEM) && !defined(_ASSUAN_IN_GPGME_BUILD_ASSUAN) int rc = closesocket (fd); if (rc && WSAGetLastError () == WSAENOTSOCK) rc = CloseHandle (fd); return rc; +#else + return close (fd); #endif } Modified: trunk/assuan/assuan.h =================================================================== --- trunk/assuan/assuan.h 2007-07-13 14:47:07 UTC (rev 1237) +++ trunk/assuan/assuan.h 2007-07-16 17:26:09 UTC (rev 1238) @@ -63,11 +63,13 @@ #ifdef _ASSUAN_IN_GPGME_BUILD_ASSUAN #include +int _gpgme_io_close (int fd); int _gpgme_io_read (int fd, void *buffer, size_t count); int _gpgme_io_write (int fd, const void *buffer, size_t count); int _gpgme_io_sendmsg (int sock, const struct msghdr *msg, int flags); int _gpgme_io_recvmsg (int sock, struct msghdr *msg, int flags); +#define close _gpgme_io_close #define read _gpgme_io_read #define write _gpgme_io_write #define waitpid _gpgme_ath_waitpid Modified: trunk/gpgme/ChangeLog =================================================================== --- trunk/gpgme/ChangeLog 2007-07-13 14:47:07 UTC (rev 1237) +++ trunk/gpgme/ChangeLog 2007-07-16 17:26:09 UTC (rev 1238) @@ -1,3 +1,17 @@ +2007-07-16 Marcus Brinkmann + + * w32-io.c (struct reader_context_s, struct writer_context_s): New + members REFCOUNT. + (create_reader, create_writer): Initialize C->refcount to 1. + (destroy_reader, destroy_writer): Only destroy if C->refcount + drops to 0. + (find_reader, find_writer, kill_reader, kill_writer): Beautify. + * priv-io.h (_gpgme_io_dup): New prototype. + * posix-io.c (_gpgme_io_dup): New function. + * w32-io.c (_gpgme_io_dup): Likewise. + * w32-glib-io.c (_gpgme_io_dup): Likewise. + * engine-gpgsm.c (start): Reverting to version 2007-07-10. + 2007-07-13 Marcus Brinkmann * data-user.c (user_read, user_write, user_seek): Set errno and Modified: trunk/gpgme/engine-gpgsm.c =================================================================== --- trunk/gpgme/engine-gpgsm.c 2007-07-13 14:47:07 UTC (rev 1237) +++ trunk/gpgme/engine-gpgsm.c 2007-07-16 17:26:09 UTC (rev 1238) @@ -283,6 +283,8 @@ if (!gpgsm) return gpg_error (GPG_ERR_INV_VALUE); + if (gpgsm->status_cb.fd != -1) + _gpgme_io_close (gpgsm->status_cb.fd); if (gpgsm->input_cb.fd != -1) _gpgme_io_close (gpgsm->input_cb.fd); if (gpgsm->output_cb.fd != -1) @@ -842,6 +844,7 @@ gpgsm->colon.any = 0; err = gpgsm->colon.fnc (gpgsm->colon.fnc_value, NULL); } + _gpgme_io_close (gpgsm->status_cb.fd); DEBUG2 ("fd %d: OK line - final status: %s\n", fd, err? gpg_strerror (err):"ok"); return err; @@ -982,15 +985,20 @@ if (nfds < 1) return gpg_error (GPG_ERR_GENERAL); /* FIXME */ - /* We used to duplicate the file descriptor so that we do not - disturb Assuan. But this gets in the way of the Handle-to-Thread - mapping in w32-io.c, so instead we just share the file descriptor - but leave it to Assuan to close it. */ - gpgsm->status_cb.fd = fdlist[0]; + /* We duplicate the file descriptor, so we can close it without + disturbing assuan. Alternatively, we could special case + status_fd and register/unregister it manually as needed, but this + increases code duplication and is more complicated as we can not + use the close notifications etc. */ + gpgsm->status_cb.fd = _gpgme_io_dup (fdlist[0]); + if (gpgsm->status_cb.fd < 0) + return gpg_error_from_syserror (); + if (_gpgme_io_set_close_notify (gpgsm->status_cb.fd, close_notify_handler, gpgsm)) { + _gpgme_io_close (gpgsm->status_cb.fd); gpgsm->status_cb.fd = -1; return gpg_error (GPG_ERR_GENERAL); } Modified: trunk/gpgme/posix-io.c =================================================================== --- trunk/gpgme/posix-io.c 2007-07-13 14:47:07 UTC (rev 1237) +++ trunk/gpgme/posix-io.c 2007-07-16 17:26:09 UTC (rev 1238) @@ -494,3 +494,10 @@ errno = saved_errno; return nwritten; } + + +int +_gpgme_io_dup (int fd) +{ + return dup (fd); +} Modified: trunk/gpgme/priv-io.h =================================================================== --- trunk/gpgme/priv-io.h 2007-07-13 14:47:07 UTC (rev 1237) +++ trunk/gpgme/priv-io.h 2007-07-16 17:26:09 UTC (rev 1238) @@ -65,4 +65,7 @@ line that the child process expects. */ int _gpgme_io_fd2str (char *buf, int buflen, int fd); +/* Like dup(). */ +int _gpgme_io_dup (int fd); + #endif /* IO_H */ Modified: trunk/gpgme/w32-glib-io.c =================================================================== --- trunk/gpgme/w32-glib-io.c 2007-07-13 14:47:07 UTC (rev 1237) +++ trunk/gpgme/w32-glib-io.c 2007-07-16 17:26:09 UTC (rev 1238) @@ -661,3 +661,10 @@ free (pollfds_map); return count; } + + +int +_gpgme_io_dup (int fd) +{ + return _dup (fd); +} Modified: trunk/gpgme/w32-io.c =================================================================== --- trunk/gpgme/w32-io.c 2007-07-13 14:47:07 UTC (rev 1237) +++ trunk/gpgme/w32-io.c 2007-07-16 17:26:09 UTC (rev 1238) @@ -68,6 +68,8 @@ struct reader_context_s { HANDLE file_hd; HANDLE thread_hd; + int refcount; + DECLARE_LOCK (mutex); int stop_me; @@ -96,6 +98,8 @@ struct writer_context_s { HANDLE file_hd; HANDLE thread_hd; + int refcount; + DECLARE_LOCK (mutex); int stop_me; @@ -248,6 +252,7 @@ return NULL; c->file_hd = fd; + c->refcount = 1; c->have_data_ev = CreateEvent (&sec_attr, TRUE, FALSE, NULL); c->have_space_ev = CreateEvent (&sec_attr, FALSE, TRUE, NULL); c->stopped = CreateEvent (&sec_attr, TRUE, FALSE, NULL); @@ -294,6 +299,12 @@ destroy_reader (struct reader_context_s *c) { LOCK (c->mutex); + c->refcount--; + if (c->refcount != 0) + { + UNLOCK (c->mutex); + return; + } c->stop_me = 1; if (c->have_space_ev) SetEvent (c->have_space_ev); @@ -315,56 +326,62 @@ } -/* - * Find a reader context or create a new one - * Note that the reader context will last until a io_close. - */ +/* Find a reader context or create a new one. Note that the reader + context will last until a _gpgme_io_close. */ static struct reader_context_s * find_reader (int fd, int start_it) { - int i; + struct reader_context_s *rd = NULL; + int i; - for (i=0; i < reader_table_size ; i++ ) { - if ( reader_table[i].used && reader_table[i].fd == fd ) - return reader_table[i].context; + LOCK (reader_table_lock); + for (i = 0; i < reader_table_size; i++) + if (reader_table[i].used && reader_table[i].fd == fd) + rd = reader_table[i].context; + + if (rd || !start_it) + { + UNLOCK (reader_table_lock); + return rd; } - if (!start_it) - return NULL; - LOCK (reader_table_lock); - for (i=0; i < reader_table_size; i++ ) { - if (!reader_table[i].used) { - reader_table[i].fd = fd; - reader_table[i].context = create_reader (fd_to_handle (fd)); - reader_table[i].used = 1; - UNLOCK (reader_table_lock); - return reader_table[i].context; - } + for (i = 0; i < reader_table_size; i++) + if (!reader_table[i].used) + break; + + if (i != reader_table_size) + { + rd = create_reader (fd_to_handle (fd)); + reader_table[i].fd = fd; + reader_table[i].context = rd; + reader_table[i].used = 1; } - UNLOCK (reader_table_lock); - return NULL; + + UNLOCK (reader_table_lock); + return rd; } static void kill_reader (int fd) { - int i; + int i; - LOCK (reader_table_lock); - for (i=0; i < reader_table_size; i++ ) { - if (reader_table[i].used && reader_table[i].fd == fd ) { - destroy_reader (reader_table[i].context); - reader_table[i].context = NULL; - reader_table[i].used = 0; - break; - } + LOCK (reader_table_lock); + for (i = 0; i < reader_table_size; i++) + { + if (reader_table[i].used && reader_table[i].fd == fd) + { + destroy_reader (reader_table[i].context); + reader_table[i].context = NULL; + reader_table[i].used = 0; + break; + } } - UNLOCK (reader_table_lock); + UNLOCK (reader_table_lock); } - int _gpgme_io_read ( int fd, void *buffer, size_t count ) { @@ -506,6 +523,7 @@ return NULL; c->file_hd = fd; + c->refcount = 1; c->have_data = CreateEvent (&sec_attr, TRUE, FALSE, NULL); c->is_empty = CreateEvent (&sec_attr, TRUE, TRUE, NULL); c->stopped = CreateEvent (&sec_attr, TRUE, FALSE, NULL); @@ -552,6 +570,12 @@ destroy_writer (struct writer_context_s *c) { LOCK (c->mutex); + ctx->refcount--; + if (ctx->refcount != 0) + { + UNLOCK (ctx->mutex); + return; + } c->stop_me = 1; if (c->have_data) SetEvent (c->have_data); @@ -580,45 +604,54 @@ static struct writer_context_s * find_writer (int fd, int start_it) { - int i; + struct writer_context_s *wt = NULL; + int i; - for (i=0; i < writer_table_size ; i++ ) { - if ( writer_table[i].used && writer_table[i].fd == fd ) - return writer_table[i].context; + LOCK (writer_table_lock); + for (i = 0; i < writer_table_size; i++) + if (writer_table[i].used && writer_table[i].fd == fd) + wt = writer_table[i].context; + + if (wt || !start_it) + { + UNLOCK (writer_table_lock); + return wt; } - if (!start_it) - return NULL; - LOCK (writer_table_lock); - for (i=0; i < writer_table_size; i++ ) { - if (!writer_table[i].used) { - writer_table[i].fd = fd; - writer_table[i].context = create_writer (fd_to_handle (fd)); - writer_table[i].used = 1; - UNLOCK (writer_table_lock); - return writer_table[i].context; - } + for (i = 0; i < writer_table_size; i++) + if (!writer_table[i].used) + break; + + if (i != writer_table_size) + { + wt = create_writer (fd_to_handle (fd)); + writer_table[i].fd = fd; + writer_table[i].context = wt; + writer_table[i].used = 1; } - UNLOCK (writer_table_lock); - return NULL; + + UNLOCK (writer_table_lock); + return wt; } static void kill_writer (int fd) { - int i; + int i; - LOCK (writer_table_lock); - for (i=0; i < writer_table_size; i++ ) { - if (writer_table[i].used && writer_table[i].fd == fd ) { - destroy_writer (writer_table[i].context); - writer_table[i].context = NULL; - writer_table[i].used = 0; - break; - } + LOCK (writer_table_lock); + for (i = 0; i < writer_table_size; i++) + { + if (writer_table[i].used && writer_table[i].fd == fd) + { + destroy_writer (writer_table[i].context); + writer_table[i].context = NULL; + writer_table[i].used = 0; + break; + } } - UNLOCK (writer_table_lock); + UNLOCK (writer_table_lock); } @@ -1146,6 +1179,67 @@ return snprintf (buf, buflen, "%d", fd); } + +int +_gpgme_io_dup (int fd) +{ + HANDLE handle = fd_to_handle (fd); + HANDLE new_handle = fd_to_handle (fd); + int i; + struct reader_context_s *rd_ctx; + struct writer_context_s *wt_ctx; + + if (!DuplicateHandle (GetCurrentProcess(), handle, + GetCurrentProcess(), &new_handle, + 0, FALSE, DUPLICATE_SAME_ACCESS)) + { + DEBUG1 ("DuplicateHandle failed: ec=%d\n", (int) GetLastError ()); + /* FIXME: Translate error code. */ + errno = EIO; + return -1; + } + + rd_ctx = find_reader (fd, 1); + if (rd_ctx) + { + /* No need for locking, as the only races are against the reader + thread itself, which doesn't touch refcount. */ + rd_ctx->refcount++; + + LOCK (reader_table_lock); + for (i = 0; i < reader_table_size; i++) + if (!reader_table[i].used) + break; + /* FIXME. */ + assert (i != reader_table_size); + reader_table[i].fd = handle_to_fd (new_handle); + reader_table[i].context = rd_ctx; + reader_table[i].used = 1; + UNLOCK (reader_table_lock); + } + + wt_ctx = find_writer (fd, 1); + if (wt_ctx) + { + /* No need for locking, as the only races are against the writer + thread itself, which doesn't touch refcount. */ + wt_ctx->refcount++; + + LOCK (writer_table_lock); + for (i = 0; i < writer_table_size; i++) + if (!writer_table[i].used) + break; + /* FIXME. */ + assert (i != writer_table_size); + writer_table[i].fd = handle_to_fd (new_handle); + writer_table[i].context = wt_ctx; + writer_table[i].used = 1; + UNLOCK (writer_table_lock); + } + + return handle_to_fd (new_handle); +} + /* The following interface is only useful for GPGME Glib. */ From cvs at cvs.gnupg.org Mon Jul 16 19:28:18 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 16 Jul 2007 19:28:18 +0200 Subject: [svn] gpgme - r1239 - trunk/gpgme Message-ID: Author: marcus Date: 2007-07-16 19:27:49 +0200 (Mon, 16 Jul 2007) New Revision: 1239 Modified: trunk/gpgme/ChangeLog trunk/gpgme/engine-gpgsm.c Log: 2007-07-16 Marcus Brinkmann * engine-gpgsm.c (status_handler): Do not send BYE here. Modified: trunk/gpgme/ChangeLog =================================================================== --- trunk/gpgme/ChangeLog 2007-07-16 17:26:09 UTC (rev 1238) +++ trunk/gpgme/ChangeLog 2007-07-16 17:27:49 UTC (rev 1239) @@ -1,5 +1,7 @@ 2007-07-16 Marcus Brinkmann + * engine-gpgsm.c (status_handler): Do not send BYE here. + * w32-io.c (struct reader_context_s, struct writer_context_s): New members REFCOUNT. (create_reader, create_writer): Initialize C->refcount to 1. @@ -11,7 +13,7 @@ * w32-io.c (_gpgme_io_dup): Likewise. * w32-glib-io.c (_gpgme_io_dup): Likewise. * engine-gpgsm.c (start): Reverting to version 2007-07-10. - + 2007-07-13 Marcus Brinkmann * data-user.c (user_read, user_write, user_seek): Set errno and Modified: trunk/gpgme/engine-gpgsm.c =================================================================== --- trunk/gpgme/engine-gpgsm.c 2007-07-16 17:26:09 UTC (rev 1238) +++ trunk/gpgme/engine-gpgsm.c 2007-07-16 17:27:49 UTC (rev 1239) @@ -807,8 +807,10 @@ assuan_err = assuan_read_line (gpgsm->assuan_ctx, &line, &linelen); if (assuan_err) { +#if 0 /* Try our best to terminate the connection friendly. */ - /* assuan_write_line (gpgsm->assuan_ctx, "BYE"); */ + assuan_write_line (gpgsm->assuan_ctx, "BYE"); +#endif err = map_assuan_error (assuan_err); DEBUG3 ("fd %d: error from assuan (%d) getting status line : %s \n", fd, assuan_err, gpg_strerror (err)); @@ -823,8 +825,10 @@ err = gpg_error (GPG_ERR_GENERAL); DEBUG2 ("fd %d: ERR line - mapped to: %s\n", fd, err? gpg_strerror (err):"ok"); +#if 0 /* Try our best to terminate the connection friendly. */ assuan_write_line (gpgsm->assuan_ctx, "BYE"); +#endif } else if (linelen >= 2 && line[0] == 'O' && line[1] == 'K' From cvs at cvs.gnupg.org Mon Jul 16 19:47:30 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 16 Jul 2007 19:47:30 +0200 Subject: [svn] gpgme - r1240 - trunk/gpgme Message-ID: Author: marcus Date: 2007-07-16 19:47:00 +0200 (Mon, 16 Jul 2007) New Revision: 1240 Modified: trunk/gpgme/w32-io.c Log: Fixed last change. Modified: trunk/gpgme/w32-io.c =================================================================== --- trunk/gpgme/w32-io.c 2007-07-16 17:27:49 UTC (rev 1239) +++ trunk/gpgme/w32-io.c 2007-07-16 17:47:00 UTC (rev 1240) @@ -570,10 +570,10 @@ destroy_writer (struct writer_context_s *c) { LOCK (c->mutex); - ctx->refcount--; - if (ctx->refcount != 0) + c->refcount--; + if (c->refcount != 0) { - UNLOCK (ctx->mutex); + UNLOCK (c->mutex); return; } c->stop_me = 1; From cvs at cvs.gnupg.org Tue Jul 17 14:43:12 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue, 17 Jul 2007 14:43:12 +0200 Subject: [svn] gpgme - r1242 - trunk Message-ID: Author: marcus Date: 2007-07-17 14:42:42 +0200 (Tue, 17 Jul 2007) New Revision: 1242 Modified: trunk/TODO Log: Add item for tracepoints. Modified: trunk/TODO =================================================================== --- trunk/TODO 2007-07-17 12:36:04 UTC (rev 1241) +++ trunk/TODO 2007-07-17 12:42:42 UTC (rev 1242) @@ -149,6 +149,18 @@ ** Test reading key signatures. * Debug +** Tracepoints should be added at: Every public interface enter/leave, + before and in every callback, at major decision points, at every + internal data point which might easily be observed by the outside + (system handles). We also trace handles and I/O support threads in + the w32 implementation because that's fragile code. + Files left to do: + data-fd.c data-mem.c data-stream.c data-user.c debug.c rungpg.c + engine.c engine-gpgsm.c funopen.c w32-glib-io.c wait.c + wait-global.c wait-private.c wait-user.c op-support.c decrypt.c + decrypt-verify.c delete.c edit.c encrypt.c encrypt-sign.c export.c + genkey.c import.c key.c keylist.c passphrase.c progress.c signers.c + sig-notation.c trust-item.c trustlist.c verify.c ** Handle malloc and vasprintf errors. But decide first if they should be ignored (and logged with 255?!), or really be assertions. ! From cvs at cvs.gnupg.org Tue Jul 17 20:12:15 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 17 Jul 2007 20:12:15 +0200 Subject: [svn] GnuPG - r4544 - in trunk: . agent doc g10 sm tools Message-ID: Author: wk Date: 2007-07-17 20:11:24 +0200 (Tue, 17 Jul 2007) New Revision: 4544 Modified: trunk/NEWS trunk/TODO trunk/agent/call-pinentry.c trunk/doc/ChangeLog trunk/doc/gpgsm.texi trunk/g10/ChangeLog trunk/g10/card-util.c trunk/g10/gpg.c trunk/sm/ChangeLog trunk/sm/gpgsm.c trunk/sm/sign.c trunk/tools/ChangeLog trunk/tools/gpgconf-comp.c Log: Typo fixes. Made --default-key work for gpgsm Add --default-key and --encrypt-to to gpgconf. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2007-07-16 14:33:34 UTC (rev 4543) +++ trunk/NEWS 2007-07-17 18:11:24 UTC (rev 4544) @@ -1,7 +1,11 @@ Noteworthy changes in version 2.0.6 ------------------------------------------------ + * gpgsm does now grok --default-key. + + * gpgconf is now aware of --default-key and --encrypt-to. + Noteworthy changes in version 2.0.5 (2007-07-05) ------------------------------------------------ Modified: trunk/TODO =================================================================== --- trunk/TODO 2007-07-16 14:33:34 UTC (rev 4543) +++ trunk/TODO 2007-07-17 18:11:24 UTC (rev 4544) @@ -59,7 +59,7 @@ * scd ** Application context vs. reader slot - We have 2 concurrent method of tracking whether a read is in use: + We have 2 concurrent method of tracking whether a reader is in use: Using the session_list in command.c and the lock_table in app.c. IT would be better to do this just at one place. First we need to see how we can support cards with multiple applications. Modified: trunk/agent/call-pinentry.c =================================================================== --- trunk/agent/call-pinentry.c 2007-07-16 14:33:34 UTC (rev 4543) +++ trunk/agent/call-pinentry.c 2007-07-17 18:11:24 UTC (rev 4544) @@ -1,4 +1,4 @@ -/* call-pinnetry.c - fork of the pinentry to query stuff from the user +/* call-pinentry.c - fork of the pinentry to query stuff from the user * Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. * * This file is part of GnuPG. Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2007-07-16 14:33:34 UTC (rev 4543) +++ trunk/doc/ChangeLog 2007-07-17 18:11:24 UTC (rev 4544) @@ -1,3 +1,7 @@ +2007-07-17 Werner Koch + + * gpgsm.texi (Input and Output): Document --default-key. + 2007-07-04 Werner Koch * gpl.texi: Updated to GPLv3. Modified: trunk/doc/gpgsm.texi =================================================================== --- trunk/doc/gpgsm.texi 2007-07-16 14:33:34 UTC (rev 4543) +++ trunk/doc/gpgsm.texi 2007-07-17 18:11:24 UTC (rev 4544) @@ -457,6 +457,14 @@ passphrase encoded to the most commonly used encodings. + at item --default-key @var{user_id} + at opindex default-key +Use @var{user_id} as the standard key for signing. This key is used if +no other key has been defined as a signing key. Note, that the first + at option{--local-users} option also sets this key if it has not yet been +set; however @option{--default-key} always overrides this. + + @item --local-user @var{user_id} @item -u @var{user_id} @opindex local-user Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2007-07-16 14:33:34 UTC (rev 4543) +++ trunk/g10/ChangeLog 2007-07-17 18:11:24 UTC (rev 4544) @@ -1,3 +1,9 @@ +2007-07-17 Werner Koch + + * gpg.c (gpgconf_list): Declare --encrypt-to and --default-key. + + * card-util.c (get_manufacturer): Add the unmanaged S/N range. + 2007-07-12 Werner Koch * gpg.c (main): Use translate_sys2libc_fd_int when passing an int Modified: trunk/g10/card-util.c =================================================================== --- trunk/g10/card-util.c 2007-07-16 14:33:34 UTC (rev 4543) +++ trunk/g10/card-util.c 2007-07-17 18:11:24 UTC (rev 4544) @@ -153,12 +153,15 @@ /* Note: Make sure that there is no colon or linefeed in the string. */ switch (no) { - case 0: - case 0xffff: return "test card"; case 0x0001: return "PPC Card Systems"; case 0x0002: return "Prism"; case 0x0003: return "OpenFortress"; - default: return "unknown"; + /* 0x00000 and 0xFFFF are defined as test cards per spec, + 0xFFF00 to 0xFFFE are assigned for use with randomly created + serial numbers. */ + case 0x0000: + case 0xffff: return "test card"; + default: return (no & 0xff00) == 0xff00? "unmanaged S/N range":"unknown"; } } Modified: trunk/g10/gpg.c =================================================================== --- trunk/g10/gpg.c 2007-07-16 14:33:34 UTC (rev 4543) +++ trunk/g10/gpg.c 2007-07-17 18:11:24 UTC (rev 4544) @@ -1467,6 +1467,8 @@ printf ("quiet:%lu:\n", GC_OPT_FLAG_NONE); printf ("keyserver:%lu:\n", GC_OPT_FLAG_NONE); printf ("reader-port:%lu:\n", GC_OPT_FLAG_NONE); + printf ("default-key:%lu:\n", GC_OPT_FLAG_NONE); + printf ("encrypt-to:%lu:\n", GC_OPT_FLAG_NONE); xfree (configfile_esc); } Modified: trunk/sm/ChangeLog =================================================================== --- trunk/sm/ChangeLog 2007-07-16 14:33:34 UTC (rev 4543) +++ trunk/sm/ChangeLog 2007-07-17 18:11:24 UTC (rev 4544) @@ -1,3 +1,8 @@ +2007-07-17 Werner Koch + + * gpgsm.c (main): Implement --default-key. + (main) : Declare --default-key and --encrypt-to. + 2007-07-16 Werner Koch * server.c (cmd_message): Use gnupg_fd_t to avoid dependecy on Modified: trunk/sm/gpgsm.c =================================================================== --- trunk/sm/gpgsm.c 2007-07-16 14:33:34 UTC (rev 4543) +++ trunk/sm/gpgsm.c 2007-07-17 18:11:24 UTC (rev 4544) @@ -1101,8 +1101,11 @@ case oNoGreeting: nogreeting = 1; break; case oDefaultKey: - /* fixme:opt.def_secret_key = pargs.r.ret_str;*/ - log_info ("WARNING: --default-key has not yet been implemented\n"); + if (*pargs.r.ret_str) + { + xfree (opt.local_user); + opt.local_user = xstrdup (pargs.r.ret_str); + } break; case oDefRecipient: if (*pargs.r.ret_str) @@ -1139,9 +1142,9 @@ case oTextmodeShort: /*fixme:opt.textmode = 2;*/ break; case oTextmode: /*fixme:opt.textmode=1;*/ break; - case oUser: /* store the local users, the first one is the default */ + case oUser: /* Store the local users, the first one is the default */ if (!opt.local_user) - opt.local_user = pargs.r.ret_str; + opt.local_user = xstrdup (pargs.r.ret_str); add_to_strlist (&locusr, pargs.r.ret_str); break; @@ -1424,6 +1427,10 @@ GC_OPT_FLAG_DEFAULT ); printf ("p12-charset:%lu:\n", GC_OPT_FLAG_DEFAULT ); + printf ("default-key:%lu:\n", + GC_OPT_FLAG_DEFAULT ); + printf ("encrypt-to:%lu:\n", + GC_OPT_FLAG_DEFAULT ); } break; Modified: trunk/sm/sign.c =================================================================== --- trunk/sm/sign.c 2007-07-16 14:33:34 UTC (rev 4543) +++ trunk/sm/sign.c 2007-07-17 18:11:24 UTC (rev 4544) @@ -122,8 +122,9 @@ } -/* Get the default certificate which is defined as the first cabable - of signing our keyDB returns and has a secret key available. */ +/* Get the default certificate which is defined as the first + certificate capable of signing returned by the keyDB and has a + secret key available. */ int gpgsm_get_default_cert (ctrl_t ctrl, ksba_cert_t *r_cert) { @@ -364,7 +365,7 @@ goto leave; } - /* If no list of signers is given, use a default one. */ + /* If no list of signers is given, use the default certificate. */ if (!signerlist) { ksba_cert_t cert = get_default_signer (ctrl); @@ -376,8 +377,7 @@ } /* Although we don't check for ambigious specification we will - check that the signer's certificate is is usable and - valid. */ + check that the signer's certificate is usable and valid. */ rc = gpgsm_cert_use_sign_p (cert); if (!rc) rc = gpgsm_validate_chain (ctrl, cert, NULL, 0, NULL, 0); Modified: trunk/tools/ChangeLog =================================================================== --- trunk/tools/ChangeLog 2007-07-16 14:33:34 UTC (rev 4543) +++ trunk/tools/ChangeLog 2007-07-17 18:11:24 UTC (rev 4544) @@ -1,3 +1,8 @@ +2007-07-17 Werner Koch + + * gpgconf-comp.c: Add --encrypt-to and --default-key to gpg and + gpgsm. + 2007-07-16 Marcus Brinkmann * gpg-connect-agent.c (main): Bail out if write fails. Modified: trunk/tools/gpgconf-comp.c =================================================================== --- trunk/tools/gpgconf-comp.c 2007-07-16 14:33:34 UTC (rev 4543) +++ trunk/tools/gpgconf-comp.c 2007-07-17 18:11:24 UTC (rev 4544) @@ -616,6 +616,12 @@ { "Configuration", GC_OPT_FLAG_GROUP, GC_LEVEL_EXPERT, "gnupg", N_("Options controlling the configuration") }, + { "default-key", GC_OPT_FLAG_NONE, GC_LEVEL_BASIC, + "gnupg", N_("|NAME|use NAME as default secret key"), + GC_ARG_TYPE_STRING, GC_BACKEND_GPG }, + { "encrypt-to", GC_OPT_FLAG_NONE, GC_LEVEL_BASIC, + "gnupg", N_("|NAME|encrypt to user ID NAME as well"), + GC_ARG_TYPE_STRING, GC_BACKEND_GPG }, { "options", GC_OPT_FLAG_NONE, GC_LEVEL_EXPERT, "gnupg", "|FILE|read options from FILE", GC_ARG_TYPE_PATHNAME, GC_BACKEND_GPG }, @@ -672,6 +678,12 @@ { "Configuration", GC_OPT_FLAG_GROUP, GC_LEVEL_EXPERT, "gnupg", N_("Options controlling the configuration") }, + { "default-key", GC_OPT_FLAG_NONE, GC_LEVEL_BASIC, + "gnupg", N_("|NAME|use NAME as default secret key"), + GC_ARG_TYPE_STRING, GC_BACKEND_GPGSM }, + { "encrypt-to", GC_OPT_FLAG_NONE, GC_LEVEL_BASIC, + "gnupg", N_("|NAME|encrypt to user ID NAME as well"), + GC_ARG_TYPE_STRING, GC_BACKEND_GPGSM }, { "options", GC_OPT_FLAG_NONE, GC_LEVEL_EXPERT, "gnupg", "|FILE|read options from FILE", GC_ARG_TYPE_PATHNAME, GC_BACKEND_GPGSM }, From cvs at cvs.gnupg.org Wed Jul 18 19:09:20 2007 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Wed, 18 Jul 2007 19:09:20 +0200 Subject: [svn] GnuPG - r4545 - branches/STABLE-BRANCH-1-4/g10 Message-ID: Author: dshaw Date: 2007-07-18 19:08:47 +0200 (Wed, 18 Jul 2007) New Revision: 4545 Modified: branches/STABLE-BRANCH-1-4/g10/ChangeLog branches/STABLE-BRANCH-1-4/g10/armor.c Log: * armor.c (is_armor_tag): New. Detect if an armor header matches 2440bis-21. (parse_header_line): Call it here, as bis-21 requires warning the user (but continuing to process the message) when seeing an unknown header. Modified: branches/STABLE-BRANCH-1-4/g10/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/g10/ChangeLog 2007-07-17 18:11:24 UTC (rev 4544) +++ branches/STABLE-BRANCH-1-4/g10/ChangeLog 2007-07-18 17:08:47 UTC (rev 4545) @@ -1,3 +1,11 @@ +2007-07-18 David Shaw + + * armor.c (is_armor_tag): New. Detect if an armor header matches + 2440bis-21. + (parse_header_line): Call it here, as bis-21 requires warning the + user (but continuing to process the message) when seeing an + unknown header. + 2007-07-09 Werner Koch * gpg.c: Better print an extra warning if Camellia has been Modified: branches/STABLE-BRANCH-1-4/g10/armor.c =================================================================== --- branches/STABLE-BRANCH-1-4/g10/armor.c 2007-07-17 18:11:24 UTC (rev 4544) +++ branches/STABLE-BRANCH-1-4/g10/armor.c 2007-07-18 17:08:47 UTC (rev 4545) @@ -1,6 +1,6 @@ /* armor.c - Armor flter - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - * 2006 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + * 2007 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -314,7 +314,19 @@ return found; } +/* Returns true if this is a valid armor tag as per RFC-2440bis-21. */ +static int +is_armor_tag(const char *line) +{ + if(strncmp(line,"Version",7)==0 + || strncmp(line,"Comment",7)==0 + || strncmp(line,"MessageID",9)==0 + || strncmp(line,"Hash",4)==0 + || strncmp(line,"Charset",7)==0) + return 1; + return 0; +} /**************** * Check whether this is a armor line. @@ -424,6 +436,18 @@ putc('\n', stderr); } + /* Section 6.2: OpenPGP should consider improperly formatted Armor + Headers to be corruption of the ASCII Armor. Unknown keys + should be reported to the user, but OpenPGP should continue to + process the message. */ + + if(!is_armor_tag(line)) + { + log_info(_("unknown armor header: ")); + print_string( stderr, line, len, 0 ); + putc('\n', stderr); + } + if( afx->in_cleartext ) { if( (hashes=parse_hash_header( line )) ) afx->hashes |= hashes; From cvs at cvs.gnupg.org Wed Jul 18 19:43:44 2007 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Wed, 18 Jul 2007 19:43:44 +0200 Subject: [svn] GnuPG - r4546 - branches/STABLE-BRANCH-1-4/checks Message-ID: Author: dshaw Date: 2007-07-18 19:43:14 +0200 (Wed, 18 Jul 2007) New Revision: 4546 Modified: branches/STABLE-BRANCH-1-4/checks/ChangeLog branches/STABLE-BRANCH-1-4/checks/defs.inc branches/STABLE-BRANCH-1-4/checks/sigs.test Log: * defs.inc (all_hash_algos): See "all_cipher_algos", below. * sigs.test: Use it here, and also test with >=160 bit hashes for DSA2. Modified: branches/STABLE-BRANCH-1-4/checks/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/checks/ChangeLog 2007-07-18 17:08:47 UTC (rev 4545) +++ branches/STABLE-BRANCH-1-4/checks/ChangeLog 2007-07-18 17:43:14 UTC (rev 4546) @@ -1,3 +1,10 @@ +2007-07-18 David Shaw + + * defs.inc (all_hash_algos): See "all_cipher_algos", below. + + * sigs.test: Use it here, and also test with >=160 bit hashes for + DSA2. + 2007-05-14 David Shaw * defs.inc (all_cipher_algos): New function to return all ciphers Modified: branches/STABLE-BRANCH-1-4/checks/defs.inc =================================================================== --- branches/STABLE-BRANCH-1-4/checks/defs.inc 2007-07-18 17:08:47 UTC (rev 4545) +++ branches/STABLE-BRANCH-1-4/checks/defs.inc 2007-07-18 17:43:14 UTC (rev 4546) @@ -134,6 +134,10 @@ ../g10/gpg --homedir . --version | grep "Cipher" | sed 's/^Cipher: //; s/,//g' } +all_hash_algos () { + ../g10/gpg --homedir . --version | grep "Hash" | sed 's/^Hash: //; s/,//g' +} + set -e pgmname=`basename $0` #trap cleanup SIGHUP SIGINT SIGQUIT Modified: branches/STABLE-BRANCH-1-4/checks/sigs.test =================================================================== --- branches/STABLE-BRANCH-1-4/checks/sigs.test 2007-07-18 17:08:47 UTC (rev 4545) +++ branches/STABLE-BRANCH-1-4/checks/sigs.test 2007-07-18 17:43:14 UTC (rev 4546) @@ -2,45 +2,17 @@ . $srcdir/defs.inc || exit 3 -#info Checking signatures for i in $plain_files $data_files; do echo "$usrpass1" | $GPG --passphrase-fd 0 -s -o x --yes $i $GPG -o y --yes x cmp $i y || error "$i: mismatch" done -# Using the DSA sig key - only 160 bit hashes -for da in ripemd160 sha1 ; do - for i in $plain_files; do - echo "$usrpass1" | $GPG --passphrase-fd 0 --digest-algo $da \ - -s -o x --yes $i - $GPG -o y --yes x - cmp $i y || error "$i: mismatch" - # process only the first one - break - done -done +for da in `all_hash_algos` ; do + echo_n "$da " -# TODO: add the new SHAs here once we allow them to be used in new -# documents. - -if have_pubkey_algo "RSA"; then - # Using the RSA sig key - all hashes - hash_algo_list="ripemd160 sha1 md5" - if have_hash_algo "SHA224"; then - hash_algo_list="$hash_algo_list sha224" - fi - if have_hash_algo "SHA256"; then - hash_algo_list="$hash_algo_list sha256" - fi - if have_hash_algo "SHA384"; then - hash_algo_list="$hash_algo_list sha384" - fi - if have_hash_algo "SHA512"; then - hash_algo_list="$hash_algo_list sha512" - fi - - for da in $hash_algo_list ; do + # RSA key, so any hash is okay + if have_pubkey_algo "RSA"; then for i in $plain_files; do $GPG -u $usrname3 --digest-algo $da -s -o x --yes $i $GPG -o y --yes x @@ -48,5 +20,18 @@ # process only the first one break done - done -fi + fi + + # Using the DSA sig key - only 160 bit or larger hashes + if test $da != "MD5"; then + for i in $plain_files; do + echo "$usrpass1" | $GPG --passphrase-fd 0 --digest-algo $da \ + -s -o x --yes $i + $GPG -o y --yes x + cmp $i y || error "$i: mismatch" + # process only the first one + break + done + fi +done +echo_n "| " From cvs at cvs.gnupg.org Wed Jul 18 21:36:54 2007 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Wed, 18 Jul 2007 21:36:54 +0200 Subject: [svn] GnuPG - r4547 - branches/STABLE-BRANCH-1-4 Message-ID: Author: dshaw Date: 2007-07-18 21:36:24 +0200 (Wed, 18 Jul 2007) New Revision: 4547 Modified: branches/STABLE-BRANCH-1-4/ChangeLog branches/STABLE-BRANCH-1-4/configure.ac Log: * configure.ac: It seems that AM_GNU_GETTEXT doesn't like being run conditionally and it confuses the includes when doing later type checks. This is bug#810. Modified: branches/STABLE-BRANCH-1-4/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/ChangeLog 2007-07-18 17:43:14 UTC (rev 4546) +++ branches/STABLE-BRANCH-1-4/ChangeLog 2007-07-18 19:36:24 UTC (rev 4547) @@ -1,3 +1,9 @@ +2007-07-18 David Shaw + + * configure.ac: It seems that AM_GNU_GETTEXT doesn't like being + run conditionally and it confuses the includes when doing later + type checks. This is bug#810. + 2007-07-08 David Shaw * configure.ac: AM_PROG_CC_C_O is desired by automake 1.10 to do Modified: branches/STABLE-BRANCH-1-4/configure.ac =================================================================== --- branches/STABLE-BRANCH-1-4/configure.ac 2007-07-18 17:43:14 UTC (rev 4546) +++ branches/STABLE-BRANCH-1-4/configure.ac 2007-07-18 19:36:24 UTC (rev 4547) @@ -827,17 +827,14 @@ dnl Checks for libraries. -AM_GNU_GETTEXT_VERSION(0.14.1) if test "$try_gettext" = yes; then - AM_GNU_GETTEXT(,[need-ngettext]) - # gettext requires some extra checks. These really should be part of # the basic AM_GNU_GETTEXT macro. TODO: move other gettext-specific # function checks to here. AC_CHECK_FUNCS(strchr) else - USE_NLS=no + enable_nls=no USE_INCLUDED_LIBINTL=no BUILD_INCLUDED_LIBINTL=no AC_SUBST(USE_NLS) @@ -846,6 +843,9 @@ AM_PO_SUBDIRS fi +AM_GNU_GETTEXT_VERSION(0.14.1) +AM_GNU_GETTEXT(,[need-ngettext]) + if test "$try_extensions" = yes || test x"$card_support" = xyes ; then if test "$need_dlopen" = yes; then _dl_save_libs=$LIBS From cvs at cvs.gnupg.org Thu Jul 19 14:30:07 2007 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Thu, 19 Jul 2007 14:30:07 +0200 Subject: [svn] GnuPG - r4548 - branches/STABLE-BRANCH-1-4/g10 Message-ID: Author: dshaw Date: 2007-07-19 14:29:22 +0200 (Thu, 19 Jul 2007) New Revision: 4548 Modified: branches/STABLE-BRANCH-1-4/g10/ChangeLog branches/STABLE-BRANCH-1-4/g10/armor.c Log: * armor.c (parse_header_line): Improve test so that the header test only allows "Hash" in the signed data section. Modified: branches/STABLE-BRANCH-1-4/g10/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/g10/ChangeLog 2007-07-18 19:36:24 UTC (rev 4547) +++ branches/STABLE-BRANCH-1-4/g10/ChangeLog 2007-07-19 12:29:22 UTC (rev 4548) @@ -1,3 +1,8 @@ +2007-07-19 David Shaw + + * armor.c (parse_header_line): Improve test so that the header + test only allows "Hash" in the signed data section. + 2007-07-18 David Shaw * armor.c (is_armor_tag): New. Detect if an armor header matches Modified: branches/STABLE-BRANCH-1-4/g10/armor.c =================================================================== --- branches/STABLE-BRANCH-1-4/g10/armor.c 2007-07-18 19:36:24 UTC (rev 4547) +++ branches/STABLE-BRANCH-1-4/g10/armor.c 2007-07-19 12:29:22 UTC (rev 4548) @@ -436,28 +436,32 @@ putc('\n', stderr); } - /* Section 6.2: OpenPGP should consider improperly formatted Armor - Headers to be corruption of the ASCII Armor. Unknown keys - should be reported to the user, but OpenPGP should continue to - process the message. */ + if( afx->in_cleartext ) + { + if( (hashes=parse_hash_header( line )) ) + afx->hashes |= hashes; + else if( strlen(line) > 15 && !memcmp( line, "NotDashEscaped:", 15 ) ) + afx->not_dash_escaped = 1; + else + { + log_error(_("invalid clearsig header\n")); + return -1; + } + } + else if(!is_armor_tag(line)) + { + /* Section 6.2: "Unknown keys should be reported to the user, + but OpenPGP should continue to process the message." Note + that in a clearsigned message this applies to the signature + part (i.e. "BEGIN PGP SIGNATURE") and not the signed data + ("BEGIN PGP SIGNED MESSAGE"). The only key allowed in the + signed data section is "Hash". */ - if(!is_armor_tag(line)) - { log_info(_("unknown armor header: ")); print_string( stderr, line, len, 0 ); putc('\n', stderr); } - if( afx->in_cleartext ) { - if( (hashes=parse_hash_header( line )) ) - afx->hashes |= hashes; - else if( strlen(line) > 15 && !memcmp( line, "NotDashEscaped:", 15 ) ) - afx->not_dash_escaped = 1; - else { - log_error(_("invalid clearsig header\n")); - return -1; - } - } return 1; } From cvs at cvs.gnupg.org Thu Jul 19 14:46:38 2007 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Thu, 19 Jul 2007 14:46:38 +0200 Subject: [svn] GnuPG - r4549 - branches/STABLE-BRANCH-1-4/g10 Message-ID: Author: dshaw Date: 2007-07-19 14:46:08 +0200 (Thu, 19 Jul 2007) New Revision: 4549 Modified: branches/STABLE-BRANCH-1-4/g10/ChangeLog branches/STABLE-BRANCH-1-4/g10/gpg.c Log: * gpg.c (main): Fix typo. Noted by John Clizbe. Modified: branches/STABLE-BRANCH-1-4/g10/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/g10/ChangeLog 2007-07-19 12:29:22 UTC (rev 4548) +++ branches/STABLE-BRANCH-1-4/g10/ChangeLog 2007-07-19 12:46:08 UTC (rev 4549) @@ -1,5 +1,7 @@ 2007-07-19 David Shaw + * gpg.c (main): Fix typo. Noted by John Clizbe. + * armor.c (parse_header_line): Improve test so that the header test only allows "Hash" in the signed data section. Modified: branches/STABLE-BRANCH-1-4/g10/gpg.c =================================================================== --- branches/STABLE-BRANCH-1-4/g10/gpg.c 2007-07-19 12:29:22 UTC (rev 4548) +++ branches/STABLE-BRANCH-1-4/g10/gpg.c 2007-07-19 12:46:08 UTC (rev 4549) @@ -2850,7 +2850,7 @@ #ifdef USE_CAMELLIA /* We better also print a runtime warning if people build it with support for Camellia (which is not yet defiend by OpenPGP). */ - log_info ("WARNING: This version has been build with support for the " + log_info ("WARNING: This version has been built with support for the " "Camellia cipher.\n"); log_info (" It is for testing only and is NOT for production " "use!\n"); From cvs at cvs.gnupg.org Fri Jul 20 17:26:48 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Fri, 20 Jul 2007 17:26:48 +0200 Subject: [svn] w32pth - r9 - trunk Message-ID: Author: marcus Date: 2007-07-20 17:26:16 +0200 (Fri, 20 Jul 2007) New Revision: 9 Modified: trunk/ChangeLog trunk/README trunk/pth.h trunk/w32-pth.c Log: 2007-07-20 Marcus Brinkmann * pth.h (PTH_RWLOCK_RD, PTH_RWLOCK_RW): New symbols. (pth_rwlock_t): New type. * w32-pth.c (pth_rwlock_init, pth_rwlock_acquire, (pth_rwlock_release): New functions. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-07-05 18:53:18 UTC (rev 8) +++ trunk/ChangeLog 2007-07-20 15:26:16 UTC (rev 9) @@ -1,3 +1,10 @@ +2007-07-20 Marcus Brinkmann + + * pth.h (PTH_RWLOCK_RD, PTH_RWLOCK_RW): New symbols. + (pth_rwlock_t): New type. + * w32-pth.c (pth_rwlock_init, pth_rwlock_acquire, + (pth_rwlock_release): New functions. + 2007-07-05 Werner Koch Released 2.0.0 (first release). Modified: trunk/README =================================================================== --- trunk/README 2007-07-05 18:53:18 UTC (rev 8) +++ trunk/README 2007-07-20 15:26:16 UTC (rev 9) @@ -10,12 +10,13 @@ It is currently limited to what GnuPG 2.0 requires. - Missing stuff: PTH_MODE_STATIC is known but ignored. PTH_MODE_REUSE PTH_MODE_CHAIN + rwlock - currently just a mutex + as well as many more things. Modified: trunk/pth.h =================================================================== --- trunk/pth.h 2007-07-05 18:53:18 UTC (rev 8) +++ trunk/pth.h 2007-07-20 15:26:16 UTC (rev 9) @@ -74,7 +74,17 @@ /* Note: We can't do static initialization, thus we don't define the initializer PTH_MUTEX_INIT. */ +/* Read-write lock values. */ +enum + { + PTH_RWLOCK_RD, + PTH_RWLOCK_RW + }; +/* Note: We can't do static initialization, thus we don't define the + initializer PTH_RWLOCK_INIT. */ + + #define PTH_KEY_INIT (1<<0) @@ -179,7 +189,10 @@ /* The Mutex object. */ typedef W32_PTH_HANDLE_INTERNAL pth_mutex_t; +/* The read-write lock object. */ +typedef W32_PTH_HANDLE_INTERNAL pth_rwlock_t; + /* The Event object. */ struct pth_event_s; typedef struct pth_event_s *pth_event_t; @@ -224,7 +237,11 @@ int pth_mutex_acquire(pth_mutex_t *hd, int try_only, pth_event_t ev_extra); int pth_mutex_init (pth_mutex_t *hd); +int pth_rwlock_init (pth_rwlock_t *rwlock); +int pth_rwlock_acquire (pth_rwlock_t *rwlock, int op, int try, pth_event_t ev); +int pth_rwlock_release (pth_rwlock_t *rwlock); + pth_attr_t pth_attr_new (void); int pth_attr_destroy (pth_attr_t hd); int pth_attr_set (pth_attr_t hd, int field, ...); Modified: trunk/w32-pth.c =================================================================== --- trunk/w32-pth.c 2007-07-05 18:53:18 UTC (rev 8) +++ trunk/w32-pth.c 2007-07-20 15:26:16 UTC (rev 9) @@ -804,6 +804,29 @@ } +int +pth_rwlock_init (pth_rwlock_t *rwlock) +{ + /* FIXME */ + return pth_mutex_init (rwlock); +} + + +int +pth_rwlock_acquire (pth_rwlock_t *rwlock, int op, int try, pth_event_t ev) +{ + /* FIXME */ + return pth_mutex_acquire (rwlock, try, ev); +} + +int +pth_rwlock_release (pth_rwlock_t *rwlock) +{ + /* FIXME */ + return pth_mutex_release (rwlock); +} + + pth_attr_t pth_attr_new (void) { From cvs at cvs.gnupg.org Fri Jul 20 17:28:19 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Fri, 20 Jul 2007 17:28:19 +0200 Subject: [svn] dirmngr - r246 - trunk/src Message-ID: Author: marcus Date: 2007-07-20 17:27:48 +0200 (Fri, 20 Jul 2007) New Revision: 246 Modified: trunk/src/ChangeLog trunk/src/certcache.c Log: 2007-07-20 Marcus Brinkmann * certcache.c (cert_cache_lock): Do not initialize statically. (init_cache_lock): New function. (cert_cache_init): Call init_cache_lock. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2007-07-20 01:04:38 UTC (rev 245) +++ trunk/src/ChangeLog 2007-07-20 15:27:48 UTC (rev 246) @@ -1,5 +1,9 @@ 2007-07-20 Marcus Brinkmann + * certcache.c (cert_cache_lock): Do not initialize statically. + (init_cache_lock): New function. + (cert_cache_init): Call init_cache_lock. + * estream.h, estream.c, estream-printf.h, estream-printf.c: New files. * Makefile.am (dirmngr_SOURCES): Add estream.c, estream.h, Modified: trunk/src/certcache.c =================================================================== --- trunk/src/certcache.c 2007-07-20 01:04:38 UTC (rev 245) +++ trunk/src/certcache.c 2007-07-20 15:27:48 UTC (rev 246) @@ -1,5 +1,5 @@ /* certcache.c - Certificate caching - * Copyright (C) 2004, 2005 g10 Code GmbH + * Copyright (C) 2004, 2005, 2007 g10 Code GmbH * * This file is part of DirMngr. * @@ -66,9 +66,10 @@ /* This is the global cache_lock variable. In general looking is not needed but it would take extra efforts to make sure that no - indirect use of pth functions is done, so we simply lock it - always. */ -static pth_rwlock_t cert_cache_lock = PTH_RWLOCK_INIT; + indirect use of pth functions is done, so we simply lock it always. + Note: We can't use static initialization, as that is not available + through w32-pth. */ +static pth_rwlock_t cert_cache_lock; /* Flag to track whether the cache has been initialized. */ static int initialization_done; @@ -80,8 +81,16 @@ -/* Helper to do the cahce locking. */ +/* Helper to do the cache locking. */ static void +init_cache_lock (void) +{ + if (!pth_rwlock_init (&cert_cache_lock)) + log_fatal (_("can't initialize certificate cache lock: %s\n"), + strerror (errno)); +} + +static void acquire_cache_read_lock (void) { if (!pth_rwlock_acquire (&cert_cache_lock, PTH_RWLOCK_RD, FALSE, NULL)) @@ -404,6 +413,7 @@ if (initialization_done) return; + init_cache_lock (); acquire_cache_write_lock (); dname = make_filename (opt.homedir, "trusted-certs", NULL); From cvs at cvs.gnupg.org Mon Jul 23 18:22:39 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 23 Jul 2007 18:22:39 +0200 Subject: [svn] dirmngr - r247 - trunk/src Message-ID: Author: marcus Date: 2007-07-23 18:22:05 +0200 (Mon, 23 Jul 2007) New Revision: 247 Added: trunk/src/exechelp.c trunk/src/exechelp.h Modified: trunk/src/ChangeLog trunk/src/Makefile.am trunk/src/ldap.c Log: 2007-07-23 Marcus Brinkmann * Makefile.am (dirmngr_SOURCES): Add exechelp.h and exechelp.c. * exechelp.h, exechelp.c: New files. * ldap.c: Don't include but "exechelp.h". (destroy_wrapper, ldap_wrapper_thread, ldap_wrapper_connection_cleanup): Use dirmngr_kill_process instead of kill. (ldap_wrapper_thread): Use dirmngr_wait_process instead of waitpid. (ldap_wrapper): Use dirmngr_spawn_process. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2007-07-20 15:27:48 UTC (rev 246) +++ trunk/src/ChangeLog 2007-07-23 16:22:05 UTC (rev 247) @@ -1,3 +1,15 @@ +2007-07-23 Marcus Brinkmann + + * Makefile.am (dirmngr_SOURCES): Add exechelp.h and exechelp.c. + * exechelp.h, exechelp.c: New files. + * ldap.c: Don't include but "exechelp.h". + (destroy_wrapper, ldap_wrapper_thread, + ldap_wrapper_connection_cleanup): Use dirmngr_kill_process instead + of kill. + (ldap_wrapper_thread): Use dirmngr_wait_process instead of + waitpid. + (ldap_wrapper): Use dirmngr_spawn_process. + 2007-07-20 Marcus Brinkmann * certcache.c (cert_cache_lock): Do not initialize statically. Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2007-07-20 15:27:48 UTC (rev 246) +++ trunk/src/Makefile.am 2007-07-23 16:22:05 UTC (rev 247) @@ -43,7 +43,7 @@ certcache.c certcache.h i18n.h util.h \ cdb.h cdblib.c ldap.c http.c http.h misc.c ocsp.c ocsp.h \ estream.c estream.h estream-printf.c estream-printf.h \ - validate.c validate.h + validate.c validate.h exechelp.h exechelp.c dirmngr_LDADD = ../jnlib/libjnlib.a $(LIBOBJS) $(LIBASSUAN_PTH_LIBS) \ $(LIBGCRYPT_LIBS) $(KSBA_LIBS) $(PTH_LIBS) $(LIBINTL) Added: trunk/src/exechelp.c =================================================================== --- trunk/src/exechelp.c 2007-07-20 15:27:48 UTC (rev 246) +++ trunk/src/exechelp.c 2007-07-23 16:22:05 UTC (rev 247) @@ -0,0 +1,545 @@ +/* exechelp.c - fork and exec helpers + * Copyright (C) 2004, 2007 g10 Code GmbH + * + * This file is part of DirMngr. + * + * DirMngr is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * DirMngr is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#ifndef HAVE_W32_SYSTEM +#include +#endif + +#include "util.h" +#include "i18n.h" +#include "exechelp.h" + +/* Define to 1 do enable debugging. */ +#define DEBUG_W32_SPAWN 0 + +#ifdef _POSIX_OPEN_MAX +#define MAX_OPEN_FDS _POSIX_OPEN_MAX +#else +#define MAX_OPEN_FDS 20 +#endif + +#ifdef HAVE_W32_SYSTEM +/* We assume that a HANDLE can be represented by an int which should + be true for all i386 systems (HANDLE is defined as void *) and + these are the only systems for which Windows is available. Further + we assume that -1 denotes an invalid handle. */ +# define fd_to_handle(a) ((HANDLE)(a)) +# define handle_to_fd(a) ((int)(a)) +# define pid_to_handle(a) ((HANDLE)(a)) +# define handle_to_pid(a) ((int)(a)) +#endif + + +#ifdef HAVE_W32_SYSTEM +/* Helper function to build_w32_commandline. */ +static char * +build_w32_commandline_copy (char *buffer, const char *string) +{ + char *p = buffer; + const char *s; + + if (!*string) /* Empty string. */ + p = stpcpy (p, "\"\""); + else if (strpbrk (string, " \t\n\v\f\"")) + { + /* Need top do some kind of quoting. */ + p = stpcpy (p, "\""); + for (s=string; *s; s++) + { + *p++ = *s; + if (*s == '\"') + *p++ = *s; + } + *p++ = '\"'; + *p = 0; + } + else + p = stpcpy (p, string); + + return p; +} + +/* Build a command line for use with W32's CreateProcess. On success + CMDLINE gets the address of a newly allocated string. */ +static gpg_error_t +build_w32_commandline (const char *pgmname, const char * const *argv, + char **cmdline) +{ + int i, n; + const char *s; + char *buf, *p; + + *cmdline = NULL; + n = 0; + s = pgmname; + n += strlen (s) + 1 + 2; /* (1 space, 2 quoting */ + for (; *s; s++) + if (*s == '\"') + n++; /* Need to double inner quotes. */ + for (i=0; (s=argv[i]); i++) + { + n += strlen (s) + 1 + 2; /* (1 space, 2 quoting */ + for (; *s; s++) + if (*s == '\"') + n++; /* Need to double inner quotes. */ + } + n++; + + buf = p = xtrymalloc (n); + if (!buf) + return gpg_error_from_syserror (); + + p = build_w32_commandline_copy (p, pgmname); + for (i=0; argv[i]; i++) + { + *p++ = ' '; + p = build_w32_commandline_copy (p, argv[i]); + } + + *cmdline= buf; + return 0; +} +#endif /*HAVE_W32_SYSTEM*/ + + +#ifdef HAVE_W32_SYSTEM +/* Create pipe where the write end is inheritable. */ +static int +create_inheritable_pipe (int filedes[2]) +{ + HANDLE r, w, h; + SECURITY_ATTRIBUTES sec_attr; + + memset (&sec_attr, 0, sizeof sec_attr ); + sec_attr.nLength = sizeof sec_attr; + sec_attr.bInheritHandle = FALSE; + + if (!CreatePipe (&r, &w, &sec_attr, 0)) + return -1; + + if (!DuplicateHandle (GetCurrentProcess(), w, + GetCurrentProcess(), &h, 0, + TRUE, DUPLICATE_SAME_ACCESS )) + { + log_error ("DuplicateHandle failed: %s\n", w32_strerror (-1)); + CloseHandle (r); + CloseHandle (w); + return -1; + } + CloseHandle (w); + w = h; + + filedes[0] = handle_to_fd (r); + filedes[1] = handle_to_fd (w); + return 0; +} +#endif /*HAVE_W32_SYSTEM*/ + + +#ifndef HAVE_W32_SYSTEM +/* The exec core used right after the fork. This will never return. */ +static void +do_exec (const char *pgmname, char *argv[], + int fd_in, int fd_out, int fd_err) +{ + char **arg_list; + int n, i, j; + int fds[3]; + + fds[0] = fd_in; + fds[1] = fd_out; + fds[2] = fd_err; + + /* Create the command line argument array. */ + i = 0; + if (argv) + while (argv[i]) + i++; + arg_list = xcalloc (i+2, sizeof *arg_list); + arg_list[0] = strrchr (pgmname, '/'); + if (arg_list[0]) + arg_list[0]++; + else + arg_list[0] = xstrdup (pgmname); + if (argv) + for (i=0,j=1; argv[i]; i++, j++) + arg_list[j] = (char*)argv[i]; + + /* Connect the standard files. */ + for (i = 0; i <= 2; i++) + { + if (fds[i] == -1) + { + fds[i] = open ("/dev/null", i ? O_WRONLY : O_RDONLY); + if (fds[i] == -1) + log_fatal ("failed to open `%s': %s\n", + "/dev/null", strerror (errno)); + } + else if (fds[i] != i && dup2 (fds[i], i) == -1) + log_fatal ("dup2 std%s failed: %s\n", + i==0?"in":i==1?"out":"err", strerror (errno)); + } + + /* Close all other files. */ + n = sysconf (_SC_OPEN_MAX); + if (n < 0) + n = MAX_OPEN_FDS; + for (i=3; i < n; i++) + close(i); + errno = 0; + + execv (pgmname, arg_list); + + /* No way to print anything, as we have closed all streams. */ + _exit (127); +} +#endif /*!HAVE_W32_SYSTEM*/ + + +/* Fork and exec the PGMNAME, connect the file descriptor of INFILE to + stdin, write the output to OUTFILE, return a new stream in + STATUSFILE for stderr and the pid of the process in PID. The + arguments for the process are expected in the NULL terminated array + ARGV. The program name itself should not be included there. if + PREEXEC is not NULL, that function will be called right before the + exec. + + Returns 0 on success or an error code. */ +gpg_error_t +dirmngr_spawn_process (const char *pgmname, char *argv[], + int *fdout, int *fderr, pid_t *pid) +{ +#ifdef HAVE_W32_SYSTEM + gpg_error_t err; + SECURITY_ATTRIBUTES sec_attr; + PROCESS_INFORMATION pi = + { + NULL, /* Returns process handle. */ + 0, /* Returns primary thread handle. */ + 0, /* Returns pid. */ + 0 /* Returns tid. */ + }; + STARTUPINFO si; + int cr_flags; + char *cmdline; + int rp_stdout[2]; + int rp_stderr[2]; + HANDLE hnul = INVALID_HANDLE_VALUE; + + /* Setup return values. */ + *fdout = -1; + *fderr = -1; + *pid = (pid_t)(-1); + + /* Build the command line. */ + err = build_w32_commandline (pgmname, argv, &cmdline); + if (err) + return err; + + /* Create a pipe. */ + if (create_inheritable_pipe (rp_stdout)) + { + err = gpg_error (GPG_ERR_GENERAL); + log_error (_("error creating a pipe: %s\n"), gpg_strerror (err)); + xfree (cmdline); + return err; + } + + if (create_inheritable_pipe (rp_stderr)) + { + err = gpg_error (GPG_ERR_GENERAL); + log_error (_("error creating a pipe: %s\n"), gpg_strerror (err)); + xfree (cmdline); + CloseHandle (fd_to_handle (rp_stdout[0])); + CloseHandle (fd_to_handle (rp_stdout[1])); + return err; + } + + /* Prepare security attributes. */ + memset (&sec_attr, 0, sizeof sec_attr); + sec_attr.nLength = sizeof sec_attr; + sec_attr.bInheritHandle = TRUE; + hnul = CreateFile ("nul", + GENERIC_READ|GENERIC_WRITE, + FILE_SHARE_READ|FILE_SHARE_WRITE, + &sec_attr, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + if (hnul == INVALID_HANDLE_VALUE) + { + err = gpg_error (GPG_ERR_GENERAL); + log_error (_("error opening nul: %s\n"), gpg_strerror (err)); + xfree (cmdline); + CloseHandle (fd_to_handle (rp_stdout[0])); + CloseHandle (fd_to_handle (rp_stdout[1])); + CloseHandle (fd_to_handle (rp_stderr[0])); + CloseHandle (fd_to_handle (rp_stderr[1])); + return err; + } + + /* Prepare security attributes. */ + memset (&sec_attr, 0, sizeof sec_attr ); + sec_attr.nLength = sizeof sec_attr; + sec_attr.bInheritHandle = FALSE; + + /* Start the process. Note that we can't run the PREEXEC function + because this would change our own environment. */ + memset (&si, 0, sizeof si); + si.cb = sizeof (si); + si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; + si.wShowWindow = DEBUG_W32_SPAWN? SW_SHOW : SW_MINIMIZE; + si.hStdInput = hnul; + si.hStdOutput = fd_to_handle (rp_stderr[0]); + si.hStdError = fd_to_handle (rp_stderr[1]); + + cr_flags = (CREATE_DEFAULT_ERROR_MODE + | GetPriorityClass (GetCurrentProcess ()) + | CREATE_SUSPENDED); + log_debug ("CreateProcess, path=`%s' cmdline=`%s'\n", pgmname, cmdline); + if (!CreateProcess (pgmname, /* Program to start. */ + cmdline, /* Command line arguments. */ + &sec_attr, /* Process security attributes. */ + &sec_attr, /* Thread security attributes. */ + TRUE, /* Inherit handles. */ + cr_flags, /* Creation flags. */ + NULL, /* Environment. */ + NULL, /* Use current drive/directory. */ + &si, /* Startup information. */ + &pi /* Returns process information. */ + )) + { + log_error ("CreateProcess failed: %s\n", w32_strerror (-1)); + xfree (cmdline); + CloseHandle (fd_to_handle (rp_stdout[0])); + CloseHandle (fd_to_handle (rp_stdout[1])); + CloseHandle (fd_to_handle (rp_stderr[0])); + CloseHandle (fd_to_handle (rp_stderr[1])); + CloseHandle (hnul); + return gpg_error (GPG_ERR_GENERAL); + } + xfree (cmdline); + cmdline = NULL; + + /* Close the other end of the pipe. */ + CloseHandle (fd_to_handle (rp_stdout[1])); + CloseHandle (fd_to_handle (rp_stderr[1])); + CloseHandle (hnul); + + log_debug ("CreateProcess ready: hProcess=%p hThread=%p" + " dwProcessID=%d dwThreadId=%d\n", + pi.hProcess, pi.hThread, + (int) pi.dwProcessId, (int) pi.dwThreadId); + + /* Process has been created suspended; resume it now. */ + ResumeThread (pi.hThread); + CloseHandle (pi.hThread); + + *fdout = handle_to_fd (rp_stdout[0]); + *fderr = handle_to_fd (rp_stderr[0]); + *pid = handle_to_pid (pi.hProcess); + return 0; + +#else /* !HAVE_W32_SYSTEM */ + gpg_error_t err; + int rp_stdout[2]; + int rp_stderr[2]; + + *fdout = -1; + *fderr = -1; + *pid = (pid_t)(-1); + + if (pipe (rp_stdout) == -1) + { + err = gpg_error_from_syserror (); + log_error (_("error creating a pipe: %s\n"), strerror (errno)); + return err; + } + + if (pipe (rp_stderr) == -1) + { + err = gpg_error_from_syserror (); + log_error (_("error creating a pipe: %s\n"), strerror (errno)); + close (rp_stdout[0]); + close (rp_stdout[1]); + return err; + } + + *pid = pth_fork (); + if (*pid == (pid_t)(-1)) + { + err = gpg_error_from_syserror (); + log_error (_("error forking process: %s\n"), strerror (errno)); + close (rp_stdout[0]); + close (rp_stdout[1]); + close (rp_stderr[0]); + close (rp_stderr[1]); + return err; + } + + if (!*pid) + { + /* Run child. */ + do_exec (pgmname, argv, -1, rp_stdout[1], rp_stderr[1]); + /*NOTREACHED*/ + } + + /* Parent. */ + close (rp_stdout[1]); + close (rp_stderr[1]); + + *fdout = rp_stdout[0]; + *fderr = rp_stderr[0]; + + return 0; +#endif /* !HAVE_W32_SYSTEM */ +} + + +/* Wait for the process identified by PID to terminate. PGMNAME should + be the same as suplieed to the spawn fucntion and is only used for + diagnostics. Returns 0 if the process succeded, GPG_ERR_GENERAL for + any failures of the spawned program or other error codes.*/ +gpg_error_t +dirmngr_wait_process (pid_t pid, int hang, int *status) +{ + gpg_err_code_t ec; + +#ifdef HAVE_W32_SYSTEM + HANDLE proc = pid_to_handle (pid); + int code; + DWORD exc; + + *status = 0; + if (pid == (pid_t)(-1)) + return gpg_error (GPG_ERR_INV_VALUE); + + /* FIXME: We should do a pth_waitpid here. However this has not yet + been implemented. A special W32 pth system call would even be + better. */ + code = WaitForSingleObject (proc, hang ? INFINITE : 0); + switch (code) + { + case WAIT_TIMEOUT: + + break; + case WAIT_FAILED: + log_error (_("waiting for process %d to terminate failed: %s\n"), + (int)pid, w32_strerror (-1)); + ec = GPG_ERR_GENERAL; + break; + + case WAIT_OBJECT_0: + if (!GetExitCodeProcess (proc, &exc)) + { + log_error (_("error getting exit code of process %d: %s\n"), + (int)pid, w32_strerror (-1) ); + ec = GPG_ERR_GENERAL; + } + else if (exc) + { + log_error (_("error detected in waitpid: exit status %d\n"), + (int) exc); + ec = GPG_ERR_GENERAL; + } + else + ec = 0; + *status = 1; + break; + + default: + log_error ("WaitForSingleObject returned unexpected " + "code %d for pid %d\n", code, (int)pid ); + ec = GPG_ERR_GENERAL; + break; + } + +#else /* !HAVE_W32_SYSTEM */ + int i; + int r_status; + + *status = 0; + if (pid == (pid_t)(-1)) + return gpg_error (GPG_ERR_INV_VALUE); + + i = pth_waitpid (pid, &r_status, 0); + if (i == (pid_t)(-1)) + { + log_error (_("waiting for process %d to terminate failed: %s\n"), + (int)pid, strerror (errno)); + ec = gpg_err_code_from_errno (errno); + } + if (i == 0) + { + *status = 0; + ec = 0; + } + else if (WIFEXITED (status) && WEXITSTATUS (status) == 127) + { + log_error (_("error detected: program probably not installed\n")); + ec = GPG_ERR_CONFIGURATION; + } + else if (WIFEXITED (status) && WEXITSTATUS (status)) + { + log_error (_("error detected: exit status %d\n"), WEXITSTATUS (status)); + ec = GPG_ERR_GENERAL; + } + else if (!WIFEXITED (status)) + { + log_error (_("error detected: terminated\n")); + ec = GPG_ERR_GENERAL; + } + else + { + *status = 1; + ec = 0; + } +#endif /* !HAVE_W32_SYSTEM */ + + return gpg_err_make (GPG_ERR_SOURCE_DEFAULT, ec); + +} + + +/* Kill the program PID with name PGMNAME (only used for + diagnostics). */ +gpg_error_t +dirmngr_kill_process (pid_t pid) +{ +#ifdef HAVE_W32_SYSTEM + /* FIXME: Implement something. */ + return 0; +#else + return kill (pid, SIGTERM); +#endif +} Added: trunk/src/exechelp.h =================================================================== --- trunk/src/exechelp.h 2007-07-20 15:27:48 UTC (rev 246) +++ trunk/src/exechelp.h 2007-07-23 16:22:05 UTC (rev 247) @@ -0,0 +1,42 @@ +/* exechelp.h - fork and exec helpers + * Copyright (C) 2004, 2007 g10 Code GmbH + * + * This file is part of DirMngr. + * + * DirMngr is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * DirMngr is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#ifndef DIRMNGR_EXECHELP_H +#define DIRMNGR_EXECHELP_H + +/* Fork and exec the PGMNAME with /dev/null as stdin, and pipes for + stdout and stderr. The read ends of these pipes are returned in + FDOUT and FDERR, as well as the pid of the process in PID. The + arguments for the process are expected in the NULL terminated array + ARGV. The program name itself should not be included there. + Returns 0 on success or an error code. */ +gpg_error_t dirmngr_spawn_process (const char *pgmname, char *argv[], + int *fdout, int *fderr, pid_t *pid); + +/* Wait for the process identified by PID to terminate. Returns -1 if + an error occurs, if the process succeded, GPG_ERR_GENERAL for any + failures of the spawned program or other error codes. STATUS is + set to 0 if timeout occurs. */ +gpg_error_t dirmngr_wait_process (pid_t pid, int hang, int *status); + +/* Kill the program PID. */ +gpg_error_t dirmngr_kill_process (pid_t pid); + +#endif /* DIRMNGR_EXECHELP_H */ Modified: trunk/src/ldap.c =================================================================== --- trunk/src/ldap.c 2007-07-20 15:27:48 UTC (rev 246) +++ trunk/src/ldap.c 2007-07-23 16:22:05 UTC (rev 247) @@ -27,12 +27,12 @@ #include #include #include -#include #include #include /* fixme: remove it */ #include #include +#include "exechelp.h" #include "crlfetch.h" #include "dirmngr.h" #include "misc.h" @@ -159,7 +159,7 @@ destroy_wrapper (struct wrapper_context_s *ctx) { if (ctx->pid != (pid_t)(-1)) - kill (ctx->pid, SIGTERM); + dirmngr_kill_process (ctx->pid); ksba_reader_release (ctx->reader); if (ctx->fd) close (ctx->fd); @@ -309,25 +309,17 @@ /* Check whether the process is still running. */ if (ctx->pid != (pid_t)(-1)) { - int i, status; + gpg_error_t err; + int status; - while ( (i=waitpid (ctx->pid, &status, WNOHANG)) == -1 - && errno == EINTR) - ; - if (i == -1) + err = dirmngr_wait_process (ctx->pid, 0, &status); + + if (err == -1) log_error (_("waiting for ldap wrapper %d failed: %s\n"), - (int)ctx->pid, strerror (errno)); - else if (i) + (int)ctx->pid, gpg_strerror (err)); + else if (status) { - if (!WIFEXITED (status)) - log_info (_("ldap wrapper %d ready: terminated\n"), - (int)ctx->pid); - else if (WEXITSTATUS (status) == 10 ) - log_info (_("ldap wrapper %d ready: timeout\n"), - (int)ctx->pid); - else - log_info (_("ldap wrapper %d ready: exit status %d\n"), - (int)ctx->pid, WEXITSTATUS (status)); + log_info (_("ldap wrapper %d ready"), (int)ctx->pid); ctx->ready = 1; ctx->pid = (pid_t)(-1); } @@ -337,7 +329,7 @@ if (ctx->pid != (pid_t)(-1) && ctx->stamp != (time_t)(-1) && ctx->stamp < current_time) { - if (!kill (ctx->pid, SIGTERM)) + if (!dirmngr_kill_process (ctx->pid)) ctx->stamp = (time_t)(-1); log_info (_("ldap wrapper %d stalled - killing\n"), (int)ctx->pid); @@ -423,7 +415,7 @@ ctx->ctrl->refcount--; ctx->ctrl = NULL; if (ctx->pid != (pid_t)(-1)) - kill (ctx->pid, SIGTERM); + dirmngr_kill_process (ctx->pid); if (ctx->fd_error) log_info (_("reading from ldap wrapper %d failed: %s\n"), ctx->printable_pid, gpg_strerror (ctx->fd_error)); @@ -538,22 +530,26 @@ a long response, the frok/exec overhead is acceptable. Special hack to avoid passing a password through the command line - which is gloabbally visible: If the first element of ARGV is - "--pass" it will be removed and instead the environment variable + which is globally visible: If the first element of ARGV is "--pass" + it will be removed and instead the environment variable DIRMNGR_LDAP_PASS will be set to the next value of ARGV. On modern OSes the environment is not visible to other other user. For those old systems where it can't be avoided, we don't want to go into the hassle of passing the password via stdin; it's just too complicated - and an LDAP password used for public directory lookups should be - that confidential. - */ + and an LDAP password used for public directory lookups should not + be that confidential. */ static gpg_error_t ldap_wrapper (ctrl_t ctrl, ksba_reader_t *reader, const char *argv[]) { gpg_error_t err; pid_t pid; - int rp[2], rp2[2]; struct wrapper_context_s *ctx; + int i; + int j; + char **arg_list; + char *pgmname; + int fd_out; + int fd_err; /* It would be too simple to connect stderr just to our logging stream. The problem is that if we are running multi-threaded @@ -566,127 +562,54 @@ *reader = NULL; - if (pipe (rp) == -1) - { - err = gpg_error_from_errno (errno); - log_error (_("error creating a pipe: %s\n"), strerror (errno)); - return err; - } - if (pipe (rp2) == -1) - { - err = gpg_error_from_errno (errno); - log_error (_("error creating a pipe: %s\n"), strerror (errno)); - close (rp[0]); - close (rp[1]); - return err; - } - - pid = pth_fork (); - if (pid == (pid_t)(-1)) - { - err = gpg_error_from_errno (errno); - log_error (_("error forking process: %s\n"), strerror (errno)); - close (rp[0]); - close (rp[1]); - close (rp2[0]); - close (rp2[1]); - return err; - } + /* Files: We need to prepare stdin and stdout. We get stderr from + the function. */ + if (!opt.ldap_wrapper_program || !*opt.ldap_wrapper_program) + pgmname = DIRMNGR_LIBEXECDIR "/dirmngr_ldap"; + else + pgmname = opt.ldap_wrapper_program; - if (!pid) - { /* Child. */ - char *pgmname; - char **arg_list; - int n, i, j; - int fd; + /* Create command line argument array. */ + for (i = 0; argv[i]; i++) + ; + arg_list = xcalloc (i + 3, sizeof *arg_list); + arg_list[0] = strrchr (pgmname, '/'); + if (arg_list[0]) + arg_list[0]++; + else + arg_list[0] = pgmname; + for (i = 0, j = 1; argv[i]; i++, j++) + if (!i && argv[i + 1] && !strcmp (*argv, "--pass")) + { + arg_list[j] = "--env-pass"; + setenv ("DIRMNGR_LDAP_PASS", argv[1], 1); + i++; + } + else + arg_list[j] = (char*) argv[i]; - if (!opt.ldap_wrapper_program || !*opt.ldap_wrapper_program) - pgmname = DIRMNGR_LIBEXECDIR "/dirmngr_ldap"; - else - pgmname = opt.ldap_wrapper_program; - - /* Create command line argument array. */ - for (i=0; argv[i]; i++) - ; - arg_list = xcalloc (i+3, sizeof *arg_list); - arg_list[0] = strrchr (pgmname, '/'); - if (arg_list[0]) - arg_list[0]++; - else - arg_list[0] = pgmname; - for (i=0,j=1; argv[i]; i++, j++) - if (!i && argv[i+1] && !strcmp (*argv, "--pass")) - { - arg_list[j] = "--env-pass"; - setenv ("DIRMNGR_LDAP_PASS", argv[1], 1 ); - i++; - } - else - arg_list[j] = (char*)argv[i]; - - /* Connect stdin to /dev/null. */ - fd = open ("/dev/null", O_RDONLY); - if (fd == -1) - { - log_error (_("can't open `%s': %s\n"), "/dev/null",strerror (errno)); - _exit (4); - } - if (fd != STDIN_FILENO && dup2 (fd, STDIN_FILENO) == -1) - { - log_error (_("dup2 failed in child: %s\n"), strerror (errno)); - _exit (4); - } - - /* Connect stdout to the first pipe. */ - if (rp[1] != STDOUT_FILENO && dup2 (rp[1], STDOUT_FILENO) == -1) - { - log_error (_("dup2 failed in child: %s\n"), strerror (errno)); - _exit (4); - } - - /* Connect stderr to the second pipe. */ - if (rp2[1] != STDERR_FILENO && dup2 (rp2[1], STDERR_FILENO) == -1) - { - log_error (_("dup2 failed in child: %s\n"), strerror (errno)); - _exit (4); - } - - - /* Close all files which will not be duped. */ - n = sysconf (_SC_OPEN_MAX); - if (n < 0) - n = MAX_OPEN_FDS; - for (i=0; i < n; i++) - { - if ( i == STDIN_FILENO || i == STDOUT_FILENO || i == STDERR_FILENO) - continue; - close(i); - } - errno = 0; - - execv (pgmname, arg_list); - log_error (_("error running `%s': %s\n"), pgmname, strerror (errno)); - _exit (31); - } - - /* Parent. */ - close (rp[1]); - close (rp2[1]); - ctx = xtrycalloc (1, sizeof *ctx); if (!ctx) { err = gpg_error_from_errno (errno); log_error (_("error allocating memory: %s\n"), strerror (errno)); - kill (pid, SIGTERM); - close (rp[0]); - close (rp2[0]); + xfree (arg_list); return err; } + + err = dirmngr_spawn_process (pgmname, arg_list, + &fd_out, &fd_err, &pid); + xfree (arg_list); + if (err) + { + xfree (ctx); + return err; + } + ctx->pid = pid; - ctx->printable_pid = (int)pid; - ctx->fd = rp[0]; - ctx->log_fd = rp2[0]; + ctx->printable_pid = (int) pid; + ctx->fd = fd_out; + ctx->log_fd = fd_err; ctx->ctrl = ctrl; ctrl->refcount++; ctx->stamp = time (NULL); From cvs at cvs.gnupg.org Thu Jul 26 01:20:53 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Thu, 26 Jul 2007 01:20:53 +0200 Subject: [svn] dirmngr - r248 - in trunk: . m4 src Message-ID: Author: marcus Date: 2007-07-26 01:20:23 +0200 (Thu, 26 Jul 2007) New Revision: 248 Added: trunk/src/ldap-url.c trunk/src/vasprintf.c Modified: trunk/ChangeLog trunk/README trunk/acinclude.m4 trunk/configure.ac trunk/m4/ChangeLog trunk/m4/Makefile.am trunk/m4/gnupg-pth.m4 trunk/src/ChangeLog trunk/src/Makefile.am trunk/src/dirmngr.c trunk/src/dirmngr_ldap.c trunk/src/ldap.c trunk/src/no-libgcrypt.h trunk/src/util.h Log: 2007-07-26 Marcus Brinkmann * acinclude.m4 (GNUPG_PTH_VERSION_CHECK): Remove macro. (GNUPG_CHECK_VA_COPY): Add macro. * configure.ac: Call AM_ICONV and add vasprintf as a replacement function (checking GNUPG_CHECK_VA_COPY if necessary). m4/ 2007-07-26 Marcus Brinkmann * Makefile.am (EXTRA_DIST): Add estream.m4. * estream.m4: New file. * gnupg-pth.m4: Remove exception for W32 systems. The canonical check works and is necessary. src/ 2007-07-26 Marcus Brinkmann * Makefile.am (ldap_url): New variable. (dirmngr_ldap_SOURCES): Add $(ldap_url). (dirmngr_ldap_LDADD): Add $(LIBOBJS). * ldap-url.c: New file, excerpted from OpenLDAP. * dirmngr.c (main) [HAVE_W32_SYSTEM]: Avoid the daemonization. * dirmngr_ldap.c: Include "util.h". (main) [HAVE_W32_SYSTEM]: Don't set up alarm. (set_timeout) [HAVE_W32_SYSTEM]: Likewise. * ldap.c [HAVE_W32_SYSTEM]: Add macros for setenv and pth_yield. * no-libgcrypt.h (NO_LIBGCRYPT): Define. * util.h [NO_LIBGCRYPT]: Don't include . Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-07-23 16:22:05 UTC (rev 247) +++ trunk/ChangeLog 2007-07-25 23:20:23 UTC (rev 248) @@ -1,3 +1,10 @@ +2007-07-26 Marcus Brinkmann + + * acinclude.m4 (GNUPG_PTH_VERSION_CHECK): Remove macro. + (GNUPG_CHECK_VA_COPY): Add macro. + * configure.ac: Call AM_ICONV and add vasprintf as a replacement + function (checking GNUPG_CHECK_VA_COPY if necessary). + 2007-07-20 Marcus Brinkmann * acinclude.m4 (GNUPG_FUNC_MKDIR_TAKES_ONE_ARG): New. Modified: trunk/README =================================================================== --- trunk/README 2007-07-23 16:22:05 UTC (rev 247) +++ trunk/README 2007-07-25 23:20:23 UTC (rev 248) @@ -17,7 +17,12 @@ See the file COPYING for copyright and warranty information. See the file AUTHORS for contact addresses and code history. + On W32 targets, the URL extension of OpenLDAP is included which is + provided in src/ldap-url.c. This file has a different copyright + from the rest of the package. Please see that file for more + details. + Installation ------------ Please read the file INSTALL. Here is a quick summary: Modified: trunk/acinclude.m4 =================================================================== --- trunk/acinclude.m4 2007-07-23 16:22:05 UTC (rev 247) +++ trunk/acinclude.m4 2007-07-25 23:20:23 UTC (rev 248) @@ -35,48 +35,6 @@ fi ]) -# GNUPG_PTH_VERSION_CHECK(REQUIRED) -# -# If the version is sufficient, HAVE_PTH will be set to yes. -# -# Taken form the m4 macros which come with Pth -AC_DEFUN([GNUPG_PTH_VERSION_CHECK], - [ - _pth_version=`$PTH_CONFIG --version | awk 'NR==1 {print [$]3}'` - _req_version="ifelse([$1],,1.2.0,$1)" - for _var in _pth_version _req_version; do - eval "_val=\"\$${_var}\"" - _major=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\1/'` - _minor=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\2/'` - _rtype=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\3/'` - _micro=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\4/'` - case $_rtype in - "a" ) _rtype=0 ;; - "b" ) _rtype=1 ;; - "." ) _rtype=2 ;; - esac - _hex=`echo dummy | awk '{ printf("%d%02d%1d%02d", major, minor, rtype, micro); }' \ - "major=$_major" "minor=$_minor" "rtype=$_rtype" "micro=$_micro"` - eval "${_var}_hex=\"\$_hex\"" - done - have_pth=no - if test ".$_pth_version_hex" != .; then - if test ".$_req_version_hex" != .; then - if test $_pth_version_hex -ge $_req_version_hex; then - have_pth=yes - fi - fi - fi - if test $have_pth = no; then - AC_MSG_WARN([[ -*** -*** Found Pth version $_pth_version, but require at least -*** version $_req_version. Please upgrade Pth first. -***]]) - fi - ]) - - dnl Stolen from gcc dnl Define MKDIR_TAKES_ONE_ARG if mkdir accepts only one argument instead dnl of the usual 2. @@ -100,3 +58,46 @@ [Defined if mkdir() does not take permission flags]) fi ]) + + +dnl GNUPG_CHECK_VA_COPY() +dnl Do some check on how to implement va_copy. +dnl May define MUST_COPY_VA_BY_VAL. +dnl Actual test code taken from glib-1.1. +AC_DEFUN([GNUPG_CHECK_VA_COPY], +[ AC_MSG_CHECKING(whether va_lists must be copied by value) + AC_CACHE_VAL(gnupg_cv_must_copy_va_byval,[ + if test "$cross_compiling" = yes; then + gnupg_cv_must_copy_va_byval=no + else + gnupg_cv_must_copy_va_byval=no + AC_TRY_RUN([ + #include + void f (int i, ...) + { + va_list args1, args2; + va_start (args1, i); + args2 = args1; + if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42) + exit (1); + va_end (args1); + va_end (args2); + } + + int main() + { + f (0, 42); + return 0; + } + ],gnupg_cv_must_copy_va_byval=yes) + fi + ]) + if test "$gnupg_cv_must_copy_va_byval" = yes; then + AC_DEFINE(MUST_COPY_VA_BYVAL,1,[used to implement the va_copy macro]) + fi + if test "$cross_compiling" = yes; then + AC_MSG_RESULT(assuming $gnupg_cv_must_copy_va_byval) + else + AC_MSG_RESULT($gnupg_cv_must_copy_va_byval) + fi +]) Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-07-23 16:22:05 UTC (rev 247) +++ trunk/configure.ac 2007-07-25 23:20:23 UTC (rev 248) @@ -99,7 +99,6 @@ #AC_ARG_PROGRAM AC_SYS_LARGEFILE - AC_ARG_ENABLE(gcc-warnings, AC_HELP_STRING([--enable-gcc-warnings], [enable more verbose gcc warnings]), @@ -180,7 +179,13 @@ # # Checks for libraries. # +AM_ICONV +AC_REPLACE_FUNCS(vasprintf) +if test "$ac_cv_func_vasprintf" != yes; then + GNUPG_CHECK_VA_COPY +fi + # # We need the GNU Pth library # Modified: trunk/m4/ChangeLog =================================================================== --- trunk/m4/ChangeLog 2007-07-23 16:22:05 UTC (rev 247) +++ trunk/m4/ChangeLog 2007-07-25 23:20:23 UTC (rev 248) @@ -1,6 +1,9 @@ -2007-06-22 Marcus Brinkmann +2007-07-26 Marcus Brinkmann + * Makefile.am (EXTRA_DIST): Add estream.m4. * estream.m4: New file. + * gnupg-pth.m4: Remove exception for W32 systems. The canonical + check works and is necessary. 2006-11-17 Werner Koch @@ -90,4 +93,4 @@ - \ No newline at end of file + Modified: trunk/m4/Makefile.am =================================================================== --- trunk/m4/Makefile.am 2007-07-23 16:22:05 UTC (rev 247) +++ trunk/m4/Makefile.am 2007-07-25 23:20:23 UTC (rev 248) @@ -4,7 +4,7 @@ lcmessage.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 longdouble.m4 \ longlong.m4 nls.m4 po.m4 printf-posix.m4 progtest.m4 signed.m4 \ size_max.m4 stdint_h.m4 uintmax_t.m4 ulonglong.m4 \ - wchar_t.m4 wint_t.m4 xsize.m4 + wchar_t.m4 wint_t.m4 xsize.m4 estream.m4 EXTRA_DIST += autobuild.m4 EXTRA_DIST += gpg-error.m4 ksba.m4 libassuan.m4 libgcrypt.m4 Modified: trunk/m4/gnupg-pth.m4 =================================================================== --- trunk/m4/gnupg-pth.m4 2007-07-23 16:22:05 UTC (rev 247) +++ trunk/m4/gnupg-pth.m4 2007-07-25 23:20:23 UTC (rev 248) @@ -91,9 +91,7 @@ fi AC_PATH_PROG(PTH_CONFIG, pth-config, no) tmp=ifelse([$1], ,1.3.7,$1) - test -z "$have_w32_system" && have_w32_system="no" - if test "$have_w32_system" = no; then - if test "$PTH_CONFIG" != "no"; then + if test "$PTH_CONFIG" != "no"; then GNUPG_PTH_VERSION_CHECK($tmp) if test $have_pth = yes; then PTH_CFLAGS=`$PTH_CONFIG --cflags` @@ -102,12 +100,6 @@ AC_DEFINE(HAVE_PTH, 1, [Defined if the GNU Pth is available]) fi - fi - else - have_pth=yes - PTH_CFLAGS="" - PTH_LIBS="" - AC_DEFINE(HAVE_PTH, 1) fi AC_SUBST(PTH_CFLAGS) AC_SUBST(PTH_LIBS) Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2007-07-23 16:22:05 UTC (rev 247) +++ trunk/src/ChangeLog 2007-07-25 23:20:23 UTC (rev 248) @@ -1,3 +1,17 @@ +2007-07-26 Marcus Brinkmann + + * Makefile.am (ldap_url): New variable. + (dirmngr_ldap_SOURCES): Add $(ldap_url). + (dirmngr_ldap_LDADD): Add $(LIBOBJS). + * ldap-url.c: New file, excerpted from OpenLDAP. + * dirmngr.c (main) [HAVE_W32_SYSTEM]: Avoid the daemonization. + * dirmngr_ldap.c: Include "util.h". + (main) [HAVE_W32_SYSTEM]: Don't set up alarm. + (set_timeout) [HAVE_W32_SYSTEM]: Likewise. + * ldap.c [HAVE_W32_SYSTEM]: Add macros for setenv and pth_yield. + * no-libgcrypt.h (NO_LIBGCRYPT): Define. + * util.h [NO_LIBGCRYPT]: Don't include . + 2007-07-23 Marcus Brinkmann * Makefile.am (dirmngr_SOURCES): Add exechelp.h and exechelp.c. Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2007-07-23 16:22:05 UTC (rev 247) +++ trunk/src/Makefile.am 2007-07-25 23:20:23 UTC (rev 248) @@ -25,6 +25,7 @@ EXTRA_DIST = Manifest bin_PROGRAMS = dirmngr dirmngr-client + libexec_PROGRAMS = dirmngr_ldap AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" @@ -48,14 +49,19 @@ dirmngr_LDADD = ../jnlib/libjnlib.a $(LIBOBJS) $(LIBASSUAN_PTH_LIBS) \ $(LIBGCRYPT_LIBS) $(KSBA_LIBS) $(PTH_LIBS) $(LIBINTL) +if HAVE_W32_SYSTEM +ldap_url = ldap-url.c +else +ldap_url = +endif + dirmngr_ldap_SOURCES = dirmngr_ldap.c i18n.h util.h \ - no-libgcrypt.c no-libgcrypt.h + no-libgcrypt.c no-libgcrypt.h $(ldap_url) dirmngr_ldap_CFLAGS = $(GPG_ERROR_CFLAGS) dirmngr_ldap_LDFLAGS = -dirmngr_ldap_LDADD = ../jnlib/libjnlib.a $(LIBOBJS) $(GPG_ERROR_LIBS) \ - $(LDAPLIBS) $(LIBINTL) +dirmngr_ldap_LDADD = $(ldap_ldadd) ../jnlib/libjnlib.a $(LIBOBJS) \ + $(GPG_ERROR_LIBS) $(LDAPLIBS) $(LIBINTL) - dirmngr_client_SOURCES = dirmngr-client.c i18n.h util.h b64enc.c \ no-libgcrypt.c no-libgcrypt.h dirmngr_client_LDADD = ../jnlib/libjnlib.a $(LIBOBJS) $(LIBASSUAN_LIBS) \ Modified: trunk/src/dirmngr.c =================================================================== --- trunk/src/dirmngr.c 2007-07-23 16:22:05 UTC (rev 247) +++ trunk/src/dirmngr.c 2007-07-25 23:20:23 UTC (rev 248) @@ -875,6 +875,11 @@ log_info (_("listening on socket `%s'\n"), socket_name ); fflush (NULL); + +#ifdef HAVE_W32_SYSTEM + pid = getpid (); + printf ("set DIRMNGR_INFO=%s;%lu;1\n", socket_name, (ulong) pid); +#else pid = pth_fork (); if (pid == (pid_t)-1) { @@ -949,6 +954,7 @@ dirmngr_exit (1); } } +#endif launch_reaper_thread (); cert_cache_init (); Modified: trunk/src/dirmngr_ldap.c =================================================================== --- trunk/src/dirmngr_ldap.c 2007-07-23 16:22:05 UTC (rev 247) +++ trunk/src/dirmngr_ldap.c 2007-07-25 23:20:23 UTC (rev 248) @@ -42,8 +42,8 @@ #include "../jnlib/strlist.h" #include "i18n.h" +#include "no-libgcrypt.h" #include "util.h" -#include "no-libgcrypt.h" #define DEFAULT_LDAP_TIMEOUT 100 /* Arbitrary long timeout. */ @@ -255,17 +255,19 @@ if (opt.alarm_timeout) { -#if defined(HAVE_SIGACTION) && defined(HAVE_STRUCT_SIGACTION) +#ifndef HAVE_W32_SYSTEM +# if defined(HAVE_SIGACTION) && defined(HAVE_STRUCT_SIGACTION) struct sigaction act; act.sa_handler = catch_alarm; sigemptyset (&act.sa_mask); act.sa_flags = 0; if (sigaction (SIGALRM,&act,NULL)) -#else +# else if (signal (SIGALRM, catch_alarm) == SIG_ERR) +# endif + log_fatal ("unable to register timeout handler\n"); #endif - log_fatal ("unable to register timeout handler\n"); } for (; argc; argc--, argv++) @@ -286,12 +288,14 @@ static void set_timeout (void) { +#ifndef HAVE_W32_SYSTEM + /* FIXME for W32. */ if (opt.alarm_timeout) alarm (opt.alarm_timeout); +#endif } - /* Helper for fetch_ldap(). */ static int print_ldap_entries (LDAP *ld, LDAPMessage *msg, char *want_attr) Added: trunk/src/ldap-url.c =================================================================== --- trunk/src/ldap-url.c 2007-07-23 16:22:05 UTC (rev 247) +++ trunk/src/ldap-url.c 2007-07-25 23:20:23 UTC (rev 248) @@ -0,0 +1,928 @@ +/* The following code comes from the OpenLDAP project. The references + to the COPYRIGHT file below refer to the corresponding file in the + OpenLDAP distribution, which is reproduced here in full: + +Copyright 1998-2004 The OpenLDAP Foundation +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted only as authorized by the OpenLDAP +Public License. + +A copy of this license is available in the file LICENSE in the +top-level directory of the distribution or, alternatively, at +. + +OpenLDAP is a registered trademark of the OpenLDAP Foundation. + +Individual files and/or contributed packages may be copyright by +other parties and subject to additional restrictions. + +This work is derived from the University of Michigan LDAP v3.3 +distribution. Information concerning this software is available +at . + +This work also contains materials derived from public sources. + +Additional information about OpenLDAP can be obtained at +. + +--- + +Portions Copyright 1998-2004 Kurt D. Zeilenga. +Portions Copyright 1998-2004 Net Boolean Incorporated. +Portions Copyright 2001-2004 IBM Corporation. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted only as authorized by the OpenLDAP +Public License. + +--- + +Portions Copyright 1999-2003 Howard Y.H. Chu. +Portions Copyright 1999-2003 Symas Corporation. +Portions Copyright 1998-2003 Hallvard B. Furuseth. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that this notice is preserved. +The names of the copyright holders may not be used to endorse or +promote products derived from this software without their specific +prior written permission. This software is provided ``as is'' +without express or implied warranty. + +--- + +Portions Copyright (c) 1992-1996 Regents of the University of Michigan. +All rights reserved. + +Redistribution and use in source and binary forms are permitted +provided that this notice is preserved and that due credit is given +to the University of Michigan at Ann Arbor. The name of the +University may not be used to endorse or promote products derived +from this software without specific prior written permission. This +software is provided ``as is'' without express or implied warranty. */ + + +#include +#include +#include +#include +#include +#include +#include + +#define LDAP_URL_URLCOLON "URL:" +#define LDAP_URL_URLCOLON_LEN (sizeof(LDAP_URL_URLCOLON)-1) +#define LDAP_URL_PREFIX "ldap://" +#define LDAP_URL_PREFIX_LEN (sizeof(LDAP_URL_PREFIX)-1) +#define LDAPS_URL_PREFIX "ldaps://" +#define LDAPS_URL_PREFIX_LEN (sizeof(LDAPS_URL_PREFIX)-1) +#define LDAPI_URL_PREFIX "ldapi://" +#define LDAPI_URL_PREFIX_LEN (sizeof(LDAPI_URL_PREFIX)-1) +#define LDAP_VFREE(v) { int _i; for (_i = 0; (v)[_i]; _i++) free((v)[_i]); } +#define LDAP_FREE free +#define LDAP_STRDUP strdup +#define LDAP_CALLOC calloc +#define LDAP_MALLOC malloc +#define LDAP_REALLOC realloc +#define ldap_utf8_strchr strchr +#define ldap_utf8_strtok(n,d,s) strtok (n,d) +#define Debug(a,b,c,d,e) +void ldap_pvt_hex_unescape( char *s ); + + +/* $OpenLDAP: pkg/ldap/libraries/libldap/charray.c,v 1.9.2.2 2003/03/03 17:10:04 kurt Exp $ */ +/* + * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* charray.c - routines for dealing with char * arrays */ + +int +ldap_charray_add( + char ***a, + char *s +) +{ + int n; + + if ( *a == NULL ) { + *a = (char **) LDAP_MALLOC( 2 * sizeof(char *) ); + n = 0; + + if( *a == NULL ) { + return -1; + } + + } else { + char **new; + + for ( n = 0; *a != NULL && (*a)[n] != NULL; n++ ) { + ; /* NULL */ + } + + new = (char **) LDAP_REALLOC( (char *) *a, + (n + 2) * sizeof(char *) ); + + if( new == NULL ) { + /* caller is required to call ldap_charray_free(*a) */ + return -1; + } + + *a = new; + } + + (*a)[n] = LDAP_STRDUP(s); + + if( (*a)[n] == NULL ) { + return 1; + } + + (*a)[++n] = NULL; + + return 0; +} + +int +ldap_charray_merge( + char ***a, + char **s +) +{ + int i, n, nn; + char **aa; + + for ( n = 0; *a != NULL && (*a)[n] != NULL; n++ ) { + ; /* NULL */ + } + for ( nn = 0; s[nn] != NULL; nn++ ) { + ; /* NULL */ + } + + aa = (char **) LDAP_REALLOC( (char *) *a, (n + nn + 1) * sizeof(char *) ); + + if( aa == NULL ) { + return -1; + } + + *a = aa; + + for ( i = 0; i < nn; i++ ) { + (*a)[n + i] = LDAP_STRDUP(s[i]); + + if( (*a)[n + i] == NULL ) { + for( --i ; i >= 0 ; i-- ) { + LDAP_FREE( (*a)[n + i] ); + (*a)[n + i] = NULL; + } + return -1; + } + } + + (*a)[n + nn] = NULL; + return 0; +} + +void +ldap_charray_free( char **a ) +{ + char **p; + + if ( a == NULL ) { + return; + } + + for ( p = a; *p != NULL; p++ ) { + if ( *p != NULL ) { + LDAP_FREE( *p ); + } + } + + LDAP_FREE( (char *) a ); +} + +int +ldap_charray_inlist( + char **a, + char *s +) +{ + int i; + + if( a == NULL ) return 0; + + for ( i=0; a[i] != NULL; i++ ) { + if ( strcasecmp( s, a[i] ) == 0 ) { + return 1; + } + } + + return 0; +} + +char ** +ldap_charray_dup( char **a ) +{ + int i; + char **new; + + for ( i = 0; a[i] != NULL; i++ ) + ; /* NULL */ + + new = (char **) LDAP_MALLOC( (i + 1) * sizeof(char *) ); + + if( new == NULL ) { + return NULL; + } + + for ( i = 0; a[i] != NULL; i++ ) { + new[i] = LDAP_STRDUP( a[i] ); + + if( new[i] == NULL ) { + for( --i ; i >= 0 ; i-- ) { + LDAP_FREE( new[i] ); + } + LDAP_FREE( new ); + return NULL; + } + } + new[i] = NULL; + + return( new ); +} + +char ** +ldap_str2charray( const char *str_in, const char *brkstr ) +{ + char **res; + char *str, *s; + char *lasts; + int i; + + /* protect the input string from strtok */ + str = LDAP_STRDUP( str_in ); + if( str == NULL ) { + return NULL; + } + + i = 1; + for ( s = str; *s; s++ ) { + if ( ldap_utf8_strchr( brkstr, s ) != NULL ) { + i++; + } + } + + res = (char **) LDAP_MALLOC( (i + 1) * sizeof(char *) ); + + if( res == NULL ) { + LDAP_FREE( str ); + return NULL; + } + + i = 0; + + for ( s = ldap_utf8_strtok( str, brkstr, &lasts ); + s != NULL; + s = ldap_utf8_strtok( NULL, brkstr, &lasts ) ) + { + res[i] = LDAP_STRDUP( s ); + + if(res[i] == NULL) { + for( --i ; i >= 0 ; i-- ) { + LDAP_FREE( res[i] ); + } + LDAP_FREE( res ); + LDAP_FREE( str ); + return NULL; + } + + i++; + } + + res[i] = NULL; + + LDAP_FREE( str ); + return( res ); +} + +char * ldap_charray2str( char **a, const char *sep ) +{ + char *s, **v, *p; + int len; + int slen; + + if( sep == NULL ) sep = " "; + + slen = strlen( sep ); + len = 0; + + for ( v = a; *v != NULL; v++ ) { + len += strlen( *v ) + slen; + } + + if ( len == 0 ) { + return NULL; + } + + /* trim extra sep len */ + len -= slen; + + s = LDAP_MALLOC ( len + 1 ); + + if ( s == NULL ) { + return NULL; + } + + p = s; + for ( v = a; *v != NULL; v++ ) { + if ( v != a ) { + strncpy( p, sep, slen ); + p += slen; + } + + len = strlen( *v ); + strncpy( p, *v, len ); + p += len; + } + + *p = '\0'; + return s; +} + + + +/* $OpenLDAP: pkg/ldap/libraries/libldap/url.c,v 1.64.2.5 2003/03/03 17:10:05 kurt Exp $ */ +/* + * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ +/* Portions + * Copyright (c) 1996 Regents of the University of Michigan. + * All rights reserved. + * + * LIBLDAP url.c -- LDAP URL (RFC 2255) related routines + * + * LDAP URLs look like this: + * ldap[is]://host:port[/[dn[?[attributes][?[scope][?[filter][?exts]]]]]] + * + * where: + * attributes is a comma separated list + * scope is one of these three strings: base one sub (default=base) + * filter is an string-represented filter as in RFC 2254 + * + * e.g., ldap://host:port/dc=com?o,cn?base?(o=openldap)?extension + * + * We also tolerate URLs that look like: and + */ + +/* local functions */ +static const char* skip_url_prefix LDAP_P(( + const char *url, + int *enclosedp, + const char **scheme )); + +int +ldap_is_ldap_url( LDAP_CONST char *url ) +{ + int enclosed; + const char * scheme; + + if( url == NULL ) { + return 0; + } + + if( skip_url_prefix( url, &enclosed, &scheme ) == NULL ) { + return 0; + } + + return 1; +} + + +static const char* +skip_url_prefix( + const char *url, + int *enclosedp, + const char **scheme ) +{ + /* + * return non-zero if this looks like a LDAP URL; zero if not + * if non-zero returned, *urlp will be moved past "ldap://" part of URL + */ + const char *p; + + if ( url == NULL ) { + return( NULL ); + } + + p = url; + + /* skip leading '<' (if any) */ + if ( *p == '<' ) { + *enclosedp = 1; + ++p; + } else { + *enclosedp = 0; + } + + /* skip leading "URL:" (if any) */ + if ( strncasecmp( p, LDAP_URL_URLCOLON, LDAP_URL_URLCOLON_LEN ) == 0 ) { + p += LDAP_URL_URLCOLON_LEN; + } + + /* check for "ldap://" prefix */ + if ( strncasecmp( p, LDAP_URL_PREFIX, LDAP_URL_PREFIX_LEN ) == 0 ) { + /* skip over "ldap://" prefix and return success */ + p += LDAP_URL_PREFIX_LEN; + *scheme = "ldap"; + return( p ); + } + + /* check for "ldaps://" prefix */ + if ( strncasecmp( p, LDAPS_URL_PREFIX, LDAPS_URL_PREFIX_LEN ) == 0 ) { + /* skip over "ldaps://" prefix and return success */ + p += LDAPS_URL_PREFIX_LEN; + *scheme = "ldaps"; + return( p ); + } + + /* check for "ldapi://" prefix */ + if ( strncasecmp( p, LDAPI_URL_PREFIX, LDAPI_URL_PREFIX_LEN ) == 0 ) { + /* skip over "ldapi://" prefix and return success */ + p += LDAPI_URL_PREFIX_LEN; + *scheme = "ldapi"; + return( p ); + } + +#ifdef LDAP_CONNECTIONLESS + /* check for "cldap://" prefix */ + if ( strncasecmp( p, LDAPC_URL_PREFIX, LDAPC_URL_PREFIX_LEN ) == 0 ) { + /* skip over "cldap://" prefix and return success */ + p += LDAPC_URL_PREFIX_LEN; + *scheme = "cldap"; + return( p ); + } +#endif + + return( NULL ); +} + + +static int str2scope( const char *p ) +{ + if ( strcasecmp( p, "one" ) == 0 ) { + return LDAP_SCOPE_ONELEVEL; + + } else if ( strcasecmp( p, "onetree" ) == 0 ) { + return LDAP_SCOPE_ONELEVEL; + + } else if ( strcasecmp( p, "base" ) == 0 ) { + return LDAP_SCOPE_BASE; + + } else if ( strcasecmp( p, "sub" ) == 0 ) { + return LDAP_SCOPE_SUBTREE; + + } else if ( strcasecmp( p, "subtree" ) == 0 ) { + return LDAP_SCOPE_SUBTREE; + } + + return( -1 ); +} + + +int +ldap_url_parse_ext( LDAP_CONST char *url_in, LDAPURLDesc **ludpp ) +{ +/* + * Pick apart the pieces of an LDAP URL. + */ + + LDAPURLDesc *ludp; + char *p, *q, *r; + int i, enclosed; + const char *scheme = NULL; + const char *url_tmp; + char *url; + + if( url_in == NULL || ludpp == NULL ) { + return LDAP_URL_ERR_PARAM; + } + +#ifndef LDAP_INT_IN_KERNEL + /* Global options may not be created yet + * We can't test if the global options are initialized + * because a call to LDAP_INT_GLOBAL_OPT() will try to allocate + * the options and cause infinite recursion + */ +#ifdef NEW_LOGGING + LDAP_LOG ( OPERATION, ENTRY, "ldap_url_parse_ext(%s)\n", url_in, 0, 0 ); +#else + Debug( LDAP_DEBUG_TRACE, "ldap_url_parse_ext(%s)\n", url_in, 0, 0 ); +#endif +#endif + + *ludpp = NULL; /* pessimistic */ + + url_tmp = skip_url_prefix( url_in, &enclosed, &scheme ); + + if ( url_tmp == NULL ) { + return LDAP_URL_ERR_BADSCHEME; + } + + assert( scheme ); + + /* make working copy of the remainder of the URL */ + url = LDAP_STRDUP( url_tmp ); + if ( url == NULL ) { + return LDAP_URL_ERR_MEM; + } + + if ( enclosed ) { + p = &url[strlen(url)-1]; + + if( *p != '>' ) { + LDAP_FREE( url ); + return LDAP_URL_ERR_BADENCLOSURE; + } + + *p = '\0'; + } + + /* allocate return struct */ + ludp = (LDAPURLDesc *)LDAP_CALLOC( 1, sizeof( LDAPURLDesc )); + + if ( ludp == NULL ) { + LDAP_FREE( url ); + return LDAP_URL_ERR_MEM; + } + + ludp->lud_next = NULL; + ludp->lud_host = NULL; + ludp->lud_port = 0; + ludp->lud_dn = NULL; + ludp->lud_attrs = NULL; + ludp->lud_filter = NULL; + ludp->lud_scope = LDAP_SCOPE_DEFAULT; + ludp->lud_filter = NULL; + ludp->lud_exts = NULL; + + ludp->lud_scheme = LDAP_STRDUP( scheme ); + + if ( ludp->lud_scheme == NULL ) { + LDAP_FREE( url ); + ldap_free_urldesc( ludp ); + return LDAP_URL_ERR_MEM; + } + + /* scan forward for '/' that marks end of hostport and begin. of dn */ + p = strchr( url, '/' ); + + if( p != NULL ) { + /* terminate hostport; point to start of dn */ + *p++ = '\0'; + } + + /* IPv6 syntax with [ip address]:port */ + if ( *url == '[' ) { + r = strchr( url, ']' ); + if ( r == NULL ) { + LDAP_FREE( url ); + ldap_free_urldesc( ludp ); + return LDAP_URL_ERR_BADURL; + } + *r++ = '\0'; + q = strchr( r, ':' ); + } else { + q = strchr( url, ':' ); + } + + if ( q != NULL ) { + *q++ = '\0'; + ldap_pvt_hex_unescape( q ); + + if( *q == '\0' ) { + LDAP_FREE( url ); + ldap_free_urldesc( ludp ); + return LDAP_URL_ERR_BADURL; + } + + ludp->lud_port = atoi( q ); + } + + ldap_pvt_hex_unescape( url ); + + /* If [ip address]:port syntax, url is [ip and we skip the [ */ + ludp->lud_host = LDAP_STRDUP( url + ( *url == '[' ) ); + + if( ludp->lud_host == NULL ) { + LDAP_FREE( url ); + ldap_free_urldesc( ludp ); + return LDAP_URL_ERR_MEM; + } + + /* + * Kludge. ldap://111.222.333.444:389??cn=abc,o=company + * + * On early Novell releases, search references/referrals were returned + * in this format, i.e., the dn was kind of in the scope position, + * but the required slash is missing. The whole thing is illegal syntax, + * but we need to account for it. Fortunately it can't be confused with + * anything real. + */ + if( (p == NULL) && (q != NULL) && ((q = strchr( q, '?')) != NULL)) { + q++; + /* ? immediately followed by question */ + if( *q == '?') { + q++; + if( *q != '\0' ) { + /* parse dn part */ + ldap_pvt_hex_unescape( q ); + ludp->lud_dn = LDAP_STRDUP( q ); + } else { + ludp->lud_dn = LDAP_STRDUP( "" ); + } + + if( ludp->lud_dn == NULL ) { + LDAP_FREE( url ); + ldap_free_urldesc( ludp ); + return LDAP_URL_ERR_MEM; + } + } + } + + if( p == NULL ) { + LDAP_FREE( url ); + *ludpp = ludp; + return LDAP_URL_SUCCESS; + } + + /* scan forward for '?' that may marks end of dn */ + q = strchr( p, '?' ); + + if( q != NULL ) { + /* terminate dn part */ + *q++ = '\0'; + } + + if( *p != '\0' ) { + /* parse dn part */ + ldap_pvt_hex_unescape( p ); + ludp->lud_dn = LDAP_STRDUP( p ); + } else { + ludp->lud_dn = LDAP_STRDUP( "" ); + } + + if( ludp->lud_dn == NULL ) { + LDAP_FREE( url ); + ldap_free_urldesc( ludp ); + return LDAP_URL_ERR_MEM; + } + + if( q == NULL ) { + /* no more */ + LDAP_FREE( url ); + *ludpp = ludp; + return LDAP_URL_SUCCESS; + } + + /* scan forward for '?' that may marks end of attributes */ + p = q; + q = strchr( p, '?' ); + + if( q != NULL ) { + /* terminate attributes part */ + *q++ = '\0'; + } + + if( *p != '\0' ) { + /* parse attributes */ + ldap_pvt_hex_unescape( p ); + ludp->lud_attrs = ldap_str2charray( p, "," ); + + if( ludp->lud_attrs == NULL ) { + LDAP_FREE( url ); + ldap_free_urldesc( ludp ); + return LDAP_URL_ERR_BADATTRS; + } + } + + if ( q == NULL ) { + /* no more */ + LDAP_FREE( url ); + *ludpp = ludp; + return LDAP_URL_SUCCESS; + } + + /* scan forward for '?' that may marks end of scope */ + p = q; + q = strchr( p, '?' ); + + if( q != NULL ) { + /* terminate the scope part */ + *q++ = '\0'; + } + + if( *p != '\0' ) { + /* parse the scope */ + ldap_pvt_hex_unescape( p ); + ludp->lud_scope = str2scope( p ); + + if( ludp->lud_scope == -1 ) { + LDAP_FREE( url ); + ldap_free_urldesc( ludp ); + return LDAP_URL_ERR_BADSCOPE; + } + } + + if ( q == NULL ) { + /* no more */ + LDAP_FREE( url ); + *ludpp = ludp; + return LDAP_URL_SUCCESS; + } + + /* scan forward for '?' that may marks end of filter */ + p = q; + q = strchr( p, '?' ); + + if( q != NULL ) { + /* terminate the filter part */ + *q++ = '\0'; + } + + if( *p != '\0' ) { + /* parse the filter */ + ldap_pvt_hex_unescape( p ); + + if( ! *p ) { + /* missing filter */ + LDAP_FREE( url ); + ldap_free_urldesc( ludp ); + return LDAP_URL_ERR_BADFILTER; + } + + LDAP_FREE( ludp->lud_filter ); + ludp->lud_filter = LDAP_STRDUP( p ); + + if( ludp->lud_filter == NULL ) { + LDAP_FREE( url ); + ldap_free_urldesc( ludp ); + return LDAP_URL_ERR_MEM; + } + } + + if ( q == NULL ) { + /* no more */ + LDAP_FREE( url ); + *ludpp = ludp; + return LDAP_URL_SUCCESS; + } + + /* scan forward for '?' that may marks end of extensions */ + p = q; + q = strchr( p, '?' ); + + if( q != NULL ) { + /* extra '?' */ + LDAP_FREE( url ); + ldap_free_urldesc( ludp ); + return LDAP_URL_ERR_BADURL; + } + + /* parse the extensions */ + ludp->lud_exts = ldap_str2charray( p, "," ); + + if( ludp->lud_exts == NULL ) { + LDAP_FREE( url ); + ldap_free_urldesc( ludp ); + return LDAP_URL_ERR_BADEXTS; + } + + for( i=0; ludp->lud_exts[i] != NULL; i++ ) { + ldap_pvt_hex_unescape( ludp->lud_exts[i] ); + + if( *ludp->lud_exts[i] == '!' ) { + /* count the number of critical extensions */ + ludp->lud_crit_exts++; + } + } + + if( i == 0 ) { + /* must have 1 or more */ + LDAP_FREE( url ); + ldap_free_urldesc( ludp ); + return LDAP_URL_ERR_BADEXTS; + } + + /* no more */ + *ludpp = ludp; + LDAP_FREE( url ); + return LDAP_URL_SUCCESS; +} + +int +ldap_url_parse( LDAP_CONST char *url_in, LDAPURLDesc **ludpp ) +{ + int rc = ldap_url_parse_ext( url_in, ludpp ); + + if( rc != LDAP_URL_SUCCESS ) { + return rc; + } + + if ((*ludpp)->lud_scope == LDAP_SCOPE_DEFAULT) { + (*ludpp)->lud_scope = LDAP_SCOPE_BASE; + } + + if ((*ludpp)->lud_host != NULL && *(*ludpp)->lud_host == '\0') { + LDAP_FREE( (*ludpp)->lud_host ); + (*ludpp)->lud_host = NULL; + } + + if ((*ludpp)->lud_port == 0) { + if( strcmp((*ludpp)->lud_scheme, "ldap") == 0 ) { + (*ludpp)->lud_port = LDAP_PORT; +#ifdef LDAP_CONNECTIONLESS + } else if( strcmp((*ludpp)->lud_scheme, "cldap") == 0 ) { + (*ludpp)->lud_port = LDAP_PORT; +#endif + } else if( strcmp((*ludpp)->lud_scheme, "ldaps") == 0 ) { + (*ludpp)->lud_port = LDAPS_PORT; + } + } + + return rc; +} + + +void +ldap_free_urldesc( LDAPURLDesc *ludp ) +{ + if ( ludp == NULL ) { + return; + } + + if ( ludp->lud_scheme != NULL ) { + LDAP_FREE( ludp->lud_scheme ); + } + + if ( ludp->lud_host != NULL ) { + LDAP_FREE( ludp->lud_host ); + } + + if ( ludp->lud_dn != NULL ) { + LDAP_FREE( ludp->lud_dn ); + } + + if ( ludp->lud_filter != NULL ) { + LDAP_FREE( ludp->lud_filter); + } + + if ( ludp->lud_attrs != NULL ) { + LDAP_VFREE( ludp->lud_attrs ); + } + + if ( ludp->lud_exts != NULL ) { + LDAP_VFREE( ludp->lud_exts ); + } + + LDAP_FREE( ludp ); +} + + +static int +ldap_int_unhex( int c ) +{ + return( c >= '0' && c <= '9' ? c - '0' + : c >= 'A' && c <= 'F' ? c - 'A' + 10 + : c - 'a' + 10 ); +} + +void +ldap_pvt_hex_unescape( char *s ) +{ + /* + * Remove URL hex escapes from s... done in place. The basic concept for + * this routine is borrowed from the WWW library HTUnEscape() routine. + */ + char *p; + + for ( p = s; *s != '\0'; ++s ) { + if ( *s == '%' ) { + if ( *++s == '\0' ) { + break; + } + *p = ldap_int_unhex( *s ) << 4; + if ( *++s == '\0' ) { + break; + } + *p++ += ldap_int_unhex( *s ); + } else { + *p++ = *s; + } + } + + *p = '\0'; +} + Modified: trunk/src/ldap.c =================================================================== --- trunk/src/ldap.c 2007-07-23 16:22:05 UTC (rev 247) +++ trunk/src/ldap.c 2007-07-25 23:20:23 UTC (rev 248) @@ -37,6 +37,11 @@ #include "dirmngr.h" #include "misc.h" +#if HAVE_W32_SYSTEM +#define setenv(a,b,c) SetEnvironmentVariable ((a),(b)) +#define pth_yield(a) /* FIXME */ +#endif + /* In case sysconf does not return a value we need to have a limit. */ #ifdef _POSIX_OPEN_MAX #define MAX_OPEN_FDS _POSIX_OPEN_MAX Modified: trunk/src/no-libgcrypt.h =================================================================== --- trunk/src/no-libgcrypt.h 2007-07-23 16:22:05 UTC (rev 247) +++ trunk/src/no-libgcrypt.h 2007-07-25 23:20:23 UTC (rev 248) @@ -21,6 +21,8 @@ #ifndef NO_LIBGCRYPT_H #define NO_LIBGCRYPT_H +#define NO_LIBGCRYPT 1 + void *gcry_malloc (size_t n); void *gcry_xmalloc (size_t n); void *gcry_realloc (void *a, size_t n); Modified: trunk/src/util.h =================================================================== --- trunk/src/util.h 2007-07-23 16:22:05 UTC (rev 247) +++ trunk/src/util.h 2007-07-25 23:20:23 UTC (rev 248) @@ -22,7 +22,9 @@ #define UTIL_H #include +#ifndef NO_LIBGCRYPT #include +#endif /* Get all the stuff from jnlib. */ #include "../jnlib/logging.h" Added: trunk/src/vasprintf.c =================================================================== --- trunk/src/vasprintf.c 2007-07-23 16:22:05 UTC (rev 247) +++ trunk/src/vasprintf.c 2007-07-25 23:20:23 UTC (rev 248) @@ -0,0 +1,192 @@ +/* Like vsprintf but provides a pointer to malloc'd storage, which must + be freed by the caller. + Copyright (C) 1994, 2002 Free Software Foundation, Inc. + +This file is part of the libiberty library. +Libiberty is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +Libiberty is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with libiberty; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include +#include +#include +#include + + +#ifndef va_copy /* According to POSIX, va_copy is a macro. */ +#if defined (__GNUC__) && defined (__PPC__) \ + && (defined (_CALL_SYSV) || defined (_WIN32)) +#define va_copy(d, s) (*(d) = *(s)) +#elif defined (MUST_COPY_VA_BYVAL) +#define va_copy(d, s) ((d) = (s)) +#else +#define va_copy(d, s) memcpy ((d), (s), sizeof (va_list)) +#endif +#endif + + +#ifdef TEST +int global_total_width; +#endif + +static int int_vasprintf (char **, const char *, va_list *); + +static int +int_vasprintf (result, format, args) + char **result; + const char *format; + va_list *args; +{ + const char *p = format; + /* Add one to make sure that it is never zero, which might cause malloc + to return NULL. */ + int total_width = strlen (format) + 1; + va_list ap; + + va_copy (ap, *args); + + while (*p != '\0') + { + if (*p++ == '%') + { + while (strchr ("-+ #0", *p)) + ++p; + if (*p == '*') + { + ++p; + total_width += abs (va_arg (ap, int)); + } + else + total_width += strtoul (p, (char **) &p, 10); + if (*p == '.') + { + ++p; + if (*p == '*') + { + ++p; + total_width += abs (va_arg (ap, int)); + } + else + total_width += strtoul (p, (char **) &p, 10); + } + while (strchr ("hlL", *p)) + ++p; + /* Should be big enough for any format specifier except %s and floats. */ + total_width += 30; + switch (*p) + { + case 'd': + case 'i': + case 'o': + case 'u': + case 'x': + case 'X': + case 'c': + (void) va_arg (ap, int); + break; + case 'f': + case 'e': + case 'E': + case 'g': + case 'G': + (void) va_arg (ap, double); + /* Since an ieee double can have an exponent of 307, we'll + make the buffer wide enough to cover the gross case. */ + total_width += 307; + break; + case 's': + { + char *tmp = va_arg (ap, char *); + if (tmp) + total_width += strlen (tmp); + else /* in case the vsprintf does prints a text */ + total_width += 25; /* e.g. "(null pointer reference)" */ + } + break; + case 'p': + case 'n': + (void) va_arg (ap, char *); + break; + } + p++; + } + } +#ifdef TEST + global_total_width = total_width; +#endif + *result = malloc (total_width); + if (*result != NULL) + return vsprintf (*result, format, *args); + else + return 0; +} + +int +vasprintf (result, format, args) + char **result; + const char *format; +#if defined (_BSD_VA_LIST_) && defined (__FreeBSD__) + _BSD_VA_LIST_ args; +#else + va_list args; +#endif +{ + return int_vasprintf (result, format, &args); +} + + +int +asprintf (char **buf, const char *fmt, ...) +{ + int status; + va_list ap; + + va_start (ap, fmt); + status = vasprintf (buf, fmt, ap); + va_end (ap); + return status; +} + + +#ifdef TEST +void +checkit (const char* format, ...) +{ + va_list args; + char *result; + + va_start (args, format); + vasprintf (&result, format, args); + if (strlen (result) < global_total_width) + printf ("PASS: "); + else + printf ("FAIL: "); + printf ("%d %s\n", global_total_width, result); +} + +int +main (void) +{ + checkit ("%d", 0x12345678); + checkit ("%200d", 5); + checkit ("%.300d", 6); + checkit ("%100.150d", 7); + checkit ("%s", "jjjjjjjjjiiiiiiiiiiiiiiioooooooooooooooooppppppppppppaa\n\ +777777777777777777333333333333366666666666622222222222777777777777733333"); + checkit ("%f%s%d%s", 1.0, "foo", 77, "asdjffffffffffffffiiiiiiiiiiixxxxx"); +} +#endif /* TEST */ From cvs at cvs.gnupg.org Thu Jul 26 02:24:54 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Thu, 26 Jul 2007 02:24:54 +0200 Subject: [svn] dirmngr - r249 - in trunk: . src tests Message-ID: Author: marcus Date: 2007-07-26 02:24:24 +0200 (Thu, 26 Jul 2007) New Revision: 249 Added: trunk/src/ldap-url.h Modified: trunk/ChangeLog trunk/Makefile.am trunk/src/ChangeLog trunk/src/Makefile.am trunk/src/dirmngr_ldap.c trunk/src/ldap-url.c trunk/src/ldap.c trunk/tests/test-dirmngr.c Log: 2007-07-26 Marcus Brinkmann * Makefile.am (tests): New variable. (SUBDIRS): Replace tests with $(tests). * tests/test-dirmngr.c: Include and undefine _ASSUAN_ONLY_GPG_ERRORS. src/ 2007-07-26 Marcus Brinkmann * dirmngr_ldap.c [HAVE_W32_SYSTEM]: Do not include , but , and "ldap-url.h". * ldap.c [HAVE_W32_SYSTEM]: Do not include , but and . * ldap-url.c: Do not include , but , and "ldap-url.h". (LDAP_P): New macro. * ldap-url.h: New file. * Makefile.am (ldap_url): Add ldap-url.h. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-07-25 23:20:23 UTC (rev 248) +++ trunk/ChangeLog 2007-07-26 00:24:24 UTC (rev 249) @@ -1,10 +1,15 @@ 2007-07-26 Marcus Brinkmann + * Makefile.am (tests): New variable. + (SUBDIRS): Replace tests with $(tests). + * tests/test-dirmngr.c: Include and undefine + _ASSUAN_ONLY_GPG_ERRORS. + * acinclude.m4 (GNUPG_PTH_VERSION_CHECK): Remove macro. (GNUPG_CHECK_VA_COPY): Add macro. * configure.ac: Call AM_ICONV and add vasprintf as a replacement function (checking GNUPG_CHECK_VA_COPY if necessary). - + 2007-07-20 Marcus Brinkmann * acinclude.m4 (GNUPG_FUNC_MKDIR_TAKES_ONE_ARG): New. Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2007-07-25 23:20:23 UTC (rev 248) +++ trunk/Makefile.am 2007-07-26 00:24:24 UTC (rev 249) @@ -24,5 +24,10 @@ EXTRA_DIST = config.rpath autogen.sh -SUBDIRS = m4 jnlib src po doc tests +if HAVE_W32_SYSTEM +tests = +else +tests = tests +endif +SUBDIRS = m4 jnlib src po doc $(tests) Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2007-07-25 23:20:23 UTC (rev 248) +++ trunk/src/ChangeLog 2007-07-26 00:24:24 UTC (rev 249) @@ -1,5 +1,15 @@ 2007-07-26 Marcus Brinkmann + * dirmngr_ldap.c [HAVE_W32_SYSTEM]: Do not include , but + , and "ldap-url.h". + * ldap.c [HAVE_W32_SYSTEM]: Do not include , but + and . + * ldap-url.c: Do not include , but , + and "ldap-url.h". + (LDAP_P): New macro. + * ldap-url.h: New file. + * Makefile.am (ldap_url): Add ldap-url.h. + * Makefile.am (ldap_url): New variable. (dirmngr_ldap_SOURCES): Add $(ldap_url). (dirmngr_ldap_LDADD): Add $(LIBOBJS). Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2007-07-25 23:20:23 UTC (rev 248) +++ trunk/src/Makefile.am 2007-07-26 00:24:24 UTC (rev 249) @@ -50,7 +50,7 @@ $(LIBGCRYPT_LIBS) $(KSBA_LIBS) $(PTH_LIBS) $(LIBINTL) if HAVE_W32_SYSTEM -ldap_url = ldap-url.c +ldap_url = ldap-url.h ldap-url.c else ldap_url = endif Modified: trunk/src/dirmngr_ldap.c =================================================================== --- trunk/src/dirmngr_ldap.c 2007-07-25 23:20:23 UTC (rev 248) +++ trunk/src/dirmngr_ldap.c 2007-07-26 00:24:24 UTC (rev 249) @@ -30,10 +30,16 @@ #include #include #include + +#ifdef HAVE_W32_SYSTEM +#include +#include +#include "ldap-url.h" +#else #include +#endif - #define JNLIB_NEED_LOG_LOGV #include "../jnlib/logging.h" #include "../jnlib/argparse.h" Modified: trunk/src/ldap-url.c =================================================================== --- trunk/src/ldap-url.c 2007-07-25 23:20:23 UTC (rev 248) +++ trunk/src/ldap-url.c 2007-07-26 00:24:24 UTC (rev 249) @@ -71,13 +71,16 @@ #include #include #include -#include -#define LDAP_URL_URLCOLON "URL:" +#include +#include +#include "ldap-url.h" +#define LDAP_P(protos) protos +#define LDAP_URL_URLCOLON "URL:" #define LDAP_URL_URLCOLON_LEN (sizeof(LDAP_URL_URLCOLON)-1) #define LDAP_URL_PREFIX "ldap://" #define LDAP_URL_PREFIX_LEN (sizeof(LDAP_URL_PREFIX)-1) -#define LDAPS_URL_PREFIX "ldaps://" +#define LDAPS_URL_PREFIX "ldaps://" #define LDAPS_URL_PREFIX_LEN (sizeof(LDAPS_URL_PREFIX)-1) #define LDAPI_URL_PREFIX "ldapi://" #define LDAPI_URL_PREFIX_LEN (sizeof(LDAPI_URL_PREFIX)-1) @@ -92,6 +95,7 @@ #define Debug(a,b,c,d,e) void ldap_pvt_hex_unescape( char *s ); + /* $OpenLDAP: pkg/ldap/libraries/libldap/charray.c,v 1.9.2.2 2003/03/03 17:10:04 kurt Exp $ */ /* Added: trunk/src/ldap-url.h =================================================================== --- trunk/src/ldap-url.h 2007-07-25 23:20:23 UTC (rev 248) +++ trunk/src/ldap-url.h 2007-07-26 00:24:24 UTC (rev 249) @@ -0,0 +1,50 @@ +/* Copyright 2007 g10 Code GmbH + + This file is free software; as a special exception the author gives + unlimited permission to copy and/or distribute it, with or without + modifications, as long as this notice is preserved. + + This file is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY, to the extent permitted by law; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. */ + +#ifndef LDAP_URL_H +#define LDAP_URL_H 1 + +#define LDAP_CONST const + +typedef struct ldap_url_desc +{ + struct ldap_url_desc *lud_next; + char?*lud_scheme; + char?*lud_host; + int?lud_port; + char?*lud_dn; + char?**lud_attrs; + int?lud_scope; + char?*lud_filter; + char?**lud_exts; + int?lud_crit_exts; +} LDAPURLDesc; + +#define LDAP_URL_SUCCESS 0x00 +#define LDAP_URL_ERR_MEM 0x01 +#define LDAP_URL_ERR_PARAM 0x02 + +#define LDAP_URL_ERR_BADSCHEME 0x03 +#define LDAP_URL_ERR_BADENCLOSURE 0x04 +#define LDAP_URL_ERR_BADURL 0x05 +#define LDAP_URL_ERR_BADHOST 0x06 +#define LDAP_URL_ERR_BADATTRS 0x07 +#define LDAP_URL_ERR_BADSCOPE 0x08 +#define LDAP_URL_ERR_BADFILTER 0x09 +#define LDAP_URL_ERR_BADEXTS 0x0a + +#define LDAPS_PORT 636 + +int ldap_is_ldap_url (LDAP_CONST char *url); +int ldap_url_parse (LDAP_CONST char *url_in, LDAPURLDesc **ludpp); +void ldap_free_urldesc (LDAPURLDesc *ludp); + +#endif /* !LDAP_URL_H */ Modified: trunk/src/ldap.c =================================================================== --- trunk/src/ldap.c 2007-07-25 23:20:23 UTC (rev 248) +++ trunk/src/ldap.c 2007-07-26 00:24:24 UTC (rev 249) @@ -28,7 +28,12 @@ #include #include #include +#ifdef HAVE_W32_SYSTEM +#include +#include +#else #include /* fixme: remove it */ +#endif #include #include Modified: trunk/tests/test-dirmngr.c =================================================================== --- trunk/tests/test-dirmngr.c 2007-07-25 23:20:23 UTC (rev 248) +++ trunk/tests/test-dirmngr.c 2007-07-26 00:24:24 UTC (rev 249) @@ -1,3 +1,6 @@ +#include +#undef _ASSUAN_ONLY_GPG_ERRORS + #include #include #include From cvs at cvs.gnupg.org Thu Jul 26 11:15:44 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 26 Jul 2007 11:15:44 +0200 Subject: [svn] gcry - r1259 - in trunk: . cipher doc Message-ID: Author: wk Date: 2007-07-26 11:15:12 +0200 (Thu, 26 Jul 2007) New Revision: 1259 Modified: trunk/ChangeLog trunk/NEWS trunk/THANKS trunk/TODO trunk/acinclude.m4 trunk/autogen.sh trunk/cipher/pubkey.c trunk/cipher/random.c trunk/doc/ChangeLog trunk/doc/gcrypt.texi Log: Fixed symbol prefix detection. Typo fixes. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-06-20 18:07:52 UTC (rev 1258) +++ trunk/ChangeLog 2007-07-26 09:15:12 UTC (rev 1259) @@ -1,7 +1,14 @@ -2007-06-15 Marcus Brinkmann +2007-07-26 Werner Koch - * autogen.sh: Use = instead of == in test. + * acinclude.m4 (GNUPG_SYS_SYMBOL_UNDERSCORE): Fix a syntax error + in the test program which lurked there for 4 years. Adjusted name + of libtools global_system_pipe variable and add extra cut stage. + Reported by Gregor Riepl. + +2007-06-15 Werner Koch + * autogen.sh (FORCE): Use = and not == in test to be POSIXly correct. + 2007-05-30 Werner Koch * configure.ac: Camellia is no longer GPL. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2007-06-20 18:07:52 UTC (rev 1258) +++ trunk/NEWS 2007-07-26 09:15:12 UTC (rev 1259) @@ -3,6 +3,9 @@ * The Camellia cipher is now under the LGPL and included by default. + * Fixed a bug in the detection of symbol prefixes which inhibited the + build of optimzied assembler code on certain systems. + * Interface changes relative to the 1.3.0 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Modified: trunk/THANKS =================================================================== --- trunk/THANKS 2007-06-20 18:07:52 UTC (rev 1258) +++ trunk/THANKS 2007-07-26 09:15:12 UTC (rev 1259) @@ -34,6 +34,7 @@ Frank Heckenbach heckenb at mi.uni-erlangen.de Frank Stajano frank.stajano at cl.cam.ac.uk Ga?l Qu?ri gqueri at mail.dotcom.fr +Gregor Riepl seto-kun at freesurf.ch Gerlinde Klaes gk at u64.de Greg Louis glouis at dynamicro.on.ca Greg Troxel gdt at ir.bbn.com Modified: trunk/TODO =================================================================== --- trunk/TODO 2007-06-20 18:07:52 UTC (rev 1258) +++ trunk/TODO 2007-07-26 09:15:12 UTC (rev 1259) @@ -132,3 +132,6 @@ ** C++ tests We have some code to allow using libgcrypt from C++, so we also should have a test case. + +* /dev/urandom and Solaris + Make the configure check similar to GnuPG. Modified: trunk/acinclude.m4 =================================================================== --- trunk/acinclude.m4 2007-06-20 18:07:52 UTC (rev 1258) +++ trunk/acinclude.m4 2007-07-26 09:15:12 UTC (rev 1259) @@ -93,12 +93,12 @@ [ac_cv_sys_symbol_underscore=no cat > conftest.$ac_ext < $ac_nlist) && test -s "$ac_nlist"; then + if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \| cut -d \' \' -f 2 \> $ac_nlist) && test -s "$ac_nlist"; then # See whether the symbols have a leading underscore. if egrep '^_nm_test_func' "$ac_nlist" >/dev/null; then ac_cv_sys_symbol_underscore=yes @@ -110,7 +110,7 @@ fi fi else - echo "configure: cannot run $global_symbol_pipe" >&AC_FD_CC + echo "configure: cannot run $lt_cv_sys_global_symbol_pipe" >&AC_FD_CC fi else echo "configure: failed program was:" >&AC_FD_CC Modified: trunk/autogen.sh =================================================================== --- trunk/autogen.sh 2007-06-20 18:07:52 UTC (rev 1258) +++ trunk/autogen.sh 2007-07-26 09:15:12 UTC (rev 1259) @@ -31,7 +31,7 @@ DIE=no FORCE= -if test "$1" = "--force"; then +if test x"$1" = x"--force"; then FORCE=" --force" shift fi @@ -75,11 +75,9 @@ fi fi - # Note: we include Camellia because this is anyway a GPLed build. ./configure --enable-maintainer-mode --prefix=${w32root} \ --host=${host} --build=${build} \ - --with-gpg-error-prefix=${w32root} \ - --enable-ciphers=arcfour:blowfish:cast5:des:aes:twofish:serpent:rfc2268:seed:camellia + --with-gpg-error-prefix=${w32root} exit $? fi # ***** end W32 build script ******* Modified: trunk/cipher/pubkey.c =================================================================== --- trunk/cipher/pubkey.c 2007-06-20 18:07:52 UTC (rev 1258) +++ trunk/cipher/pubkey.c 2007-07-26 09:15:12 UTC (rev 1259) @@ -1214,7 +1214,7 @@ return err; } -/* Take the hash value and convert into an MPI, suitable for for +/* Take the hash value and convert into an MPI, suitable for passing to the low level functions. We currently support the old style way of passing just a MPI and the modern interface which allows to pass flags so that we can choose between raw and pkcs1 Modified: trunk/cipher/random.c =================================================================== --- trunk/cipher/random.c 2007-06-20 18:07:52 UTC (rev 1258) +++ trunk/cipher/random.c 2007-07-26 09:15:12 UTC (rev 1259) @@ -163,7 +163,7 @@ /* Option flag useful for debugging and the test suite. If set requests for very strong random are degraded to strong random. Not - used by regualr applications. */ + used by regular applications. */ static int quick_test; /* On systems without entropy gathering modules, this flag is set to Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2007-06-20 18:07:52 UTC (rev 1258) +++ trunk/doc/ChangeLog 2007-07-26 09:15:12 UTC (rev 1259) @@ -1,3 +1,8 @@ +2007-06-15 Werner Koch + + * gcrypt.texi (Controlling the library): Clarified the use of + GCRYCTL_ENABLE_QUICK_RANDOM. + 2007-04-30 Werner Koch * HACKING: New. Two items by Marcus. Modified: trunk/doc/gcrypt.texi =================================================================== --- trunk/doc/gcrypt.texi 2007-06-20 18:07:52 UTC (rev 1258) +++ trunk/doc/gcrypt.texi 2007-07-26 09:15:12 UTC (rev 1259) @@ -519,10 +519,17 @@ own memory management callbacks. @item GCRYCTL_ENABLE_QUICK_RANDOM; Arguments: none -This command activates the use of a highly-insecure, but fast PRNG. It -can only be used at initialization time. The only useful applications -for this are certain regression tests. +This command inhibits the use the very secure random quality level +(@code{GCRY_VERY_STRONG_RANDOM}) and degrades all request down to + at code{GCRY_STRONG_RANDOM}. In general this is not recommened. However, +for some applications the extra quality random Libgcrypt tries to create +is not justified and this option may help to get better performace. +Please check with a crypto expert whether this option can be used for +your application. +This option can only be used at initialization time. + + @item GCRYCTL_DUMP_RANDOM_STATS This command dumps PRNG related statistics to the librarys logging stream. From cvs at cvs.gnupg.org Thu Jul 26 13:41:14 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Thu, 26 Jul 2007 13:41:14 +0200 Subject: [svn] dirmngr - r250 - trunk/src Message-ID: Author: marcus Date: 2007-07-26 13:40:44 +0200 (Thu, 26 Jul 2007) New Revision: 250 Modified: trunk/src/ChangeLog trunk/src/ldap.c Log: 2007-07-26 Marcus Brinkmann * ldap (pth_yield) [HAVE_W32_SYSTEM]: Define to Sleep(0). Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2007-07-26 00:24:24 UTC (rev 249) +++ trunk/src/ChangeLog 2007-07-26 11:40:44 UTC (rev 250) @@ -1,9 +1,12 @@ 2007-07-26 Marcus Brinkmann + * ldap (pth_yield) [HAVE_W32_SYSTEM]: Define to Sleep(0). + * dirmngr_ldap.c [HAVE_W32_SYSTEM]: Do not include , but , and "ldap-url.h". * ldap.c [HAVE_W32_SYSTEM]: Do not include , but and . + * ldap-url.c: Do not include , but , and "ldap-url.h". (LDAP_P): New macro. Modified: trunk/src/ldap.c =================================================================== --- trunk/src/ldap.c 2007-07-26 00:24:24 UTC (rev 249) +++ trunk/src/ldap.c 2007-07-26 11:40:44 UTC (rev 250) @@ -44,7 +44,7 @@ #if HAVE_W32_SYSTEM #define setenv(a,b,c) SetEnvironmentVariable ((a),(b)) -#define pth_yield(a) /* FIXME */ +#define pth_yield(a) Sleep (0) #endif /* In case sysconf does not return a value we need to have a limit. */ From cvs at cvs.gnupg.org Thu Jul 26 21:12:18 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Thu, 26 Jul 2007 21:12:18 +0200 Subject: [svn] w32pth - r10 - trunk Message-ID: Author: marcus Date: 2007-07-26 21:11:47 +0200 (Thu, 26 Jul 2007) New Revision: 10 Modified: trunk/ChangeLog trunk/libw32pth.def trunk/pth.h trunk/w32-pth.c Log: 2007-07-26 Marcus Brinkmann * libw32pth.def: Add pth_rwlock_init, pth_rwlock_acquire, pth_rwlock_release, and pth_yield. * pth.h (pth_yield): New prototype. * w32-pth.c (pth_yield): New function. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-07-20 15:26:16 UTC (rev 9) +++ trunk/ChangeLog 2007-07-26 19:11:47 UTC (rev 10) @@ -1,3 +1,10 @@ +2007-07-26 Marcus Brinkmann + + * libw32pth.def: Add pth_rwlock_init, pth_rwlock_acquire, + pth_rwlock_release, and pth_yield. + * pth.h (pth_yield): New prototype. + * w32-pth.c (pth_yield): New function. + 2007-07-20 Marcus Brinkmann * pth.h (PTH_RWLOCK_RD, PTH_RWLOCK_RW): New symbols. Modified: trunk/libw32pth.def =================================================================== --- trunk/libw32pth.def 2007-07-20 15:26:16 UTC (rev 9) +++ trunk/libw32pth.def 2007-07-26 19:11:47 UTC (rev 10) @@ -60,5 +60,10 @@ pth_select_ev @33 pth_sigmask @34 - + pth_rwlock_release @35 + pth_rwlock_acquire @36 + pth_rwlock_init @37 + + pth_yield @38 + Modified: trunk/pth.h =================================================================== --- trunk/pth.h 2007-07-20 15:26:16 UTC (rev 9) +++ trunk/pth.h 2007-07-26 19:11:47 UTC (rev 10) @@ -270,8 +270,10 @@ int pth_sigmask (int how, const sigset_t *set, sigset_t *old); +int pth_yield (pth_t tid); + /*-- pth_util.c --*/ /* void sigemptyset (struct sigset_s * ss); */ Modified: trunk/w32-pth.c =================================================================== --- trunk/w32-pth.c 2007-07-20 15:26:16 UTC (rev 9) +++ trunk/w32-pth.c 2007-07-26 19:11:47 UTC (rev 10) @@ -1837,6 +1837,15 @@ } +int +pth_yield (pth_t tid) +{ + implicit_init (); + enter_pth (__FUNCTION__); + Sleep (0); + leave_pth (__FUNCTION__); + return TRUE; +} /* From cvs at cvs.gnupg.org Thu Jul 26 21:19:45 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Thu, 26 Jul 2007 21:19:45 +0200 Subject: [svn] dirmngr - r251 - trunk/src Message-ID: Author: marcus Date: 2007-07-26 21:19:13 +0200 (Thu, 26 Jul 2007) New Revision: 251 Modified: trunk/src/ChangeLog trunk/src/ldap.c Log: 2007-07-26 Marcus Brinkmann * ldap.c (pth_yield): Remove macro. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2007-07-26 11:40:44 UTC (rev 250) +++ trunk/src/ChangeLog 2007-07-26 19:19:13 UTC (rev 251) @@ -1,7 +1,9 @@ 2007-07-26 Marcus Brinkmann - * ldap (pth_yield) [HAVE_W32_SYSTEM]: Define to Sleep(0). + * ldap.c (pth_yield): Remove macro. + * ldap.c (pth_yield) [HAVE_W32_SYSTEM]: Define to Sleep(0). + * dirmngr_ldap.c [HAVE_W32_SYSTEM]: Do not include , but , and "ldap-url.h". * ldap.c [HAVE_W32_SYSTEM]: Do not include , but Modified: trunk/src/ldap.c =================================================================== --- trunk/src/ldap.c 2007-07-26 11:40:44 UTC (rev 250) +++ trunk/src/ldap.c 2007-07-26 19:19:13 UTC (rev 251) @@ -44,7 +44,6 @@ #if HAVE_W32_SYSTEM #define setenv(a,b,c) SetEnvironmentVariable ((a),(b)) -#define pth_yield(a) Sleep (0) #endif /* In case sysconf does not return a value we need to have a limit. */ From cvs at cvs.gnupg.org Fri Jul 27 15:06:20 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Fri, 27 Jul 2007 15:06:20 +0200 Subject: [svn] dirmngr - r252 - trunk/src Message-ID: Author: marcus Date: 2007-07-27 15:05:47 +0200 (Fri, 27 Jul 2007) New Revision: 252 Modified: trunk/src/ChangeLog trunk/src/Makefile.am trunk/src/dirmngr.c trunk/src/ldap-url.h trunk/src/ldap.c trunk/src/util.h Log: 2007-07-27 Marcus Brinkmann * get-path.c: New file. * Makefile.am (dirmngr_SOURCES): Add get-path.c. * util.h (default_homedir, get_dirmngr_ldap_path): New prototypes. * dirmngr.c (main): Use default_homedir(). * ldap-url.h: Remove japanese white space (sorry!). Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2007-07-26 19:19:13 UTC (rev 251) +++ trunk/src/ChangeLog 2007-07-27 13:05:47 UTC (rev 252) @@ -1,3 +1,11 @@ +2007-07-27 Marcus Brinkmann + + * get-path.c: New file. + * Makefile.am (dirmngr_SOURCES): Add get-path.c. + * util.h (default_homedir, get_dirmngr_ldap_path): New prototypes. + * dirmngr.c (main): Use default_homedir(). + * ldap-url.h: Remove japanese white space (sorry!). + 2007-07-26 Marcus Brinkmann * ldap.c (pth_yield): Remove macro. Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2007-07-26 19:19:13 UTC (rev 251) +++ trunk/src/Makefile.am 2007-07-27 13:05:47 UTC (rev 252) @@ -44,7 +44,7 @@ certcache.c certcache.h i18n.h util.h \ cdb.h cdblib.c ldap.c http.c http.h misc.c ocsp.c ocsp.h \ estream.c estream.h estream-printf.c estream-printf.h \ - validate.c validate.h exechelp.h exechelp.c + validate.c validate.h exechelp.h exechelp.c get-path.c dirmngr_LDADD = ../jnlib/libjnlib.a $(LIBOBJS) $(LIBASSUAN_PTH_LIBS) \ $(LIBGCRYPT_LIBS) $(KSBA_LIBS) $(PTH_LIBS) $(LIBINTL) Modified: trunk/src/dirmngr.c =================================================================== --- trunk/src/dirmngr.c 2007-07-26 19:19:13 UTC (rev 251) +++ trunk/src/dirmngr.c 2007-07-27 13:05:47 UTC (rev 252) @@ -545,15 +545,7 @@ if (shell && strlen (shell) >= 3 && !strcmp (shell+strlen (shell)-3, "csh") ) csh_style = 1; - opt.homedir = getenv("GNUPGHOME"); - if (!opt.homedir || !*opt.homedir) - { -#ifdef HAVE_DRIVE_LETTERS - opt.homedir = "c:/gnupg"; -#else - opt.homedir = "~/.gnupg"; -#endif - } + opt.homedir = default_homedir (); /* Reset rereadable options to default values. */ parse_rereadable_options (NULL, 0); Modified: trunk/src/ldap-url.h =================================================================== --- trunk/src/ldap-url.h 2007-07-26 19:19:13 UTC (rev 251) +++ trunk/src/ldap-url.h 2007-07-27 13:05:47 UTC (rev 252) @@ -17,15 +17,15 @@ typedef struct ldap_url_desc { struct ldap_url_desc *lud_next; - char?*lud_scheme; - char?*lud_host; - int?lud_port; - char?*lud_dn; - char?**lud_attrs; - int?lud_scope; - char?*lud_filter; - char?**lud_exts; - int?lud_crit_exts; + char *lud_scheme; + char *lud_host; + int lud_port; + char *lud_dn; + char **lud_attrs; + int lud_scope; + char *lud_filter; + char **lud_exts; + int lud_crit_exts; } LDAPURLDesc; #define LDAP_URL_SUCCESS 0x00 Modified: trunk/src/ldap.c =================================================================== --- trunk/src/ldap.c 2007-07-26 19:19:13 UTC (rev 251) +++ trunk/src/ldap.c 2007-07-27 13:05:47 UTC (rev 252) @@ -574,7 +574,7 @@ /* Files: We need to prepare stdin and stdout. We get stderr from the function. */ if (!opt.ldap_wrapper_program || !*opt.ldap_wrapper_program) - pgmname = DIRMNGR_LIBEXECDIR "/dirmngr_ldap"; + pgmname = (char *) get_dirmngr_ldap_path (); else pgmname = opt.ldap_wrapper_program; Modified: trunk/src/util.h =================================================================== --- trunk/src/util.h 2007-07-26 19:19:13 UTC (rev 251) +++ trunk/src/util.h 2007-07-27 13:05:47 UTC (rev 252) @@ -80,5 +80,12 @@ *(p) <= 'F'? (*(p)-'A'+10):(*(p)-'a'+10)) #define xtoi_2(p) ((xtoi_1(p) * 16) + xtoi_1((p)+1)) + +/* Set up the default home directory. The usual --homedir option + should be parsed later. */ +const char *default_homedir (void); +/* Find the dirmngr_ldap program image. */ +const char *get_dirmngr_ldap_path (void); + #endif /*UTIL_H*/ From cvs at cvs.gnupg.org Fri Jul 27 16:55:34 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Fri, 27 Jul 2007 16:55:34 +0200 Subject: [svn] w32pth - r11 - trunk Message-ID: Author: marcus Date: 2007-07-27 16:55:04 +0200 (Fri, 27 Jul 2007) New Revision: 11 Modified: trunk/ChangeLog trunk/w32-pth.c Log: 2007-07-27 Marcus Brinkmann * w32-pth.c (pth_select): Reimplement in terms of pth_select_ev. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-07-26 19:11:47 UTC (rev 10) +++ trunk/ChangeLog 2007-07-27 14:55:04 UTC (rev 11) @@ -1,3 +1,7 @@ +2007-07-27 Marcus Brinkmann + + * w32-pth.c (pth_select): Reimplement in terms of pth_select_ev. + 2007-07-26 Marcus Brinkmann * libw32pth.def: Add pth_rwlock_init, pth_rwlock_acquire, Modified: trunk/w32-pth.c =================================================================== --- trunk/w32-pth.c 2007-07-26 19:11:47 UTC (rev 10) +++ trunk/w32-pth.c 2007-07-27 14:55:04 UTC (rev 11) @@ -481,19 +481,6 @@ } -int -pth_select (int nfd, fd_set * rfds, fd_set * wfds, fd_set * efds, - const struct timeval * timeout) -{ - int n; - - implicit_init (); - enter_pth (__FUNCTION__); - n = select (nfd, rfds, wfds, efds, timeout); - leave_pth (__FUNCTION__); - return n; -} - static void show_event_ring (const char *text, pth_event_t ev) { @@ -599,6 +586,14 @@ int +pth_select (int nfd, fd_set * rfds, fd_set * wfds, fd_set * efds, + const struct timeval * timeout) +{ + return pth_select_ev (nfd, rfds, wfds, efds, timeout, NULL); +} + + +int pth_fdmode (int fd, int mode) { unsigned long val; From cvs at cvs.gnupg.org Fri Jul 27 17:49:08 2007 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Fri, 27 Jul 2007 17:49:08 +0200 Subject: [svn] GnuPG - r4550 - branches/STABLE-BRANCH-1-4/m4 Message-ID: Author: dshaw Date: 2007-07-27 17:48:35 +0200 (Fri, 27 Jul 2007) New Revision: 4550 Modified: branches/STABLE-BRANCH-1-4/m4/ChangeLog branches/STABLE-BRANCH-1-4/m4/ldap.m4 Log: * ldap.m4: If we don't find ldap or winldap, try for mozldap. Modified: branches/STABLE-BRANCH-1-4/m4/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/m4/ChangeLog 2007-07-19 12:46:08 UTC (rev 4549) +++ branches/STABLE-BRANCH-1-4/m4/ChangeLog 2007-07-27 15:48:35 UTC (rev 4550) @@ -1,3 +1,7 @@ +2007-07-27 David Shaw + + * ldap.m4: If we don't find ldap or winldap, try for mozldap. + 2007-01-16 David Shaw * libcurl.m4: Check for curl_easy_escape() and Modified: branches/STABLE-BRANCH-1-4/m4/ldap.m4 =================================================================== --- branches/STABLE-BRANCH-1-4/m4/ldap.m4 2007-07-19 12:46:08 UTC (rev 4549) +++ branches/STABLE-BRANCH-1-4/m4/ldap.m4 2007-07-27 15:48:35 UTC (rev 4550) @@ -1,5 +1,5 @@ dnl Check for LDAP -dnl Copyright (C) 2005 Free Software Foundation, Inc. +dnl Copyright (C) 2005, 2007 Free Software Foundation, Inc. dnl dnl This file is free software, distributed under the terms of the GNU dnl General Public License. As a special exception to the GNU General @@ -33,11 +33,12 @@ CPPFLAGS="${LDAP_CPPFLAGS} ${CPPFLAGS}" _ldap_save_ldflags=$LDFLAGS LDFLAGS="${LDAP_LDFLAGS} ${LDFLAGS}" + _ldap_save_libs=$LIBS for MY_LDAPLIBS in ${LDAPLIBS+"$LDAPLIBS"} "-lldap" "-lldap -llber" "-lldap -llber -lresolv" "-lwldap32"; do - _ldap_save_libs=$LIBS - LIBS="$MY_LDAPLIBS $1 $LIBS" + LIBS="$MY_LDAPLIBS $1 $_ldap_save_libs" + AC_MSG_CHECKING([whether LDAP via \"$MY_LDAPLIBS\" is present and sane]) AC_TRY_LINK([ #ifdef _WIN32 @@ -59,39 +60,62 @@ fi if test "$gnupg_cv_func_ldaplber_init" = yes ; then - AC_DEFINE(NEED_LBER_H,1,[Define if the LDAP library requires including lber.h before ldap.h]) + AC_DEFINE(NEED_LBER_H,1, + [Define if the LDAP library requires including lber.h before ldap.h]) fi if test "$gnupg_cv_func_ldap_init" = yes || \ test "$gnupg_cv_func_ldaplber_init" = yes ; then LDAPLIBS="$LDAP_LDFLAGS $MY_LDAPLIBS" GPGKEYS_LDAP="gpgkeys_ldap$EXEEXT" + break + fi + done - AC_CHECK_FUNCS(ldap_get_option ldap_set_option ldap_start_tls_s) + if test "$GPGKEYS_LDAP" = "" ; then + # It didn't work, so try for mozldap. We only do this via + # pkg-config due to a really impressive dependency list. + AC_PATH_PROG([_pkg_config],[pkg-config]) + if test x$_pkg_config != x ; then + AC_MSG_CHECKING([for mozldap]) + LDAPLIBS=`$_pkg_config --libs mozldap 2>/dev/null` + LDAP_CPPFLAGS=`$_pkg_config --cflags mozldap 2>/dev/null` + if test x"$LDAPLIBS" = x && test x"$LDAP_CPPFLAGS" = x; then + AC_MSG_RESULT([no]) + else + AC_MSG_RESULT([yes]) + LIBS="$LDAPLIBS" + GPGKEYS_LDAP="gpgkeys_ldap$EXEEXT" + CPPFLAGS="${LDAP_CPPFLAGS} ${CPPFLAGS}" + AC_CHECK_HEADERS([ldap_ssl.h],,,[#include ]) + fi + fi + fi - if test "$ac_cv_func_ldap_get_option" != yes ; then - AC_MSG_CHECKING([whether LDAP supports ld_errno]) - AC_TRY_LINK([#include ],[LDAP *ldap; ldap->ld_errno;], - [gnupg_cv_func_ldap_ld_errno=yes], - [gnupg_cv_func_ldap_ld_errno=no]) - AC_MSG_RESULT([$gnupg_cv_func_ldap_ld_errno]) + if test "$GPGKEYS_LDAP" != "" ; then + # Whichever library we ended up with, check for some features... + AC_CHECK_FUNCS(ldap_get_option ldap_set_option ldap_start_tls_s) - if test "$gnupg_cv_func_ldap_ld_errno" = yes ; then - AC_DEFINE(HAVE_LDAP_LD_ERRNO,1,[Define if the LDAP library supports ld_errno]) - fi - fi - fi + if test "$ac_cv_func_ldap_get_option" != yes ; then + AC_MSG_CHECKING([whether LDAP supports ld_errno]) + AC_TRY_LINK([#include ],[LDAP *ldap; ldap->ld_errno;], + [gnupg_cv_func_ldap_ld_errno=yes], + [gnupg_cv_func_ldap_ld_errno=no]) + AC_MSG_RESULT([$gnupg_cv_func_ldap_ld_errno]) - LIBS=$_ldap_save_libs + if test "$gnupg_cv_func_ldap_ld_errno" = yes ; then + AC_DEFINE(HAVE_LDAP_LD_ERRNO,1, + [Define if the LDAP library supports ld_errno]) + fi + fi + fi - if test "$GPGKEYS_LDAP" != "" ; then break; fi - done + LIBS=$_ldap_save_libs + CPPFLAGS=$_ldap_save_cppflags + LDFLAGS=$_ldap_save_ldflags AC_SUBST(GPGKEYS_LDAP) AC_SUBST(LDAPLIBS) AC_SUBST(LDAP_CPPFLAGS) - - CPPFLAGS=$_ldap_save_cppflags - LDFLAGS=$_ldap_save_ldflags fi ])dnl From cvs at cvs.gnupg.org Fri Jul 27 18:06:49 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Fri, 27 Jul 2007 18:06:49 +0200 Subject: [svn] dirmngr - r253 - trunk/src Message-ID: Author: marcus Date: 2007-07-27 18:06:18 +0200 (Fri, 27 Jul 2007) New Revision: 253 Modified: trunk/src/ChangeLog trunk/src/estream.c trunk/src/estream.h Log: 2007-07-27 Marcus Brinkmann * estream.h, estream.c: Update from recent GnuPG. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2007-07-27 13:05:47 UTC (rev 252) +++ trunk/src/ChangeLog 2007-07-27 16:06:18 UTC (rev 253) @@ -1,5 +1,7 @@ 2007-07-27 Marcus Brinkmann + * estream.h, estream.c: Update from recent GnuPG. + * get-path.c: New file. * Makefile.am (dirmngr_SOURCES): Add get-path.c. * util.h (default_homedir, get_dirmngr_ldap_path): New prototypes. Modified: trunk/src/estream.c =================================================================== --- trunk/src/estream.c 2007-07-27 13:05:47 UTC (rev 252) +++ trunk/src/estream.c 2007-07-27 16:06:18 UTC (rev 253) @@ -67,6 +67,10 @@ +#ifndef O_BINARY +#define O_BINARY 0 +#endif + /* Generally used types. */ typedef void *(*func_realloc_t) (void *mem, size_t size); @@ -139,8 +143,6 @@ #define ES_DEFAULT_OPEN_MODE (S_IRUSR | S_IWUSR) -#define ES_FLAG_WRITING ES__FLAG_WRITING - /* An internal stream object. */ struct estream_internal @@ -148,9 +150,9 @@ unsigned char buffer[BUFFER_BLOCK_SIZE]; unsigned char unread_buffer[BUFFER_UNREAD_SIZE]; estream_mutex_t lock; /* Lock. */ - void *cookie; /* Cookie. */ - void *opaque; /* Opaque data. */ - unsigned int flags; /* Flags. */ + void *cookie; /* Cookie. */ + void *opaque; /* Opaque data. */ + unsigned int modeflags; /* Flags for the backend. */ off_t offset; es_cookie_read_function_t func_read; es_cookie_write_function_t func_write; @@ -305,7 +307,7 @@ if (!initialized) { - if (!pth_init ()) + if (!pth_init () && errno != EPERM ) return -1; if (pth_mutex_init (&estream_list_lock)) initialized = 1; @@ -325,7 +327,7 @@ /* Cookie for memory objects. */ typedef struct estream_cookie_mem { - unsigned int flags; /* Open flags. */ + unsigned int modeflags; /* Open flags. */ unsigned char *memory; /* Data. */ size_t memory_size; /* Size of MEMORY. */ size_t offset; /* Current offset in MEMORY. */ @@ -349,7 +351,7 @@ unsigned int append_zero, unsigned int dont_free, char **ptr, size_t *size, func_realloc_t func_realloc, func_free_t func_free, - unsigned int flags) + unsigned int modeflags) { estream_cookie_mem_t mem_cookie; int err; @@ -359,7 +361,7 @@ err = -1; else { - mem_cookie->flags = flags; + mem_cookie->modeflags = modeflags; mem_cookie->memory = data; mem_cookie->memory_size = data_n; mem_cookie->offset = 0; @@ -416,7 +418,7 @@ { /* Regular write. */ - if (mem_cookie->flags & O_APPEND) + if (mem_cookie->modeflags & O_APPEND) /* Append to data. */ mem_cookie->offset = mem_cookie->data_len; @@ -593,17 +595,20 @@ es_func_mem_destroy }; + + /* Implementation of fd I/O. */ /* Cookie for fd objects. */ typedef struct estream_cookie_fd { - int fd; + int fd; /* The file descriptor we are using for actual output. */ + int no_close; /* If set we won't close the file descriptor. */ } *estream_cookie_fd_t; /* Create function for fd objects. */ static int -es_func_fd_create (void **cookie, int fd, unsigned int flags) +es_func_fd_create (void **cookie, int fd, unsigned int modeflags, int no_close) { estream_cookie_fd_t fd_cookie; int err; @@ -613,7 +618,13 @@ err = -1; else { +#ifdef HAVE_DOSISH_SYSTEM + /* Make sure it is in binary mode if requested. */ + if ( (modeflags & O_BINARY) ) + setmode (fd, O_BINARY); +#endif fd_cookie->fd = fd; + fd_cookie->no_close = no_close; *cookie = fd_cookie; err = 0; } @@ -680,7 +691,7 @@ if (fd_cookie) { - err = close (fd_cookie->fd); + err = fd_cookie->no_close? 0 : close (fd_cookie->fd); ES_MEM_FREE (fd_cookie); } else @@ -689,6 +700,7 @@ return err; } + static es_cookie_io_functions_t estream_functions_fd = { es_func_fd_read, @@ -697,12 +709,132 @@ es_func_fd_destroy }; + + + +/* Implementation of FILE* I/O. */ + +/* Cookie for fp objects. */ +typedef struct estream_cookie_fp +{ + FILE *fp; /* The file pointer we are using for actual output. */ + int no_close; /* If set we won't close the file pointer. */ +} *estream_cookie_fp_t; + +/* Create function for fd objects. */ +static int +es_func_fp_create (void **cookie, FILE *fp, unsigned int modeflags, int no_close) +{ + estream_cookie_fp_t fp_cookie; + int err; + + fp_cookie = ES_MEM_ALLOC (sizeof *fp_cookie); + if (!fp_cookie) + err = -1; + else + { +#ifdef HAVE_DOSISH_SYSTEM + /* Make sure it is in binary mode if requested. */ + if ( (modeflags & O_BINARY) ) + setmode (fileno (fp), O_BINARY); +#endif + fp_cookie->fp = fp; + fp_cookie->no_close = no_close; + *cookie = fp_cookie; + err = 0; + } + + return err; +} + +/* Read function for FILE* objects. */ +static ssize_t +es_func_fp_read (void *cookie, void *buffer, size_t size) + +{ + estream_cookie_fp_t file_cookie = cookie; + ssize_t bytes_read; + + bytes_read = fread (buffer, 1, size, file_cookie->fp); + if (!bytes_read && ferror (file_cookie->fp)) + return -1; + return bytes_read; +} + +/* Write function for FILE* objects. */ +static ssize_t +es_func_fp_write (void *cookie, const void *buffer, size_t size) + +{ + estream_cookie_fp_t file_cookie = cookie; + size_t bytes_written; + + bytes_written = fwrite (buffer, 1, size, file_cookie->fp); + if (bytes_written != size) + return -1; + return bytes_written; +} + +/* Seek function for FILE* objects. */ +static int +es_func_fp_seek (void *cookie, off_t *offset, int whence) +{ + estream_cookie_fp_t file_cookie = cookie; + long int offset_new; + + if ( fseek (file_cookie->fp, (long int)*offset, whence) ) + { + fprintf (stderr, "\nfseek failed: errno=%d (%s)\n", errno,strerror (errno)); + return -1; + } + + offset_new = ftell (file_cookie->fp); + if (offset_new == -1) + { + fprintf (stderr, "\nftell failed: errno=%d (%s)\n", errno,strerror (errno)); + return -1; + } + *offset = offset_new; + return 0; +} + +/* Destroy function for fd objects. */ +static int +es_func_fp_destroy (void *cookie) +{ + estream_cookie_fp_t fp_cookie = cookie; + int err; + + if (fp_cookie) + { + fflush (fp_cookie->fp); + err = fp_cookie->no_close? 0 : fclose (fp_cookie->fp); + ES_MEM_FREE (fp_cookie); + } + else + err = 0; + + return err; +} + + +static es_cookie_io_functions_t estream_functions_fp = + { + es_func_fp_read, + es_func_fp_write, + es_func_fp_seek, + es_func_fp_destroy + }; + + + + /* Implementation of file I/O. */ /* Create function for file objects. */ static int es_func_file_create (void **cookie, int *filedes, - const char *path, unsigned int flags) + const char *path, unsigned int modeflags) { estream_cookie_fd_t file_cookie; int err; @@ -718,14 +850,20 @@ goto out; } - fd = open (path, flags, ES_DEFAULT_OPEN_MODE); + fd = open (path, modeflags, ES_DEFAULT_OPEN_MODE); if (fd == -1) { err = -1; goto out; } +#ifdef HAVE_DOSISH_SYSTEM + /* Make sure it is in binary mode if requested. */ + if ( (modeflags & O_BINARY) ) + setmode (fd, O_BINARY); +#endif file_cookie->fd = fd; + file_cookie->no_close = 0; *cookie = file_cookie; *filedes = fd; @@ -750,16 +888,10 @@ /* Stream primitives. */ static int -es_convert_mode (const char *mode, unsigned int *flags) +es_convert_mode (const char *mode, unsigned int *modeflags) { - /* FIXME: We need to allow all mode flags permutations and for - binary mode we need to do a - - #ifdef HAVE_DOSISH_SYSTEM - setmode (fd, O_BINARY); - #endif - */ + /* FIXME: We need to allow all mode flags permutations. */ struct { const char *mode; @@ -767,33 +899,34 @@ } mode_flags[] = { { "r", O_RDONLY }, { "rb", - O_RDONLY }, + O_RDONLY | O_BINARY }, { "w", O_WRONLY | O_TRUNC | O_CREAT }, { "wb", - O_WRONLY | O_TRUNC | O_CREAT }, + O_WRONLY | O_TRUNC | O_CREAT | O_BINARY }, { "a", O_WRONLY | O_APPEND | O_CREAT }, { "ab", - O_WRONLY | O_APPEND | O_CREAT }, + O_WRONLY | O_APPEND | O_CREAT | O_BINARY }, { "r+", O_RDWR }, { "rb+", - O_RDWR }, + O_RDWR | O_BINARY }, { "r+b", - O_RDONLY | O_WRONLY }, + O_RDONLY | O_WRONLY | O_BINARY }, { "w+", O_RDWR | O_TRUNC | O_CREAT }, { "wb+", - O_RDWR | O_TRUNC | O_CREAT }, + O_RDWR | O_TRUNC | O_CREAT | O_BINARY }, { "w+b", - O_RDWR | O_TRUNC | O_CREAT }, + O_RDWR | O_TRUNC | O_CREAT | O_BINARY }, { "a+", O_RDWR | O_CREAT | O_APPEND }, { "ab+", - O_RDWR | O_CREAT | O_APPEND }, + O_RDWR | O_CREAT | O_APPEND | O_BINARY }, { "a+b", - O_RDWR | O_CREAT | O_APPEND } }; + O_RDWR | O_CREAT | O_APPEND | O_BINARY } + }; unsigned int i; int err; @@ -808,7 +941,7 @@ else { err = 0; - *flags = mode_flags[i].flags; + *modeflags = mode_flags[i].flags; } return err; @@ -868,7 +1001,7 @@ es_cookie_write_function_t func_write = stream->intern->func_write; int err; - assert (stream->flags & ES_FLAG_WRITING); + assert (stream->flags.writing); if (stream->data_offset) { @@ -935,7 +1068,7 @@ static void es_empty (estream_t stream) { - assert (! (stream->flags & ES_FLAG_WRITING)); + assert (!stream->flags.writing); stream->data_len = 0; stream->data_offset = 0; stream->unread_data_len = 0; @@ -944,7 +1077,8 @@ /* Initialize STREAM. */ static void es_initialize (estream_t stream, - void *cookie, int fd, es_cookie_io_functions_t functions) + void *cookie, int fd, es_cookie_io_functions_t functions, + unsigned int modeflags) { stream->intern->cookie = cookie; stream->intern->opaque = NULL; @@ -967,7 +1101,15 @@ stream->data_offset = 0; stream->data_flushed = 0; stream->unread_data_len = 0; - stream->flags = 0; + /* Depending on the modeflags we set whether we start in writing or + reading mode. This is required in case we are working on a + wronly stream which is not seeekable (like stdout). Without this + pre-initialization we would do a seek at the first write call and + as this will fail no utput will be delivered. */ + if ((modeflags & O_WRONLY) || (modeflags & O_RDWR) ) + stream->flags.writing = 1; + else + stream->flags.writing = 0; } /* Deinitialize STREAM. */ @@ -988,7 +1130,7 @@ func_close = stream->intern->func_close; err = 0; - if (stream->flags & ES_FLAG_WRITING) + if (stream->flags.writing) SET_UNLESS_NONZERO (err, tmp_err, es_flush (stream)); if (func_close) SET_UNLESS_NONZERO (err, tmp_err, (*func_close) (stream->intern->cookie)); @@ -1000,7 +1142,7 @@ /* Create a new stream object, initialize it. */ static int es_create (estream_t *stream, void *cookie, int fd, - es_cookie_io_functions_t functions) + es_cookie_io_functions_t functions, unsigned int modeflags) { estream_internal_t stream_internal_new; estream_t stream_new; @@ -1030,7 +1172,7 @@ stream_new->intern = stream_internal_new; ESTREAM_MUTEX_INITIALIZE (stream_new->intern->lock); - es_initialize (stream_new, cookie, fd, functions); + es_initialize (stream_new, cookie, fd, functions, modeflags); err = es_list_add (stream_new); if (err) @@ -1186,13 +1328,13 @@ data_read = 0; err = 0; - if (stream->flags & ES_FLAG_WRITING) + if (stream->flags.writing) { /* Switching to reading mode -> flush output. */ err = es_flush (stream); if (err) goto out; - stream->flags &= ~ES_FLAG_WRITING; + stream->flags.writing = 0; } /* Read unread data first. */ @@ -1274,14 +1416,14 @@ goto out; } - if (stream->flags & ES_FLAG_WRITING) + if (stream->flags.writing) { /* Flush data first in order to prevent flushing it to the wrong offset. */ err = es_flush (stream); if (err) goto out; - stream->flags &= ~ES_FLAG_WRITING; + stream->flags.writing = 0; } off = offset; @@ -1451,7 +1593,7 @@ data_written = 0; err = 0; - if (! (stream->flags & ES_FLAG_WRITING)) + if (!stream->flags.writing) { /* Switching to writing mode -> discard input data and seek to position at which reading has stopped. We can do this only @@ -1489,8 +1631,8 @@ if (bytes_written) *bytes_written = data_written; if (data_written) - if (! (stream->flags & ES_FLAG_WRITING)) - stream->flags |= ES_FLAG_WRITING; + if (!stream->flags.writing) + stream->flags.writing = 1; return err; } @@ -1502,13 +1644,13 @@ { int err; - if (stream->flags & ES_FLAG_WRITING) + if (stream->flags.writing) { /* Switching to reading mode -> flush output. */ err = es_flush (stream); if (err) goto out; - stream->flags &= ~ES_FLAG_WRITING; + stream->flags.writing = 0; } if (stream->data_offset == stream->data_len) @@ -1572,12 +1714,13 @@ line_stream_cookie = NULL; err = es_func_mem_create (&line_stream_cookie, NULL, 0, 0, BUFFER_BLOCK_SIZE, - 1, 0, 0, NULL, 0, ES_MEM_REALLOC, ES_MEM_FREE, O_RDWR); + 1, 0, 0, NULL, 0, ES_MEM_REALLOC, ES_MEM_FREE, + O_RDWR); if (err) goto out; err = es_create (&line_stream, line_stream_cookie, -1, - estream_functions_mem); + estream_functions_mem, O_RDWR); if (err) goto out; @@ -1738,7 +1881,7 @@ int err; /* Flush or empty buffer depending on mode. */ - if (stream->flags & ES_FLAG_WRITING) + if (stream->flags.writing) { err = es_flush (stream); if (err) @@ -1839,7 +1982,7 @@ estream_t es_fopen (const char *ES__RESTRICT path, const char *ES__RESTRICT mode) { - unsigned int flags; + unsigned int modeflags; int create_called; estream_t stream; void *cookie; @@ -1850,16 +1993,16 @@ cookie = NULL; create_called = 0; - err = es_convert_mode (mode, &flags); + err = es_convert_mode (mode, &modeflags); if (err) goto out; - err = es_func_file_create (&cookie, &fd, path, flags); + err = es_func_file_create (&cookie, &fd, path, modeflags); if (err) goto out; create_called = 1; - err = es_create (&stream, cookie, fd, estream_functions_file); + err = es_create (&stream, cookie, fd, estream_functions_file, modeflags); if (err) goto out; @@ -1878,7 +2021,7 @@ func_realloc_t func_realloc, func_free_t func_free, const char *ES__RESTRICT mode) { - unsigned int flags; + unsigned int modeflags; int create_called; estream_t stream; void *cookie; @@ -1888,18 +2031,18 @@ stream = NULL; create_called = 0; - err = es_convert_mode (mode, &flags); + err = es_convert_mode (mode, &modeflags); if (err) goto out; err = es_func_mem_create (&cookie, data, data_n, data_len, BUFFER_BLOCK_SIZE, grow, 0, 0, - NULL, 0, func_realloc, func_free, flags); + NULL, 0, func_realloc, func_free, modeflags); if (err) goto out; create_called = 1; - err = es_create (&stream, cookie, -1, estream_functions_mem); + err = es_create (&stream, cookie, -1, estream_functions_mem, modeflags); out: @@ -1913,25 +2056,25 @@ estream_t es_open_memstream (char **ptr, size_t *size) { - unsigned int flags; + unsigned int modeflags; int create_called; estream_t stream; void *cookie; int err; - flags = O_RDWR; + modeflags = O_RDWR; create_called = 0; stream = NULL; cookie = 0; err = es_func_mem_create (&cookie, NULL, 0, 0, BUFFER_BLOCK_SIZE, 1, 1, 1, - ptr, size, ES_MEM_REALLOC, ES_MEM_FREE, flags); + ptr, size, ES_MEM_REALLOC, ES_MEM_FREE, modeflags); if (err) goto out; create_called = 1; - err = es_create (&stream, cookie, -1, estream_functions_mem); + err = es_create (&stream, cookie, -1, estream_functions_mem, modeflags); out: @@ -1947,18 +2090,18 @@ const char *ES__RESTRICT mode, es_cookie_io_functions_t functions) { - unsigned int flags; + unsigned int modeflags; estream_t stream; int err; stream = NULL; - flags = 0; + modeflags = 0; - err = es_convert_mode (mode, &flags); + err = es_convert_mode (mode, &modeflags); if (err) goto out; - err = es_create (&stream, cookie, -1, functions); + err = es_create (&stream, cookie, -1, functions, modeflags); if (err) goto out; @@ -1969,9 +2112,9 @@ estream_t -es_fdopen (int filedes, const char *mode) +do_fdopen (int filedes, const char *mode, int no_close) { - unsigned int flags; + unsigned int modeflags; int create_called; estream_t stream; void *cookie; @@ -1981,16 +2124,16 @@ cookie = NULL; create_called = 0; - err = es_convert_mode (mode, &flags); + err = es_convert_mode (mode, &modeflags); if (err) goto out; - err = es_func_fd_create (&cookie, filedes, flags); + err = es_func_fd_create (&cookie, filedes, modeflags, no_close); if (err) goto out; create_called = 1; - err = es_create (&stream, cookie, filedes, estream_functions_fd); + err = es_create (&stream, cookie, filedes, estream_functions_fd, modeflags); out: @@ -1999,9 +2142,80 @@ return stream; } + +estream_t +es_fdopen (int filedes, const char *mode) +{ + return do_fdopen (filedes, mode, 0); +} + +/* A variant of es_fdopen which does not close FILEDES at the end. */ +estream_t +es_fdopen_nc (int filedes, const char *mode) +{ + return do_fdopen (filedes, mode, 1); +} + + +estream_t +do_fpopen (FILE *fp, const char *mode, int no_close) +{ + unsigned int modeflags; + int create_called; + estream_t stream; + void *cookie; + int err; + + stream = NULL; + cookie = NULL; + create_called = 0; + + err = es_convert_mode (mode, &modeflags); + if (err) + goto out; + + fflush (fp); + err = es_func_fp_create (&cookie, fp, modeflags, no_close); + if (err) + goto out; + + create_called = 1; + err = es_create (&stream, cookie, fileno (fp), estream_functions_fp, + modeflags); + + out: + + if (err && create_called) + (*estream_functions_fp.func_close) (cookie); + + return stream; +} + +/* Create an estream from the stdio stream FP. This mechanism is + useful in case the stdio streams have special properties and may + not be mixed with fd based functions. This is for example the case + under Windows where the 3 standard streams are associated with the + console whereas a duped and fd-opened stream of one of this stream + won't be associated with the console. As this messes things up it + is easier to keep on using the standard I/O stream as a backend for + estream. */ +estream_t +es_fpopen (FILE *fp, const char *mode) +{ + return do_fpopen (fp, mode, 0); +} + +/* Same as es_fpopen but does not close FP at the end. */ estream_t +es_fpopen_nc (FILE *fp, const char *mode) +{ + return do_fpopen (fp, mode, 1); +} + + +estream_t es_freopen (const char *ES__RESTRICT path, const char *ES__RESTRICT mode, estream_t ES__RESTRICT stream) { @@ -2009,7 +2223,7 @@ if (path) { - unsigned int flags; + unsigned int modeflags; int create_called; void *cookie; int fd; @@ -2021,16 +2235,16 @@ es_deinitialize (stream); - err = es_convert_mode (mode, &flags); + err = es_convert_mode (mode, &modeflags); if (err) goto leave; - err = es_func_file_create (&cookie, &fd, path, flags); + err = es_func_file_create (&cookie, &fd, path, modeflags); if (err) goto leave; create_called = 1; - es_initialize (stream, cookie, fd, estream_functions_file); + es_initialize (stream, cookie, fd, estream_functions_file, modeflags); leave: @@ -2173,7 +2387,7 @@ if (stream) { ESTREAM_LOCK (stream); - if (stream->flags & ES_FLAG_WRITING) + if (stream->flags.writing) err = es_flush (stream); else { @@ -2686,7 +2900,7 @@ estream_t es_tmpfile (void) { - unsigned int flags; + unsigned int modeflags; int create_called; estream_t stream; void *cookie; @@ -2695,7 +2909,7 @@ create_called = 0; stream = NULL; - flags = O_RDWR | O_TRUNC | O_CREAT; + modeflags = O_RDWR | O_TRUNC | O_CREAT; cookie = NULL; fd = tmpfd (); @@ -2705,12 +2919,12 @@ goto out; } - err = es_func_fd_create (&cookie, fd, flags); + err = es_func_fd_create (&cookie, fd, modeflags, 0); if (err) goto out; create_called = 1; - err = es_create (&stream, cookie, fd, estream_functions_fd); + err = es_create (&stream, cookie, fd, estream_functions_fd, modeflags); out: Modified: trunk/src/estream.h =================================================================== --- trunk/src/estream.h 2007-07-27 13:05:47 UTC (rev 252) +++ trunk/src/estream.h 2007-07-27 16:06:18 UTC (rev 253) @@ -45,6 +45,9 @@ #define es_mopen _ESTREAM_PREFIX(es_mopen) #define es_open_memstream _ESTREAM_PREFIX(es_open_memstream) #define es_fdopen _ESTREAM_PREFIX(es_fdopen) +#define es_fdopen_nc _ESTREAM_PREFIX(es_fdopen_nc) +#define es_fpopen _ESTREAM_PREFIX(es_fpopen) +#define es_fpopen_nc _ESTREAM_PREFIX(es_fpopen_nc) #define es_freopen _ESTREAM_PREFIX(es_freopen) #define es_fopencookie _ESTREAM_PREFIX(es_fopencookie) #define es_fclose _ESTREAM_PREFIX(es_fclose) @@ -136,8 +139,10 @@ size_t unread_data_len; /* Various flags. */ -#define ES__FLAG_WRITING (1 << 0) - unsigned int flags; + struct { + unsigned int writing: 1; + unsigned int reserved: 7; + } flags; /* A pointer to our internal data for this stream. */ struct estream_internal *intern; @@ -197,6 +202,9 @@ const char *ES__RESTRICT mode); estream_t es_open_memstream (char **ptr, size_t *size); estream_t es_fdopen (int filedes, const char *mode); +estream_t es_fdopen_nc (int filedes, const char *mode); +estream_t es_fpopen (FILE *fp, const char *mode); +estream_t es_fpopen_nc (FILE *fp, const char *mode); estream_t es_freopen (const char *ES__RESTRICT path, const char *ES__RESTRICT mode, estream_t ES__RESTRICT stream); @@ -232,14 +240,14 @@ int _es_putc_overflow (int c, estream_t stream); #define es_getc_unlocked(stream) \ - (((! ((stream)->flags & 1)) \ + (((!(stream)->flags.writing) \ && ((stream)->data_offset < (stream)->data_len) \ && (! (stream)->unread_data_len)) \ ? ((int) (stream)->buffer[((stream)->data_offset)++]) \ : _es_getc_underflow ((stream))) #define es_putc_unlocked(c, stream) \ - ((((stream)->flags & 1) \ + (((stream)->flags.writing \ && ((stream)->data_offset < (stream)->buffer_size) \ && (c != '\n')) \ ? ((int) ((stream)->buffer[((stream)->data_offset)++] = (c))) \ From cvs at cvs.gnupg.org Fri Jul 27 18:33:40 2007 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Fri, 27 Jul 2007 18:33:40 +0200 Subject: [svn] GnuPG - r4552 - branches/STABLE-BRANCH-1-4/keyserver Message-ID: Author: dshaw Date: 2007-07-27 18:33:05 +0200 (Fri, 27 Jul 2007) New Revision: 4552 Modified: branches/STABLE-BRANCH-1-4/keyserver/ChangeLog branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_ldap.c Log: * gpgkeys_ldap.c: Fix build warning with mozldap. Modified: branches/STABLE-BRANCH-1-4/keyserver/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/keyserver/ChangeLog 2007-07-27 16:21:18 UTC (rev 4551) +++ branches/STABLE-BRANCH-1-4/keyserver/ChangeLog 2007-07-27 16:33:05 UTC (rev 4552) @@ -1,5 +1,7 @@ 2007-07-27 David Shaw + * gpgkeys_ldap.c: Fix build warning with mozldap. + * gpgkeys_ldap.c (search_key, main): Fix bug where searching for foo bar (no quotes) on the command line resulted in searching for "foo\2Abar" due to LDAP quoting. The proper search is "foo*bar". Modified: branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_ldap.c =================================================================== --- branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_ldap.c 2007-07-27 16:21:18 UTC (rev 4551) +++ branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_ldap.c 2007-07-27 16:33:05 UTC (rev 4552) @@ -55,6 +55,11 @@ #include #endif +/* For mozldap */ +#ifdef HAVE_LDAP_SSL_H +#include +#endif + #include "compat.h" #include "keyserver.h" #include "ksutil.h" From cvs at cvs.gnupg.org Fri Jul 27 18:21:51 2007 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Fri, 27 Jul 2007 18:21:51 +0200 Subject: [svn] GnuPG - r4551 - branches/STABLE-BRANCH-1-4/keyserver Message-ID: Author: dshaw Date: 2007-07-27 18:21:18 +0200 (Fri, 27 Jul 2007) New Revision: 4551 Modified: branches/STABLE-BRANCH-1-4/keyserver/ChangeLog branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_ldap.c Log: * gpgkeys_ldap.c (search_key, main): Fix bug where searching for foo bar (no quotes) on the command line resulted in searching for "foo\2Abar" due to LDAP quoting. The proper search is "foo*bar". Modified: branches/STABLE-BRANCH-1-4/keyserver/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/keyserver/ChangeLog 2007-07-27 15:48:35 UTC (rev 4550) +++ branches/STABLE-BRANCH-1-4/keyserver/ChangeLog 2007-07-27 16:21:18 UTC (rev 4551) @@ -1,3 +1,9 @@ +2007-07-27 David Shaw + + * gpgkeys_ldap.c (search_key, main): Fix bug where searching for + foo bar (no quotes) on the command line resulted in searching for + "foo\2Abar" due to LDAP quoting. The proper search is "foo*bar". + 2007-04-16 David Shaw * gpgkeys_hkp.c (main): Show curl or fake-curl version string. Modified: branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_ldap.c =================================================================== --- branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_ldap.c 2007-07-27 15:48:35 UTC (rev 4550) +++ branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_ldap.c 2007-07-27 16:21:18 UTC (rev 4551) @@ -1291,18 +1291,25 @@ static int search_key(const char *searchkey) { - char **vals; + char **vals,*search; LDAPMessage *res,*each; int err,count=0; struct keylist *dupelist=NULL; /* The maximum size of the search, including the optional stuff and the trailing \0 */ - char search[2+1+9+1+3+(MAX_LINE*3)+3+1+15+14+1+1+20]; char *attrs[]={"pgpcertid","pgpuserid","pgprevoked","pgpdisabled", "pgpkeycreatetime","pgpkeyexpiretime","modifytimestamp", "pgpkeysize","pgpkeytype",NULL}; enum ks_search_type search_type; + search=malloc(2+1+9+1+3+strlen(searchkey)+3+1+15+14+1+1+20); + if(!search) + { + fprintf(console,"gpgkeys: out of memory when building search list\n"); + fprintf(output,"SEARCH %s FAILED %d\n",searchkey,KEYSERVER_NO_MEMORY); + return KEYSERVER_NO_MEMORY; + } + fprintf(output,"SEARCH %s BEGIN\n",searchkey); search_type=classify_ks_search(&searchkey); @@ -1357,7 +1364,7 @@ break; } - ldap_quote(search,searchkey); + strcat(search,searchkey); switch(search_type) { @@ -1395,6 +1402,7 @@ err=ldap_search_s(ldap,basekeyspacedn, LDAP_SCOPE_SUBTREE,search,attrs,0,&res); + free(search); if(err!=LDAP_SUCCESS && err!=LDAP_SIZELIMIT_EXCEEDED) { int errtag=ldap_err_to_gpg_err(err); @@ -2311,7 +2319,7 @@ keyptr=keyptr->next; } - searchkey=malloc(len+1); + searchkey=malloc((len*3)+1); if(searchkey==NULL) { ret=KEYSERVER_NO_MEMORY; @@ -2324,7 +2332,7 @@ keyptr=keylist; while(keyptr!=NULL) { - strcat(searchkey,keyptr->str); + ldap_quote(searchkey,keyptr->str); strcat(searchkey,"*"); keyptr=keyptr->next; } From cvs at cvs.gnupg.org Sun Jul 29 04:58:55 2007 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Sun, 29 Jul 2007 04:58:55 +0200 Subject: [svn] GnuPG - r4553 - branches/STABLE-BRANCH-1-4/keyserver Message-ID: Author: dshaw Date: 2007-07-29 04:58:26 +0200 (Sun, 29 Jul 2007) New Revision: 4553 Modified: branches/STABLE-BRANCH-1-4/keyserver/ChangeLog branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_ldap.c Log: * gpgkeys_ldap.c (main): Fix bug in setting up whether to verify peer SSL cert. This used to work with older OpenLDAP, but is now more strictly handled. Modified: branches/STABLE-BRANCH-1-4/keyserver/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/keyserver/ChangeLog 2007-07-27 16:33:05 UTC (rev 4552) +++ branches/STABLE-BRANCH-1-4/keyserver/ChangeLog 2007-07-29 02:58:26 UTC (rev 4553) @@ -1,3 +1,9 @@ +2007-07-28 David Shaw + + * gpgkeys_ldap.c (main): Fix bug in setting up whether to verify + peer SSL cert. This used to work with older OpenLDAP, but is now + more strictly handled. + 2007-07-27 David Shaw * gpgkeys_ldap.c: Fix build warning with mozldap. Modified: branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_ldap.c =================================================================== --- branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_ldap.c 2007-07-27 16:33:05 UTC (rev 4552) +++ branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_ldap.c 2007-07-29 02:58:26 UTC (rev 4553) @@ -2188,7 +2188,7 @@ else ver=LDAP_OPT_X_TLS_NEVER; - err=ldap_set_option(ldap,LDAP_OPT_X_TLS_REQUIRE_CERT,&ver); + err=ldap_set_option(NULL,LDAP_OPT_X_TLS_REQUIRE_CERT,&ver); } #endif From cvs at cvs.gnupg.org Mon Jul 30 23:33:59 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 30 Jul 2007 23:33:59 +0200 Subject: [svn] dirmngr - r254 - trunk/src Message-ID: Author: marcus Date: 2007-07-30 23:33:28 +0200 (Mon, 30 Jul 2007) New Revision: 254 Modified: trunk/src/ChangeLog trunk/src/ldap-url.c Log: 2007-07-30 Marcus Brinkmann * ldap-url.c (ldap_str2charray): Fix buglet in ldap_utf8_strchr invocation. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2007-07-27 16:06:18 UTC (rev 253) +++ trunk/src/ChangeLog 2007-07-30 21:33:28 UTC (rev 254) @@ -1,3 +1,7 @@ +2007-07-30 Marcus Brinkmann + + * ldap-url.c (ldap_str2charray): Fix buglet in ldap_utf8_strchr invocation. + 2007-07-27 Marcus Brinkmann * estream.h, estream.c: Update from recent GnuPG. Modified: trunk/src/ldap-url.c =================================================================== --- trunk/src/ldap-url.c 2007-07-27 16:06:18 UTC (rev 253) +++ trunk/src/ldap-url.c 2007-07-30 21:33:28 UTC (rev 254) @@ -273,7 +273,7 @@ i = 1; for ( s = str; *s; s++ ) { - if ( ldap_utf8_strchr( brkstr, s ) != NULL ) { + if ( ldap_utf8_strchr( brkstr, *s ) != NULL ) { i++; } } From cvs at cvs.gnupg.org Tue Jul 31 00:03:58 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue, 31 Jul 2007 00:03:58 +0200 Subject: [svn] dirmngr - r255 - trunk/src Message-ID: Author: marcus Date: 2007-07-31 00:03:27 +0200 (Tue, 31 Jul 2007) New Revision: 255 Modified: trunk/src/ChangeLog trunk/src/http.c Log: 2007-07-31 Marcus Brinkmann * http.c: Include . (http_wait_response) [HAVE_W32_SYSTEM]: Use DuplicateHandle. (cookie_read): Use pth_read instead read. (cookie_write): Use pth_write instead write. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2007-07-30 21:33:28 UTC (rev 254) +++ trunk/src/ChangeLog 2007-07-30 22:03:27 UTC (rev 255) @@ -1,3 +1,10 @@ +2007-07-31 Marcus Brinkmann + + * http.c: Include . + (http_wait_response) [HAVE_W32_SYSTEM]: Use DuplicateHandle. + (cookie_read): Use pth_read instead read. + (cookie_write): Use pth_write instead write. + 2007-07-30 Marcus Brinkmann * ldap-url.c (ldap_str2charray): Fix buglet in ldap_utf8_strchr invocation. Modified: trunk/src/http.c =================================================================== --- trunk/src/http.c 2007-07-30 21:33:28 UTC (rev 254) +++ trunk/src/http.c 2007-07-30 22:03:27 UTC (rev 255) @@ -59,6 +59,8 @@ # include #endif /*!HAVE_W32_SYSTEM*/ +#include + #ifdef HTTP_USE_GNUTLS # include /* For non-understandable reasons GNUTLS dropped the _t suffix from @@ -398,7 +400,14 @@ else #endif /*HTTP_USE_ESTREAM*/ { +#ifndef HAVE_W32_SYSTEM hd->sock = dup (hd->sock); +#else + if (!DuplicateHandle (GetCurrentProcess(), hd->sock, + GetCurrentProcess(), &hd->sock, 0, + TRUE, DUPLICATE_SAME_ACCESS )) + return gpg_error_from_syserror (); +#endif if (hd->sock == -1) return gpg_error_from_syserror (); } @@ -1767,7 +1776,7 @@ { do { - nread = read (c->fd, buffer, size); + nread = pth_read (c->fd, buffer, size); } while (nread == -1 && errno == EINTR); } @@ -1814,15 +1823,13 @@ else #endif /*HTTP_USE_GNUTLS*/ { - if ( write_server (c->fd, buffer, size) ) + do { - errno = EIO; - nwritten = -1; + nwritten = pth_write (c->fd, buffer, size); } - else - nwritten = size; + while (nwritten == -1 && errno == EINTR); } - + return nwritten; } From cvs at cvs.gnupg.org Tue Jul 31 00:20:14 2007 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue, 31 Jul 2007 00:20:14 +0200 Subject: [svn] dirmngr - r256 - trunk/src Message-ID: Author: marcus Date: 2007-07-31 00:19:44 +0200 (Tue, 31 Jul 2007) New Revision: 256 Modified: trunk/src/ChangeLog trunk/src/crlfetch.c trunk/src/ocsp.c Log: 2007-07-31 Marcus Brinkmann * crlfetch.c: Include "estream.h". (crl_fetch): Use es_read callback instead a file handle. (crl_close_reader): Use es_fclose instead of fclose. (struct file_reader_map_s): Change type of FP to estream_t. (register_file_reader, crl_fetch, crl_close_reader): Likewise. * ocsp.c: Include "estream.h". (read_response): Change type of FP to estream_t. (read_response, do_ocsp_request): Use es_* variants of I/O functions. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2007-07-30 22:03:27 UTC (rev 255) +++ trunk/src/ChangeLog 2007-07-30 22:19:44 UTC (rev 256) @@ -1,5 +1,15 @@ 2007-07-31 Marcus Brinkmann + * crlfetch.c: Include "estream.h". + (crl_fetch): Use es_read callback instead a file handle. + (crl_close_reader): Use es_fclose instead of fclose. + (struct file_reader_map_s): Change type of FP to estream_t. + (register_file_reader, crl_fetch, crl_close_reader): Likewise. + * ocsp.c: Include "estream.h". + (read_response): Change type of FP to estream_t. + (read_response, do_ocsp_request): Use es_* variants of I/O + functions. + * http.c: Include . (http_wait_response) [HAVE_W32_SYSTEM]: Use DuplicateHandle. (cookie_read): Use pth_read instead read. Modified: trunk/src/crlfetch.c =================================================================== --- trunk/src/crlfetch.c 2007-07-30 22:03:27 UTC (rev 255) +++ trunk/src/crlfetch.c 2007-07-30 22:19:44 UTC (rev 256) @@ -30,13 +30,14 @@ #include "misc.h" #include "http.h" +#include "estream.h" /* We need to associate a reader object with file streams. This table is used for it. */ struct file_reader_map_s { ksba_reader_t reader; - FILE *fp; + estream_t fp; }; #define MAX_FILE_READER 50 static struct file_reader_map_s file_reader_map[MAX_FILE_READER]; @@ -44,7 +45,7 @@ /* Associate FP with READER. If the table is full wait until another thread has removed an entry. */ static void -register_file_reader (ksba_reader_t reader, FILE *fp) +register_file_reader (ksba_reader_t reader, estream_t fp) { int i; @@ -64,10 +65,10 @@ /* Scan the table for an entry matching READER, emove tha entry and return the associated file pointer. */ -static FILE * +static estream_t get_file_reader (ksba_reader_t reader) { - FILE *fp = NULL; + estream_t fp = NULL; int i; for (i=0; i < MAX_FILE_READER; i++) @@ -82,8 +83,6 @@ } - - /* Fetch CRL from URL and return the entire CRL using new ksba reader object in READER. Note that this reader object should be closed only using ldap_close_reader. */ @@ -140,11 +139,11 @@ { case 200: { - FILE *fp = http_get_read_ptr (hd); + estream_t fp = http_get_read_ptr (hd); err = ksba_reader_new (reader); if (!err) - err = ksba_reader_set_file (*reader, fp); + err = ksba_reader_set_cb (*reader, &es_read, fp); if (err) { log_error (_("error initializing reader object: %s\n"), @@ -323,7 +322,7 @@ void crl_close_reader (ksba_reader_t reader) { - FILE *fp; + estream_t fp; if (!reader) return; @@ -331,7 +330,7 @@ /* Check whether this is a HTTP one. */ fp = get_file_reader (reader); if (fp) /* This is an HTTP context. */ - fclose (fp); + es_fclose (fp); else /* This is an ldap wrapper context. */ ldap_wrapper_release_context (reader); Modified: trunk/src/ocsp.c =================================================================== --- trunk/src/ocsp.c 2007-07-30 22:03:27 UTC (rev 255) +++ trunk/src/ocsp.c 2007-07-30 22:19:44 UTC (rev 256) @@ -29,8 +29,8 @@ #include "http.h" #include "validate.h" #include "certcache.h" - #include "ocsp.h" +#include "estream.h" /* The maximum size we allow as a response from an OCSP reponder. */ #define MAX_RESPONSE_SIZE 65536 @@ -53,7 +53,7 @@ /* Read from FP and return a newly allocated buffer in R_BUFFER with the entire data read from FP. */ static gpg_error_t -read_response (FILE *fp, unsigned char **r_buffer, size_t *r_buflen) +read_response (estream_t fp, unsigned char **r_buffer, size_t *r_buflen) { gpg_error_t err; unsigned char *buffer; @@ -74,8 +74,8 @@ size_t nread = 0; assert (nbytes < bufsize); - nread = fread (buffer+nbytes, 1, bufsize-nbytes, fp); - if (nread < bufsize-nbytes && ferror (fp)) + nread = es_fread (buffer+nbytes, 1, bufsize-nbytes, fp); + if (nread < bufsize-nbytes && es_ferror (fp)) { err = gpg_error_from_errno (errno); log_error (_("error reading from responder: %s\n"), @@ -83,7 +83,7 @@ xfree (buffer); return err; } - if ( !(nread == bufsize-nbytes && !feof (fp))) + if ( !(nread == bufsize-nbytes && !es_feof (fp))) { /* Response succesfully received. */ nbytes += nread; *r_buffer = buffer; @@ -175,12 +175,12 @@ return err; } - fprintf (http_get_write_ptr (http), - "Content-Type: application/ocsp-request\r\n" - "Content-Length: %lu\r\n", - (unsigned long)requestlen ); + es_fprintf (http_get_write_ptr (http), + "Content-Type: application/ocsp-request\r\n" + "Content-Length: %lu\r\n", + (unsigned long)requestlen ); http_start_data (http); - if (fwrite (request, requestlen, 1, http_get_write_ptr (http)) != 1) + if (es_fwrite (request, requestlen, 1, http_get_write_ptr (http)) != 1) { err = gpg_error_from_errno (errno); log_error ("error sending request to `%s': %s\n", url, strerror (errno));