From cvs at cvs.gnupg.org Fri Sep 1 15:57:33 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Fri Sep 1 15:14:02 2006 Subject: [svn] GnuPG - r4233 - trunk/scd Message-ID: Author: marcus Date: 2006-09-01 15:57:33 +0200 (Fri, 01 Sep 2006) New Revision: 4233 Modified: trunk/scd/ChangeLog trunk/scd/command.c Log: 2006-09-01 Marcus Brinkmann * command.c (cmd_getinfo): Handle status command. Modified: trunk/scd/ChangeLog =================================================================== --- trunk/scd/ChangeLog 2006-08-30 15:57:17 UTC (rev 4232) +++ trunk/scd/ChangeLog 2006-09-01 13:57:33 UTC (rev 4233) @@ -1,3 +1,7 @@ +2006-09-01 Marcus Brinkmann + + * command.c (cmd_getinfo): Handle status command. + 2006-08-30 Marcus Brinkmann * command.c (do_reset): Delay resetting CTRL->reader_slot until Modified: trunk/scd/command.c =================================================================== --- trunk/scd/command.c 2006-08-30 15:57:17 UTC (rev 4232) +++ trunk/scd/command.c 2006-09-01 13:57:33 UTC (rev 4233) @@ -295,7 +295,7 @@ /* If the card has not yet been opened, do it. Note that this function returns an Assuan error, so don't map the error a second - time */ + time. */ static assuan_error_t open_card (ctrl_t ctrl, const char *apptype) { @@ -1355,7 +1355,12 @@ Supported values of WHAT are: socket_name - Return the name of the socket. - + status - Return the status of the current slot (in the future, may + also return the status of all slots). The status is a list of + one-character flags. The following flags are currently defined: + 'u' Usable card present. This is the normal state during operation. + 'r' Card removed. A reset is necessary. + These flags are exclusive. */ static int @@ -1372,6 +1377,29 @@ else rc = gpg_error (GPG_ERR_NO_DATA); } + else if (!strcmp (line, "status")) + { + ctrl_t ctrl = assuan_get_pointer (ctx); + int slot = ctrl->reader_slot; + char flag = 'r'; + + if (!ctrl->server_local->card_removed && slot != -1) + { + struct slot_status_s *ss; + + if (!(slot >= 0 && slot < DIM(slot_table))) + BUG (); + + ss = &slot_table[slot]; + + if (!ss->valid) + BUG (); + + if (ss->any && (ss->status & 1)) + flag = 'u'; + } + rc = assuan_send_data (ctx, &flag, 1); + } else rc = set_error (Parameter_Error, "unknown value for WHAT"); return rc; @@ -1752,7 +1780,7 @@ will set this on any card change because a reset or SERIALNO request must be done in any case. */ if (ss->any) - update_card_removed (ss->slot, 1); + update_card_removed (ss->slot, 1); /* XXX: MB: Should be idx? */ ss->any = 1; ss->status = status; From cvs at cvs.gnupg.org Sat Sep 2 16:47:55 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Sat Sep 2 16:04:28 2006 Subject: [svn] GnuPG - r4234 - trunk/scd Message-ID: Author: marcus Date: 2006-09-02 16:47:47 +0200 (Sat, 02 Sep 2006) New Revision: 4234 Modified: trunk/scd/ChangeLog trunk/scd/command.c Log: 2006-09-02 Marcus Brinkmann * command.c (get_reader_slot): Return the slot_table index, not the APDU slot number. (update_reader_status_file): Use the slot_table index in the update_card_removed invocation. Modified: trunk/scd/ChangeLog =================================================================== --- trunk/scd/ChangeLog 2006-09-01 13:57:33 UTC (rev 4233) +++ trunk/scd/ChangeLog 2006-09-02 14:47:47 UTC (rev 4234) @@ -1,3 +1,10 @@ +2006-09-02 Marcus Brinkmann + + * command.c (get_reader_slot): Return the slot_table index, not + the APDU slot number. + (update_reader_status_file): Use the slot_table index in the + update_card_removed invocation. + 2006-09-01 Marcus Brinkmann * command.c (cmd_getinfo): Handle status command. Modified: trunk/scd/command.c =================================================================== --- trunk/scd/command.c 2006-09-01 13:57:33 UTC (rev 4233) +++ trunk/scd/command.c 2006-09-02 14:47:47 UTC (rev 4234) @@ -104,7 +104,9 @@ }; -/* The table with information on all used slots. */ +/* The table with information on all used slots. FIXME: This is a + different slot number than the one used by the APDU layer, and + should be renamed. */ static struct slot_status_s slot_table[10]; @@ -290,7 +292,8 @@ if (ss->slot == -1) ss->slot = apdu_open_reader (opt.reader_port); - return ss->slot; + /* Return the slot_table index. */ + return 0; } /* If the card has not yet been opened, do it. Note that this @@ -1762,7 +1765,10 @@ log_info ("updating status of slot %d to 0x%04X\n", ss->slot, status); - + + /* FIXME: Should this be IDX instead of ss->slot? This + depends on how client sessions will associate the reader + status with their session. */ sprintf (templ, "reader_%d.status", ss->slot); fname = make_filename (opt.homedir, templ, NULL ); fp = fopen (fname, "w"); @@ -1780,7 +1786,7 @@ will set this on any card change because a reset or SERIALNO request must be done in any case. */ if (ss->any) - update_card_removed (ss->slot, 1); /* XXX: MB: Should be idx? */ + update_card_removed (idx, 1); ss->any = 1; ss->status = status; From cvs at cvs.gnupg.org Mon Sep 4 10:07:12 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon Sep 4 09:23:27 2006 Subject: [svn] GnuPG - r4235 - trunk/agent Message-ID: Author: wk Date: 2006-09-04 10:07:12 +0200 (Mon, 04 Sep 2006) New Revision: 4235 Modified: trunk/agent/ChangeLog trunk/agent/command.c Log: Added comamnds PUTVAL and GETVAL Modified: trunk/agent/ChangeLog =================================================================== --- trunk/agent/ChangeLog 2006-09-02 14:47:47 UTC (rev 4234) +++ trunk/agent/ChangeLog 2006-09-04 08:07:12 UTC (rev 4235) @@ -1,3 +1,8 @@ +2006-09-04 Werner Koch + + * command.c (percent_plus_unescape): New. + (cmd_get_val, cmd_putval): New. + 2006-08-29 Werner Koch * command-ssh.c (stream_read_mpi): Sanity check for early Modified: trunk/agent/command.c =================================================================== --- trunk/agent/command.c 2006-09-02 14:47:47 UTC (rev 4234) +++ trunk/agent/command.c 2006-09-04 08:07:12 UTC (rev 4235) @@ -49,8 +49,9 @@ #endif /* Data used to associate an Assuan context with local server data */ -struct server_local_s { - ASSUAN_CONTEXT assuan_ctx; +struct server_local_s +{ + assuan_context_t assuan_ctx; int message_fd; int use_cache_for_signing; char *keydesc; /* Allocated description for the next key @@ -58,8 +59,22 @@ }; +/* An entry for the getval/putval commands. */ +struct putval_item_s +{ + struct putval_item_s *next; + size_t off; /* Offset to the value into DATA. */ + size_t len; /* Length of the value. */ + char d[1]; /* Key | Nul | value. */ +}; +/* A list of key value pairs fpr the getval/putval commands. */ +static struct putval_item_s *putval_list; + + + + /* Release the memory buffer MB but first wipe out the used memory. */ static void @@ -133,6 +148,42 @@ } +/* Do the percent and plus/space unescaping in place and return the + length of the valid buffer. */ +static size_t +percent_plus_unescape (char *string) +{ + unsigned char *p = string; + size_t n = 0; + + while (*string) + { + if (*string == '%' && string[1] && string[2]) + { + string++; + *p++ = xtoi_2 (string); + n++; + string+= 2; + } + else if (*string == '+') + { + *p++ = ' '; + n++; + string++; + } + else + { + *p++ = *string++; + n++; + } + } + + return n; +} + + + + /* Parse a hex string. Return an Assuan error code or 0 on success and the length of the parsed string in LEN. */ static int @@ -310,7 +361,7 @@ } -/* SETKEYDESC plus_percent_escaped_string: +/* SETKEYDESC plus_percent_escaped_string Set a description to be used for the next PKSIGN or PKDECRYPT operation if this operation requires the entry of a passphrase. If @@ -318,7 +369,7 @@ this description implictly selects the label used for the entry box; if the string contains the string PIN (which in general will not be translated), "PIN" is used, otherwise the translation of - 'passphrase" is used. The description string should not contain + "passphrase" is used. The description string should not contain blanks unless they are percent or '+' escaped. The description is only valid for the next PKSIGN or PKDECRYPT @@ -877,6 +928,141 @@ +/* GETVAL + + Return the value for KEY from the special environment as created by + PUTVAL. + */ +static int +cmd_getval (assuan_context_t ctx, char *line) +{ + int rc = 0; + char *key = NULL; + char *p; + struct putval_item_s *vl; + + for (p=line; *p == ' '; p++) + ; + key = p; + p = strchr (key, ' '); + if (p) + { + *p++ = 0; + for (; *p == ' '; p++) + ; + if (*p) + return set_error (Parameter_Error, "too many arguments"); + } + if (!key || !*key) + return set_error (Parameter_Error, "no key given"); + + + for (vl=putval_list; vl; vl = vl->next) + if ( !strcmp (vl->d, key) ) + break; + + if (vl) /* Got an entry. */ + { + rc = assuan_send_data (ctx, vl->d+vl->off, vl->len); + if (rc) + rc = map_assuan_err (rc); + } + else + return gpg_error (GPG_ERR_NO_DATA); + + if (rc) + log_error ("command getval failed: %s\n", gpg_strerror (rc)); + return map_to_assuan_status (rc); +} + + +/* PUTVAL [] + + The gpg-agent maintains a kind of environment which may be used to + store key/value pairs in it, so that they can be retrieved later. + This may be used by helper daemons to daemonize themself on + invocation and register them with gpg-agent. Callers of the + daemon's service may now first try connect to get the information + for that service from gpg-agent through the GETVAL command and then + try to connect to that daemon. Only if that fails they may start + an own instance of the service daemon. + + KEY is an an arbitrary symbol with the same syntax rules as keys + for shell environment variables. PERCENT_ESCAPED_VALUE is the + corresponsing value; they should be similar to the values of + envronment variables but gpg-agent does not enforce any + restrictions. If that value is not given any value under that KEY + is removed from this special environment. +*/ +static int +cmd_putval (assuan_context_t ctx, char *line) +{ + int rc = 0; + char *key = NULL; + char *value = NULL; + size_t valuelen = 0; + char *p; + struct putval_item_s *vl, *vlprev; + + for (p=line; *p == ' '; p++) + ; + key = p; + p = strchr (key, ' '); + if (p) + { + *p++ = 0; + for (; *p == ' '; p++) + ; + if (*p) + { + value = p; + p = strchr (value, ' '); + if (p) + *p = 0; + valuelen = percent_plus_unescape (value); + } + } + if (!key || !*key) + return set_error (Parameter_Error, "no key given"); + + + for (vl=putval_list,vlprev=NULL; vl; vlprev=vl, vl = vl->next) + if ( !strcmp (vl->d, key) ) + break; + + if (vl) /* Delete old entry. */ + { + if (vlprev) + vlprev->next = vl->next; + else + putval_list = vl->next; + xfree (vl); + } + + if (valuelen) /* Add entry. */ + { + vl = xtrymalloc (sizeof *vl + strlen (key) + valuelen); + if (!vl) + rc = gpg_error_from_errno (errno); + else + { + vl->len = valuelen; + vl->off = strlen (key) + 1; + strcpy (vl->d, key); + memcpy (vl->d + vl->off, value, valuelen); + vl->next = putval_list; + putval_list = vl; + } + } + + if (rc) + log_error ("command putval failed: %s\n", gpg_strerror (rc)); + return map_to_assuan_status (rc); +} + + + + /* UPDATESTARTUPTTY Set startup TTY and X DISPLAY variables to the values of this @@ -999,6 +1185,8 @@ { "INPUT", NULL }, { "OUTPUT", NULL }, { "SCD", cmd_scd }, + { "GETVAL", cmd_getval }, + { "PUTVAL", cmd_putval }, { "UPDATESTARTUPTTY", cmd_updatestartuptty }, { NULL } }; From cvs at cvs.gnupg.org Mon Sep 4 13:00:53 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon Sep 4 12:17:08 2006 Subject: [svn] GnuPG - r4236 - trunk/common Message-ID: Author: wk Date: 2006-09-04 13:00:52 +0200 (Mon, 04 Sep 2006) New Revision: 4236 Modified: trunk/common/ChangeLog trunk/common/http.c trunk/common/http.h Log: Support to read response headers. Required for redirection support in the dirmngr package. Modified: trunk/common/ChangeLog =================================================================== --- trunk/common/ChangeLog 2006-09-04 08:07:12 UTC (rev 4235) +++ trunk/common/ChangeLog 2006-09-04 11:00:52 UTC (rev 4236) @@ -1,3 +1,10 @@ +2006-09-04 Werner Koch + + * http.c (http_get_header): New. + (capitalize_header_name, store_header): New. + (parse_response): Store headers away. + * http.h: New flag HTTP_FLAG_NEED_HEADER. + 2006-08-21 Werner Koch * Makefile.am (libcommon_a_SOURCES): Added keyserver.h Modified: trunk/common/http.c =================================================================== --- trunk/common/http.c 2006-09-04 08:07:12 UTC (rev 4235) +++ trunk/common/http.c 2006-09-04 11:00:52 UTC (rev 4236) @@ -65,6 +65,10 @@ typedef gnutls_transport_ptr gnutls_transport_ptr_t; #endif /*HTTP_USE_GNUTLS*/ +#ifdef TEST +#undef USE_DNS_SRV +#endif + #include "util.h" #include "http.h" #ifdef USE_DNS_SRV @@ -157,6 +161,17 @@ static gpg_error_t (*tls_callback) (http_t, gnutls_session_t, int); #endif /*HTTP_USE_GNUTLS*/ + +/* An object to save header lines. */ +struct header_s +{ + struct header_s *next; + char *value; /* The value of the header (malloced). */ + char name[1]; /* The name of the header (canonicalized). */ +}; +typedef struct header_s *header_t; + + /* Our handle context. */ struct http_context_s { @@ -178,6 +193,7 @@ char *buffer; /* Line buffer. */ size_t buffer_size; unsigned int flags; + header_t headers; /* Received headers. */ }; @@ -444,6 +460,13 @@ if (hd->fp_write) P_ES(fclose) (hd->fp_write); http_release_parsed_uri (hd->uri); + while (hd->headers) + { + header_t tmp = hd->headers->next; + xfree (hd->headers->value); + xfree (hd->headers); + hd->headers = tmp; + } xfree (hd->buffer); xfree (hd); } @@ -1160,6 +1183,129 @@ } +/* Transform a header name into a standard capitalized format; e.g. + "Content-Type". Conversion stops at the colon. As usual we don't + use the localized versions of ctype.h. */ +static void +capitalize_header_name (char *name) +{ + int first = 1; + + for (; *name && *name != ':'; name++) + { + if (*name == '-') + first = 1; + else if (first) + { + if (*name >= 'a' && *name <= 'z') + *name = *name - 'a' + 'A'; + first = 0; + } + else if (*name >= 'A' && *name <= 'Z') + *name = *name - 'A' + 'a'; + } +} + + +/* Store an HTTP header line in LINE away. Line continuation is + supported as well as merging of headers with the same name. This + function may modify LINE. */ +static gpg_error_t +store_header (http_t hd, char *line) +{ + size_t n; + char *p, *value; + header_t h; + + n = strlen (line); + if (n && line[n-1] == '\n') + { + line[--n] = 0; + if (n && line[n-1] == '\r') + line[--n] = 0; + } + if (!n) /* we are never called to hit this. */ + return gpg_error (GPG_ERR_BUG); + if (*line == ' ' || *line == '\t') + { + /* Continuation. This won't happen too often as it is not + recommended. We use a straightforward implementaion. */ + if (!hd->headers) + return gpg_error (GPG_ERR_PROTOCOL_VIOLATION); + n += strlen (hd->headers->value); + p = xtrymalloc (n+1); + if (!p) + return gpg_error_from_errno (errno); + strcpy (stpcpy (p, hd->headers->value), line); + xfree (hd->headers->value); + hd->headers->value = p; + return 0; + } + + capitalize_header_name (line); + p = strchr (line, ':'); + if (!p) + return gpg_error (GPG_ERR_PROTOCOL_VIOLATION); + *p++ = 0; + while (*p == ' ' || *p == '\t') + p++; + value = p; + + for (h=hd->headers; h; h = h->next) + if ( !strcmp (h->name, line) ) + break; + if (h) + { + /* We have already seen a line with that name. Thus we assume + it is a comma separated list and merge them. */ + p = xtrymalloc (strlen (h->value) + 1 + strlen (value)+ 1); + if (!p) + return gpg_error_from_errno (errno); + strcpy (stpcpy (stpcpy (p, h->value), ","), value); + xfree (h->value); + h->value = p; + return 0; + } + + /* Append a new header. */ + h = xtrymalloc (sizeof *h + strlen (line)); + if (!h) + return gpg_error_from_errno (errno); + strcpy (h->name, line); + h->value = xtrymalloc (strlen (value)+1); + if (!h->value) + { + xfree (h); + return gpg_error_from_errno (errno); + } + strcpy (h->value, value); + h->next = hd->headers; + hd->headers = h; + + return 0; +} + + +/* Return the header NAME from the last response. The returned value + is valid as along as HD has not been closed and no othe request has + been send. If the header was not found, NULL is returned. Name + must be canonicalized, that is the first letter of each dash + delimited part must be uppercase and all other letters lowercase. + Note that the context must have been opened with the + HTTP_FLAG_NEED_HEADER. */ +const char * +http_get_header (http_t hd, const char *name) +{ + header_t h; + + for (h=hd->headers; h; h = h->next) + if ( !strcmp (h->name, name) ) + return h->value; + return NULL; +} + + + /* * Parse the response from a server. * Returns: Errorcode and sets some files in the handle @@ -1170,6 +1316,15 @@ char *line, *p, *p2; size_t maxlen, len; + /* Delete old header lines. */ + while (hd->headers) + { + header_t tmp = hd->headers->next; + xfree (hd->headers->value); + xfree (hd->headers); + hd->headers = tmp; + } + /* Wait for the status line. */ do { @@ -1231,6 +1386,12 @@ if ( (hd->flags & HTTP_FLAG_LOG_RESP) ) log_info ("RESP: `%.*s'\n", (int)strlen(line)-(*line&&line[1]?2:0),line); + if ( (hd->flags & HTTP_FLAG_NEED_HEADER) && *line ) + { + gpg_error_t err = store_header (hd, line); + if (err) + return err; + } } while (len && *line); @@ -1703,6 +1864,7 @@ gnutls_certificate_credentials certcred; const int certprio[] = { GNUTLS_CRT_X509, 0 }; #endif /*HTTP_USE_GNUTLS*/ + header_t hdr; #ifdef HTTP_USE_ESTREAM es_init (); @@ -1792,7 +1954,8 @@ http_release_parsed_uri (uri); uri = NULL; - rc = http_open_document (&hd, *argv, NULL, HTTP_FLAG_NO_SHUTDOWN, + rc = http_open_document (&hd, *argv, NULL, + HTTP_FLAG_NO_SHUTDOWN | HTTP_FLAG_NEED_HEADER, NULL, tls_session); if (rc) { @@ -1801,8 +1964,19 @@ } log_info ("open_http_document succeeded; status=%u\n", http_get_status_code (hd)); - while ((c = P_ES(getc) (http_get_read_ptr (hd))) != EOF) - putchar (c); + for (hdr = hd->headers; hdr; hdr = hdr->next) + printf ("HDR: %s: %s\n", hdr->name, hdr->value); + switch (http_get_status_code (hd)) + { + case 200: + while ((c = P_ES(getc) (http_get_read_ptr (hd))) != EOF) + putchar (c); + break; + case 301: + case 302: + printf ("Redirected to `%s'\n", http_get_header (hd, "Location")); + break; + } http_close (hd, 0); #ifdef HTTP_USE_GNUTLS Modified: trunk/common/http.h =================================================================== --- trunk/common/http.h 2006-09-04 08:07:12 UTC (rev 4235) +++ trunk/common/http.h 2006-09-04 11:00:52 UTC (rev 4236) @@ -66,7 +66,8 @@ HTTP_FLAG_TRY_PROXY = 1, HTTP_FLAG_NO_SHUTDOWN = 2, HTTP_FLAG_TRY_SRV = 4, - HTTP_FLAG_LOG_RESP = 8 + HTTP_FLAG_LOG_RESP = 8, + HTTP_FLAG_NEED_HEADER = 16 }; struct http_context_s; @@ -106,6 +107,7 @@ FILE *http_get_write_ptr (http_t hd); #endif /*!HTTP_USE_ESTREAM*/ unsigned int http_get_status_code (http_t hd); +const char *http_get_header (http_t hd, const char *name); char *http_escape_string (const char *string, const char *specials); From cvs at cvs.gnupg.org Mon Sep 4 16:53:21 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon Sep 4 16:09:28 2006 Subject: [svn] GnuPG - r4237 - trunk/doc Message-ID: Author: wk Date: 2006-09-04 16:53:20 +0200 (Mon, 04 Sep 2006) New Revision: 4237 Modified: trunk/doc/gpg-agent.texi trunk/doc/gpg.texi trunk/doc/gpgsm.texi trunk/doc/yat2m.c Log: Some fixes as needed by dirmngr man pages Modified: trunk/doc/gpg-agent.texi =================================================================== --- trunk/doc/gpg-agent.texi 2006-09-04 11:00:52 UTC (rev 4236) +++ trunk/doc/gpg-agent.texi 2006-09-04 14:53:20 UTC (rev 4237) @@ -602,7 +602,7 @@ @c @c Assuan Protocol @c -@mansect assuan +@manpause @node Agent Protocol @section Agent's Assuan Protocol @@ -1051,3 +1051,13 @@ session. This command is useful to direct future pinentry invocations to another screen. It is only required because there is no way in the ssh-agent protocol to convey this information. + + +@mansect see also +@ifset isman +@command{gpg2}(1), +@command{gpgsm}(1), +@command{gpg-connect-agent}(1), +@command{scdaemon}(1) +@end ifset +@include see-also-note.texi Modified: trunk/doc/gpg.texi =================================================================== --- trunk/doc/gpg.texi 2006-09-04 11:00:52 UTC (rev 4236) +++ trunk/doc/gpg.texi 2006-09-04 14:53:20 UTC (rev 4237) @@ -2572,3 +2572,10 @@ locking without being root. The program drops root privileges as soon as locked memory is allocated. +@mansect see also +@ifset isman +@command{gpgv}(1), +@command{gpgsm}(1), +@command{gpg-agent}(1) +@end ifset +@include see-also-note.texi Modified: trunk/doc/gpgsm.texi =================================================================== --- trunk/doc/gpgsm.texi 2006-09-04 11:00:52 UTC (rev 4236) +++ trunk/doc/gpgsm.texi 2006-09-04 14:53:20 UTC (rev 4237) @@ -773,7 +773,7 @@ @c *************** ASSSUAN ***************** @c *************** ***************** @c ******************************************* -@mansect assuan +@manpause @node GPGSM Protocol @section The Protocol the Server Mode Uses. @@ -1071,3 +1071,10 @@ The certificates must be specified unambiguously otherwise an error is returned. + +@mansect see also +@ifset isman +@command{gpg2}(1), +@command{gpg-agent}(1) +@end ifset +@include see-also-note.texi Modified: trunk/doc/yat2m.c =================================================================== --- trunk/doc/yat2m.c 2006-09-04 11:00:52 UTC (rev 4236) +++ trunk/doc/yat2m.c 2006-09-04 14:53:20 UTC (rev 4237) @@ -41,7 +41,7 @@ left space. Processing starts after a "manpage" macro has been seen. "mansect" identifies the section and yat2m make sure to emit the sections in the proper order. Note that @mansect skips - the next input line if that line begins with @subsection or + the next input line if that line begins with @section, @subsection or @chapheading. To insert verbatim troff markup, the follwing texinfo code may be @@ -147,13 +147,14 @@ } thepage; -/* The list of standard section names. */ +/* The list of standard section names. COMMANDS and ASSUAN are GnuPG + specific. */ static const char * const standard_sections[] = { "NAME", "SYNOPSIS", "DESCRIPTION", "RETURN VALUE", "EXIT STATUS", "ERROR HANDLING", "ERRORS", - "OPTIONS", "USAGE", "EXAMPLES", "FILES", + "COMMANDS", "OPTIONS", "USAGE", "EXAMPLES", "FILES", "ENVIRONMENT", "DIAGNOSTICS", "SECURITY", "CONFORMING TO", - "NOTES", "BUGS", "AUTHOR", "SEE ALSO", NULL }; + "ASSUAN", "NOTES", "BUGS", "AUTHOR", "SEE ALSO", NULL }; /*-- Local prototypes. --*/ @@ -432,11 +433,13 @@ } cmdtbl[] = { { "command", 0, "\\fB", "\\fR" }, { "code", 0, "\\fB", "\\fR" }, + { "sc", 0, "\\fB", "\\fR" }, { "var", 0, "\\fI", "\\fR" }, { "samp", 0, "\n'", "'\n" }, { "file", 0, "`\\fI","\\fR'" }, { "env", 0, "`\\fI","\\fR'" }, { "acronym", 0 }, + { "dfn", 0 }, { "option", 0, "\\fB", "\\fR" }, { "example", 1, ".RS 2\n.nf\n" }, { "smallexample", 1, ".RS 2\n.nf\n" }, @@ -456,6 +459,7 @@ { "node", 1 }, { "noindent", 0 }, { "section", 1 }, + { "chapter", 1 }, { "subsection", 6, "\n.SS " }, { "chapheading", 0}, { "item", 2, ".TP\n.B " }, @@ -804,12 +808,11 @@ /* Parse one Texinfo file and create manpages according to the embedded instructions. */ static void -parse_file (const char *fname, FILE *fp, char **section_name) +parse_file (const char *fname, FILE *fp, char **section_name, int in_pause) { char *line; int lnr = 0; int in_verbatim = 0; - int in_pause = 0; int skip_to_end = 0; /* Used to skip over menu entries. */ int skip_sect_line = 0; /* Skip after @mansect. */ @@ -832,7 +835,8 @@ if (skip_sect_line) { skip_sect_line = 0; - if (!strncmp (line, "@subsection", 11) + if (!strncmp (line, "@section", 8) + || !strncmp (line, "@subsection", 11) || !strncmp (line, "@chapheading", 12)) continue; } @@ -943,7 +947,7 @@ incname, strerror (errno)); else { - parse_file (incname, incfp, section_name); + parse_file (incname, incfp, section_name, in_pause); fclose (incfp); } free (incname); @@ -971,7 +975,7 @@ { char *section_name = NULL; /* Name of the current section or NULL if not in a section. */ - parse_file (fname, fp, §ion_name); + parse_file (fname, fp, §ion_name, 0); free (section_name); finish_page (); } From cvs at cvs.gnupg.org Mon Sep 4 16:53:45 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon Sep 4 16:09:50 2006 Subject: [svn] dirmngr - r232 - trunk/doc Message-ID: Author: wk Date: 2006-09-04 16:53:44 +0200 (Mon, 04 Sep 2006) New Revision: 232 Added: trunk/doc/see-also-note.texi trunk/doc/yat2m.c Modified: trunk/doc/Makefile.am trunk/doc/dirmngr.texi Log: Build man pages. Modified: trunk/doc/Makefile.am =================================================================== --- trunk/doc/Makefile.am 2006-09-01 17:11:39 UTC (rev 231) +++ trunk/doc/Makefile.am 2006-09-04 14:53:44 UTC (rev 232) @@ -19,11 +19,46 @@ ## Process this file with automake to produce Makefile.in -EXTRA_DIST = internals.texi +EXTRA_DIST = internals.texi see-also-note.texi +noinst_PROGRAMS = yat2m + +YAT2M_OPTIONS = -I $(srcdir) \ + --release "Dirmngr @PACKAGE_VERSION@" --source "GNU Privacy Guard" + +myman_sources = dirmngr.texi +myman_pages = dirmngr.1 dirmngr-client.1 + +man_MANS = $(myman_pages) + info_TEXINFOS = dirmngr.texi -dirmngr_TEXINFOS = gpl.texi fdl.texi +dirmngr_TEXINFOS = gpl.texi -DISTCLEANFILES = dirmngr.ops +DISTCLEANFILES = dirmngr.ops yat2m-stamp.tmp yat2m-stamp $(myman_pages) +yat2m_SOURCES = yat2m.c + +yat2m-stamp: $(myman_sources) + @rm -f yat2m-stamp.tmp + @touch yat2m-stamp.tmp + for file in $(myman_sources) ; do \ + ./yat2m $(YAT2M_OPTIONS) --store \ + `test -f '$$file' || echo '$(srcdir)/'`$$file ; done + @mv -f yat2m-stamp.tmp $@ + +yat2m-stamp: yat2m + +$(myman_pages) : yat2m-stamp + @if test -f $@; then :; else \ + trap 'rm -rf yat2m-stamp yat2m-lock' 1 2 13 15; \ + if mkdir yat2m-lock 2>/dev/null; then \ + rm -f yat2m-stamp; \ + $(MAKE) $(AM_MAKEFLAGS) yat2m-stamp; \ + rmdir yat2m-lock; \ + else \ + while test -d yat2m-lock; do sleep 1; done; \ + test -f yat2m-stamp; exit $$?; \ + fi; \ + fi + Modified: trunk/doc/dirmngr.texi =================================================================== --- trunk/doc/dirmngr.texi 2006-09-01 17:11:39 UTC (rev 231) +++ trunk/doc/dirmngr.texi 2006-09-04 14:53:44 UTC (rev 232) @@ -3,6 +3,19 @@ @setfilename dirmngr.info @include version.texi @settitle Using Dirmngr + +@c A couple of macros with no effect on texinfo +@c but used by the yat2m processor. +@macro manpage {a} +@end macro +@macro mansect {a} +@end macro +@macro manpause +@end macro +@macro mancont +@end macro + + @c Create a separate index for command line options. @defcodeindex op @c Merge the standard indexes into a single one. @@ -19,7 +32,7 @@ Copyright @copyright{} 2002 Klarälvdalens Datakonsult AB -Copyright @copyright{} 2004, 2005 g10 Code GmbH +Copyright @copyright{} 2004, 2005, 2006 g10 Code GmbH @quotation Permission is granted to copy, distribute and/or modify this document @@ -102,17 +115,29 @@ @node Introduction @chapter About Dirmngr. +@manpage dirmngr.1 +@ifset manverb +.B dirmngr +\- CRL and OCSP daemon +@end ifset +@mansect synopsis +@ifset manverb +.B dirmngr +.RI [ options ] +.I command +.RI [ args ] +@end ifset -@c man begin DESCRIPTION +@mansect description Dirmngr is a server for managing and downloading certificate revocation lists (CRLs) for X.509 certificates and for downloading the certificates themselves. Dirmngr also handles OCSP requests as an alternative to CRLs. Dirmngr is either invoked internally by gpgsm (from gnupg 1.9) or when running as a system daemon through the @command{dirmngr-client} tool. -@c man end +@manpause @node Installation @@ -140,6 +165,7 @@ @option{--prefix=/} you obviously don't need those option as they are the default then. Further on we assume that you used these options. +@mansect files Dirmngr makes use of several directories when running in daemon mode: @table @file @@ -181,6 +207,7 @@ sure that the upper directory exists. @end table +@manpause To be able to see what's going on you should create the configure file @file{/etc/dirmngr/dirmngr.conf} with at least one line: @@ -206,13 +233,12 @@ -@c man begin COMMANDS - @node Dirmngr Commands @chapter Commands +@mansect commands Commands are not distinguished from options execpt for the fact that -only one one command is allowed. +only one command is allowed. @table @gnupgtabopt @item --version @@ -268,8 +294,8 @@ @end table -@c man begin OPTIONS +@mansect options @node Dirmngr Options @chapter Option Summary @@ -287,27 +313,28 @@ effective when used on the command line. The default depends on the running mode: - @table @asis - @item With @code{--daemon} given on the commandline +@table @asis + +@item With @code{--daemon} given on the commandline the directory named @file{/etc/dirmngr} for configuration files, @file{/var/lib/dirmngr/} for extra data and @file{/var/cache/dirmngr} for cached CRLs. - @item Without @code{--daemon} given on the commandline + +@item Without @code{--daemon} given on the commandline the directory named @file{.gnupg} directly below the home directory of the user unless the environment variable @code{GNUPGHOME} has been set in which case its value will be used. All kind of data is stored below this directory. - @end table +@end table - @item -v @item --verbose @opindex v @opindex verbose Outputs additional information while running. You can increase the verbosity by giving several -verbose commands to @sc{dirmngr}, such as @samp{-vv}. +verbose commands to @sc{dirmngr}, such as @option{-vv}. @@ -321,18 +348,18 @@ Select the debug level for investigating problems. @var{level} may be one of: - @table @code - @item none - no debugging at all. - @item basic - some basic debug messages - @item advanced - more verbose debug messages - @item expert - even more detailed messages - @item guru - all of the debug messages you can get - @end table +@table @code +@item none +no debugging at all. +@item basic +some basic debug messages +@item advanced +more verbose debug messages +@item expert +even more detailed messages +@item guru +all of the debug messages you can get +@end table How these messages are mapped to the actual debugging flags is not specified and may change with newer releases of this program. They are @@ -502,8 +529,10 @@ @c @c Dirmngr Signals @c +@mansect signals @node Dirmngr Signals @chapter Use of signals. + A running @command{dirmngr} may be controlled by signals, i.e. using the @command{kill} command to send a signal to the process. @@ -539,10 +568,10 @@ @c @c Examples @c +@mansect examples @node Dirmngr Examples @chapter Examples -@c man begin EXAMPLES The way to start the dirmngr in the foreground (as done by tools if no dirmngr is running in the background) is to use: @@ -562,20 +591,21 @@ versions and may be ignored. +@mansect see also +@command{gpgsm}(1), +@command{dirmngr-client}(1) +@include see-also-note.texi -@c man end - - - @c @c Assuan Protocol @c +@manpause @node Dirmngr Protocol @chapter Dirmngr's Assuan Protocol -The Dirmngr should be started by the system to provide access to -certificates and CRLs on LDAP servers. +Assuan is the IPC protocol used to access dirmngr. This is a +description of the commands implemented by dirmngr. @menu * Dirmngr LOOKUP:: Look up a certificate via LDAP @@ -755,6 +785,20 @@ @node Dirmngr Client @chapter The Client Tool +@manpage dirmngr-client.1 +@ifset manverb +.B dirmngr-client +\- CRL and OCSP daemon +@end ifset + +@mansect synopsis +@ifset manverb +.B dirmngr-client +.RI [ options ] +.RI [ certfile | pattern ] +@end ifset + +@mansect description The @command{dirmngr-client} is a simple tool to contact a running dirmngr and test whether a certificate has been revoked --- either by being listed in the corresponding CRL or by running the OCSP protocol. @@ -776,8 +820,15 @@ @end example Where @var{acert} is one DER encoded (binary) X.509 certificates to be -tested. The return value of this command is +tested. +@ifclear isman +The return value of this command is +@end ifclear +@mansect return value +@ifset isman +@command{dirmngr-client} returns these values: +@end ifset @table @code @item 0 @@ -795,6 +846,7 @@ @end table +@mansect options @noindent @command{dirmngr-client} may be called with the following options: @@ -864,8 +916,14 @@ @end table +@mansect see also +@command{dirmngr}(1), +@command{gpgsm}(1) +@include see-also-note.texi +@manpause + @include gpl.texi @c --------------------------------------------------------------------- @@ -891,7 +949,7 @@ @itemize @item Using DirMngr, 2002, Steffen Hansen, Klarälvdalens Datakonsult AB. -@item Using DirMngr, 2004, 2005 Werner Koch, g10 Code GmbH. +@item Using DirMngr, 2004, 2005, 2006 Werner Koch, g10 Code GmbH. @end itemize Added: trunk/doc/see-also-note.texi =================================================================== --- trunk/doc/see-also-note.texi 2006-09-01 17:11:39 UTC (rev 231) +++ trunk/doc/see-also-note.texi 2006-09-04 14:53:44 UTC (rev 232) @@ -0,0 +1,14 @@ +@c We append this note to all ``see also'' sections of the man pages + +@ifset isman +The full documentation for this tool is maintained as a Texinfo manual. +If dirmngr and the info program are properly installed at your site, the +command + +@example +info dirmngr +@end example + +should give you access to the complete manual including a menu structure +and an index. +@end ifset Added: trunk/doc/yat2m.c =================================================================== --- trunk/doc/yat2m.c 2006-09-01 17:11:39 UTC (rev 231) +++ trunk/doc/yat2m.c 2006-09-04 14:53:44 UTC (rev 232) @@ -0,0 +1,1115 @@ +/* yat2m.c - Yet Another Texi 2 Man converter + * Copyright (C) 2005 g10 Code GmbH + * Copyright (C) 2006 2006 Free Software Foundation, Inc. + * + * This program 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. + * + * This program 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., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +/* + This is a simple textinfo to man page converter. It needs some + special markup in th e texinfo and tries best to get a create man + page. It has been designed for the GnuPG man pages and thus only + a few texinfo commands are supported. + + To use this you need to add the following macros into your texinfo + source: + + @macro manpage {a} + @end macro + @macro mansect {a} + @end macro + @macro manpause + @end macro + @macro mancont + @end macro + + They are used by yat2m to select parts of the Texinfo which should + go into the man page. These macros need to be used without leading + left space. Processing starts after a "manpage" macro has been + seen. "mansect" identifies the section and yat2m make sure to + emit the sections in the proper order. Note that @mansect skips + the next input line if that line begins with @section, @subsection or + @chapheading. + + To insert verbatim troff markup, the follwing texinfo code may be + used: + + @ifset manverb + .B whateever you want + @end ifset + + alternativly a special comment may be used: + + @c man:.B whatever you want + + This is useful in case you need just one line. If you want to + include parts only in the man page but keep the texinfo + translation you may use: + + @ifset isman + stuff to be rendered only on man pages + @end ifset + + or to exclude stuff from man pages: + + @ifclear isman + stuff not to be rendered on man pages + @end ifclear + + the keyword @section is ignored, however @subsection gets rendered + as ".SS". @menu is completely skipped. Several man pages may be + extracted from one file, either using the --store or the --select + option. + + +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#define PGM "yat2m" +#define VERSION "0.5" + +/* The maximum length of a line including the linefeed and one extra + character. */ +#define LINESIZE 1024 + +/* Option flags. */ +static int verbose; +static int quiet; +static int debug; +static const char *opt_source; +static const char *opt_release; +static const char *opt_select; +static const char *opt_include; +static int opt_store; + + +/* Flag to keep track whether any error occurred. */ +static int any_error; + + +/* Object to store one line of content. */ +struct line_buffer_s +{ + struct line_buffer_s *next; + int verbatim; /* True if LINE contains verbatim data. The default + is Texinfo source. */ + char *line; +}; +typedef struct line_buffer_s *line_buffer_t; + + +/* Object to collect the data of a section. */ +struct section_buffer_s +{ + char *name; /* Malloced name of the section. This may be + NULL to indicate this slot is not used. */ + line_buffer_t lines; /* Linked list with the lines of the section. */ + line_buffer_t *lines_tail; /* Helper for faster appending to the + linked list. */ + line_buffer_t last_line; /* Points to the last line appended. */ +}; +typedef struct section_buffer_s *section_buffer_t; + +/* Variable to keep info about the current page together. */ +static struct +{ + /* Filename of the current page or NULL if no page is active. Malloced. */ + char *name; + + /* Number of allocated elements in SECTIONS below. */ + size_t n_sections; + /* Array with the data of the sections. */ + section_buffer_t sections; + +} thepage; + + +/* The list of standard section names. COMMANDS and ASSUAN are GnuPG + specific. */ +static const char * const standard_sections[] = + { "NAME", "SYNOPSIS", "DESCRIPTION", + "RETURN VALUE", "EXIT STATUS", "ERROR HANDLING", "ERRORS", + "COMMANDS", "OPTIONS", "USAGE", "EXAMPLES", "FILES", + "ENVIRONMENT", "DIAGNOSTICS", "SECURITY", "CONFORMING TO", + "ASSUAN", "NOTES", "BUGS", "AUTHOR", "SEE ALSO", NULL }; + + +/*-- Local prototypes. --*/ +static void proc_texi_buffer (FILE *fp, const char *line, size_t len, + int *table_level, int *eol_action); + + + +/* Print diagnostic message and exit with failure. */ +static void +die (const char *format, ...) +{ + va_list arg_ptr; + + fflush (stdout); + fprintf (stderr, "%s: ", PGM); + + va_start (arg_ptr, format); + vfprintf (stderr, format, arg_ptr); + va_end (arg_ptr); + putc ('\n', stderr); + + exit (1); +} + + +/* Print diagnostic message. */ +static void +err (const char *format, ...) +{ + va_list arg_ptr; + + fflush (stdout); + if (strncmp (format, "%s:%d:", 6)) + fprintf (stderr, "%s: ", PGM); + + va_start (arg_ptr, format); + vfprintf (stderr, format, arg_ptr); + va_end (arg_ptr); + putc ('\n', stderr); + any_error = 1; +} + +/* Print diagnostic message. */ +static void +inf (const char *format, ...) +{ + va_list arg_ptr; + + fflush (stdout); + fprintf (stderr, "%s: ", PGM); + + va_start (arg_ptr, format); + vfprintf (stderr, format, arg_ptr); + va_end (arg_ptr); + putc ('\n', stderr); +} + + +static void * +xmalloc (size_t n) +{ + void *p = malloc (n); + if (!p) + die ("out of core: %s", strerror (errno)); + return p; +} + +static void * +xcalloc (size_t n, size_t m) +{ + void *p = calloc (n, m); + if (!p) + die ("out of core: %s", strerror (errno)); + return p; +} + +static void * +xrealloc (void *old, size_t n) +{ + void *p = realloc (old, n); + if (!p) + die ("out of core: %s", strerror (errno)); + return p; +} + +static char * +xstrdup (const char *string) +{ + void *p = malloc (strlen (string)+1); + if (!p) + die ("out of core: %s", strerror (errno)); + strcpy (p, string); + return p; +} + + +/* Uppercase the ascii characters in STRING. */ +static char * +ascii_strupr (char *string) +{ + char *p; + + for (p = string; *p; p++) + if (!(*p & 0x80)) + *p = toupper (*p); + return string; +} + + +/* Return the current date as an ISO string. */ +const char * +isodatestring (void) +{ + static char buffer[11+5]; + struct tm *tp; + time_t atime = time (NULL); + + if (atime < 0) + strcpy (buffer, "????" "-??" "-??"); + else + { + tp = gmtime (&atime); + sprintf (buffer,"%04d-%02d-%02d", + 1900+tp->tm_year, tp->tm_mon+1, tp->tm_mday ); + } + return buffer; +} + + + +/* Return a section buffer for the section NAME. Allocate a new buffer + if this is a new section. Keep track of the sections in THEPAGE. + This function may reallocate the section array in THEPAGE. */ +static section_buffer_t +get_section_buffer (const char *name) +{ + int i; + section_buffer_t sect; + + /* If there is no section we put everything into the required NAME + section. Given that this is the first one listed it is likely + that error are easily visible. */ + if (!name) + name = "NAME"; + + for (i=0; i < thepage.n_sections; i++) + { + sect = thepage.sections + i; + if (sect->name && !strcmp (name, sect->name)) + return sect; + } + for (i=0; i < thepage.n_sections; i++) + if (!thepage.sections[i].name) + break; + if (i < thepage.n_sections) + sect = thepage.sections + i; + else + { + /* We need to allocate or reallocate the section array. */ + size_t old_n = thepage.n_sections; + size_t new_n = 20; + + if (!old_n) + thepage.sections = xcalloc (new_n, sizeof *thepage.sections); + else + { + thepage.sections = xrealloc (thepage.sections, + ((old_n + new_n) + * sizeof *thepage.sections)); + memset (thepage.sections + old_n, 0, + new_n * sizeof *thepage.sections); + } + thepage.n_sections += new_n; + + /* Setup the tail pointers. */ + for (i=old_n; i < thepage.n_sections; i++) + { + sect = thepage.sections + i; + sect->lines_tail = §->lines; + } + sect = thepage.sections + old_n; + } + + /* Store the name. */ + assert (!sect->name); + sect->name = xstrdup (name); + return sect; +} + + + +/* Add the content of LINE to the section named SECTNAME. */ +static void +add_content (const char *sectname, char *line, int verbatim) +{ + section_buffer_t sect; + line_buffer_t lb; + + sect = get_section_buffer (sectname); + if (sect->last_line && !sect->last_line->verbatim == !verbatim) + { + /* Lets append that line to the last one. We do this to keep + all lines of the same kind (i.e.verbatim or not) together in + one large buffer. */ + size_t n1, n; + + lb = sect->last_line; + n1 = strlen (lb->line); + n = n1 + 1 + strlen (line) + 1; + lb->line = xrealloc (lb->line, n); + strcpy (lb->line+n1, "\n"); + strcpy (lb->line+n1+1, line); + } + else + { + lb = xcalloc (1, sizeof *lb); + lb->verbatim = verbatim; + lb->line = xstrdup (line); + sect->last_line = lb; + *sect->lines_tail = lb; + sect->lines_tail = &lb->next; + } +} + + +/* Prepare for a new man page using the filename NAME. */ +static void +start_page (char *name) +{ + if (verbose) + inf ("starting page `%s'", name); + assert (!thepage.name); + thepage.name = xstrdup (name); + thepage.n_sections = 0; +} + + +/* Write the .TH entry of the current page. Return -1 if there is a + problem with the page. */ +static int +write_th (FILE *fp) +{ + char *name, *p; + + name = ascii_strupr (xstrdup (thepage.name)); + p = strrchr (name, '.'); + if (!p || !p[1]) + { + err ("no section name in man page `%s'", thepage.name); + free (name); + return -1; + } + *p++ = 0; + fprintf (fp, ".TH %s %s %s \"%s\" \"%s\"\n", + name, p, isodatestring (), opt_release, opt_source); + return 0; +} + + +/* Process the texinfo command COMMAND (without the leading @) and + write output if needed to FP. REST is the remainer of the line + which should either point to an opening brace or to a white space. + The function returns the number of characters already processed + from REST. LEN is the usable length of REST. TABLE_LEVEL is used to + control the indentation of tables. */ +static size_t +proc_texi_cmd (FILE *fp, const char *command, const char *rest, size_t len, + int *table_level, int *eol_action) +{ + static struct { + const char *name; /* Name of the command. */ + int what; /* What to do with this command. */ + const char *lead_in; /* String to print with a opening brace. */ + const char *lead_out;/* String to print with the closing brace. */ + } cmdtbl[] = { + { "command", 0, "\\fB", "\\fR" }, + { "code", 0, "\\fB", "\\fR" }, + { "sc", 0, "\\fB", "\\fR" }, + { "var", 0, "\\fI", "\\fR" }, + { "samp", 0, "\n'", "'\n" }, + { "file", 0, "`\\fI","\\fR'" }, + { "env", 0, "`\\fI","\\fR'" }, + { "acronym", 0 }, + { "dfn", 0 }, + { "option", 0, "\\fB", "\\fR" }, + { "example", 1, ".RS 2\n.nf\n" }, + { "smallexample", 1, ".RS 2\n.nf\n" }, + { "asis", 7 }, + { "anchor", 7 }, + { "cartouche", 1 }, + { "xref", 0, "see: [", "]" }, + { "pxref", 0, "see: [", "]" }, + { "uref", 0, "(\\fB", "\\fR)" }, + { "footnote",0, " ([", "])" }, + { "emph", 0, "\\fI", "\\fR" }, + { "w", 1 }, + { "c", 5 }, + { "opindex", 1 }, + { "cpindex", 1 }, + { "cindex", 1 }, + { "node", 1 }, + { "noindent", 0 }, + { "section", 1 }, + { "chapter", 1 }, + { "subsection", 6, "\n.SS " }, + { "chapheading", 0}, + { "item", 2, ".TP\n.B " }, + { "itemx", 2, ".TP\n.B " }, + { "table", 3 }, + { "end", 4 }, + { "quotation",1, ".RS\n\\fB" }, + { "ifset", 1 }, + { "ifclear", 1 }, + { NULL } + }; + size_t n; + int i; + const char *s; + const char *lead_out = NULL; + int ignore_args = 0; + + for (i=0; cmdtbl[i].name && strcmp (cmdtbl[i].name, command); i++) + ; + if (cmdtbl[i].name) + { + s = cmdtbl[i].lead_in; + if (s) + fputs (s, fp); + lead_out = cmdtbl[i].lead_out; + switch (cmdtbl[i].what) + { + case 1: /* Throw away the entire line. */ + s = memchr (rest, '\n', len); + return s? (s-rest)+1 : len; + case 2: /* Handle @item. */ + break; + case 3: /* Handle table. */ + if (++(*table_level) > 1) + fputs (".RS\n", fp); + /* Now throw away the entire line. */ + s = memchr (rest, '\n', len); + return s? (s-rest)+1 : len; + break; + case 4: /* Handle end. */ + for (s=rest, n=len; n && (*s == ' ' || *s == '\t'); s++, n--) + ; + if (n >= 5 && !memcmp (s, "table", 5) + && (!n || s[5] == ' ' || s[5] == '\t' || s[5] == '\n')) + { + if ((*table_level)-- > 1) + fputs (".RE\n", fp); + } + else if (n >= 7 && !memcmp (s, "example", 7) + && (!n || s[7] == ' ' || s[7] == '\t' || s[7] == '\n')) + { + fputs (".fi\n.RE\n", fp); + } + else if (n >= 12 && !memcmp (s, "smallexample", 12) + && (!n || s[12] == ' ' || s[12] == '\t' || s[12] == '\n')) + { + fputs (".fi\n.RE\n", fp); + } + else if (n >= 9 && !memcmp (s, "quotation", 9) + && (!n || s[9] == ' ' || s[9] == '\t' || s[9] == '\n')) + { + fputs ("\\fR\n.RE\n", fp); + } + else if (n >= 5 && !memcmp (s, "ifset", 5) + && (!n || s[5] == ' ' || s[5] == '\t' || s[5] == '\n')) + { + fputs ("\\fR\n.RE\n", fp); + } + /* Now throw away the entire line. */ + s = memchr (rest, '\n', len); + return s? (s-rest)+1 : len; + case 5: /* Handle special comments. */ + for (s=rest, n=len; n && (*s == ' ' || *s == '\t'); s++, n--) + ; + if (n >= 4 && !memcmp (s, "man:", 4)) + { + for (s+=4, n-=4; n && *s != '\n'; n--, s++) + putc (*s, fp); + putc ('\n', fp); + } + /* Now throw away the entire line. */ + s = memchr (rest, '\n', len); + return s? (s-rest)+1 : len; + case 6: + *eol_action = 1; + break; + case 7: + ignore_args = 1; + break; + default: + break; + } + } + else + { + inf ("texinfo command `%s' not supported (%.*s)", command, + ((s = memchr (rest, '\n', len)), (s? (s-rest) : len)), rest); + } + + if (*rest == '{') + { + /* Find matching closing brace. */ + for (s=rest+1, n=1, i=1; i && *s && n < len; s++, n++) + if (*s == '{') + i++; + else if (*s == '}') + i--; + if (i) + { + err ("closing brace for command `%s' not found", command); + return len; + } + if (n > 2 && !ignore_args) + proc_texi_buffer (fp, rest+1, n-2, table_level, eol_action); + } + else + n = 0; + + if (lead_out) + fputs (lead_out, fp); + + return n; +} + + + +/* Process the string LINE with LEN bytes of Texinfo content. */ +static void +proc_texi_buffer (FILE *fp, const char *line, size_t len, + int *table_level, int *eol_action) +{ + const char *s; + char cmdbuf[256]; + int cmdidx = 0; + int in_cmd = 0; + size_t n; + + for (s=line; *s && len; s++, len--) + { + if (in_cmd) + { + if (in_cmd == 1) + { + switch (*s) + { + case '@': case '{': case '}': + putc (*s, fp); in_cmd = 0; + break; + case ':': /* Not ending a sentence flag. */ + in_cmd = 0; + break; + case '.': case '!': case '?': /* Ending a sentence. */ + putc (*s, fp); in_cmd = 0; + break; + case ' ': case '\t': case '\n': /* Non collapsing spaces. */ + putc (*s, fp); in_cmd = 0; + break; + default: + cmdidx = 0; + cmdbuf[cmdidx++] = *s; + in_cmd++; + break; + } + } + else if (*s == '{' || *s == ' ' || *s == '\t' || *s == '\n') + { + cmdbuf[cmdidx] = 0; + n = proc_texi_cmd (fp, cmdbuf, s, len, table_level, eol_action); + assert (n <= len); + s += n; len -= n; + s--; len++; + in_cmd = 0; + } + else if (cmdidx < sizeof cmdbuf -1) + cmdbuf[cmdidx++] = *s; + else + { + err ("texinfo command too long - ignored"); + in_cmd = 0; + } + } + else if (*s == '@') + in_cmd = 1; + else if (*s == '\n') + { + switch (*eol_action) + { + case 1: /* Create a dummy paragraph. */ + fputs ("\n\\ \n", fp); + break; + default: + putc (*s, fp); + } + *eol_action = 0; + } + else + putc (*s, fp); + } +} + + +/* Do something with the Texinfo line LINE. */ +static void +parse_texi_line (FILE *fp, const char *line, int *table_level) +{ + int eol_action = 0; + + /* A quick test whether there are any texinfo commands. */ + if (!strchr (line, '@')) + { + fputs (line, fp); + putc ('\n', fp); + return; + } + proc_texi_buffer (fp, line, strlen (line), table_level, &eol_action); + putc ('\n', fp); +} + + +/* Write all the lines LINES to FP. */ +static void +write_content (FILE *fp, line_buffer_t lines) +{ + line_buffer_t line; + int table_level = 0; + + for (line = lines; line; line = line->next) + { + if (line->verbatim) + { + fputs (line->line, fp); + putc ('\n', fp); + } + else + { +/* fputs ("TEXI---", fp); */ +/* fputs (line->line, fp); */ +/* fputs ("---\n", fp); */ + parse_texi_line (fp, line->line, &table_level); + } + } +} + + + +static int +is_standard_section (const char *name) +{ + int i; + const char *s; + + for (i=0; (s=standard_sections[i]); i++) + if (!strcmp (s, name)) + return 1; + return 0; +} + + +/* Finish a page; that is sort the data and write it out to the file. */ +static void +finish_page (void) +{ + FILE *fp; + section_buffer_t sect; + int idx; + const char *s; + int i; + + if (!thepage.name) + return; /* No page active. */ + + if (verbose) + inf ("finishing page `%s'", thepage.name); + + if (opt_select) + { + if (!strcmp (opt_select, thepage.name)) + { + inf ("selected `%s'", thepage.name ); + fp = stdout; + } + else + { + fp = fopen ( "/dev/null", "w" ); + if (!fp) + die ("failed to open /dev/null: %s\n", strerror (errno)); + } + } + else if (opt_store) + { + inf ("writing `%s'", thepage.name ); + fp = fopen ( thepage.name, "w" ); + if (!fp) + die ("failed to create `%s': %s\n", thepage.name, strerror (errno)); + } + else + fp = stdout; + + if (write_th (fp)) + goto leave; + + for (idx=0; (s=standard_sections[idx]); idx++) + { + for (i=0; i < thepage.n_sections; i++) + { + sect = thepage.sections + i; + if (sect->name && !strcmp (s, sect->name)) + break; + } + if (i == thepage.n_sections) + sect = NULL; + + if (sect) + { + fprintf (fp, ".SH %s\n", sect->name); + write_content (fp, sect->lines); + /* Now continue with all non standard sections directly + following this one. */ + for (i++; i < thepage.n_sections; i++) + { + sect = thepage.sections + i; + if (sect->name && is_standard_section (sect->name)) + break; + if (sect->name) + { + fprintf (fp, ".SH %s\n", sect->name); + write_content (fp, sect->lines); + } + } + + } + } + + + leave: + if (fp != stdout) + fclose (fp); + free (thepage.name); + thepage.name = NULL; + /* FIXME: Cleanup the content. */ +} + + + + +/* Parse one Texinfo file and create manpages according to the + embedded instructions. */ +static void +parse_file (const char *fname, FILE *fp, char **section_name, int in_pause) +{ + char *line; + int lnr = 0; + int in_verbatim = 0; + int skip_to_end = 0; /* Used to skip over menu entries. */ + int skip_sect_line = 0; /* Skip after @mansect. */ + + line = xmalloc (LINESIZE); + while (fgets (line, LINESIZE, fp)) + { + size_t n = strlen (line); + int got_line = 0; + char *p; + + lnr++; + if (!n || line[n-1] != '\n') + { + err ("%s:$d: trailing linefeed missing, line too long or " + "embedded Nul character", fname, lnr); + break; + } + line[--n] = 0; + + if (skip_sect_line) + { + skip_sect_line = 0; + if (!strncmp (line, "@section", 8) + || !strncmp (line, "@subsection", 11) + || !strncmp (line, "@chapheading", 12)) + continue; + } + + /* We only parse lines we need and ignore the rest. There are a + few macros used to control this as well as one @ifset + command. Parts we know about are saved away into containers + separate for each section. */ + if (*line == '@') + { + for (p=line+1, n=1; *p && *p != ' ' && *p != '\t'; p++) + n++; + while (*p == ' ' || *p == '\t') + p++; + + if (skip_to_end + && n == 4 && !memcmp (line, "@end", 4) + && (line[4]==' '||line[4]=='\t'||!line[4])) + { + skip_to_end = 0; + } + else if (n == 6 && !memcmp (line, "@ifset", 6) + && !strncmp (p, "manverb", 7) && (p[7]==' '||p[7]=='\t'||!p[7])) + { + if (in_verbatim) + err ("%s:%d: nested \"@ifset manverb\"", fname, lnr); + else + in_verbatim = 1; + } + else if (in_verbatim && n == 4 && !memcmp (line, "@end", 4) + && !strncmp (p, "ifset", 5) + && (p[5]==' '||p[5]=='\t'||!p[5])) + { + in_verbatim = 0; + } + else if (in_verbatim) + { + got_line = 1; + } + else if (n == 8 && !memcmp (line, "@manpage", 8)) + { + free (*section_name); + *section_name = NULL; + finish_page (); + start_page (p); + in_pause = 0; + } + else if (n == 8 && !memcmp (line, "@mansect", 8)) + { + if (!thepage.name) + err ("%s:%d: section outside of a man page", fname, lnr); + else + { + free (*section_name); + *section_name = ascii_strupr (xstrdup (p)); + in_pause = 0; + skip_sect_line = 1; + } + } + else if (n == 9 && !memcmp (line, "@manpause", 9)) + { + if (!*section_name) + err ("%s:%d: pausing outside of a man section", fname, lnr); + else if (in_pause) + err ("%s:%d: already pausing", fname, lnr); + else + in_pause = 1; + } + else if (n == 8 && !memcmp (line, "@mancont", 8)) + { + if (!*section_name) + err ("%s:%d: continue outside of a man section", fname, lnr); + else if (!in_pause) + err ("%s:%d: continue while not pausing", fname, lnr); + else + in_pause = 0; + } + else if (n == 5 && !memcmp (line, "@menu", 5) + && (line[5]==' '||line[5]=='\t'||!line[5])) + { + skip_to_end = 1; + } + else if (n == 8 && !memcmp (line, "@ifclear", 8) + && !strncmp (p, "isman", 5) && (p[5]==' '||p[5]=='\t'||!p[5])) + { + skip_to_end = 1; + } + else if (n == 8 && !memcmp (line, "@include", 8) + && (line[8]==' '||line[8]=='\t'||!line[8])) + { + char *incname = xstrdup (p); + FILE *incfp = fopen (incname, "r"); + + if (!incfp && opt_include && *opt_include && *p != '/') + { + free (incname); + incname = xmalloc (strlen (opt_include) + 1 + + strlen (p) + 1); + strcpy (incname, opt_include); + if ( incname[strlen (incname)-1] != '/' ) + strcat (incname, "/"); + strcat (incname, p); + incfp = fopen (incname, "r"); + } + + if (!incfp) + err ("can't open include file `%s':%s", + incname, strerror (errno)); + else + { + parse_file (incname, incfp, section_name, in_pause); + fclose (incfp); + } + free (incname); + } + else if (!skip_to_end) + got_line = 1; + } + else if (!skip_to_end) + got_line = 1; + + if (got_line && in_verbatim) + add_content (*section_name, line, 1); + else if (got_line && thepage.name && *section_name && !in_pause) + add_content (*section_name, line, 0); + + } + if (ferror (fp)) + err ("%s:%d: read error: %s", fname, lnr, strerror (errno)); + free (line); +} + + +static void +top_parse_file (const char *fname, FILE *fp) +{ + char *section_name = NULL; /* Name of the current section or NULL + if not in a section. */ + parse_file (fname, fp, §ion_name, 0); + free (section_name); + finish_page (); +} + + +int +main (int argc, char **argv) +{ + int last_argc = -1; + + opt_source = "GNU"; + opt_release = ""; + + if (argc) + { + argc--; argv++; + } + while (argc && last_argc != argc ) + { + last_argc = argc; + if (!strcmp (*argv, "--")) + { + argc--; argv++; + break; + } + else if (!strcmp (*argv, "--help")) + { + puts ( + "Usage: " PGM " [OPTION] [FILE]\n" + "Extract man pages from a Texinfo source.\n\n" + " --source NAME use NAME as source field\n" + " --release STRING use STRING as the release field\n" + " --store write output using @manpage name\n" + " --select NAME only output pages with @manpage NAME\n" + " --verbose enable extra informational output\n" + " --debug enable additional debug output\n" + " --help display this help and exit\n" + " -I DIR also search in include DIR\n\n" + "With no FILE, or when FILE is -, read standard input.\n\n" + "Report bugs to ."); + exit (0); + } + else if (!strcmp (*argv, "--version")) + { + puts (PGM " " VERSION "\n" + "Copyright (C) 2005 g10 Code GmbH\n" + "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."); + exit (0); + } + else if (!strcmp (*argv, "--verbose")) + { + verbose = 1; + argc--; argv++; + } + else if (!strcmp (*argv, "--quiet")) + { + quiet = 1; + argc--; argv++; + } + else if (!strcmp (*argv, "--debug")) + { + verbose = debug = 1; + argc--; argv++; + } + else if (!strcmp (*argv, "--source")) + { + argc--; argv++; + if (argc) + { + opt_source = *argv; + argc--; argv++; + } + } + else if (!strcmp (*argv, "--release")) + { + argc--; argv++; + if (argc) + { + opt_release = *argv; + argc--; argv++; + } + } + else if (!strcmp (*argv, "--store")) + { + opt_store = 1; + argc--; argv++; + } + else if (!strcmp (*argv, "--select")) + { + argc--; argv++; + if (argc) + { + opt_select = strrchr (*argv, '/'); + if (opt_select) + opt_select++; + else + opt_select = *argv; + argc--; argv++; + } + } + else if (!strcmp (*argv, "-I")) + { + argc--; argv++; + if (argc) + { + opt_include = *argv; + argc--; argv++; + } + } + } + + if (argc > 1) + die ("usage: " PGM " [OPTION] [FILE] (try --help for more information)\n"); + + /* Start processing. */ + if (argc && strcmp (*argv, "-")) + { + FILE *fp = fopen (*argv, "rb"); + if (!fp) + die ("%s:0: can't open file: %s", *argv, strerror (errno)); + top_parse_file (*argv, fp); + fclose (fp); + } + else + top_parse_file ("-", stdin); + + return !!any_error; +} + + +/* +Local Variables: +compile-command: "gcc -Wall -g -Wall -o yat2m yat2m.c" +End: +*/ From cvs at cvs.gnupg.org Mon Sep 4 16:57:43 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon Sep 4 16:13:47 2006 Subject: [svn] dirmngr - r233 - in trunk: . po src Message-ID: Author: wk Date: 2006-09-04 16:57:42 +0200 (Mon, 04 Sep 2006) New Revision: 233 Modified: trunk/ChangeLog trunk/NEWS trunk/TODO trunk/po/de.po trunk/po/dirmngr.pot trunk/src/ChangeLog trunk/src/crlfetch.c trunk/src/http.c trunk/src/http.h trunk/src/ocsp.c Log: Well, here are the man pages Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-09-04 14:53:44 UTC (rev 232) +++ trunk/ChangeLog 2006-09-04 14:57:42 UTC (rev 233) @@ -1,3 +1,7 @@ +2006-09-04 Werner Koch + + * doc/Makefile.am (dirmngr_TEXINFOS): Do not distribute the fdl.texi. + 2006-08-31 Werner Koch * configure.ac: Require ksba 1.0.0 and added API check for it. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-09-04 14:53:44 UTC (rev 232) +++ trunk/NEWS 2006-09-04 14:57:42 UTC (rev 233) @@ -8,7 +8,11 @@ * No more lost file descriptors when loading CRLs via HTTP. + * HTTP redirection for CRL and OCSP has been implemented. + * Man pages are now build and installed from the texinfo sources. + + Noteworthy changes in version 0.9.5 (2006-06-27) ------------------------------------------------ Modified: trunk/TODO =================================================================== --- trunk/TODO 2006-09-04 14:53:44 UTC (rev 232) +++ trunk/TODO 2006-09-04 14:57:42 UTC (rev 233) @@ -28,3 +28,7 @@ available and using OCSP with the same responder is point less. Needs more investigation. +* Test OCSP responder redirection. + We need to figure out an OCSP responder actually using rediection. + + Modified: trunk/po/de.po =================================================================== --- trunk/po/de.po 2006-09-04 14:53:44 UTC (rev 232) +++ trunk/po/de.po 2006-09-04 14:57:42 UTC (rev 233) @@ -7,8 +7,8 @@ msgstr "" "Project-Id-Version: dirmngr 0.9.2\n" "Report-Msgid-Bugs-To: gpa-dev@gnupg.org\n" -"POT-Creation-Date: 2006-09-01 18:25+0200\n" -"PO-Revision-Date: 2005-11-02 08:26+0100\n" +"POT-Creation-Date: 2006-09-04 14:49+0200\n" +"PO-Revision-Date: 2006-09-04 14:59+0200\n" "Last-Translator: Werner Koch \n" "Language-Team: de\n" "MIME-Version: 1.0\n" @@ -70,9 +70,9 @@ msgstr "Zertifikat `%s' ist bereits im Zwischenspeicher\n" #: src/certcache.c:375 -#, fuzzy, c-format +#, c-format msgid "trusted certificate `%s' loaded\n" -msgstr "Zertifikat `%s' wurde geladen\n" +msgstr "Vertrauensw?rdiges Zertifikat `%s' wurde geladen\n" #: src/certcache.c:377 #, c-format @@ -80,13 +80,13 @@ msgstr "Zertifikat `%s' wurde geladen\n" #: src/certcache.c:381 -#, fuzzy, c-format +#, c-format msgid " SHA1 fingerprint = %s\n" -msgstr "SHA1 Fingerabdruck=%s\n" +msgstr " SHA1 Fingerabdruck=%s\n" #: src/certcache.c:384 msgid " name =" -msgstr "" +msgstr " name =" #: src/certcache.c:388 #, c-format @@ -428,7 +428,7 @@ msgid "converting S-expression failed: %s\n" msgstr "Konvertierung der S-Expression fehlgeschlagen: %s\n" -#: src/crlcache.c:1474 src/ocsp.c:372 +#: src/crlcache.c:1474 src/ocsp.c:414 #, c-format msgid "creating S-expression failed: %s\n" msgstr "Erzeugen der S-Expression fehlgeschlagen: %s\n" @@ -618,7 +618,7 @@ msgid "End CRL dump\n" msgstr "Ende CRL Ausgabe\n" -#: src/crlcache.c:2159 src/crlfetch.c:154 src/ldap.c:699 +#: src/crlcache.c:2159 src/crlfetch.c:150 src/ldap.c:699 #, c-format msgid "error initializing reader object: %s\n" msgstr "Fehler beim Initialisieren des \"reader\" Objekts: %s\n" @@ -645,28 +645,37 @@ #: src/crlfetch.c:60 msgid "reader to file mapping table full - waiting\n" -msgstr "" +msgstr "\"reader to file\" Zuordnungstabelle ist voll - warte\n" -#: src/crlfetch.c:115 +#: src/crlfetch.c:117 msgid "using \"http\" instead of \"https\"\n" msgstr "Es wird \"HTTP\" anstatt \"HTTPS\" verwendet\n" -#: src/crlfetch.c:126 src/crlfetch.c:171 src/crlfetch.c:191 src/crlfetch.c:209 +#: src/crlfetch.c:128 src/crlfetch.c:209 src/crlfetch.c:229 src/crlfetch.c:247 #, c-format msgid "CRL access not possible due to disabled %s\n" msgstr "CRL Zugriff nicht m?glich da %s abgeschaltet ist\n" -#: src/crlfetch.c:137 +#: src/crlfetch.c:169 src/ocsp.c:210 #, c-format +msgid "URL `%s' redirected to `%s' (%u)\n" +msgstr "URL `%s' nach `%s' umgeleitet (%u)\n" + +#: src/crlfetch.c:188 src/ocsp.c:227 +msgid "too many redirections\n" +msgstr "zu viele verschachtelte Umleitungen\n" + +#: src/crlfetch.c:194 +#, c-format msgid "error retrieving `%s': %s\n" msgstr "Fehler beim Holen von `%s': %s\n" -#: src/crlfetch.c:140 +#: src/crlfetch.c:199 #, c-format msgid "error retrieving `%s': http status %u\n" msgstr "Fehler beim Holen von `%s': HTTP Status %u\n" -#: src/crlfetch.c:223 +#: src/crlfetch.c:261 #, c-format msgid "certificate search not possible due to disabled %s\n" msgstr "Zertifikatsuche ist nicht m?glich da %s abgeschaltet ist\n" @@ -1025,14 +1034,14 @@ msgid "error spawning connection handler: %s\n" msgstr "Fehler beim Starten des Verbindungshandler: %s\n" -#: src/http.c:1447 +#: src/http.c:1610 #, c-format msgid "error creating socket: %s\n" msgstr "Fehler beim Erzeugen des Sockets: %s\n" -#: src/http.c:1491 +#: src/http.c:1654 msgid "host not found" -msgstr "" +msgstr "Server nicht gefunden" #: src/ldap.c:137 #, c-format @@ -1165,156 +1174,155 @@ msgid "response from server too large; limit is %d bytes\n" msgstr "Antwort vom Server zu lang; die Grenze sind %d Bytes\n" -#: src/ocsp.c:134 +#: src/ocsp.c:136 msgid "OCSP request not possible due to disabled HTTP\n" msgstr "OCSP Anfrage nicht m?glich da HTTP abgeschaltet ist\n" -#: src/ocsp.c:141 +#: src/ocsp.c:143 #, c-format msgid "error setting OCSP target: %s\n" msgstr "Fehler beim Setzen des OCSP Ziels: %s\n" -#: src/ocsp.c:159 +#: src/ocsp.c:161 #, c-format msgid "error building OCSP request: %s\n" msgstr "Fehler beim Aufbauen der OCSP Anfrage: %s\n" -#: src/ocsp.c:168 +#: src/ocsp.c:173 #, c-format msgid "error connecting to `%s': %s\n" msgstr "Fehler beim Verbinden mit '%s': %s\n" -#: src/ocsp.c:192 src/ocsp.c:208 +#: src/ocsp.c:199 src/ocsp.c:247 #, c-format msgid "error reading HTTP response for `%s': %s\n" msgstr "Fehler beim Lesen der HTTP Antwort von `%s': %s\n" -#: src/ocsp.c:196 +#: src/ocsp.c:232 #, c-format msgid "error accessing `%s': http status %u\n" msgstr "Fehler beim Zugreifen auf `%s': HTTP Status %u\n" -#: src/ocsp.c:217 +#: src/ocsp.c:257 #, c-format msgid "error parsing OCSP response for `%s': %s\n" msgstr "Fehler beim Zerlegen der OCSP Antwort f?r `%s': %s\n" -#: src/ocsp.c:239 src/ocsp.c:249 +#: src/ocsp.c:280 src/ocsp.c:290 #, c-format msgid "OCSP responder at `%s' status: %s\n" msgstr "OCSP Responder `%s' Status: %s\n" -#: src/ocsp.c:244 +#: src/ocsp.c:285 #, c-format msgid "hashing the OCSP response for `%s' failed: %s\n" msgstr "Hashen der OCSP Antwort f?r `%s' fehlgeschlagen: %s\n" -#: src/ocsp.c:274 -#, fuzzy +#: src/ocsp.c:316 msgid "not signed by default OCSP signer certificate" -msgstr "Kein voreingestellter OCSP \"Signer\" definiert\n" +msgstr "Nicht durch voreingestellten OCSP \"Signer\" signiert" -#: src/ocsp.c:364 +#: src/ocsp.c:406 msgid "only SHA-1 is supported for OCSP responses\n" msgstr "Lediglich SHA-1 wird bei OCSP Antworten unterst?tzt\n" -#: src/ocsp.c:413 -#, fuzzy, c-format +#: src/ocsp.c:455 +#, c-format msgid "allocating list item failed: %s\n" msgstr "malloc() fehlgeschlagen: %s\n" -#: src/ocsp.c:428 -#, fuzzy, c-format +#: src/ocsp.c:470 +#, c-format msgid "error getting responder ID: %s\n" -msgstr "Fehler beim Lesen vom Responder: %s\n" +msgstr "Fehler beim Holen der Responder-ID: %s\n" -#: src/ocsp.c:462 +#: src/ocsp.c:504 msgid "no suitable certificate found to verify the OCSP response\n" msgstr "" "Kein benutzbares Zertifikat zur ?berpr?fung der OCSP Antwort gefunden\n" -#: src/ocsp.c:499 src/validate.c:519 +#: src/ocsp.c:541 src/validate.c:519 #, c-format msgid "issuer certificate not found: %s\n" msgstr "Herausgeberzertifikat nicht gefunden: %s\n" -#: src/ocsp.c:509 +#: src/ocsp.c:551 msgid "caller did not return the target certificate\n" msgstr "Aufrufer gab das Ziel Zertifikat nicht zur?ck\n" -#: src/ocsp.c:516 +#: src/ocsp.c:558 msgid "caller did not return the issuing certificate\n" msgstr "Aufrufer gab das Issuer Zertifikat nicht zur?ck\n" -#: src/ocsp.c:526 +#: src/ocsp.c:568 #, c-format msgid "failed to allocate OCSP context: %s\n" msgstr "Fehler beim Bereitstellen eines OCSP Kontext: %s\n" -#: src/ocsp.c:560 +#: src/ocsp.c:602 #, c-format msgid "can't get authorityInfoAccess: %s\n" msgstr "authorityInfoAccess kann nicht geholt werden: %s\n" -#: src/ocsp.c:567 +#: src/ocsp.c:609 msgid "no default OCSP responder defined\n" msgstr "Kein voreingestellter OCSP Responder definiert\n" -#: src/ocsp.c:573 +#: src/ocsp.c:615 msgid "no default OCSP signer defined\n" msgstr "Kein voreingestellter OCSP \"Signer\" definiert\n" -#: src/ocsp.c:580 +#: src/ocsp.c:622 #, c-format msgid "using default OCSP responder `%s'\n" msgstr "Der voreingestellte OCSP Responder `%s' wird benutzt\n" -#: src/ocsp.c:585 +#: src/ocsp.c:627 #, c-format msgid "using OCSP responder `%s'\n" msgstr "Der OCSP Responder `%s' wird benutzt\n" -#: src/ocsp.c:592 +#: src/ocsp.c:634 #, c-format msgid "failed to establish a hashing context for OCSP: %s\n" msgstr "Kontext zum Hashen von OCSP kann nicht erzeugt werden: %s\n" -#: src/ocsp.c:622 +#: src/ocsp.c:664 #, c-format msgid "error getting OCSP status for target certificate: %s\n" msgstr "Fehler beim Holen des OCSP Status f?r das Zielzertifikat: %s\n" -#: src/ocsp.c:647 +#: src/ocsp.c:689 #, c-format msgid "certificate status is: %s (this=%s next=%s)\n" msgstr "Zertifikatstatus ist: %s (this=%s next=%s)\n" -#: src/ocsp.c:648 +#: src/ocsp.c:690 msgid "good" msgstr "Gut" -#: src/ocsp.c:649 +#: src/ocsp.c:691 msgid "revoked" msgstr "Widerrufen" -#: src/ocsp.c:650 +#: src/ocsp.c:692 msgid "unknown" msgstr "Unbekannt" -#: src/ocsp.c:651 +#: src/ocsp.c:693 msgid "none" msgstr "Kein" -#: src/ocsp.c:654 +#: src/ocsp.c:696 #, c-format msgid "certificate has been revoked at: %s due to: %s\n" msgstr "Zertifikat wurde widerrufen am: %s wegen: %s\n" -#: src/ocsp.c:687 +#: src/ocsp.c:729 msgid "OCSP responder returned an too old status\n" msgstr "OCSP Responder gab einen zu alten Status zur?ck\n" -#: src/ocsp.c:697 +#: src/ocsp.c:739 msgid "OCSP responder returned a non-current status\n" msgstr "OCSP Responder gab einen nicht aktuellen Status zur?ck\n" @@ -1401,9 +1409,9 @@ msgstr "Die Zertifikatrichtlinie ist nicht erlaubt" #: src/validate.c:187 -#, fuzzy msgid "accepting root CA not marked as a CA" -msgstr "Das Herausgeberzertifikat ist nicht f?r eine CA gekennzeichnet" +msgstr "" +"Herausgeberzertifikat akzeptiert obgleich nicht f?r eine CA gekennzeichnet" #: src/validate.c:191 msgid "issuer certificate is not marked as a CA" @@ -1415,16 +1423,15 @@ #: src/validate.c:231 msgid "not checking CRL for" -msgstr "" +msgstr "keine Pr?fung der CRL f?r" #: src/validate.c:236 -#, fuzzy msgid "checking CRL for" -msgstr "Die CRL konnte nicht gepr?ft werden: %s" +msgstr "Pr?fen der CRL f?r" #: src/validate.c:297 msgid "running in compatibility mode - certificate chain not checked!\n" -msgstr "" +msgstr "Kompatibilit?tsmodus - Zertifikatkette nicht gepr?ft!\n" #: src/validate.c:382 #, c-format @@ -1482,14 +1489,12 @@ msgstr "Die Zertifikatkette ist l?nger als von der CA erlaubt (%d)" #: src/validate.c:618 -#, fuzzy msgid "certificate is good\n" msgstr "Zertifikat ist g?ltig\n" #: src/validate.c:638 -#, fuzzy msgid "certificate chain is good\n" -msgstr "Der Zertifikatkette ist zu lang\n" +msgstr "Der Zertifikatkette ist g?ltig\n" #: src/validate.c:856 msgid "DSA requires the use of a 160 bit hash algorithm\n" @@ -1516,9 +1521,9 @@ "sollen\n" #: src/validate.c:1004 -#, fuzzy msgid "certificate should have not been used for CRL signing\n" -msgstr "Das Zertifikat h??tte nicht zum Signieren benutzt werden sollen\n" +msgstr "" +"Das Zertifikat h?tte nicht zum Signieren einer CRL benutzt werden sollen\n" #: src/validate.c:1015 msgid "certificate should have not been used for encryption\n" Modified: trunk/po/dirmngr.pot =================================================================== --- trunk/po/dirmngr.pot 2006-09-04 14:53:44 UTC (rev 232) +++ trunk/po/dirmngr.pot 2006-09-04 14:57:42 UTC (rev 233) @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: gpa-dev@gnupg.org\n" -"POT-Creation-Date: 2006-09-01 18:25+0200\n" +"POT-Creation-Date: 2006-09-04 14:49+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -405,7 +405,7 @@ msgid "converting S-expression failed: %s\n" msgstr "" -#: src/crlcache.c:1474 src/ocsp.c:372 +#: src/crlcache.c:1474 src/ocsp.c:414 #, c-format msgid "creating S-expression failed: %s\n" msgstr "" @@ -582,7 +582,7 @@ msgid "End CRL dump\n" msgstr "" -#: src/crlcache.c:2159 src/crlfetch.c:154 src/ldap.c:699 +#: src/crlcache.c:2159 src/crlfetch.c:150 src/ldap.c:699 #, c-format msgid "error initializing reader object: %s\n" msgstr "" @@ -611,26 +611,35 @@ msgid "reader to file mapping table full - waiting\n" msgstr "" -#: src/crlfetch.c:115 +#: src/crlfetch.c:117 msgid "using \"http\" instead of \"https\"\n" msgstr "" -#: src/crlfetch.c:126 src/crlfetch.c:171 src/crlfetch.c:191 src/crlfetch.c:209 +#: src/crlfetch.c:128 src/crlfetch.c:209 src/crlfetch.c:229 src/crlfetch.c:247 #, c-format msgid "CRL access not possible due to disabled %s\n" msgstr "" -#: src/crlfetch.c:137 +#: src/crlfetch.c:169 src/ocsp.c:210 #, c-format +msgid "URL `%s' redirected to `%s' (%u)\n" +msgstr "" + +#: src/crlfetch.c:188 src/ocsp.c:227 +msgid "too many redirections\n" +msgstr "" + +#: src/crlfetch.c:194 +#, c-format msgid "error retrieving `%s': %s\n" msgstr "" -#: src/crlfetch.c:140 +#: src/crlfetch.c:199 #, c-format msgid "error retrieving `%s': http status %u\n" msgstr "" -#: src/crlfetch.c:223 +#: src/crlfetch.c:261 #, c-format msgid "certificate search not possible due to disabled %s\n" msgstr "" @@ -977,12 +986,12 @@ msgid "error spawning connection handler: %s\n" msgstr "" -#: src/http.c:1447 +#: src/http.c:1610 #, c-format msgid "error creating socket: %s\n" msgstr "" -#: src/http.c:1491 +#: src/http.c:1654 msgid "host not found" msgstr "" @@ -1117,154 +1126,154 @@ msgid "response from server too large; limit is %d bytes\n" msgstr "" -#: src/ocsp.c:134 +#: src/ocsp.c:136 msgid "OCSP request not possible due to disabled HTTP\n" msgstr "" -#: src/ocsp.c:141 +#: src/ocsp.c:143 #, c-format msgid "error setting OCSP target: %s\n" msgstr "" -#: src/ocsp.c:159 +#: src/ocsp.c:161 #, c-format msgid "error building OCSP request: %s\n" msgstr "" -#: src/ocsp.c:168 +#: src/ocsp.c:173 #, c-format msgid "error connecting to `%s': %s\n" msgstr "" -#: src/ocsp.c:192 src/ocsp.c:208 +#: src/ocsp.c:199 src/ocsp.c:247 #, c-format msgid "error reading HTTP response for `%s': %s\n" msgstr "" -#: src/ocsp.c:196 +#: src/ocsp.c:232 #, c-format msgid "error accessing `%s': http status %u\n" msgstr "" -#: src/ocsp.c:217 +#: src/ocsp.c:257 #, c-format msgid "error parsing OCSP response for `%s': %s\n" msgstr "" -#: src/ocsp.c:239 src/ocsp.c:249 +#: src/ocsp.c:280 src/ocsp.c:290 #, c-format msgid "OCSP responder at `%s' status: %s\n" msgstr "" -#: src/ocsp.c:244 +#: src/ocsp.c:285 #, c-format msgid "hashing the OCSP response for `%s' failed: %s\n" msgstr "" -#: src/ocsp.c:274 +#: src/ocsp.c:316 msgid "not signed by default OCSP signer certificate" msgstr "" -#: src/ocsp.c:364 +#: src/ocsp.c:406 msgid "only SHA-1 is supported for OCSP responses\n" msgstr "" -#: src/ocsp.c:413 +#: src/ocsp.c:455 #, c-format msgid "allocating list item failed: %s\n" msgstr "" -#: src/ocsp.c:428 +#: src/ocsp.c:470 #, c-format msgid "error getting responder ID: %s\n" msgstr "" -#: src/ocsp.c:462 +#: src/ocsp.c:504 msgid "no suitable certificate found to verify the OCSP response\n" msgstr "" -#: src/ocsp.c:499 src/validate.c:519 +#: src/ocsp.c:541 src/validate.c:519 #, c-format msgid "issuer certificate not found: %s\n" msgstr "" -#: src/ocsp.c:509 +#: src/ocsp.c:551 msgid "caller did not return the target certificate\n" msgstr "" -#: src/ocsp.c:516 +#: src/ocsp.c:558 msgid "caller did not return the issuing certificate\n" msgstr "" -#: src/ocsp.c:526 +#: src/ocsp.c:568 #, c-format msgid "failed to allocate OCSP context: %s\n" msgstr "" -#: src/ocsp.c:560 +#: src/ocsp.c:602 #, c-format msgid "can't get authorityInfoAccess: %s\n" msgstr "" -#: src/ocsp.c:567 +#: src/ocsp.c:609 msgid "no default OCSP responder defined\n" msgstr "" -#: src/ocsp.c:573 +#: src/ocsp.c:615 msgid "no default OCSP signer defined\n" msgstr "" -#: src/ocsp.c:580 +#: src/ocsp.c:622 #, c-format msgid "using default OCSP responder `%s'\n" msgstr "" -#: src/ocsp.c:585 +#: src/ocsp.c:627 #, c-format msgid "using OCSP responder `%s'\n" msgstr "" -#: src/ocsp.c:592 +#: src/ocsp.c:634 #, c-format msgid "failed to establish a hashing context for OCSP: %s\n" msgstr "" -#: src/ocsp.c:622 +#: src/ocsp.c:664 #, c-format msgid "error getting OCSP status for target certificate: %s\n" msgstr "" -#: src/ocsp.c:647 +#: src/ocsp.c:689 #, c-format msgid "certificate status is: %s (this=%s next=%s)\n" msgstr "" -#: src/ocsp.c:648 +#: src/ocsp.c:690 msgid "good" msgstr "" -#: src/ocsp.c:649 +#: src/ocsp.c:691 msgid "revoked" msgstr "" -#: src/ocsp.c:650 +#: src/ocsp.c:692 msgid "unknown" msgstr "" -#: src/ocsp.c:651 +#: src/ocsp.c:693 msgid "none" msgstr "" -#: src/ocsp.c:654 +#: src/ocsp.c:696 #, c-format msgid "certificate has been revoked at: %s due to: %s\n" msgstr "" -#: src/ocsp.c:687 +#: src/ocsp.c:729 msgid "OCSP responder returned an too old status\n" msgstr "" -#: src/ocsp.c:697 +#: src/ocsp.c:739 msgid "OCSP responder returned a non-current status\n" msgstr "" Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2006-09-04 14:53:44 UTC (rev 232) +++ trunk/src/ChangeLog 2006-09-04 14:57:42 UTC (rev 233) @@ -1,3 +1,15 @@ +2006-09-04 Werner Koch + + * crlfetch.c (crl_fetch): Implement HTTP redirection. + * ocsp.c (do_ocsp_request): Ditto. + + New HTTP code version taken from gnupg svn release 4236. + * http.c (http_get_header): New. + (capitalize_header_name, store_header): New. + (parse_response): Store headers away. + (send_request): Return GPG_ERR_NOT_FOUND if connect_server failed. + * http.h: New flag HTTP_FLAG_NEED_HEADER. + 2006-09-01 Werner Koch * crlfetch.c (register_file_reader, get_file_reader): New. Modified: trunk/src/crlfetch.c =================================================================== --- trunk/src/crlfetch.c 2006-09-04 14:53:44 UTC (rev 232) +++ trunk/src/crlfetch.c 2006-09-04 14:57:42 UTC (rev 233) @@ -93,9 +93,11 @@ gpg_error_t err; parsed_uri_t uri; char *free_this = NULL; + int redirects_left = 2; /* We allow for 2 redirect levels. */ *reader = NULL; + once_more: err = http_parse_uri (&uri, url); http_release_parsed_uri (uri); if (err && url && !strncmp (url, "https:", 6)) @@ -130,39 +132,75 @@ else err = http_open_document (&hd, url, NULL, (opt.honor_http_proxy? HTTP_FLAG_TRY_PROXY:0) - |HTTP_FLAG_NO_SHUTDOWN, + |HTTP_FLAG_NO_SHUTDOWN + |HTTP_FLAG_NEED_HEADER, opt.http_proxy, NULL); - if (err) - log_error (_("error retrieving `%s': %s\n"), url, gpg_strerror (err)); - else if (http_get_status_code (hd) != 200) + switch ( err? 99999 : http_get_status_code (hd) ) { + case 200: + { + FILE *fp = http_get_read_ptr (hd); + + err = ksba_reader_new (reader); + if (!err) + err = ksba_reader_set_file (*reader, fp); + if (err) + { + log_error (_("error initializing reader object: %s\n"), + gpg_strerror (err)); + ksba_reader_release (*reader); + *reader = NULL; + http_close (hd, 0); + } + else + { + register_file_reader (*reader, fp); + http_close (hd, 1); + } + } + break; + + case 301: /* Redirection (perm.). */ + case 302: /* Redirection (temp.). */ + { + const char *s = http_get_header (hd, "Location"); + + log_info (_("URL `%s' redirected to `%s' (%u)\n"), + url, s?s:"[none]", http_get_status_code (hd)); + if (s && *s && redirects_left-- ) + { + xfree (free_this); url = NULL; + free_this = xtrystrdup (s); + if (!free_this) + err = gpg_error_from_errno (errno); + else + { + url = free_this; + http_close (hd, 0); + /* Note, that our implementation of redirection + actually handles a redirect to LDAP. */ + goto once_more; + } + } + else + err = gpg_error (GPG_ERR_NO_DATA); + log_error (_("too many redirections\n")); /* Or no "Location". */ + http_close (hd, 0); + } + break; + + case 99999: /* Made up status code foer error reporting. */ + log_error (_("error retrieving `%s': %s\n"), + url, gpg_strerror (err)); + break; + + default: log_error (_("error retrieving `%s': http status %u\n"), url, http_get_status_code (hd)); err = gpg_error (GPG_ERR_NO_DATA); http_close (hd, 0); } - else - { - FILE *fp = http_get_read_ptr (hd); - - err = ksba_reader_new (reader); - if (!err) - err = ksba_reader_set_file (*reader, fp); - if (err) - { - log_error (_("error initializing reader object: %s\n"), - gpg_strerror (err)); - ksba_reader_release (*reader); - *reader = NULL; - http_close (hd, 0); - } - else - { - register_file_reader (*reader, fp); - http_close (hd, 1); - } - } } else /* Let the LDAP code try other schemes. */ { @@ -175,8 +213,8 @@ else err = url_fetch_ldap (ctrl, url, NULL, 0, reader); } - if (free_this) - xfree (free_this); + + xfree (free_this); return err; } Modified: trunk/src/http.c =================================================================== --- trunk/src/http.c 2006-09-04 14:53:44 UTC (rev 232) +++ trunk/src/http.c 2006-09-04 14:57:42 UTC (rev 233) @@ -65,6 +65,10 @@ typedef gnutls_transport_ptr gnutls_transport_ptr_t; #endif /*HTTP_USE_GNUTLS*/ +#ifdef TEST +#undef USE_DNS_SRV +#endif + #include "util.h" #include "http.h" #ifdef USE_DNS_SRV @@ -157,6 +161,17 @@ static gpg_error_t (*tls_callback) (http_t, gnutls_session_t, int); #endif /*HTTP_USE_GNUTLS*/ + +/* An object to save header lines. */ +struct header_s +{ + struct header_s *next; + char *value; /* The value of the header (malloced). */ + char name[1]; /* The name of the header (canonicalized). */ +}; +typedef struct header_s *header_t; + + /* Our handle context. */ struct http_context_s { @@ -178,6 +193,7 @@ char *buffer; /* Line buffer. */ size_t buffer_size; unsigned int flags; + header_t headers; /* Received headers. */ }; @@ -444,6 +460,13 @@ if (hd->fp_write) P_ES(fclose) (hd->fp_write); http_release_parsed_uri (hd->uri); + while (hd->headers) + { + header_t tmp = hd->headers->next; + xfree (hd->headers->value); + xfree (hd->headers); + hd->headers = tmp; + } xfree (hd->buffer); xfree (hd); } @@ -849,7 +872,9 @@ if (hd->sock == -1) { xfree (proxy_authstr); - return gpg_error_from_errno (save_errno); + return (save_errno + ? gpg_error_from_errno (save_errno) + : gpg_error (GPG_ERR_NOT_FOUND)); } #ifdef HTTP_USE_GNUTLS @@ -1160,6 +1185,129 @@ } +/* Transform a header name into a standard capitalized format; e.g. + "Content-Type". Conversion stops at the colon. As usual we don't + use the localized versions of ctype.h. */ +static void +capitalize_header_name (char *name) +{ + int first = 1; + + for (; *name && *name != ':'; name++) + { + if (*name == '-') + first = 1; + else if (first) + { + if (*name >= 'a' && *name <= 'z') + *name = *name - 'a' + 'A'; + first = 0; + } + else if (*name >= 'A' && *name <= 'Z') + *name = *name - 'A' + 'a'; + } +} + + +/* Store an HTTP header line in LINE away. Line continuation is + supported as well as merging of headers with the same name. This + function may modify LINE. */ +static gpg_error_t +store_header (http_t hd, char *line) +{ + size_t n; + char *p, *value; + header_t h; + + n = strlen (line); + if (n && line[n-1] == '\n') + { + line[--n] = 0; + if (n && line[n-1] == '\r') + line[--n] = 0; + } + if (!n) /* we are never called to hit this. */ + return gpg_error (GPG_ERR_BUG); + if (*line == ' ' || *line == '\t') + { + /* Continuation. This won't happen too often as it is not + recommended. We use a straightforward implementaion. */ + if (!hd->headers) + return gpg_error (GPG_ERR_PROTOCOL_VIOLATION); + n += strlen (hd->headers->value); + p = xtrymalloc (n+1); + if (!p) + return gpg_error_from_errno (errno); + strcpy (stpcpy (p, hd->headers->value), line); + xfree (hd->headers->value); + hd->headers->value = p; + return 0; + } + + capitalize_header_name (line); + p = strchr (line, ':'); + if (!p) + return gpg_error (GPG_ERR_PROTOCOL_VIOLATION); + *p++ = 0; + while (*p == ' ' || *p == '\t') + p++; + value = p; + + for (h=hd->headers; h; h = h->next) + if ( !strcmp (h->name, line) ) + break; + if (h) + { + /* We have already seen a line with that name. Thus we assume + it is a comma separated list and merge them. */ + p = xtrymalloc (strlen (h->value) + 1 + strlen (value)+ 1); + if (!p) + return gpg_error_from_errno (errno); + strcpy (stpcpy (stpcpy (p, h->value), ","), value); + xfree (h->value); + h->value = p; + return 0; + } + + /* Append a new header. */ + h = xtrymalloc (sizeof *h + strlen (line)); + if (!h) + return gpg_error_from_errno (errno); + strcpy (h->name, line); + h->value = xtrymalloc (strlen (value)+1); + if (!h->value) + { + xfree (h); + return gpg_error_from_errno (errno); + } + strcpy (h->value, value); + h->next = hd->headers; + hd->headers = h; + + return 0; +} + + +/* Return the header NAME from the last response. The returned value + is valid as along as HD has not been closed and no othe request has + been send. If the header was not found, NULL is returned. Name + must be canonicalized, that is the first letter of each dash + delimited part must be uppercase and all other letters lowercase. + Note that the context must have been opened with the + HTTP_FLAG_NEED_HEADER. */ +const char * +http_get_header (http_t hd, const char *name) +{ + header_t h; + + for (h=hd->headers; h; h = h->next) + if ( !strcmp (h->name, name) ) + return h->value; + return NULL; +} + + + /* * Parse the response from a server. * Returns: Errorcode and sets some files in the handle @@ -1170,6 +1318,15 @@ char *line, *p, *p2; size_t maxlen, len; + /* Delete old header lines. */ + while (hd->headers) + { + header_t tmp = hd->headers->next; + xfree (hd->headers->value); + xfree (hd->headers); + hd->headers = tmp; + } + /* Wait for the status line. */ do { @@ -1231,6 +1388,12 @@ if ( (hd->flags & HTTP_FLAG_LOG_RESP) ) log_info ("RESP: `%.*s'\n", (int)strlen(line)-(*line&&line[1]?2:0),line); + if ( (hd->flags & HTTP_FLAG_NEED_HEADER) && *line ) + { + gpg_error_t err = store_header (hd, line); + if (err) + return err; + } } while (len && *line); @@ -1703,6 +1866,7 @@ gnutls_certificate_credentials certcred; const int certprio[] = { GNUTLS_CRT_X509, 0 }; #endif /*HTTP_USE_GNUTLS*/ + header_t hdr; #ifdef HTTP_USE_ESTREAM es_init (); @@ -1792,7 +1956,8 @@ http_release_parsed_uri (uri); uri = NULL; - rc = http_open_document (&hd, *argv, NULL, HTTP_FLAG_NO_SHUTDOWN, + rc = http_open_document (&hd, *argv, NULL, + HTTP_FLAG_NO_SHUTDOWN | HTTP_FLAG_NEED_HEADER, NULL, tls_session); if (rc) { @@ -1801,8 +1966,19 @@ } log_info ("open_http_document succeeded; status=%u\n", http_get_status_code (hd)); - while ((c = P_ES(getc) (http_get_read_ptr (hd))) != EOF) - putchar (c); + for (hdr = hd->headers; hdr; hdr = hdr->next) + printf ("HDR: %s: %s\n", hdr->name, hdr->value); + switch (http_get_status_code (hd)) + { + case 200: + while ((c = P_ES(getc) (http_get_read_ptr (hd))) != EOF) + putchar (c); + break; + case 301: + case 302: + printf ("Redirected to `%s'\n", http_get_header (hd, "Location")); + break; + } http_close (hd, 0); #ifdef HTTP_USE_GNUTLS Modified: trunk/src/http.h =================================================================== --- trunk/src/http.h 2006-09-04 14:53:44 UTC (rev 232) +++ trunk/src/http.h 2006-09-04 14:57:42 UTC (rev 233) @@ -66,7 +66,8 @@ HTTP_FLAG_TRY_PROXY = 1, HTTP_FLAG_NO_SHUTDOWN = 2, HTTP_FLAG_TRY_SRV = 4, - HTTP_FLAG_LOG_RESP = 8 + HTTP_FLAG_LOG_RESP = 8, + HTTP_FLAG_NEED_HEADER = 16 }; struct http_context_s; @@ -106,6 +107,7 @@ FILE *http_get_write_ptr (http_t hd); #endif /*!HTTP_USE_ESTREAM*/ unsigned int http_get_status_code (http_t hd); +const char *http_get_header (http_t hd, const char *name); char *http_escape_string (const char *string, const char *specials); Modified: trunk/src/ocsp.c =================================================================== --- trunk/src/ocsp.c 2006-09-04 14:53:44 UTC (rev 232) +++ trunk/src/ocsp.c 2006-09-04 14:57:42 UTC (rev 233) @@ -128,6 +128,8 @@ http_t http; ksba_ocsp_response_status_t response_status; const char *t; + int redirects_left = 2; + char *free_this = NULL; if (opt.disable_http) { @@ -160,12 +162,16 @@ return err; } + once_more: err = http_open (&http, HTTP_REQ_POST, url, NULL, - opt.honor_http_proxy? HTTP_FLAG_TRY_PROXY:0, opt.http_proxy, + (opt.honor_http_proxy? HTTP_FLAG_TRY_PROXY:0) + |HTTP_FLAG_NEED_HEADER, + opt.http_proxy, NULL); if (err) { log_error (_("error connecting to `%s': %s\n"), url, gpg_strerror (err)); + xfree (free_this); return err; } @@ -180,6 +186,7 @@ log_error ("error sending request to `%s': %s\n", url, strerror (errno)); http_close (http, 0); xfree (request); + xfree (free_this); return err; } xfree (request); @@ -193,11 +200,43 @@ url, gpg_strerror (err)); else { - log_error (_("error accessing `%s': http status %u\n"), - url, http_get_status_code (http)); - err = gpg_error (GPG_ERR_NO_DATA); + switch (http_get_status_code (http)) + { + case 301: + case 302: + { + const char *s = http_get_header (http, "Location"); + + log_info (_("URL `%s' redirected to `%s' (%u)\n"), + url, s?s:"[none]", http_get_status_code (http)); + if (s && *s && redirects_left-- ) + { + xfree (free_this); url = NULL; + free_this = xtrystrdup (s); + if (!free_this) + err = gpg_error_from_errno (errno); + else + { + url = free_this; + http_close (http, 0); + goto once_more; + } + } + else + err = gpg_error (GPG_ERR_NO_DATA); + log_error (_("too many redirections\n")); + } + break; + + default: + log_error (_("error accessing `%s': http status %u\n"), + url, http_get_status_code (http)); + err = gpg_error (GPG_ERR_NO_DATA); + break; + } } http_close (http, 0); + xfree (free_this); return err; } @@ -207,6 +246,7 @@ { log_error (_("error reading HTTP response for `%s': %s\n"), url, gpg_strerror (err)); + xfree (free_this); return err; } @@ -217,6 +257,7 @@ log_error (_("error parsing OCSP response for `%s': %s\n"), url, gpg_strerror (err)); xfree (response); + xfree (free_this); return err; } @@ -251,6 +292,7 @@ } xfree (response); + xfree (free_this); return err; } From cvs at cvs.gnupg.org Mon Sep 4 18:39:01 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon Sep 4 17:55:08 2006 Subject: [svn] dirmngr - r234 - in trunk: . jnlib Message-ID: Author: wk Date: 2006-09-04 18:39:01 +0200 (Mon, 04 Sep 2006) New Revision: 234 Modified: trunk/ChangeLog trunk/NEWS trunk/TODO trunk/configure.ac trunk/jnlib/ChangeLog trunk/jnlib/argparse.c trunk/jnlib/argparse.h trunk/jnlib/dotlock.c trunk/jnlib/dotlock.h trunk/jnlib/libjnlib-config.h trunk/jnlib/logging.c trunk/jnlib/logging.h trunk/jnlib/mischelp.h trunk/jnlib/stringhelp.c trunk/jnlib/stringhelp.h trunk/jnlib/strlist.c trunk/jnlib/strlist.h trunk/jnlib/types.h trunk/jnlib/utf8conv.c trunk/jnlib/utf8conv.h trunk/jnlib/xmalloc.c trunk/jnlib/xmalloc.h Log: Updated jnlib Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-09-04 14:57:42 UTC (rev 233) +++ trunk/ChangeLog 2006-09-04 16:39:01 UTC (rev 234) @@ -1,5 +1,7 @@ 2006-09-04 Werner Koch + Released 0.9.6. + * doc/Makefile.am (dirmngr_TEXINFOS): Do not distribute the fdl.texi. 2006-08-31 Werner Koch Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-09-04 14:57:42 UTC (rev 233) +++ trunk/NEWS 2006-09-04 16:39:01 UTC (rev 234) @@ -1,16 +1,16 @@ -Noteworthy changes in version 0.9.6 +Noteworthy changes in version 0.9.6 (2006-09-04) ------------------------------------------------ * A couple of bug fixes for OCSP. - * OCSP does not make use of the responder ID and optionally included - certificates in the response to locate certificate. + * OCSP does now make use of the responder ID and optionally included + certificates in the response to locate certificates. * No more lost file descriptors when loading CRLs via HTTP. * HTTP redirection for CRL and OCSP has been implemented. - * Man pages are now build and installed from the texinfo sources. + * Man pages are now build and installed from the texinfo source. Noteworthy changes in version 0.9.5 (2006-06-27) Modified: trunk/TODO =================================================================== --- trunk/TODO 2006-09-04 14:57:42 UTC (rev 233) +++ trunk/TODO 2006-09-04 16:39:01 UTC (rev 234) @@ -24,7 +24,7 @@ * Various problems with German SigG certs We need to implement the chain-validation-model and come up with a - way to verify the intermediate certificates. Tehre are no CRLs + way to verify the intermediate certificates. There are no CRLs available and using OCSP with the same responder is point less. Needs more investigation. Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-09-04 14:57:42 UTC (rev 233) +++ trunk/configure.ac 2006-09-04 16:39:01 UTC (rev 234) @@ -23,7 +23,7 @@ AC_PREREQ(2.59) min_automake_version="1.9.3" -AC_INIT(dirmngr, 0.9.6-cvs, gpa-dev@gnupg.org) +AC_INIT(dirmngr, 0.9.6, gpa-dev@gnupg.org) NEED_GPG_ERROR_VERSION=1.0 Modified: trunk/jnlib/ChangeLog =================================================================== --- trunk/jnlib/ChangeLog 2006-09-04 14:57:42 UTC (rev 233) +++ trunk/jnlib/ChangeLog 2006-09-04 16:39:01 UTC (rev 234) @@ -1,3 +1,56 @@ +2006-09-04 Werner Koch + + Updated to current jnlib version of GnuPG SVN revision 4236. + + * logging.c (do_logv): Emit a missing LF for fatal errors. + + * dotlock.c (make_dotlock, release_dotlock, read_lockfile) + (maybe_deadlock, destroy_dotlock, create_dotlock): Re-indented. + (create_dotlock): Repalces some log_fatal by log_error as it was + not intended that they should terminate. Write the nodename to + the locking file. Code cleanups. + (read_lockfile): Reworked to read the node name. + (make_dotlock): Test for identical node name and delete lock stale + file. + (release_dotlock): Likewise. + + * libjnlib-config.h (JNLIB_NEED_UTF8CONV): Fixed typo in name. + + * dotlock.c (release_dotlock): Don't act if we don't have any + locks at all. + (destroy_dotlock): New. From 1.4.3. + (dotlock_remove_lockfiles): Make use of destroy function. + + * strlist.c (append_to_strlist2): Enabled. + + * stringhelp.c (print_sanitized_buffer2): New. Changed the rules + to match the behaviour of print_string2 from gnupg 1.4.3. + (print_sanitized_buffer): Use the new function. + (print_sanitized_string2): New. + (hextobyte): New. Taken from gpg 1.4.3. + + * stringhelp.c (print_sanitized_buffer): Fix bug where the count + got wrong for the \xNN representation. + (sanitize_buffer): Fix bug where some control characters lose part + of their \xNN representation. + + * stringhelp.c (make_basename): New arg INPUTPATH for future + riscos compatibility. + + * libjnlib-config.h (JNLIB_NEED_UTF8CONF): Defined. + * strlist.c (add_to_strlist2) [JNLIB_NEED_UTF8CONV]: Enabled. + + * stringhelp.c (sanitize_buffer): Make P a void*. + (ascii_memistr, memistr): Ditto. + (ascii_memcasecmp): Ditto. + * logging.c (writen): Use void * for arg BUFFER. + * stringhelp.c (memistr): Fixed unsigned/signed pointer conflict. + (ascii_memistr): Ditto. + (ascii_memcasemem): Ditto. + * utf8conv.c (utf8_to_native): Ditto. + (utf8_to_native): Ditto. + * argparse.c (show_version): Removed non-required cast. + 2005-01-19 Werner Koch * logging.c (fun_writer): Don't fallback to stderr. Print to Modified: trunk/jnlib/argparse.c =================================================================== --- trunk/jnlib/argparse.c 2006-09-04 14:57:42 UTC (rev 233) +++ trunk/jnlib/argparse.c 2006-09-04 16:39:01 UTC (rev 234) @@ -1,21 +1,22 @@ /* [argparse.c wk 17.06.97] Argument Parser for option handling * Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. * - * This file is part of GnuPG. + * This file is part of GnuPG. * - * GnuPG 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. + * GnuPG 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. * - * GnuPG 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. + * GnuPG 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 + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. */ #include @@ -852,7 +853,7 @@ /* additional program info */ for(i=30; i < 40; i++ ) if( (s=strusage(i)) ) - fputs( (const byte*)s, stdout); + fputs (s, stdout); fflush(stdout); } @@ -904,7 +905,7 @@ switch( level ) { case 11: p = "foo"; break; case 13: p = "0.0"; break; - case 14: p = "Copyright (C) 2005 Free Software Foundation, Inc."; break; + case 14: p = "Copyright (C) 2006 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" @@ -920,7 +921,8 @@ "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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n"; +"Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,\n" +"USA.\n"; break; case 40: /* short and long usage */ case 41: p = ""; break; Modified: trunk/jnlib/argparse.h =================================================================== --- trunk/jnlib/argparse.h 2006-09-04 14:57:42 UTC (rev 233) +++ trunk/jnlib/argparse.h 2006-09-04 16:39:01 UTC (rev 234) @@ -15,7 +15,8 @@ * * 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. */ #ifndef LIBJNLIB_ARGPARSE_H Modified: trunk/jnlib/dotlock.c =================================================================== --- trunk/jnlib/dotlock.c 2006-09-04 14:57:42 UTC (rev 233) +++ trunk/jnlib/dotlock.c 2006-09-04 16:39:01 UTC (rev 234) @@ -1,5 +1,6 @@ /* dotlock.c - dotfile locking - * Copyright (C) 1998,2000,2001,2003 Free Software Foundation, Inc. + * Copyright (C) 1998, 2000, 2001, 2003, 2004, + * 2005, 2006 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -15,7 +16,8 @@ * * 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. */ #include @@ -53,32 +55,35 @@ #endif -struct dotlock_handle { - struct dotlock_handle *next; - char *tname; /* name of lockfile template */ - char *lockname; /* name of the real lockfile */ - int locked; /* lock status */ - int disable; /* locking */ +struct dotlock_handle +{ + struct dotlock_handle *next; + char *tname; /* Name of lockfile template. */ + size_t nodename_off; /* Offset in TNAME of the nodename part. */ + size_t nodename_len; /* Length of the nodename part. */ + char *lockname; /* Name of the real lockfile. */ + int locked; /* Lock status. */ + int disable; /* When true, locking is disabled. */ }; static volatile DOTLOCK all_lockfiles; static int never_lock; -static int read_lockfile( const char *name ); +static int read_lockfile (DOTLOCK h, int *same_node); void disable_dotlock(void) { - never_lock = 1; + never_lock = 1; } /**************** * Create a lockfile with the given name and return an object of * type DOTLOCK which may be used later to actually do the lock. * A cleanup routine gets installed to cleanup left over locks - * or other files used together with the lockmechanism. - * Althoug the function is called dotlock, this does not necessarily + * or other files used together with the lock mechanism. + * Although the function is called dotlock, this does not necessarily * mean that real lockfiles are used - the function may decide to * use fcntl locking. Calling the function with NULL only install * the atexit handler and maybe used to assure that the cleanup @@ -92,229 +97,286 @@ DOTLOCK create_dotlock( const char *file_to_lock ) { - static int initialized; - DOTLOCK h; - int fd = -1; - char pidstr[16]; - #ifndef HAVE_DOSISH_SYSTEM - struct utsname utsbuf; - #endif - const char *nodename; - const char *dirpart; - int dirpartlen; + static int initialized; + DOTLOCK h; + int fd = -1; + char pidstr[16]; + const char *nodename; + const char *dirpart; + int dirpartlen; +#ifndef HAVE_DOSISH_SYSTEM + struct utsname utsbuf; +#endif - if( !initialized ) { - atexit( dotlock_remove_lockfiles ); - initialized = 1; + if ( !initialized ) + { + atexit( dotlock_remove_lockfiles ); + initialized = 1; } - if( !file_to_lock ) - return NULL; + if ( !file_to_lock ) + return NULL; /* Only initialization was requested. */ - h = jnlib_xcalloc( 1, sizeof *h ); - if( never_lock ) { - h->disable = 1; + h = jnlib_xcalloc ( 1, sizeof *h ); + if( never_lock ) + { + h->disable = 1; #ifdef _REENTRANT - /* fixme: aquire mutex on all_lockfiles */ + /* fixme: aquire mutex on all_lockfiles */ #endif - h->next = all_lockfiles; - all_lockfiles = h; - return h; + h->next = all_lockfiles; + all_lockfiles = h; + return h; } #ifndef HAVE_DOSISH_SYSTEM - sprintf( pidstr, "%10d\n", (int)getpid() ); - /* fixme: add the hostname to the second line (FQDN or IP addr?) */ + sprintf (pidstr, "%10d\n", (int)getpid() ); + /* fixme: add the hostname to the second line (FQDN or IP addr?) */ - /* create a temporary file */ - if( uname( &utsbuf ) ) - nodename = "unknown"; - else - nodename = utsbuf.nodename; - + /* Create a temporary file. */ + if ( uname ( &utsbuf ) ) + nodename = "unknown"; + else + nodename = utsbuf.nodename; + #ifdef __riscos__ - { - char *iter = (char *) nodename; - for (; iter[0]; iter++) - if (iter[0] == '.') - iter[0] = '/'; - } + { + char *iter = (char *) nodename; + for (; iter[0]; iter++) + if (iter[0] == '.') + iter[0] = '/'; + } #endif /* __riscos__ */ - if( !(dirpart = strrchr( file_to_lock, DIRSEP_C )) ) { - dirpart = EXTSEP_S; - dirpartlen = 1; + if ( !(dirpart = strrchr ( file_to_lock, DIRSEP_C )) ) + { + dirpart = EXTSEP_S; + dirpartlen = 1; } - else { - dirpartlen = dirpart - file_to_lock; - dirpart = file_to_lock; + else + { + dirpartlen = dirpart - file_to_lock; + dirpart = file_to_lock; } - #ifdef _REENTRANT +#ifdef _REENTRANT /* fixme: aquire mutex on all_lockfiles */ - #endif - h->next = all_lockfiles; - all_lockfiles = h; +#endif + h->next = all_lockfiles; + all_lockfiles = h; - h->tname = jnlib_xmalloc( dirpartlen + 6+30+ strlen(nodename) + 11 ); + h->tname = jnlib_xmalloc ( dirpartlen + 6+30+ strlen(nodename) + 11 ); + h->nodename_len = strlen (nodename); #ifndef __riscos__ - sprintf( h->tname, "%.*s/.#lk%p.%s.%d", - dirpartlen, dirpart, h, nodename, (int)getpid() ); + sprintf (h->tname, "%.*s/.#lk%p.", dirpartlen, dirpart, h ); + h->nodename_off = strlen (h->tname); + sprintf (h->tname+h->nodename_off, "%s.%d", nodename, (int)getpid ()); #else /* __riscos__ */ - sprintf( h->tname, "%.*s.lk%p/%s/%d", - dirpartlen, dirpart, h, nodename, (int)getpid() ); + sprintf (h->tname, "%.*s.lk%p/", dirpartlen, dirpart, h ); + h->nodename_off = strlen (h->tname); + sprintf (h->tname+h->nodename_off, "%s/%d", nodename, (int)getpid () ); #endif /* __riscos__ */ - do { - errno = 0; - fd = open( h->tname, O_WRONLY|O_CREAT|O_EXCL, - S_IRUSR|S_IRGRP|S_IROTH|S_IWUSR ); - } while( fd == -1 && errno == EINTR ); - if( fd == -1 ) { - all_lockfiles = h->next; - log_error( "failed to create temporary file `%s': %s\n", - h->tname, strerror(errno)); - jnlib_free(h->tname); - jnlib_free(h); - return NULL; + do + { + errno = 0; + fd = open (h->tname, O_WRONLY|O_CREAT|O_EXCL, + S_IRUSR|S_IRGRP|S_IROTH|S_IWUSR ); + } + while (fd == -1 && errno == EINTR); + + if ( fd == -1 ) + { + all_lockfiles = h->next; + log_error ( "failed to create temporary file `%s': %s\n", + h->tname, strerror(errno)); + jnlib_free(h->tname); + jnlib_free(h); + return NULL; } - if( write(fd, pidstr, 11 ) != 11 ) { - all_lockfiles = h->next; - #ifdef _REENTRANT - /* release mutex */ - #endif - log_fatal( "error writing to `%s': %s\n", h->tname, strerror(errno) ); - close(fd); - unlink(h->tname); - jnlib_free(h->tname); - jnlib_free(h); - return NULL; - } - if( close(fd) ) { - all_lockfiles = h->next; - #ifdef _REENTRANT - /* release mutex */ - #endif - log_fatal( "error writing to `%s': %s\n", h->tname, strerror(errno) ); - close(fd); - unlink(h->tname); - jnlib_free(h->tname); - jnlib_free(h); - return NULL; - } + if ( write (fd, pidstr, 11 ) != 11 ) + goto write_failed; + if ( write (fd, nodename, strlen (nodename) ) != strlen (nodename) ) + goto write_failed; + if ( write (fd, "\n", 1 ) != 1 ) + goto write_failed; + if ( close (fd) ) + goto write_failed; - #ifdef _REENTRANT - /* release mutex */ - #endif +# ifdef _REENTRANT + /* release mutex */ +# endif #endif /* !HAVE_DOSISH_SYSTEM */ - h->lockname = jnlib_xmalloc( strlen(file_to_lock) + 6 ); - strcpy(stpcpy(h->lockname, file_to_lock), EXTSEP_S "lock"); - return h; + h->lockname = jnlib_xmalloc ( strlen (file_to_lock) + 6 ); + strcpy (stpcpy(h->lockname, file_to_lock), EXTSEP_S "lock"); + return h; + write_failed: + all_lockfiles = h->next; +# ifdef _REENTRANT + /* fixme: release mutex */ +# endif + log_error ( "error writing to `%s': %s\n", h->tname, strerror(errno) ); + close(fd); + unlink(h->tname); + jnlib_free(h->tname); + jnlib_free(h); + return NULL; } + +void +destroy_dotlock ( DOTLOCK h ) +{ +#ifndef HAVE_DOSISH_SYSTEM + if ( h ) + { + DOTLOCK hprev, htmp; + + /* First remove the handle from our global list of all locks. */ + for (hprev=NULL, htmp=all_lockfiles; htmp; hprev=htmp, htmp=htmp->next) + if (htmp == h) + { + if (hprev) + hprev->next = htmp->next; + else + all_lockfiles = htmp->next; + h->next = NULL; + break; + } + + /* Second destroy the lock. */ + if (!h->disable) + { + if (h->locked && h->lockname) + unlink (h->lockname); + if (h->tname) + unlink (h->tname); + jnlib_free (h->tname); + jnlib_free (h->lockname); + } + jnlib_free(h); + } +#endif /*!HAVE_DOSISH_SYSTEM*/ +} + + + static int maybe_deadlock( DOTLOCK h ) { - DOTLOCK r; + DOTLOCK r; - for( r=all_lockfiles; r; r = r->next ) { - if( r != h && r->locked ) - return 1; + for ( r=all_lockfiles; r; r = r->next ) + { + if ( r != h && r->locked ) + return 1; } - return 0; + return 0; } /**************** - * Do a lock on H. A TIMEOUT of 0 returns immediately, - * -1 waits forever (hopefully not), other - * values are timeouts in milliseconds. - * Returns: 0 on success + * Do a lock on H. A TIMEOUT of 0 returns immediately, -1 waits + * forever (hopefully not), other values are reserved (should then be + * timeouts in milliseconds). Returns: 0 on success */ int make_dotlock( DOTLOCK h, long timeout ) { #ifdef HAVE_DOSISH_SYSTEM - return 0; + return 0; #else - int pid; - const char *maybe_dead=""; - int backoff=0; + int pid; + const char *maybe_dead=""; + int backoff=0; + int same_node; - if( h->disable ) { - return 0; - } + if ( h->disable ) + return 0; /* Locks are completely disabled. Return success. */ - if( h->locked ) { + if ( h->locked ) + { #ifndef __riscos__ - log_debug("oops, `%s' is already locked\n", h->lockname ); + log_debug("oops, `%s' is already locked\n", h->lockname ); #endif /* !__riscos__ */ - return 0; + return 0; } - for(;;) { + for(;;) + { #ifndef __riscos__ - if( !link(h->tname, h->lockname) ) { - /* fixme: better use stat to check the link count */ - h->locked = 1; - return 0; /* okay */ + if ( !link(h->tname, h->lockname) ) + { + /* fixme: better use stat to check the link count */ + h->locked = 1; + return 0; /* okay */ } - if( errno != EEXIST ) { - log_error( "lock not made: link() failed: %s\n", strerror(errno) ); - return -1; + if ( errno != EEXIST ) + { + log_error( "lock not made: link() failed: %s\n", strerror(errno) ); + return -1; } #else /* __riscos__ */ - if( !renamefile(h->tname, h->lockname) ) { - h->locked = 1; - return 0; /* okay */ + if ( !renamefile(h->tname, h->lockname) ) + { + h->locked = 1; + return 0; /* okay */ } - if( errno != EEXIST ) { - log_error( "lock not made: rename() failed: %s\n", strerror(errno) ); - return -1; + if ( errno != EEXIST ) + { + log_error( "lock not made: rename() failed: %s\n", strerror(errno) ); + return -1; } #endif /* __riscos__ */ - if( (pid = read_lockfile(h->lockname)) == -1 ) { - if( errno != ENOENT ) { - log_info("cannot read lockfile\n"); - return -1; + + if ( (pid = read_lockfile (h, &same_node)) == -1 ) + { + if ( errno != ENOENT ) + { + log_info ("cannot read lockfile\n"); + return -1; } - log_info( "lockfile disappeared\n"); - continue; + log_info( "lockfile disappeared\n"); + continue; } - else if( pid == getpid() ) { - log_info( "Oops: lock already held by us\n"); - h->locked = 1; - return 0; /* okay */ + else if ( pid == getpid() && same_node ) + { + log_info( "Oops: lock already held by us\n"); + h->locked = 1; + return 0; /* okay */ } - else if( kill(pid, 0) && errno == ESRCH ) { + else if ( same_node && kill (pid, 0) && errno == ESRCH ) + { #ifndef __riscos__ - maybe_dead = " - probably dead"; -#if 0 /* we should not do this without checking the permissions */ - /* and the hostname */ - log_info( "removing stale lockfile (created by %d)", pid ); -#endif + log_info ("removing stale lockfile (created by %d)", pid ); + unlink (h->lockname); + continue; #else /* __riscos__ */ - /* we are *pretty* sure that the other task is dead and therefore - we remove the other lock file */ - maybe_dead = " - probably dead - removing lock"; - unlink(h->lockname); + /* Under RISCOS we are *pretty* sure that the other task + is dead and therefore we remove the stale lock file. */ + maybe_dead = " - probably dead - removing lock"; + unlink(h->lockname); #endif /* __riscos__ */ } - if( timeout == -1 ) { - struct timeval tv; - log_info( "waiting for lock (held by %d%s) %s...\n", - pid, maybe_dead, maybe_deadlock(h)? "(deadlock?) ":""); + if ( timeout == -1 ) + { + /* Wait until lock has been released. */ + struct timeval tv; + + log_info ("waiting for lock (held by %d%s) %s...\n", + pid, maybe_dead, maybe_deadlock(h)? "(deadlock?) ":""); - /* can't use sleep, cause signals may be blocked */ - tv.tv_sec = 1 + backoff; - tv.tv_usec = 0; - select(0, NULL, NULL, NULL, &tv); - if( backoff < 10 ) - backoff++ ; + + /* We can't use sleep, cause signals may be blocked. */ + tv.tv_sec = 1 + backoff; + tv.tv_usec = 0; + select(0, NULL, NULL, NULL, &tv); + if ( backoff < 10 ) + backoff++ ; } - else - return -1; + else + return -1; } - /*not reached */ + /*NOTREACHED*/ #endif /* !HAVE_DOSISH_SYSTEM */ } @@ -327,85 +389,150 @@ release_dotlock( DOTLOCK h ) { #ifdef HAVE_DOSISH_SYSTEM - return 0; + return 0; #else - int pid; + int pid, same_node; - if( h->disable ) { - return 0; - } + /* To avoid atexit race conditions we first check whether there are + any locks left. It might happen that another atexit handler + tries to release the lock while the atexit handler of this module + already ran and thus H is undefined. */ + if (!all_lockfiles) + return 0; - if( !h->locked ) { - log_debug("oops, `%s' is not locked\n", h->lockname ); - return 0; + if ( h->disable ) + return 0; + + if ( !h->locked ) + { + log_debug("oops, `%s' is not locked\n", h->lockname ); + return 0; } - pid = read_lockfile( h->lockname ); - if( pid == -1 ) { - log_error( "release_dotlock: lockfile error\n"); - return -1; + pid = read_lockfile (h, &same_node); + if ( pid == -1 ) + { + log_error( "release_dotlock: lockfile error\n"); + return -1; } - if( pid != getpid() ) { - log_error( "release_dotlock: not our lock (pid=%d)\n", pid); - return -1; + if ( pid != getpid() || !same_node ) + { + log_error( "release_dotlock: not our lock (pid=%d)\n", pid); + return -1; } #ifndef __riscos__ - if( unlink( h->lockname ) ) { - log_error( "release_dotlock: error removing lockfile `%s'", - h->lockname); - return -1; + if ( unlink( h->lockname ) ) + { + log_error( "release_dotlock: error removing lockfile `%s'", + h->lockname); + return -1; } #else /* __riscos__ */ - if( renamefile(h->lockname, h->tname) ) { - log_error( "release_dotlock: error renaming lockfile `%s' to `%s'", - h->lockname, h->tname); - return -1; + if ( renamefile(h->lockname, h->tname) ) + { + log_error( "release_dotlock: error renaming lockfile `%s' to `%s'", + h->lockname, h->tname); + return -1; } #endif /* __riscos__ */ - /* fixme: check that the link count is now 1 */ - h->locked = 0; - return 0; + /* fixme: check that the link count is now 1 */ + h->locked = 0; + return 0; #endif /* !HAVE_DOSISH_SYSTEM */ } -/**************** - * Read the lock file and return the pid, returns -1 on error. +/* + Read the lock file and return the pid, returns -1 on error. True + will be stored at SAME_NODE if the lock file has been created on + the same node. */ static int -read_lockfile( const char *name ) +read_lockfile (DOTLOCK h, int *same_node ) { #ifdef HAVE_DOSISH_SYSTEM - return 0; + return 0; #else - int fd, pid; - char pidstr[16]; + char buffer_space[10+1+70+1]; /* 70 is just an estimated value; node + name are usually shorter. */ + int fd, pid; + char *buffer, *p; + size_t expected_len; + int res, nread; + + *same_node = 0; + expected_len = 10 + 1 + h->nodename_len + 1; + if ( expected_len >= sizeof buffer_space) + buffer = jnlib_xmalloc (expected_len); + else + buffer = buffer_space; - if( (fd = open(name, O_RDONLY)) == -1 ) { - int e = errno; - log_debug("error opening lockfile `%s': %s\n", name, strerror(errno) ); - errno = e; - return -1; + if ( (fd = open (h->lockname, O_RDONLY)) == -1 ) + { + int e = errno; + log_info ("error opening lockfile `%s': %s\n", + h->lockname, strerror(errno) ); + if (buffer != buffer_space) + jnlib_free (buffer); + errno = e; /* Need to return ERRNO here. */ + return -1; } - if( read(fd, pidstr, 10 ) != 10 ) { /* Read 10 digits w/o newline */ - log_debug("error reading lockfile `%s'", name ); - close(fd); - errno = 0; - return -1; + + p = buffer; + nread = 0; + do + { + res = read (fd, p, expected_len - nread); + if (res == -1 && errno == EINTR) + continue; + if (res < 0) + { + log_info ("error reading lockfile `%s'", h->lockname ); + close (fd); + if (buffer != buffer_space) + jnlib_free (buffer); + errno = 0; /* Do not return an inappropriate ERRNO. */ + return -1; + } + p += res; + nread += res; } - pidstr[10] = 0; /* terminate pid string */ - close(fd); - pid = atoi(pidstr); + while (res && nread != expected_len); + close(fd); + + if (nread < 11) + { + log_info ("invalid size of lockfile `%s'", h->lockname ); + if (buffer != buffer_space) + jnlib_free (buffer); + errno = 0; /* Do not return an inappropriate ERRNO. */ + return -1; + } + + if (buffer[10] != '\n' + || (buffer[10] = 0, pid = atoi (buffer)) == -1 #ifndef __riscos__ - if( !pid || pid == -1 ) { + || !pid #else /* __riscos__ */ - if( (!pid && riscos_getpid()) || pid == -1 ) { + || (!pid && riscos_getpid()) #endif /* __riscos__ */ - log_error("invalid pid %d in lockfile `%s'", pid, name ); - errno = 0; - return -1; + ) + { + log_error ("invalid pid %d in lockfile `%s'", pid, h->lockname ); + if (buffer != buffer_space) + jnlib_free (buffer); + errno = 0; + return -1; } - return pid; + + if (nread == expected_len + && !memcmp (h->tname+h->nodename_off, buffer+11, h->nodename_len) + && buffer[11+h->nodename_len] == '\n') + *same_node = 1; + + if (buffer != buffer_space) + jnlib_free (buffer); + return pid; #endif } @@ -414,22 +541,16 @@ dotlock_remove_lockfiles() { #ifndef HAVE_DOSISH_SYSTEM - DOTLOCK h, h2; - - h = all_lockfiles; - all_lockfiles = NULL; - - while( h ) { - h2 = h->next; - if (!h->disable ) { - if( h->locked ) - unlink( h->lockname ); - unlink(h->tname); - jnlib_free(h->tname); - jnlib_free(h->lockname); - } - jnlib_free(h); - h = h2; + DOTLOCK h, h2; + + h = all_lockfiles; + all_lockfiles = NULL; + + while ( h ) + { + h2 = h->next; + destroy_dotlock (h); + h = h2; } #endif } Modified: trunk/jnlib/dotlock.h =================================================================== --- trunk/jnlib/dotlock.h 2006-09-04 14:57:42 UTC (rev 233) +++ trunk/jnlib/dotlock.h 2006-09-04 16:39:01 UTC (rev 234) @@ -15,7 +15,8 @@ * * 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. */ #ifndef LIBJNLIB_DOTLOCK_H @@ -26,6 +27,7 @@ void disable_dotlock (void); DOTLOCK create_dotlock(const char *file_to_lock); +void destroy_dotlock ( DOTLOCK h ); int make_dotlock (DOTLOCK h, long timeout); int release_dotlock (DOTLOCK h); void dotlock_remove_lockfiles (void); Modified: trunk/jnlib/libjnlib-config.h =================================================================== --- trunk/jnlib/libjnlib-config.h 2006-09-04 14:57:42 UTC (rev 233) +++ trunk/jnlib/libjnlib-config.h 2006-09-04 16:39:01 UTC (rev 234) @@ -15,7 +15,8 @@ * * 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. */ /**************** @@ -29,6 +30,10 @@ #include /* gcry_malloc & Cie. */ #include "logging.h" +/* We require support for utf-8 conversion. */ +#define JNLIB_NEED_UTF8CONV 1 + + #ifdef USE_SIMPLE_GETTEXT int set_gettext_file( const char *filename ); const char *gettext( const char *msgid ); Modified: trunk/jnlib/logging.c =================================================================== --- trunk/jnlib/logging.c 2006-09-04 14:57:42 UTC (rev 233) +++ trunk/jnlib/logging.c 2006-09-04 16:39:01 UTC (rev 234) @@ -16,7 +16,8 @@ * * 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. */ @@ -87,10 +88,11 @@ char name[1]; }; -/* Write NBYTES of BUF to file descriptor FD. */ +/* Write NBYTES of BUFFER to file descriptor FD. */ static int -writen (int fd, const unsigned char *buf, size_t nbytes) +writen (int fd, const void *buffer, size_t nbytes) { + const char *buf = buffer; size_t nleft = nbytes; int nwritten; @@ -484,9 +486,17 @@ } if (level == JNLIB_LOG_FATAL) - exit(2); + { + if (missing_lf) + putc('\n', logstream ); + exit(2); + } if (level == JNLIB_LOG_BUG) - abort(); + { + if (missing_lf) + putc('\n', logstream ); + abort(); + } } static void Modified: trunk/jnlib/logging.h =================================================================== --- trunk/jnlib/logging.h 2006-09-04 14:57:42 UTC (rev 233) +++ trunk/jnlib/logging.h 2006-09-04 16:39:01 UTC (rev 234) @@ -15,7 +15,8 @@ * * 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. */ #ifndef LIBJNLIB_LOGGING_H Modified: trunk/jnlib/mischelp.h =================================================================== --- trunk/jnlib/mischelp.h 2006-09-04 14:57:42 UTC (rev 233) +++ trunk/jnlib/mischelp.h 2006-09-04 16:39:01 UTC (rev 234) @@ -15,7 +15,8 @@ * * 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. */ #ifndef LIBJNLIB_MISCHELP_H Modified: trunk/jnlib/stringhelp.c =================================================================== --- trunk/jnlib/stringhelp.c 2006-09-04 14:57:42 UTC (rev 233) +++ trunk/jnlib/stringhelp.c 2006-09-04 16:39:01 UTC (rev 234) @@ -1,6 +1,6 @@ /* stringhelp.c - standard string helper functions - * Copyright (C) 1998, 1999, 2000, 2001, 2003, - * 2004 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005, + * 2006 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -16,7 +16,8 @@ * * 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. */ #include @@ -35,45 +36,57 @@ /* * Look for the substring SUB in buffer and return a pointer to that - * substring in BUF or NULL if not found. + * substring in BUFFER or NULL if not found. * Comparison is case-insensitive. */ const char * -memistr( const char *buf, size_t buflen, const char *sub ) +memistr (const void *buffer, size_t buflen, const char *sub) { - const byte *t, *s ; - size_t n; + const unsigned char *buf = buffer; + const unsigned char *t = (const unsigned char *)buffer; + const unsigned char *s = (const unsigned char *)sub; + size_t n = buflen; - for( t=buf, n=buflen, s=sub ; n ; t++, n-- ) - if( toupper(*t) == toupper(*s) ) { - for( buf=t++, buflen = n--, s++; - n && toupper(*t) == toupper(*s); t++, s++, n-- ) - ; - if( !*s ) - return buf; - t = buf; n = buflen; s = sub ; + for ( ; n ; t++, n-- ) + { + if ( toupper (*t) == toupper (*s) ) + { + for ( buf=t++, buflen = n--, s++; + n && toupper (*t) == toupper (*s); t++, s++, n-- ) + ; + if (!*s) + return (const char*)buf; + t = buf; + s = (const unsigned char *)sub ; + n = buflen; } - - return NULL ; + } + return NULL; } const char * -ascii_memistr( const char *buf, size_t buflen, const char *sub ) +ascii_memistr ( const void *buffer, size_t buflen, const char *sub ) { - const byte *t, *s ; - size_t n; + const unsigned char *buf = buffer; + const unsigned char *t = (const unsigned char *)buf; + const unsigned char *s = (const unsigned char *)sub; + size_t n = buflen; - for( t=buf, n=buflen, s=sub ; n ; t++, n-- ) - if( ascii_toupper(*t) == ascii_toupper(*s) ) { - for( buf=t++, buflen = n--, s++; - n && ascii_toupper(*t) == ascii_toupper(*s); t++, s++, n-- ) - ; - if( !*s ) - return buf; - t = buf; n = buflen; s = sub ; + for ( ; n ; t++, n-- ) + { + if (ascii_toupper (*t) == ascii_toupper (*s) ) + { + for ( buf=t++, buflen = n--, s++; + n && ascii_toupper (*t) == ascii_toupper (*s); t++, s++, n-- ) + ; + if (!*s) + return (const char*)buf; + t = (const unsigned char *)buf; + s = (const unsigned char *)sub ; + n = buflen; } - - return NULL ; + } + return NULL; } /* This function is similar to strncpy(). However it won't copy more @@ -206,8 +219,8 @@ return len; } -/**************** - * remove trailing white spaces and return the length of the buffer +/* + * Return the length of line ignoring trailing white-space. */ size_t length_sans_trailing_ws (const unsigned char *line, size_t len) @@ -222,15 +235,19 @@ * */ char * -make_basename(const char *filepath) +make_basename(const char *filepath, const char *inputpath) { char *p; +#ifdef __riscos__ + return riscos_make_basename(filepath, inputpath); +#endif + if ( !(p=strrchr(filepath, '/')) ) - #ifdef HAVE_DRIVE_LETTERS +#ifdef HAVE_DRIVE_LETTERS if ( !(p=strrchr(filepath, '\\')) ) if ( !(p=strrchr(filepath, ':')) ) - #endif +#endif { return jnlib_xstrdup(filepath); } @@ -320,48 +337,112 @@ #endif } + +/* Convert 2 hex characters at S to a byte value. Return this value + or -1 if there is an error. */ +int +hextobyte (const char *s) +{ + int c; + + if ( *s >= '0' && *s <= '9' ) + c = 16 * (*s - '0'); + else if ( *s >= 'A' && *s <= 'F' ) + c = 16 * (10 + *s - 'A'); + else if ( *s >= 'a' && *s <= 'f' ) + c = 16 * (10 + *s - 'a'); + else + return -1; + s++; + if ( *s >= '0' && *s <= '9' ) + c += *s - '0'; + else if ( *s >= 'A' && *s <= 'F' ) + c += 10 + *s - 'A'; + else if ( *s >= 'a' && *s <= 'f' ) + c += 10 + *s - 'a'; + else + return -1; + return c; +} + + /* Print a BUFFER to stream FP while replacing all control characters - and the character DELIM with standard C escape sequences. Returns - the number of characters printed. */ + and the characters DELIM and DELIM2 with standard C escape + sequences. Returns the number of characters printed. */ size_t -print_sanitized_buffer (FILE *fp, const void *buffer, size_t length, - int delim) +print_sanitized_buffer2 (FILE *fp, const void *buffer, size_t length, + int delim, int delim2) { const unsigned char *p = buffer; size_t count = 0; for (; length; length--, p++, count++) { - if (*p < 0x20 || *p == 0x7f || *p == delim) + /* Fixme: Check whether *p < 0xa0 is correct for utf8 encoding. */ + if (*p < 0x20 + || (*p >= 0x7f && *p < 0xa0) + || *p == delim + || *p == delim2 + || ((delim || delim2) && *p=='\\')) { putc ('\\', fp); count++; if (*p == '\n') - putc ('n', fp); + { + putc ('n', fp); + count++; + } else if (*p == '\r') - putc ('r', fp); + { + putc ('r', fp); + count++; + } else if (*p == '\f') - putc ('f', fp); + { + putc ('f', fp); + count++; + } else if (*p == '\v') - putc ('v', fp); + { + putc ('v', fp); + count++; + } else if (*p == '\b') - putc ('b', fp); + { + putc ('b', fp); + count++; + } else if (!*p) - putc('0', fp); + { + putc('0', fp); + count++; + } else { fprintf (fp, "x%02x", *p); - count += 2; + count += 3; } } else - putc (*p, fp); + { + putc (*p, fp); + count++; + } } return count; } +/* Same as print_sanitized_buffer2 but with just one delimiter. */ size_t +print_sanitized_buffer (FILE *fp, const void *buffer, size_t length, + int delim) +{ + return print_sanitized_buffer2 (fp, buffer, length, delim, 0); +} + + +size_t print_sanitized_utf8_buffer (FILE *fp, const void *buffer, size_t length, int delim) { @@ -389,6 +470,13 @@ size_t +print_sanitized_string2 (FILE *fp, const char *string, int delim, int delim2) +{ + return string? print_sanitized_buffer2 (fp, string, strlen (string), + delim, delim2):0; +} + +size_t print_sanitized_string (FILE *fp, const char *string, int delim) { return string? print_sanitized_buffer (fp, string, strlen (string), delim):0; @@ -402,16 +490,17 @@ delim) : 0; } -/* Create a string from the buffer P of length N which is suitable for +/* Create a string from the buffer P_ARG of length N which is suitable for printing. Caller must release the created string using xfree. */ char * -sanitize_buffer (const unsigned char *p, size_t n, int delim) +sanitize_buffer (const void *p_arg, size_t n, int delim) { + const unsigned char *p = p_arg; size_t save_n, buflen; - const byte *save_p; + const unsigned char *save_p; char *buffer, *d; - /* first count length */ + /* First count length. */ for (save_n = n, save_p = p, buflen=1 ; n; n--, p++ ) { if ( *p < 0x20 || *p == 0x7f || *p == delim || (delim && *p=='\\')) @@ -420,14 +509,14 @@ || *p=='\v' || *p=='\b' || !*p ) buflen += 2; else - buflen += 4; + buflen += 5; } else buflen++; } p = save_p; n = save_n; - /* and now make the string */ + /* And now make the string */ d = buffer = jnlib_xmalloc( buflen ); for ( ; n; n--, p++ ) { @@ -447,7 +536,7 @@ *d++ = '0'; else { sprintf(d, "x%02x", *p ); - d += 2; + d += 3; } } else @@ -552,15 +641,19 @@ int -ascii_memcasecmp( const char *a, const char *b, size_t n ) +ascii_memcasecmp (const void *a_arg, const void *b_arg, size_t n ) { - if (a == b) - return 0; - for ( ; n; n--, a++, b++ ) { - if( *a != *b && ascii_toupper (*a) != ascii_toupper (*b) ) - return *a == *b? 0 : (ascii_toupper (*a) - ascii_toupper (*b)); + const char *a = a_arg; + const char *b = b_arg; + + if (a == b) + return 0; + for ( ; n; n--, a++, b++ ) + { + if( *a != *b && ascii_toupper (*a) != ascii_toupper (*b) ) + return *a == *b? 0 : (ascii_toupper (*a) - ascii_toupper (*b)); } - return 0; + return 0; } int @@ -586,8 +679,8 @@ return (void*)haystack; /* finding an empty needle is really easy */ if (nneedle <= nhaystack) { - const unsigned char *a = haystack; - const unsigned char *b = a + nhaystack - nneedle; + const char *a = haystack; + const char *b = a + nhaystack - nneedle; for (; a <= b; a++) { Modified: trunk/jnlib/stringhelp.h =================================================================== --- trunk/jnlib/stringhelp.h 2006-09-04 14:57:42 UTC (rev 233) +++ trunk/jnlib/stringhelp.h 2006-09-04 16:39:01 UTC (rev 234) @@ -15,7 +15,8 @@ * * 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. */ #ifndef LIBJNLIB_STRINGHELP_H @@ -23,7 +24,7 @@ #include "types.h" -const char *memistr( const char *buf, size_t buflen, const char *sub ); +const char *memistr (const void *buf, size_t buflen, const char *sub); char *mem2str( char *, const void *, size_t); char *trim_spaces( char *string ); char *trim_trailing_spaces( char *string ); @@ -35,18 +36,24 @@ size_t length_sans_trailing_ws (const unsigned char *line, size_t len); -char *make_basename(const char *filepath); +char *make_basename(const char *filepath, const char *inputpath); char *make_dirname(const char *filepath); char *make_filename( const char *first_part, ... ); int compare_filenames( const char *a, const char *b ); +int hextobyte (const char *s); + size_t print_sanitized_buffer (FILE *fp, const void *buffer, size_t length, int delim); +size_t print_sanitized_buffer2 (FILE *fp, const void *buffer, size_t length, + int delim, int delim2); size_t print_sanitized_utf8_buffer (FILE *fp, const void *buffer, size_t length, int delim); size_t print_sanitized_string (FILE *fp, const char *string, int delim); +size_t print_sanitized_string2 (FILE *fp, const char *string, + int delim, int delim2); size_t print_sanitized_utf8_string (FILE *fp, const char *string, int delim); -char *sanitize_buffer (const unsigned char *p, size_t n, int delim); +char *sanitize_buffer (const void *p, size_t n, int delim); #ifdef HAVE_W32_SYSTEM @@ -54,15 +61,14 @@ #endif -const char *ascii_memistr( const char *buf, size_t buflen, const char *sub ); int ascii_isupper (int c); int ascii_islower (int c); int ascii_toupper (int c); int ascii_tolower (int c); int ascii_strcasecmp( const char *a, const char *b ); int ascii_strncasecmp (const char *a, const char *b, size_t n); -int ascii_memcasecmp( const char *a, const char *b, size_t n ); -const char *ascii_memistr ( const char *buf, size_t buflen, const char *sub); +int ascii_memcasecmp( const void *a, const void *b, size_t n ); +const char *ascii_memistr ( const void *buf, size_t buflen, const char *sub); void *ascii_memcasemem (const void *haystack, size_t nhaystack, const void *needle, size_t nneedle); Modified: trunk/jnlib/strlist.c =================================================================== --- trunk/jnlib/strlist.c 2006-09-04 14:57:42 UTC (rev 233) +++ trunk/jnlib/strlist.c 2006-09-04 16:39:01 UTC (rev 234) @@ -1,5 +1,5 @@ /* strlist.c - string helpers - * Copyright (C) 1998, 2000, 2001 Free Software Foundation, Inc. + * Copyright (C) 1998, 2000, 2001, 2006 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -15,7 +15,8 @@ * * 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. */ #include @@ -26,8 +27,10 @@ #include "libjnlib-config.h" #include "strlist.h" +#ifdef JNLIB_NEED_UTF8CONV +#include "utf8conv.h" +#endif - void free_strlist( strlist_t sl ) { @@ -53,26 +56,26 @@ return sl; } -#if 0 -/**************** - * same as add_to_strlist() but if is_utf8 is *not* set a conversion - * to UTF8 is done - */ + +/* Same as add_to_strlist() but if is_utf8 is *not* set, a conversion + to UTF-8 is done. */ +#ifdef JNLIB_NEED_UTF8CONV strlist_t add_to_strlist2( strlist_t *list, const char *string, int is_utf8 ) { - strlist_t sl; - - if( is_utf8 ) - sl = add_to_strlist( list, string ); - else { - char *p = native_to_utf8( string ); - sl = add_to_strlist( list, p ); - m_free( p ); + strlist_t sl; + + if (is_utf8) + sl = add_to_strlist( list, string ); + else + { + char *p = native_to_utf8( string ); + sl = add_to_strlist( list, p ); + jnlib_free ( p ); } - return sl; + return sl; } -#endif +#endif /* JNLIB_NEED_UTF8CONV*/ strlist_t append_to_strlist( strlist_t *list, const char *string ) @@ -93,22 +96,24 @@ return sl; } -#if 0 + +#ifdef JNLIB_NEED_UTF8CONV strlist_t append_to_strlist2( strlist_t *list, const char *string, int is_utf8 ) { - strlist_t sl; - - if( is_utf8 ) - sl = append_to_strlist( list, string ); - else { - char *p = native_to_utf8( string ); - sl = append_to_strlist( list, p ); - m_free( p ); + strlist_t sl; + + if( is_utf8 ) + sl = append_to_strlist( list, string ); + else + { + char *p = native_to_utf8 (string); + sl = append_to_strlist( list, p ); + jnlib_free( p ); } - return sl; + return sl; } -#endif +#endif /* JNLIB_NEED_UTF8CONV */ /* Return a copy of LIST. */ Modified: trunk/jnlib/strlist.h =================================================================== --- trunk/jnlib/strlist.h 2006-09-04 14:57:42 UTC (rev 233) +++ trunk/jnlib/strlist.h 2006-09-04 16:39:01 UTC (rev 234) @@ -15,7 +15,8 @@ * * 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. */ #ifndef LIBJNLIB_STRLIST_H @@ -32,15 +33,14 @@ void free_strlist (strlist_t sl); strlist_t add_to_strlist (strlist_t *list, const char *string); -/*strlist_t add_to_strlist2( strlist_t *list, - const char *string, int is_utf8);*/ +strlist_t add_to_strlist2( strlist_t *list, const char *string, int is_utf8); strlist_t append_to_strlist (strlist_t *list, const char *string); +strlist_t append_to_strlist2 (strlist_t *list, const char *string, + int is_utf8); strlist_t strlist_copy (strlist_t list); -/*strlist_t append_to_strlist2( strlist_t *list, const char *string, - int is_utf8);*/ strlist_t strlist_prev (strlist_t head, strlist_t node); strlist_t strlist_last (strlist_t node); char * strlist_pop (strlist_t *list); Modified: trunk/jnlib/types.h =================================================================== --- trunk/jnlib/types.h 2006-09-04 14:57:42 UTC (rev 233) +++ trunk/jnlib/types.h 2006-09-04 16:39:01 UTC (rev 234) @@ -15,7 +15,8 @@ * * 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. */ #ifndef LIBJNLIB_TYPES_H Modified: trunk/jnlib/utf8conv.c =================================================================== --- trunk/jnlib/utf8conv.c 2006-09-04 14:57:42 UTC (rev 233) +++ trunk/jnlib/utf8conv.c 2006-09-04 16:39:01 UTC (rev 234) @@ -16,7 +16,8 @@ * * 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. */ #include @@ -136,16 +137,17 @@ * new allocated UTF8 string. */ char * -native_to_utf8 (const char *string) +native_to_utf8 (const char *orig_string) { - const byte *s; + const unsigned char *string = (const unsigned char *)orig_string; + const unsigned char *s; char *buffer; - byte *p; + unsigned char *p; size_t length = 0; if (no_translation) { - buffer = jnlib_xstrdup (string); + buffer = jnlib_xstrdup (orig_string); } else if (active_charset) { @@ -156,7 +158,7 @@ length += 2; /* we may need 3 bytes */ } buffer = jnlib_xmalloc (length + 1); - for (p = buffer, s = string; *s; s++) + for (p = (unsigned char *)buffer, s = string; *s; s++) { if ((*s & 0x80)) { @@ -187,7 +189,7 @@ length++; } buffer = jnlib_xmalloc (length + 1); - for (p = buffer, s = string; *s; s++) + for (p = (unsigned char *)buffer, s = string; *s; s++) { if (*s & 0x80) { @@ -212,11 +214,12 @@ { int nleft; int i; - byte encbuf[8]; + unsigned char encbuf[8]; int encidx; const byte *s; size_t n; - byte *buffer = NULL, *p = NULL; + char *buffer = NULL; + char *p = NULL; unsigned long val = 0; size_t slen; int resync = 0; @@ -225,7 +228,8 @@ /* 2. pass (p!=NULL): create string */ for (;;) { - for (slen = length, nleft = encidx = 0, n = 0, s = string; slen; + for (slen = length, nleft = encidx = 0, n = 0, + s = (const unsigned char *)string; slen; s++, slen--) { if (resync) Modified: trunk/jnlib/utf8conv.h =================================================================== --- trunk/jnlib/utf8conv.h 2006-09-04 14:57:42 UTC (rev 233) +++ trunk/jnlib/utf8conv.h 2006-09-04 16:39:01 UTC (rev 234) @@ -15,7 +15,8 @@ * * 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. */ #ifndef LIBJNLIB_UTF8CONF_H Modified: trunk/jnlib/xmalloc.c =================================================================== --- trunk/jnlib/xmalloc.c 2006-09-04 14:57:42 UTC (rev 233) +++ trunk/jnlib/xmalloc.c 2006-09-04 16:39:01 UTC (rev 234) @@ -15,7 +15,8 @@ * * 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. */ #include Modified: trunk/jnlib/xmalloc.h =================================================================== --- trunk/jnlib/xmalloc.h 2006-09-04 14:57:42 UTC (rev 233) +++ trunk/jnlib/xmalloc.h 2006-09-04 16:39:01 UTC (rev 234) @@ -15,7 +15,8 @@ * * 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. */ #ifndef LIBJNLIB_XMALLOC_H From cvs at cvs.gnupg.org Mon Sep 4 18:56:46 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon Sep 4 18:12:53 2006 Subject: [svn] dirmngr - r235 - tags Message-ID: Author: wk Date: 2006-09-04 18:56:45 +0200 (Mon, 04 Sep 2006) New Revision: 235 Added: tags/dirmngr-0.9.6/ Log: Released Copied: tags/dirmngr-0.9.6 (from rev 234, trunk) From cvs at cvs.gnupg.org Tue Sep 5 20:50:35 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue Sep 5 20:06:35 2006 Subject: [svn] GnuPG - r4238 - trunk/doc Message-ID: Author: wk Date: 2006-09-05 20:50:34 +0200 (Tue, 05 Sep 2006) New Revision: 4238 Added: trunk/doc/gnupg7.texi Log: Missing file Added: trunk/doc/gnupg7.texi =================================================================== --- trunk/doc/gnupg7.texi 2006-09-04 14:53:20 UTC (rev 4237) +++ trunk/doc/gnupg7.texi 2006-09-05 18:50:34 UTC (rev 4238) @@ -0,0 +1,29 @@ +@c @c -*-texinfo-*- +@c This is only used to create a man page, thus we don't need to care +@c about actual texinfo stuff. + +@manpage gnupg.7 +@ifset manverb +.B GnuPG +\- The GNU Privacy Guard suite of programs +@end ifset +@mansect description +@ifset isman +GnuPG is a set of programs for public key encryption and digital +signatures. The program most users will want to use is the OpenPGP +command line tool, named @command{gpg2}. @command{gpgv}is a stripped +down version of @command{gpg2} with no encryption functionality, used +only to verify signatures against a trusted keyring. @command{gpgsm} is +the X.509/CMS (for S/MIME) counterpart of +@command{gpg2}. @command{gpg-agent} is a passphrase and private key +daemon which may also emulate the @command{ssh-agent}. +@mansect see also +@command{gpg2}(1), +@command{gpgv}(1), +@command{gpgsm}(1), +@command{gpg-agent}(1), +@command{scdaemon}(1) +@include see-also-note.texi +@end ifset + +@bye From cvs at cvs.gnupg.org Tue Sep 5 21:17:14 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue Sep 5 20:33:12 2006 Subject: [svn] gpg-error - r176 - in trunk: . src Message-ID: Author: wk Date: 2006-09-05 21:17:14 +0200 (Tue, 05 Sep 2006) New Revision: 176 Modified: trunk/ChangeLog trunk/NEWS trunk/src/err-codes.h.in trunk/src/err-sources.h.in Log: New error codes. This is mainly to support a change in libassuan. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-07-04 12:18:29 UTC (rev 175) +++ trunk/ChangeLog 2006-09-05 19:17:14 UTC (rev 176) @@ -1,3 +1,12 @@ +2006-09-05 Werner Koch + + * src/err-sources.h.in (GPG_ERR_SOURCE_ANY): New. This is so that + we have source distinguished from the Unknown one but declaring + that it is an gpg-error style error code. + + * src/err-codes.h.in: Added GPG_ERR_ASS_* codes, rabnge 257-281. + (GPG_ERR_MISSING_ERRNO): New. + 2006-07-04 Marcus Brinkmann * src/init.c (get_locale_dir): Return NULL instead of garbage. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-07-04 12:18:29 UTC (rev 175) +++ trunk/NEWS 2006-09-05 19:17:14 UTC (rev 176) @@ -3,7 +3,47 @@ * Support for Common Lisp is included. + * New error codes for the Assuan IPC library. + * New error code GPG_ERR_MISSING_ERRNO to be used in cases when a + system accidently does not set errno but a system error definitely + occured. + + * New error source GPG_ERR_SOURCE_ANY to allow proper use of + libgpg-error even if a specific source is not available. + + * Interface changes relative to the 1.2 release: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + GPG_ERR_SOURCE_ANY NEW + GPG_ERR_MISSING_ERRNO NEW + GPG_ERR_ASS_GENERAL NEW + GPG_ERR_ASS_ACCEPT_FAILED NEW + GPG_ERR_ASS_CONNECT_FAILED NEW + GPG_ERR_ASS_INV_RESPONSE NEW + GPG_ERR_ASS_INV_VALUE NEW + GPG_ERR_ASS_INCOMPLETE_LINE NEW + GPG_ERR_ASS_LINE_TOO_LONG NEW + GPG_ERR_ASS_NESTED_COMMANDS NEW + GPG_ERR_ASS_NO_DATA_CB NEW + GPG_ERR_ASS_NO_INQUIRE_CB NEW + GPG_ERR_ASS_NOT_A_SERVER NEW + GPG_ERR_ASS_NOT_A_CLIENT NEW + GPG_ERR_ASS_SERVER_START NEW + GPG_ERR_ASS_READ_ERROR NEW + GPG_ERR_ASS_WRITE_ERROR NEW + GPG_ERR_ASS_SERVER_FAULT NEW + GPG_ERR_ASS_TOO_MUCH_DATA NEW + GPG_ERR_ASS_UNEXPECTED_CMD NEW + GPG_ERR_ASS_UNKNOWN_CMD NEW + GPG_ERR_ASS_SYNTAX NEW + GPG_ERR_ASS_CANCELED NEW + GPG_ERR_ASS_NO_INPUT NEW + GPG_ERR_ASS_NO_OUTPUT NEW + GPG_ERR_ASS_PARAMETER NEW + GPG_ERR_ASS_UNKNOWN_INQUIRE NEW + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + Noteworthy changes in version 1.3 (2006-03-14) ---------------------------------------------- @@ -68,7 +108,7 @@ evaluate to plain numbers, but expressions. If you want to cross-compile, you might have to set CC_FOR_BUILD, though. - * A new tool gpg-error to convert error numbers into symbols into + * A new tool gpg-error to convert error numbers into symbols into strings is provided. * Interface changes relative to the 0.6 release: @@ -128,7 +168,7 @@ GPG_ERR_UNSUPPORTED_CRL_VERSION NEW GPG_ERR_INV_CERT_OBJ NEW GPG_ERR_UNKNOWN_NAME NEW -GPG_ERR_BUFFER_TOO_SHORT. NEW +GPG_ERR_BUFFER_TOO_SHORT. NEW ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Noteworthy changes in version 0.5 (2003-10-06) Modified: trunk/src/err-codes.h.in =================================================================== --- trunk/src/err-codes.h.in 2006-07-04 12:18:29 UTC (rev 175) +++ trunk/src/err-codes.h.in 2006-09-05 19:17:14 UTC (rev 176) @@ -223,8 +223,39 @@ 212 GPG_ERR_SEXP_ODD_HEX_NUMBERS Odd hexadecimal numbers in S-expression 213 GPG_ERR_SEXP_BAD_OCT_CHAR Bad octadecimal character in S-expression -# 214 to 1023 are free to be used. +# 214 to 254 are free to be used. 255 and 256 are RFU. +# Error codes pertaining to the Assuan IPC interface +257 GPG_ERR_ASS_GENERAL General IPC error +258 GPG_ERR_ASS_ACCEPT_FAILED IPC accept call failed +259 GPG_ERR_ASS_CONNECT_FAILED IPC connect call failed +260 GPG_ERR_ASS_INV_RESPONSE Invalid IPC response +261 GPG_ERR_ASS_INV_VALUE Invalid value passed to IPC +262 GPG_ERR_ASS_INCOMPLETE_LINE Incomplete line passed to IPC +263 GPG_ERR_ASS_LINE_TOO_LONG Line passed to IPC too long +264 GPG_ERR_ASS_NESTED_COMMANDS Nested IPC commands +265 GPG_ERR_ASS_NO_DATA_CB No data callback in IPC +266 GPG_ERR_ASS_NO_INQUIRE_CB No inquire callback in IPC +267 GPG_ERR_ASS_NOT_A_SERVER Not an IPC server +268 GPG_ERR_ASS_NOT_A_CLIENT Not an IPC client +269 GPG_ERR_ASS_SERVER_START Problem starting IPC server +270 GPG_ERR_ASS_READ_ERROR IPC read error +271 GPG_ERR_ASS_WRITE_ERROR IPC write error +272 GPG_ERR_ASS_SERVER_FAULT IPC server fault +273 GPG_ERR_ASS_TOO_MUCH_DATA Too much data for IPC layer +274 GPG_ERR_ASS_UNEXPECTED_CMD Unexpected IPC command +275 GPG_ERR_ASS_UNKNOWN_CMD Unknown IPC command +276 GPG_ERR_ASS_SYNTAX IPC syntax error +277 GPG_ERR_ASS_CANCELED IPC call has been cancelled +278 GPG_ERR_ASS_NO_INPUT No input source for IPC +279 GPG_ERR_ASS_NO_OUTPUT No output source for IPC +280 GPG_ERR_ASS_PARAMETER IPC parameter error +281 GPG_ERR_ASS_UNKNOWN_INQUIRE Unknown IPC inquire + +# 282 to 299 are reserved for future assuan codes. + +# 300 to 1023 are free to be used. + # For free use by non-GnuPG components. 1024 GPG_ERR_USER_1 User defined error code 1 1025 GPG_ERR_USER_2 User defined error code 2 @@ -243,8 +274,9 @@ 1038 GPG_ERR_USER_15 User defined error code 15 1039 GPG_ERR_USER_16 User defined error code 16 -# 1040 to 16381 are free to be used. +# 1040 to 16380 are free to be used. +16381 GPG_ERR_MISSING_ERRNO System error w/o errno 16382 GPG_ERR_UNKNOWN_ERRNO Unknown system error 16383 GPG_ERR_EOF End of file Modified: trunk/src/err-sources.h.in =================================================================== --- trunk/src/err-sources.h.in 2006-07-04 12:18:29 UTC (rev 175) +++ trunk/src/err-sources.h.in 2006-09-05 19:17:14 UTC (rev 176) @@ -42,8 +42,9 @@ 10 GPG_ERR_SOURCE_DIRMNGR Dirmngr 11 GPG_ERR_SOURCE_GSTI GSTI -# 11 to 31 are free to be used. +# 11 to 30 are free to be used. +31 GPG_ERR_SOURCE_ANY Any source 32 GPG_ERR_SOURCE_USER_1 User defined source 1 33 GPG_ERR_SOURCE_USER_2 User defined source 2 34 GPG_ERR_SOURCE_USER_3 User defined source 3 From cvs at cvs.gnupg.org Wed Sep 6 13:28:23 2006 From: cvs at cvs.gnupg.org (svn author twoaday) Date: Wed Sep 6 12:44:21 2006 Subject: [svn] GPGol - r162 - trunk/src Message-ID: Author: twoaday Date: 2006-09-06 13:28:22 +0200 (Wed, 06 Sep 2006) New Revision: 162 Modified: trunk/src/ChangeLog trunk/src/recipient-dialog.c Log: Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2006-08-28 14:32:45 UTC (rev 161) +++ trunk/src/ChangeLog 2006-09-06 11:28:22 UTC (rev 162) @@ -1,3 +1,8 @@ +2009-09-06 Timo Schulz + + * recipient-dialog.c (recipient_dialog2): Do not free + key array here. + 2008-08-21 Timo Schulz * engine-gpgme.c (op_lookup_keys): Only add useable keys Modified: trunk/src/recipient-dialog.c =================================================================== --- trunk/src/recipient-dialog.c 2006-08-28 14:32:45 UTC (rev 161) +++ trunk/src/recipient-dialog.c 2006-09-06 11:28:22 UTC (rev 162) @@ -542,6 +542,5 @@ *ret_rset = cb.selected_keys; release_keyarray (cb.keyarray, cb.keyarray_count); - xfree (cb.fnd_keys); return cb.opts; } From cvs at cvs.gnupg.org Wed Sep 6 13:53:28 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed Sep 6 13:09:23 2006 Subject: [svn] GnuPG - r4239 - in trunk: . agent common g10 m4 sm Message-ID: Author: wk Date: 2006-09-06 13:53:24 +0200 (Wed, 06 Sep 2006) New Revision: 4239 Modified: trunk/ChangeLog trunk/agent/gpg-agent.c trunk/common/ChangeLog trunk/common/http.c trunk/configure.ac trunk/g10/ChangeLog trunk/g10/call-agent.c trunk/g10/gpg.c trunk/m4/ksba.m4 trunk/sm/certchain.c trunk/sm/certreqgen.c trunk/sm/keylist.c Log: Minor changes and typo fixes. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-09-05 18:50:34 UTC (rev 4238) +++ trunk/ChangeLog 2006-09-06 11:53:24 UTC (rev 4239) @@ -1,3 +1,9 @@ +2006-08-31 Werner Koch + + * configure.ac: Require libksba 1.0 and added API check for it. + (GPG_ERR_LOCKED): Removed DECL check as we require 1.2 anyway. + (have_libusb): New to give a feedback about CCID support + 2006-08-21 Werner Koch * configure.ac: Removed docbook tests. Modified: trunk/agent/gpg-agent.c =================================================================== --- trunk/agent/gpg-agent.c 2006-09-05 18:50:34 UTC (rev 4238) +++ trunk/agent/gpg-agent.c 2006-09-06 11:53:24 UTC (rev 4239) @@ -1142,7 +1142,7 @@ unique name in a unique new directory will be created. In both cases check for valid characters as well as against a maximum allowed length for a unix domain socket is done. The function - terminates the process in case of an error. Retunrs: Pointer to an + terminates the process in case of an error. Returns: Pointer to an allcoated string with the absolute name of the socket used. */ static char * create_socket_name (int use_standard_socket, Modified: trunk/common/ChangeLog =================================================================== --- trunk/common/ChangeLog 2006-09-05 18:50:34 UTC (rev 4238) +++ trunk/common/ChangeLog 2006-09-06 11:53:24 UTC (rev 4239) @@ -3,6 +3,7 @@ * http.c (http_get_header): New. (capitalize_header_name, store_header): New. (parse_response): Store headers away. + (send_request): Return GPG_ERR_NOT_FOUND if connect_server failed. * http.h: New flag HTTP_FLAG_NEED_HEADER. 2006-08-21 Werner Koch Modified: trunk/common/http.c =================================================================== --- trunk/common/http.c 2006-09-05 18:50:34 UTC (rev 4238) +++ trunk/common/http.c 2006-09-06 11:53:24 UTC (rev 4239) @@ -872,7 +872,9 @@ if (hd->sock == -1) { xfree (proxy_authstr); - return gpg_error_from_errno (save_errno); + return (save_errno + ? gpg_error_from_errno (save_errno) + : gpg_error (GPG_ERR_NOT_FOUND)); } #ifdef HTTP_USE_GNUTLS Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-09-05 18:50:34 UTC (rev 4238) +++ trunk/configure.ac 2006-09-06 11:53:24 UTC (rev 4239) @@ -46,7 +46,8 @@ NEED_LIBASSUAN_VERSION=0.6.10 -NEED_KSBA_VERSION=0.9.16 +NEED_KSBA_API=1 +NEED_KSBA_VERSION=1.0.0 PACKAGE=$PACKAGE_NAME @@ -68,6 +69,7 @@ have_libassuan=no have_ksba=no have_pth=no +have_libusb=no use_bzip2=yes use_exec=yes @@ -561,10 +563,6 @@ # AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION", have_gpg_error=yes,have_gpg_error=no) -_tmp_gpg_error_save_cflags="$CFLAGS" -CFLAGS="$CFLAGS $GPG_ERROR_CFLAGS" -AC_CHECK_DECLS(GPG_ERR_LOCKED,,,[#include ]) -CFLAGS="${_tmp_gpg_error_save_cflags}" # @@ -584,7 +582,7 @@ # # libksba is our X.509 support library # -AM_PATH_KSBA("$NEED_KSBA_VERSION",have_ksba=yes,have_ksba=no) +AM_PATH_KSBA("$NEED_KSBA_API:$NEED_KSBA_VERSION",have_ksba=yes,have_ksba=no) # @@ -595,6 +593,7 @@ [ LIBUSB_LIBS="$LIBUSB_LIBS -lusb" AC_DEFINE(HAVE_LIBUSB,1, [defined if libusb is available]) + have_libusb=yes ]) AC_SUBST(LIBUSB_LIBS) AC_CHECK_FUNCS(usb_create_match) @@ -1208,6 +1207,10 @@ tmp=", " missing_pth=yes fi + if test $have_libusb = no; then + build_scdaemon_extra="${tmp}without internal CCID driver" + tmp=", " + fi if test -n "$build_scdaemon_extra"; then build_scdaemon_extra="(${build_scdaemon_extra})" fi @@ -1251,7 +1254,7 @@ *** You need libgcrypt to build this program. ** This library is for example available at *** ftp://ftp.gnupg.org/gcrypt/libgcrypt/ -*** (at least version $NEED_LIBGCRYPT_VERSION using API $NEED_LIBGCRYPT_API) is required.) +*** (at least version $NEED_LIBGCRYPT_VERSION using API $NEED_LIBGCRYPT_API is required.) ***]]) fi if test "$have_libassuan" = "no"; then @@ -1269,8 +1272,8 @@ *** *** You need libksba to build this program. *** This library is for example available at -*** ftp://ftp.gnupg.org/gcrypt/alpha/libksba/ -*** (at least version $NEED_KSBA_VERSION is required). +*** ftp://ftp.gnupg.org/gcrypt/libksba/ +*** (at least version $NEED_KSBA_VERSION using API $NEED_KSBA_API is required). ***]]) fi if test "$missing_pth" = "yes"; then Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2006-09-05 18:50:34 UTC (rev 4238) +++ trunk/g10/ChangeLog 2006-09-06 11:53:24 UTC (rev 4239) @@ -1,3 +1,9 @@ +2006-09-01 Werner Koch + + * call-agent.c: Do not force using the pipe server. + + * gpg.c (main): Enable card related commands. + 2006-08-22 Werner Koch * mainproc.c (proc_plaintext): Fixed a #warning Modified: trunk/g10/call-agent.c =================================================================== --- trunk/g10/call-agent.c 2006-09-05 18:50:34 UTC (rev 4238) +++ trunk/g10/call-agent.c 2006-09-06 11:53:24 UTC (rev 4239) @@ -48,7 +48,7 @@ #endif static assuan_context_t agent_ctx = NULL; -static int force_pipe_server = 1; /* FIXME: set this back to 0. */ +static int force_pipe_server; struct cipher_parm_s { Modified: trunk/g10/gpg.c =================================================================== --- trunk/g10/gpg.c 2006-09-05 18:50:34 UTC (rev 4238) +++ trunk/g10/gpg.c 2006-09-06 11:53:24 UTC (rev 4239) @@ -2012,8 +2012,14 @@ case aRefreshKeys: case aFetchKeys: case aExport: +#ifdef ENABLE_CARD_SUPPORT + case aCardStatus: + case aCardEdit: + case aChangePIN: +#endif /* ENABLE_CARD_SUPPORT*/ set_cmd (&cmd, pargs.r_opt); break; + case aListKeys: set_cmd( &cmd, aListKeys); break; case aListSigs: set_cmd( &cmd, aListSigs); break; case aExportSecret: set_cmd( &cmd, aExportSecret); break; Modified: trunk/m4/ksba.m4 =================================================================== --- trunk/m4/ksba.m4 2006-09-05 18:50:34 UTC (rev 4238) +++ trunk/m4/ksba.m4 2006-09-06 11:53:24 UTC (rev 4239) @@ -13,6 +13,12 @@ dnl AM_PATH_KSBA([MINIMUM-VERSION, dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]]) dnl Test for libksba and define KSBA_CFLAGS and KSBA_LIBS +dnl MINIMUN-VERSION is a string with the version number optionalliy prefixed +dnl with the API version to also check the API compatibility. Example: +dnl a MINIMUN-VERSION of 1:1.0.7 won't pass the test unless the installed +dnl version of libksba is at least 1.0.7 *and* the API number is 1. Using +dnl this features allows to prevent build against newer versions of libksba +dnl with a changed API. dnl AC_DEFUN([AM_PATH_KSBA], [ AC_ARG_WITH(ksba-prefix, @@ -27,7 +33,15 @@ fi AC_PATH_PROG(KSBA_CONFIG, ksba-config, no) - min_ksba_version=ifelse([$1], ,0.4.4,$1) + tmp=ifelse([$1], ,1:1.0.0,$1) + if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then + req_ksba_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'` + min_ksba_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'` + else + req_ksba_api=0 + min_ksba_version="$tmp" + fi + AC_MSG_CHECKING(for KSBA - version >= $min_ksba_version) ok=no if test "$KSBA_CONFIG" != "no" ; then @@ -61,14 +75,33 @@ fi fi if test $ok = yes; then + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + fi + if test $ok = yes; then + # Even if we have a recent libksba, we should check that the + # API is compatible. + if test "$req_ksba_api" -gt 0 ; then + tmp=`$KSBA_CONFIG --api-version 2>/dev/null || echo 0` + if test "$tmp" -gt 0 ; then + AC_MSG_CHECKING([KSBA API version]) + if test "$req_ksba_api" -eq "$tmp" ; then + AC_MSG_RESULT(okay) + else + ok=no + AC_MSG_RESULT([does not match. want=$req_ksba_api got=$tmp.]) + fi + fi + fi + fi + if test $ok = yes; then KSBA_CFLAGS=`$KSBA_CONFIG $ksba_config_args --cflags` KSBA_LIBS=`$KSBA_CONFIG $ksba_config_args --libs` - AC_MSG_RESULT(yes) ifelse([$2], , :, [$2]) else KSBA_CFLAGS="" KSBA_LIBS="" - AC_MSG_RESULT(no) ifelse([$3], , :, [$3]) fi AC_SUBST(KSBA_CFLAGS) Modified: trunk/sm/certchain.c =================================================================== --- trunk/sm/certchain.c 2006-09-05 18:50:34 UTC (rev 4238) +++ trunk/sm/certchain.c 2006-09-06 11:53:24 UTC (rev 4239) @@ -136,6 +136,8 @@ { if (get_regtp_ca_info (cert, chainlen)) { + /* Note that dirmngr takes a different way to cope with such + certs. */ return 0; /* RegTP issued certificate. */ } Modified: trunk/sm/certreqgen.c =================================================================== --- trunk/sm/certreqgen.c 2006-09-05 18:50:34 UTC (rev 4238) +++ trunk/sm/certreqgen.c 2006-09-06 11:53:24 UTC (rev 4239) @@ -66,7 +66,7 @@ Length of the key in bits. Default is 1024. Key-Grip: hexstring This is optional and used to generate a request for an already - existsing key. Key-Length will be ignored when given, + existing key. Key-Length will be ignored when given, Key-Usage: Space or comma delimited list of key usage, allowed values are "encrypt" and "sign". This is used to generate the KeyUsage extension. Modified: trunk/sm/keylist.c =================================================================== --- trunk/sm/keylist.c 2006-09-05 18:50:34 UTC (rev 4238) +++ trunk/sm/keylist.c 2006-09-06 11:53:24 UTC (rev 4239) @@ -70,6 +70,9 @@ { "2.16.840.1.113730.4.1", "serverGatedCrypto.ns" }, /* Netscape. */ { "1.3.6.1.4.1.311.10.3.3", "serverGatedCrypto.ms"}, /* Microsoft. */ + + { "1.3.6.1.5.5.7.48.1.5", "ocspNoCheck" }, + { NULL, NULL } }; @@ -125,6 +128,11 @@ { "1.3.6.1.5.5.7.1.10", "acProxying" }, { "1.3.6.1.5.5.7.1.11", "subjectInfoAccess" }, + { "1.3.6.1.5.5.7.48.1", "ocsp" }, + { "1.3.6.1.5.5.7.48.2", "caIssuers" }, + { "1.3.6.1.5.5.7.48.3", "timeStamping" }, + { "1.3.6.1.5.5.7.48.5", "caRepository" }, + /* X.509 id-ce */ { "2.5.29.14", "subjectKeyIdentifier", 1}, { "2.5.29.15", "keyUsage", 1 }, From cvs at cvs.gnupg.org Wed Sep 6 18:36:47 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed Sep 6 17:52:40 2006 Subject: [svn] assuan - r196 - in trunk: . doc src tests Message-ID: Author: wk Date: 2006-09-06 18:36:45 +0200 (Wed, 06 Sep 2006) New Revision: 196 Added: trunk/tests/ trunk/tests/Makefile.am trunk/tests/common.h trunk/tests/fdpassing.c Modified: trunk/ChangeLog trunk/Makefile.am trunk/NEWS trunk/TODO trunk/configure.ac trunk/doc/assuan.texi trunk/src/ChangeLog trunk/src/Makefile.am trunk/src/assuan-buffer.c trunk/src/assuan-client.c trunk/src/assuan-defs.h trunk/src/assuan-domain-connect.c trunk/src/assuan-domain-server.c trunk/src/assuan-handler.c trunk/src/assuan-inquire.c trunk/src/assuan-listen.c trunk/src/assuan-logging.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.h trunk/src/mkerrors Log: Changes to support gpg-error style error codes. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-06-27 10:37:31 UTC (rev 195) +++ trunk/ChangeLog 2006-09-06 16:36:45 UTC (rev 196) @@ -1,3 +1,7 @@ +2006-09-05 Werner Koch + + * configure.ac (AH_BOTTOM): Define _ASSUAN_IN_LIBASSUAN. + 2005-10-24 Werner Koch * COPYING.LESSER: Added. Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2006-06-27 10:37:31 UTC (rev 195) +++ trunk/Makefile.am 2006-09-06 16:36:45 UTC (rev 196) @@ -1,6 +1,8 @@ -SUBDIRS = src doc + ACLOCAL_AMFLAGS = -I m4 AUTOMAKE_OPTIONS = dist-bzip2 EXTRA_DIST = config.rpath config.rpath autogen.sh README.SVN +SUBDIRS = src doc tests + Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-06-27 10:37:31 UTC (rev 195) +++ trunk/NEWS 2006-09-06 16:36:45 UTC (rev 196) @@ -1,4 +1,4 @@ -Noteworthy changes in version 0.6.11 +Noteworthy changes in version 0.9.0 ------------------------------------------------- * Internal cleanups to make inclusion of the code into libraries @@ -6,7 +6,14 @@ * Made clear that the software is under the LGPL. + * New function assuan_set_assuan_err_source. All gpg-error enabled + software should call this right at startup to switch libassuan into + the gpg-error style mode. All error codes are then returned as + gpg-error style codes (GPG_ERR_ASS_* as well as others). + If the new macro _ASSUAN_ONLY_GPG_ERRORS is defned all old + definitions are excluded from assuan.h. + Noteworthy changes in version 0.6.10 (2005-06-20) ------------------------------------------------- Modified: trunk/TODO =================================================================== --- trunk/TODO 2006-06-27 10:37:31 UTC (rev 195) +++ trunk/TODO 2006-09-06 16:36:45 UTC (rev 196) @@ -1,3 +1,4 @@ + -*- outline -*- * waitpid is used instead of pth_waitpid as well as some other functions. * When turning libassuan into a shared library, provide a general @@ -3,8 +4,11 @@ version as well as a Pth-enabled one. * Need API documentation. -* assuan_transact returns immetitely on an error in the callback - function. It might be Better to return the error to the caller. As - an example see dirmngr-client, where we need to send empty reponses +* assuan_transact returns immediately on an error in the callback + function. It might be better to return the error to the caller. As + an example see dirmngr-client, where we need to send empty responses for unknown inquiries, albeit dirmngr itself would handle the - returns for assuan_inquire gracefully. We need to chekc all + returns for assuan_inquire gracefully. We need to check all applications whether it is safe to change this. +* Check the system error to assuan error translation +* Do a configure test for SO_PEERCRED. + We already use HAVE_SO_PEERCRED buty it never gets defined. Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-06-27 10:37:31 UTC (rev 195) +++ trunk/configure.ac 2006-09-06 16:36:45 UTC (rev 196) @@ -23,7 +23,7 @@ # Version number: Remember to change it immediately *after* a release. # Add a "-cvs" prefix for non-released code. -AC_INIT(libassuan, 0.6.11-cvs, gnupg-devel@gnupg.org) +AC_INIT(libassuan, 0.9.0-cvs, gnupg-devel@gnupg.org) # Note, that this is not yet available as a shared library. PACKAGE=$PACKAGE_NAME @@ -68,6 +68,11 @@ fi +AH_BOTTOM([ +#define _ASSUAN_IN_LIBASSUAN 1 +]) + + # # Options depending on the host OS. # @@ -160,6 +165,7 @@ AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([src/Makefile]) AC_CONFIG_FILES([doc/Makefile]) +AC_CONFIG_FILES([tests/Makefile]) AC_CONFIG_FILES([src/libassuan-config], [chmod +x src/libassuan-config]) AC_OUTPUT Modified: trunk/doc/assuan.texi =================================================================== --- trunk/doc/assuan.texi 2006-06-27 10:37:31 UTC (rev 195) +++ trunk/doc/assuan.texi 2006-09-06 16:36:45 UTC (rev 196) @@ -175,7 +175,7 @@ @item Easy module testing @item Extendible @item Optional authentication and encryption facility -@item Usable by access external hardware +@item Usable to access external hardware @end itemize @@ -261,7 +261,7 @@ over to the next token (except for data lines where the raw data starts exactly after 2 bytes). Lines larger than 1000 bytes should be treated as a communication error. (The rationale for having a line -length limit is to allow for easier multiplexing of multiple channels). +length limit is to allow for easier multiplexing of several channels). @node Client requests @@ -405,7 +405,7 @@ @end table For historical reasons a few more error codes are defined in -@file{assuan.h}; they should not be used be new applications. +@file{assuan.h}; they should not be used by new applications. Errror codes in the range @var{ASSUAN_USER_ERROR_FIRST} to @var{ASSUAN_USER_ERROR_LAST} may be used at the applications own Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2006-06-27 10:37:31 UTC (rev 195) +++ trunk/src/ChangeLog 2006-09-06 16:36:45 UTC (rev 196) @@ -1,3 +1,37 @@ +2006-09-06 Werner Koch + + * assuan.h (_ASSUAN_ONLY_GPG_ERRORS): New. + + * assuan-handler.c (dispatch_command): Use Syntax_Error instead of + Invalid_Command. + + * assuan-domain-connect.c: Changed alloc malloc/free/realloc to + xtrymalloc et al. + (read_int, write_int): Make args void pointers. + (domain_receivefd): Take care of realloc shrinking failure. + + * assuan-buffer.c (_assuan_read_line, _assuan_write_line) + (assuan_write_line, _assuan_cookie_write_data) + (_assuan_cookie_write_flush): Print the inbound fd instead of the + address of the context when logging I/0. This makes it more + readable. + +2006-09-05 Werner Koch + + * assuan-defs.h (err_code, err_is_eof): New. + + * mkerrors (_assuan_error): New. Wrapped all error code + assignments in a call to this. + (assuan_strerror): Map gpg-style error codes back. Also print a + string for the old EOF code. + (assuan_set_assuan_err_source): New. + + * assuan-logging.c (_assuan_log_printf): Do not change ERRNO and + print the pid. + + * assuan-domain-connect.c (domain_reader): Replaced plain printf + by assuan_log function. + 2005-10-24 Werner Koch * putc_unlocked.c, memrchr.c, isascii.c, funopen.c: Changed Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2006-06-27 10:37:31 UTC (rev 195) +++ trunk/src/Makefile.am 2006-09-06 16:36:45 UTC (rev 196) @@ -54,5 +54,5 @@ libassuan_a_LIBADD = @LIBOBJS@ -assuan-errors.c : assuan.h +assuan-errors.c : assuan.h mkerrors $(srcdir)/mkerrors < $(srcdir)/assuan.h > assuan-errors.c Modified: trunk/src/assuan-buffer.c =================================================================== --- trunk/src/assuan-buffer.c 2006-06-27 10:37:31 UTC (rev 195) +++ trunk/src/assuan-buffer.c 2006-09-06 16:36:45 UTC (rev 196) @@ -31,6 +31,9 @@ #endif #include "assuan-defs.h" + +/* Extended version of write(2) to guarantee that all bytes are + written. Returns 0 on success or -1 and ERRNO on failure. */ static int writen (ASSUAN_CONTEXT ctx, const char *buffer, size_t length) { @@ -50,7 +53,9 @@ return 0; /* okay */ } -/* Read an entire line. */ +/* Read an entire line. Returns 0 on success or -1 and ERRNo on + failure. EOF is indictated by setting the integer at address + R_EOF. */ static int readline (ASSUAN_CONTEXT ctx, char *buf, size_t buflen, int *r_nread, int *r_eof) @@ -89,6 +94,7 @@ } +/* Function returns an Assuan error. */ int _assuan_read_line (ASSUAN_CONTEXT ctx) { @@ -129,19 +135,20 @@ if (rc) { if (ctx->log_fp) - fprintf (ctx->log_fp, "%s[%u.%p] DBG: <- [Error: %s]\n", + fprintf (ctx->log_fp, "%s[%u.%d] DBG: <- [Error: %s]\n", assuan_get_assuan_log_prefix (), - (unsigned int)getpid (), ctx, strerror (errno)); - return ASSUAN_Read_Error; + (unsigned int)getpid (), ctx->inbound.fd, + strerror (errno)); + return _assuan_error (ASSUAN_Read_Error); } if (!nread) { assert (ctx->inbound.eof); if (ctx->log_fp) - fprintf (ctx->log_fp, "%s[%u.%p] DBG: <- [EOF]\n", + fprintf (ctx->log_fp, "%s[%u.%d] DBG: <- [EOF]\n", assuan_get_assuan_log_prefix (), - (unsigned int)getpid (), ctx); - return -1; + (unsigned int)getpid (), ctx->inbound.fd); + return _assuan_error (-1); } ctx->inbound.attic.pending = 0; @@ -171,9 +178,9 @@ ctx->inbound.linelen = endp - line; if (ctx->log_fp) { - fprintf (ctx->log_fp, "%s[%u.%p] DBG: <- ", + fprintf (ctx->log_fp, "%s[%u.%d] DBG: <- ", assuan_get_assuan_log_prefix (), - (unsigned int)getpid (), ctx); + (unsigned int)getpid (), ctx->inbound.fd); if (ctx->confidential) fputs ("[Confidential data not shown]", ctx->log_fp); else @@ -187,13 +194,14 @@ else { if (ctx->log_fp) - fprintf (ctx->log_fp, "%s[%u.%p] DBG: <- [Invalid line]\n", + fprintf (ctx->log_fp, "%s[%u.%d] DBG: <- [Invalid line]\n", assuan_get_assuan_log_prefix (), - (unsigned int)getpid (), ctx); + (unsigned int)getpid (), ctx->inbound.fd); *line = 0; ctx->inbound.linelen = 0; - return ctx->inbound.eof ? ASSUAN_Line_Not_Terminated - : ASSUAN_Line_Too_Long; + return _assuan_error (ctx->inbound.eof + ? ASSUAN_Line_Not_Terminated + : ASSUAN_Line_Too_Long); } } @@ -213,7 +221,7 @@ assuan_error_t err; if (!ctx) - return ASSUAN_Invalid_Value; + return _assuan_error (ASSUAN_Invalid_Value); err = _assuan_read_line (ctx); *line = ctx->inbound.line; @@ -242,10 +250,10 @@ if (len + prefixlen + 2 > ASSUAN_LINELENGTH) { if (ctx->log_fp) - fprintf (ctx->log_fp, "%s[%u.%p] DBG: -> " + fprintf (ctx->log_fp, "%s[%u.%d] DBG: -> " "[supplied line too long -truncated]\n", assuan_get_assuan_log_prefix (), - (unsigned int)getpid (), ctx); + (unsigned int)getpid (), ctx->inbound.fd); if (prefixlen > 5) prefixlen = 5; if (len > ASSUAN_LINELENGTH - prefixlen - 2) @@ -255,9 +263,9 @@ /* Fixme: we should do some kind of line buffering. */ if (ctx->log_fp) { - fprintf (ctx->log_fp, "%s[%u.%p] DBG: -> ", + fprintf (ctx->log_fp, "%s[%u.%d] DBG: -> ", assuan_get_assuan_log_prefix (), - (unsigned int)getpid (), ctx); + (unsigned int)getpid (), ctx->inbound.fd); if (ctx->confidential) fputs ("[Confidential data not shown]", ctx->log_fp); else @@ -269,18 +277,18 @@ { rc = writen (ctx, prefix, prefixlen); if (rc) - rc = ASSUAN_Write_Error; + rc = _assuan_error (ASSUAN_Write_Error); } if (!rc) { rc = writen (ctx, line, len); if (rc) - rc = ASSUAN_Write_Error; + rc = _assuan_error (ASSUAN_Write_Error); if (!rc) { rc = writen (ctx, "\n", 1); if (rc) - rc = ASSUAN_Write_Error; + rc = _assuan_error (ASSUAN_Write_Error); } } return rc; @@ -294,7 +302,7 @@ const char *s; if (!ctx) - return ASSUAN_Invalid_Value; + return _assuan_error (ASSUAN_Invalid_Value); /* Make sure that we never take a LF from the user - this might violate the protocol. */ @@ -302,10 +310,10 @@ len = s? (s-line) : strlen (line); if (ctx->log_fp && s) - fprintf (ctx->log_fp, "%s[%u.%p] DBG: -> " - "[supplied line contained a LF -truncated]\n", + fprintf (ctx->log_fp, "%s[%u.%d] DBG: -> " + "[supplied line contained a LF - truncated]\n", assuan_get_assuan_log_prefix (), - (unsigned int)getpid (), ctx); + (unsigned int)getpid (), ctx->inbound.fd); return _assuan_write_line (ctx, NULL, line, len); } @@ -360,9 +368,9 @@ { if (ctx->log_fp) { - fprintf (ctx->log_fp, "%s[%u.%p] DBG: -> ", + fprintf (ctx->log_fp, "%s[%u.%d] DBG: -> ", assuan_get_assuan_log_prefix (), - (unsigned int)getpid (), ctx); + (unsigned int)getpid (), ctx->inbound.fd); if (ctx->confidential) fputs ("[Confidential data not shown]", ctx->log_fp); @@ -376,7 +384,7 @@ linelen++; if (writen (ctx, ctx->outbound.data.line, linelen)) { - ctx->outbound.data.error = ASSUAN_Write_Error; + ctx->outbound.data.error = _assuan_error (ASSUAN_Write_Error); return 0; } line = ctx->outbound.data.line; @@ -408,9 +416,9 @@ { if (ctx->log_fp) { - fprintf (ctx->log_fp, "%s[%u.%p] DBG: -> ", + fprintf (ctx->log_fp, "%s[%u.%d] DBG: -> ", assuan_get_assuan_log_prefix (), - (unsigned int)getpid (), ctx); + (unsigned int)getpid (), ctx->inbound.fd); if (ctx->confidential) fputs ("[Confidential data not shown]", ctx->log_fp); else @@ -422,7 +430,7 @@ linelen++; if (writen (ctx, ctx->outbound.data.line, linelen)) { - ctx->outbound.data.error = ASSUAN_Write_Error; + ctx->outbound.data.error = _assuan_error (ASSUAN_Write_Error); return 0; } ctx->outbound.data.linelen = 0; @@ -453,9 +461,9 @@ assuan_send_data (ASSUAN_CONTEXT ctx, const void *buffer, size_t length) { if (!ctx) - return ASSUAN_Invalid_Value; + return _assuan_error (ASSUAN_Invalid_Value); if (!buffer && length) - return ASSUAN_Invalid_Value; + return _assuan_error (ASSUAN_Invalid_Value); if (!buffer) { /* flush what we have */ Modified: trunk/src/assuan-client.c =================================================================== --- trunk/src/assuan-client.c 2006-06-27 10:37:31 UTC (rev 195) +++ trunk/src/assuan-client.c 2006-09-06 16:36:45 UTC (rev 196) @@ -104,7 +104,7 @@ *off = 3; } else - rc = ASSUAN_Invalid_Response; + rc = _assuan_error (ASSUAN_Invalid_Response); return rc; } @@ -113,7 +113,7 @@ /** * assuan_transact: * @ctx: The Assuan context - * @command: Coimmand line to be send to server + * @command: Command line to be send to the server * @data_cb: Callback function for data lines * @data_cb_arg: first argument passed to @data_cb * @inquire_cb: Callback function for a inquire response @@ -167,7 +167,7 @@ else if (okay == 2) { if (!data_cb) - rc = ASSUAN_No_Data_Callback; + rc = _assuan_error (ASSUAN_No_Data_Callback); else { char *s, *d; @@ -196,7 +196,7 @@ { assuan_write_line (ctx, "END"); /* get out of inquire mode */ _assuan_read_from_server (ctx, &okay, &off); /* dummy read */ - rc = ASSUAN_No_Inquire_Callback; + rc = _assuan_error (ASSUAN_No_Inquire_Callback); } else { @@ -217,7 +217,7 @@ else if (okay == 5) { if (!data_cb) - rc = ASSUAN_No_Data_Callback; + rc = _assuan_error (ASSUAN_No_Data_Callback); else { rc = data_cb (data_cb_arg, NULL, 0); Modified: trunk/src/assuan-defs.h =================================================================== --- trunk/src/assuan-defs.h 2006-06-27 10:37:31 UTC (rev 195) +++ trunk/src/assuan-defs.h 2006-09-06 16:36:45 UTC (rev 196) @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. + * USA. */ #ifndef ASSUAN_DEFS_H @@ -63,12 +63,16 @@ #define LINELENGTH ASSUAN_LINELENGTH + struct cmdtbl_s { const char *name; int (*handler)(ASSUAN_CONTEXT, char *line); }; + +/* A structure to dispatch I/O functions. All these functions need to + return 0 on success and set ERRNO on failure. */ struct assuan_io { /* Routine to read from input_fd. */ @@ -79,8 +83,10 @@ assuan_error_t (*sendfd) (ASSUAN_CONTEXT, int); /* Receive a file descriptor. */ assuan_error_t (*receivefd) (ASSUAN_CONTEXT, int *); -}; +}; + +/* The context we use with most functions. */ struct assuan_context_s { assuan_error_t err_no; @@ -89,17 +95,17 @@ error codes. */ /* Context specific flags (cf. assuan_flag_t). */ - struct + struct { unsigned int no_waitpid:1; /* See ASSUAN_NO_WAITPID. */ - } flags; + } flags; int confidential; int is_server; /* Set if this is context belongs to a server */ int in_inquire; char *hello_line; char *okay_line; /* See assuan_set_okay_line() */ - + void *user_pointer; /* For assuan_get_pointer and assuan-set_pointer (). */ FILE *log_fp; @@ -123,14 +129,14 @@ struct { FILE *fp; char line[LINELENGTH]; - int linelen; + int linelen; int error; - } data; + } data; } outbound; int pipe_mode; /* We are in pipe mode, i.e. we can handle just one connection and must terminate then */ - pid_t pid; /* The the pid of the peer. */ + 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 */ @@ -152,7 +158,7 @@ int *pendingfds; int pendingfdscount; - void (*deinit_handler)(ASSUAN_CONTEXT); + void (*deinit_handler)(ASSUAN_CONTEXT); int (*accept_handler)(ASSUAN_CONTEXT); int (*finish_handler)(ASSUAN_CONTEXT); @@ -183,8 +189,8 @@ Assuan context in CTX. SERVER_PID is currently not used but may become handy in the future. */ assuan_error_t _assuan_domain_init (ASSUAN_CONTEXT *r_ctx, - int rendezvousfd, - pid_t peer); + int rendezvousfd, + pid_t peer); /*-- assuan-handler.c --*/ int _assuan_register_std_commands (ASSUAN_CONTEXT ctx); @@ -199,7 +205,24 @@ /*-- assuan-client.c --*/ assuan_error_t _assuan_read_from_server (ASSUAN_CONTEXT ctx, int *okay, int *off); +/*-- assuan-error.c --*/ + +/* Map error codes as used in this implementaion to the libgpg-error + codes. */ +int _assuan_error (int oldcode); + +/* Extrac the erro code from A. This works for both the old and the + new style error codes. This needs to be whenever an error code is + compared. */ +#define err_code(a) ((a) & 0x00ffffff) + +/* Check whether A is the erro code for EOF. We allow forold and new + style EOF error codes here. */ +#define err_is_eof(a) ((a) == (-1) || err_code (a) == 16383) + + + /*-- assuan-util.c --*/ void *_assuan_malloc (size_t n); void *_assuan_calloc (size_t n, size_t m); @@ -211,7 +234,8 @@ #define xtryrealloc(a,b) _assuan_realloc((a),(b)) #define xfree(a) _assuan_free ((a)) -#define set_error(c,e,t) assuan_set_error ((c), ASSUAN_ ## e, (t)) +#define set_error(c,e,t) \ + assuan_set_error ((c), _assuan_error (ASSUAN_ ## e), (t)) void _assuan_log_print_buffer (FILE *fp, const void *buffer, size_t length); void _assuan_log_sanitized_string (const char *string); @@ -267,4 +291,3 @@ #endif #endif /*ASSUAN_DEFS_H*/ - Modified: trunk/src/assuan-domain-connect.c =================================================================== --- trunk/src/assuan-domain-connect.c 2006-06-27 10:37:31 UTC (rev 195) +++ trunk/src/assuan-domain-connect.c 2006-09-06 16:36:45 UTC (rev 196) @@ -60,7 +60,7 @@ /* Read an integer from byte address ADDR. Works even if ADDR is misaligned. */ static int -read_int (const char *addr) +read_int (const void *addr) { int val; @@ -73,7 +73,7 @@ /* Write the integer VAL to byte address ADDR. Works even if ADDR is misaligned. */ static void -write_int (char *addr, int val) +write_int (void *addr, int val) { memcpy (addr, &val, sizeof (int)); } @@ -90,7 +90,7 @@ if (ctx->domainbuffer) { assert (ctx->domainbufferallocated); - free (ctx->domainbuffer); + xfree (ctx->domainbuffer); } if (ctx->pendingfds) @@ -101,7 +101,7 @@ for (i = 0; i < ctx->pendingfdscount; i ++) _assuan_close (ctx->pendingfds[i]); - free (ctx->pendingfds); + xfree (ctx->pendingfds); } unlink (ctx->myaddr.sun_path); @@ -126,8 +126,7 @@ { struct cmsghdr hdr; int fd; - } - cmsg; + } cmsg; memset (&msg, 0, sizeof (msg)); @@ -147,7 +146,7 @@ len = recvmsg (ctx->inbound.fd, &msg, MSG_PEEK); if (len < 0) { - printf ("domain_reader: %m\n"); + _assuan_log_printf ("domain_reader: %s\n", strerror (errno)); return -1; } @@ -171,11 +170,11 @@ else size *= 2; - tmp = malloc (size); + tmp = xtrymalloc (size); if (! tmp) return -1; - free (ctx->domainbuffer); + xfree (ctx->domainbuffer); ctx->domainbuffer = tmp; ctx->domainbufferallocated = size; } @@ -221,8 +220,8 @@ { void *tmp; - tmp = realloc (ctx->pendingfds, - sizeof (int) * (ctx->pendingfdscount + 1)); + tmp = xtryrealloc (ctx->pendingfds, + sizeof (int) * (ctx->pendingfdscount + 1)); if (! tmp) { _assuan_log_printf ("domain_reader: %s\n", strerror (errno)); @@ -303,8 +302,7 @@ { struct cmsghdr hdr; int fd; - } - cmsg; + } cmsg; int len; memset (&msg, 0, sizeof (msg)); @@ -329,7 +327,7 @@ if (len < 0) { _assuan_log_printf ("domain_sendfd: %s\n", strerror (errno)); - return ASSUAN_General_Error; + return _assuan_error (ASSUAN_General_Error); } else return 0; @@ -345,22 +343,28 @@ if (ctx->pendingfds == 0) { _assuan_log_printf ("no pending file descriptors!\n"); - return ASSUAN_General_Error; + return _assuan_error (ASSUAN_General_Error); } *fd = ctx->pendingfds[0]; if (-- ctx->pendingfdscount == 0) { - free (ctx->pendingfds); + xfree (ctx->pendingfds); ctx->pendingfds = 0; } - else - /* Fix the array. */ + else /* Fix the array. */ { + void *tmp; + memmove (ctx->pendingfds, ctx->pendingfds + 1, ctx->pendingfdscount * sizeof (int)); - ctx->pendingfds = realloc (ctx->pendingfds, - ctx->pendingfdscount * sizeof (int)); + tmp = xtryrealloc (ctx->pendingfds, + ctx->pendingfdscount * sizeof (int)); + if (tmp) + ctx->pendingfds = tmp; + /* Note: we ignore an shrinking error here thus the next realloc + to increase the size will succeed as the block is already of + the then requested size. */ } #endif return 0; @@ -368,9 +372,6 @@ -/* Make a connection to the Unix domain socket NAME and return a new - Assuan context in CTX. SERVER_PID is currently not used but may - become handy in the future. */ assuan_error_t _assuan_domain_init (assuan_context_t *r_ctx, int rendezvousfd, pid_t peer) { @@ -384,7 +385,7 @@ int tries; if (!r_ctx) - return ASSUAN_Invalid_Value; + return _assuan_error (ASSUAN_Invalid_Value); *r_ctx = NULL; err = _assuan_new_context (&ctx); @@ -404,7 +405,7 @@ { _assuan_log_printf ("can't create socket: %s\n", strerror (errno)); _assuan_release_context (ctx); - return ASSUAN_General_Error; + return _assuan_error (ASSUAN_General_Error); } ctx->inbound.fd = fd; @@ -438,7 +439,7 @@ "name. DoS in progress?\n"); _assuan_release_context (ctx); _assuan_close (fd); - return ASSUAN_General_Error; + return _assuan_error (ASSUAN_General_Error); } memset (&ctx->myaddr, 0, sizeof ctx->myaddr); @@ -458,7 +459,7 @@ strerror (errno)); _assuan_release_context (ctx); _assuan_close (fd); - return ASSUAN_Connect_Failed; + return _assuan_error (ASSUAN_Connect_Failed); } /* Rendezvous with our peer. */ @@ -469,8 +470,9 @@ fp = fdopen (rendezvousfd, "w+"); if (! fp) { - _assuan_log_printf ("can't open rendezvous port: %s\n", strerror (errno)); - return ASSUAN_Connect_Failed; + _assuan_log_printf ("can't open rendezvous port: %s\n", + strerror (errno)); + return _assuan_error (ASSUAN_Connect_Failed); } /* Send our address. */ @@ -498,13 +500,17 @@ return 0; } +/* Connect to a Unix domain socket server. RENDEZVOUSFD is + bidirectional file descriptor (normally returned via socketpair) + which the client can use to rendezvous with the server. SERVER is + the server's pid. */ assuan_error_t -assuan_domain_connect (assuan_context_t * r_ctx, int rendezvousfd, pid_t peer) +assuan_domain_connect (assuan_context_t *r_ctx, int rendezvousfd, pid_t server) { assuan_error_t aerr; int okay, off; - aerr = _assuan_domain_init (r_ctx, rendezvousfd, peer); + aerr = _assuan_domain_init (r_ctx, rendezvousfd, server); if (aerr) return aerr; @@ -518,7 +524,7 @@ _assuan_log_printf ("can't connect to server: `"); _assuan_log_sanitized_string ((*r_ctx)->inbound.line); fprintf (assuan_get_assuan_log_stream (), "'\n"); - aerr = ASSUAN_Connect_Failed; + aerr = _assuan_error (ASSUAN_Connect_Failed); } if (aerr) Modified: trunk/src/assuan-domain-server.c =================================================================== --- trunk/src/assuan-domain-server.c 2006-06-27 10:37:31 UTC (rev 195) +++ trunk/src/assuan-domain-server.c 2006-09-06 16:36:45 UTC (rev 196) @@ -27,15 +27,18 @@ #include "assuan-defs.h" -/* Initialize a server. */ +/* Initialize a server. RENDEZVOUSFD is a bidirectional file + descriptor (normally returned via socketpair) that the domain + server can use to rendezvous with the client. CLIENT is the + client's pid. */ assuan_error_t assuan_init_domain_server (ASSUAN_CONTEXT *r_ctx, int rendezvousfd, - pid_t peer) + pid_t client) { assuan_error_t err; - err = _assuan_domain_init (r_ctx, rendezvousfd, peer); + err = _assuan_domain_init (r_ctx, rendezvousfd, client); if (err) return err; Modified: trunk/src/assuan-handler.c =================================================================== --- trunk/src/assuan-handler.c 2006-06-27 10:37:31 UTC (rev 195) +++ trunk/src/assuan-handler.c 2006-09-06 16:36:45 UTC (rev 196) @@ -246,7 +246,7 @@ cmd_name = NULL; if (!cmd_name) - return ASSUAN_Invalid_Value; + return _assuan_error (ASSUAN_Invalid_Value); if (!handler) { /* find a default handler. */ @@ -269,7 +269,7 @@ ctx->cmdtbl_size = 50; ctx->cmdtbl = xtrycalloc ( ctx->cmdtbl_size, sizeof *ctx->cmdtbl); if (!ctx->cmdtbl) - return ASSUAN_Out_Of_Core; + return _assuan_error (ASSUAN_Out_Of_Core); ctx->cmdtbl_used = 0; } else if (ctx->cmdtbl_used >= ctx->cmdtbl_size) @@ -278,7 +278,7 @@ x = xtryrealloc ( ctx->cmdtbl, (ctx->cmdtbl_size+10) * sizeof *x); if (!x) - return ASSUAN_Out_Of_Core; + return _assuan_error (ASSUAN_Out_Of_Core); ctx->cmdtbl = x; ctx->cmdtbl_size += 50; } @@ -293,7 +293,7 @@ assuan_register_bye_notify (ASSUAN_CONTEXT ctx, void (*fnc)(ASSUAN_CONTEXT)) { if (!ctx) - return ASSUAN_Invalid_Value; + return _assuan_error (ASSUAN_Invalid_Value); ctx->bye_notify_fnc = fnc; return 0; } @@ -302,7 +302,7 @@ assuan_register_reset_notify (ASSUAN_CONTEXT ctx, void (*fnc)(ASSUAN_CONTEXT)) { if (!ctx) - return ASSUAN_Invalid_Value; + return _assuan_error (ASSUAN_Invalid_Value); ctx->reset_notify_fnc = fnc; return 0; } @@ -311,7 +311,7 @@ assuan_register_cancel_notify (ASSUAN_CONTEXT ctx, void (*fnc)(ASSUAN_CONTEXT)) { if (!ctx) - return ASSUAN_Invalid_Value; + return _assuan_error (ASSUAN_Invalid_Value); ctx->cancel_notify_fnc = fnc; return 0; } @@ -322,7 +322,7 @@ const char*, const char*)) { if (!ctx) - return ASSUAN_Invalid_Value; + return _assuan_error (ASSUAN_Invalid_Value); ctx->option_handler_fnc = fnc; return 0; } @@ -332,7 +332,7 @@ void (*fnc)(ASSUAN_CONTEXT, const char *)) { if (!ctx) - return ASSUAN_Invalid_Value; + return _assuan_error (ASSUAN_Invalid_Value); ctx->input_notify_fnc = fnc; return 0; } @@ -342,7 +342,7 @@ void (*fnc)(ASSUAN_CONTEXT, const char *)) { if (!ctx) - return ASSUAN_Invalid_Value; + return _assuan_error (ASSUAN_Invalid_Value); ctx->output_notify_fnc = fnc; return 0; } @@ -407,7 +407,7 @@ for (p=line; *p && *p != ' ' && *p != '\t'; p++) ; if (p==line) - return set_error (ctx, Invalid_Command, "leading white-space"); + return set_error (ctx, Syntax_Error, "leading white-space"); if (*p) { /* Skip over leading WS after the keyword */ *p++ = 0; @@ -447,7 +447,7 @@ int rc; if (ctx->in_inquire) - return ASSUAN_Nested_Commands; + return _assuan_error (ASSUAN_Nested_Commands); rc = _assuan_read_line (ctx); if (rc) @@ -478,7 +478,7 @@ { rc = assuan_write_line (ctx, ctx->okay_line? ctx->okay_line : "OK"); } - else if (rc == -1) + else if (err_is_eof (rc)) { /* No error checking because the peer may have already disconnect */ assuan_write_line (ctx, "OK closing connection"); ctx->finish_handler (ctx); @@ -489,7 +489,7 @@ if (rc < 100) sprintf (errline, "ERR %d server fault (%.50s)", - ASSUAN_Server_Fault, assuan_strerror (rc)); + _assuan_error (ASSUAN_Server_Fault), assuan_strerror (rc)); else { const char *text = ctx->err_no == rc? ctx->err_str:NULL; @@ -499,7 +499,7 @@ strings from libgpg-error without creating a dependency. They are used for debugging purposes only, so there is no problem if they are not available. We need to make sure - that we are using elf because only this guarantees that + that we are using ELF because only this guarantees that weak symbol support is available in case GNU ld is not used. */ unsigned int source, code; @@ -561,7 +561,7 @@ rc = process_request (ctx); } while (!rc); - if (rc == -1) + if (err_is_eof (rc)) rc = 0; return rc; @@ -662,7 +662,7 @@ assuan_set_okay_line (ASSUAN_CONTEXT ctx, const char *line) { if (!ctx) - return ASSUAN_Invalid_Value; + return _assuan_error (ASSUAN_Invalid_Value); if (!line) { xfree (ctx->okay_line); @@ -674,7 +674,7 @@ we should allocate the entire line in secure memory */ char *buf = xtrymalloc (3+strlen(line)+1); if (!buf) - return ASSUAN_Out_Of_Core; + return _assuan_error (ASSUAN_Out_Of_Core); strcpy (buf, "OK "); strcpy (buf+3, line); xfree (ctx->okay_line); @@ -694,7 +694,7 @@ assuan_error_t ae; if ( !ctx || !keyword) - return ASSUAN_Invalid_Value; + return _assuan_error (ASSUAN_Invalid_Value); if (!text) text = ""; Modified: trunk/src/assuan-inquire.c =================================================================== --- trunk/src/assuan-inquire.c 2006-06-27 10:37:31 UTC (rev 195) +++ trunk/src/assuan-inquire.c 2006-09-06 16:36:45 UTC (rev 196) @@ -147,14 +147,14 @@ int nodataexpected; if (!ctx || !keyword || (10 + strlen (keyword) >= sizeof (cmdbuf))) - return ASSUAN_Invalid_Value; + return _assuan_error (ASSUAN_Invalid_Value); nodataexpected = !r_buffer && !r_length && !maxlen; if (!nodataexpected && (!r_buffer || !r_length)) - return ASSUAN_Invalid_Value; + return _assuan_error (ASSUAN_Invalid_Value); if (!ctx->is_server) - return ASSUAN_Not_A_Server; + return _assuan_error (ASSUAN_Not_A_Server); if (ctx->in_inquire) - return ASSUAN_Nested_Commands; + return _assuan_error (ASSUAN_Nested_Commands); ctx->in_inquire = 1; if (nodataexpected) @@ -183,12 +183,12 @@ break; /* END command received*/ if (line[0] == 'C' && line[1] == 'A' && line[2] == 'N') { - rc = ASSUAN_Canceled; + rc = _assuan_error (ASSUAN_Canceled); goto leave; } if (line[0] != 'D' || line[1] != ' ' || nodataexpected) { - rc = ASSUAN_Unexpected_Command; + rc = _assuan_error (ASSUAN_Unexpected_Command); goto leave; } if (linelen < 3) @@ -215,7 +215,7 @@ } if (mb.too_large) { - rc = ASSUAN_Too_Much_Data; + rc = _assuan_error (ASSUAN_Too_Much_Data); goto leave; } } @@ -224,7 +224,7 @@ { *r_buffer = get_membuf (&mb, r_length); if (!*r_buffer) - rc = ASSUAN_Out_Of_Core; + rc = _assuan_error (ASSUAN_Out_Of_Core); } leave: Modified: trunk/src/assuan-listen.c =================================================================== --- trunk/src/assuan-listen.c 2006-06-27 10:37:31 UTC (rev 195) +++ trunk/src/assuan-listen.c 2006-09-06 16:36:45 UTC (rev 196) @@ -31,7 +31,7 @@ assuan_set_hello_line (assuan_context_t ctx, const char *line) { if (!ctx) - return ASSUAN_Invalid_Value; + return _assuan_error (ASSUAN_Invalid_Value); if (!line) { xfree (ctx->hello_line); @@ -41,7 +41,7 @@ { char *buf = xtrymalloc (3+strlen(line)+1); if (!buf) - return ASSUAN_Out_Of_Core; + return _assuan_error (ASSUAN_Out_Of_Core); if (strchr (line, '\n')) strcpy (buf, line); else @@ -74,7 +74,7 @@ const char *p, *pend; if (!ctx) - return ASSUAN_Invalid_Value; + return _assuan_error (ASSUAN_Invalid_Value); if (ctx->pipe_mode > 1) return -1; /* second invocation for pipemode -> terminate */ @@ -135,7 +135,7 @@ assuan_close_input_fd (assuan_context_t ctx) { if (!ctx || ctx->input_fd == -1) - return ASSUAN_Invalid_Value; + return _assuan_error (ASSUAN_Invalid_Value); _assuan_close (ctx->input_fd); ctx->input_fd = -1; return 0; @@ -147,7 +147,7 @@ assuan_close_output_fd (assuan_context_t ctx) { if (!ctx || ctx->output_fd == -1) - return ASSUAN_Invalid_Value; + return _assuan_error (ASSUAN_Invalid_Value); _assuan_close (ctx->output_fd); ctx->output_fd = -1; Modified: trunk/src/assuan-logging.c =================================================================== --- trunk/src/assuan-logging.c 2006-06-27 10:37:31 UTC (rev 195) +++ trunk/src/assuan-logging.c 2006-09-06 16:36:45 UTC (rev 196) @@ -28,6 +28,7 @@ #ifdef HAVE_W32_SYSTEM #include #endif /*HAVE_W32_SYSTEM*/ +#include #include "assuan-defs.h" @@ -81,18 +82,17 @@ va_list arg_ptr; FILE *fp; const char *prf; - + int save_errno = errno; + fp = assuan_get_assuan_log_stream (); prf = assuan_get_assuan_log_prefix (); if (*prf) - { - fputs (prf, fp); - fputs (": ", fp); - } + fprintf (fp, "%s[%u]: ", prf, (unsigned int)getpid ()); va_start (arg_ptr, format); vfprintf (fp, format, arg_ptr ); va_end (arg_ptr); + errno = save_errno; } Modified: trunk/src/assuan-pipe-connect.c =================================================================== --- trunk/src/assuan-pipe-connect.c 2006-06-27 10:37:31 UTC (rev 195) +++ trunk/src/assuan-pipe-connect.c 2006-09-06 16:36:45 UTC (rev 196) @@ -270,7 +270,7 @@ HANDLE nullfd = INVALID_HANDLE_VALUE; if (!ctx || !name || !argv || !argv[0]) - return ASSUAN_Invalid_Value; + return _assuan_error (ASSUAN_Invalid_Value); fix_signals (); @@ -278,13 +278,13 @@ /* Build the command line. */ if (build_w32_commandline (argv, &cmdline)) - return ASSUAN_Out_Of_Core; + return _assuan_error (ASSUAN_Out_Of_Core); /* Create thew two pipes. */ if (create_inheritable_pipe (rp, 0)) { xfree (cmdline); - return ASSUAN_General_Error; + return _assuan_error (ASSUAN_General_Error); } if (create_inheritable_pipe (wp, 1)) @@ -292,7 +292,7 @@ CloseHandle (fd_to_handle (rp[0])); CloseHandle (fd_to_handle (rp[1])); xfree (cmdline); - return ASSUAN_General_Error; + return _assuan_error (ASSUAN_General_Error); } @@ -304,7 +304,7 @@ CloseHandle (fd_to_handle (wp[0])); CloseHandle (fd_to_handle (wp[1])); xfree (cmdline); - return ASSUAN_General_Error; + return _assuan_error (ASSUAN_General_Error); } (*ctx)->pipe_mode = 1; @@ -391,7 +391,7 @@ CloseHandle (nullfd); xfree (cmdline); _assuan_release_context (*ctx); - return ASSUAN_General_Error; + return _assuan_error (ASSUAN_General_Error); } xfree (cmdline); cmdline = NULL; @@ -421,20 +421,20 @@ char mypidstr[50]; if (!ctx || !name || !argv || !argv[0]) - return ASSUAN_Invalid_Value; + return _assuan_error (ASSUAN_Invalid_Value); fix_signals (); sprintf (mypidstr, "%lu", (unsigned long)getpid ()); if (pipe (rp) < 0) - return ASSUAN_General_Error; + return _assuan_error (ASSUAN_General_Error); if (pipe (wp) < 0) { close (rp[0]); close (rp[1]); - return ASSUAN_General_Error; + return _assuan_error (ASSUAN_General_Error); } err = _assuan_new_context (ctx); @@ -462,7 +462,7 @@ close (wp[0]); close (wp[1]); _assuan_release_context (*ctx); - return ASSUAN_General_Error; + return _assuan_error (ASSUAN_General_Error); } if ((*ctx)->pid == 0) @@ -559,7 +559,8 @@ /* oops - use the pipe to tell the parent about it */ snprintf (errbuf, sizeof(errbuf)-1, "ERR %d can't exec `%s': %.50s\n", - ASSUAN_Problem_Starting_Server, name, strerror (errno)); + _assuan_error (ASSUAN_Problem_Starting_Server), + name, strerror (errno)); errbuf[sizeof(errbuf)-1] = 0; writen (1, errbuf, strlen (errbuf)); _exit (4); @@ -594,7 +595,7 @@ { _assuan_log_printf ("can't connect server: `%s'\n", (*ctx)->inbound.line); - err = ASSUAN_Connect_Failed; + err = _assuan_error (ASSUAN_Connect_Failed); } } Modified: trunk/src/assuan-pipe-server.c =================================================================== --- trunk/src/assuan-pipe-server.c 2006-06-27 10:37:31 UTC (rev 195) +++ trunk/src/assuan-pipe-server.c 2006-09-06 16:36:45 UTC (rev 196) @@ -66,7 +66,7 @@ *r_ctx = NULL; ctx = xtrycalloc (1, sizeof *ctx); if (!ctx) - return ASSUAN_Out_Of_Core; + return _assuan_error (ASSUAN_Out_Of_Core); ctx->input_fd = -1; ctx->output_fd = -1; Modified: trunk/src/assuan-socket-connect.c =================================================================== --- trunk/src/assuan-socket-connect.c 2006-06-27 10:37:31 UTC (rev 195) +++ trunk/src/assuan-socket-connect.c 2006-09-06 16:36:45 UTC (rev 196) @@ -89,7 +89,7 @@ const char *s; if (!r_ctx || !name) - return ASSUAN_Invalid_Value; + return _assuan_error (ASSUAN_Invalid_Value); *r_ctx = NULL; /* We require that the name starts with a slash, so that we can @@ -99,10 +99,10 @@ if (*s && s[1] == ':') s += 2; if (*s != DIRSEP_C && *s != '/') - return ASSUAN_Invalid_Value; + return _assuan_error (ASSUAN_Invalid_Value); if (strlen (name)+1 >= sizeof srvr_addr.sun_path) - return ASSUAN_Invalid_Value; + return _assuan_error (ASSUAN_Invalid_Value); err = _assuan_new_context (&ctx); if (err) @@ -116,7 +116,7 @@ { _assuan_log_printf ("can't create socket: %s\n", strerror (errno)); _assuan_release_context (ctx); - return ASSUAN_General_Error; + return _assuan_error (ASSUAN_General_Error); } memset (&srvr_addr, 0, sizeof srvr_addr); @@ -132,7 +132,7 @@ name, strerror (errno)); _assuan_release_context (ctx); _assuan_close (fd); - return ASSUAN_Connect_Failed; + return _assuan_error (ASSUAN_Connect_Failed); } ctx->inbound.fd = fd; @@ -152,7 +152,7 @@ /*LOG ("can't connect to server: `");*/ _assuan_log_sanitized_string (ctx->inbound.line); fprintf (assuan_get_assuan_log_stream (), "'\n"); - err = ASSUAN_Connect_Failed; + err = _assuan_error (ASSUAN_Connect_Failed); } } Modified: trunk/src/assuan-socket-server.c =================================================================== --- trunk/src/assuan-socket-server.c 2006-06-27 10:37:31 UTC (rev 195) +++ trunk/src/assuan-socket-server.c 2006-09-06 16:36:45 UTC (rev 196) @@ -79,7 +79,7 @@ if (fd == -1) { ctx->os_errno = errno; - return ASSUAN_Accept_Failed; + return _assuan_error (ASSUAN_Accept_Failed); } ctx->connected_fd = fd; @@ -119,7 +119,7 @@ *r_ctx = NULL; ctx = xtrycalloc (1, sizeof *ctx); if (!ctx) - return ASSUAN_Out_Of_Core; + return _assuan_error (ASSUAN_Out_Of_Core); ctx->is_server = 1; ctx->input_fd = -1; ctx->output_fd = -1; @@ -153,7 +153,7 @@ *r_ctx = NULL; ctx = xtrycalloc (1, sizeof *ctx); if (!ctx) - return ASSUAN_Out_Of_Core; + return _assuan_error (ASSUAN_Out_Of_Core); ctx->is_server = 1; ctx->pipe_mode = 1; /* we want a second accept to indicate EOF */ ctx->input_fd = -1; Modified: trunk/src/assuan.h =================================================================== --- trunk/src/assuan.h 2006-06-27 10:37:31 UTC (rev 195) +++ trunk/src/assuan.h 2006-09-06 16:36:45 UTC (rev 196) @@ -27,24 +27,32 @@ #include -/* To use this file with libraries the following macros are often - useful: +/* To use this file with libraries the following macros are useful: - #define _ASSUAN_EXT_SYM_PREFIX _foo_ + #define _ASSUAN_EXT_SYM_PREFIX _foo_ This prefixes all external symbols with "_foo_". - #define _ASSUAN_NO_PTH + #define _ASSUAN_ONLY_GPG_ERRORS - This avoids inclusion of special GNU Pth hacks. + If this is defined all old-style Assuan error codes are made + inactive as well as other dereacted stuff. - #define _ASSUAN_NO_FIXED_SIGNALS + The follwing macros are used internally in the implementation of + libassuan: - This disables changing of certain signal handler; i.e. SIGPIPE. + #define _ASSUAN_NO_PTH - #define _ASSUAN_USE_DOUBLE_FORK + This avoids inclusion of special GNU Pth hacks. - Use a double fork approach when connecting to a server through a pipe. + #define _ASSUAN_NO_FIXED_SIGNALS + + This disables changing of certain signal handler; i.e. SIGPIPE. + + #define _ASSUAN_USE_DOUBLE_FORK + + Use a double fork approach when connecting to a server through + a pipe. */ @@ -105,6 +113,8 @@ #define assuan_begin_confidential _ASSUAN_PREFIX(assuan_begin_confidential) #define assuan_end_confidential _ASSUAN_PREFIX(assuan_end_confidential) #define assuan_strerror _ASSUAN_PREFIX(assuan_strerror) +#define assuan_set_assuan_err_source \ + _ASSUAN_PREFIX(assuan_set_assuan_err_source) #define assuan_set_assuan_log_stream \ _ASSUAN_PREFIX(assuan_set_assuan_log_stream) #define assuan_get_assuan_log_stream \ @@ -156,19 +166,27 @@ #endif #endif - +#ifndef _ASSUAN_ONLY_GPG_ERRORS +/* Assuan error codes. These are only used by old applications or + those applications which won't make use of libgpg-error. */ typedef enum { +#ifndef _ASSUAN_IN_LIBASSUAN ASSUAN_No_Error = 0, +#endif ASSUAN_General_Error = 1, ASSUAN_Out_Of_Core = 2, ASSUAN_Invalid_Value = 3, +#ifndef _ASSUAN_IN_LIBASSUAN ASSUAN_Timeout = 4, +#endif ASSUAN_Read_Error = 5, ASSUAN_Write_Error = 6, ASSUAN_Problem_Starting_Server = 7, ASSUAN_Not_A_Server = 8, +#ifndef _ASSUAN_IN_LIBASSUAN ASSUAN_Not_A_Client = 9, +#endif ASSUAN_Nested_Commands = 10, ASSUAN_Invalid_Response = 11, ASSUAN_No_Data_Callback = 12, @@ -179,24 +197,33 @@ /* Error codes above 99 are meant as status codes */ ASSUAN_Not_Implemented = 100, ASSUAN_Server_Fault = 101, +#ifndef _ASSUAN_IN_LIBASSUAN ASSUAN_Invalid_Command = 102, +#endif ASSUAN_Unknown_Command = 103, ASSUAN_Syntax_Error = 104, +#ifndef _ASSUAN_IN_LIBASSUAN ASSUAN_Parameter_Error = 105, +#endif ASSUAN_Parameter_Conflict = 106, ASSUAN_Line_Too_Long = 107, ASSUAN_Line_Not_Terminated = 108, +#ifndef _ASSUAN_IN_LIBASSUAN ASSUAN_No_Input = 109, ASSUAN_No_Output = 110, +#endif ASSUAN_Canceled = 111, +#ifndef _ASSUAN_IN_LIBASSUAN ASSUAN_Unsupported_Algorithm = 112, ASSUAN_Server_Resource_Problem = 113, ASSUAN_Server_IO_Error = 114, ASSUAN_Server_Bug = 115, ASSUAN_No_Data_Available = 116, ASSUAN_Invalid_Data = 117, +#endif ASSUAN_Unexpected_Command = 118, ASSUAN_Too_Much_Data = 119, +#ifndef _ASSUAN_IN_LIBASSUAN ASSUAN_Inquire_Unknown = 120, ASSUAN_Inquire_Error = 121, ASSUAN_Invalid_Option = 122, @@ -207,7 +234,7 @@ ASSUAN_Locale_Problem = 127, ASSUAN_Not_Confirmed = 128, - /* Warning: Don't use the rror codes, below they are deprecated. */ + /* Warning: Don't use the Error codes, below they are deprecated. */ ASSUAN_Bad_Certificate = 201, ASSUAN_Bad_Certificate_Chain = 202, ASSUAN_Missing_Certificate = 203, @@ -233,7 +260,7 @@ at their own discretion. */ ASSUAN_USER_ERROR_FIRST = 1000, ASSUAN_USER_ERROR_LAST = 9999 - +#endif } assuan_error_t; typedef assuan_error_t AssuanError; /* Deprecated. */ @@ -258,6 +285,13 @@ } AssuanCommand; +#else /*!_ASSUAN_ONLY_GPG_ERRORS*/ + +typedef int assuan_error_t; + +#endif /*!_ASSUAN_ONLY_GPG_ERRORS*/ + + /* Definitions of flags for assuan_set_flag(). */ typedef enum { @@ -274,7 +308,9 @@ struct assuan_context_s; typedef struct assuan_context_s *assuan_context_t; +#ifndef _ASSUAN_ONLY_GPG_ERRORS typedef struct assuan_context_s *ASSUAN_CONTEXT; +#endif /*_ASSUAN_ONLY_GPG_ERRORS*/ /*-- assuan-handler.c --*/ int assuan_register_command (assuan_context_t ctx, @@ -351,8 +387,8 @@ which the client can use to rendezvous with the server. SERVER s the server's pid. */ assuan_error_t assuan_domain_connect (assuan_context_t *r_ctx, - int rendezvousfd, - pid_t server); + int rendezvousfd, + pid_t server); /*-- assuan-domain-server.c --*/ @@ -360,8 +396,8 @@ via socketpair) that the domain server can use to rendezvous with the client. CLIENT is the client's pid. */ assuan_error_t assuan_init_domain_server (assuan_context_t *r_ctx, - int rendezvousfd, - pid_t client); + int rendezvousfd, + pid_t client); /*-- assuan-connect.c --*/ @@ -421,9 +457,21 @@ int assuan_get_flag (assuan_context_t ctx, assuan_flag_t flag); -/*-- assuan-errors.c (built) --*/ +/*-- assuan-errors.c --*/ + +#ifndef _ASSUAN_ONLY_GPG_ERRORS +/* Return a string describing the assuan error. The use of this + function is deprecated; it is better to call + assuan_set_assuan_err_source once and then make use libgpg-error. */ const char *assuan_strerror (assuan_error_t err); +#endif /*_ASSUAN_ONLY_GPG_ERRORS*/ +/* Enable gpg-error style error codes. ERRSOURCE is one of gpg-error + sources. Note, that this function is not thread-safe and should be + used right at startup. Switching back to the old style mode is not + supported. */ +void assuan_set_assuan_err_source (int errsource); + /*-- assuan-logging.c --*/ /* Set the stream to which assuan should log message not associated Modified: trunk/src/mkerrors =================================================================== --- trunk/src/mkerrors 2006-06-27 10:37:31 UTC (rev 195) +++ trunk/src/mkerrors 2006-09-06 16:36:45 UTC (rev 196) @@ -1,7 +1,7 @@ #!/bin/sh # mkerrors - Extract error strings from assuan.h # and create C source for assuan_strerror -# Copyright (C) 2001, 2002 Free Software Foundation, Inc. +# Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc. # # This file is part of Assuan. # @@ -21,15 +21,114 @@ cat < #endif #include +#include +#include + +#undef _ASSUAN_IN_LIBASSUAN /* undef to get all error codes. */ #include "assuan.h" +/* If true the modern gpg-error style error codes are used in the + API. */ +static unsigned int err_source; + +/* Enable gpg-error style error codes. ERRSOURCE is one of gpg-error + sources. Note, that this function is not thread-safe and should be + used right at startup. Switching back to the old style mode is not + supported. */ +void +assuan_set_assuan_err_source (int errsource) +{ + errsource &= 0xff; + err_source = errsource? errsource : 31 /*GPG_ERR_SOURCE_ANY*/; +} + + +/* Helper to map old style Assuan error codes to gpg-error codes. + This is used internally to keep an compatible ABI. */ +int +_assuan_error (int oldcode) +{ + unsigned int n; + + if (!err_source) + return (oldcode & 0x00ffffff); /* Make sure that the gpg-error + source part is cleared. */ + + switch (oldcode) + { + case ASSUAN_General_Error: n = 257; break; + case ASSUAN_Accept_Failed: n = 258; break; + case ASSUAN_Connect_Failed: n = 259; break; + case ASSUAN_Invalid_Response: n = 260; break; + case ASSUAN_Invalid_Value: n = 261; break; + case ASSUAN_Line_Not_Terminated: n = 262; break; + case ASSUAN_Line_Too_Long: n = 263; break; + case ASSUAN_Nested_Commands: n = 264; break; + case ASSUAN_No_Data_Callback: n = 265; break; + case ASSUAN_No_Inquire_Callback: n = 266; break; + case ASSUAN_Not_A_Server: n = 267; break; + case ASSUAN_Not_Implemented: n = 69; break; + case ASSUAN_Parameter_Conflict: n = 280; break; + case ASSUAN_Problem_Starting_Server: n = 269; break; + case ASSUAN_Server_Fault: n = 80; break; + case ASSUAN_Syntax_Error: n = 276; break; + case ASSUAN_Too_Much_Data: n = 273; break; + case ASSUAN_Unexpected_Command: n = 274; break; + case ASSUAN_Unknown_Command: n = 275; break; + case ASSUAN_Canceled: n = 277; break; + + case ASSUAN_Read_Error: + switch (errno) + { + case 0: n = 16381; /*GPG_ERR_MISSING_ERRNO*/ break; + default: n = 270; /*GPG_ERR_ASS_READ_ERROR*/ break; + } + break; + + case ASSUAN_Write_Error: + switch (errno) + { + case 0: n = 16381; /*GPG_ERR_MISSING_ERRNO*/ break; + default: n = 271; /*GPG_ERR_ASS_WRITE_ERROR*/ break; + } + break; + + case ASSUAN_Out_Of_Core: + switch (errno) + { + case 0: /* Should not happen but a user might have provided + an incomplete implemented malloc function. Give + him a chance to correct this fault but make sure + an error is indeed returned. */ + n = 16381; /*GPG_ERR_MISSING_ERRNO*/ + break; + case ENOMEM: n = (1 << 15) | 86; break; + default: + n = 16382; /*GPG_ERR_UNKNOWN_ERRNO*/ + break; + } + break; + + case -1: n = 16383 /*GPG_ERR_EOF*/; break; + + default: + assert (!"unmapped error code used in libassuan!!"); + n = 257; /* Just in case someone compiled with NDEBUG. */ + break; + } + + return ((err_source << 24) | (n & 0x00ffffff)); + +} + + /** * assuan_strerror: * @err: Error code @@ -54,6 +153,7 @@ /ASSUAN_No_Error/ { okay=1 } !okay {next} /}/ { exit 0 } +/^#/ {next} /ASSUAN_[A-Za-z_]*/ { print_code($1) } @@ -66,21 +166,62 @@ ' cat <> 24) & 0xff); code = (err & 0x00ffffff); - if (source) /* Assume this is an libgpg-error. */ - sprintf (buf, "ec=%u.%u", source, code ); + if (source) + { + /* Assume this is an libgpg-error and try to map the codes + back. */ + switch (code) + { + case 257: n = ASSUAN_General_Error ; break; + case 258: n = ASSUAN_Accept_Failed ; break; + case 259: n = ASSUAN_Connect_Failed ; break; + case 260: n = ASSUAN_Invalid_Response ; break; + case 261: n = ASSUAN_Invalid_Value ; break; + case 262: n = ASSUAN_Line_Not_Terminated ; break; + case 263: n = ASSUAN_Line_Too_Long ; break; + case 264: n = ASSUAN_Nested_Commands ; break; + case 265: n = ASSUAN_No_Data_Callback ; break; + case 266: n = ASSUAN_No_Inquire_Callback ; break; + case 267: n = ASSUAN_Not_A_Server ; break; + case 69: n = ASSUAN_Not_Implemented ; break; + case 280: n = ASSUAN_Parameter_Conflict ; break; + case 269: n = ASSUAN_Problem_Starting_Server; break; + case 270: n = ASSUAN_Read_Error ; break; + case 271: n = ASSUAN_Write_Error ; break; + case 80: n = ASSUAN_Server_Fault ; break; + case 276: n = ASSUAN_Syntax_Error ; break; + case 273: n = ASSUAN_Too_Much_Data ; break; + case 274: n = ASSUAN_Unexpected_Command ; break; + case 275: n = ASSUAN_Unknown_Command ; break; + case 277: n = ASSUAN_Canceled ; break; + case ((1<<15)|86): n = ASSUAN_Out_Of_Core ; break; + default: n = 0; break; + } + if (n) + s = assuan_strerror (n); + else + { + sprintf (buf, "ec=%u.%u", source, code ); + s=buf; + } + } else - sprintf (buf, "ec=%d", err ); - s=buf; break; + { + sprintf (buf, "ec=%d", err ); + s=buf; + } } + break; } return s; } -EOF \ No newline at end of file +EOF Added: trunk/tests/Makefile.am =================================================================== --- trunk/tests/Makefile.am 2006-06-27 10:37:31 UTC (rev 195) +++ trunk/tests/Makefile.am 2006-09-06 16:36:45 UTC (rev 196) @@ -0,0 +1,37 @@ +# Makefile for Assuan regression tests +# Copyright (C) 2006 Free Software Foundation, Inc. +# +# This file is part of Assuan. +# +# 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 2.1 of +# the License, or (at your option) any later version. +# +# Assuan 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 +# 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, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1301, USA + +## Process this file with automake to produce Makefile.in + +TESTS_ENVIRONMENT = + +EXTRA_DIST = + +BUILT_SOURCES = +CLEANFILES = + +TESTS = fdpassing + +AM_CFLAGS = # $(GPG_ERROR_CFLAGS) + +noinst_HEADERS = common.h +noinst_PROGRAMS = $(TESTS) +LDADD = ../src/libassuan.a # $(GPG_ERROR_LIBS) + Added: trunk/tests/common.h =================================================================== --- trunk/tests/common.h 2006-06-27 10:37:31 UTC (rev 195) +++ trunk/tests/common.h 2006-09-06 16:36:45 UTC (rev 196) @@ -0,0 +1,149 @@ +/* common.h - Common functions for the tests. + * Copyright (C) 2006 Free Software Foundation, Inc. + * + * This file is part of Assuan. + * + * 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 2.1 of + * the License, or (at your option) any later version. + * + * Assuan 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 + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + */ + +#include + + +static const char *log_prefix; +static int errorcount; +static int verbose; +static int debug; + + +void * +xmalloc (size_t n) +{ + char *p = malloc (n); + if (!p) + { + fprintf (stderr, "out of core\n"); + exit (1); + } + return p; +} + +void * +xcalloc (size_t n, size_t m) +{ + char *p = calloc (n, m); + if (!p) + { + fprintf (stderr, "out of core\n"); + exit (1); + } + return p; +} + +void +xfree (void *a) +{ + if (a) + free (a); +} + + +void +log_set_prefix (const char *s) +{ + log_prefix = strrchr (s, '/'); + if (log_prefix) + log_prefix++; + else + log_prefix = s; +} + + +void +log_info (const char *format, ...) +{ + va_list arg_ptr ; + + if (!verbose) + return; + + va_start (arg_ptr, format) ; + if (log_prefix) + fprintf (stderr, "%s[%u]: ", log_prefix, (unsigned int)getpid ()); + vfprintf (stderr, format, arg_ptr ); + va_end (arg_ptr); +} + + +void +log_error (const char *format, ...) +{ + va_list arg_ptr ; + + va_start (arg_ptr, format) ; + if (log_prefix) + fprintf (stderr, "%s[%u]: ", log_prefix, (unsigned int)getpid ()); + vfprintf (stderr, format, arg_ptr ); + va_end (arg_ptr); + errorcount++; +} + + +void +log_fatal (const char *format, ...) +{ + va_list arg_ptr ; + + va_start (arg_ptr, format) ; + if (log_prefix) + fprintf (stderr, "%s[%u]: ", log_prefix, (unsigned int)getpid ()); + vfprintf (stderr, format, arg_ptr ); + va_end (arg_ptr); + exit (2); +} + + +void +log_printhex (const char *text, const void *buffer, size_t length) +{ + const unsigned char *s; + + if (log_prefix) + fprintf (stderr, "%s[%u]: ", log_prefix, (unsigned int)getpid ()); + fputs (text, stderr); + for (s=buffer; length; s++, length--) + fprintf (stderr, "%02X", *s); + putc ('\n', stderr); +} + + +/* Prepend FNAME with the srcdir environment variable's value and + return an allocated filename. */ +char * +prepend_srcdir (const char *fname) +{ + static const char *srcdir; + char *result; + + if (!srcdir && !(srcdir = getenv ("srcdir"))) + srcdir = "."; + + result = xmalloc (strlen (srcdir) + 1 + strlen (fname) + 1); + strcpy (result, srcdir); + strcat (result, "/"); + strcat (result, fname); + return result; +} + Added: trunk/tests/fdpassing.c =================================================================== --- trunk/tests/fdpassing.c 2006-06-27 10:37:31 UTC (rev 195) +++ trunk/tests/fdpassing.c 2006-09-06 16:36:45 UTC (rev 196) @@ -0,0 +1,213 @@ +/* fdpassing - Check the fiel descriptor passing. + * Copyright (C) 2006 Free Software Foundation, Inc. + * + * This file is part of Assuan. + * + * 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 2.1 of + * the License, or (at your option) any later version. + * + * Assuan 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 + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include /* Used by main driver. */ + +#include "../src/assuan.h" +#include "common.h" + + +/* + + S E R V E R + +*/ + +static int +cmd_echo (assuan_context_t ctx, char *line) +{ + log_info ("got ECHO command (%s)\n", line); + return 0; +} + +static assuan_error_t +register_commands (assuan_context_t ctx) +{ + static struct { + const char *name; + int (*handler)(assuan_context_t, char *line); + } table[] = { + { "ECHO", cmd_echo }, + { "INPUT", NULL }, + { "OUTPUT", NULL }, + { NULL } + }; + int i; + assuan_error_t rc; + + for (i=0; table[i].name; i++) + { + rc = assuan_register_command (ctx, table[i].name, table[i].handler); + if (rc) + return rc; + } + return 0; +} + + +static void +server (int fd) +{ + int rc; + assuan_context_t ctx; + + log_info ("server started on fd %d\n", fd); + + rc = assuan_init_domain_server (&ctx, fd, (pid_t)(-1)); + if (rc) + log_fatal ("assuan_init_domain_server failed: %s\n", assuan_strerror (rc)); + + rc = register_commands (ctx); + if (rc) + log_fatal ("register_commands failed: %s\n", assuan_strerror(rc)); + + assuan_set_assuan_log_prefix (log_prefix); + assuan_set_log_stream (ctx, stderr); + + for (;;) + { + rc = assuan_accept (ctx); + if (rc) + { + log_error ("assuan_accept failed: %s\n", assuan_strerror (rc)); + break; + } + + rc = assuan_process (ctx); + if (rc) + log_error ("assuan_process failed: %s\n", assuan_strerror (rc)); + } + + assuan_deinit_server (ctx); +} + + + + +/* + + C L I E N T + +*/ + + +/* Client main. If true is returned, a disconnect has not been done. */ +static int +client (int fd) +{ + int rc; + assuan_context_t ctx; + + log_info ("client started on fd %d\n", fd); + + rc = assuan_domain_connect (&ctx, fd, (pid_t)(-1)); + if (rc) + { + log_error ("assuan_domain_connect failed: %s\n", assuan_strerror (rc)); + return -1; + } + + + assuan_disconnect (ctx); + return 0; +} + + + + +/* + + M A I N + +*/ +int +main (int argc, char **argv) +{ + int last_argc = -1; + const char *srcdir = getenv ("srcdir"); + int fds[2]; + pid_t pid; + + if (!srcdir) + srcdir = "."; + + if (argc) + { + log_set_prefix (*argv); + argc--; argv++; + } + while (argc && last_argc != argc ) + { + last_argc = argc; + if (!strcmp (*argv, "--help")) + { + puts ( +"usage: ./fdpassing [options]\n" +"\n" +" Options are --verbose and --debug"); + exit (0); + } + if (!strcmp (*argv, "--verbose")) + { + verbose = 1; + argc--; argv++; + } + else if (!strcmp (*argv, "--debug")) + { + verbose = debug = 1; + argc--; argv++; + } + } + + /* Create a socketpair. */ + if ( socketpair (AF_LOCAL, SOCK_STREAM, 0, fds) ) + log_fatal ("socketpair failed: %s\n", strerror (errno)); + + /* Fork and run server and client. */ + pid = fork (); + if (pid == (pid_t)(-1)) + log_fatal ("fork failed: %s\n", strerror (errno)); + if (!pid) + { + server (fds[0]); /* The child is our server. */ + log_info ("server finished\n"); + } + else + { + if (client (fds[1])) /* The parent is the client. */ + { + log_info ("waiting for server to terminate...\n"); + waitpid (pid, NULL, 0); + } + log_info ("client finished\n"); + } + + return errorcount? 1:0; +} + From cvs at cvs.gnupg.org Wed Sep 6 18:37:17 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed Sep 6 17:53:06 2006 Subject: [svn] gpg-error - r177 - in trunk: . src Message-ID: Author: wk Date: 2006-09-06 18:37:17 +0200 (Wed, 06 Sep 2006) New Revision: 177 Modified: trunk/ChangeLog trunk/NEWS trunk/src/err-codes.h.in Log: Minor tweaks of yesterday's changes. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-09-05 19:17:14 UTC (rev 176) +++ trunk/ChangeLog 2006-09-06 16:37:17 UTC (rev 177) @@ -1,3 +1,8 @@ +2006-09-06 Werner Koch + + * src/err-codes.h.in: Add GPG_ERR_UNKNOWN_OPTION and + GPG_ERR_UNKNOWN_COMMAND. + 2006-09-05 Werner Koch * src/err-sources.h.in (GPG_ERR_SOURCE_ANY): New. This is so that Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-09-05 19:17:14 UTC (rev 176) +++ trunk/NEWS 2006-09-06 16:37:17 UTC (rev 177) @@ -16,6 +16,8 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GPG_ERR_SOURCE_ANY NEW GPG_ERR_MISSING_ERRNO NEW + GPG_ERR_UNKNOWN_OPTION NEW + GPG_ERR_UNKNOWN_COMMAND NEW GPG_ERR_ASS_GENERAL NEW GPG_ERR_ASS_ACCEPT_FAILED NEW GPG_ERR_ASS_CONNECT_FAILED NEW @@ -31,7 +33,6 @@ GPG_ERR_ASS_SERVER_START NEW GPG_ERR_ASS_READ_ERROR NEW GPG_ERR_ASS_WRITE_ERROR NEW - GPG_ERR_ASS_SERVER_FAULT NEW GPG_ERR_ASS_TOO_MUCH_DATA NEW GPG_ERR_ASS_UNEXPECTED_CMD NEW GPG_ERR_ASS_UNKNOWN_CMD NEW Modified: trunk/src/err-codes.h.in =================================================================== --- trunk/src/err-codes.h.in 2006-09-05 19:17:14 UTC (rev 176) +++ trunk/src/err-codes.h.in 2006-09-06 16:37:17 UTC (rev 177) @@ -109,8 +109,8 @@ 77 GPG_ERR_NO_AGENT No agent running 78 GPG_ERR_AGENT agent error 79 GPG_ERR_INV_DATA Invalid data -80 GPG_ERR_ASSUAN_SERVER_FAULT Assuan server fault -81 GPG_ERR_ASSUAN Assuan error +80 GPG_ERR_ASSUAN_SERVER_FAULT Unspecific Assuan server fault +81 GPG_ERR_ASSUAN General Assuan error 82 GPG_ERR_INV_SESSION_KEY Invalid session key 83 GPG_ERR_INV_SEXP Invalid S-expression 84 GPG_ERR_UNSUPPORTED_ALGORITHM Unsupported algorithm @@ -203,7 +203,9 @@ 171 GPG_ERR_UNKNOWN_EXTN Unknown extension 172 GPG_ERR_UNKNOWN_CRIT_EXTN Unknown critical extension 173 GPG_ERR_LOCKED Locked -# 174 to 199 are free to be used. +174 GPG_ERR_UNKNOWN_OPTION Unknown option +175 GPG_ERR_UNKNOWN_COMMAND Unknown command +# 176 to 199 are free to be used. 200 GPG_ERR_BUFFER_TOO_SHORT Buffer too short @@ -241,7 +243,7 @@ 269 GPG_ERR_ASS_SERVER_START Problem starting IPC server 270 GPG_ERR_ASS_READ_ERROR IPC read error 271 GPG_ERR_ASS_WRITE_ERROR IPC write error -272 GPG_ERR_ASS_SERVER_FAULT IPC server fault +# reserved 273 GPG_ERR_ASS_TOO_MUCH_DATA Too much data for IPC layer 274 GPG_ERR_ASS_UNEXPECTED_CMD Unexpected IPC command 275 GPG_ERR_ASS_UNKNOWN_CMD Unknown IPC command From cvs at cvs.gnupg.org Wed Sep 6 22:57:57 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Wed Sep 6 22:13:48 2006 Subject: [svn] GnuPG - r4241 - trunk/agent Message-ID: Author: marcus Date: 2006-09-06 22:57:57 +0200 (Wed, 06 Sep 2006) New Revision: 4241 Modified: trunk/agent/ChangeLog trunk/agent/Makefile.am Log: 2006-09-06 Marcus Brinkmann * Makefile.am (AM_CFLAGS): Add $(GPG_ERR_CFLAGS). (gpg_agent_LDADD): Replace -lgpg-error with $(GPG_ERROR_LIBS). Modified: trunk/agent/ChangeLog =================================================================== --- trunk/agent/ChangeLog 2006-09-06 16:35:52 UTC (rev 4240) +++ trunk/agent/ChangeLog 2006-09-06 20:57:57 UTC (rev 4241) @@ -1,3 +1,8 @@ +2006-09-06 Marcus Brinkmann + + * Makefile.am (AM_CFLAGS): Add $(GPG_ERR_CFLAGS). + (gpg_agent_LDADD): Replace -lgpg-error with $(GPG_ERROR_LIBS). + 2006-09-06 Werner Koch * query.c: Renamed to .. Modified: trunk/agent/Makefile.am =================================================================== --- trunk/agent/Makefile.am 2006-09-06 16:35:52 UTC (rev 4240) +++ trunk/agent/Makefile.am 2006-09-06 20:57:57 UTC (rev 4241) @@ -27,7 +27,8 @@ include $(top_srcdir)/am/cmacros.am -AM_CFLAGS = $(LIBGCRYPT_CFLAGS) $(LIBASSUAN_CFLAGS) $(PTH_CFLAGS) +AM_CFLAGS = $(LIBGCRYPT_CFLAGS) $(LIBASSUAN_CFLAGS) $(GPG_ERROR_CFLAGS) \ + $(PTH_CFLAGS) gpg_agent_SOURCES = \ gpg-agent.c agent.h \ @@ -48,7 +49,7 @@ gpg_agent_LDADD = ../jnlib/libjnlib.a ../common/libcommon.a ../gl/libgnu.a \ $(LIBGCRYPT_LIBS) $(PTH_LIBS) $(LIBASSUAN_LIBS) \ - -lgpg-error @LIBINTL@ $(NETLIBS) + $(GPG_ERROR_LIBS) @LIBINTL@ $(NETLIBS) gpg_protect_tool_SOURCES = \ protect-tool.c \ From cvs at cvs.gnupg.org Wed Sep 6 23:09:37 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Wed Sep 6 22:25:26 2006 Subject: [svn] GnuPG - r4242 - in trunk: . tests Message-ID: Author: marcus Date: 2006-09-06 23:09:36 +0200 (Wed, 06 Sep 2006) New Revision: 4242 Modified: trunk/ChangeLog trunk/configure.ac trunk/tests/ChangeLog trunk/tests/Makefile.am Log: 2006-09-06 Marcus Brinkmann * configure.ac: New automake conditional RUN_GPG_TESTS. tests/ 2006-09-06 Marcus Brinkmann * Makefile.am (openpgp): New variable. (SUBDIRS): Conditionalize openpgp on RUN_GPG_TESTS. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-09-06 20:57:57 UTC (rev 4241) +++ trunk/ChangeLog 2006-09-06 21:09:36 UTC (rev 4242) @@ -1,3 +1,7 @@ +2006-09-06 Marcus Brinkmann + + * configure.ac: New automake conditional RUN_GPG_TESTS. + 2006-09-06 Werner Koch * configure.ac: Define _ASSUAN_ONLY_GPG_ERRORS. Require Assuan Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-09-06 20:57:57 UTC (rev 4241) +++ trunk/configure.ac 2006-09-06 21:09:36 UTC (rev 4242) @@ -1232,6 +1232,8 @@ AM_CONDITIONAL(BUILD_SCDAEMON, test "$build_scdaemon" = "yes") AM_CONDITIONAL(BUILD_SYMCRYPTRUN, test "$build_symcryptrun" = "yes") +AM_CONDITIONAL(RUN_GPG_TESTS, + test x$cross_compiling = xno -a "$build_gpg" = yes ) # Modified: trunk/tests/ChangeLog =================================================================== --- trunk/tests/ChangeLog 2006-09-06 20:57:57 UTC (rev 4241) +++ trunk/tests/ChangeLog 2006-09-06 21:09:36 UTC (rev 4242) @@ -1,3 +1,8 @@ +2006-09-06 Marcus Brinkmann + + * Makefile.am (openpgp): New variable. + (SUBDIRS): Conditionalize openpgp on RUN_GPG_TESTS. + 2006-08-21 Werner Koch * Makefile.am (SUBDIRS): New. Modified: trunk/tests/Makefile.am =================================================================== --- trunk/tests/Makefile.am 2006-09-06 20:57:57 UTC (rev 4241) +++ trunk/tests/Makefile.am 2006-09-06 21:09:36 UTC (rev 4242) @@ -29,8 +29,14 @@ # #SUBDIRS = . ${pkits} -SUBDIRS = openpgp +if RUN_GPG_TESTS +openpgp = openpgp +else +openpgp = +endif +SUBDIRS = ${openpgp} + GPGSM = ../sm/gpgsm From cvs at cvs.gnupg.org Wed Sep 6 23:41:15 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Wed Sep 6 22:57:06 2006 Subject: [svn] GnuPG - r4243 - trunk/g10 Message-ID: Author: marcus Date: 2006-09-06 23:41:14 +0200 (Wed, 06 Sep 2006) New Revision: 4243 Modified: trunk/g10/ChangeLog trunk/g10/Makefile.am Log: 2006-09-06 Marcus Brinkmann * Makefile.am (gpg2_LDADD, gpgv2_LDADD): Replace -lassuan and -lgpg-error with $(LIBASSUAN_LIBS) and $(GPG_ERROR_LIBS). (AM_CFLAGS): Add $(LIBASSUAN_CFLAGS) and $(GPG_ERROR_CFLAGS). Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2006-09-06 21:09:36 UTC (rev 4242) +++ trunk/g10/ChangeLog 2006-09-06 21:41:14 UTC (rev 4243) @@ -1,3 +1,9 @@ +2006-09-06 Marcus Brinkmann + + * Makefile.am (gpg2_LDADD, gpgv2_LDADD): Replace -lassuan and + -lgpg-error with $(LIBASSUAN_LIBS) and $(GPG_ERROR_LIBS). + (AM_CFLAGS): Add $(LIBASSUAN_CFLAGS) and $(GPG_ERROR_CFLAGS). + 2006-09-06 Werner Koch * gpg.c (main): Enable new assuan API. Modified: trunk/g10/Makefile.am =================================================================== --- trunk/g10/Makefile.am 2006-09-06 21:09:36 UTC (rev 4242) +++ trunk/g10/Makefile.am 2006-09-06 21:41:14 UTC (rev 4243) @@ -27,7 +27,7 @@ include $(top_srcdir)/am/cmacros.am -AM_CFLAGS = $(LIBGCRYPT_CFLAGS) +AM_CFLAGS = $(LIBGCRYPT_CFLAGS) $(LIBASSUAN_CFLAGS) $(GPG_ERROR_CFLAGS) needed_libs = ../gl/libgnu.a ../common/libcommon.a ../jnlib/libjnlib.a @@ -110,8 +110,8 @@ LDADD = $(needed_libs) $(ZLIBS) $(DNSLIBS) $(LIBREADLINE) \ $(LIBINTL) $(CAPLIBS) $(W32LIBS) -gpg2_LDADD = $(LIBGCRYPT_LIBS) $(LDADD) -lassuan -lgpg-error -gpgv2_LDADD = $(LIBGCRYPT_LIBS) $(LDADD) -lassuan -lgpg-error +gpg2_LDADD = $(LIBGCRYPT_LIBS) $(LDADD) $(LIBASSUAN_LIBS) $(GPG_ERROR_LIBS) +gpgv2_LDADD = $(LIBGCRYPT_LIBS) $(LDADD) $(LIBASSUAN_LIBS) $(GPG_ERROR_LIBS) $(PROGRAMS): $(needed_libs) From cvs at cvs.gnupg.org Wed Sep 6 23:43:45 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Wed Sep 6 22:59:35 2006 Subject: [svn] GnuPG - r4244 - trunk/keyserver Message-ID: Author: marcus Date: 2006-09-06 23:43:44 +0200 (Wed, 06 Sep 2006) New Revision: 4244 Modified: trunk/keyserver/ChangeLog trunk/keyserver/Makefile.am Log: 2006-09-06 Marcus Brinkmann * Makefile.am (gpg2_LDADD, gpgv2_LDADD): Replace -lassuan and -lgpg-error with $(LIBASSUAN_LIBS) and $(GPG_ERROR_LIBS). (AM_CFLAGS): Add $(LIBASSUAN_CFLAGS) and $(GPG_ERROR_CFLAGS). 2006-09-06 Marcus Brinkmann * Makefile.am (AM_CFLAGS): Add $(GPG_ERROR_CFLAGS). Modified: trunk/keyserver/ChangeLog =================================================================== --- trunk/keyserver/ChangeLog 2006-09-06 21:41:14 UTC (rev 4243) +++ trunk/keyserver/ChangeLog 2006-09-06 21:43:44 UTC (rev 4244) @@ -1,3 +1,7 @@ +2006-09-06 Marcus Brinkmann + + * Makefile.am (AM_CFLAGS): Add $(GPG_ERROR_CFLAGS). + 2006-08-16 Werner Koch * Makefile.am: Renamed all binaries to gpg2keys_*. Modified: trunk/keyserver/Makefile.am =================================================================== --- trunk/keyserver/Makefile.am 2006-09-06 21:41:14 UTC (rev 4243) +++ trunk/keyserver/Makefile.am 2006-09-06 21:43:44 UTC (rev 4244) @@ -23,7 +23,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/gl -I$(top_srcdir)/common -I$(top_srcdir)/intl -AM_CFLAGS = $(LIBGCRYPT_CFLAGS) +AM_CFLAGS = $(LIBGCRYPT_CFLAGS) $(GPG_ERROR_CFLAGS) include $(top_srcdir)/am/cmacros.am From cvs at cvs.gnupg.org Thu Sep 7 08:42:55 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu Sep 7 07:58:46 2006 Subject: [svn] GnuPG - r4245 - trunk/g10 Message-ID: Author: wk Date: 2006-09-07 08:42:55 +0200 (Thu, 07 Sep 2006) New Revision: 4245 Added: trunk/g10/compress-bz2.c Log: Added missing file Added: trunk/g10/compress-bz2.c =================================================================== --- trunk/g10/compress-bz2.c 2006-09-06 21:43:44 UTC (rev 4244) +++ trunk/g10/compress-bz2.c 2006-09-07 06:42:55 UTC (rev 4245) @@ -0,0 +1,243 @@ +/* compress.c - bzip2 compress filter + * Copyright (C) 2003, 2004 Free Software Foundation, Inc. + * + * This file is part of GnuPG. + * + * GnuPG 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. + * + * GnuPG 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + */ + +#include +#include +#include /* Early versions of bzlib (1.0) require stdio.h */ +#include + +#include "gpg.h" +#include "util.h" +#include "packet.h" +#include "filter.h" +#include "main.h" +#include "options.h" + +/* Note that the code in compress.c is nearly identical to the code + here, so if you fix a bug here, look there to see if a matching bug + needs to be fixed. I tried to have one set of functions that could + do ZIP, ZLIB, and BZIP2, but it became dangerously unreadable with + #ifdefs and if(algo) -dshaw */ + +static void +init_compress( compress_filter_context_t *zfx, bz_stream *bzs ) +{ + int rc; + int level; + + if( opt.bz2_compress_level >= 1 && opt.bz2_compress_level <= 9 ) + level = opt.bz2_compress_level; + else if( opt.bz2_compress_level == -1 ) + level = 6; /* no particular reason, but it seems reasonable */ + else + { + log_error("invalid compression level; using default level\n"); + level = 6; + } + + if((rc=BZ2_bzCompressInit(bzs,level,0,0))!=BZ_OK) + log_fatal("bz2lib problem: %d\n",rc); + + zfx->outbufsize = 8192; + zfx->outbuf = xmalloc( zfx->outbufsize ); +} + +static int +do_compress(compress_filter_context_t *zfx, bz_stream *bzs, int flush, IOBUF a) +{ + int rc; + int zrc; + unsigned n; + + do + { + bzs->next_out = zfx->outbuf; + bzs->avail_out = zfx->outbufsize; + if( DBG_FILTER ) + log_debug("enter bzCompress: avail_in=%u, avail_out=%u, flush=%d\n", + (unsigned)bzs->avail_in, (unsigned)bzs->avail_out, flush ); + zrc = BZ2_bzCompress( bzs, flush ); + if( zrc == BZ_STREAM_END && flush == BZ_FINISH ) + ; + else if( zrc != BZ_RUN_OK && zrc != BZ_FINISH_OK ) + log_fatal("bz2lib deflate problem: rc=%d\n", zrc ); + + n = zfx->outbufsize - bzs->avail_out; + if( DBG_FILTER ) + log_debug("leave bzCompress:" + " avail_in=%u, avail_out=%u, n=%u, zrc=%d\n", + (unsigned)bzs->avail_in, (unsigned)bzs->avail_out, + (unsigned)n, zrc ); + + if( (rc=iobuf_write( a, zfx->outbuf, n )) ) + { + log_debug("bzCompress: iobuf_write failed\n"); + return rc; + } + } + while( bzs->avail_in || (flush == BZ_FINISH && zrc != BZ_STREAM_END) ); + + return 0; +} + +static void +init_uncompress( compress_filter_context_t *zfx, bz_stream *bzs ) +{ + int rc; + + if((rc=BZ2_bzDecompressInit(bzs,0,opt.bz2_decompress_lowmem))!=BZ_OK) + log_fatal("bz2lib problem: %d\n",rc); + + zfx->inbufsize = 2048; + zfx->inbuf = xmalloc( zfx->inbufsize ); + bzs->avail_in = 0; +} + +static int +do_uncompress( compress_filter_context_t *zfx, bz_stream *bzs, + IOBUF a, size_t *ret_len ) +{ + int zrc; + int rc=0; + size_t n; + int nread, count; + int refill = !bzs->avail_in; + + if( DBG_FILTER ) + log_debug("begin bzDecompress: avail_in=%u, avail_out=%u, inbuf=%u\n", + (unsigned)bzs->avail_in, (unsigned)bzs->avail_out, + (unsigned)zfx->inbufsize ); + do + { + if( bzs->avail_in < zfx->inbufsize && refill ) + { + n = bzs->avail_in; + if( !n ) + bzs->next_in = zfx->inbuf; + count = zfx->inbufsize - n; + nread = iobuf_read( a, zfx->inbuf + n, count ); + if( nread == -1 ) nread = 0; + n += nread; + bzs->avail_in = n; + } + + refill = 1; + + if( DBG_FILTER ) + log_debug("enter bzDecompress: avail_in=%u, avail_out=%u\n", + (unsigned)bzs->avail_in, (unsigned)bzs->avail_out); + + zrc=BZ2_bzDecompress(bzs); + if( DBG_FILTER ) + log_debug("leave bzDecompress: avail_in=%u, avail_out=%u, zrc=%d\n", + (unsigned)bzs->avail_in, (unsigned)bzs->avail_out, zrc); + if( zrc == BZ_STREAM_END ) + rc = -1; /* eof */ + else if( zrc != BZ_OK && zrc != BZ_PARAM_ERROR ) + log_fatal("bz2lib inflate problem: rc=%d\n", zrc ); + } + while( bzs->avail_out && zrc != BZ_STREAM_END && zrc != BZ_PARAM_ERROR ); + + /* I'm not completely happy with the two uses of BZ_PARAM_ERROR + here. The corresponding zlib function is Z_BUF_ERROR, which + covers a narrower scope than BZ_PARAM_ERROR. -dshaw */ + + *ret_len = zfx->outbufsize - bzs->avail_out; + if( DBG_FILTER ) + log_debug("do_uncompress: returning %u bytes\n", (unsigned)*ret_len ); + return rc; +} + +int +compress_filter_bz2( void *opaque, int control, + IOBUF a, byte *buf, size_t *ret_len) +{ + size_t size = *ret_len; + compress_filter_context_t *zfx = opaque; + bz_stream *bzs = zfx->opaque; + int rc=0; + + if( control == IOBUFCTRL_UNDERFLOW ) + { + if( !zfx->status ) + { + bzs = zfx->opaque = xmalloc_clear( sizeof *bzs ); + init_uncompress( zfx, bzs ); + zfx->status = 1; + } + + bzs->next_out = buf; + bzs->avail_out = size; + zfx->outbufsize = size; /* needed only for calculation */ + rc = do_uncompress( zfx, bzs, a, ret_len ); + } + else if( control == IOBUFCTRL_FLUSH ) + { + if( !zfx->status ) + { + PACKET pkt; + PKT_compressed cd; + + if( zfx->algo != COMPRESS_ALGO_BZIP2 ) + BUG(); + memset( &cd, 0, sizeof cd ); + cd.len = 0; + cd.algorithm = zfx->algo; + init_packet( &pkt ); + pkt.pkttype = PKT_COMPRESSED; + pkt.pkt.compressed = &cd; + if( build_packet( a, &pkt )) + log_bug("build_packet(PKT_COMPRESSED) failed\n"); + bzs = zfx->opaque = xmalloc_clear( sizeof *bzs ); + init_compress( zfx, bzs ); + zfx->status = 2; + } + + bzs->next_in = buf; + bzs->avail_in = size; + rc = do_compress( zfx, bzs, BZ_RUN, a ); + } + else if( control == IOBUFCTRL_FREE ) + { + if( zfx->status == 1 ) + { + BZ2_bzDecompressEnd(bzs); + xfree(bzs); + zfx->opaque = NULL; + xfree(zfx->outbuf); zfx->outbuf = NULL; + } + else if( zfx->status == 2 ) + { + bzs->next_in = buf; + bzs->avail_in = 0; + do_compress( zfx, bzs, BZ_FINISH, a ); + BZ2_bzCompressEnd(bzs); + xfree(bzs); + zfx->opaque = NULL; + xfree(zfx->outbuf); zfx->outbuf = NULL; + } + if (zfx->release) + zfx->release (zfx); + } + else if( control == IOBUFCTRL_DESC ) + *(char**)buf = "compress_filter"; + return rc; +} From cvs at cvs.gnupg.org Thu Sep 7 17:13:35 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu Sep 7 16:29:26 2006 Subject: [svn] GnuPG - r4246 - in trunk: . agent common doc doc/examples scd Message-ID: Author: wk Date: 2006-09-07 17:13:33 +0200 (Thu, 07 Sep 2006) New Revision: 4246 Added: trunk/doc/examples/ trunk/doc/examples/scd-event Modified: trunk/NEWS trunk/TODO trunk/agent/call-scd.c trunk/common/ChangeLog trunk/common/exechelp.c trunk/common/exechelp.h trunk/doc/ChangeLog trunk/doc/Makefile.am trunk/doc/scdaemon.texi trunk/scd/ChangeLog trunk/scd/command.c Log: Let scdaemon call a script on status changes Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-09-07 06:42:55 UTC (rev 4245) +++ trunk/NEWS 2006-09-07 15:13:33 UTC (rev 4246) @@ -12,7 +12,9 @@ * API change in gpg-agent's pkdecrypt command. Thus an older gpgsm may not be used with the current gpg-agent. + * The scdaemon will now call a script on reader status changes. + Noteworthy changes in version 1.9.22 (2006-07-27) ------------------------------------------------- Modified: trunk/TODO =================================================================== --- trunk/TODO 2006-09-07 06:42:55 UTC (rev 4245) +++ trunk/TODO 2006-09-07 15:13:33 UTC (rev 4246) @@ -80,10 +80,7 @@ * doc/ ** Explain how to setup a root CA key as trusted ** Explain how trustlist.txt might be managed. -** Write a script to generate man pages from texi. - In progress (yatm) - * Windows port ** gpgsm's LISTKEYS does not yet work Fix is to change everything to libestream @@ -91,8 +88,6 @@ This means we can't reread a configuration ** No card status notifications. - - * sm/ ** check that we issue NO_SECKEY xxx if a -u key was not found We don't. The messages retruned are also wrong (recipient vs. signer). Modified: trunk/agent/call-scd.c =================================================================== --- trunk/agent/call-scd.c 2006-09-07 06:42:55 UTC (rev 4245) +++ trunk/agent/call-scd.c 2006-09-07 15:13:33 UTC (rev 4246) @@ -193,7 +193,7 @@ /* Fork off the SCdaemon if this has not already been done. Lock the daemon and make sure that a proper context has been setup in CTRL. - Thsi fucntion might also lock the daemon, which means that the + This function might also lock the daemon, which means that the caller must call unlock_scd after this fucntion has returned success and the actual Assuan transaction been done. */ static int Modified: trunk/common/ChangeLog =================================================================== --- trunk/common/ChangeLog 2006-09-07 06:42:55 UTC (rev 4245) +++ trunk/common/ChangeLog 2006-09-07 15:13:33 UTC (rev 4246) @@ -1,3 +1,10 @@ +2006-09-07 Werner Koch + + * exechelp.c (gnupg_spawn_process): Factor out post fork code to .. + (do_exec): .. new function. Allow passing of -1 for the fds. + (gnupg_spawn_process): Terminate gcrypt's secure memory in the child. + (gnupg_spawn_process_detached): New. + 2006-09-06 Werner Koch * maperror.c: Removed. Modified: trunk/common/exechelp.c =================================================================== --- trunk/common/exechelp.c 2006-09-07 06:42:55 UTC (rev 4245) +++ trunk/common/exechelp.c 2006-09-07 15:13:33 UTC (rev 4246) @@ -28,6 +28,7 @@ #include #include #include +#include #ifdef USE_GNU_PTH #include #endif @@ -159,7 +160,68 @@ #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, const char *argv[], + int fd_in, int fd_out, int fd_err, + void (*preexec)(void) ) +{ + 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; + + if (preexec) + preexec (); + 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 @@ -325,47 +387,10 @@ if (!*pid) { - /* Child. */ - char **arg_list; - int n, i, j; - - /* Create the command line argument array. */ - for (i=0; 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); - for (i=0,j=1; argv[i]; i++, j++) - arg_list[j] = (char*)argv[i]; - - /* Connect the infile to stdin. */ - if (fd != 0 && dup2 (fd, 0) == -1) - log_fatal ("dup2 stdin failed: %s\n", strerror (errno)); - - /* Connect the outfile to stdout. */ - if (fdout != 1 && dup2 (fdout, 1) == -1) - log_fatal ("dup2 stdout failed: %s\n", strerror (errno)); - - /* Connect stderr to our pipe. */ - if (rp[1] != 2 && dup2 (rp[1], 2) == -1) - log_fatal ("dup2 stderr failed: %s\n", 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; - - if (preexec) - preexec (); - execv (pgmname, arg_list); - /* No way to print anything, as we have closed all streams. */ - _exit (127); + gcry_control (GCRYCTL_TERM_SECMEM); + /* Run child. */ + do_exec (pgmname, argv, fd, fdout, rp[1], preexec); + /*NOTREACHED*/ } /* Parent. */ @@ -481,3 +506,64 @@ } + +/* Spawn a new process and immediatley detach from it. The name of + the program to exec is PGMNAME and its arguments are in ARGV (the + programname is automatically passed as first argument). + Environment strings in ENVP are set. An error is returned if + pgmname is not executable; to make this work it is necessary to + provide an absolute file name. All standard file descriptors are + connected to /dev/null. */ +gpg_error_t +gnupg_spawn_process_detached (const char *pgmname, const char *argv[], + const char *envp[] ) +{ +#ifdef HAVE_W32_SYSTEM + return gpg_error (GPG_ERR_NOT_IMPLEMENTED); +#else + pid_t pid; + int i; + + if (getuid() != geteuid()) + return gpg_error (GPG_ERR_BUG); + + if (access (pgmname, X_OK)) + return gpg_error_from_errno (errno); + +#ifdef USE_GNU_PTH + pid = pth_fork? pth_fork () : fork (); +#else + pid = fork (); +#endif + if (pid == (pid_t)(-1)) + { + log_error (_("error forking process: %s\n"), strerror (errno)); + return gpg_error_from_errno (errno); + } + if (!pid) + { + gcry_control (GCRYCTL_TERM_SECMEM); + if (setsid() == -1 || chdir ("/")) + _exit (1); + pid = fork (); /* Double fork to let init takes over the new child. */ + if (pid == (pid_t)(-1)) + _exit (1); + if (pid) + _exit (0); /* Let the parent exit immediately. */ + + if (envp) + for (i=0; envp[i]; i++) + putenv (xstrdup (envp[i])); + + do_exec (pgmname, argv, -1, -1, -1, NULL); + + /*NOTREACHED*/ + } + + if (waitpid (pid, NULL, 0) == -1) + log_error ("waitpid failed in gnupg_spawn_process_detached: %s", + strerror (errno)); + + return 0; +#endif /* !HAVE_W32_SYSTEM*/ +} Modified: trunk/common/exechelp.h =================================================================== --- trunk/common/exechelp.h 2006-09-07 06:42:55 UTC (rev 4245) +++ trunk/common/exechelp.h 2006-09-07 15:13:33 UTC (rev 4246) @@ -43,4 +43,16 @@ gpg_error_t gnupg_wait_process (const char *pgmname, pid_t pid); +/* Spawn a new process and immediatley detach from it. The name of + the program to exec is PGMNAME and its arguments are in ARGV (the + programname is automatically passed as first argument). + Environment strings in ENVP are set. An error is returned if + pgmname is not executable; to make this work it is necessary to + provide an absolute file name. */ +gpg_error_t gnupg_spawn_process_detached (const char *pgmname, + const char *argv[], + const char *envp[] ); + + + #endif /*GNUPG_COMMON_EXECHELP_H*/ Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2006-09-07 06:42:55 UTC (rev 4245) +++ trunk/doc/ChangeLog 2006-09-07 15:13:33 UTC (rev 4246) @@ -1,3 +1,10 @@ +2006-09-07 Werner Koch + + * scdaemon.texi (Scdaemon Configuration): New. + + * examples/scd-event: Event handler for sdaemon. + * examples/: New directory + 2006-08-22 Werner Koch * yat2m.c (parse_file): Added code to skip a line after @mansect. Modified: trunk/doc/Makefile.am =================================================================== --- trunk/doc/Makefile.am 2006-09-07 06:42:55 UTC (rev 4245) +++ trunk/doc/Makefile.am 2006-09-07 15:13:33 UTC (rev 4246) @@ -19,13 +19,16 @@ ## Process this file with automake to produce Makefile.in +examples=examples/scd-event + EXTRA_DIST = DETAILS HACKING TRANSLATE OpenPGP KEYSERVER samplekeys.asc \ gnupg-badge-openpgp.eps gnupg-badge-openpgp.jpg \ gnupg-badge-openpgp.pdf \ gnupg-card-architecture.eps gnupg-card-architecture.png \ gnupg-card-architecture.pdf \ faq.raw FAQ faq.html gnupg7.texi \ - opt-homedir.texi see-also-note.texi + opt-homedir.texi see-also-note.texi \ + $(examples) BUILT_SOURCES = gnupg-card-architecture.eps gnupg-card-architecture.png \ gnupg-card-architecture.pdf FAQ faq.html Added: trunk/doc/examples/scd-event =================================================================== --- trunk/doc/examples/scd-event 2006-09-07 06:42:55 UTC (rev 4245) +++ trunk/doc/examples/scd-event 2006-09-07 15:13:33 UTC (rev 4246) @@ -0,0 +1,102 @@ +#!/bin/sh +# Sample script for scdaemon event mechanism. + +#exec >>/tmp/scd-event.log + +PGM=scd-event + +reader_port= +old_code=0x0000 +new_code=0x0000 +status= + +tick='`' +prev= +while [ $# -gt 0 ]; do + arg="$1" + case $arg in + -*=*) optarg=$(echo "X$arg" | sed -e '1s/^X//' -e 's/[-_a-zA-Z0-9]*=//') + ;; + *) optarg= + ;; + esac + if [ -n "$prev" ]; then + eval "$prev=\$arg" + prev= + shift + continue + fi + case $arg in + --help|-h) + cat <&2 + exit 1 + ;; + + *) + break + ;; + esac + shift +done +if [ -n "$prev" ]; then + echo "$PGM: argument missing for option $tick$prev'" >&2 + exit 1 +fi + +cat <&1 +fi + Property changes on: trunk/doc/examples/scd-event ___________________________________________________________________ Name: svn:executable + * Modified: trunk/doc/scdaemon.texi =================================================================== --- trunk/doc/scdaemon.texi 2006-09-07 06:42:55 UTC (rev 4245) +++ trunk/doc/scdaemon.texi 2006-09-07 15:13:33 UTC (rev 4246) @@ -48,6 +48,7 @@ * Scdaemon Commands:: List of all commands. * Scdaemon Options:: List of all options. * Card applications:: Description of card applications. +* Scdaemon Configuration:: Configuration files. * Scdaemon Examples:: Some usage examples. * Scdaemon Protocol:: The protocol the daemon uses. @end menu @@ -320,7 +321,42 @@ @command{gpgsm}. +@c ******************************************* +@c *************** **************** +@c *************** FILES **************** +@c *************** **************** +@c ******************************************* +@mansect files +@node Scdaemon Configuration +@section Configuration files +There are a few configuration files to control certain aspects of +@command{scdaemons}'s operation. Unless noted, they are expected in the +current home directory (@pxref{option --homedir}). + +@table @file + +@item scdaemon.conf +@cindex scdaemon.conf +This is the standard configuration file read by @command{scdaemon} on +startup. It may contain any valid long option; the leading two dashes +may not be entered and the option may not be abbreviated. This default +name may be changed on the command line (@pxref{option --options}). + +@item scd-event +@cindex scd-event +If this file is present and executable, it will be called on veyer card +reader's status changed. An example of this script is provided with the +distribution + +@item reader_@var{n}.status +This file is created by @command{sdaemon} to let other applications now +about reader status changes. Its use is now deprecated in favor of +@file{scd-event}. + +@end table + + @c @c Examples @c @@ -339,7 +375,7 @@ @c @c Assuan Protocol @c -@mansect assuan +@manpause @node Scdaemon Protocol @section Scdaemon's Assuan Protocol @@ -621,3 +657,11 @@ +@mansect see also +@ifset isman +@command{gpg-agent}(1), +@command{gpgsm}(1), +@command{gpg2}(1) +@end ifset +@include see-also-note.texi + Modified: trunk/scd/ChangeLog =================================================================== --- trunk/scd/ChangeLog 2006-09-07 06:42:55 UTC (rev 4245) +++ trunk/scd/ChangeLog 2006-09-07 15:13:33 UTC (rev 4246) @@ -1,3 +1,8 @@ +2006-09-07 Werner Koch + + * command.c (update_reader_status_file): Execute an event handler + if available. + 2006-09-06 Werner Koch * apdu.c (pcsc_end_transaction): Modified: trunk/scd/command.c =================================================================== --- trunk/scd/command.c 2006-09-07 06:42:55 UTC (rev 4245) +++ trunk/scd/command.c 2006-09-07 15:13:33 UTC (rev 4246) @@ -37,6 +37,7 @@ #include #include "app-common.h" #include "apdu.h" /* Required for apdu_*_reader (). */ +#include "exechelp.h" /* Maximum length allowed as a PIN; used for INQUIRE NEEDPIN */ #define MAXLEN_PIN 100 @@ -1778,6 +1779,47 @@ } xfree (fname); + /* If a status script is executable, run it. */ + { + const char *args[9], *envs[2]; + char numbuf1[30], numbuf2[3], numbuf3[30]; + char *homestr, *envstr; + gpg_error_t err; + + homestr = make_filename (opt.homedir, NULL); + if (asprintf (&envstr, "GNUPGHOME=%s", homestr) < 0) + log_error ("out of core while building environment\n"); + else + { + envs[0] = envstr; + envs[1] = NULL; + + sprintf (numbuf1, "%d", ss->slot); + sprintf (numbuf2, "0x%04X", ss->status); + sprintf (numbuf3, "0x%04X", status); + args[0] = "--reader-port"; + args[1] = numbuf1; + args[2] = "--old-code"; + args[3] = numbuf2; + args[4] = "--new-code"; + args[5] = numbuf3; + args[6] = "--status"; + args[7] = ((status & 1)? "USABLE": + (status & 4)? "ACTIVE": + (status & 2)? "PRESENT": "NOCARD"); + args[8] = NULL; + + fname = make_filename (opt.homedir, "scd-event", NULL); + err = gnupg_spawn_process_detached (fname, args, envs); + if (err && gpg_err_code (err) != GPG_ERR_ENOENT) + log_error ("failed to run event handler `%s': %s\n", + fname, gpg_strerror (err)); + xfree (fname); + free (envstr); + } + xfree (homestr); + } + /* Set the card removed flag for all current sessions. We will set this on any card change because a reset or SERIALNO request must be done in any case. */ @@ -1802,6 +1844,7 @@ kill (pid, signo); #endif } + } } } From cvs at cvs.gnupg.org Fri Sep 8 12:06:27 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri Sep 8 11:22:14 2006 Subject: [svn] gpg-error - r178 - trunk/po Message-ID: Author: wk Date: 2006-09-08 12:06:27 +0200 (Fri, 08 Sep 2006) New Revision: 178 Modified: trunk/po/ChangeLog trunk/po/pl.po Log: Updated. Modified: trunk/po/ChangeLog =================================================================== --- trunk/po/ChangeLog 2006-09-06 16:37:17 UTC (rev 177) +++ trunk/po/ChangeLog 2006-09-08 10:06:27 UTC (rev 178) @@ -1,3 +1,7 @@ +2006-09-08 Werner Koch + + * pl.po: Updated. + 2006-03-14 gettextize * Makefile.in.in: Upgrade to gettext-0.14.5. Modified: trunk/po/pl.po =================================================================== --- trunk/po/pl.po 2006-09-06 16:37:17 UTC (rev 177) +++ trunk/po/pl.po 2006-09-08 10:06:27 UTC (rev 178) @@ -1,13 +1,14 @@ # Polish translation for libgpg-error. +# Copyright (C) 2004, 2005 Free Software Foundation, Inc. # This file is distributed under the same license as the libgpg-error package. -# Jakub Bogusz , 2004. +# Jakub Bogusz , 2004-2005. # msgid "" msgstr "" -"Project-Id-Version: libgpg-error 0.8-cvs\n" +"Project-Id-Version: libgpg-error 1.1\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2006-03-14 12:56+0100\n" -"PO-Revision-Date: 2004-04-20 21:03+0200\n" +"POT-Creation-Date: 2004-07-30 14:49+0200\n" +"PO-Revision-Date: 2005-07-04 17:42+0200\n" "Last-Translator: Jakub Bogusz \n" "Language-Team: Polish \n" "MIME-Version: 1.0\n" @@ -519,9 +520,8 @@ msgstr "B³±d karty" #: src/err-codes.h:137 -#, fuzzy msgid "Card reset required" -msgstr "Reset karty" +msgstr "Wymagany reset karty" #: src/err-codes.h:138 msgid "Card removed" @@ -757,171 +757,154 @@ #: src/err-codes.h:196 msgid "Protocol violation" -msgstr "" +msgstr "Naruszenie protoko³u" #: src/err-codes.h:197 -#, fuzzy msgid "Invalid MAC" -msgstr "Niepoprawne CRL" +msgstr "Niepoprawny MAC" #: src/err-codes.h:198 -#, fuzzy msgid "Invalid request" -msgstr "Niepoprawny argument" +msgstr "Niepoprawne ¿±danie" #: src/err-codes.h:199 -#, fuzzy -msgid "Unknown extension" -msgstr "Nieznane S-wyra¿enie" - -#: src/err-codes.h:200 -#, fuzzy -msgid "Unknown critical extension" -msgstr "Nieznane S-wyra¿enie" - -#: src/err-codes.h:201 -#, fuzzy -msgid "Locked" -msgstr "Nie zablokowany" - -#: src/err-codes.h:202 msgid "Buffer too short" msgstr "Bufor zbyt ma³y" -#: src/err-codes.h:203 +#: src/err-codes.h:200 msgid "Invalid length specifier in S-expression" msgstr "Niepoprawne okre¶lenie d³ugo¶ci w S-wyra¿eniu" -#: src/err-codes.h:204 +#: src/err-codes.h:201 msgid "String too long in S-expression" msgstr "Zbyt d³ugi ³añcuch w S-wyra¿eniu" -#: src/err-codes.h:205 +#: src/err-codes.h:202 msgid "Unmatched parentheses in S-expression" msgstr "Niedopasowane nawiasy w S-wyra¿eniu" -#: src/err-codes.h:206 +#: src/err-codes.h:203 msgid "S-expression not canonical" msgstr "S-wyra¿enie nie kanoniczne" -#: src/err-codes.h:207 +#: src/err-codes.h:204 msgid "Bad character in S-expression" msgstr "B³êdny znak w S-wyra¿eniu" -#: src/err-codes.h:208 +#: src/err-codes.h:205 msgid "Bad quotation in S-expression" msgstr "B³êdne cytowanie w S-wyra¿eniu" -#: src/err-codes.h:209 +#: src/err-codes.h:206 msgid "Zero prefix in S-expression" msgstr "Zerowy prefiks w S-wyra¿eniu" -#: src/err-codes.h:210 +#: src/err-codes.h:207 msgid "Nested display hints in S-expression" msgstr "Zagnie¿d¿one podpowiedzi wy¶wietlania w S-wyra¿eniu" -#: src/err-codes.h:211 +#: src/err-codes.h:208 msgid "Unmatched display hints" msgstr "Niedopasowane podpowiedzi wy¶wietlania" -#: src/err-codes.h:212 +#: src/err-codes.h:209 msgid "Unexpected reserved punctuation in S-expression" msgstr "Nieoczekiwany zarezerwowany znak w S-wyra¿eniu" -#: src/err-codes.h:213 +#: src/err-codes.h:210 msgid "Bad hexadecimal character in S-expression" msgstr "B³êdny znak szesnastkowy w S-wyra¿eniu" -#: src/err-codes.h:214 +#: src/err-codes.h:211 msgid "Odd hexadecimal numbers in S-expression" msgstr "Nieparzysta liczba cyfr szesnastkowych w S-wyra¿eniu" -#: src/err-codes.h:215 +#: src/err-codes.h:212 msgid "Bad octadecimal character in S-expression" msgstr "B³êdny znak ósemkowy w S-wyra¿eniu" -#: src/err-codes.h:216 +#: src/err-codes.h:213 msgid "User defined error code 1" msgstr "Zdefiniowany przez u¿ytkownika kod b³êdu 1" -#: src/err-codes.h:217 +#: src/err-codes.h:214 msgid "User defined error code 2" msgstr "Zdefiniowany przez u¿ytkownika kod b³êdu 2" -#: src/err-codes.h:218 +#: src/err-codes.h:215 msgid "User defined error code 3" msgstr "Zdefiniowany przez u¿ytkownika kod b³êdu 3" -#: src/err-codes.h:219 +#: src/err-codes.h:216 msgid "User defined error code 4" msgstr "Zdefiniowany przez u¿ytkownika kod b³êdu 4" -#: src/err-codes.h:220 +#: src/err-codes.h:217 msgid "User defined error code 5" msgstr "Zdefiniowany przez u¿ytkownika kod b³êdu 5" -#: src/err-codes.h:221 +#: src/err-codes.h:218 msgid "User defined error code 6" msgstr "Zdefiniowany przez u¿ytkownika kod b³êdu 6" -#: src/err-codes.h:222 +#: src/err-codes.h:219 msgid "User defined error code 7" msgstr "Zdefiniowany przez u¿ytkownika kod b³êdu 7" -#: src/err-codes.h:223 +#: src/err-codes.h:220 msgid "User defined error code 8" msgstr "Zdefiniowany przez u¿ytkownika kod b³êdu 8" -#: src/err-codes.h:224 +#: src/err-codes.h:221 msgid "User defined error code 9" msgstr "Zdefiniowany przez u¿ytkownika kod b³êdu 9" -#: src/err-codes.h:225 +#: src/err-codes.h:222 msgid "User defined error code 10" msgstr "Zdefiniowany przez u¿ytkownika kod b³êdu 10" -#: src/err-codes.h:226 +#: src/err-codes.h:223 msgid "User defined error code 11" msgstr "Zdefiniowany przez u¿ytkownika kod b³êdu 11" -#: src/err-codes.h:227 +#: src/err-codes.h:224 msgid "User defined error code 12" msgstr "Zdefiniowany przez u¿ytkownika kod b³êdu 12" -#: src/err-codes.h:228 +#: src/err-codes.h:225 msgid "User defined error code 13" msgstr "Zdefiniowany przez u¿ytkownika kod b³êdu 13" -#: src/err-codes.h:229 +#: src/err-codes.h:226 msgid "User defined error code 14" msgstr "Zdefiniowany przez u¿ytkownika kod b³êdu 14" -#: src/err-codes.h:230 +#: src/err-codes.h:227 msgid "User defined error code 15" msgstr "Zdefiniowany przez u¿ytkownika kod b³êdu 15" -#: src/err-codes.h:231 +#: src/err-codes.h:228 msgid "User defined error code 16" msgstr "Zdefiniowany przez u¿ytkownika kod b³êdu 16" -#: src/err-codes.h:232 +#: src/err-codes.h:229 msgid "Unknown system error" msgstr "Nieznany b³±d systemu" -#: src/err-codes.h:233 +#: src/err-codes.h:230 msgid "End of file" msgstr "Koniec pliku" -#: src/err-codes.h:234 +#: src/err-codes.h:231 msgid "Unknown error code" msgstr "Nieznany kod b³êdu" -#: src/gpg-error.c:456 +#: src/gpg-error.c:281 #, c-format msgid "Usage: %s GPG-ERROR [...]\n" msgstr "Sk³adnia: %s B£¡D-GPG [...]\n" -#: src/gpg-error.c:477 +#: src/gpg-error.c:302 #, c-format msgid "%s: warning: could not recognize %s\n" msgstr "%s: uwaga: nie rozpoznano %s\n" From cvs at cvs.gnupg.org Fri Sep 8 19:02:10 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri Sep 8 18:18:29 2006 Subject: [svn] GnuPG - r4247 - in trunk: . doc doc/examples Message-ID: Author: wk Date: 2006-09-08 19:02:06 +0200 (Fri, 08 Sep 2006) New Revision: 4247 Added: trunk/doc/specify-user-id.texi Modified: trunk/README trunk/doc/ChangeLog trunk/doc/HACKING trunk/doc/Makefile.am trunk/doc/examples/scd-event trunk/doc/gnupg.texi trunk/doc/gpg-agent.texi trunk/doc/gpg.texi trunk/doc/gpgsm.texi trunk/doc/tools.texi trunk/doc/yat2m.c Log: doc fixes Modified: trunk/README =================================================================== --- trunk/README 2006-09-07 15:13:33 UTC (rev 4246) +++ trunk/README 2006-09-08 17:02:06 UTC (rev 4247) @@ -11,9 +11,9 @@ You should use this GnuPG version if you want to use the gpg-agent or gpgsm (the S/MIME variant of gpg). Note that the gpg-agent is also -helpful when using the standard gpg versions (1.4.x as well as some of -the old 1.2.x). There are no problems installing 1.4 and 1.9 -alongside; in dact we suggest to do this. +helpful when using the standard gpg versions (1.4.x) the old 1.2.x). +There are no problems installing 1.4 and 1.9 alongside; in fact we +suggest to do this. BUILD INSTRUCTIONS @@ -23,12 +23,9 @@ libgpg-error (ftp://ftp.gnupg.org/gcrypt/libgpg-error/) libgcrypt (ftp://ftp.gnupg.org/gcrypt/libgcrypt/) + libksba (ftp://ftp.gnupg.org/gcrypt/libksba/) libassuan (ftp://ftp.gnupg.org/gcrypt/alpha/libassuan/) - libksba (ftp://ftp.gnupg.org/gcrypt/alpha/libksba/) -If you use the configure option --enable-agent-only, libksba is not -required. - You also need the pinentry package for most function of GnuPG; however it is not a build requirement. pinentry is available at ftp://ftp.gnupg.org/gcrypt/pinentry/ . @@ -51,452 +48,21 @@ If everything succeeds, you have a working GnuPG with support for S/MIME and smartcards. Note that there is no binary gpg but a gpg2 so -that this package won't conflict with a GnuPG 1.2 or 1.3 -installation. gpg2 behaves just like gpg; it is however suggested to -keep using gpg 1.2.x or 1.3.x. gpg2 is not even build by default. +that this package won't conflict with a GnuPG 1.4 installation. gpg2 +behaves just like gpg. -In case of problem please ask on gnupg-dev@gnupg.org for advise. Note +In case of problem please ask on gnupg-users@gnupg.org for advise. Note that this release is only expected to build on GNU and *BSD systems. -A texinfo manual named `gnupg.info' will get installed. man pages for -all major components are also provided. Some commands and options -given below. See also the section `SMARTCARD INTRO'. -COMMANDS -======== +DOCUMENTATION +================== -See the info documentation ("info gnupg") for a full list of commands -and options. +The complete documentation is in the texinfo manual named +`gnupg.info'. Run "info gnupg" to read it. If you want a a printable +copy of the manual, change to the "doc" directory and enter "make +gnupg.pdf". For a HTML version enter "make gnupg.html" and point your +browser to gnupg.html/index.html. Standard man pages for all +components are provided as well. -gpgsm: ------- - ---learn-card - - Read information about the private keys from the smartcard and - import the certificates from there. - ---export - - Export all certificates stored in the Keybox or those specified on - the command line. When using --armor a few informational lines are - prepended before each block. - - -OPTIONS -======= - -gpgsm: ------- - ---include-certs - - Using N of -2 includes all certificate except for the Root cert, - -1 includes all certs, 0 does not include any certs, 1 includes only - the signers cert (this is the default) and all other positives - values include up to N certs starting with the signer cert. - ---policy-file - - Change the default name of the policy file - ---enable-policy-checks ---disable-policy-checks - - By default policy checks are enabled. These options may be used to - change it. - ---enable-crl-checks ---disable-crl-checks - - By default the CRL checks are enabled and the DirMngr is used to - check for revoked certificates. The disable option is most useful - with an off-line connection to suppres this check. - ---agent-program - - Specify an agent program to be used for secret key operations. The - default value is "../agent/gpg-agent". This is only used as a - fallback when the envrionment variable GPG_AGENT_INFO is not set or - a running agent can't be connected. - ---dirmngr-program - - Specify a dirmngr program to be used for CRL checks. The default - value is "/usr/sbin/dirmngr". This is only used as a fallback when - the environment variable DIRMNGR_INFO is not set or a running - dirmngr can't be connected. - ---no-secmem-warning - - Don't print the warning "no secure memory" - ---armor - - Create PEM encoded output. Default is binary output. - ---base64 - - Create Base-64 encoded output; i.e. PEM without the header lines. - ---assume-armor - - Assume the input data is PEM encoded. Default is to autodetect the - encoding but this is may fail. - ---assume-base64 - - Assume the input data is plain base-64 encoded. - ---assume-binary - - Assume the input data is binary encoded. - ---server - - Run in server mode. This is used by GPGME to control gpgsm. See - the assuan specification regarding gpgsm about the used protocol. - Some options are ignored in server mode. - ---local-user - - Set the user to be used for signing. The default is the first - secret key found in the database. - ---with-key-data - - Displays extra information with the --list-keys commands. Especially - a line tagged "grp" is printed which tells you the keygrip of a - key. This is string is for example used as the filename of the - secret key. - - - -gpg-agent: ---------- - ---pinentry-program - - Specify the PINentry program. The default value is - "/bin/pinentry" so you most likely want to specify it. - ---no-grab - - Tell the pinentry not to grab keyboard and mouse. You most likely - want to give this option during testing and development to avoid - lockups in case of bugs. - - -scdaemon: --------- - ---ctapi-driver - - The default for Scdaemon is to use the PC/SC API currently provided - by libpcsclite.so. As an alternative the ctAPI can be used by - specify this option with the appropriate driver name - (e.g. libtowitoko.so). - ---reader-port - - This specifies the port of the chipcard reader. For PC/SC this is - currently ignored and the first PC/SC reader is used. For the - ctAPI, a number must be specified (the default is 32768 for the - first USB port). - ---disable-ccid - - Disable the integrated support for CCID compliant readers. This - allows to fall back to one of the other drivers even if the internal - CCID driver can handle the reader. Note, that CCID support is only - available if libusb was available at build time. - - -FILES -===== - -The default home directory is ~/.gnupg. It can be changed by -either the --homedir option or by setting the environment variable -GNUPGHOME. This is a list of files usually found in this directory: - -gpgsm.conf - - Options for gpgsm. Options are the same as the command line - options but don't enter the leading dashes and give arguments - without an equal sign. Blank lines and lines starting with a - hash mark as the first non white space character are ignored. - -gpg-agent.conf - - Options for gpg-agent - -scdaemon.conf - - Options for scdaemon. - -dirmngr.conf - - Options for the DirMngr which is not part of this package and - the option file will most likely be moved to /etc - -gpg.conf - - Options for gpg. Note that old versions of gpg use the - filename `options' instead of `gpg.conf'. - -gpg.conf-1.9.x - - Options for gpg; tried before gpg.conf - - -policies.txt - - A list of allowed CA policies. This file should give the - object identifiers of the policies line by line. Empty lines - and lines starting with a hash mark are ignored. - - ++++++++++ - 2.289.9.9 - ++++++++++ - -trustlist.txt - - A list of trusted certificates. The file will be created - automagically with some explaining comments. By using - gpg-agent's option --allow-mark-trusted, gpg-agent may add new - entries after user confirmation. - -random_seed - - Used internally for keeping the state of the RNG over - invocations. - -pubring.kbx - - The database file with the certificates. - -pubring.gpg - - The database file with the OpenPGP public keys. This will - eventually be merged with pubring.kbx - -secring.gpg - - The database file with the OpenPGP secret keys. This will be - removed when gpg is changed to make use of the gpg-agent. - - -private-keys-v1.d/ - - Directory holding the private keys maintained by gpg-agent. - For detailed info see agent/keyformat.txt. Note that there is - a helper tool gpg-protect-tool which may be used to protect or - unprotect keys. This is however nothing a user should care - about. - - -SOURCE FILES -============ - -Here is a list of directories with source files: - -jnlib/ utility functions -kbx/ keybox library -g10/ the gpg program here called gpg2 -sm/ the gpgsm program -agent/ the gpg-agent -scd/ the smartcard daemon -doc/ documentation - - - -HOW TO SPECIFY A USER ID -======================== - -Due to the way X.509 certificates are made up we need a few new ways -to specify a certificate (aka key in OpenPGP). In addition to the -ways a user ID can be specified with gpg, I have implemented 3 new -modes for gpgsm, here is the entire list of ways to specify a key: - - * By keyID. - - This format is deducted from the length of the string and its - content or "0x" prefix. For use with OpenPGP an exclamation mark may - be appended to force use of the specified (sub)key. - - As with v34 OpenPGP keys, the keyID of an X509 certificate are the - low 64 bits of the SHA-1 fingerprint. The use of keyIDs is just a - shortcut, for all automated processing the fingerprint should be - used. - - Examples: - - 234567C4 - 0F34E556E - 01347A56A - 0xAB123456 - - 234AABBCC34567C4 - 0F323456784E56EAB - 01AB3FED1347A5612 - 0x234AABBCC34567C4 - - * By fingerprint - - This is format is deduced from the length of the string and its - content or "0x" prefix. Note, that only the 20 byte fingerprint is - used with GPGSM (SHA-1 hash of the certificate). For use with - OpenPGP an exclamation mark may be appended to force use of the - specified (sub)key. - - Examples: - - 1234343434343434C434343434343434 - 123434343434343C3434343434343734349A3434 - 0E12343434343434343434EAB3484343434343434 - 0xE12343434343434343434EAB3484343434343434 - - * Exact match on OpenPGP user ID - - This is denoted by a leading equal sign. It does not make much - sense for X.509. - - Example: - - =Heinrich Heine - - * Exact match on an email address. - - This is indicated by enclosing the email address in the usual way - with left and right angles - - Example: - - - - * Word match - - All words must match exactly (not case sensitive) but can appear in - any order in the user ID or a subjects name. Words are any - sequences of letters, digits, the underscore and all characters - with bit 7 set. - - Example: - - +Heinrich Heine duesseldorf - - * Exact match by subject's DN - - This is indicated by a leading slash, directly followed by the - rfc2253 encoded DN of the subject. Note that you can't use the - string printed by "gpgsm --list-keys" because that one as been - reordered and modified for better readability; use --with-colons to - print the raw (but standard escaped) rfc2253 string - - Example: - - /CN=Heinrich Heine,O=Poets,L=Paris,C=FR - - * Exact match by issuer's DN - - This is indicated by a leading hash mark, directly followed by a - slash and then directly followed by the rfc2253 encoded DN of the - issuer. This should return the Root cert of the issuer. See note - above. - - Example: - - #/CN=Root Cert,O=Poets,L=Paris,C=FR - - * Exact match by serial number and issuer's DN - - This is indicated by a hash mark, followed by the hexadecmal - representation of the serial number, the followed by a slash and - the RFC2253 encoded DN of the issuer. See note above. - - Example: - - #4F03/CN=Root Cert,O=Poets,L=Paris,C=FR - - * Substring match - - By case insensitive substring matching. This is the default mode - but applications may want to explicitly indicate this by putting - the asterisk in front. - - Example: - - Heine - *Heine - - -Please note that we have reused the hash mark identifier which was -used in old GnuPG versions to indicate the so called local-id. It is -not anymore used and there should be no conflict when used with X.509 -stuff. - -Using the rfc2253 format of DNs has the drawback that it is not -possible to map them back to the original encoding, however we don't -have to do this, because our key database stores this encoding as meta -data. - -Some of the search modes are not yet implemented ;-) - - -HOW TO IMPORT A PRIVATE KEY -=========================== -There is some limited support to import a private key from a PKCS-12 -file. - - gpgsm --import foo.p12 - -This requires that the gpg-agent is running. - - -HOW TO EXPORT A PRIVATE KEY -=========================== -There is also limited support to export a private key in PKCS-12 -format. However there is no MAC applied. - - gpgsm --export-secret-key-p12 userID >foo.p12 - - -SMARTCARD INTRO -=============== - -GPG, the OpenPGP part of GnuPG, supports the OpenPGP smartcard -(surprise!); see http://g10code.com/p-card.html and -http://www.gnupg.org/documentation/howtos.html#GnuPG-cardHOWTO . - -GPGSM, the CMS (S/MIME) part of GnuPG, supports two kinds of -smartcards. The most flexible way is to use PKCS#15 compliant cards, -however you must have build GnuPG with support for the OpenSC library. -The build process automagically detects the presence of this library -and will include support for these cards. - -The other cards we currently support are the Telesec NetKey card with -the NKS 2.0 card application and all generic DINSIG cards. - -Before GPGSM can make use of a new card it must gather some -information, like the card's serial number, the public keys and the -certificates stored on the card. Thus for a new card you need to run -the command - - gpgsm --learn-card - -once. This is also a good test to see whether your card reader is -properly installed. See below in case of error. Once this has been -done you may use the keys stored on the card in the same way you use -keys stored on the disk. gpgsm automagically knows whether a card is -required and will pop up the pinentry to ask you to insert the -correct card. - -For selecting the driver, see the options of scdaemon. A useful -debugging flag is "--debug 2048" showing the communication between -scdaemon and the reader. - - - - - Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2006-09-07 15:13:33 UTC (rev 4246) +++ trunk/doc/ChangeLog 2006-09-08 17:02:06 UTC (rev 4247) @@ -1,3 +1,10 @@ +2006-09-08 Werner Koch + + * yat2m.c (parse_file): Ignore @node lines immediately. + (proc_texi_cmd): No special @end ifset processing anymore. + + * specify-user-id.texi: New. Factored out of gpg.texi and ../README. + 2006-09-07 Werner Koch * scdaemon.texi (Scdaemon Configuration): New. Modified: trunk/doc/HACKING =================================================================== --- trunk/doc/HACKING 2006-09-07 15:13:33 UTC (rev 4246) +++ trunk/doc/HACKING 2006-09-08 17:02:06 UTC (rev 4247) @@ -6,6 +6,22 @@ ===> Under construction <======= +SOURCE FILES +============ + +Here is a list of directories with source files: + +jnlib/ utility functions +kbx/ keybox library +g10/ the gpg program here called gpg2 +sm/ the gpgsm program +agent/ the gpg-agent +scd/ the smartcard daemon +doc/ documentation + + + + CVS Access ========== Modified: trunk/doc/Makefile.am =================================================================== --- trunk/doc/Makefile.am 2006-09-07 15:13:33 UTC (rev 4246) +++ trunk/doc/Makefile.am 2006-09-08 17:02:06 UTC (rev 4247) @@ -27,7 +27,7 @@ gnupg-card-architecture.eps gnupg-card-architecture.png \ gnupg-card-architecture.pdf \ faq.raw FAQ faq.html gnupg7.texi \ - opt-homedir.texi see-also-note.texi \ + opt-homedir.texi see-also-note.texi specify-user-id.texi \ $(examples) BUILT_SOURCES = gnupg-card-architecture.eps gnupg-card-architecture.png \ Modified: trunk/doc/examples/scd-event =================================================================== --- trunk/doc/examples/scd-event 2006-09-07 15:13:33 UTC (rev 4246) +++ trunk/doc/examples/scd-event 2006-09-08 17:02:06 UTC (rev 4247) @@ -36,12 +36,12 @@ --reader-port N Reports change for port N --old-code 0xNNNN Previous status code --old-code 0xNNNN Current status code - --status USABLE|ACTIVE|PRESENT}NOCARD + --status USABLE|ACTIVE|PRESENT|NOCARD Human readable status code Environment: -GNUPGHOME=DIR Set to the active hmedir +GNUPGHOME=DIR Set to the active homedir EOF exit 0 Modified: trunk/doc/gnupg.texi =================================================================== --- trunk/doc/gnupg.texi 2006-09-07 15:13:33 UTC (rev 4246) +++ trunk/doc/gnupg.texi 2006-09-08 17:02:06 UTC (rev 4247) @@ -118,6 +118,7 @@ * Invoking GPGSM:: Using the S/MIME protocol. * Invoking GPG-AGENT:: How to launch the secret key daemon. * Invoking SCDAEMON:: How to handle Smartcards. +* Specify a User ID:: How to Specify a User Id. * Helper Tools:: Description of small helper tools @@ -152,6 +153,12 @@ @include gpg-agent.texi @include scdaemon.texi +@node Specify a User ID +@chapter How to Specify a User Id +@anchor{how-to-specify-a-user-id} +@include specify-user-id.texi + + @include tools.texi @include sysnotes.texi Modified: trunk/doc/gpg-agent.texi =================================================================== --- trunk/doc/gpg-agent.texi 2006-09-07 15:13:33 UTC (rev 4246) +++ trunk/doc/gpg-agent.texi 2006-09-08 17:02:06 UTC (rev 4247) @@ -500,6 +500,14 @@ # Key added on 2005-02-25 15:08:29 5A6592BF45DC73BD876874A28FD4639282E29B52 0 @end example + +@item private-keys-v1.d/ + + This is the directory where gpg-agent stores the private keys. Each + key is stored in a file with the name made up of the keygrip and the + suffix @file{key}. + + @end table Note that on larger installations, it is useful to put predefined Modified: trunk/doc/gpg.texi =================================================================== --- trunk/doc/gpg.texi 2006-09-07 15:13:33 UTC (rev 4246) +++ trunk/doc/gpg.texi 2006-09-08 17:02:06 UTC (rev 4247) @@ -30,7 +30,7 @@ @mansect description @command{gpg2} is the OpenPGP part of the GNU Privacy Guard (GnuPG). It -is a tool to provide digitla encryption and signing services using the +is a tool to provide digital encryption and signing services using the OpenPGP standard. @command{gpg2} features complete key management and all bells and whistles you can expect from a decent OpenPGP implementation. @@ -2455,60 +2455,16 @@ @end table +@c ******************************************* +@c *************** **************** +@c *************** USER ID **************** +@c *************** **************** +@c ******************************************* @mansect how to specify a user id -@chapheading How to specify a user ID +@ifset isman +@include specify-user-id.texi +@end ifset -There are different ways to specify a user ID to GnuPG; here are some -examples: - -@table @asis - -@item - -@item 234567C4 -@itemx 0F34E556E -@itemx 01347A56A -@itemx 0xAB123456 -Here the key ID is given in the usual short form. - -@item 234AABBCC34567C4 -@itemx 0F323456784E56EAB -@itemx 01AB3FED1347A5612 -@itemx 0x234AABBCC34567C4 -Here the key ID is given in the long form as used by OpenPGP -(you can get the long key ID using the option --with-colons). - -@item 1234343434343434C434343434343434 -@itemx 123434343434343C3434343434343734349A3434 -@itemx 0E12343434343434343434EAB3484343434343434 -@itemx 0xE12343434343434343434EAB3484343434343434 -The best way to specify a key ID is by using the fingerprint of -the key. This avoids any ambiguities in case that there are duplicated -key IDs (which are really rare for the long key IDs). - -@item =Heinrich Heine -Using an exact to match string. The equal sign indicates this. - -@item -Using the email address part which must match exactly. The left angle bracket -indicates this email address mode. - -@item @@heinrichh -Match within the part of a user ID. The at sign -indicates this email address mode. - -@item Heine -@itemx *Heine -By case insensitive substring matching. This is the default mode but -applications may want to explicitly indicate this by putting the asterisk -in front. -@end table - -Note that you can append an exclamation mark (!) to key IDs or -fingerprints. This flag tells GnuPG to use the specified primary or -secondary key and not to try and calculate which primary or secondary -key to use. - @mansect return vaue @chapheading RETURN VALUE Modified: trunk/doc/gpgsm.texi =================================================================== --- trunk/doc/gpgsm.texi 2006-09-07 15:13:33 UTC (rev 4246) +++ trunk/doc/gpgsm.texi 2006-09-08 17:02:06 UTC (rev 4247) @@ -105,18 +105,19 @@ @table @gnupgtabopt @item --encrypt @opindex encrypt -Perform an encryption. +Perform an encryption. The keys the data is encrypted too must be set +using the option @option{--recipient}. @item --decrypt @opindex decrypt -Perform a decryption; the type of input is automatically detmerined. It +Perform a decryption; the type of input is automatically determined. It may either be in binary form or PEM encoded; automatic determination of base-64 encoding is not done. @item --sign @opindex sign Create a digital signature. The key used is either the fist one found -in the keybox or thise set with the -u option +in the keybox or those set with the @option{--local-user} option. @item --verify @opindex verify @@ -428,6 +429,14 @@ Set the user(s) to be used for signing. The default is the first secret key found in the database. + +@item --recipient @var{name} +@itemx -r +@opindex recipient +Encrypt to the user id @var{name}. There are several ways a user id +may be given (@pxref{how-to-specify-a-user-id}). + + @item --output @var{file} @itemx -o @var{file} @opindex output @@ -500,18 +509,18 @@ Select the debug level for investigating problems. @var{level} may be one of: - @table @code - @item none - no debugging at all. - @item basic - some basic debug messages - @item advanced - more verbose debug messages - @item expert - even more detailed messages - @item guru - all of the debug messages you can get - @end table +@table @code +@item none +no debugging at all. +@item basic +some basic debug messages +@item advanced +more verbose debug messages +@item expert +even more detailed messages +@item guru +all of the debug messages you can get +@end table How these messages are mapped to the actual debugging flags is not specified and may change with newer releaes of this program. They are @@ -524,24 +533,24 @@ preferred method to select the debug verbosity. FLAGS are bit encoded and may be given in usual C-Syntax. The currently defined bits are: - @table @code - @item 0 (1) - X.509 or OpenPGP protocol related data - @item 1 (2) - values of big number integers - @item 2 (4) - low level crypto operations - @item 5 (32) - memory allocation - @item 6 (64) - caching - @item 7 (128) - show memory statistics. - @item 9 (512) - write hashed data to files named @code{dbgmd-000*} - @item 10 (1024) - trace Assuan protocol - @end table +@table @code +@item 0 (1) +X.509 or OpenPGP protocol related data +@item 1 (2) +values of big number integers +@item 2 (4) +low level crypto operations +@item 5 (32) +memory allocation +@item 6 (64) +caching +@item 7 (128) +show memory statistics. +@item 9 (512) +write hashed data to files named @code{dbgmd-000*} +@item 10 (1024) +trace Assuan protocol +@end table Note, that all flags set using this option may get overriden by @code{--debug-level}. @@ -580,6 +589,15 @@ All the long options may also be given in the configuration file after stripping off the two leading dashes. +@c ******************************************* +@c *************** **************** +@c *************** USER ID **************** +@c *************** **************** +@c ******************************************* +@mansect how to specify a user id +@ifset isman +@include specify-user-id.texi +@end ifset @c ******************************************* @c *************** **************** Added: trunk/doc/specify-user-id.texi =================================================================== --- trunk/doc/specify-user-id.texi 2006-09-07 15:13:33 UTC (rev 4246) +++ trunk/doc/specify-user-id.texi 2006-09-08 17:02:06 UTC (rev 4247) @@ -0,0 +1,160 @@ +@c Include file to allow for different placements in man pages and the manual + +There are different ways to specify a user ID to GnuPG. Some of them +are only valid for @command{gpg} others are only good for +@command{gpgsm}. Here is the entire list of ways to specify a key: + +@itemize @bullet + +@item By key Id. +This format is deduced from the length of the string and its content or +@code{0x} prefix. The key Id of an X.509 certificate are the low 64 bits +of its SHA-1 fingerprint. The use of key Ids is just a shortcut, for +all automated processing the fingerprint should be used. + +When using @command{gpg} an exclamation mark may be appended to force +using the specified primary or secondary key and not to try and +calculate which primary or secondary key to use. + +The last four lines of the example give the key ID in their long form as +internally used by the OpenPGP protocol. You can see the long key ID +using the option @option{--with-colons}. + +@cartouche +@example +234567C4 +0F34E556E +01347A56A +0xAB123456 + +234AABBCC34567C4 +0F323456784E56EAB +01AB3FED1347A5612 +0x234AABBCC34567C4 +@end example +@end cartouche + + + +@item By fingerprint. +This format is deduced from the length of the string and its content or +the @code{0x} prefix. Note, that only the 20 byte version fingerprint +is available with @command{gpgsm} (i.e. the SHA-1 hash of the +certificate). + +When using @command{gpg} an exclamation mark may be appended to force +using the specified primary or secondary key and not to try and +calculate which primary or secondary key to use. + +The best way to specify a key Id is by using the fingerprint. This +avoids any ambiguities in case that there are duplicated key IDs. + +@cartouche +@example +1234343434343434C434343434343434 +123434343434343C3434343434343734349A3434 +0E12343434343434343434EAB3484343434343434 +0xE12343434343434343434EAB3484343434343434 +@end example +@end cartouche + +@noindent +(@command{gpgsm} also accepts colons between each pair of hexadecimal +digits because this is the de-facto standard on how to present X.509 +fingerprints.) + +@item By exact match on OpenPGP user ID. +This is denoted by a leading equal sign. It does not make sense for +X.509 certificates. + +@cartouche +@example +=Heinrich Heine +@end example +@end cartouche + +@item By exact match on an email address. +This is indicated by enclosing the email address in the usual way +with left and right angles. + +@cartouche +@example + +@end example +@end cartouche + + +@item By word match. +All words must match exactly (not case sensitive) but can appear in any +order in the user ID or a subjects name. Words are any sequences of +letters, digits, the underscore and all characters with bit 7 set. + +@cartouche +@example ++Heinrich Heine duesseldorf +@end example +@end cartouche + +@item By exact match on the subject's DN. +This is indicated by a leading slash, directly followed by the RFC-2253 +encoded DN of the subject. Note that you can't use the string printed +by "gpgsm --list-keys" because that one as been reordered and modified +for better readability; use --with-colons to print the raw (but standard +escaped) RFC-2253 string + +@cartouche +@example +/CN=Heinrich Heine,O=Poets,L=Paris,C=FR +@end example +@end cartouche + +@item By exact match on the issuer's DN. +This is indicated by a leading hash mark, directly followed by a slash +and then directly followed by the rfc2253 encoded DN of the issuer. +This should return the Root cert of the issuer. See note above. + +@cartouche +@example +#/CN=Root Cert,O=Poets,L=Paris,C=FR +@end example +@end cartouche + + +@item By exact match on serial number and issuer's DN. +This is indicated by a hash mark, followed by the hexadecmal +representation of the serial number, the followed by a slash and the +RFC-2253 encoded DN of the issuer. See note above. + +@cartouche +@example +#4F03/CN=Root Cert,O=Poets,L=Paris,C=FR +@end example +@end cartouche + + +@item By substring match. +This is the default mode but applications may want to explicitly +indicate this by putting the asterisk in front. Match is not case +sensitive. + +@cartouche +@example +Heine +*Heine +@end example +@end cartouche + +@end itemize + + +Please note that we have reused the hash mark identifier which was used +in old GnuPG versions to indicate the so called local-id. It is not +anymore used and there should be no conflict when used with X.509 stuff. + +Using the RFC-2253 format of DNs has the drawback that it is not +possible to map them back to the original encoding, however we don't +have to do this because our key database stores this encoding as meta +data. + + + Modified: trunk/doc/tools.texi =================================================================== --- trunk/doc/tools.texi 2006-09-07 15:13:33 UTC (rev 4246) +++ trunk/doc/tools.texi 2006-09-08 17:02:06 UTC (rev 4247) @@ -948,13 +948,13 @@ here we connect to a running instance. @menu -* Invoking gpg-connect-agent:: List of all commands and options. +* Invoking gpg-connect-agent:: List of all options. +* Controlling gpg-connect-agent:: Control commands. @end menu @manpause @node Invoking gpg-connect-agent -@subsection List of all commands and options. -@mancont +@subsection List of all options. @noindent @command{gpg-connect-agent} is invoked this way: @@ -962,6 +962,7 @@ @example gpg-connect-agent [options] @end example +@mancont @noindent The following options may be used: @@ -990,13 +991,49 @@ @end table +@mansect control commands +@node Controlling gpg-connect-agent +@subsection Control commands. + +While reading Assuan commands, gpg-agent also allows a few special +commands to control its operation. These control commands all start +with a slash (@code{/}). + + +@table @code + +@item /echo @var{args} +Just print @var{args}. + +@item /definqfile @var{name} @var{file} + +Use content of @var{file} for inquiries with @var{name}. +@var{name} may be an asterisk (@code{*} to match any inquiry. + +@item /definqprog @var{name} @var{prog} +Run @var{prog} for inquiries matching @var{name} and pass the +entire line to it as command line arguments + +@item /showdef +Print all definitions + +@item /cleardef +Delete all definitions + +@item /help +Print a list of available control commands. + +@end table + + +@ifset isman @mansect see also @command{gpg-agent}(1), @command{scdaemon}(1) @include see-also-note.texi +@end ifset - @c @c GPGPARSEMAIL @c Modified: trunk/doc/yat2m.c =================================================================== --- trunk/doc/yat2m.c 2006-09-07 15:13:33 UTC (rev 4246) +++ trunk/doc/yat2m.c 2006-09-08 17:02:06 UTC (rev 4247) @@ -456,7 +456,6 @@ { "opindex", 1 }, { "cpindex", 1 }, { "cindex", 1 }, - { "node", 1 }, { "noindent", 0 }, { "section", 1 }, { "chapter", 1 }, @@ -465,6 +464,8 @@ { "item", 2, ".TP\n.B " }, { "itemx", 2, ".TP\n.B " }, { "table", 3 }, + { "itemize", 3 }, + { "bullet", 0, "* " }, { "end", 4 }, { "quotation",1, ".RS\n\\fB" }, { "ifset", 1 }, @@ -523,11 +524,6 @@ { fputs ("\\fR\n.RE\n", fp); } - else if (n >= 5 && !memcmp (s, "ifset", 5) - && (!n || s[5] == ' ' || s[5] == '\t' || s[5] == '\n')) - { - fputs ("\\fR\n.RE\n", fp); - } /* Now throw away the entire line. */ s = memchr (rest, '\n', len); return s? (s-rest)+1 : len; @@ -832,6 +828,14 @@ } line[--n] = 0; + if (n >= 5 && !memcmp (line, "@node", 5) + && (line[5]==' '||line[5]=='\t'||!line[5])) + { + /* Completey ignore @node lines. */ + continue; + } + + if (skip_sect_line) { skip_sect_line = 0; From cvs at cvs.gnupg.org Sun Sep 10 14:24:41 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Sun Sep 10 13:40:19 2006 Subject: [svn] assuan - r197 - in trunk: . src tests Message-ID: Author: wk Date: 2006-09-10 14:24:40 +0200 (Sun, 10 Sep 2006) New Revision: 197 Modified: trunk/NEWS trunk/src/ChangeLog trunk/src/assuan-defs.h trunk/src/assuan-logging.c trunk/src/assuan-util.c trunk/src/assuan.h trunk/tests/fdpassing.c Log: fixes Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-09-06 16:36:45 UTC (rev 196) +++ trunk/NEWS 2006-09-10 12:24:40 UTC (rev 197) @@ -13,6 +13,9 @@ If the new macro _ASSUAN_ONLY_GPG_ERRORS is defned all old definitions are excluded from assuan.h. + * Logging of hex strings is now limited to 16 bytes. To enable + printing of the full data, a new environment variable + ASSUAN_FULL_LOGGING may be set to any value. Noteworthy changes in version 0.6.10 (2005-06-20) ------------------------------------------------- Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2006-09-06 16:36:45 UTC (rev 196) +++ trunk/src/ChangeLog 2006-09-10 12:24:40 UTC (rev 197) @@ -1,3 +1,13 @@ +2006-09-10 Werner Koch + + * assuan-util.c (_assuan_log_print_buffer) + (_assuan_log_sanitized_string,assuan_set_log_stream): Moved to .. + * assuan-logging.c: .. here. + (_assuan_log_print_buffer): Only print the leading bytes in hex + log mode unless the new env variable ASSUAN_FULL_LOGGING has been + set. + (_assuan_set_default_log_stream): Test this env variable. + 2006-09-06 Werner Koch * assuan.h (_ASSUAN_ONLY_GPG_ERRORS): New. Modified: trunk/src/assuan-defs.h =================================================================== --- trunk/src/assuan-defs.h 2006-09-06 16:36:45 UTC (rev 196) +++ trunk/src/assuan-defs.h 2006-09-10 12:24:40 UTC (rev 197) @@ -237,9 +237,6 @@ #define set_error(c,e,t) \ assuan_set_error ((c), _assuan_error (ASSUAN_ ## e), (t)) -void _assuan_log_print_buffer (FILE *fp, const void *buffer, size_t length); -void _assuan_log_sanitized_string (const char *string); - #ifdef HAVE_W32_SYSTEM const char *_assuan_w32_strerror (int ec); #define w32_strerror(e) _assuan_w32_strerror ((e)) @@ -254,7 +251,10 @@ __attribute__ ((format (printf,1,2))) #endif ; +void _assuan_log_print_buffer (FILE *fp, const void *buffer, size_t length); +void _assuan_log_sanitized_string (const char *string); + /*-- assuan-io.c --*/ ssize_t _assuan_simple_read (ASSUAN_CONTEXT ctx, void *buffer, size_t size); ssize_t _assuan_simple_write (ASSUAN_CONTEXT ctx, const void *buffer, Modified: trunk/src/assuan-logging.c =================================================================== --- trunk/src/assuan-logging.c 2006-09-06 16:36:45 UTC (rev 196) +++ trunk/src/assuan-logging.c 2006-09-10 12:24:40 UTC (rev 197) @@ -23,23 +23,29 @@ #include #endif #include +#include #include #include #ifdef HAVE_W32_SYSTEM #include #endif /*HAVE_W32_SYSTEM*/ #include +#include #include "assuan-defs.h" static char prefix_buffer[80]; static FILE *_assuan_log; +static int full_logging; void _assuan_set_default_log_stream (FILE *fp) { if (!_assuan_log) - _assuan_log = fp; + { + _assuan_log = fp; + full_logging = !!getenv ("ASSUAN_FULL_LOGGING"); + } } void @@ -48,6 +54,22 @@ _assuan_log = fp; } + +/* Set the per context log stream. Also enable the default log stream + if it has not been set. */ +void +assuan_set_log_stream (assuan_context_t ctx, FILE *fp) +{ + if (ctx) + { + if (ctx->log_fp) + fflush (ctx->log_fp); + ctx->log_fp = fp; + _assuan_set_default_log_stream (fp); + } +} + + FILE * assuan_get_assuan_log_stream (void) { @@ -96,7 +118,113 @@ } +/* Dump a possibly binary string (used for debugging). Distinguish + ascii text from binary and print it accordingly. This function + takes FILE pointer arg becuase logging may be enabled on a per + context basis. */ +void +_assuan_log_print_buffer (FILE *fp, const void *buffer, size_t length) +{ + const unsigned char *s; + int n; + for (n=length,s=buffer; n; n--, s++) + if ((!isascii (*s) || iscntrl (*s) || !isprint (*s)) && !(*s >= 0x80)) + break; + + s = buffer; + if (!n && *s != '[') + fwrite (buffer, length, 1, fp); + else + { +#ifdef HAVE_FLOCKFILE + flockfile (fp); +#endif + putc_unlocked ('[', fp); + if ( length > 16 && !full_logging) + { + for (n=0; n < 12; n++, s++) + fprintf (fp, " %02x", *s); + fprintf (fp, " ...(%d bytes skipped)", (int)length - 12); + } + else + { + for (n=0; n < length; n++, s++) + fprintf (fp, " %02x", *s); + } + putc_unlocked (' ', fp); + putc_unlocked (']', fp); +#ifdef HAVE_FUNLOCKFILE + funlockfile (fp); +#endif + } +} + +/* Log a user supplied string. Escapes non-printable before + printing. */ +void +_assuan_log_sanitized_string (const char *string) +{ + const unsigned char *s = (const unsigned char *) string; + FILE *fp = assuan_get_assuan_log_stream (); + + if (! *s) + return; + +#ifdef HAVE_FLOCKFILE + flockfile (fp); +#endif + + for (; *s; s++) + { + int c = 0; + + switch (*s) + { + case '\r': + c = 'r'; + break; + + case '\n': + c = 'n'; + break; + + case '\f': + c = 'f'; + break; + + case '\v': + c = 'v'; + break; + + case '\b': + c = 'b'; + break; + + default: + if ((isascii (*s) && isprint (*s)) || (*s >= 0x80)) + putc_unlocked (*s, fp); + else + { + putc_unlocked ('\\', fp); + fprintf (fp, "x%02x", *s); + } + } + + if (c) + { + putc_unlocked ('\\', fp); + putc_unlocked (c, fp); + } + } + +#ifdef HAVE_FUNLOCKFILE + funlockfile (fp); +#endif +} + + + #ifdef HAVE_W32_SYSTEM const char * _assuan_w32_strerror (int ec) Modified: trunk/src/assuan-util.c =================================================================== --- trunk/src/assuan-util.c 2006-09-06 16:36:45 UTC (rev 196) +++ trunk/src/assuan-util.c 2006-09-10 12:24:40 UTC (rev 197) @@ -107,19 +107,6 @@ void -assuan_set_log_stream (assuan_context_t ctx, FILE *fp) -{ - if (ctx) - { - if (ctx->log_fp) - fflush (ctx->log_fp); - ctx->log_fp = fp; - _assuan_set_default_log_stream (fp); - } -} - - -void assuan_begin_confidential (assuan_context_t ctx) { if (ctx) @@ -167,97 +154,3 @@ } -/* Dump a possibly binary string (used for debugging). Distinguish - ascii text from binary and print it accordingly. */ -void -_assuan_log_print_buffer (FILE *fp, const void *buffer, size_t length) -{ - const unsigned char *s; - int n; - - for (n=length,s=buffer; n; n--, s++) - if ((!isascii (*s) || iscntrl (*s) || !isprint (*s)) && !(*s >= 0x80)) - break; - - s = buffer; - if (!n && *s != '[') - fwrite (buffer, length, 1, fp); - else - { -#ifdef HAVE_FLOCKFILE - flockfile (fp); -#endif - putc_unlocked ('[', fp); - for (n=0; n < length; n++, s++) - fprintf (fp, " %02x", *s); - putc_unlocked (' ', fp); - putc_unlocked (']', fp); -#ifdef HAVE_FUNLOCKFILE - funlockfile (fp); -#endif - } -} - -/* Log a user supplied string. Escapes non-printable before - printing. */ -void -_assuan_log_sanitized_string (const char *string) -{ - const unsigned char *s = (const unsigned char *) string; - FILE *fp = assuan_get_assuan_log_stream (); - - if (! *s) - return; - -#ifdef HAVE_FLOCKFILE - flockfile (fp); -#endif - - for (; *s; s++) - { - int c = 0; - - switch (*s) - { - case '\r': - c = 'r'; - break; - - case '\n': - c = 'n'; - break; - - case '\f': - c = 'f'; - break; - - case '\v': - c = 'v'; - break; - - case '\b': - c = 'b'; - break; - - default: - if ((isascii (*s) && isprint (*s)) || (*s >= 0x80)) - putc_unlocked (*s, fp); - else - { - putc_unlocked ('\\', fp); - fprintf (fp, "x%02x", *s); - } - } - - if (c) - { - putc_unlocked ('\\', fp); - putc_unlocked (c, fp); - } - } - -#ifdef HAVE_FUNLOCKFILE - funlockfile (fp); -#endif -} - Modified: trunk/src/assuan.h =================================================================== --- trunk/src/assuan.h 2006-09-06 16:36:45 UTC (rev 196) +++ trunk/src/assuan.h 2006-09-10 12:24:40 UTC (rev 197) @@ -430,9 +430,8 @@ const void *buffer, size_t length); /* The file descriptor must be pending before assuan_receivefd is - call. This means that assuan_sendfd should be called *before* the - trigger is sent (normally via assuan_send_data ("I sent you a - descriptor")). */ + 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); Modified: trunk/tests/fdpassing.c =================================================================== --- trunk/tests/fdpassing.c 2006-09-06 16:36:45 UTC (rev 196) +++ trunk/tests/fdpassing.c 2006-09-10 12:24:40 UTC (rev 197) @@ -42,7 +42,28 @@ static int cmd_echo (assuan_context_t ctx, char *line) { + int fd; + int c; + FILE *fp; + log_info ("got ECHO command (%s)\n", line); + + fd = assuan_get_input_fd (ctx); + if (fd == -1) + return ASSUAN_No_Input; + fp = fdopen (dup (fd), "r"); + if (!fp) + { + log_error ("fdopen failed on input fd: %s\n", strerror (errno)); + return ASSUAN_General_Error; + } + log_info ("printing input to stdout:\n"); + while ( (c=getc (fp)) != -1) + putc (c, stdout); + fflush (stdout); + log_info ("done printing input to stdout\n"); + + fclose (fp); return 0; } @@ -123,6 +144,8 @@ { int rc; assuan_context_t ctx; + FILE *fp; + int i; log_info ("client started on fd %d\n", fd); @@ -132,8 +155,38 @@ log_error ("assuan_domain_connect failed: %s\n", assuan_strerror (rc)); return -1; } - + fp = fopen ("/etc/motd", "r"); + if (!fp) + { + log_error ("failed to open `%s': %s\n", "/etc/motd", strerror (errno)); + return -1; + } + + rc = assuan_sendfd (ctx, fileno (fp)); + if (rc) + { + log_error ("assuan_sendfd failed: %s\n", assuan_strerror (rc)); + return -1; + } + + rc = assuan_transact (ctx, "INPUT FD", NULL, NULL, NULL, NULL, NULL, NULL); + if (rc) + { + log_error ("sending INPUT FD failed: %s\n", assuan_strerror (rc)); + return -1; + } + + + rc = assuan_transact (ctx, "ECHO", NULL, NULL, NULL, NULL, NULL, NULL); + if (rc) + { + log_error ("sending ECHO failed: %s\n", assuan_strerror (rc)); + return -1; + } + + sleep (100); + assuan_disconnect (ctx); return 0; } From cvs at cvs.gnupg.org Mon Sep 11 15:14:44 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon Sep 11 14:30:25 2006 Subject: [svn] dirmngr - r236 - in trunk: . po src Message-ID: Author: wk Date: 2006-09-11 15:14:42 +0200 (Mon, 11 Sep 2006) New Revision: 236 Removed: trunk/src/maperror.c Modified: trunk/ChangeLog trunk/NEWS trunk/autogen.sh trunk/configure.ac trunk/po/de.po trunk/po/dirmngr.pot trunk/src/ChangeLog trunk/src/Makefile.am trunk/src/dirmngr-client.c trunk/src/dirmngr.c trunk/src/server.c trunk/src/util.h Log: Replaced use of assuan error codes by gpg-error codes. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-09-04 16:56:45 UTC (rev 235) +++ trunk/ChangeLog 2006-09-11 13:14:42 UTC (rev 236) @@ -1,3 +1,9 @@ +2006-09-11 Werner Koch + + * configure.ac: Require libassuan 0.9.0. + (AH_BOTTOM): New. Move HAVE_JNLIB_LOGGING into it + and define _ASSUAN_ONLY_GPG_ERRORS. + 2006-09-04 Werner Koch Released 0.9.6. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-09-04 16:56:45 UTC (rev 235) +++ trunk/NEWS 2006-09-11 13:14:42 UTC (rev 236) @@ -1,3 +1,9 @@ +Noteworthy changes in version 0.9.7 +------------------------------------------------ + + * Internal cleanups. + + Noteworthy changes in version 0.9.6 (2006-09-04) ------------------------------------------------ Modified: trunk/autogen.sh =================================================================== --- trunk/autogen.sh 2006-09-04 16:56:45 UTC (rev 235) +++ trunk/autogen.sh 2006-09-11 13:14:42 UTC (rev 236) @@ -97,4 +97,4 @@ echo "Running autoconf..." $AUTOCONF -echo "You may now run \"./configure --enable-maintainer-mode && make\"." +echo "You may now run \"./configure --enable-maintainer-mode --sysconfdir=/etc && make\"." Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-09-04 16:56:45 UTC (rev 235) +++ trunk/configure.ac 2006-09-11 13:14:42 UTC (rev 236) @@ -23,14 +23,14 @@ AC_PREREQ(2.59) min_automake_version="1.9.3" -AC_INIT(dirmngr, 0.9.6, gpa-dev@gnupg.org) +AC_INIT(dirmngr, 0.9.7-cvs, gpa-dev@gnupg.org) -NEED_GPG_ERROR_VERSION=1.0 +NEED_GPG_ERROR_VERSION=1.4 NEED_LIBGCRYPT_API=1 NEED_LIBGCRYPT_VERSION=1.2.0 -NEED_LIBASSUAN_VERSION=0.6.8 +NEED_LIBASSUAN_VERSION=0.9.0 NEED_KSBA_API=1 NEED_KSBA_VERSION=1.0.0 @@ -329,12 +329,20 @@ fi fi -# We use jnlib, so tell other modules about it -AC_DEFINE(HAVE_JNLIB_LOGGING, 1, - [Defined if jnlib style logging fucntions are available]) +# +# Stuff which goes at the bottom of config.h. +# +AH_BOTTOM([ +/* We use jnlib, so tell other modules about it. */ +#define HAVE_JNLIB_LOGGING 1 +/* We don't want the old assuan codes anymore. */ +#define _ASSUAN_ONLY_GPG_ERRORS 1 +]) + + # # Print errors here so that they are visible all # together and the user can acquire them all together. Modified: trunk/po/de.po =================================================================== --- trunk/po/de.po 2006-09-04 16:56:45 UTC (rev 235) +++ trunk/po/de.po 2006-09-11 13:14:42 UTC (rev 236) @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: dirmngr 0.9.2\n" "Report-Msgid-Bugs-To: gpa-dev@gnupg.org\n" -"POT-Creation-Date: 2006-09-04 14:49+0200\n" +"POT-Creation-Date: 2006-09-11 14:27+0200\n" "PO-Revision-Date: 2006-09-04 14:59+0200\n" "Last-Translator: Werner Koch \n" "Language-Team: de\n" @@ -15,7 +15,7 @@ "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -#: jnlib/logging.c:609 +#: jnlib/logging.c:619 #, c-format msgid "you found a bug ... (%s:%d)\n" msgstr "Sie haben einen Bug (Softwarefehler) gefunden ... (%s:%d)\n" @@ -103,7 +103,7 @@ msgid " runtime cached certificates: %u\n" msgstr "zur Laufzeit zwischengespeicherte Zertifikate: %u\n" -#: src/certcache.c:480 src/dirmngr-client.c:365 +#: src/certcache.c:480 src/dirmngr-client.c:366 msgid "certificate already cached\n" msgstr "Zertifikat ist bereits im Zwischenspeicher\n" @@ -111,7 +111,7 @@ msgid "certificate cached\n" msgstr "Zertifikat wurde zwischengespeichert\n" -#: src/certcache.c:484 src/certcache.c:504 src/dirmngr-client.c:369 +#: src/certcache.c:484 src/certcache.c:504 src/dirmngr-client.c:370 #, c-format msgid "error caching certificate: %s\n" msgstr "Fehler beim Zwischenspeichern des Zertifikats: %s\n" @@ -233,7 +233,7 @@ msgid "unsupported record type in `%s' line %u skipped\n" msgstr "Nicht unterst?tzter Datensatztyp in `%s', Zeile %u ?bergangen\n" -#: src/crlcache.c:573 src/crlcache.c:802 src/dirmngr.c:1229 +#: src/crlcache.c:573 src/crlcache.c:802 src/dirmngr.c:1230 #, c-format msgid "error reading `%s': %s\n" msgstr "Fehler beim Lesen von `%s': %s\n" @@ -880,156 +880,156 @@ msgid "%s is too old (need %s, have %s)\n" msgstr "%s ist zu alt (ben?tige %s, habe %s)\n" -#: src/dirmngr.c:615 +#: src/dirmngr.c:616 #, c-format msgid "NOTE: no default option file `%s'\n" msgstr "Hinweis: Voreingestellte Optionendatei `%s' nicht vorhanden\n" -#: src/dirmngr.c:620 src/dirmngr.c:1286 +#: src/dirmngr.c:621 src/dirmngr.c:1287 #, c-format msgid "option file `%s': %s\n" msgstr "Optionendatei `%s': %s\n" -#: src/dirmngr.c:628 +#: src/dirmngr.c:629 #, c-format msgid "reading options from `%s'\n" msgstr "Optionen werden von `%s' gelesen\n" -#: src/dirmngr.c:728 +#: src/dirmngr.c:729 #, c-format msgid "WARNING: running with faked system time %s\n" msgstr "WARNUNG: Prozess l?uft mit get?rkter Systemzeit %s\n" -#: src/dirmngr.c:805 +#: src/dirmngr.c:806 msgid "colons are not allowed in the socket name\n" msgstr "Doppelpunkte sind im Namen des Sockets nicht erlaubt\n" -#: src/dirmngr.c:810 +#: src/dirmngr.c:811 msgid "name of socket too long\n" msgstr "Name des Sockets ist zu lang\n" -#: src/dirmngr.c:817 +#: src/dirmngr.c:818 #, c-format msgid "can't create socket: %s\n" msgstr "Fehler beim Erzeugen des Sockets: %s\n" -#: src/dirmngr.c:836 +#: src/dirmngr.c:837 #, c-format msgid "error binding socket to `%s': %s\n" msgstr "Fehler beim Binden des Sockets an `%s': %s\n" -#: src/dirmngr.c:845 +#: src/dirmngr.c:846 #, c-format msgid "listen() failed: %s\n" msgstr "listen() fehlgeschlagen: %s\n" -#: src/dirmngr.c:851 +#: src/dirmngr.c:852 #, c-format msgid "listening on socket `%s'\n" msgstr "Anfragen werden auf Socket `%s' engegengenommen\n" -#: src/dirmngr.c:857 +#: src/dirmngr.c:858 #, c-format msgid "fork failed: %s\n" msgstr "fork() fehlgeschlagen: %s\n" -#: src/dirmngr.c:875 +#: src/dirmngr.c:876 msgid "out of core\n" msgstr "Nicht gen?gend Hauptspeicher vorhanden\n" -#: src/dirmngr.c:914 +#: src/dirmngr.c:915 #, c-format msgid "setsid() failed: %s\n" msgstr "setsid() fehlgeschlagen: %s\n" -#: src/dirmngr.c:924 +#: src/dirmngr.c:925 #, c-format msgid "chdir to / failed: %s\n" msgstr "chdir nach / fehlgeschlagen: %s\n" -#: src/dirmngr.c:979 +#: src/dirmngr.c:980 #, c-format msgid "fetching CRL from `%s' failed: %s\n" msgstr "Holen der CRL von `%s' fehlgeschlagen: %s\n" -#: src/dirmngr.c:985 +#: src/dirmngr.c:986 #, c-format msgid "processing CRL from `%s' failed: %s\n" msgstr "Verarbeitung der CRL von `%s' fehlgeschlagen: %s\n" -#: src/dirmngr.c:1133 +#: src/dirmngr.c:1134 #, c-format msgid "error opening `%s': %s\n" msgstr "Fehler beim ?ffnen von `%s': %s\n" -#: src/dirmngr.c:1150 +#: src/dirmngr.c:1151 #, c-format msgid "%s:%u: line too long - skipped\n" msgstr "%s:%u: Zeile ist zu lang - ?bergangen\n" -#: src/dirmngr.c:1178 +#: src/dirmngr.c:1179 #, c-format msgid "%s:%u: no hostname given\n" msgstr "%s:%u: Kein Hostname angegeben\n" -#: src/dirmngr.c:1197 +#: src/dirmngr.c:1198 #, c-format msgid "%s:%u: password given without user\n" msgstr "%s:%u: Passwort angegeben ohne Username\n" -#: src/dirmngr.c:1218 +#: src/dirmngr.c:1219 #, c-format msgid "%s:%u: skipping this line\n" msgstr "%s:%u: Diese Zeile wird ?bersprungen\n" -#: src/dirmngr.c:1318 +#: src/dirmngr.c:1319 msgid "SIGHUP received - re-reading configuration and flushing caches\n" msgstr "" "SIGHUP empfangen - lese die Konfiguration erneut und l?sche die " "Zwischenspeicher\n" -#: src/dirmngr.c:1332 +#: src/dirmngr.c:1333 msgid "SIGUSR2 received - no action defined\n" msgstr "SIGUSR2 empfangen - keine Aktion definiert\n" -#: src/dirmngr.c:1337 +#: src/dirmngr.c:1338 msgid "SIGTERM received - shutting down ...\n" msgstr "SIGTERM empfangen - wird heruntergefahren ...\n" -#: src/dirmngr.c:1339 +#: src/dirmngr.c:1340 #, c-format msgid "SIGTERM received - still %d active connections\n" msgstr "SIGTERM empfangen - immer noch %d Verbindungen aktiv\n" -#: src/dirmngr.c:1344 +#: src/dirmngr.c:1345 msgid "shutdown forced\n" msgstr "Herunterfahren wurde erzwungen\n" -#: src/dirmngr.c:1352 +#: src/dirmngr.c:1353 msgid "SIGINT received - immediate shutdown\n" msgstr "SIGINT empfangen - wird sofort heruntergefahren\n" -#: src/dirmngr.c:1359 +#: src/dirmngr.c:1360 #, c-format msgid "signal %d received - no action defined\n" msgstr "Signal %d empfangen - keine Aktion definiert\n" -#: src/dirmngr.c:1373 +#: src/dirmngr.c:1374 #, c-format msgid "handler for fd %d started\n" msgstr "Routine f?r fd %d gestartet\n" -#: src/dirmngr.c:1378 +#: src/dirmngr.c:1379 #, c-format msgid "handler for fd %d terminated\n" msgstr "Routine f?r fd %d beendet\n" -#: src/dirmngr.c:1434 +#: src/dirmngr.c:1435 #, c-format msgid "accept failed: %s - waiting 1s\n" msgstr "accept() fehlgeschlagen: %s - warte 1s\n" -#: src/dirmngr.c:1441 +#: src/dirmngr.c:1442 #, c-format msgid "error spawning connection handler: %s\n" msgstr "Fehler beim Starten des Verbindungshandler: %s\n" @@ -1326,71 +1326,71 @@ msgid "OCSP responder returned a non-current status\n" msgstr "OCSP Responder gab einen nicht aktuellen Status zur?ck\n" -#: src/server.c:132 src/server.c:244 +#: src/server.c:111 src/server.c:223 #, c-format msgid "assuan_inquire(%s) failed: %s\n" msgstr "assuan_inquire(%s) fehlgeschlagen: %s\n" -#: src/server.c:377 +#: src/server.c:355 msgid "serialno missing in cert ID" msgstr "Seriennummer fehlt in der Cert-ID" -#: src/server.c:428 src/server.c:544 src/server.c:623 src/server.c:781 -#: src/server.c:809 src/server.c:833 src/server.c:886 src/server.c:955 +#: src/server.c:406 src/server.c:520 src/server.c:597 src/server.c:753 +#: src/server.c:781 src/server.c:805 src/server.c:856 src/server.c:923 #, c-format msgid "command %s failed: %s\n" msgstr "Kommando %s fehlgeschlagen: %s\n" -#: src/server.c:514 src/server.c:596 src/server.c:865 src/server.c:918 +#: src/server.c:491 src/server.c:571 src/server.c:836 src/server.c:887 #, c-format msgid "assuan_inquire failed: %s\n" msgstr "assuan_inquire fehlgeschlagen: %s\n" -#: src/server.c:700 +#: src/server.c:673 #, c-format msgid "start_cert_fetch failed: %s\n" msgstr "start_cert_fetch fehlgeschlagen: %s\n" -#: src/server.c:733 +#: src/server.c:706 #, c-format msgid "fetch_next_cert failed: %s\n" msgstr "fetch_next_cert fehlgeschlagen: %s\n" -#: src/server.c:752 +#: src/server.c:725 #, c-format msgid "error sending data: %s\n" msgstr "Fehler beim Senden der Daten: %s\n" -#: src/server.c:761 +#: src/server.c:733 #, c-format msgid "max_replies %d exceeded\n" msgstr "max_replies %d ?berschritten\n" -#: src/server.c:829 +#: src/server.c:801 msgid "no data stream" msgstr "Kein Datenstrom" -#: src/server.c:1008 +#: src/server.c:976 #, c-format msgid "can't allocate control structure: %s\n" msgstr "Fehler beim Erzeugen der Kontrollstruktur: %s\n" -#: src/server.c:1031 +#: src/server.c:999 #, c-format msgid "failed to initialize the server: %s\n" msgstr "Fehler beim Initialisieren des Servers: %s\n" -#: src/server.c:1039 +#: src/server.c:1007 #, c-format msgid "failed to the register commands with Assuan: %s\n" msgstr "Fehler beim Registrieren der Kommandos gegen Assuan: %s\n" -#: src/server.c:1059 +#: src/server.c:1027 #, c-format msgid "Assuan accept problem: %s\n" msgstr "Assuan accept Problem: %s\n" -#: src/server.c:1066 +#: src/server.c:1034 #, c-format msgid "Assuan processing failed: %s\n" msgstr "Assuan Verarbeitung fehlgeschlagen: %s\n" @@ -1591,94 +1591,94 @@ "The Prozess gibt 0 zur?ck wenn das Zertifikat g?ltig ist, 1 wenn es nicht\n" "g?ltig ist und weitere Werte bei anderen Fehlern.\n" -#: src/dirmngr-client.c:265 src/dirmngr-client.c:970 +#: src/dirmngr-client.c:266 src/dirmngr-client.c:970 #, c-format msgid "error reading certificate from stdin: %s\n" msgstr "Fehler beim Lesen des Zertifikats von der Standardeingabe: %s\n" -#: src/dirmngr-client.c:272 +#: src/dirmngr-client.c:273 #, c-format msgid "error reading certificate from `%s': %s\n" msgstr "Fehler beim Lesen des Zertifikats von `%s': %s\n" -#: src/dirmngr-client.c:286 +#: src/dirmngr-client.c:287 msgid "certificate too large to make any sense\n" msgstr "Zertifikat ist zu gro? um Sinnvoll zu sein\n" -#: src/dirmngr-client.c:312 +#: src/dirmngr-client.c:313 #, c-format msgid "lookup failed: %s\n" msgstr "Aufsuchen fehlgeschlagen: %s\n" -#: src/dirmngr-client.c:327 +#: src/dirmngr-client.c:328 #, c-format msgid "loading CRL `%s' failed: %s\n" msgstr "Laden der CRL von `%s' fehlgeschlagen: %s\n" -#: src/dirmngr-client.c:355 +#: src/dirmngr-client.c:356 msgid "a dirmngr daemon is up and running\n" msgstr "Ein dirmngr ist vorhanden und aktiv\n" -#: src/dirmngr-client.c:377 +#: src/dirmngr-client.c:378 #, c-format msgid "validation of certificate failed: %s\n" msgstr "Pr?fung des Zertifikats fehlgeschlagen: %s\n" -#: src/dirmngr-client.c:384 src/dirmngr-client.c:981 +#: src/dirmngr-client.c:385 src/dirmngr-client.c:981 msgid "certificate is valid\n" msgstr "Zertifikat ist g?ltig\n" -#: src/dirmngr-client.c:390 src/dirmngr-client.c:989 +#: src/dirmngr-client.c:391 src/dirmngr-client.c:989 msgid "certificate has been revoked\n" msgstr "Zertifikat wurde widerrufen\n" -#: src/dirmngr-client.c:395 src/dirmngr-client.c:991 +#: src/dirmngr-client.c:396 src/dirmngr-client.c:991 #, c-format msgid "certificate check failed: %s\n" msgstr "Zertifikatpr?fung fehlgeschlagen: %s\n" -#: src/dirmngr-client.c:406 +#: src/dirmngr-client.c:407 #, c-format msgid "got status: `%s'\n" msgstr "Erhielt Status: `%s'\n" -#: src/dirmngr-client.c:421 +#: src/dirmngr-client.c:422 #, c-format msgid "error writing base64 encoding: %s\n" msgstr "Fehler beim Schreiben der Base-64 Darstellung: %s\n" -#: src/dirmngr-client.c:453 +#: src/dirmngr-client.c:454 msgid "apparently no running dirmngr\n" msgstr "Offensichtlich ist kein Dirmngr vorhanden\n" -#: src/dirmngr-client.c:458 +#: src/dirmngr-client.c:459 msgid "no running dirmngr - starting one\n" msgstr "Dirmngr l?uft nicht - ein neuer wird gestartet\n" -#: src/dirmngr-client.c:491 +#: src/dirmngr-client.c:492 msgid "malformed DIRMNGR_INFO environment variable\n" msgstr "Fehlerhafte DIRMNGR_INFO Variable\n" -#: src/dirmngr-client.c:506 +#: src/dirmngr-client.c:507 #, c-format msgid "dirmngr protocol version %d is not supported\n" msgstr "Dirmngr Protocol Version %d wird nicht unterst?tzt\n" -#: src/dirmngr-client.c:522 +#: src/dirmngr-client.c:523 msgid "can't connect to the dirmngr - trying fall back\n" msgstr "Verbindung zum Dirmngr nicht m?glich - R?ckfallmethode wird versucht\n" -#: src/dirmngr-client.c:530 +#: src/dirmngr-client.c:531 #, c-format msgid "can't connect to the dirmngr: %s\n" msgstr "Verbindung zum Dirmngr nicht m?glich: %s\n" -#: src/dirmngr-client.c:779 +#: src/dirmngr-client.c:780 #, c-format msgid "unsupported inquiry `%s'\n" msgstr "Nicht unterst?tzte INQUIRY `%s'\n" -#: src/dirmngr-client.c:875 +#: src/dirmngr-client.c:876 msgid "absolute file name expected\n" msgstr "Absoluter Dateiname erwartet\n" Modified: trunk/po/dirmngr.pot =================================================================== --- trunk/po/dirmngr.pot 2006-09-04 16:56:45 UTC (rev 235) +++ trunk/po/dirmngr.pot 2006-09-11 13:14:42 UTC (rev 236) @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: gpa-dev@gnupg.org\n" -"POT-Creation-Date: 2006-09-04 14:49+0200\n" +"POT-Creation-Date: 2006-09-11 14:27+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -16,7 +16,7 @@ "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: jnlib/logging.c:609 +#: jnlib/logging.c:619 #, c-format msgid "you found a bug ... (%s:%d)\n" msgstr "" @@ -100,7 +100,7 @@ msgid " runtime cached certificates: %u\n" msgstr "" -#: src/certcache.c:480 src/dirmngr-client.c:365 +#: src/certcache.c:480 src/dirmngr-client.c:366 msgid "certificate already cached\n" msgstr "" @@ -108,7 +108,7 @@ msgid "certificate cached\n" msgstr "" -#: src/certcache.c:484 src/certcache.c:504 src/dirmngr-client.c:369 +#: src/certcache.c:484 src/certcache.c:504 src/dirmngr-client.c:370 #, c-format msgid "error caching certificate: %s\n" msgstr "" @@ -225,7 +225,7 @@ msgid "unsupported record type in `%s' line %u skipped\n" msgstr "" -#: src/crlcache.c:573 src/crlcache.c:802 src/dirmngr.c:1229 +#: src/crlcache.c:573 src/crlcache.c:802 src/dirmngr.c:1230 #, c-format msgid "error reading `%s': %s\n" msgstr "" @@ -834,154 +834,154 @@ msgid "%s is too old (need %s, have %s)\n" msgstr "" -#: src/dirmngr.c:615 +#: src/dirmngr.c:616 #, c-format msgid "NOTE: no default option file `%s'\n" msgstr "" -#: src/dirmngr.c:620 src/dirmngr.c:1286 +#: src/dirmngr.c:621 src/dirmngr.c:1287 #, c-format msgid "option file `%s': %s\n" msgstr "" -#: src/dirmngr.c:628 +#: src/dirmngr.c:629 #, c-format msgid "reading options from `%s'\n" msgstr "" -#: src/dirmngr.c:728 +#: src/dirmngr.c:729 #, c-format msgid "WARNING: running with faked system time %s\n" msgstr "" -#: src/dirmngr.c:805 +#: src/dirmngr.c:806 msgid "colons are not allowed in the socket name\n" msgstr "" -#: src/dirmngr.c:810 +#: src/dirmngr.c:811 msgid "name of socket too long\n" msgstr "" -#: src/dirmngr.c:817 +#: src/dirmngr.c:818 #, c-format msgid "can't create socket: %s\n" msgstr "" -#: src/dirmngr.c:836 +#: src/dirmngr.c:837 #, c-format msgid "error binding socket to `%s': %s\n" msgstr "" -#: src/dirmngr.c:845 +#: src/dirmngr.c:846 #, c-format msgid "listen() failed: %s\n" msgstr "" -#: src/dirmngr.c:851 +#: src/dirmngr.c:852 #, c-format msgid "listening on socket `%s'\n" msgstr "" -#: src/dirmngr.c:857 +#: src/dirmngr.c:858 #, c-format msgid "fork failed: %s\n" msgstr "" -#: src/dirmngr.c:875 +#: src/dirmngr.c:876 msgid "out of core\n" msgstr "" -#: src/dirmngr.c:914 +#: src/dirmngr.c:915 #, c-format msgid "setsid() failed: %s\n" msgstr "" -#: src/dirmngr.c:924 +#: src/dirmngr.c:925 #, c-format msgid "chdir to / failed: %s\n" msgstr "" -#: src/dirmngr.c:979 +#: src/dirmngr.c:980 #, c-format msgid "fetching CRL from `%s' failed: %s\n" msgstr "" -#: src/dirmngr.c:985 +#: src/dirmngr.c:986 #, c-format msgid "processing CRL from `%s' failed: %s\n" msgstr "" -#: src/dirmngr.c:1133 +#: src/dirmngr.c:1134 #, c-format msgid "error opening `%s': %s\n" msgstr "" -#: src/dirmngr.c:1150 +#: src/dirmngr.c:1151 #, c-format msgid "%s:%u: line too long - skipped\n" msgstr "" -#: src/dirmngr.c:1178 +#: src/dirmngr.c:1179 #, c-format msgid "%s:%u: no hostname given\n" msgstr "" -#: src/dirmngr.c:1197 +#: src/dirmngr.c:1198 #, c-format msgid "%s:%u: password given without user\n" msgstr "" -#: src/dirmngr.c:1218 +#: src/dirmngr.c:1219 #, c-format msgid "%s:%u: skipping this line\n" msgstr "" -#: src/dirmngr.c:1318 +#: src/dirmngr.c:1319 msgid "SIGHUP received - re-reading configuration and flushing caches\n" msgstr "" -#: src/dirmngr.c:1332 +#: src/dirmngr.c:1333 msgid "SIGUSR2 received - no action defined\n" msgstr "" -#: src/dirmngr.c:1337 +#: src/dirmngr.c:1338 msgid "SIGTERM received - shutting down ...\n" msgstr "" -#: src/dirmngr.c:1339 +#: src/dirmngr.c:1340 #, c-format msgid "SIGTERM received - still %d active connections\n" msgstr "" -#: src/dirmngr.c:1344 +#: src/dirmngr.c:1345 msgid "shutdown forced\n" msgstr "" -#: src/dirmngr.c:1352 +#: src/dirmngr.c:1353 msgid "SIGINT received - immediate shutdown\n" msgstr "" -#: src/dirmngr.c:1359 +#: src/dirmngr.c:1360 #, c-format msgid "signal %d received - no action defined\n" msgstr "" -#: src/dirmngr.c:1373 +#: src/dirmngr.c:1374 #, c-format msgid "handler for fd %d started\n" msgstr "" -#: src/dirmngr.c:1378 +#: src/dirmngr.c:1379 #, c-format msgid "handler for fd %d terminated\n" msgstr "" -#: src/dirmngr.c:1434 +#: src/dirmngr.c:1435 #, c-format msgid "accept failed: %s - waiting 1s\n" msgstr "" -#: src/dirmngr.c:1441 +#: src/dirmngr.c:1442 #, c-format msgid "error spawning connection handler: %s\n" msgstr "" @@ -1277,71 +1277,71 @@ msgid "OCSP responder returned a non-current status\n" msgstr "" -#: src/server.c:132 src/server.c:244 +#: src/server.c:111 src/server.c:223 #, c-format msgid "assuan_inquire(%s) failed: %s\n" msgstr "" -#: src/server.c:377 +#: src/server.c:355 msgid "serialno missing in cert ID" msgstr "" -#: src/server.c:428 src/server.c:544 src/server.c:623 src/server.c:781 -#: src/server.c:809 src/server.c:833 src/server.c:886 src/server.c:955 +#: src/server.c:406 src/server.c:520 src/server.c:597 src/server.c:753 +#: src/server.c:781 src/server.c:805 src/server.c:856 src/server.c:923 #, c-format msgid "command %s failed: %s\n" msgstr "" -#: src/server.c:514 src/server.c:596 src/server.c:865 src/server.c:918 +#: src/server.c:491 src/server.c:571 src/server.c:836 src/server.c:887 #, c-format msgid "assuan_inquire failed: %s\n" msgstr "" -#: src/server.c:700 +#: src/server.c:673 #, c-format msgid "start_cert_fetch failed: %s\n" msgstr "" -#: src/server.c:733 +#: src/server.c:706 #, c-format msgid "fetch_next_cert failed: %s\n" msgstr "" -#: src/server.c:752 +#: src/server.c:725 #, c-format msgid "error sending data: %s\n" msgstr "" -#: src/server.c:761 +#: src/server.c:733 #, c-format msgid "max_replies %d exceeded\n" msgstr "" -#: src/server.c:829 +#: src/server.c:801 msgid "no data stream" msgstr "" -#: src/server.c:1008 +#: src/server.c:976 #, c-format msgid "can't allocate control structure: %s\n" msgstr "" -#: src/server.c:1031 +#: src/server.c:999 #, c-format msgid "failed to initialize the server: %s\n" msgstr "" -#: src/server.c:1039 +#: src/server.c:1007 #, c-format msgid "failed to the register commands with Assuan: %s\n" msgstr "" -#: src/server.c:1059 +#: src/server.c:1027 #, c-format msgid "Assuan accept problem: %s\n" msgstr "" -#: src/server.c:1066 +#: src/server.c:1034 #, c-format msgid "Assuan processing failed: %s\n" msgstr "" @@ -1528,94 +1528,94 @@ "not valid and other error codes for general failures\n" msgstr "" -#: src/dirmngr-client.c:265 src/dirmngr-client.c:970 +#: src/dirmngr-client.c:266 src/dirmngr-client.c:970 #, c-format msgid "error reading certificate from stdin: %s\n" msgstr "" -#: src/dirmngr-client.c:272 +#: src/dirmngr-client.c:273 #, c-format msgid "error reading certificate from `%s': %s\n" msgstr "" -#: src/dirmngr-client.c:286 +#: src/dirmngr-client.c:287 msgid "certificate too large to make any sense\n" msgstr "" -#: src/dirmngr-client.c:312 +#: src/dirmngr-client.c:313 #, c-format msgid "lookup failed: %s\n" msgstr "" -#: src/dirmngr-client.c:327 +#: src/dirmngr-client.c:328 #, c-format msgid "loading CRL `%s' failed: %s\n" msgstr "" -#: src/dirmngr-client.c:355 +#: src/dirmngr-client.c:356 msgid "a dirmngr daemon is up and running\n" msgstr "" -#: src/dirmngr-client.c:377 +#: src/dirmngr-client.c:378 #, c-format msgid "validation of certificate failed: %s\n" msgstr "" -#: src/dirmngr-client.c:384 src/dirmngr-client.c:981 +#: src/dirmngr-client.c:385 src/dirmngr-client.c:981 msgid "certificate is valid\n" msgstr "" -#: src/dirmngr-client.c:390 src/dirmngr-client.c:989 +#: src/dirmngr-client.c:391 src/dirmngr-client.c:989 msgid "certificate has been revoked\n" msgstr "" -#: src/dirmngr-client.c:395 src/dirmngr-client.c:991 +#: src/dirmngr-client.c:396 src/dirmngr-client.c:991 #, c-format msgid "certificate check failed: %s\n" msgstr "" -#: src/dirmngr-client.c:406 +#: src/dirmngr-client.c:407 #, c-format msgid "got status: `%s'\n" msgstr "" -#: src/dirmngr-client.c:421 +#: src/dirmngr-client.c:422 #, c-format msgid "error writing base64 encoding: %s\n" msgstr "" -#: src/dirmngr-client.c:453 +#: src/dirmngr-client.c:454 msgid "apparently no running dirmngr\n" msgstr "" -#: src/dirmngr-client.c:458 +#: src/dirmngr-client.c:459 msgid "no running dirmngr - starting one\n" msgstr "" -#: src/dirmngr-client.c:491 +#: src/dirmngr-client.c:492 msgid "malformed DIRMNGR_INFO environment variable\n" msgstr "" -#: src/dirmngr-client.c:506 +#: src/dirmngr-client.c:507 #, c-format msgid "dirmngr protocol version %d is not supported\n" msgstr "" -#: src/dirmngr-client.c:522 +#: src/dirmngr-client.c:523 msgid "can't connect to the dirmngr - trying fall back\n" msgstr "" -#: src/dirmngr-client.c:530 +#: src/dirmngr-client.c:531 #, c-format msgid "can't connect to the dirmngr: %s\n" msgstr "" -#: src/dirmngr-client.c:779 +#: src/dirmngr-client.c:780 #, c-format msgid "unsupported inquiry `%s'\n" msgstr "" -#: src/dirmngr-client.c:875 +#: src/dirmngr-client.c:876 msgid "absolute file name expected\n" msgstr "" Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2006-09-04 16:56:45 UTC (rev 235) +++ trunk/src/ChangeLog 2006-09-11 13:14:42 UTC (rev 236) @@ -1,3 +1,11 @@ +2006-09-11 Werner Koch + + Changed everything to use Assuan with gpg-error codes. + * maperror.c: Removed. + * server.c (map_to_assuan_status): Removed. + * dirmngr.c (main): Set assuan error source. + * dirmngr-client.c (main): Ditto. + 2006-09-04 Werner Koch * crlfetch.c (crl_fetch): Implement HTTP redirection. Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2006-09-04 16:56:45 UTC (rev 235) +++ trunk/src/Makefile.am 2006-09-11 13:14:42 UTC (rev 236) @@ -40,7 +40,7 @@ dirmngr_SOURCES = \ dirmngr.c dirmngr.h server.c crlcache.c crlfetch.c \ - certcache.c certcache.h i18n.h util.h maperror.c \ + certcache.c certcache.h i18n.h util.h \ cdb.h cdblib.c ldap.c http.c http.h misc.c ocsp.c ocsp.h \ validate.c validate.h @@ -53,11 +53,11 @@ dirmngr_ldap_CFLAGS = $(GPG_ERROR_CFLAGS) dirmngr_ldap_LDFLAGS = dirmngr_ldap_LDADD = ../jnlib/libjnlib.a $(LIBOBJS) $(GPG_ERROR_LIBS) \ - $(LDAPLIBS) @LIBINTL@ @LIBICONV@ + $(LDAPLIBS) $(LIBINTL) $(LIBICONV) -dirmngr_client_SOURCES = dirmngr-client.c i18n.h util.h b64enc.c maperror.c \ +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) \ - $(GPG_ERROR_LIBS) @LIBINTL@ @LIBICONV@ + $(GPG_ERROR_LIBS) $(LIBINTL) $(LIBICONV) Modified: trunk/src/dirmngr-client.c =================================================================== --- trunk/src/dirmngr-client.c 2006-09-04 16:56:45 UTC (rev 235) +++ trunk/src/dirmngr-client.c 2006-09-11 13:14:42 UTC (rev 236) @@ -197,6 +197,7 @@ /* Init Assuan. */ assuan_set_assuan_log_stream (log_get_stream ()); assuan_set_assuan_log_prefix (log_get_prefix (NULL)); + assuan_set_assuan_err_source (GPG_ERR_SOURCE_DEFAULT); /* Setup I18N. */ i18n_init(); @@ -399,7 +400,7 @@ /* Print status line from the assuan protocol. */ -static assuan_error_t +static int status_cb (void *opaque, const char *line) { if (opt.verbose > 2) @@ -408,7 +409,7 @@ } /* Print data as retrieved by the lookup function. */ -static assuan_error_t +static int data_cb (void *opaque, const void *buffer, size_t length) { gpg_error_t err; @@ -475,7 +476,7 @@ no_close_list[i] = -1; /* Connect to the agent and perform initial handshaking. */ - rc = assuan_pipe_connect (&ctx, opt.dirmngr_program, (char**)argv, + rc = assuan_pipe_connect (&ctx, opt.dirmngr_program, argv, no_close_list); } else /* Connect to a daemon. */ @@ -517,7 +518,7 @@ rc = assuan_socket_connect (&ctx, infostr, pid); xfree (infostr); - if (rc == ASSUAN_Connect_Failed && !only_daemon) + if (gpg_err_code(rc) == GPG_ERR_ASS_CONNECT_FAILED && !only_daemon) { log_error (_("can't connect to the dirmngr - trying fall back\n")); opt.force_pipe_server = 1; @@ -528,7 +529,7 @@ if (rc) { log_error (_("can't connect to the dirmngr: %s\n"), - assuan_strerror (rc)); + gpg_strerror (rc)); return NULL; } @@ -744,47 +745,47 @@ /* Callback for the inquire fiunction to send back the certificate. */ -static assuan_error_t +static int inq_cert (void *opaque, const char *line) { struct inq_cert_parm_s *parm = opaque; - assuan_error_t ae; + gpg_error_t err; if (!strncmp (line, "TARGETCERT", 10) && (line[10] == ' ' || !line[10])) { - ae = assuan_send_data (parm->ctx, parm->cert, parm->certlen); + err = assuan_send_data (parm->ctx, parm->cert, parm->certlen); } else if (!strncmp (line, "SENDCERT", 8) && (line[8] == ' ' || !line[8])) { /* We don't support this but dirmngr might ask for it. So simply ignore it by sending back and empty value. */ - ae = assuan_send_data (parm->ctx, NULL, 0); + err = assuan_send_data (parm->ctx, NULL, 0); } else if (!strncmp (line, "SENDCERT_SKI", 12) && (line[12]==' ' || !line[12])) { /* We don't support this but dirmngr might ask for it. So simply ignore it by sending back an empty value. */ - ae = assuan_send_data (parm->ctx, NULL, 0); + err = assuan_send_data (parm->ctx, NULL, 0); } else if (!strncmp (line, "SENDISSUERCERT", 14) && (line[14] == ' ' || !line[14])) { /* We don't support this but dirmngr might ask for it. So simply ignore it by sending back an empty value. */ - ae = assuan_send_data (parm->ctx, NULL, 0); + err = assuan_send_data (parm->ctx, NULL, 0); } else { log_info (_("unsupported inquiry `%s'\n"), line); - ae = ASSUAN_Inquire_Unknown; + err = gpg_error (GPG_ERR_ASS_UNKNOWN_INQUIRE); /* Note that this error will let assuan_transact terminate immediately instead of return the error to the caller. It is not clear whether this is the desired behaviour - it may change in future. */ } - return ae; + return err; } @@ -793,7 +794,7 @@ static gpg_error_t do_check (assuan_context_t ctx, const unsigned char *cert, size_t certlen) { - assuan_error_t ae; + gpg_error_t err; struct inq_cert_parm_s parm; memset (&parm, 0, sizeof parm); @@ -801,12 +802,12 @@ parm.cert = cert; parm.certlen = certlen; - ae = assuan_transact (ctx, opt.use_ocsp? "CHECKOCSP":"CHECKCRL", NULL, NULL, + err = assuan_transact (ctx, opt.use_ocsp? "CHECKOCSP":"CHECKCRL", NULL, NULL, inq_cert, &parm, status_cb, NULL); if (opt.verbose > 1) - log_info ("response of dirmngr: %s\n", ae? assuan_strerror (ae): "okay"); - return map_assuan_err (ae); + log_info ("response of dirmngr: %s\n", err? gpg_strerror (err): "okay"); + return err; } /* Check the certificate CERT,CERTLEN for validity using a CRL or OCSP. @@ -814,7 +815,7 @@ static gpg_error_t do_cache (assuan_context_t ctx, const unsigned char *cert, size_t certlen) { - assuan_error_t ae; + gpg_error_t err; struct inq_cert_parm_s parm; memset (&parm, 0, sizeof parm); @@ -822,12 +823,12 @@ parm.cert = cert; parm.certlen = certlen; - ae = assuan_transact (ctx, "CACHECERT", NULL, NULL, + err = assuan_transact (ctx, "CACHECERT", NULL, NULL, inq_cert, &parm, status_cb, NULL); if (opt.verbose > 1) - log_info ("response of dirmngr: %s\n", ae? assuan_strerror (ae): "okay"); - return map_assuan_err (ae); + log_info ("response of dirmngr: %s\n", err? gpg_strerror (err): "okay"); + return err; } /* Check the certificate CERT,CERTLEN for validity using dirmngrs @@ -835,7 +836,7 @@ static gpg_error_t do_validate (assuan_context_t ctx, const unsigned char *cert, size_t certlen) { - assuan_error_t ae; + gpg_error_t err; struct inq_cert_parm_s parm; memset (&parm, 0, sizeof parm); @@ -843,19 +844,19 @@ parm.cert = cert; parm.certlen = certlen; - ae = assuan_transact (ctx, "VALIDATE", NULL, NULL, + err = assuan_transact (ctx, "VALIDATE", NULL, NULL, inq_cert, &parm, status_cb, NULL); if (opt.verbose > 1) - log_info ("response of dirmngr: %s\n", ae? assuan_strerror (ae): "okay"); - return map_assuan_err (ae); + log_info ("response of dirmngr: %s\n", err? gpg_strerror (err): "okay"); + return err; } /* Load a CRL into the dirmngr. */ static gpg_error_t do_loadcrl (assuan_context_t ctx, const char *filename) { - assuan_error_t ae; + gpg_error_t err; const char *s; char *fname, *line, *p; @@ -892,14 +893,14 @@ } *p = 0; - ae = assuan_transact (ctx, line, NULL, NULL, + err = assuan_transact (ctx, line, NULL, NULL, NULL, NULL, status_cb, NULL); if (opt.verbose > 1) - log_info ("response of dirmngr: %s\n", ae? assuan_strerror (ae): "okay"); + log_info ("response of dirmngr: %s\n", err? gpg_strerror (err): "okay"); xfree (line); xfree (fname); - return map_assuan_err (ae); + return err; } @@ -909,7 +910,6 @@ do_lookup (assuan_context_t ctx, const char *pattern) { gpg_error_t err; - assuan_error_t ae; const unsigned char *s; char *line, *p; struct b64state state; @@ -939,17 +939,17 @@ *p = 0; - ae = assuan_transact (ctx, line, - data_cb, &state, - NULL, NULL, - status_cb, NULL); + err = assuan_transact (ctx, line, + data_cb, &state, + NULL, NULL, + status_cb, NULL); if (opt.verbose > 1) - log_info ("response of dirmngr: %s\n", ae? assuan_strerror (ae): "okay"); + log_info ("response of dirmngr: %s\n", err? gpg_strerror (err): "okay"); err = b64enc_finish (&state); xfree (line); - return ae? map_assuan_err (ae) : err; + return err; } /* The body of an endless loop: Read a line from stdin, retrieve the Modified: trunk/src/dirmngr.c =================================================================== --- trunk/src/dirmngr.c 2006-09-04 16:56:45 UTC (rev 235) +++ trunk/src/dirmngr.c 2006-09-11 13:14:42 UTC (rev 236) @@ -527,6 +527,7 @@ assuan_set_malloc_hooks (gcry_malloc, gcry_realloc, gcry_free); assuan_set_assuan_log_stream (log_get_stream ()); assuan_set_assuan_log_prefix (log_get_prefix (NULL)); + assuan_set_assuan_err_source (GPG_ERR_SOURCE_DEFAULT); /* Setup I18N. */ i18n_init(); Deleted: trunk/src/maperror.c Modified: trunk/src/server.c =================================================================== --- trunk/src/server.c 2006-09-04 16:56:45 UTC (rev 235) +++ trunk/src/server.c 2006-09-11 13:14:42 UTC (rev 236) @@ -45,40 +45,19 @@ something reasonable. */ #define MAX_CERT_LENGTH (8*1024) -#define PARM_ERROR(t) assuan_set_error (ctx, ASSUAN_Parameter_Error, (t)) +#define PARM_ERROR(t) assuan_set_error (ctx, \ + gpg_error (GPG_ERR_ASS_PARAMETER), (t)) /* Data used to associate an Assuan context with local server data */ -struct server_local_s { - ASSUAN_CONTEXT assuan_ctx; +struct server_local_s +{ + assuan_context_t assuan_ctx; }; -/* Map GPG_ERR_xx error codes to Assuan status codes */ -static int -map_to_assuan_status (int rc) -{ - gpg_err_code_t ec = gpg_err_code (rc); - gpg_err_source_t es = gpg_err_source (rc); - if (!rc) - return 0; - if (!es) - { - es = GPG_ERR_SOURCE_USER_4; /* This should not happen, but we - need to make sure to pass a new - Assuan error code along. */ - log_debug ("map_to_assuan_status called with no error source\n"); - } - if (ec == -1) - ec = GPG_ERR_NO_DATA; /* That used to be ASSUAN_No_Data_Available. */ - - return gpg_err_make (es, ec); -} - - - /* Copy the % and + escaped string S into the buffer D and replace the escape sequences. Note, that it is sufficient to allocate the target string D as long as the source string S, i.e.: strlen(s)+1. @@ -130,7 +109,7 @@ if (rc) { log_error (_("assuan_inquire(%s) failed: %s\n"), - command, assuan_strerror (rc)); + command, gpg_strerror (rc)); return NULL; } @@ -242,7 +221,7 @@ if (rc) { log_error (_("assuan_inquire(%s) failed: %s\n"), "SENDCERT_SKI", - assuan_strerror (rc)); + gpg_strerror (rc)); return NULL; } @@ -277,14 +256,13 @@ { ctrl_t ctrl = assuan_get_pointer (ctx); gpg_error_t err; - assuan_error_t ae; unsigned char *value = NULL; size_t valuelen; ksba_cert_t cert = NULL; - ae = assuan_inquire( ctx, "SENDCERT", &value, &valuelen, 0); - if (ae) - return map_assuan_err (ae); + err = assuan_inquire( ctx, "SENDCERT", &value, &valuelen, 0); + if (err) + return err; /* { */ /* FILE *fp = fopen ("foo.der", "r"); */ @@ -315,7 +293,7 @@ /* Handle OPTION commands. */ static int -option_handler (ASSUAN_CONTEXT ctx, const char *key, const char *value) +option_handler (assuan_context_t ctx, const char *key, const char *value) { ctrl_t ctrl = assuan_get_pointer (ctx); @@ -325,7 +303,7 @@ ctrl->force_crl_refresh = i; } else - return ASSUAN_Invalid_Option; + return gpg_error (GPG_ERR_UNKNOWN_OPTION); return 0; } @@ -427,7 +405,7 @@ if (err) log_error (_("command %s failed: %s\n"), "ISVALID", gpg_strerror (err)); xfree (issuerhash); - return map_to_assuan_status (err); + return err; } @@ -503,16 +481,14 @@ { /* We do not have this certificate yet or the fingerprint has not been given. Inquire it from the client. */ - assuan_error_t ae; unsigned char *value = NULL; size_t valuelen; - ae = assuan_inquire (ctrl->server_local->assuan_ctx, "TARGETCERT", + err = assuan_inquire (ctrl->server_local->assuan_ctx, "TARGETCERT", &value, &valuelen, MAX_CERT_LENGTH); - if (ae) + if (err) { - log_error (_("assuan_inquire failed: %s\n"), assuan_strerror (ae)); - err = map_assuan_err (ae); + log_error (_("assuan_inquire failed: %s\n"), gpg_strerror (err)); goto leave; } @@ -543,7 +519,7 @@ if (err) log_error (_("command %s failed: %s\n"), "CHECKCRL", gpg_strerror (err)); ksba_cert_release (cert); - return map_to_assuan_status (err); + return err; } @@ -585,16 +561,14 @@ { /* We do not have this certificate yet or the fingerprint has not been given. Inquire it from the client. */ - assuan_error_t ae; unsigned char *value = NULL; size_t valuelen; - ae = assuan_inquire (ctrl->server_local->assuan_ctx, "TARGETCERT", + err = assuan_inquire (ctrl->server_local->assuan_ctx, "TARGETCERT", &value, &valuelen, MAX_CERT_LENGTH); - if (ae) + if (err) { - log_error (_("assuan_inquire failed: %s\n"), assuan_strerror (ae)); - err = map_assuan_err (ae); + log_error (_("assuan_inquire failed: %s\n"), gpg_strerror (err)); goto leave; } @@ -622,7 +596,7 @@ if (err) log_error (_("command %s failed: %s\n"), "CHECKOCSP", gpg_strerror (err)); ksba_cert_release (cert); - return map_to_assuan_status (err); + return err; } @@ -640,7 +614,6 @@ { ctrl_t ctrl = assuan_get_pointer (ctx); gpg_error_t err = 0; - assuan_error_t ae; char *p; strlist_t sl, list = NULL; int truncated = 0, truncation_forced = 0; @@ -742,15 +715,14 @@ /* Send the data, flush the buffer and then send an END line as a certificate delimiter. */ - ae = assuan_send_data (ctx, value, valuelen); - if (!ae) - ae = assuan_send_data (ctx, NULL, 0); - if (!ae) - ae = assuan_write_line (ctx, "END"); - if (ae) + err = assuan_send_data (ctx, value, valuelen); + if (!err) + err = assuan_send_data (ctx, NULL, 0); + if (!err) + err = assuan_write_line (ctx, "END"); + if (err) { - log_error (_("error sending data: %s\n"), assuan_strerror (ae)); - err = map_assuan_err (ae); + log_error (_("error sending data: %s\n"), gpg_strerror (err)); end_cert_fetch (fetch_context); goto leave; } @@ -780,7 +752,7 @@ if (err) log_error (_("command %s failed: %s\n"), "LOOKUP", gpg_strerror (err)); free_strlist (list); - return map_to_assuan_status (err); + return err; } @@ -807,7 +779,7 @@ xfree (buf); if (err) log_error (_("command %s failed: %s\n"), "LOADCRL", gpg_strerror (err)); - return map_to_assuan_status (err); + return err; } @@ -831,7 +803,7 @@ err = crl_cache_list (fp); if (err) log_error (_("command %s failed: %s\n"), "LISTCRLS", gpg_strerror (err)); - return map_to_assuan_status (err); + return err; } @@ -854,16 +826,14 @@ ctrl_t ctrl = assuan_get_pointer (ctx); gpg_error_t err; ksba_cert_t cert = NULL; - assuan_error_t ae; unsigned char *value = NULL; size_t valuelen; - ae = assuan_inquire (ctrl->server_local->assuan_ctx, "TARGETCERT", + err = assuan_inquire (ctrl->server_local->assuan_ctx, "TARGETCERT", &value, &valuelen, MAX_CERT_LENGTH); - if (ae) + if (err) { - log_error (_("assuan_inquire failed: %s\n"), assuan_strerror (ae)); - err = map_assuan_err (ae); + log_error (_("assuan_inquire failed: %s\n"), gpg_strerror (err)); goto leave; } @@ -885,7 +855,7 @@ if (err) log_error (_("command %s failed: %s\n"), "CACHECERT", gpg_strerror (err)); ksba_cert_release (cert); - return map_to_assuan_status (err); + return err; } @@ -907,16 +877,14 @@ ctrl_t ctrl = assuan_get_pointer (ctx); gpg_error_t err; ksba_cert_t cert = NULL; - assuan_error_t ae; unsigned char *value = NULL; size_t valuelen; - ae = assuan_inquire (ctrl->server_local->assuan_ctx, "TARGETCERT", + err = assuan_inquire (ctrl->server_local->assuan_ctx, "TARGETCERT", &value, &valuelen, MAX_CERT_LENGTH); - if (ae) + if (err) { - log_error (_("assuan_inquire failed: %s\n"), assuan_strerror (ae)); - err = map_assuan_err (ae); + log_error (_("assuan_inquire failed: %s\n"), gpg_strerror (err)); goto leave; } @@ -954,18 +922,18 @@ if (err) log_error (_("command %s failed: %s\n"), "VALIDATE", gpg_strerror (err)); ksba_cert_release (cert); - return map_to_assuan_status (err); + return err; } /* Tell the assuan library about our commands. */ static int -register_commands (ASSUAN_CONTEXT ctx) +register_commands (assuan_context_t ctx) { static struct { const char *name; - int (*handler)(ASSUAN_CONTEXT, char *line); + int (*handler)(assuan_context_t, char *line); } table[] = { { "ISVALID", cmd_isvalid }, { "CHECKCRL", cmd_checkcrl }, @@ -1029,7 +997,7 @@ if (rc) { log_error (_("failed to initialize the server: %s\n"), - assuan_strerror(rc)); + gpg_strerror(rc)); dirmngr_exit (2); } @@ -1037,7 +1005,7 @@ if (rc) { log_error (_("failed to the register commands with Assuan: %s\n"), - assuan_strerror(rc)); + gpg_strerror(rc)); dirmngr_exit (2); } assuan_set_hello_line (ctx, "Dirmngr " VERSION " at your service"); @@ -1056,14 +1024,14 @@ break; if (rc) { - log_info (_("Assuan accept problem: %s\n"), assuan_strerror (rc)); + log_info (_("Assuan accept problem: %s\n"), gpg_strerror (rc)); break; } rc = assuan_process (ctx); if (rc) { - log_info (_("Assuan processing failed: %s\n"), assuan_strerror (rc)); + log_info (_("Assuan processing failed: %s\n"), gpg_strerror (rc)); continue; } } @@ -1116,7 +1084,7 @@ *p++ = *text++; } *p = 0; - err = map_assuan_err (assuan_write_status (ctx, keyword, buf)); + err = assuan_write_status (ctx, keyword, buf); } va_end (arg_ptr); Modified: trunk/src/util.h =================================================================== --- trunk/src/util.h 2006-09-04 16:56:45 UTC (rev 235) +++ trunk/src/util.h 2006-09-11 13:14:42 UTC (rev 236) @@ -50,10 +50,8 @@ -/*-- maperror.c --*/ -gpg_error_t map_assuan_err (int err); + - /* Handy malloc macros - use only them. */ #define xtrymalloc(a) gcry_malloc ((a)) #define xtrycalloc(a,b) gcry_calloc ((a),(b)) From cvs at cvs.gnupg.org Mon Sep 11 15:15:49 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon Sep 11 14:31:12 2006 Subject: [svn] assuan - r198 - in trunk: doc src Message-ID: Author: wk Date: 2006-09-11 15:15:48 +0200 (Mon, 11 Sep 2006) New Revision: 198 Modified: trunk/doc/assuan.texi trunk/src/assuan-client.c trunk/src/assuan.h Log: Added stuff to the manual. Minor prototype cleanups. Modified: trunk/doc/assuan.texi =================================================================== --- trunk/doc/assuan.texi 2006-09-10 12:24:40 UTC (rev 197) +++ trunk/doc/assuan.texi 2006-09-11 13:15:48 UTC (rev 198) @@ -3,7 +3,7 @@ @setfilename assuan.info @macro copyrightnotice -Copyright @copyright{} 2002, 2003 Free Software Foundation, Inc. +Copyright @copyright{} 2002, 2003, 2006 Free Software Foundation, Inc. @end macro @macro permissionnotice Permission is granted to copy, distribute and/or modify this document @@ -26,6 +26,11 @@ @syncodeindex pg cp @syncodeindex tp cp +@c A simple macro for optional variables. +@macro ovar{varname} +@r{[}@var{\varname\}@r{]} +@end macro + @c printing stuff taken from gcc. @macro gnupgtabopt{body} @code{\body\} @@ -106,6 +111,11 @@ * Introduction:: An introduction to and the motivation behind Assuan. * Assuan:: Description of the Assuan protocol. * Implementation:: Overview of the implementation. +* Preparation:: What you should do before using the library. +* Generalities:: Initialization code and data types used. +* Client code:: How to develop an Assuan client. +* Server code:: How to develop an Assuan server. +* Utilities:: Utility functions. Miscellaneous @@ -115,13 +125,14 @@ Indices -* Option Index:: Index to command line options. * Index:: Index of concepts and symbol names. @end menu - +@c +@c I N T R O +@c @node Introduction @chapter Introduction to Assuan @@ -414,7 +425,249 @@ maps libgpg-error codes into this range. +@c +@c P R E P A R A T I O N +@c +@node Preparation +@chapter Preparation +To use `@sc{libassuan}', you have to perform some changes to your +sources and the build system. The necessary changes are small and +explained in the following sections. + + +@menu +* Header:: What header file you need to include. +* Building sources:: How to build sources using the library. +* Automake:: How to build sources with the help of Automake. +* Multi Threading:: How @sc{libassuan} can be used in a MT environment. +@end menu + +@node Header +@section Header + +All interfaces (data types and functions) of @sc{libassuan} are defined +in the header file @file{assuan.h}. You must include this in all source +files using the library, either directly or through some other header +file, like this: + +@example +#include +@end example + +The name space of `@sc{assuan}' is @code{assuan_*} for function +and type names and @code{ASSUAN*} for other symbols. In addition the +same name prefixes with one prepended underscore are reserved for +internal use and should never be used by an application. + +@node Building sources +@section Building sources + +If you want to compile a source file including the @file{assuan.h} +header file, you must make sure that the compiler can find it in the +directory hierarchy. This is accomplished by adding the path to the +directory in which the header file is located to the compilers include +file search path (via the @option{-I} option). + +However, the path to the include file is determined at the time the +source is configured. To solve this problem, @sc{libgcrypt} ships with +a small helper program @command{libassuan-config} that knows the path to +the include file and other configuration options. The options that need +to be added to the compiler invocation at compile time are output by the +@option{--cflags} option to @command{libassuan-config}. The following +example shows how it can be used at the command line: + +@example +gcc -c foo.c $(libassuan-config --cflags) +@end example + +Adding the output of @samp{libassuan-config --cflags} to the compiler's +command line will ensure that the compiler can find the @file{assuan.h} +header file. + +A similar problem occurs when linking the program with the library. +Again, the compiler/linker has to find the library files. For this to +work, the path to the library files has to be added to the library +search path (via the @option{-L} option). For this, the option +@option{--libs} to @command{libassuan-config} can be used. For +convenience, this option also outputs all other options that are +required to link the program with the @sc{libassuan} libraries (in +particular, the @option{-lassuan} option). The example shows how to +link @file{foo.o} with the @sc{libassuan} library to a program +@command{foo}. + +@example +gcc -o foo foo.o $(libassuan-config --libs) +@end example + +Of course you can also combine both examples to a single command by +specifying both options to @command{libassuan-config}: + +@example +gcc -o foo foo.c $(libassuan-config --cflags --libs) +@end example + +@node Automake +@section Building sources using Automake + +It is much easier if you use GNU Automake instead of writing your own +Makefiles. If you do that you do not have to worry about finding and +invoking the @command{libassuan-config} script at all. @sc{libassuan} +provides an Automake macro that does all the work for you. + +@defmac AM_PATH_LIBASSUAN (@ovar{minimum-version}, @ovar{action-if-found}, @ovar{action-if-not-found}) +Check whether @sc{libassuan} (at least version @var{minimum-version}, if +given) exists on the host system. If it is found, execute +@var{action-if-found}, otherwise do @var{action-if-not-found}, if given. + +Additionally, the function defines @code{LIBASSUAN_CFLAGS} to the +flags needed for compilation of the program to find the +@file{assuan.h} header file, and @code{LIBASSUAN_LIBS} to the linker +flags needed to link the program to the @sc{libassuan} library. +@end defmac + +You can use the defined Autoconf variables like this in your +@file{Makefile.am}: + +@example +AM_CPPFLAGS = $(LIBASSUAN_CFLAGS) +LDADD = $(LIBASSUAN_LIBS) +@end example + + +@node Multi Threading +@section Multi Threading + +The @sc{libgcrypt} library is thread-safe if you adhere to the following +requirements: + +@itemize @bullet +@item Run the initialization functions before you actually start +to use threads. +@item Only one thread at a time may access an @sc{libassuan} context. +@item Use @code{assuan_set_assuan_log_stream} to setup a default log stream. +@end itemize + + +@c +@c G E N E R A L I T I E S +@c +@node Generalities +@chapter Generalities + +@menu +* Data Types:: Data types used by @sc{libassuan}. +* Initializing the library:: How to initialize the library. +@end menu + + + +@node Data Types +@section Data Types used by the library + +@sc{libassuan} uses a context approach to keep state. The following +data type is used all over the palce: + +@deftp {Data type} assuan_context_t +The @code{assuan_context_t} type is a pointer to an object mainted +internally by the library. Certain assuan fucntions allocate such a +context and return it to the caller using this data type. Other +functions take this data type to access the state created by these +functions. +@end deftp + +For compatibility with older versions of @sc{libassuan} a data +type for error return values exists: + +@deftp {Data type} assuan_error_t +This has orginally been an @code{enum} but applications should either +view it as an @code{int} or if possible use the @code{gpg_error_t} data +type as defined by the @sc{libgpg-error} package. +@end deftp + + +@node Initializing the library +@section Initializing the library + +In general the library requires no initialization. There are however +some initialization hooks provided which aren often useful. These +should be called as early as possible and in a multi-threaded +application before a second thread is created. + +If your application uses its own memory allocation functions or wrappers +it is good idea to tell @sc{libassuan} about it so it can make use of the +same functions or wrappers. You do this with + +@deftypefun void assuan_set_malloc_hooks (@w{void *(*@var{malloc_func})(size_t)}, @w{void *(*@var{realloc_func})(void *, size_t)}, @w{void (*@var{free_func})(void*)}) +You need to provide all three functions. Those functions need to behave +exactly as their standard counterparts (@code{malloc}, @code{realloc} +and @code{free}). If you write your own functions please take care to +set @code{errno} whenever an error has occured. +@end deftypefun + +To integrate assuan logging and diagnostics into your own logging +system, you may use the following two functions: + +@deftypefun void assuan_set_assuan_log_stream (FILE *@var{fp}) +This sets the stream to which @sc{libassuan} should log messages not +associated with a specific context to @var{fp}. The default is to log +to @code{stderr}. This default value is also changed by using +@code{assuan_set_log_stream} (to set a logging stream for a specific +context) unless this function has been used. Obviously this is not +thread-asfe and thus it is highly recommended to use this function to +setup a proper default. +@end deftypefun + +@deftypefun void assuan_set_assuan_log_prefix (const char *@var{text}) +Set the prefix to be used at the start of a line emitted by assuan +on the log stream to @var{text}. The default is the empty string. +@end deftypefun + +If you intend to use @sc{libassuan} along with the package +@sc{libgpg-error} it is recommended to switch @sc{libassuan} into a mode +which directly makes use of error codes provided by @sc{libgpg-error}. +Because the Assuan error codes and those of gpg-error overlap, it is +required to explictly request this. You do this by calling the function + +@deftypefun void assuan_set_assuan_err_source (int @var{errsource}) +Enable gpg-error style error codes. @var{errsource} is one of the +gpg-error sources. Switching back to the old style mode is not +possible. The usual way to call this function is +@smallexample +assuan_set_assuan_err_source (GPG_ERR_SOURCE_DEFAULT); +@end smallexample +@end deftypefun + +@c +@c C L I E N T C O D E +@c +@node Client code +@chapter How to develop an Assuan client + +foo + + +@c +@c S E R V E R C O D E +@c +@node Server code +@chapter How to develop an Assuan server + +bar + +@c +@c U T I L I T I E S +@c +@node Utilities +@chapter Utility functions + +baz + + +@c --------------------------------------------------------------------- +@c Legal BS +@c --------------------------------------------------------------------- + @include lgpl.texi @include gpl.texi @@ -423,11 +676,6 @@ @c Indexes @c --------------------------------------------------------------------- -@node Option Index -@unnumbered Option Index - -@printindex op - @node Index @unnumbered Index Modified: trunk/src/assuan-client.c =================================================================== --- trunk/src/assuan-client.c 2006-09-10 12:24:40 UTC (rev 197) +++ trunk/src/assuan-client.c 2006-09-11 13:15:48 UTC (rev 198) @@ -132,11 +132,11 @@ assuan_error_t assuan_transact (ASSUAN_CONTEXT ctx, const char *command, - assuan_error_t (*data_cb)(void *, const void *, size_t), + int (*data_cb)(void *, const void *, size_t), void *data_cb_arg, - assuan_error_t (*inquire_cb)(void*, const char *), + int (*inquire_cb)(void*, const char *), void *inquire_cb_arg, - assuan_error_t (*status_cb)(void*, const char *), + int (*status_cb)(void*, const char *), void *status_cb_arg) { int rc, okay, off; Modified: trunk/src/assuan.h =================================================================== --- trunk/src/assuan.h 2006-09-10 12:24:40 UTC (rev 197) +++ trunk/src/assuan.h 2006-09-11 13:15:48 UTC (rev 198) @@ -408,11 +408,11 @@ assuan_error_t assuan_transact (assuan_context_t ctx, const char *command, - assuan_error_t (*data_cb)(void *, const void *, size_t), + int (*data_cb)(void *, const void *, size_t), void *data_cb_arg, - assuan_error_t (*inquire_cb)(void*, const char *), + int (*inquire_cb)(void*, const char *), void *inquire_cb_arg, - assuan_error_t (*status_cb)(void*, const char *), + int (*status_cb)(void*, const char *), void *status_cb_arg); From cvs at cvs.gnupg.org Tue Sep 12 13:07:19 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue Sep 12 12:22:44 2006 Subject: [svn] assuan - r199 - in trunk: . src tests Message-ID: Author: wk Date: 2006-09-12 13:07:18 +0200 (Tue, 12 Sep 2006) New Revision: 199 Added: trunk/src/assuan-uds.c Removed: trunk/src/assuan-domain-connect.c trunk/src/assuan-domain-server.c Modified: trunk/NEWS trunk/TODO trunk/src/ChangeLog trunk/src/Makefile.am trunk/src/assuan-defs.h trunk/src/assuan-handler.c trunk/src/assuan-io.c trunk/src/assuan-pipe-connect.c trunk/src/assuan-pipe-server.c trunk/src/assuan-socket-server.c trunk/src/assuan.h trunk/tests/fdpassing.c Log: Integrated descriptor passing. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-09-11 13:15:48 UTC (rev 198) +++ trunk/NEWS 2006-09-12 11:07:18 UTC (rev 199) @@ -17,6 +17,11 @@ printing of the full data, a new environment variable ASSUAN_FULL_LOGGING may be set to any value. + * Removed the assuan_domain fucntions. Added new function + assuan_pipe_connect_ext to allow connections on a socketpair and to + pass descriptors. + + Noteworthy changes in version 0.6.10 (2005-06-20) ------------------------------------------------- Modified: trunk/TODO =================================================================== --- trunk/TODO 2006-09-11 13:15:48 UTC (rev 198) +++ trunk/TODO 2006-09-12 11:07:18 UTC (rev 199) @@ -13,3 +13,4 @@ * Check the system error to assuan error translation * Do a configure test for SO_PEERCRED. We already use HAVE_SO_PEERCRED buty it never gets defined. +* Replace assuan_pipe_connect2 by assuan_pipe_connect. \ No newline at end of file Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2006-09-11 13:15:48 UTC (rev 198) +++ trunk/src/ChangeLog 2006-09-12 11:07:18 UTC (rev 199) @@ -1,3 +1,35 @@ +2006-09-12 Werner Koch + + * assuan-defs.h (DIM, DIMof): New. + + * assuan-domain-server.c: Removed. + * assuan-domain-connect.c: Renamed to .. + * assuan-uds.c: this. + (domain_reader, domain_writer, domain_sendfd, domain_receivefd) + (assuan_domain_connect, _assuan_domain_init): Removed. + (uds_reader, uds_writer, uds_sendfd, uds_receivefd) + (_assuan_init_uds_io): New. + (_assuan_uds_deinit): New. + + * assuan-io.c (_assuan_simple_sendmsg, _assuan_simple_recvmsg): New. + (my_pth_fdmode, my_pth_select): New. + +2006-09-11 Werner Koch + + * assuan-pipe-server.c (assuan_init_pipe_server): Allow for + FILEDES to be NULL and try to start as a socketpair server in this + case. + + * assuan-pipe-connect.c (assuan_pipe_connect2): Split up into two + functions (unix and w32) for clarity. + (pipe_connect_unix): This is the new fucntion. Add USE_CMSG flag. + (pipe_connect_w32): Ditto. + (initial_handshake): Factored out code. + (socketpair_connect): New. + (assuan_pipe_connect_ext): New. + (do_finish): Handle case if outbound and inbound fd are the same. + This is to support socketpairs. + 2006-09-10 Werner Koch * assuan-util.c (_assuan_log_print_buffer) Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2006-09-11 13:15:48 UTC (rev 198) +++ trunk/src/Makefile.am 2006-09-12 11:07:18 UTC (rev 199) @@ -46,9 +46,8 @@ assuan-socket-server.c \ assuan-pipe-connect.c \ assuan-socket-connect.c \ + assuan-uds.c \ assuan-io.c \ - assuan-domain-connect.c \ - assuan-domain-server.c \ assuan-logging.c \ assuan-socket.c Modified: trunk/src/assuan-defs.h =================================================================== --- trunk/src/assuan-defs.h 2006-09-11 13:15:48 UTC (rev 198) +++ trunk/src/assuan-defs.h 2006-09-12 11:07:18 UTC (rev 199) @@ -106,7 +106,7 @@ char *hello_line; char *okay_line; /* See assuan_set_okay_line() */ - void *user_pointer; /* For assuan_get_pointer and assuan-set_pointer (). */ + void *user_pointer; /* For assuan_get_pointer and assuan_set_pointer (). */ FILE *log_fp; @@ -116,7 +116,7 @@ char line[LINELENGTH]; int linelen; /* w/o CR, LF - might not be the same as strlen(line) due to embedded nuls. However a nul - is always written at this pos */ + is always written at this pos. */ struct { char line[LINELENGTH]; int linelen ; @@ -135,7 +135,7 @@ } outbound; int pipe_mode; /* We are in pipe mode, i.e. we can handle just one - connection and must terminate then */ + 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 */ @@ -144,19 +144,19 @@ /* Used for Unix domain sockets. */ struct sockaddr_un myaddr; struct sockaddr_un serveraddr; - /* When reading from datagram sockets, we must read an entire - message at a time. This means that we have to do our own - buffering to be able to get the semantics of read. */ - void *domainbuffer; - /* Offset of start of buffer. */ - int domainbufferoffset; - /* Bytes buffered. */ - int domainbuffersize; - /* Memory allocated. */ - int domainbufferallocated; - int *pendingfds; - int pendingfdscount; + /* Structure used for unix domain socket buffering. FIXME: We don't + use datagrams anymore thus we could get away with a simpler + buffering approach. */ + struct { + void *buffer; /* Malloced buffer. */ + int bufferallocated; /* Memory allocated. */ + int bufferoffset; /* Offset of start of buffer. */ + int buffersize; /* Bytes buffered. */ + + int pendingfds[5]; /* Array to save received descriptors. */ + int pendingfdscount; /* Number of received descriptors. */ + } uds; void (*deinit_handler)(ASSUAN_CONTEXT); int (*accept_handler)(ASSUAN_CONTEXT); @@ -184,14 +184,11 @@ int _assuan_new_context (ASSUAN_CONTEXT *r_ctx); void _assuan_release_context (ASSUAN_CONTEXT ctx); -/*-- assuan-domain-connect.c --*/ -/* Make a connection to the Unix domain socket NAME and return a new - Assuan context in CTX. SERVER_PID is currently not used but may - become handy in the future. */ -assuan_error_t _assuan_domain_init (ASSUAN_CONTEXT *r_ctx, - int rendezvousfd, - pid_t peer); +/*-- assuan-uds.c --*/ +void _assuan_uds_deinit (assuan_context_t ctx); +void _assuan_init_uds_io (assuan_context_t ctx); + /*-- assuan-handler.c --*/ int _assuan_register_std_commands (ASSUAN_CONTEXT ctx); @@ -259,6 +256,8 @@ ssize_t _assuan_simple_read (ASSUAN_CONTEXT ctx, void *buffer, size_t size); ssize_t _assuan_simple_write (ASSUAN_CONTEXT ctx, const void *buffer, size_t size); +ssize_t _assuan_simple_sendmsg (assuan_context_t ctx, struct msghdr *msg); +ssize_t _assuan_simple_recvmsg (assuan_context_t ctx, struct msghdr *msg); /*-- assuan-socket.c --*/ int _assuan_close (int fd); @@ -290,4 +289,9 @@ int setenv (const char *name, const char *value, int replace); #endif + +#define DIM(v) (sizeof(v)/sizeof((v)[0])) +#define DIMof(type,member) DIM(((type *)0)->member) + + #endif /*ASSUAN_DEFS_H*/ Deleted: trunk/src/assuan-domain-connect.c Deleted: trunk/src/assuan-domain-server.c Modified: trunk/src/assuan-handler.c =================================================================== --- trunk/src/assuan-handler.c 2006-09-11 13:15:48 UTC (rev 198) +++ trunk/src/assuan-handler.c 2006-09-12 11:07:18 UTC (rev 199) @@ -479,7 +479,7 @@ rc = assuan_write_line (ctx, ctx->okay_line? ctx->okay_line : "OK"); } else if (err_is_eof (rc)) - { /* No error checking because the peer may have already disconnect */ + { /* No error checking because the peer may have already disconnect. */ assuan_write_line (ctx, "OK closing connection"); ctx->finish_handler (ctx); } Modified: trunk/src/assuan-io.c =================================================================== --- trunk/src/assuan-io.c 2006-09-11 13:15:48 UTC (rev 198) +++ trunk/src/assuan-io.c 2006-09-12 11:07:18 UTC (rev 199) @@ -1,5 +1,5 @@ /* assuan-io.c - Wraps the read and write functions. - * Copyright (C) 2002, 2004 Free Software Foundation, Inc. + * Copyright (C) 2002, 2004, 2006 Free Software Foundation, Inc. * * This file is part of Assuan. * @@ -23,23 +23,69 @@ #include #endif -#include "assuan-defs.h" #include +#include +#if HAVE_SYS_UIO_H +#include +#endif #include +#include #ifdef HAVE_W32_SYSTEM #include #endif +#include "assuan-defs.h" + +/* We can't include pth.h and we are not sure whether other headers + already included it. This we define macros with the same + values. */ +#define MY_PTH_FDMODE_ERROR (-1) +#define MY_PTH_FDMODE_POLL 0 +#define MY_PTH_FDMODE_BLOCK 1 +#define MY_PTH_FDMODE_NONBLOCK 2 + + #ifndef _ASSUAN_NO_PTH extern ssize_t pth_read (int fd, void *buffer, size_t size); extern ssize_t pth_write (int fd, const void *buffer, size_t size); +extern int pth_fdmode (int, int); +extern int pth_select(int, fd_set*, fd_set*, fd_set*, struct timeval*); #ifndef HAVE_W32_SYSTEM #pragma weak pth_read #pragma weak pth_write +#pragma weak pth_fdmode +#pragma weak pth_select #endif #endif /*!_ASSUAN_NO_PTH*/ +#ifndef _ASSUAN_NO_PTH +/* Wrapper around pth_fdmode. */ +static int +my_pth_fdmode (int fd, int mode) +{ + if (pth_fdmode) + return pth_fdmode (fd, mode); + else + return MY_PTH_FDMODE_NONBLOCK; /* This is okay, given the way we use it. */ +} +#endif /*_ASSUAN_NO_PTH*/ + +#ifndef _ASSUAN_NO_PTH +/* Wrapper around pth_select. */ +static int +my_pth_select (int nfd, fd_set *rfds, fd_set *wfds, fd_set *efds, + struct timeval *timeout) +{ + if (pth_select) + return pth_select (nfd, rfds, wfds, efds, timeout); + else + return 1; /* Fake one fd ready; this is okay, given the way we use it. */ +} +#endif /*_ASSUAN_NO_PTH*/ + + + ssize_t _assuan_simple_read (assuan_context_t ctx, void *buffer, size_t size) { @@ -69,3 +115,87 @@ # endif #endif } + + +ssize_t +_assuan_simple_sendmsg (assuan_context_t ctx, struct msghdr *msg) +{ +#if defined(HAVE_W32_SYSTEM) + return _assuan_error (ASSUAN_Not_Implemented); +#elif defined(_ASSUAN_NO_PTH) + int ret; + while ( (ret = sendmsg (ctx->outbound.fd, msg, 0)) == -1 && errno == EINTR) + ; + return ret; +#else + /* Pth does not provide a sendmsg function. Thus we implement it here. */ + int ret; + int fd = ctx->outbound.fd; + int fdmode; + + fdmode = my_pth_fdmode (fd, MY_PTH_FDMODE_POLL); + if (fdmode == MY_PTH_FDMODE_ERROR) + { + errno = EBADF; + return -1; + } + if (fdmode == MY_PTH_FDMODE_BLOCK) + { + fd_set fds; + + FD_ZERO (&fds); + FD_SET (fd, &fds); + while ( (ret = my_pth_select (fd+1, NULL, &fds, NULL, NULL)) < 0 + && errno == EINTR) + ; + if (ret < 0) + return -1; + } + + while ((ret = sendmsg (fd, msg, 0)) == -1 && errno == EINTR) + ; + return ret; +#endif +} + + +ssize_t +_assuan_simple_recvmsg (assuan_context_t ctx, struct msghdr *msg) +{ +#if defined(HAVE_W32_SYSTEM) + return _assuan_error (ASSUAN_Not_Implemented); +#elif defined(_ASSUAN_NO_PTH) + int ret; + while ( (ret = recvmsg (ctx->inbound.fd, msg, 0)) == -1 && errno == EINTR) + ; + return ret; +#else + /* Pth does not provide a recvmsg function. Thus we implement it here. */ + int ret; + int fd = ctx->inbound.fd; + int fdmode; + + fdmode = my_pth_fdmode (fd, MY_PTH_FDMODE_POLL); + if (fdmode == MY_PTH_FDMODE_ERROR) + { + errno = EBADF; + return -1; + } + if (fdmode == MY_PTH_FDMODE_BLOCK) + { + fd_set fds; + + FD_ZERO (&fds); + FD_SET (fd, &fds); + while ( (ret = my_pth_select (fd+1, &fds, NULL, NULL, NULL)) < 0 + && errno == EINTR) + ; + if (ret < 0) + return -1; + } + + while ((ret = recvmsg (fd, msg, 0)) == -1 && errno == EINTR) + ; + return ret; +#endif +} Modified: trunk/src/assuan-pipe-connect.c =================================================================== --- trunk/src/assuan-pipe-connect.c 2006-09-11 13:15:48 UTC (rev 198) +++ trunk/src/assuan-pipe-connect.c 2006-09-12 11:07:18 UTC (rev 199) @@ -1,5 +1,5 @@ /* assuan-pipe-connect.c - Establish a pipe connection (client) - * Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. + * Copyright (C) 2001, 2002, 2003, 2005, 2006 Free Software Foundation, Inc. * * This file is part of Assuan. * @@ -112,6 +112,8 @@ if (ctx->inbound.fd != -1) { _assuan_close (ctx->inbound.fd); + if (ctx->inbound.fd == ctx->outbound.fd) + ctx->outbound.fd = -1; ctx->inbound.fd = -1; } if (ctx->outbound.fd != -1) @@ -139,6 +141,402 @@ } +/* Helper for pipe_connect. */ +static assuan_error_t +initial_handshake (assuan_context_t *ctx) +{ + int okay, off; + assuan_error_t err; + + err = _assuan_read_from_server (*ctx, &okay, &off); + if (err) + _assuan_log_printf ("can't connect server: %s\n", + assuan_strerror (err)); + else if (okay != 1) + { + _assuan_log_printf ("can't connect server: `%s'\n", + (*ctx)->inbound.line); + err = _assuan_error (ASSUAN_Connect_Failed); + } + + if (err) + { + assuan_disconnect (*ctx); + *ctx = NULL; + } + return err; +} + + +#ifndef HAVE_W32_SYSTEM +#define pipe_connect pipe_connect_unix +/* Unix version of the pipe connection code. We use an extra macro to + make ChangeLog entries easier. */ +static assuan_error_t +pipe_connect_unix (assuan_context_t *ctx, + const char *name, const char *const argv[], + int *fd_child_list, + void (*atfork) (void *opaque, int reserved), + void *atforkvalue) +{ + assuan_error_t err; + int rp[2]; + int wp[2]; + char mypidstr[50]; + + if (!ctx || !name || !argv || !argv[0]) + return _assuan_error (ASSUAN_Invalid_Value); + + fix_signals (); + + sprintf (mypidstr, "%lu", (unsigned long)getpid ()); + + if (pipe (rp) < 0) + return _assuan_error (ASSUAN_General_Error); + + if (pipe (wp) < 0) + { + close (rp[0]); + close (rp[1]); + return _assuan_error (ASSUAN_General_Error); + } + + err = _assuan_new_context (ctx); + if (err) + { + close (rp[0]); + close (rp[1]); + close (wp[0]); + close (wp[1]); + return err; + } + (*ctx)->pipe_mode = 1; + (*ctx)->inbound.fd = rp[0]; /* Our inbound is read end of read pipe. */ + (*ctx)->outbound.fd = wp[1]; /* Our outbound is write end of write pipe. */ + (*ctx)->deinit_handler = do_deinit; + (*ctx)->finish_handler = do_finish; + + /* FIXME: For GPGME we should better use _gpgme_io_spawn. The PID + stored here is actually soon useless. */ + (*ctx)->pid = fork (); + if ((*ctx)->pid < 0) + { + close (rp[0]); + close (rp[1]); + close (wp[0]); + close (wp[1]); + _assuan_release_context (*ctx); + return _assuan_error (ASSUAN_General_Error); + } + + if ((*ctx)->pid == 0) + { +#ifdef _ASSUAN_USE_DOUBLE_FORK + pid_t pid; + + if ((pid = fork ()) == 0) +#endif + { + int i, n; + char errbuf[512]; + int *fdp; + + if (atfork) + atfork (atforkvalue, 0); + + /* Dup handles to stdin/stdout. */ + if (rp[1] != STDOUT_FILENO) + { + if (dup2 (rp[1], STDOUT_FILENO) == -1) + { + _assuan_log_printf ("dup2 failed in child: %s\n", + strerror (errno)); + _exit (4); + } + } + if (wp[0] != STDIN_FILENO) + { + if (dup2 (wp[0], STDIN_FILENO) == -1) + { + _assuan_log_printf ("dup2 failed in child: %s\n", + strerror (errno)); + _exit (4); + } + } + + /* Dup stderr to /dev/null unless it is in the list of FDs to be + passed to the child. */ + fdp = fd_child_list; + if (fdp) + { + for (; *fdp != -1 && *fdp != STDERR_FILENO; fdp++) + ; + } + if (!fdp || *fdp == -1) + { + int fd = open ("/dev/null", O_WRONLY); + if (fd == -1) + { + _assuan_log_printf ("can't open `/dev/null': %s\n", + strerror (errno)); + _exit (4); + } + if (dup2 (fd, STDERR_FILENO) == -1) + { + _assuan_log_printf ("dup2(dev/null, 2) failed: %s\n", + strerror (errno)); + _exit (4); + } + } + + + /* Close all files which will not be duped and are not in the + fd_child_list. */ + 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; + fdp = fd_child_list; + if (fdp) + { + while (*fdp != -1 && *fdp != i) + fdp++; + } + + if (!(fdp && *fdp != -1)) + close(i); + } + errno = 0; + + /* We store our parents pid in the environment so that the + execed assuan server is able to read the actual pid of the + client. The server can't use getppid because it might have + been double forked before the assuan server has been + initialized. */ + setenv ("_assuan_pipe_connect_pid", mypidstr, 1); + + /* Make sure that we never pass a connection fd variable + when using a simple pipe. */ + unsetenv ("_assuan_connection_fd"); + + execv (name, (char *const *) argv); + /* oops - use the pipe to tell the parent about it */ + snprintf (errbuf, sizeof(errbuf)-1, + "ERR %d can't exec `%s': %.50s\n", + _assuan_error (ASSUAN_Problem_Starting_Server), + name, strerror (errno)); + errbuf[sizeof(errbuf)-1] = 0; + writen (1, errbuf, strlen (errbuf)); + _exit (4); + } +#ifdef _ASSUAN_USE_DOUBLE_FORK + if (pid == -1) + _exit (1); + else + _exit (0); +#endif + } + +#ifdef _ASSUAN_USE_DOUBLE_FORK + waitpid ((*ctx)->pid, NULL, 0); + (*ctx)->pid = -1; +#endif + + close (rp[1]); + close (wp[0]); + + return initial_handshake (ctx); +} +#endif /*!HAVE_W32_SYSTEM*/ + + +#ifndef HAVE_W32_SYSTEM +/* This function is similar to pipe_connect but uses a socketpair and + sets the I/O up to use sendmsg/recvmsg. */ +static assuan_error_t +socketpair_connect (assuan_context_t *ctx, + const char *name, const char *const argv[], + int *fd_child_list, + void (*atfork) (void *opaque, int reserved), + void *atforkvalue) +{ + assuan_error_t err; + int fds[2]; + char mypidstr[50]; + + if (!ctx + || (name && (!argv || !argv[0])) + || (!name && argv)) + return _assuan_error (ASSUAN_Invalid_Value); + + fix_signals (); + + sprintf (mypidstr, "%lu", (unsigned long)getpid ()); + + if ( socketpair (AF_LOCAL, SOCK_STREAM, 0, fds) ) + { + _assuan_log_printf ("socketpair failed: %s\n", strerror (errno)); + return _assuan_error (ASSUAN_General_Error); + } + + err = _assuan_new_context (ctx); + if (err) + { + close (fds[0]); + close (fds[1]); + return err; + } + (*ctx)->pipe_mode = 1; + (*ctx)->inbound.fd = fds[0]; + (*ctx)->outbound.fd = fds[0]; + _assuan_init_uds_io (*ctx); + (*ctx)->deinit_handler = _assuan_uds_deinit; + (*ctx)->finish_handler = do_finish; + + (*ctx)->pid = fork (); + if ((*ctx)->pid < 0) + { + close (fds[0]); + close (fds[1]); + _assuan_release_context (*ctx); + *ctx = NULL; + return _assuan_error (ASSUAN_General_Error); + } + + if ((*ctx)->pid == 0) + { +#ifdef _ASSUAN_USE_DOUBLE_FORK + pid_t pid; + + if ((pid = fork ()) == 0) +#endif + { + int fd, i, n; + char errbuf[512]; + int *fdp; + + if (atfork) + atfork (atforkvalue, 0); + + /* Connect stdin and stdout to /dev/null. */ + fd = open ("/dev/null", O_RDONLY); + if (fd == -1 || dup2 (fd, STDIN_FILENO) == -1) + { + _assuan_log_printf ("dup2(dev/null) failed: %s\n", + strerror (errno)); + _exit (4); + } + fd = open ("/dev/null", O_WRONLY); + if (fd == -1 || dup2 (fd, STDOUT_FILENO) == -1) + { + _assuan_log_printf ("dup2(dev/null) failed: %s\n", + strerror (errno)); + _exit (4); + } + + /* Dup stderr to /dev/null unless it is in the list of FDs to be + passed to the child. */ + fdp = fd_child_list; + if (fdp) + { + for (; *fdp != -1 && *fdp != STDERR_FILENO; fdp++) + ; + } + if (!fdp || *fdp == -1) + { + fd = open ("/dev/null", O_WRONLY); + if (fd == -1 || dup2 (fd, STDERR_FILENO) == -1) + { + _assuan_log_printf ("dup2(dev/null) failed: %s\n", + strerror (errno)); + _exit (4); + } + } + + + /* Close all files which will not be duped, are not in the + fd_child_list and are not the connection fd. */ + 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 || i == fds[1]) + continue; + fdp = fd_child_list; + if (fdp) + { + while (*fdp != -1 && *fdp != i) + fdp++; + } + + if (!(fdp && *fdp != -1)) + close(i); + } + errno = 0; + + /* We store our parents pid in the environment so that the + execed assuan server is able to read the actual pid of the + client. The server can't use getppid becuase it might have + been double forked before the assuan server has been + initialized. */ + setenv ("_assuan_pipe_connect_pid", mypidstr, 1); + + /* Now set the environment variable used to convey the + connection's file descriptor. */ + sprintf (mypidstr, "%d", fds[1]); + if (setenv ("_assuan_connection_fd", mypidstr, 1)) + { + _assuan_log_printf ("setenv failed: %s\n", strerror (errno)); + _exit (4); + } + + if (!name && !argv) + { + /* No name and no args given, thus we don't do an exec + but continue the forked process. */ + _assuan_release_context (*ctx); + *ctx = NULL; + return 0; + } + + execv (name, (char *const *) argv); + /* oops - use the pipe to tell the parent about it */ + snprintf (errbuf, sizeof(errbuf)-1, + "ERR %d can't exec `%s': %.50s\n", + _assuan_error (ASSUAN_Problem_Starting_Server), + name, strerror (errno)); + errbuf[sizeof(errbuf)-1] = 0; + writen (1, errbuf, strlen (errbuf)); + _exit (4); + } +#ifdef _ASSUAN_USE_DOUBLE_FORK + if (pid == -1) + _exit (1); + else + _exit (0); +#endif + } + + +#ifdef _ASSUAN_USE_DOUBLE_FORK + waitpid ((*ctx)->pid, NULL, 0); + (*ctx)->pid = -1; +#endif + + close (fds[1]); + + return initial_handshake (ctx); +} +#endif /*!HAVE_W32_SYSTEM*/ + + + #ifdef HAVE_W32_SYSTEM /* Build a command line for use with W32's CreateProcess. On success CMDLINE gets the address of a newly allocated string. */ @@ -237,21 +635,16 @@ #endif /*HAVE_W32_SYSTEM*/ -/* Connect to a server over a pipe, creating the assuan context and - returning it in CTX. The server filename is NAME, the argument - vector in ARGV. FD_CHILD_LIST is a -1 terminated list of file - descriptors not to close in the child. ATFORK is called in the - child right after the fork; ATFORKVALUE is passed as the first - argument and 0 is passed as the second argument. The ATFORK - function should only act if the second value is 0. */ -assuan_error_t -assuan_pipe_connect2 (assuan_context_t *ctx, - const char *name, const char *const argv[], - int *fd_child_list, - void (*atfork) (void *opaque, int reserved), - void *atforkvalue) +#ifdef HAVE_W32_SYSTEM +#define pipe_connect pipe_connect_w32 +/* W32 version of the pipe connection code. */ +static assuan_error_t +pipe_connect_w32 (assuan_context_t *ctx, + const char *name, const char *const argv[], + int *fd_child_list, + void (*atfork) (void *opaque, int reserved), + void *atforkvalue) { -#ifdef HAVE_W32_SYSTEM assuan_error_t err; int rp[2]; int wp[2]; @@ -414,201 +807,11 @@ (*ctx)->pid = 0; /* We don't use the PID. */ CloseHandle (pi.hProcess); /* We don't need to wait for the process. */ -#else /*!HAVE_W32_SYSTEM*/ - assuan_error_t err; - int rp[2]; - int wp[2]; - char mypidstr[50]; - - if (!ctx || !name || !argv || !argv[0]) - return _assuan_error (ASSUAN_Invalid_Value); - - fix_signals (); - - sprintf (mypidstr, "%lu", (unsigned long)getpid ()); - - if (pipe (rp) < 0) - return _assuan_error (ASSUAN_General_Error); - - if (pipe (wp) < 0) - { - close (rp[0]); - close (rp[1]); - return _assuan_error (ASSUAN_General_Error); - } - - err = _assuan_new_context (ctx); - if (err) - { - close (rp[0]); - close (rp[1]); - close (wp[0]); - close (wp[1]); - return err; - } - (*ctx)->pipe_mode = 1; - (*ctx)->inbound.fd = rp[0]; /* Our inbound is read end of read pipe. */ - (*ctx)->outbound.fd = wp[1]; /* Our outbound is write end of write pipe. */ - (*ctx)->deinit_handler = do_deinit; - (*ctx)->finish_handler = do_finish; - - /* FIXME: For GPGME we should better use _gpgme_io_spawn. The PID - stored here is actually soon useless. */ - (*ctx)->pid = fork (); - if ((*ctx)->pid < 0) - { - close (rp[0]); - close (rp[1]); - close (wp[0]); - close (wp[1]); - _assuan_release_context (*ctx); - return _assuan_error (ASSUAN_General_Error); - } - - if ((*ctx)->pid == 0) - { -#ifdef _ASSUAN_USE_DOUBLE_FORK - pid_t pid; - - if ((pid = fork ()) == 0) -#endif - { - int i, n; - char errbuf[512]; - int *fdp; - - if (atfork) - atfork (atforkvalue, 0); - - /* Dup handles to stdin/stdout. */ - if (rp[1] != STDOUT_FILENO) - { - if (dup2 (rp[1], STDOUT_FILENO) == -1) - { - _assuan_log_printf ("dup2 failed in child: %s\n", - strerror (errno)); - _exit (4); - } - } - if (wp[0] != STDIN_FILENO) - { - if (dup2 (wp[0], STDIN_FILENO) == -1) - { - _assuan_log_printf ("dup2 failed in child: %s\n", - strerror (errno)); - _exit (4); - } - } - - /* Dup stderr to /dev/null unless it is in the list of FDs to be - passed to the child. */ - fdp = fd_child_list; - if (fdp) - { - for (; *fdp != -1 && *fdp != STDERR_FILENO; fdp++) - ; - } - if (!fdp || *fdp == -1) - { - int fd = open ("/dev/null", O_WRONLY); - if (fd == -1) - { - _assuan_log_printf ("can't open `/dev/null': %s\n", - strerror (errno)); - _exit (4); - } - if (dup2 (fd, STDERR_FILENO) == -1) - { - _assuan_log_printf ("dup2(dev/null, 2) failed: %s\n", - strerror (errno)); - _exit (4); - } - } - - - /* Close all files which will not be duped and are not in the - fd_child_list. */ - 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; - fdp = fd_child_list; - if (fdp) - { - while (*fdp != -1 && *fdp != i) - fdp++; - } - - if (!(fdp && *fdp != -1)) - close(i); - } - errno = 0; - - /* We store our parents pid in the environment so that the - execed assuan server is able to read the actual pid of the - client. The server can't use getppid becuase it might have - been double forked before the assuan server has been - initialized. */ - setenv ("_assuan_pipe_connect_pid", mypidstr, 1); - - execv (name, (char *const *) argv); - /* oops - use the pipe to tell the parent about it */ - snprintf (errbuf, sizeof(errbuf)-1, - "ERR %d can't exec `%s': %.50s\n", - _assuan_error (ASSUAN_Problem_Starting_Server), - name, strerror (errno)); - errbuf[sizeof(errbuf)-1] = 0; - writen (1, errbuf, strlen (errbuf)); - _exit (4); - } -#ifdef _ASSUAN_USE_DOUBLE_FORK - if (pid == -1) - _exit (1); - else - _exit (0); -#endif - } - -#ifdef _ASSUAN_USE_DOUBLE_FORK - waitpid ((*ctx)->pid, NULL, 0); - (*ctx)->pid = -1; -#endif - - close (rp[1]); - close (wp[0]); - -#endif /*!HAVE_W32_SYSTEM*/ - - /* initial handshake */ - { - int okay, off; - - err = _assuan_read_from_server (*ctx, &okay, &off); - if (err) - _assuan_log_printf ("can't connect server: %s\n", - assuan_strerror (err)); - else if (okay != 1) - { - _assuan_log_printf ("can't connect server: `%s'\n", - (*ctx)->inbound.line); - err = _assuan_error (ASSUAN_Connect_Failed); - } - } - - if (err) - { - assuan_disconnect (*ctx); - *ctx = NULL; - } - - return err; + return initial_handshake (ctx); } +#endif /*HAVE_W32_SYSTEM*/ - + /* Connect to a server over a pipe, creating the assuan context and returning it in CTX. The server filename is NAME, the argument vector in ARGV. FD_CHILD_LIST is a -1 terminated list of file @@ -617,5 +820,53 @@ assuan_pipe_connect (assuan_context_t *ctx, const char *name, const char *const argv[], int *fd_child_list) { - return assuan_pipe_connect2 (ctx, name, argv, fd_child_list, NULL, NULL); + return pipe_connect (ctx, name, argv, fd_child_list, NULL, NULL); } + + +/* Connect to a server over a pipe, creating the assuan context and + returning it in CTX. The server filename is NAME, the argument + vector in ARGV. FD_CHILD_LIST is a -1 terminated list of file + descriptors not to close in the child. ATFORK is called in the + child right after the fork; ATFORKVALUE is passed as the first + argument and 0 is passed as the second argument. The ATFORK + function should only act if the second value is 0. */ +assuan_error_t +assuan_pipe_connect2 (assuan_context_t *ctx, + const char *name, const char *const argv[], + int *fd_child_list, + void (*atfork) (void *opaque, int reserved), + void *atforkvalue) +{ + return pipe_connect (ctx, name, argv, fd_child_list, atfork, atforkvalue); +} + + +/* Connect to a server over a socketpair, creating the assuan context + and returning it in CTX. The server filename is NAME, the argument + vector in ARGV. FD_CHILD_LIST is a -1 terminated list of file + descriptors not to close in the child. ATFORK is called in the + child right after the fork; ATFORKVALUE is passed as the first + argument and 0 is passed as the second argument. The ATFORK + function should only act if the second value is 0. + + If NAME as well as ARGV are NULL, no exec is done but the same + process is continued. However all file descriptors are closed and + some specila environment variables are set. To let the caller + detect whether the cild or the parent continues, the child returns + a CTX of NULL. */ +assuan_error_t +assuan_pipe_connect_ext (assuan_context_t *ctx, + const char *name, const char *const argv[], + int *fd_child_list, + void (*atfork) (void *opaque, int reserved), + void *atforkvalue) +{ +#ifdef HAVE_W32_SYSTEM + return _assuan_error (ASSUAN_Not_Implemented); +#else + return socketpair_connect (ctx, name, argv, fd_child_list, + atfork, atforkvalue); +#endif +} + Modified: trunk/src/assuan-pipe-server.c =================================================================== --- trunk/src/assuan-pipe-server.c 2006-09-11 13:15:48 UTC (rev 198) +++ trunk/src/assuan-pipe-server.c 2006-09-12 11:07:18 UTC (rev 199) @@ -111,8 +111,28 @@ ctx->inbound.fd = _get_osfhandle (filedes[0]); ctx->outbound.fd = _get_osfhandle (filedes[1]); #else - ctx->inbound.fd = filedes[0]; - ctx->outbound.fd = filedes[1]; + s = getenv ("_assuan_connection_fd"); + if (!filedes && s && *s && atoi (s) >= 0 ) + { + /* Well, we are called with an bi-directional file + descriptor. Prepare for using sendmsg/recvmsg. In this + case we ignore the passed file descriptors. */ + ctx->inbound.fd = ctx->outbound.fd = atoi (s); + _assuan_init_uds_io (ctx); + ctx->deinit_handler = _assuan_uds_deinit; + } + else if (filedes) + { + /* Standard pipe server. */ + ctx->inbound.fd = filedes[0]; + ctx->outbound.fd = filedes[1]; + } + else + { + _assuan_release_context (*r_ctx); + *r_ctx = NULL; + return ASSUAN_Problem_Starting_Server; + } #endif ctx->pipe_mode = 1; Modified: trunk/src/assuan-socket-server.c =================================================================== --- trunk/src/assuan-socket-server.c 2006-09-11 13:15:48 UTC (rev 198) +++ trunk/src/assuan-socket-server.c 2006-09-12 11:07:18 UTC (rev 199) @@ -34,6 +34,10 @@ #include "assuan-defs.h" +static struct assuan_io io = { _assuan_simple_read, + _assuan_simple_write }; + + static int accept_connection_bottom (assuan_context_t ctx) { @@ -105,9 +109,6 @@ finish_connection (ctx); } -static struct assuan_io io = { _assuan_simple_read, - _assuan_simple_write }; - /* Initialize a server for the socket LISTEN_FD which has already be put into listen mode */ int Copied: trunk/src/assuan-uds.c (from rev 196, trunk/src/assuan-domain-connect.c) =================================================================== --- trunk/src/assuan-domain-connect.c 2006-09-06 16:36:45 UTC (rev 196) +++ trunk/src/assuan-uds.c 2006-09-12 11:07:18 UTC (rev 199) @@ -0,0 +1,273 @@ +/* assuan-uds.c - Assuan unix domain socket utilities + * Copyright (C) 2006 Free Software Foundation, Inc. + * + * This file is part of Assuan. + * + * 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 2.1 of + * the License, or (at your option) any later version. + * + * Assuan 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 + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#ifndef HAVE_W32_SYSTEM +#include +#include +#else +#include +#endif +#if HAVE_SYS_UIO_H +#include +#endif +#include +#include +#include +#include + +#include "assuan-defs.h" + + +/* Read from a unix domain socket using sendmsg. */ +static ssize_t +uds_reader (assuan_context_t ctx, void *buf, size_t buflen) +{ + int len = ctx->uds.buffersize; + +#ifndef HAVE_W32_SYSTEM + + if (!ctx->uds.bufferallocated) + { + ctx->uds.buffer = xtrymalloc (2048); + if (!ctx->uds.buffer) + return _assuan_error (ASSUAN_Out_Of_Core); + ctx->uds.bufferallocated = 2048; + } + + while (!len) /* No data is buffered. */ + { + struct msghdr msg; + struct iovec iovec; + union { + struct cmsghdr cm; + char control[CMSG_SPACE(sizeof (int))]; + } control_u; + struct cmsghdr *cmptr; + + memset (&msg, 0, sizeof (msg)); + + msg.msg_name = NULL; + msg.msg_namelen = 0; + msg.msg_iov = &iovec; + msg.msg_iovlen = 1; + iovec.iov_base = ctx->uds.buffer; + iovec.iov_len = ctx->uds.bufferallocated; + msg.msg_control = control_u.control; + msg.msg_controllen = sizeof (control_u.control); + + len = _assuan_simple_recvmsg (ctx, &msg); + if (len < 0) + return -1; + + ctx->uds.buffersize = len; + ctx->uds.bufferoffset = 0; + + cmptr = CMSG_FIRSTHDR (&msg); + if (cmptr && cmptr->cmsg_len == CMSG_LEN (sizeof(int))) + { + if (cmptr->cmsg_level != SOL_SOCKET + || cmptr->cmsg_type != SCM_RIGHTS) + _assuan_log_printf ("unexpected ancillary data received\n"); + else + { + int fd = *((int*)CMSG_DATA (cmptr)); + + if (ctx->uds.pendingfdscount >= DIM (ctx->uds.pendingfds)) + { + _assuan_log_printf ("too many descriptors pending - " + "closing received descriptor %d\n", fd); + _assuan_close (fd); + } + else + ctx->uds.pendingfds[ctx->uds.pendingfdscount++] = fd; + } + } + } +#else /*HAVE_W32_SYSTEM*/ + len = recvfrom (ctx->inbound.fd, buf, buflen, 0, NULL, NULL); +#endif /*HAVE_W32_SYSTEM*/ + + /* Return some data to the user. */ + + if (len > buflen) /* We have more than the user requested. */ + len = buflen; + + memcpy (buf, ctx->uds.buffer + ctx->uds.bufferoffset, len); + ctx->uds.buffersize -= len; + assert (ctx->uds.buffersize >= 0); + ctx->uds.bufferoffset += len; + assert (ctx->uds.bufferoffset <= ctx->uds.bufferallocated); + + return len; +} + + +/* Write to the domain server. */ +static ssize_t +uds_writer (assuan_context_t ctx, const void *buf, size_t buflen) +{ +#ifndef HAVE_W32_SYSTEM + struct msghdr msg; + struct iovec iovec; + ssize_t len; + + memset (&msg, 0, sizeof (msg)); + + msg.msg_name = NULL; + msg.msg_namelen = 0; + msg.msg_iovlen = 1; + msg.msg_iov = &iovec; + iovec.iov_base = (void*)buf; + iovec.iov_len = buflen; + msg.msg_control = 0; + msg.msg_controllen = 0; + + len = _assuan_simple_sendmsg (ctx, &msg); +#else /*HAVE_W32_SYSTEM*/ + int len; + + len = sendto (ctx->outbound.fd, buf, buflen, 0, + (struct sockaddr *)&ctx->serveraddr, + sizeof (struct sockaddr_in)); +#endif /*HAVE_W32_SYSTEM*/ + return len; +} + + +static assuan_error_t +uds_sendfd (assuan_context_t ctx, int fd) +{ +#ifndef HAVE_W32_SYSTEM + struct msghdr msg; + struct iovec iovec; + union { + struct cmsghdr cm; + char control[CMSG_SPACE(sizeof (int))]; + } control_u; + struct cmsghdr *cmptr; + int len; + char buffer[80]; + + /* We need to send some real data so that a read won't return 0 + which will be taken as an EOF. It also helps with debugging. */ + snprintf (buffer, sizeof(buffer)-1, "# descriptor %d is in flight\n", fd); + buffer[sizeof(buffer)-1] = 0; + + memset (&msg, 0, sizeof (msg)); + + msg.msg_name = NULL; + msg.msg_namelen = 0; + msg.msg_iovlen = 1; + msg.msg_iov = &iovec; + iovec.iov_base = buffer; + iovec.iov_len = strlen (buffer); + + msg.msg_control = control_u.control; + msg.msg_controllen = sizeof (control_u.control); + cmptr = CMSG_FIRSTHDR (&msg); + cmptr->cmsg_len = CMSG_LEN(sizeof(int)); + cmptr->cmsg_level = SOL_SOCKET; + cmptr->cmsg_type = SCM_RIGHTS; + *((int*)CMSG_DATA (cmptr)) = fd; + + len = _assuan_simple_sendmsg (ctx, &msg); + if (len < 0) + { + _assuan_log_printf ("uds_sendfd: %s\n", strerror (errno)); + return _assuan_error (ASSUAN_Write_Error); + } + else + return 0; +#else + return _assuan_error (ASSUAN_Not_Implemented); +#endif +} + + +static assuan_error_t +uds_receivefd (assuan_context_t ctx, int *fd) +{ +#ifndef HAVE_W32_SYSTEM + if (!ctx->uds.pendingfds) + { + _assuan_log_printf ("no pending file descriptors!\n"); + return _assuan_error (ASSUAN_General_Error); + } + + *fd = ctx->uds.pendingfds[0]; + if (--ctx->uds.pendingfdscount) + memmove (ctx->uds.pendingfds, ctx->uds.pendingfds + 1, + ctx->uds.pendingfdscount * sizeof (int)); + + return 0; +#else + return _assuan_error (ASSUAN_Not_Implemented); +#endif +} + + +/* Deinitialize the unix domain socket I/O functions. */ +void +_assuan_uds_deinit (assuan_context_t ctx) +{ + int i; + + /* First call the finish_handler which should close descriptors etc. */ + ctx->finish_handler (ctx); + + if (ctx->uds.buffer) + { + assert (ctx->uds.bufferallocated); + ctx->uds.bufferallocated = 0; + xfree (ctx->uds.buffer); + } + + for (i = 0; i < ctx->uds.pendingfdscount; i++) + _assuan_close (ctx->uds.pendingfds[i]); + ctx->uds.pendingfdscount = 0; +} + + + +/* Helper function to initialize a context for domain I/O. */ +void +_assuan_init_uds_io (assuan_context_t ctx) +{ + static struct assuan_io io = { uds_reader, uds_writer, + uds_sendfd, uds_receivefd }; + + ctx->io = &io; + ctx->uds.buffer = 0; + ctx->uds.bufferoffset = 0; + ctx->uds.buffersize = 0; + ctx->uds.bufferallocated = 0; + ctx->uds.pendingfdscount = 0; +} + Modified: trunk/src/assuan.h =================================================================== --- trunk/src/assuan.h 2006-09-11 13:15:48 UTC (rev 198) +++ trunk/src/assuan.h 2006-09-12 11:07:18 UTC (rev 199) @@ -347,7 +347,7 @@ file descriptor via CTX and stores it in *RDF (the CTX must be capable of passing file descriptors). */ assuan_error_t assuan_command_parse_fd (assuan_context_t ctx, char *line, - int *rfd); + int *rfd); /*-- assuan-listen.c --*/ assuan_error_t assuan_set_hello_line (assuan_context_t ctx, const char *line); @@ -368,38 +368,29 @@ /*-- assuan-pipe-connect.c --*/ -assuan_error_t assuan_pipe_connect (assuan_context_t *ctx, const char *name, +assuan_error_t assuan_pipe_connect (assuan_context_t *ctx, + const char *name, const char *const argv[], int *fd_child_list); -assuan_error_t assuan_pipe_connect2 (assuan_context_t *ctx, const char *name, +assuan_error_t assuan_pipe_connect2 (assuan_context_t *ctx, + const char *name, const char *const argv[], int *fd_child_list, void (*atfork) (void*, int), void *atforkvalue); +assuan_error_t assuan_pipe_connect_ext (assuan_context_t *ctx, + const char *name, + const char *const argv[], + int *fd_child_list, + void (*atfork) (void *, int), + void *atforkvalue); + /*-- assuan-socket-connect.c --*/ assuan_error_t assuan_socket_connect (assuan_context_t *ctx, const char *name, pid_t server_pid); -/*-- assuan-domain-connect.c --*/ -/* Connect to a Unix domain socket server. RENDEZVOUSFD is - bidirectional file descriptor (normally returned via socketpair) - which the client can use to rendezvous with the server. SERVER s - the server's pid. */ -assuan_error_t assuan_domain_connect (assuan_context_t *r_ctx, - int rendezvousfd, - pid_t server); -/*-- assuan-domain-server.c --*/ - -/* RENDEZVOUSFD is a bidirectional file descriptor (normally returned - via socketpair) that the domain server can use to rendezvous with - the client. CLIENT is the client's pid. */ -assuan_error_t assuan_init_domain_server (assuan_context_t *r_ctx, - int rendezvousfd, - pid_t client); - - /*-- assuan-connect.c --*/ void assuan_disconnect (assuan_context_t ctx); pid_t assuan_get_pid (assuan_context_t ctx); Modified: trunk/tests/fdpassing.c =================================================================== --- trunk/tests/fdpassing.c 2006-09-11 13:15:48 UTC (rev 198) +++ trunk/tests/fdpassing.c 2006-09-12 11:07:18 UTC (rev 199) @@ -45,23 +45,28 @@ int fd; int c; FILE *fp; + int nbytes; log_info ("got ECHO command (%s)\n", line); fd = assuan_get_input_fd (ctx); if (fd == -1) return ASSUAN_No_Input; - fp = fdopen (dup (fd), "r"); + fp = fdopen (fd, "r"); if (!fp) { log_error ("fdopen failed on input fd: %s\n", strerror (errno)); return ASSUAN_General_Error; } log_info ("printing input to stdout:\n"); + nbytes = 0; while ( (c=getc (fp)) != -1) - putc (c, stdout); + { + putc (c, stdout); + nbytes++; + } fflush (stdout); - log_info ("done printing input to stdout\n"); + log_info ("done printing %d bytes to stdout\n", nbytes); fclose (fp); return 0; @@ -93,22 +98,21 @@ static void -server (int fd) +server (void) { int rc; assuan_context_t ctx; - log_info ("server started on fd %d\n", fd); + log_info ("server started\n"); - rc = assuan_init_domain_server (&ctx, fd, (pid_t)(-1)); + rc = assuan_init_pipe_server (&ctx, NULL); if (rc) - log_fatal ("assuan_init_domain_server failed: %s\n", assuan_strerror (rc)); + log_fatal ("assuan_init_pipe_server failed: %s\n", assuan_strerror (rc)); rc = register_commands (ctx); if (rc) log_fatal ("register_commands failed: %s\n", assuan_strerror(rc)); - assuan_set_assuan_log_prefix (log_prefix); assuan_set_log_stream (ctx, stderr); for (;;) @@ -116,7 +120,8 @@ rc = assuan_accept (ctx); if (rc) { - log_error ("assuan_accept failed: %s\n", assuan_strerror (rc)); + if (rc != -1) + log_error ("assuan_accept failed: %s\n", assuan_strerror (rc)); break; } @@ -140,53 +145,51 @@ /* Client main. If true is returned, a disconnect has not been done. */ static int -client (int fd) +client (assuan_context_t ctx) { int rc; - assuan_context_t ctx; FILE *fp; int i; - log_info ("client started on fd %d\n", fd); + log_info ("client started\n"); - rc = assuan_domain_connect (&ctx, fd, (pid_t)(-1)); - if (rc) + for (i=0; i < 8; i++) { - log_error ("assuan_domain_connect failed: %s\n", assuan_strerror (rc)); - return -1; - } + fp = fopen ("/etc/motd", "r"); + if (!fp) + { + log_error ("failed to open `%s': %s\n", "/etc/motd", + strerror (errno)); + return -1; + } + + rc = assuan_sendfd (ctx, fileno (fp)); + if (rc) + { + log_error ("assuan_sendfd failed: %s\n", assuan_strerror (rc)); + return -1; + } + fclose (fp); - fp = fopen ("/etc/motd", "r"); - if (!fp) - { - log_error ("failed to open `%s': %s\n", "/etc/motd", strerror (errno)); - return -1; - } + rc = assuan_transact (ctx, "INPUT FD", NULL, NULL, NULL, NULL, + NULL, NULL); + if (rc) + { + log_error ("sending INPUT FD failed: %s\n", assuan_strerror (rc)); + return -1; + } - rc = assuan_sendfd (ctx, fileno (fp)); - if (rc) - { - log_error ("assuan_sendfd failed: %s\n", assuan_strerror (rc)); - return -1; + rc = assuan_transact (ctx, "ECHO", NULL, NULL, NULL, NULL, NULL, NULL); + if (rc) + { + log_error ("sending ECHO failed: %s\n", assuan_strerror (rc)); + return -1; + } } - - rc = assuan_transact (ctx, "INPUT FD", NULL, NULL, NULL, NULL, NULL, NULL); - if (rc) - { - log_error ("sending INPUT FD failed: %s\n", assuan_strerror (rc)); - return -1; - } + /* Give us some time to check with lsof that all descriptors are closed. */ +/* sleep (10); */ - rc = assuan_transact (ctx, "ECHO", NULL, NULL, NULL, NULL, NULL, NULL); - if (rc) - { - log_error ("sending ECHO failed: %s\n", assuan_strerror (rc)); - return -1; - } - - sleep (100); - assuan_disconnect (ctx); return 0; } @@ -204,8 +207,12 @@ { int last_argc = -1; const char *srcdir = getenv ("srcdir"); - int fds[2]; - pid_t pid; + assuan_context_t ctx; + int err; + int no_close_fds[2]; + const char *arglist[10]; + int is_server = 0; + int with_exec = 0; if (!srcdir) srcdir = "."; @@ -223,7 +230,10 @@ puts ( "usage: ./fdpassing [options]\n" "\n" -" Options are --verbose and --debug"); +"Options:\n" +" --verbose Show what is going on\n" +" --with-exec Exec the child. Default is just a fork\n" +); exit (0); } if (!strcmp (*argv, "--verbose")) @@ -236,29 +246,60 @@ verbose = debug = 1; argc--; argv++; } + else if (!strcmp (*argv, "--server")) + { + is_server = 1; + argc--; argv++; + } + else if (!strcmp (*argv, "--with-exec")) + { + with_exec = 1; + argc--; argv++; + } } - /* Create a socketpair. */ - if ( socketpair (AF_LOCAL, SOCK_STREAM, 0, fds) ) - log_fatal ("socketpair failed: %s\n", strerror (errno)); + assuan_set_assuan_log_prefix (log_prefix); + assuan_set_assuan_log_stream (stderr); - /* Fork and run server and client. */ - pid = fork (); - if (pid == (pid_t)(-1)) - log_fatal ("fork failed: %s\n", strerror (errno)); - if (!pid) + if (is_server) { - server (fds[0]); /* The child is our server. */ + server (); log_info ("server finished\n"); } else { - if (client (fds[1])) /* The parent is the client. */ + no_close_fds[0] = 2; + no_close_fds[1] = -1; + if (with_exec) { - log_info ("waiting for server to terminate...\n"); - waitpid (pid, NULL, 0); + arglist[0] = "fdpassing"; + arglist[1] = "--server"; + arglist[2] = verbose? "--verbose":NULL; + arglist[3] = NULL; } - log_info ("client finished\n"); + err = assuan_pipe_connect_ext (&ctx, with_exec? "./fdpassing":NULL, + with_exec? arglist :NULL, + no_close_fds, NULL, NULL); + if (err) + { + log_error ("assuan_pipe_connect failed: %s\n",assuan_strerror (err)); + return 1; + } + + if (!ctx) + { + server (); + log_info ("server finished\n"); + } + else + { + if (client (ctx)) + { + log_info ("waiting for server to terminate...\n"); + assuan_disconnect (ctx); + } + log_info ("client finished\n"); + } } return errorcount? 1:0; From cvs at cvs.gnupg.org Wed Sep 13 17:55:26 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed Sep 13 17:10:42 2006 Subject: [svn] assuan - r200 - in trunk: . src tests Message-ID: Author: wk Date: 2006-09-13 17:55:25 +0200 (Wed, 13 Sep 2006) New Revision: 200 Modified: trunk/NEWS trunk/TODO trunk/src/ChangeLog trunk/src/assuan-buffer.c trunk/src/assuan-client.c trunk/src/assuan-defs.h trunk/src/assuan-handler.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-uds.c trunk/src/assuan.h trunk/src/mkerrors trunk/tests/fdpassing.c Log: More tweaks for descriptor passing. gpg-connect-agent may now be used as a test program. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-09-12 11:07:18 UTC (rev 199) +++ trunk/NEWS 2006-09-13 15:55:25 UTC (rev 200) @@ -17,11 +17,12 @@ printing of the full data, a new environment variable ASSUAN_FULL_LOGGING may be set to any value. - * Removed the assuan_domain fucntions. Added new function - assuan_pipe_connect_ext to allow connections on a socketpair and to - pass descriptors. + * Removed the assuan_domain functions. + * New functions assuan_pipe_connect_ext and assuan_socket_connext_ext + to allow connections on a socketpair and to pass descriptors. + Noteworthy changes in version 0.6.10 (2005-06-20) ------------------------------------------------- Modified: trunk/TODO =================================================================== --- trunk/TODO 2006-09-12 11:07:18 UTC (rev 199) +++ trunk/TODO 2006-09-13 15:55:25 UTC (rev 200) @@ -10,7 +10,6 @@ for unknown inquiries, albeit dirmngr itself would handle the returns for assuan_inquire gracefully. We need to check all applications whether it is safe to change this. -* Check the system error to assuan error translation * Do a configure test for SO_PEERCRED. We already use HAVE_SO_PEERCRED buty it never gets defined. * Replace assuan_pipe_connect2 by assuan_pipe_connect. \ No newline at end of file Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2006-09-12 11:07:18 UTC (rev 199) +++ trunk/src/ChangeLog 2006-09-13 15:55:25 UTC (rev 200) @@ -1,5 +1,29 @@ +2006-09-13 Werner Koch + + * assuan-client.c (assuan_transact): Need to map the error code. + * mkerrors: Need to map ASSUAN_No_Secret_Key. + + * assuan-pipe-server.c (is_valid_socket): New. + (assuan_init_pipe_server): Use UDS with the environmet variable is + set and a valid descriptor is given. Ignore FILEDES in this case. + + * assuan-socket-server.c (assuan_init_socket_server_ext): New. + Changed other init fucntions to make use of it. + + * assuan-handler.c (assuan_command_parse_fd): Allow for lowercase + "fd". + (std_handler_reset): Close pending fds. + * assuan-uds.c (uds_receivefd): Fixed. + (_assuan_uds_close_fds): New. + + * assuan-socket-connect.c (assuan_socket_connect_ext): New. Takes + all code of assuan_socket_connect plus an option to use sendmsg. + * assuan-pipe-connect.c (assuan_pipe_connect_ext): New arg FLAGS. + 2006-09-12 Werner Koch + * assuan-buffer.c (_assuan_write_line): Also log the prefix. + * assuan-defs.h (DIM, DIMof): New. * assuan-domain-server.c: Removed. Modified: trunk/src/assuan-buffer.c =================================================================== --- trunk/src/assuan-buffer.c 2006-09-12 11:07:18 UTC (rev 199) +++ trunk/src/assuan-buffer.c 2006-09-13 15:55:25 UTC (rev 200) @@ -269,7 +269,11 @@ if (ctx->confidential) fputs ("[Confidential data not shown]", ctx->log_fp); else - _assuan_log_print_buffer (ctx->log_fp, line, len); + { + if (prefixlen) + _assuan_log_print_buffer (ctx->log_fp, prefix, prefixlen); + _assuan_log_print_buffer (ctx->log_fp, line, len); + } putc ('\n', ctx->log_fp); } Modified: trunk/src/assuan-client.c =================================================================== --- trunk/src/assuan-client.c 2006-09-12 11:07:18 UTC (rev 199) +++ trunk/src/assuan-client.c 2006-09-13 15:55:25 UTC (rev 200) @@ -160,7 +160,7 @@ if (!okay) { - rc = atoi (line); + rc = _assuan_error (atoi (line)); if (rc < 100) rc = ASSUAN_Server_Fault; } Modified: trunk/src/assuan-defs.h =================================================================== --- trunk/src/assuan-defs.h 2006-09-12 11:07:18 UTC (rev 199) +++ trunk/src/assuan-defs.h 2006-09-13 15:55:25 UTC (rev 200) @@ -185,6 +185,7 @@ void _assuan_release_context (ASSUAN_CONTEXT ctx); /*-- assuan-uds.c --*/ +void _assuan_uds_close_fds (assuan_context_t ctx); void _assuan_uds_deinit (assuan_context_t ctx); void _assuan_init_uds_io (assuan_context_t ctx); Modified: trunk/src/assuan-handler.c =================================================================== --- trunk/src/assuan-handler.c 2006-09-12 11:07:18 UTC (rev 199) +++ trunk/src/assuan-handler.c 2006-09-13 15:55:25 UTC (rev 200) @@ -37,20 +37,20 @@ static int -dummy_handler (ASSUAN_CONTEXT ctx, char *line) +dummy_handler (assuan_context_t ctx, char *line) { return set_error (ctx, Server_Fault, "no handler registered"); } static int -std_handler_nop (ASSUAN_CONTEXT ctx, char *line) +std_handler_nop (assuan_context_t ctx, char *line) { return 0; /* okay */ } static int -std_handler_cancel (ASSUAN_CONTEXT ctx, char *line) +std_handler_cancel (assuan_context_t ctx, char *line) { if (ctx->cancel_notify_fnc) ctx->cancel_notify_fnc (ctx); @@ -58,7 +58,7 @@ } static int -std_handler_option (ASSUAN_CONTEXT ctx, char *line) +std_handler_option (assuan_context_t ctx, char *line) { char *key, *value, *p; @@ -105,7 +105,7 @@ } static int -std_handler_bye (ASSUAN_CONTEXT ctx, char *line) +std_handler_bye (assuan_context_t ctx, char *line) { if (ctx->bye_notify_fnc) ctx->bye_notify_fnc (ctx); @@ -115,33 +115,35 @@ } static int -std_handler_auth (ASSUAN_CONTEXT ctx, char *line) +std_handler_auth (assuan_context_t ctx, char *line) { return set_error (ctx, Not_Implemented, NULL); } static int -std_handler_reset (ASSUAN_CONTEXT ctx, char *line) +std_handler_reset (assuan_context_t ctx, char *line) { if (ctx->reset_notify_fnc) ctx->reset_notify_fnc (ctx); assuan_close_input_fd (ctx); assuan_close_output_fd (ctx); + _assuan_uds_close_fds (ctx); return 0; } static int -std_handler_end (ASSUAN_CONTEXT ctx, char *line) +std_handler_end (assuan_context_t ctx, char *line) { return set_error (ctx, Not_Implemented, NULL); } assuan_error_t -assuan_command_parse_fd (ASSUAN_CONTEXT ctx, char *line, int *rfd) +assuan_command_parse_fd (assuan_context_t ctx, char *line, int *rfd) { char *endp; - if (strncmp (line, "FD", 2) != 0 || (line[2] != '=' && line[2] != '\0')) + if ( (strncmp (line, "FD", 2) && strncmp (line, "fd", 2)) + || (line[2] != '=' && line[2] != '\0')) return set_error (ctx, Syntax_Error, "FD[=] expected"); line += 2; if (*line == '=') @@ -150,7 +152,7 @@ if (!digitp (*line)) return set_error (ctx, Syntax_Error, "number required"); *rfd = strtoul (line, &endp, 10); - /* remove that argument so that a notify handler won't see it */ + /* Remove that argument so that a notify handler won't see it. */ memset (line, ' ', endp? (endp-line):strlen(line)); if (*rfd == ctx->inbound.fd) @@ -166,7 +168,7 @@ /* Format is INPUT FD= */ static int -std_handler_input (ASSUAN_CONTEXT ctx, char *line) +std_handler_input (assuan_context_t ctx, char *line) { int rc, fd; @@ -181,7 +183,7 @@ /* Format is OUTPUT FD= */ static int -std_handler_output (ASSUAN_CONTEXT ctx, char *line) +std_handler_output (assuan_context_t ctx, char *line) { int rc, fd; @@ -203,7 +205,7 @@ with default handlers */ static struct { const char *name; - int (*handler)(ASSUAN_CONTEXT, char *line); + int (*handler)(assuan_context_t, char *line); int always; /* always initialize this command */ } std_cmd_table[] = { { "NOP", std_handler_nop, 1 }, @@ -235,9 +237,9 @@ * Return value: 0 on success or an error code **/ int -assuan_register_command (ASSUAN_CONTEXT ctx, +assuan_register_command (assuan_context_t ctx, const char *cmd_name, - int (*handler)(ASSUAN_CONTEXT, char *)) + int (*handler)(assuan_context_t, char *)) { int i; const char *s; @@ -290,7 +292,8 @@ } int -assuan_register_bye_notify (ASSUAN_CONTEXT ctx, void (*fnc)(ASSUAN_CONTEXT)) +assuan_register_bye_notify (assuan_context_t ctx, + void (*fnc)(assuan_context_t)) { if (!ctx) return _assuan_error (ASSUAN_Invalid_Value); @@ -299,7 +302,8 @@ } int -assuan_register_reset_notify (ASSUAN_CONTEXT ctx, void (*fnc)(ASSUAN_CONTEXT)) +assuan_register_reset_notify (assuan_context_t ctx, + void (*fnc)(assuan_context_t)) { if (!ctx) return _assuan_error (ASSUAN_Invalid_Value); @@ -308,7 +312,8 @@ } int -assuan_register_cancel_notify (ASSUAN_CONTEXT ctx, void (*fnc)(ASSUAN_CONTEXT)) +assuan_register_cancel_notify (assuan_context_t ctx, + void (*fnc)(assuan_context_t)) { if (!ctx) return _assuan_error (ASSUAN_Invalid_Value); @@ -317,8 +322,8 @@ } int -assuan_register_option_handler (ASSUAN_CONTEXT ctx, - int (*fnc)(ASSUAN_CONTEXT, +assuan_register_option_handler (assuan_context_t ctx, + int (*fnc)(assuan_context_t, const char*, const char*)) { if (!ctx) @@ -328,8 +333,8 @@ } int -assuan_register_input_notify (ASSUAN_CONTEXT ctx, - void (*fnc)(ASSUAN_CONTEXT, const char *)) +assuan_register_input_notify (assuan_context_t ctx, + void (*fnc)(assuan_context_t, const char *)) { if (!ctx) return _assuan_error (ASSUAN_Invalid_Value); @@ -338,8 +343,8 @@ } int -assuan_register_output_notify (ASSUAN_CONTEXT ctx, - void (*fnc)(ASSUAN_CONTEXT, const char *)) +assuan_register_output_notify (assuan_context_t ctx, + void (*fnc)(assuan_context_t, const char *)) { if (!ctx) return _assuan_error (ASSUAN_Invalid_Value); @@ -350,7 +355,7 @@ /* Helper to register the standards commands */ int -_assuan_register_std_commands (ASSUAN_CONTEXT ctx) +_assuan_register_std_commands (assuan_context_t ctx) { int i, rc; @@ -371,7 +376,7 @@ /* Process the special data lines. The "D " has already been removed from the line. As all handlers this function may modify the line. */ static int -handle_data_line (ASSUAN_CONTEXT ctx, char *line, int linelen) +handle_data_line (assuan_context_t ctx, char *line, int linelen) { return set_error (ctx, Not_Implemented, NULL); } @@ -395,7 +400,7 @@ table, remove leading and white spaces from the arguments, call the handler with the argument line and return the error */ static int -dispatch_command (ASSUAN_CONTEXT ctx, char *line, int linelen) +dispatch_command (assuan_context_t ctx, char *line, int linelen) { char *p; const char *s; @@ -442,7 +447,7 @@ static int -process_request (ASSUAN_CONTEXT ctx) +process_request (assuan_context_t ctx) { int rc; @@ -553,7 +558,7 @@ * failed. Note, that no error is returned for operational errors. **/ int -assuan_process (ASSUAN_CONTEXT ctx) +assuan_process (assuan_context_t ctx) { int rc; @@ -580,7 +585,7 @@ * Return value: -1 for end of server, 0 on success or an error code **/ int -assuan_process_next (ASSUAN_CONTEXT ctx) +assuan_process_next (assuan_context_t ctx) { return process_request (ctx); } @@ -604,7 +609,7 @@ * error which is most likely a too small fdarray. **/ int -assuan_get_active_fds (ASSUAN_CONTEXT ctx, int what, +assuan_get_active_fds (assuan_context_t ctx, int what, int *fdarray, int fdarraysize) { int n = 0; @@ -637,7 +642,7 @@ implementaion for systems w/o a glibc, a simple implementation could use a child process */ FILE * -assuan_get_data_fp (ASSUAN_CONTEXT ctx) +assuan_get_data_fp (assuan_context_t ctx) { #if defined (HAVE_FOPENCOOKIE) || defined (HAVE_FUNOPEN) if (ctx->outbound.data.fp) @@ -659,7 +664,7 @@ /* Set the text used for the next OK reponse. This string is automatically reset to NULL after the next command. */ assuan_error_t -assuan_set_okay_line (ASSUAN_CONTEXT ctx, const char *line) +assuan_set_okay_line (assuan_context_t ctx, const char *line) { if (!ctx) return _assuan_error (ASSUAN_Invalid_Value); @@ -686,7 +691,8 @@ assuan_error_t -assuan_write_status (ASSUAN_CONTEXT ctx, const char *keyword, const char *text) +assuan_write_status (assuan_context_t ctx, + const char *keyword, const char *text) { char buffer[256]; char *helpbuf; Modified: trunk/src/assuan-listen.c =================================================================== --- trunk/src/assuan-listen.c 2006-09-12 11:07:18 UTC (rev 199) +++ trunk/src/assuan-listen.c 2006-09-13 15:55:25 UTC (rev 200) @@ -24,6 +24,7 @@ #include #include #include +#include #include "assuan-defs.h" Modified: trunk/src/assuan-pipe-connect.c =================================================================== --- trunk/src/assuan-pipe-connect.c 2006-09-12 11:07:18 UTC (rev 199) +++ trunk/src/assuan-pipe-connect.c 2006-09-13 15:55:25 UTC (rev 200) @@ -512,7 +512,7 @@ _assuan_error (ASSUAN_Problem_Starting_Server), name, strerror (errno)); errbuf[sizeof(errbuf)-1] = 0; - writen (1, errbuf, strlen (errbuf)); + writen (fds[1], errbuf, strlen (errbuf)); _exit (4); } #ifdef _ASSUAN_USE_DOUBLE_FORK @@ -842,31 +842,41 @@ } -/* Connect to a server over a socketpair, creating the assuan context - and returning it in CTX. The server filename is NAME, the argument - vector in ARGV. FD_CHILD_LIST is a -1 terminated list of file - descriptors not to close in the child. ATFORK is called in the - child right after the fork; ATFORKVALUE is passed as the first - argument and 0 is passed as the second argument. The ATFORK - function should only act if the second value is 0. +/* Connect to a server over a full-duplex socket (i.e. created by + socketpair), creating the assuan context and returning it in CTX. + The server filename is NAME, the argument vector in ARGV. + FD_CHILD_LIST is a -1 terminated list of file descriptors not to + close in the child. ATFORK is called in the child right after the + fork; ATFORKVALUE is passed as the first argument and 0 is passed + as the second argument. The ATFORK function should only act if the + second value is 0. + For now FLAGS may either take the value 0 to behave like + assuan_pipe_connect2 or 1 to enable the described full-duplex + socket behaviour. + If NAME as well as ARGV are NULL, no exec is done but the same process is continued. However all file descriptors are closed and - some specila environment variables are set. To let the caller - detect whether the cild or the parent continues, the child returns + some special environment variables are set. To let the caller + detect whether the child or the parent continues, the child returns a CTX of NULL. */ assuan_error_t assuan_pipe_connect_ext (assuan_context_t *ctx, const char *name, const char *const argv[], int *fd_child_list, void (*atfork) (void *opaque, int reserved), - void *atforkvalue) + void *atforkvalue, unsigned int flags) { + if ((flags & 1)) + { #ifdef HAVE_W32_SYSTEM - return _assuan_error (ASSUAN_Not_Implemented); + return _assuan_error (ASSUAN_Not_Implemented); #else - return socketpair_connect (ctx, name, argv, fd_child_list, - atfork, atforkvalue); + return socketpair_connect (ctx, name, argv, fd_child_list, + atfork, atforkvalue); #endif + } + else + return pipe_connect (ctx, name, argv, fd_child_list, atfork, atforkvalue); } Modified: trunk/src/assuan-pipe-server.c =================================================================== --- trunk/src/assuan-pipe-server.c 2006-09-12 11:07:18 UTC (rev 199) +++ trunk/src/assuan-pipe-server.c 2006-09-13 15:55:25 UTC (rev 200) @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include #ifdef HAVE_W32_SYSTEM #include @@ -89,6 +91,18 @@ } +/* Returns true if atoi(S) denotes a valid socket. */ +static int +is_valid_socket (const char *s) +{ + struct stat buf; + + if ( fstat (atoi (s), &buf ) ) + return 0; + return S_ISSOCK (buf.st_mode); +} + + int assuan_init_pipe_server (ASSUAN_CONTEXT *r_ctx, int filedes[2]) { @@ -112,7 +126,7 @@ ctx->outbound.fd = _get_osfhandle (filedes[1]); #else s = getenv ("_assuan_connection_fd"); - if (!filedes && s && *s && atoi (s) >= 0 ) + if (s && *s && is_valid_socket (s) ) { /* Well, we are called with an bi-directional file descriptor. Prepare for using sendmsg/recvmsg. In this @@ -121,7 +135,7 @@ _assuan_init_uds_io (ctx); ctx->deinit_handler = _assuan_uds_deinit; } - else if (filedes) + else if (filedes && filedes[0] != -1 && filedes[1] != -1 ) { /* Standard pipe server. */ ctx->inbound.fd = filedes[0]; Modified: trunk/src/assuan-socket-connect.c =================================================================== --- trunk/src/assuan-socket-connect.c 2006-09-12 11:07:18 UTC (rev 199) +++ trunk/src/assuan-socket-connect.c 2006-09-13 15:55:25 UTC (rev 200) @@ -55,7 +55,7 @@ static int -do_finish (ASSUAN_CONTEXT ctx) +do_finish (assuan_context_t ctx) { if (ctx->inbound.fd != -1) { @@ -67,22 +67,37 @@ } static void -do_deinit (ASSUAN_CONTEXT ctx) +do_deinit (assuan_context_t ctx) { do_finish (ctx); } + + /* Make a connection to the Unix domain socket NAME and return a new Assuan context in CTX. SERVER_PID is currently not used but may become handy in the future. */ assuan_error_t -assuan_socket_connect (ASSUAN_CONTEXT *r_ctx, +assuan_socket_connect (assuan_context_t *r_ctx, const char *name, pid_t server_pid) { + return assuan_socket_connect_ext (r_ctx, name, server_pid, 0); +} + + +/* Make a connection to the Unix domain socket NAME and return a new + Assuan context in CTX. SERVER_PID is currently not used but may + become handy in the future. With flags set to 1 sendmsg and + recvmesg are used. */ +assuan_error_t +assuan_socket_connect_ext (assuan_context_t *r_ctx, + const char *name, pid_t server_pid, + unsigned int flags) +{ static struct assuan_io io = { _assuan_simple_read, _assuan_simple_write }; assuan_error_t err; - ASSUAN_CONTEXT ctx; + assuan_context_t ctx; int fd; struct sockaddr_un srvr_addr; size_t len; @@ -92,9 +107,9 @@ return _assuan_error (ASSUAN_Invalid_Value); *r_ctx = NULL; - /* We require that the name starts with a slash, so that we can - alter reuse this function for other socket types. To make things - easier we allow an optional dirver prefix. */ + /* We require that the name starts with a slash, so that we + eventually can reuse this function for other socket types. To + make things easier we allow an optional dirver prefix. */ s = name; if (*s && s[1] == ':') s += 2; @@ -107,10 +122,9 @@ err = _assuan_new_context (&ctx); if (err) return err; - ctx->deinit_handler = do_deinit; + ctx->deinit_handler = ((flags&1))? _assuan_uds_deinit : do_deinit; ctx->finish_handler = do_finish; - fd = _assuan_sock_new (PF_LOCAL, SOCK_STREAM, 0); if (fd == -1) { @@ -138,7 +152,9 @@ ctx->inbound.fd = fd; ctx->outbound.fd = fd; ctx->io = &io; - + if ((flags&1)) + _assuan_init_uds_io (ctx); + /* initial handshake */ { int okay, off; @@ -164,3 +180,5 @@ *r_ctx = ctx; return 0; } + + Modified: trunk/src/assuan-socket-server.c =================================================================== --- trunk/src/assuan-socket-server.c 2006-09-12 11:07:18 UTC (rev 199) +++ trunk/src/assuan-socket-server.c 2006-09-13 15:55:25 UTC (rev 200) @@ -114,40 +114,25 @@ int assuan_init_socket_server (assuan_context_t *r_ctx, int listen_fd) { - assuan_context_t ctx; - int rc; - - *r_ctx = NULL; - ctx = xtrycalloc (1, sizeof *ctx); - if (!ctx) - return _assuan_error (ASSUAN_Out_Of_Core); - ctx->is_server = 1; - ctx->input_fd = -1; - ctx->output_fd = -1; - - ctx->inbound.fd = -1; - ctx->outbound.fd = -1; - - ctx->listen_fd = listen_fd; - ctx->connected_fd = -1; - ctx->deinit_handler = deinit_socket_server; - ctx->accept_handler = accept_connection; - ctx->finish_handler = finish_connection; - - ctx->io = &io; - - rc = _assuan_register_std_commands (ctx); - if (rc) - xfree (ctx); - else - *r_ctx = ctx; - return rc; + return assuan_init_socket_server_ext (r_ctx, listen_fd, 0); } /* Initialize a server using the already accepted socket FD. */ int assuan_init_connected_socket_server (assuan_context_t *r_ctx, int fd) { + return assuan_init_socket_server_ext (r_ctx, fd, 2); +} + + +/* + Flag bits: 0 - use sendmsg/recvmsg to allow descriptor passing + 1 - FD has already been accepted. +*/ +int +assuan_init_socket_server_ext (assuan_context_t *r_ctx, int fd, + unsigned int flags) +{ assuan_context_t ctx; int rc; @@ -156,21 +141,34 @@ if (!ctx) return _assuan_error (ASSUAN_Out_Of_Core); ctx->is_server = 1; - ctx->pipe_mode = 1; /* we want a second accept to indicate EOF */ + if ((flags & 2)) + ctx->pipe_mode = 1; /* We want a second accept to indicate EOF. */ ctx->input_fd = -1; ctx->output_fd = -1; ctx->inbound.fd = -1; ctx->outbound.fd = -1; - ctx->io = &io; - - ctx->listen_fd = -1; - ctx->connected_fd = fd; - ctx->deinit_handler = deinit_socket_server; - ctx->accept_handler = accept_connection_bottom; + if ((flags & 2)) + { + ctx->listen_fd = -1; + ctx->connected_fd = fd; + } + else + { + ctx->listen_fd = fd; + ctx->connected_fd = -1; + } + ctx->deinit_handler = (flags & 1)? _assuan_uds_deinit:deinit_socket_server; + ctx->accept_handler = ((flags & 2) + ? accept_connection_bottom + : accept_connection); ctx->finish_handler = finish_connection; + ctx->io = &io; + if ((flags & 1)) + _assuan_init_uds_io (ctx); + rc = _assuan_register_std_commands (ctx); if (rc) xfree (ctx); @@ -178,5 +176,3 @@ *r_ctx = ctx; return rc; } - - Modified: trunk/src/assuan-uds.c =================================================================== --- trunk/src/assuan-uds.c 2006-09-12 11:07:18 UTC (rev 199) +++ trunk/src/assuan-uds.c 2006-09-13 15:55:25 UTC (rev 200) @@ -45,7 +45,10 @@ #include "assuan-defs.h" -/* Read from a unix domain socket using sendmsg. */ +/* Read from a unix domain socket using sendmsg. + + FIXME: We don't need the buffering. It is a leftover from the time + when we used datagrams. */ static ssize_t uds_reader (assuan_context_t ctx, void *buf, size_t buflen) { @@ -215,16 +218,19 @@ uds_receivefd (assuan_context_t ctx, int *fd) { #ifndef HAVE_W32_SYSTEM - if (!ctx->uds.pendingfds) + int i; + + if (!ctx->uds.pendingfdscount) { _assuan_log_printf ("no pending file descriptors!\n"); return _assuan_error (ASSUAN_General_Error); } + assert (ctx->uds.pendingfdscount <= DIM(ctx->uds.pendingfds)); *fd = ctx->uds.pendingfds[0]; - if (--ctx->uds.pendingfdscount) - memmove (ctx->uds.pendingfds, ctx->uds.pendingfds + 1, - ctx->uds.pendingfdscount * sizeof (int)); + for (i=1; i < ctx->uds.pendingfdscount; i++) + ctx->uds.pendingfds[i-1] = ctx->uds.pendingfds[i]; + ctx->uds.pendingfdscount--; return 0; #else @@ -233,12 +239,21 @@ } +/* Close all pending fds. */ +void +_assuan_uds_close_fds (assuan_context_t ctx) +{ + int i; + + for (i = 0; i < ctx->uds.pendingfdscount; i++) + _assuan_close (ctx->uds.pendingfds[i]); + ctx->uds.pendingfdscount = 0; +} + /* Deinitialize the unix domain socket I/O functions. */ void _assuan_uds_deinit (assuan_context_t ctx) { - int i; - /* First call the finish_handler which should close descriptors etc. */ ctx->finish_handler (ctx); @@ -249,13 +264,10 @@ xfree (ctx->uds.buffer); } - for (i = 0; i < ctx->uds.pendingfdscount; i++) - _assuan_close (ctx->uds.pendingfds[i]); - ctx->uds.pendingfdscount = 0; + _assuan_uds_close_fds (ctx); } - /* Helper function to initialize a context for domain I/O. */ void _assuan_init_uds_io (assuan_context_t ctx) Modified: trunk/src/assuan.h =================================================================== --- trunk/src/assuan.h 2006-09-12 11:07:18 UTC (rev 199) +++ trunk/src/assuan.h 2006-09-13 15:55:25 UTC (rev 200) @@ -91,10 +91,12 @@ #define assuan_init_socket_server _ASSUAN_PREFIX(assuan_init_socket_server) #define assuan_init_connected_socket_server \ _ASSUAN_PREFIX(assuan_init_connected_socket_server) +#define assuan_init_socket_server_ext \ + _ASSUAN_PREFIX(assuan_init_socket_server-ext) #define assuan_pipe_connect _ASSUAN_PREFIX(assuan_pipe_connect) +#define assuan_pipe_connect_ext _ASSUAN_PREFIX(assuan_pipe_connect_ext) #define assuan_socket_connect _ASSUAN_PREFIX(assuan_socket_connect) -#define assuan_domain_connect _ASSUAN_PREFIX(assuan_domain_connect) -#define assuan_init_domain_server _ASSUAN_PREFIX(assuan_init_domain_server) +#define assuan_socket_connect_ext _ASSUAN_PREFIX(assuan_socket_connect_ext) #define assuan_disconnect _ASSUAN_PREFIX(assuan_disconnect) #define assuan_get_pid _ASSUAN_PREFIX(assuan_get_pid) #define assuan_transact _ASSUAN_PREFIX(assuan_transact) @@ -365,8 +367,9 @@ /*-- assuan-socket-server.c --*/ int assuan_init_socket_server (assuan_context_t *r_ctx, int listen_fd); int assuan_init_connected_socket_server (assuan_context_t *r_ctx, int fd); +int assuan_init_socket_server_ext (assuan_context_t *r_ctx, int fd, + unsigned int flags); - /*-- assuan-pipe-connect.c --*/ assuan_error_t assuan_pipe_connect (assuan_context_t *ctx, const char *name, @@ -383,14 +386,18 @@ const char *const argv[], int *fd_child_list, void (*atfork) (void *, int), - void *atforkvalue); + void *atforkvalue, + unsigned int flags); /*-- assuan-socket-connect.c --*/ -assuan_error_t assuan_socket_connect (assuan_context_t *ctx, const char *name, +assuan_error_t assuan_socket_connect (assuan_context_t *ctx, + const char *name, pid_t server_pid); +assuan_error_t assuan_socket_connect_ext (assuan_context_t *ctx, + const char *name, + pid_t server_pid, + unsigned int flags); - - /*-- assuan-connect.c --*/ void assuan_disconnect (assuan_context_t ctx); pid_t assuan_get_pid (assuan_context_t ctx); Modified: trunk/src/mkerrors =================================================================== --- trunk/src/mkerrors 2006-09-12 11:07:18 UTC (rev 199) +++ trunk/src/mkerrors 2006-09-13 15:55:25 UTC (rev 200) @@ -83,6 +83,7 @@ case ASSUAN_Unexpected_Command: n = 274; break; case ASSUAN_Unknown_Command: n = 275; break; case ASSUAN_Canceled: n = 277; break; + case ASSUAN_No_Secret_Key: n = 17; break; case ASSUAN_Read_Error: switch (errno) @@ -119,8 +120,7 @@ case -1: n = 16383 /*GPG_ERR_EOF*/; break; default: - assert (!"unmapped error code used in libassuan!!"); - n = 257; /* Just in case someone compiled with NDEBUG. */ + n = 257; break; } Modified: trunk/tests/fdpassing.c =================================================================== --- trunk/tests/fdpassing.c 2006-09-12 11:07:18 UTC (rev 199) +++ trunk/tests/fdpassing.c 2006-09-13 15:55:25 UTC (rev 200) @@ -279,7 +279,7 @@ } err = assuan_pipe_connect_ext (&ctx, with_exec? "./fdpassing":NULL, with_exec? arglist :NULL, - no_close_fds, NULL, NULL); + no_close_fds, NULL, NULL, 1); if (err) { log_error ("assuan_pipe_connect failed: %s\n",assuan_strerror (err)); From cvs at cvs.gnupg.org Wed Sep 13 17:57:36 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed Sep 13 17:12:47 2006 Subject: [svn] GnuPG - r4248 - in trunk: . agent doc g10 sm tools Message-ID: Author: wk Date: 2006-09-13 17:57:30 +0200 (Wed, 13 Sep 2006) New Revision: 4248 Added: trunk/README.SVN Removed: trunk/README.CVS Modified: trunk/ChangeLog trunk/NEWS trunk/agent/ChangeLog trunk/agent/call-scd.c trunk/agent/preset-passphrase.c trunk/autogen.sh trunk/doc/ChangeLog trunk/doc/HACKING trunk/doc/gpg.texi trunk/doc/gpgsm.texi trunk/doc/tools.texi trunk/g10/ChangeLog trunk/g10/gpg.c trunk/sm/ChangeLog trunk/sm/gpgsm.c trunk/sm/keylist.c trunk/sm/server.c trunk/tools/ChangeLog trunk/tools/gpg-connect-agent.c Log: Various fixes and new features. Enhanced gpg-connect-agent. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-09-08 17:02:06 UTC (rev 4247) +++ trunk/ChangeLog 2006-09-13 15:57:30 UTC (rev 4248) @@ -1,3 +1,7 @@ +2006-09-13 Werner Koch + + * autogen.sh: Better detection of the cross compiler kit. + 2006-09-06 Marcus Brinkmann * configure.ac: New automake conditional RUN_GPG_TESTS. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-09-08 17:02:06 UTC (rev 4247) +++ trunk/NEWS 2006-09-13 15:57:30 UTC (rev 4248) @@ -1,8 +1,8 @@ Noteworthy changes in version 1.9.23 ------------------------------------------------- - * man pages for most tools are now build directly from the texinfo - source. + * Regular man pages for most tools are now build directly from the + texinfo source. * The gpg code from 1.4.5 has been fully merged into this release. The configure option --enable-gpg is still required to build this @@ -14,7 +14,19 @@ * The scdaemon will now call a script on reader status changes. + * gpgsm now allows file descriptor passing for "INPUT", "OUTPUT" and + "MESSAGE". + * The gpgsm server may now output a key listing to the output file + handle. This needs to be enabled using "OPTION list-to-output=1". + + * The --output option of gpgsm has now an effect on list-keys. + + * New gpgsm commands --dump-chain and list-chain. + + * gpg-connect-agent has new options to utilize descriptor passing. + + Noteworthy changes in version 1.9.22 (2006-07-27) ------------------------------------------------- Deleted: trunk/README.CVS Copied: trunk/README.SVN (from rev 4245, trunk/README.CVS) =================================================================== --- trunk/README.CVS 2006-09-07 06:42:55 UTC (rev 4245) +++ trunk/README.SVN 2006-09-13 15:57:30 UTC (rev 4248) @@ -0,0 +1,51 @@ +If you are building from Subversion, run the script + +./autogen.sh + +first, to make sure that you have all the necessary maintainer tools +are installed and to build the actual configuration files. Then run + +./configure --enable-maintainer-mode + +followed by the usual make. + +If autogen.sh complains about insufficient versions of the required +tools, or the tools are not installed, you may use environment +variables to override the default tool names: + + AUTOMAKE_SUFFIX is used as a suffix for all tools from the automake + package. For example + AUTOMAKE_SUFFIX="-1.7" ./autogen.sh + uses "automake-1.7" and "aclocal-1.7. + AUTOMAKE_PREFIX is used as a prefix for all tools from the automake + page and may be combined with AUTOMAKE_SUFFIX. e.g.: + AUTOMAKE_PREFIX=/usr/foo/bin ./autogen.sh + uses "automake" and "aclocal" in the /usr/foo/bin + directory. + AUTOCONF_SUFFIX is used as a suffix for all tools from the automake + package + AUTOCONF_PREFIX is used as a prefix for all tools from the automake + package + GETTEXT_SUFFIX is used as a suffix for all tools from the gettext + package + GETTEXT_PREFIX is used as a prefix for all tools from the gettext + package + +It is also possible to use the variable name AUTOMAKE, AUTOCONF, +ACLOCAL, AUTOHEADER, GETTEXT and MSGMERGE to directly specify the name +of the programs to run. It is however better to use the suffix and +prefix forms as described above because that does not require +knowledge about the actual tools used by autgen.sh. + + +Please don't use autopoint, libtoolize or autoreconf unless you are +the current maintainer and want to update the standard configuration +files. All those files should be in the CVS and only updated manually +if the maintainer decides that newer versions are required. The +maintainer should also make sure that the required version of automake +et al. are properly indicated at the top of configure.ac and take care +to copy the files and not merely use symlinks. + + + + Modified: trunk/agent/ChangeLog =================================================================== --- trunk/agent/ChangeLog 2006-09-08 17:02:06 UTC (rev 4247) +++ trunk/agent/ChangeLog 2006-09-13 15:57:30 UTC (rev 4248) @@ -1,3 +1,11 @@ +2006-09-13 Werner Koch + + * preset-passphrase.c (main) [W32]: Check for WSAStartup error. + +2006-09-08 Werner Koch + + * call-scd.c: Add signal.h as we are referencing SIGUSR2. + 2006-09-06 Marcus Brinkmann * Makefile.am (AM_CFLAGS): Add $(GPG_ERR_CFLAGS). Modified: trunk/agent/call-scd.c =================================================================== --- trunk/agent/call-scd.c 2006-09-08 17:02:06 UTC (rev 4247) +++ trunk/agent/call-scd.c 2006-09-13 15:57:30 UTC (rev 4248) @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #ifndef HAVE_W32_SYSTEM Modified: trunk/agent/preset-passphrase.c =================================================================== --- trunk/agent/preset-passphrase.c 2006-09-08 17:02:06 UTC (rev 4247) +++ trunk/agent/preset-passphrase.c 2006-09-13 15:57:30 UTC (rev 4248) @@ -281,10 +281,15 @@ #ifdef HAVE_W32_SYSTEM /* Fixme: Need to initialize the Windows sockets: This should be moved to another place and we should make sure that it won't get - doen twice, like when Pth is used too. */ + done twice, like when Pth is used too. */ { WSADATA wsadat; - WSAStartup (0x202, &wsadat); + if (WSAStartup (0x202, &wsadat) ) + { + log_error ("error initializing socket library: ec=%d\n", + (int)WSAGetLastError () ); + return 2; + } } #endif Modified: trunk/autogen.sh =================================================================== --- trunk/autogen.sh 2006-09-08 17:02:06 UTC (rev 4247) +++ trunk/autogen.sh 2006-09-13 15:57:30 UTC (rev 4248) @@ -55,36 +55,32 @@ [ -z "$w32root" ] && w32root="$HOME/w32root" echo "Using $w32root as standard install directory" >&2 - # See whether we have the Debian cross compiler package or the - # old mingw32/cpd system - if i586-mingw32msvc-gcc --version >/dev/null 2>&1 ; then - host=i586-mingw32msvc - crossbindir=/usr/$host/bin - else - host=i386--mingw32 - if ! mingw32 --version >/dev/null; then - echo "We need at least version 0.3 of MingW32/CPD" >&2 - exit 1 - fi - crossbindir=`mingw32 --install-dir`/bin - # Old autoconf version required us to setup the environment - # with the proper tool names. - CC=`mingw32 --get-path gcc` - CPP=`mingw32 --get-path cpp` - AR=`mingw32 --get-path ar` - RANLIB=`mingw32 --get-path ranlib` - export CC CPP AR RANLIB + # Locate the cross compiler + crossbindir= + for host in i586-mingw32msvc i386-mingw32msvc; do + if ${host}-gcc --version >/dev/null 2>&1 ; then + crossbindir=/usr/${host}/bin + conf_CC="CC=${host}-gcc" + break; + fi + done + if [ -z "$crossbindir" ]; then + echo "Cross compiler kit not installed" >&2 + echo "Under Debian GNU/Linux, you may install it using" >&2 + echo " apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2 + echo "Stop." >&2 + exit 1 fi if [ -f "$tsdir/config.log" ]; then if ! head $tsdir/config.log | grep "$host" >/dev/null; then - echo "Pease run a 'make distclean' first" >&2 + echo "Please run a 'make distclean' first" >&2 exit 1 fi fi ./configure --enable-maintainer-mode --prefix=${w32root} \ - --host=i586-mingw32msvc --build=${build} \ + --host=${host} --build=${build} \ --with-gpg-error-prefix=${w32root} \ --with-ksba-prefix=${w32root} \ --with-libgcrypt-prefix=${w32root} \ @@ -93,10 +89,6 @@ --with-pth-prefix=${w32root} \ --disable-gpg rc=$? - # Ugly hack to overcome a gettext problem. Someone should look into - # gettext to figure out why the po directory is not ignored as it used - # to be. - [ $rc = 0 ] && touch $tsdir/po/all exit $rc fi # ***** end W32 build script ******* Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2006-09-08 17:02:06 UTC (rev 4247) +++ trunk/doc/ChangeLog 2006-09-13 15:57:30 UTC (rev 4248) @@ -1,3 +1,12 @@ +2006-09-13 Werner Koch + + * gpg.texi (GPG Esoteric Options): Fixed typo in + --require-cross-certification and made it the default. + +2006-09-11 Werner Koch + + * HACKING: Cleaned up. + 2006-09-08 Werner Koch * yat2m.c (parse_file): Ignore @node lines immediately. Modified: trunk/doc/HACKING =================================================================== --- trunk/doc/HACKING 2006-09-08 17:02:06 UTC (rev 4247) +++ trunk/doc/HACKING 2006-09-13 15:57:30 UTC (rev 4248) @@ -6,76 +6,6 @@ ===> Under construction <======= -SOURCE FILES -============ - -Here is a list of directories with source files: - -jnlib/ utility functions -kbx/ keybox library -g10/ the gpg program here called gpg2 -sm/ the gpgsm program -agent/ the gpg-agent -scd/ the smartcard daemon -doc/ documentation - - - - -CVS Access -========== - -NOTE: CVS access has been disabled while we are migrating to Subversion. -Watch www.gnupg.org for instarctions on how to use the Subversion repository. - -Anonymous read-only CVS access is available: - - cvs -z3 -d :pserver:anoncvs@cvs.gnupg.org:/cvs/gnupg login - -use the password "anoncvs". To check out the the complete -archive use: - - cvs -z3 -d :pserver:anoncvs@cvs.gnupg.org:/cvs/gnupg \ - checkout -R STABLE-BRANCH-1-0 gnupg - -This service is provided to help you in hunting bugs and not to deliver -stable snapshots; it may happen that it even does not compile, so please -don't complain. CVS may put a high load on a server, so please don't poll -poll for new updates but wait for an announcement; to receive this you may -want to subscribe to: - - gnupg-commit-watchers@gnupg.org - -by sending a mail with subject "subscribe" to - - gnupg-commit-watchers-request@gnupg.org - - -You must run scripts/autogen.sh before doing the ./configure, -as this creates some needed while which are not in the CVS. -autogen.sh should checks that you have all required tools -installed. - - -RSYNC access -============ -The FTP archive is also available by anonymous rsync. A daily snapshot -of the CVS head revision is also available. See rsync(1) and try -"rsync ftp.gnupg.org::" to see available resources. - - - -Special Tools -============= -Documentation is based on the docbook DTD. Actually we have only the -man page for now. To build a man page you need the docbook-to-man -tool and all the other thinks needed for SGML processing. Debian -comes with the docbook tools and you only need this docbook-to-man -script which is comes with gtk-doc or download it from -ftp.openit.de:/pub/devel/sgml. If you don't have it everything -should still work fine but you will have only a dummy man page. - - RFCs ==== @@ -98,44 +28,23 @@ -Debug Flags ------------ -Use the option "--debug n" to output debug information. This option -can be used multiple times, all values are ORed; n maybe prefixed with -0x to use hex-values. - - value used for - ----- ---------------------------------------------- - 1 packet reading/writing - 2 MPI details - 4 ciphers and primes (may reveal sensitive data) - 8 iobuf filter functions - 16 iobuf stuff - 32 memory allocation stuff - 64 caching - 128 show memory statistics at exit - 256 trust verification stuff - - - - Directory Layout ---------------- - ./ Readme, configure - ./scripts Scripts needed by configure and others - ./doc Documentation - ./util General purpose utility function - ./mpi Multi precision integer library - ./cipher Cryptographic functions - ./g10 GnuPG application - ./tools Some helper and demo programs - ./keybox The keybox library (under construction) - ./gcrypt Stuff needed to build libgcrypt (under construction) + ./ Readme, configure + ./agent Gpg-agent and related tools + ./doc Documentation + ./doc Documentation + ./g10 Gpg program here called gpg2 + ./jnlib Utility functions + ./kbx Keybox library + ./scd Smartcard daemon + ./scripts Scripts needed by configure and others + ./sm Gpgsm program Detailed Roadmap ---------------- -g10/g10.c Main module with option parsing and all the stuff you have +g10/gpg.c Main module with option parsing and all the stuff you have to do on startup. Also has the exout handler and some helper functions. g10/sign.c Create signature and optionally encrypt @@ -208,17 +117,28 @@ ----------------- Use only the functions: - m_alloc() - m_alloc_clear() - m_strdup() - m_free() + xmalloc + xmalloc_secure + xtrymalloc + xtrymalloc_secure + xcalloc + xcalloc_secure + xtrycalloc + xtrycalloc_secure + xrealloc + xtryrealloc + xstrdup + xtrystrdup + xfree -If you want to store a passphrase or some other sensitive data you may -want to use m_alloc_secure() instead of m_alloc(), as this puts the data -into a memory region which is protected from swapping (on some platforms). -m_free() works for both. This functions will not return if there is not -enough memory available. +The *secure versions allocated memory in the secure memory. That is, +swapping out of this memory is avoided and is gets overwritten on +free. Use this for passphrases, session keys and other sensitive +material. This memory set aside for secure memory is linited to a few +k. In general the function don't print a memeory message and +terminate the process if there is not enough memory available. The +"try" versions of the functions return NULL instead. Logging @@ -254,68 +174,3 @@ easier to understand. -How to use the message digest functions ---------------------------------------- -cipher/md.c implements an interface to hash (message digest functions). - -a) If you have a common part of data and some variable parts - and you need to hash of the concatenated parts, you can use this: - md = md_open(...) - md_write( md, common_part ) - md1 = md_copy( md ) - md_write(md1, part1) - md_final(md1); - digest1 = md_read(md1) - md2 = md_copy( md ) - md_write(md2, part2) - md_final(md2); - digest2 = md_read(md2) - - An example are key signatures; the key packet is the common part - and the user-id packets are the variable parts. - -b) If you need a running digest you should use this: - md = md_open(...) - md_write( md, part1 ) - digest_of_part1 = md_digest( md ); - md_write( md, part2 ) - digest_of_part1_cat_part2 = md_digest( md ); - .... - -Both methods may be combined. [Please see the source for the real syntax] - - - - -How to use the cipher functions -------------------------------- -cipher/cipher.c implements the interface to symmetric encryption functions. -As usual you have a function to open a cipher (which returns a handle to be used -with all other functions), some functions to set the key and other stuff and -a encrypt and decrypt function which does the real work. You probably know -how to work with files - so it should really be easy to work with these -functions. Here is an example: - - CIPHER_HANDLE hd; - - hd = cipher_open( CIPHER_ALGO_TWOFISH, CIPHER_MODE_CFB, 0 ); - if( !hd ) - oops( use other function to check for the real error ); - rc = cipher_setkey( hd, key256bit, 32 ) ) - if( rc ) - oops( weak key or something like this ); - cipher_setiv( hd, some_IV_or_NULL_for_all_zeroes ); - cipher_encrypt( hd, plain, cipher, size ); - cipher_close( hd ); - - - -How to use the public key functions ------------------------------------ -cipher/pubkey.c implements the interface to asymmetric encryption and -signature functions. This is basically the same as with the symmetric -counterparts, but due to their nature it is a little bit more complicated. - - [Give an example] - - Modified: trunk/doc/gpg.texi =================================================================== --- trunk/doc/gpg.texi 2006-09-08 17:02:06 UTC (rev 4247) +++ trunk/doc/gpg.texi 2006-09-13 15:57:30 UTC (rev 4248) @@ -2178,12 +2178,11 @@ handing out the secret key. @item --require-cross-certification -@itemx --no-require-certification +@itemx --no-require-cross-certification When verifying a signature made from a subkey, ensure that the cross certification "back signature" on the subkey is present and valid. This protects against a subtle attack against subkeys that can sign. -Currently defaults to --no-require-cross-certification, but will be -changed to --require-cross-certification in the future. +Defaults to --require-cross-certification for @command{gpg2}. @item --ask-sig-expire @itemx --no-ask-sig-expire Modified: trunk/doc/gpgsm.texi =================================================================== --- trunk/doc/gpgsm.texi 2006-09-08 17:02:06 UTC (rev 4247) +++ trunk/doc/gpgsm.texi 2006-09-13 15:57:30 UTC (rev 4248) @@ -184,11 +184,20 @@ List certificates matching @var{pattern} using an external server. This utilizes the @code{dirmngr} service. +@item --list-chain +@opindex list-chain +Same as @option{--list-keys} but also prints all keys making up the chain. + + @item --dump-keys @opindex dump-keys List all available certificates stored in the local key database using a format useful mainly for debugging. +@item --dump-chain +@opindex dump-chain +Same as @option{--dump-keys} but also prints all keys making up the chain. + @item --dump-secret-keys @opindex dump-secret-keys List all available certificates for which a corresponding a secret key Modified: trunk/doc/tools.texi =================================================================== --- trunk/doc/tools.texi 2006-09-08 17:02:06 UTC (rev 4247) +++ trunk/doc/tools.texi 2006-09-13 15:57:30 UTC (rev 4248) @@ -989,6 +989,22 @@ Do not run any special initializations or environment checks. This may be used to directly connect to any Assuan style socket server. +@item -E +@itemx --exec +@opindex exec +Take the rest of the command line as a program and it's arguments and +execute it as an assuan server. Here is how you would run @command{gpgsm}: +@smallexample + gpg-connect-agent --exec gpgsm --server +@end smallexample + + +@item --no-ext-connect +@opindex no-ext-connect +When using @option{-S} or @option{--exec}, @command{gpg-connect-agent} +connects to the assuan server in extended mode to allow descriptor +passing. This option makes it use the old mode. + @end table @mansect control commands @@ -1020,6 +1036,15 @@ @item /cleardef Delete all definitions +@item /sendfd @var{file} @var{mode} +Open @var{file} in @var{mode} (which needs to be a valid @code{fopen} +mode string) and send the file descriptor to the server. This is +usually followed by a command like @code{INPUT FD} to set the +input source for other commands. + +@item /recvfd +Not yet implemented. + @item /help Print a list of available control commands. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2006-09-08 17:02:06 UTC (rev 4247) +++ trunk/g10/ChangeLog 2006-09-13 15:57:30 UTC (rev 4248) @@ -1,3 +1,7 @@ +2006-09-13 Werner Koch + + * gpg.c (main): Made --require-cross-certification the default. + 2006-09-06 Marcus Brinkmann * Makefile.am (gpg2_LDADD, gpgv2_LDADD): Replace -lassuan and Modified: trunk/g10/gpg.c =================================================================== --- trunk/g10/gpg.c 2006-09-08 17:02:06 UTC (rev 4247) +++ trunk/g10/gpg.c 2006-09-13 15:57:30 UTC (rev 4248) @@ -1834,6 +1834,7 @@ opt.rfc2440_text=1; opt.def_sig_expire="0"; opt.def_cert_expire="0"; + opt.require_cross_cert = 1; set_homedir ( default_homedir () ); /* Check whether we have a config file on the command line. */ Modified: trunk/sm/ChangeLog =================================================================== --- trunk/sm/ChangeLog 2006-09-08 17:02:06 UTC (rev 4247) +++ trunk/sm/ChangeLog 2006-09-13 15:57:30 UTC (rev 4248) @@ -1,3 +1,17 @@ +2006-09-13 Werner Koch + + * keylist.c (list_internal_keys): Print marker line to FP and not + to stdout. + + * gpgsm.c (main): All list key list commands now make ose of + --output. Cleaned up calls to list modes. New command + --dump-chain. Renamed --list-sigs to --list-chain and added an + alias for the old one. + + * server.c (cmd_message): Changed to use assuan_command_parse_fd. + (option_handler): New option list-to-output. + (do_listkeys): Use it. + 2006-09-06 Werner Koch * gpgsm.h (OUT_OF_CORE): Removed and changed all callers to Modified: trunk/sm/gpgsm.c =================================================================== --- trunk/sm/gpgsm.c 2006-09-08 17:02:06 UTC (rev 4247) +++ trunk/sm/gpgsm.c 2006-09-13 15:57:30 UTC (rev 4248) @@ -80,7 +80,7 @@ aVerify, aVerifyFiles, aListExternalKeys, - aListSigs, + aListChain, aSendKeys, aRecvKeys, aExport, @@ -93,6 +93,7 @@ aPasswd, aGPGConfList, aDumpKeys, + aDumpChain, aDumpSecretKeys, aDumpExternalKeys, aKeydbClearSomeCertFlags, @@ -251,8 +252,7 @@ { aListKeys, "list-keys", 256, N_("list keys")}, { aListExternalKeys, "list-external-keys", 256, N_("list external keys")}, { aListSecretKeys, "list-secret-keys", 256, N_("list secret keys")}, - { aListSigs, "list-sigs", 256, N_("list certificate chain")}, - { aListSigs, "check-sigs",256, "@"}, + { aListChain, "list-chain", 256, N_("list certificate chain")}, { oFingerprint, "fingerprint", 256, N_("list keys and fingerprints")}, { aKeygen, "gen-key", 256, N_("generate a new key pair")}, { aDeleteKey, "delete-key",256, N_("remove key from the public keyring")}, @@ -269,6 +269,7 @@ { aGPGConfList, "gpgconf-list", 256, "@" }, { aDumpKeys, "dump-keys", 256, "@"}, + { aDumpChain, "dump-chain", 256, "@"}, { aDumpExternalKeys, "dump-external-keys", 256, "@"}, { aDumpSecretKeys, "dump-secret-keys", 256, "@"}, { aKeydbClearSomeCertFlags, "keydb-clear-some-cert-flags", 256, "@"}, @@ -428,9 +429,11 @@ { oWithValidation, "with-validation", 0, "@"}, { oWithMD5Fingerprint, "with-md5-fingerprint", 0, "@"}, { oWithEphemeralKeys, "with-ephemeral-keys", 0, "@"}, - { aListKeys, "list-key", 0, "@" }, /* alias */ - { aListSigs, "list-sig", 0, "@" }, /* alias */ - { aListSigs, "check-sig",0, "@" }, /* alias */ + { aListKeys, "list-key", 256, "@" }, /* alias */ + { aListChain, "list-sig", 256, "@" }, /* alias */ + { aListChain, "list-sigs",256, "@" }, /* alias */ + { aListChain, "check-sig",256, "@" }, /* alias */ + { aListChain, "check-sigs",256, "@"}, /* alias */ { oSkipVerify, "skip-verify",0, "@" }, { oCompressKeys, "compress-keys",0, "@"}, { oCompressSigs, "compress-sigs",0, "@"}, @@ -930,12 +933,13 @@ case aExport: case aExportSecretKeyP12: case aDumpKeys: + case aDumpChain: case aDumpExternalKeys: case aDumpSecretKeys: case aListKeys: case aListExternalKeys: case aListSecretKeys: - case aListSigs: + case aListChain: case aLearnCard: case aPasswd: case aKeydbClearSomeCertFlags: @@ -1518,52 +1522,43 @@ free_strlist(sl); break; - case aListSigs: - ctrl.with_chain = 1; + case aListChain: + case aDumpChain: + ctrl.with_chain = 1; case aListKeys: - for (sl=NULL; argc; argc--, argv++) - add_to_strlist (&sl, *argv); - gpgsm_list_keys (&ctrl, sl, stdout, (0 | (1<<6))); - free_strlist(sl); - break; - case aDumpKeys: - for (sl=NULL; argc; argc--, argv++) - add_to_strlist (&sl, *argv); - gpgsm_list_keys (&ctrl, sl, stdout, (256 | (1<<6))); - free_strlist(sl); - break; - case aListExternalKeys: - for (sl=NULL; argc; argc--, argv++) - add_to_strlist (&sl, *argv); - gpgsm_list_keys (&ctrl, sl, stdout, - (0 | (1<<7))); - free_strlist(sl); - break; - case aDumpExternalKeys: - for (sl=NULL; argc; argc--, argv++) - add_to_strlist (&sl, *argv); - gpgsm_list_keys (&ctrl, sl, stdout, - (256 | (1<<7))); - free_strlist(sl); - break; - case aListSecretKeys: - for (sl=NULL; argc; argc--, argv++) - add_to_strlist (&sl, *argv); - gpgsm_list_keys (&ctrl, sl, stdout, (2 | (1<<6))); - free_strlist(sl); - break; - case aDumpSecretKeys: - for (sl=NULL; argc; argc--, argv++) - add_to_strlist (&sl, *argv); - gpgsm_list_keys (&ctrl, sl, stdout, (256 | 2 | (1<<6))); - free_strlist(sl); + { + unsigned int mode; + FILE *fp; + + switch (cmd) + { + case aListChain: + case aListKeys: mode = (0 | 0 | (1<<6)); break; + case aDumpChain: + case aDumpKeys: mode = (256 | 0 | (1<<6)); break; + case aListExternalKeys: mode = (0 | 0 | (1<<7)); break; + case aDumpExternalKeys: mode = (256 | 0 | (1<<7)); break; + case aListSecretKeys: mode = (0 | 2 | (1<<6)); break; + case aDumpSecretKeys: mode = (256 | 2 | (1<<6)); break; + default: BUG(); + } + + fp = open_fwrite (opt.outfile?opt.outfile:"-"); + for (sl=NULL; argc; argc--, argv++) + add_to_strlist (&sl, *argv); + gpgsm_list_keys (&ctrl, sl, fp, mode); + free_strlist(sl); + if (fp != stdout) + fclose (fp); + } break; + case aKeygen: /* generate a key */ log_error ("this function is not yet available from the commandline\n"); break; Modified: trunk/sm/keylist.c =================================================================== --- trunk/sm/keylist.c 2006-09-08 17:02:06 UTC (rev 4247) +++ trunk/sm/keylist.c 2006-09-13 15:57:30 UTC (rev 4248) @@ -1130,7 +1130,7 @@ /* List all internal keys or just the keys given as NAMES. MODE is a bit vector to specify what keys are to be included; see gpgsm_list_keys (below) for details. If RAW_MODE is true, the raw - output mode will be used intead of the standard beautified one. + output mode will be used instead of the standard beautified one. */ static gpg_error_t list_internal_keys (ctrl_t ctrl, STRLIST names, FILE *fp, @@ -1229,7 +1229,7 @@ { fprintf (fp, "%s\n", resname ); for (i=strlen(resname); i; i-- ) - putchar('-'); + putc ('-', fp); putc ('\n', fp); lastresname = resname; } Modified: trunk/sm/server.c =================================================================== --- trunk/sm/server.c 2006-09-08 17:02:06 UTC (rev 4247) +++ trunk/sm/server.c 2006-09-13 15:57:30 UTC (rev 4248) @@ -44,6 +44,7 @@ int message_fd; int list_internal; int list_external; + int list_to_output; /* Write keylistings to the output fd. */ certlist_t recplist; certlist_t signerlist; certlist_t default_recplist; /* As set by main() - don't release. */ @@ -171,6 +172,11 @@ else return gpg_error (GPG_ERR_ASS_PARAMETER); } + else if (!strcmp (key, "list-to-output")) + { + int i = *value? atoi (value) : 0; + ctrl->server_local->list_to_output = i; + } else if (!strcmp (key, "with-validation")) { int i = *value? atoi (value) : 0; @@ -624,40 +630,33 @@ static int cmd_message (assuan_context_t ctx, char *line) { - char *endp; + int rc; int fd; ctrl_t ctrl = assuan_get_pointer (ctx); - if (strncmp (line, "FD=", 3)) - return set_error (GPG_ERR_ASS_SYNTAX, "FD= expected"); - line += 3; - if (!digitp (line)) - return set_error (GPG_ERR_ASS_SYNTAX, "number required"); - fd = strtoul (line, &endp, 10); - if (*endp) - return set_error (GPG_ERR_ASS_SYNTAX, "garbage found"); + rc = assuan_command_parse_fd (ctx, line, &fd); + if (rc) + return rc; if (fd == -1) return set_error (GPG_ERR_ASS_NO_INPUT, NULL); - ctrl->server_local->message_fd = fd; return 0; } - +/* LISTKEYS [] + LISTSECRETKEYS [] +*/ static int do_listkeys (assuan_context_t ctx, char *line, int mode) { ctrl_t ctrl = assuan_get_pointer (ctx); - FILE *fp = assuan_get_data_fp (ctx); + FILE *fp; char *p; STRLIST list, sl; unsigned int listmode; gpg_error_t err; - if (!fp) - return set_error (GPG_ERR_ASS_GENERAL, "no data stream"); - - /* break the line down into an STRLIST */ + /* Break the line down into an STRLIST. */ list = NULL; for (p=line; *p; line = p) { @@ -680,6 +679,21 @@ } } + if (ctrl->server_local->list_to_output) + { + if ( assuan_get_output_fd (ctx) == -1 ) + return set_error (GPG_ERR_ASS_NO_OUTPUT, NULL); + fp = fdopen (assuan_get_output_fd (ctx), "w"); + if (!fp) + return set_error (GPG_ERR_ASS_GENERAL, "fdopen() failed"); + } + else + { + fp = assuan_get_data_fp (ctx); + if (!fp) + return set_error (GPG_ERR_ASS_GENERAL, "no data stream"); + } + ctrl->with_colons = 1; listmode = mode; if (ctrl->server_local->list_internal) @@ -688,6 +702,11 @@ listmode |= (1<<7); err = gpgsm_list_keys (assuan_get_pointer (ctx), list, fp, listmode); free_strlist (list); + if (ctrl->server_local->list_to_output) + { + fclose (fp); + assuan_close_output_fd (ctx); + } return err; } @@ -793,9 +812,9 @@ memset (&ctrl, 0, sizeof ctrl); gpgsm_init_default_ctrl (&ctrl); - /* For now we use a simple pipe based server so that we can work - from scripts. We will later add options to run as a daemon and - wait for requests on a Unix domain socket */ + /* We use a pipe based server so that we can work from scripts. + assuan_init_pipe_server will automagically detect when we are + called with a socketpair and ignore FIELDES in this case. */ filedes[0] = 0; filedes[1] = 1; rc = assuan_init_pipe_server (&ctx, filedes); Modified: trunk/tools/ChangeLog =================================================================== --- trunk/tools/ChangeLog 2006-09-08 17:02:06 UTC (rev 4247) +++ trunk/tools/ChangeLog 2006-09-13 15:57:30 UTC (rev 4248) @@ -1,3 +1,8 @@ +2006-09-12 Werner Koch + + * gpg-connect-agent.c (read_and_print_response): With verbosity + level 2 also print comment lines. + 2006-09-06 Werner Koch * gpg-connect-agent.c: Switch everything to new Assuan error code Modified: trunk/tools/gpg-connect-agent.c =================================================================== --- trunk/tools/gpg-connect-agent.c 2006-09-08 17:02:06 UTC (rev 4247) +++ trunk/tools/gpg-connect-agent.c 2006-09-13 15:57:30 UTC (rev 4248) @@ -41,10 +41,12 @@ oQuiet = 'q', oVerbose = 'v', oRawSocket = 'S', + oExec = 'E', oNoVerbose = 500, oHomedir, - oHex + oHex, + oNoExtConnect }; @@ -58,6 +60,9 @@ { oQuiet, "quiet", 0, N_("quiet") }, { oHex, "hex", 0, N_("print data out hex encoded") }, { oRawSocket, "raw-socket", 2, N_("|NAME|connect to Assuan socket NAME")}, + { oExec, "exec", 0, N_("run the Assuan server given on the command line")}, + { oNoExtConnect, "no-ext-connect", + 0, N_("do not use extended connect mode")}, /* hidden options */ { oNoVerbose, "no-verbose", 0, "@"}, @@ -74,6 +79,8 @@ const char *homedir; /* Configuration directory name */ int hex; /* Print data lines in hex format. */ const char *raw_socket; /* Name of socket to connect in raw mode. */ + int exec; /* Run the pgm given on the command line. */ + unsigned int connect_flags; /* Flags used for connecting. */ } opt; @@ -209,13 +216,68 @@ } +static void +do_sendfd (assuan_context_t ctx, char *line) +{ + FILE *fp; + char *name, *mode, *p; + int rc, fd; + /* Get file name. */ + name = line; + for (p=name; *p && !spacep (p); p++) + ; + if (*p) + *p++ = 0; + while (spacep (p)) + p++; + + /* Get mode. */ + mode = p; + if (!*mode) + mode = "r"; + else + { + for (p=mode; *p && !spacep (p); p++) + ; + if (*p) + *p++ = 0; + } + + /* Open and send. */ + fp = fopen (name, mode); + if (!fp) + { + log_error ("can't open `%s' in \"%s\" mode: %s\n", + name, mode, strerror (errno)); + return; + } + fd = fileno (fp); + + if (opt.verbose) + log_error ("file `%s' opened in \"%s\" mode, fd=%d\n", + name, mode, fd); + + rc = assuan_sendfd (ctx, fd); + if (rc) + log_error ("sednig descriptor %d failed: %s\n", fd, gpg_strerror (rc)); + fclose (fp); +} + + +static void +do_recvfd (assuan_context_t ctx, char *line) +{ + log_info ("This command has not yet been implemented\n"); +} + + + /* gpg-connect-agent's entry point. */ int main (int argc, char **argv) { ARGPARSE_ARGS pargs; - const char *fname; int no_more_options = 0; assuan_context_t ctx; char *line, *p; @@ -229,6 +291,7 @@ i18n_init(); opt.homedir = default_homedir (); + opt.connect_flags = 1; /* Use extended connect mode. */ /* Parse the command line. */ pargs.argc = &argc; @@ -244,6 +307,8 @@ case oHomedir: opt.homedir = pargs.r.ret_str; break; case oHex: opt.hex = 1; break; case oRawSocket: opt.raw_socket = pargs.r.ret_str; break; + case oExec: opt.exec = 1; break; + case oNoExtConnect: opt.connect_flags &= ~(1); break; default: pargs.err = 2; break; } @@ -251,14 +316,50 @@ if (log_get_errorcount (0)) exit (2); - - fname = argc ? *argv : NULL; - if (opt.raw_socket) + if (opt.exec) { - rc = assuan_socket_connect (&ctx, opt.raw_socket, 0); + if (!argc) + { + log_error (_("option \"%s\" requires a program " + "and optional arguments\n"), "--exec" ); + exit (1); + } + } + else if (argc) + usage (1); + + if (opt.exec && opt.raw_socket) + log_info (_("option \"%s\" ignored due to \"%s\"\n"), + "--raw-socket", "--exec"); + + if (opt.exec) + { + int no_close[3]; + + no_close[0] = fileno (stderr); + no_close[1] = log_get_fd (); + no_close[2] = -1; + rc = assuan_pipe_connect_ext (&ctx, *argv, (const char **)argv, + no_close, NULL, NULL, + opt.connect_flags); if (rc) { + log_error ("assuan_pipe_connect_ext failed: %s\n", + gpg_strerror (rc)); + exit (1); + } + + if (opt.verbose) + log_info ("server `%s' started\n", *argv); + + } + else if (opt.raw_socket) + { + rc = assuan_socket_connect_ext (&ctx, opt.raw_socket, 0, + opt.connect_flags); + if (rc) + { log_error ("can't connect to socket `%s': %s\n", opt.raw_socket, gpg_strerror (rc)); exit (1); @@ -325,18 +426,31 @@ { puts (p); } + else if (!strcmp (cmd, "sendfd")) + { + do_sendfd (ctx, p); + continue; + } + else if (!strcmp (cmd, "recvfd")) + { + do_recvfd (ctx, p); + continue; + } else if (!strcmp (cmd, "help")) { - puts ("Available commands:\n" - "/echo ARGS Echo ARGS.\n" - "/definqfile NAME FILE\n" - " Use content of FILE for inquiries with NAME.\n" - " NAME may be \"*\" to match any inquiry.\n" - "/definqprog NAME PGM\n" - " Run PGM for inquiries matching NAME and pass the\n" - " entire line to it as arguments.\n" - "/showdef Print all definitions.\n" - "/cleardef Delete all definitions.\n" + puts ( +"Available commands:\n" +"/echo ARGS Echo ARGS.\n" +"/definqfile NAME FILE\n" +" Use content of FILE for inquiries with NAME.\n" +" NAME may be \"*\" to match any inquiry.\n" +"/definqprog NAME PGM\n" +" Run PGM for inquiries matching NAME and pass the\n" +" entire line to it as arguments.\n" +"/showdef Print all definitions.\n" +"/cleardef Delete all definitions.\n" +"/sendfd FILE MODE Open FILE and pass descripor to server.\n" +"/recvfd Receive FD from server and print. \n" "/help Print this help."); } else @@ -352,7 +466,7 @@ continue; } if (*line == '#' || !*line) - continue; /* Don't expect a response for a coment line. */ + continue; /* Don't expect a response for a comment line. */ rc = read_and_print_response (ctx); if (rc) @@ -471,6 +585,12 @@ rc = assuan_read_line (ctx, &line, &linelen); if (rc) return rc; + + if (opt.verbose > 1 && *line == '#') + { + fwrite (line, linelen, 1, stdout); + putchar ('\n'); + } } while (*line == '#' || !linelen); From cvs at cvs.gnupg.org Thu Sep 14 13:17:34 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu Sep 14 12:32:43 2006 Subject: [svn] assuan - r201 - in trunk: . doc m4 src tests Message-ID: Author: wk Date: 2006-09-14 13:17:33 +0200 (Thu, 14 Sep 2006) New Revision: 201 Added: trunk/m4/Makefile.am trunk/m4/onceonly.m4 trunk/m4/socklen.m4 trunk/m4/sys_socket_h.m4 Removed: trunk/m4/ChangeLog Modified: trunk/AUTHORS trunk/ChangeLog trunk/Makefile.am trunk/NEWS trunk/TODO trunk/configure.ac trunk/doc/assuan.texi trunk/src/ChangeLog trunk/src/assuan-buffer.c trunk/src/assuan-client.c trunk/src/assuan-connect.c trunk/src/assuan-defs.h trunk/src/assuan-io.c trunk/src/assuan-pipe-connect.c trunk/src/assuan-pipe-server.c trunk/src/assuan-socket-server.c trunk/src/assuan.h trunk/tests/fdpassing.c Log: Preparing a new release Modified: trunk/AUTHORS =================================================================== --- trunk/AUTHORS 2006-09-13 15:55:25 UTC (rev 200) +++ trunk/AUTHORS 2006-09-14 11:17:33 UTC (rev 201) @@ -13,6 +13,8 @@ Marcus Brinkmann - Bug fixes. +g10 Code GmbH + - all work indicated by mail addresses in ChangeLogs Libassuan was orginally part of NewPG, a temporary fork of GnuPG, and Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-09-13 15:55:25 UTC (rev 200) +++ trunk/ChangeLog 2006-09-14 11:17:33 UTC (rev 201) @@ -1,3 +1,11 @@ +2006-09-14 Werner Koch + + Released 0.9.0. + + * configure.ac: Check for S_PEERCRED. Include check for socklen_t. + * m4/sys_socket_h.m4, m4/onceonly.m4, m4/socklen.m4: New. + * m4/Makefile.am: New. + 2006-09-05 Werner Koch * configure.ac (AH_BOTTOM): Define _ASSUAN_IN_LIBASSUAN. Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2006-09-13 15:55:25 UTC (rev 200) +++ trunk/Makefile.am 2006-09-14 11:17:33 UTC (rev 201) @@ -4,5 +4,9 @@ EXTRA_DIST = config.rpath config.rpath autogen.sh README.SVN -SUBDIRS = src doc tests +SUBDIRS = m4 src doc tests + +dist-hook: + echo "$(VERSION)" > $(distdir)/VERSION + Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-09-13 15:55:25 UTC (rev 200) +++ trunk/NEWS 2006-09-14 11:17:33 UTC (rev 201) @@ -1,5 +1,5 @@ -Noteworthy changes in version 0.9.0 -------------------------------------------------- +Noteworthy changes in version 0.9.0 (2006-09-14) +------------------------------------------------ * Internal cleanups to make inclusion of the code into libraries easier. @@ -17,12 +17,14 @@ printing of the full data, a new environment variable ASSUAN_FULL_LOGGING may be set to any value. - * Removed the assuan_domain functions. + * Removed the assuan_domain_* functions. - * New functions assuan_pipe_connect_ext and assuan_socket_connext_ext + * New functions assuan_pipe_connect_ext and assuan_socket_connect_ext to allow connections on a socketpair and to pass descriptors. + * New function assuan_get_peercred. + Noteworthy changes in version 0.6.10 (2005-06-20) ------------------------------------------------- Modified: trunk/TODO =================================================================== --- trunk/TODO 2006-09-13 15:55:25 UTC (rev 200) +++ trunk/TODO 2006-09-14 11:17:33 UTC (rev 201) @@ -1,6 +1,5 @@ -*- outline -*- -* waitpid is used instead of pth_waitpid as well as some other - functions. +* Check that we have Pth-ed all blocking fucntions. * When turning libassuan into a shared library, provide a general version as well as a Pth-enabled one. * Need API documentation. @@ -10,6 +9,3 @@ for unknown inquiries, albeit dirmngr itself would handle the returns for assuan_inquire gracefully. We need to check all applications whether it is safe to change this. -* Do a configure test for SO_PEERCRED. - We already use HAVE_SO_PEERCRED buty it never gets defined. -* Replace assuan_pipe_connect2 by assuan_pipe_connect. \ No newline at end of file Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-09-13 15:55:25 UTC (rev 200) +++ trunk/configure.ac 2006-09-14 11:17:33 UTC (rev 201) @@ -1,29 +1,31 @@ # configure.ac - for libassuan -# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc, +# Copyright (C) 2001, 2002, 2003, 2006 Free Software Foundation, Inc, # -# This file is part of GnuPG. -# -# GnuPG 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. -# -# GnuPG 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +# This file is part of Assuan. +# +# 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 2.1 of +# the License, or (at your option) any later version. +# +# Assuan 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 +# 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, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1301, USA # Process this file with autoconf to produce a configure script. + AC_PREREQ(2.59) min_automake_version="1.9.3" # Version number: Remember to change it immediately *after* a release. # Add a "-cvs" prefix for non-released code. -AC_INIT(libassuan, 0.9.0-cvs, gnupg-devel@gnupg.org) +AC_INIT(libassuan, 0.9.0, gnupg-devel@gnupg.org) # Note, that this is not yet available as a shared library. PACKAGE=$PACKAGE_NAME @@ -132,6 +134,9 @@ AC_TYPE_SIGNAL AC_DECL_SYS_SIGLIST +gl_TYPE_SOCKLEN_T + + # Checks for library functions. AC_CHECK_FUNCS(flockfile funlockfile) @@ -161,8 +166,31 @@ AC_CHECK_HEADERS(unistd.h) AC_REPLACE_FUNCS(setenv) + +# +# 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 + + + + # Create the config files. AC_CONFIG_FILES([Makefile]) +AC_CONFIG_FILES([m4/Makefile]) AC_CONFIG_FILES([src/Makefile]) AC_CONFIG_FILES([doc/Makefile]) AC_CONFIG_FILES([tests/Makefile]) Modified: trunk/doc/assuan.texi =================================================================== --- trunk/doc/assuan.texi 2006-09-13 15:55:25 UTC (rev 200) +++ trunk/doc/assuan.texi 2006-09-14 11:17:33 UTC (rev 201) @@ -558,6 +558,7 @@ @menu * Data Types:: Data types used by @sc{libassuan}. * Initializing the library:: How to initialize the library. +* Reading and Writing:: How to communicate with the peer. @end menu @@ -566,16 +567,17 @@ @section Data Types used by the library @sc{libassuan} uses a context approach to keep state. The following -data type is used all over the palce: +data type is used all over the place: @deftp {Data type} assuan_context_t The @code{assuan_context_t} type is a pointer to an object mainted -internally by the library. Certain assuan fucntions allocate such a +internally by the library. Certain Assuan functions allocate such a context and return it to the caller using this data type. Other functions take this data type to access the state created by these functions. @end deftp +@noindent For compatibility with older versions of @sc{libassuan} a data type for error return values exists: @@ -605,6 +607,7 @@ set @code{errno} whenever an error has occured. @end deftypefun +@noindent To integrate assuan logging and diagnostics into your own logging system, you may use the following two functions: @@ -618,7 +621,7 @@ setup a proper default. @end deftypefun -@deftypefun void assuan_set_assuan_log_prefix (const char *@var{text}) +@deftypefun void assuan_set_assuan_log_prefix (@w{const char *@var{text}}) Set the prefix to be used at the start of a line emitted by assuan on the log stream to @var{text}. The default is the empty string. @end deftypefun @@ -638,15 +641,114 @@ @end smallexample @end deftypefun +@node Reading and Writing +@section How to communicate with the peer + +What would be a IPC library without the ability to read and write data? +Not very useful. Libassuan has high level functions to take care of of +the more boring stuff but eventully actually data needs to be written. + +@noindent +The basic read and write functions are: + +@deftypefun assuan_error_t assuan_read_line (@w{assuan_context_t @var{ctx}}, @w{char **@var{line}}, @w{size_t *@var{linelen}}) + +Read the next line from the client or server and store a pointer to the +buffer holding that line at the address @var{line}. The valid length of +the lines is stored at the address of @var{linelen}. This buffer is +valid until the next read operation on the same context @var{ctx}. You +may modify the contet of this buffer. The buffer is invalid (i.e. must +not be used) if an error is returned. This function returns @code{0} on +success or an error code. +@end deftypefun + +@deftypefun assuan_error_t assuan_write_line (@w{assuan_context_t @var{ctx}}, @w{const char *@var{line}}) + +Write the string @var{line} to the other end. This string needs to be a +proper formatted Assuan protocol line and should not include a linefeed. +Sending linefeed or Nul characters is not possible and not alowed by the +assuan protocol. This fucntion shall not be used for sendind data (D) +lines. This function returns @code{0} on success or an error code. +@end deftypefun + +@noindent +To actually send bulk data lines a specialized function is available: + +@deftypefun assuan_error_t assuan_send_data (@w{assuan_context_t @var{ctx}}, @w{const void *@var{buffer}}, @w{size_t @var{length}}) + +This function is used by a server or a client to send +@var{length} bytes of bulk data in @var{buffer} to the other end. +The data will be escaped as required by the Assuan protocol and +may get buffered until a line is full. To force sending the data out +@var{buffer} may be passed as @code{NULL} and @var{length} be @code{0}. + +When used by a client this flush operation does also send the +terminating @code{END} command to terminate the response on an +``INQUIRE'' response. Note, that the fucntion @code{assuan_transact} +takes care of sending this @code{END} itself. + +@noindent +This function returns @code{0} on success or an error code. +@end deftypefun + + + + @c @c C L I E N T C O D E @c @node Client code @chapter How to develop an Assuan client -foo + +assuan_error_t assuan_pipe_connect (assuan_context_t *ctx, + const char *name, + const char *const argv[], + int *fd_child_list); +assuan_error_t assuan_pipe_connect2 (assuan_context_t *ctx, + const char *name, + const char *const argv[], + int *fd_child_list, + void (*atfork) (void*, int), + void *atforkvalue); +assuan_error_t assuan_pipe_connect_ext (assuan_context_t *ctx, + const char *name, + const char *const argv[], + int *fd_child_list, + void (*atfork) (void *, int), + void *atforkvalue, + unsigned int flags); + +assuan_error_t assuan_socket_connect (assuan_context_t *ctx, + const char *name, + pid_t server_pid); +assuan_error_t assuan_socket_connect_ext (assuan_context_t *ctx, + const char *name, + pid_t server_pid, + unsigned int flags); + +void assuan_disconnect (assuan_context_t ctx); + +assuan_error_t +assuan_transact (assuan_context_t ctx, + const char *command, + int (*data_cb)(void *, const void *, size_t), + void *data_cb_arg, + int (*inquire_cb)(void*, const char *), + void *inquire_cb_arg, + int (*status_cb)(void*, const char *), + void *status_cb_arg); + + +/* 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); + + @c @c S E R V E R C O D E @c @@ -654,16 +756,138 @@ @chapter How to develop an Assuan server bar +int assuan_register_command (assuan_context_t ctx, + const char *cmd_string, + int (*handler)(assuan_context_t, char *)); +int assuan_register_bye_notify (assuan_context_t ctx, + void (*fnc)(assuan_context_t)); +int assuan_register_reset_notify (assuan_context_t ctx, + void (*fnc)(assuan_context_t)); +int assuan_register_cancel_notify (assuan_context_t ctx, + void (*fnc)(assuan_context_t)); +int assuan_register_input_notify (assuan_context_t ctx, + void (*fnc)(assuan_context_t, const char *)); +int assuan_register_output_notify (assuan_context_t ctx, + void (*fnc)(assuan_context_t, const char *)); +int assuan_register_option_handler (assuan_context_t ctx, + int (*fnc)(assuan_context_t, + const char*, const char*)); + +int assuan_process (assuan_context_t ctx); +int assuan_process_next (assuan_context_t ctx); + +FILE *assuan_get_data_fp (assuan_context_t ctx); +assuan_error_t assuan_set_okay_line (assuan_context_t ctx, const char *line); +assuan_error_t assuan_write_status (assuan_context_t ctx, + const char *keyword, const char *text); + +/* 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). */ +assuan_error_t assuan_command_parse_fd (assuan_context_t ctx, char *line, + int *rfd); + +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_error_t assuan_close_input_fd (assuan_context_t ctx); +assuan_error_t assuan_close_output_fd (assuan_context_t ctx); + +int assuan_init_pipe_server (assuan_context_t *r_ctx, int filedes[2]); +void assuan_deinit_server (assuan_context_t ctx); + +int assuan_init_socket_server (assuan_context_t *r_ctx, int listen_fd); +int assuan_init_connected_socket_server (assuan_context_t *r_ctx, int fd); +int assuan_init_socket_server_ext (assuan_context_t *r_ctx, int fd, + unsigned int flags); + +assuan_error_t assuan_inquire (assuan_context_t ctx, const char *keyword, + unsigned char **r_buffer, size_t *r_length, + size_t maxlen); + + + @c @c U T I L I T I E S @c @node Utilities @chapter Utility functions -baz +void assuan_set_log_stream (assuan_context_t ctx, FILE *fp); +int assuan_set_error (assuan_context_t ctx, int err, const char *text); +void assuan_set_pointer (assuan_context_t ctx, void *pointer); +void *assuan_get_pointer (assuan_context_t ctx); +void assuan_begin_confidential (assuan_context_t ctx); +void assuan_end_confidential (assuan_context_t ctx); + +/* For context CTX, set the flag FLAG to VALUE. Values for flags + are usually 1 or 0 but certain flags might allow for other values; + see the description of the type assuan_flag_t for details. */ +void assuan_set_flag (assuan_context_t ctx, assuan_flag_t flag, int value); + +typedef enum + /* When using a pipe server, by default Assuan will wait for the + forked process to die in assuan_disconnect. In certain cases + this is not desirable. By setting this flag, the waitpid will + be skipped and the caller is responsible to cleanup a forked + process. */ + ASSUAN_NO_WAITPID = 1 +assuan_flag_t; + + + +/* Return the VALUE of FLAG in context CTX. */ +int assuan_get_flag (assuan_context_t ctx, assuan_flag_t flag); + + +const char *assuan_strerror (assuan_error_t err); + + +@deftypefun pid_t assuan_get_pid (@w{assuan_context_t @var{ctx}}) + +This function returns the pid of the connected connected peer. If that +pid is not known @code{-1} is returned. Note that it is not always +possible to learn the pid of the other process. For a pipe based server +the client knows it instantly and a mechnism is in palce to let the +server learn it. For socket based servers the pid is only available on +systems providing the ``SO_PEERCRED'' socket option @footnote{to our +knowledge only the Linux kernel has this feature}. +@end deftypefun + + +@deftypefun assuan_error_t assuan_get_peercred (@w{assuan_context_t @var{ctx}}, @w{pid_t *@var{pid}}, @w{uid_t *@var{uid}}, @w{gid_t *@var{pid}}) + +Return user credentials of the peer. This will work only on certain +systems and only when connected over a socket. If you are not +interested in some of the values, pass @code{NULL} instead of the +address of an appropriate variable. @var{pid}, @var{uid} and @var{gid} +are only set if the function succeeds and returns with @code{0}. + +As of now only the server is able to retrieve this information. Note, +that for getting the pid of the peer @code{assuan_get_pid} is usually +better suited. +@end deftypefun + + +int assuan_get_active_fds (assuan_context_t ctx, int what, + int *fdarray, int fdarraysize); + +int assuan_pending_line (assuan_context_t ctx); + +/* Return the stream which is currently being using for global logging. */ +FILE *assuan_get_assuan_log_stream (void); + +/* Return a prefix to be used at the start of a line emitted by assuan + on the log stream. The default implementation returns the empty + string, i.e. "" */ +const char *assuan_get_assuan_log_prefix (void); + + @c --------------------------------------------------------------------- @c Legal BS @c --------------------------------------------------------------------- Deleted: trunk/m4/ChangeLog Added: trunk/m4/Makefile.am =================================================================== --- trunk/m4/Makefile.am 2006-09-13 15:55:25 UTC (rev 200) +++ trunk/m4/Makefile.am 2006-09-14 11:17:33 UTC (rev 201) @@ -0,0 +1 @@ +EXTRA_DIST = socklen.m4 sys_socket_h.m4 onceonly.m4 Added: trunk/m4/onceonly.m4 =================================================================== --- trunk/m4/onceonly.m4 2006-09-13 15:55:25 UTC (rev 200) +++ trunk/m4/onceonly.m4 2006-09-14 11:17:33 UTC (rev 201) @@ -0,0 +1,66 @@ +# onceonly.m4 serial 4 (gettext-0.15) +dnl Copyright (C) 2002-2003, 2006 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl This file defines some "once only" variants of standard autoconf macros. +dnl AC_CHECK_HEADERS_ONCE like AC_CHECK_HEADERS +dnl AC_CHECK_FUNCS_ONCE like AC_CHECK_FUNCS +dnl AC_CHECK_DECLS_ONCE like AC_CHECK_DECLS +dnl AC_REQUIRE([AC_HEADER_STDC]) like AC_HEADER_STDC +dnl The advantage is that the check for each of the headers/functions/decls +dnl will be put only once into the 'configure' file. It keeps the size of +dnl the 'configure' file down, and avoids redundant output when 'configure' +dnl is run. +dnl The drawback is that the checks cannot be conditionalized. If you write +dnl if some_condition; then gl_CHECK_HEADERS(stdlib.h); fi +dnl inside an AC_DEFUNed function, the gl_CHECK_HEADERS macro call expands to +dnl empty, and the check will be inserted before the body of the AC_DEFUNed +dnl function. + +dnl This file is only needed in autoconf <= 2.59. Newer versions of autoconf +dnl have this macro built-in. But about AC_CHECK_DECLS_ONCE: note that in +dnl autoconf >= 2.60 the symbol separator is a comma, whereas here it is +dnl whitespace. + +dnl Autoconf version 2.57 or newer is recommended. +AC_PREREQ(2.54) + +# AC_CHECK_HEADERS_ONCE(HEADER1 HEADER2 ...) is a once-only variant of +# AC_CHECK_HEADERS(HEADER1 HEADER2 ...). +AC_DEFUN([AC_CHECK_HEADERS_ONCE], [ + : + AC_FOREACH([gl_HEADER_NAME], [$1], [ + AC_DEFUN([gl_CHECK_HEADER_]m4_quote(translit(m4_defn([gl_HEADER_NAME]), + [-./], [___])), [ + AC_CHECK_HEADERS(gl_HEADER_NAME) + ]) + AC_REQUIRE([gl_CHECK_HEADER_]m4_quote(translit(gl_HEADER_NAME, + [-./], [___]))) + ]) +]) + +# AC_CHECK_FUNCS_ONCE(FUNC1 FUNC2 ...) is a once-only variant of +# AC_CHECK_FUNCS(FUNC1 FUNC2 ...). +AC_DEFUN([AC_CHECK_FUNCS_ONCE], [ + : + AC_FOREACH([gl_FUNC_NAME], [$1], [ + AC_DEFUN([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME]), [ + AC_CHECK_FUNCS(m4_defn([gl_FUNC_NAME])) + ]) + AC_REQUIRE([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME])) + ]) +]) + +# AC_CHECK_DECLS_ONCE(DECL1 DECL2 ...) is a once-only variant of +# AC_CHECK_DECLS(DECL1, DECL2, ...). +AC_DEFUN([AC_CHECK_DECLS_ONCE], [ + : + AC_FOREACH([gl_DECL_NAME], [$1], [ + AC_DEFUN([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME]), [ + AC_CHECK_DECLS(m4_defn([gl_DECL_NAME])) + ]) + AC_REQUIRE([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME])) + ]) +]) Added: trunk/m4/socklen.m4 =================================================================== --- trunk/m4/socklen.m4 2006-09-13 15:55:25 UTC (rev 200) +++ trunk/m4/socklen.m4 2006-09-14 11:17:33 UTC (rev 201) @@ -0,0 +1,52 @@ +# socklen.m4 serial 4 +dnl Copyright (C) 2005, 2006 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Albert Chin, Windows fixes from Simon Josefsson. + +dnl Check for socklen_t: historically on BSD it is an int, and in +dnl POSIX 1g it is a type of its own, but some platforms use different +dnl types for the argument to getsockopt, getpeername, etc. So we +dnl have to test to find something that will work. + +dnl On mingw32, socklen_t is in ws2tcpip.h ('int'), so we try to find +dnl it there first. That file is included by gnulib's socket_.h, which +dnl all users of this module should include. Cygwin must not include +dnl ws2tcpip.h. +AC_DEFUN([gl_TYPE_SOCKLEN_T], + [AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl + AC_CHECK_TYPE([socklen_t], , + [AC_MSG_CHECKING([for socklen_t equivalent]) + AC_CACHE_VAL([gl_cv_gl_cv_socklen_t_equiv], + [# Systems have either "struct sockaddr *" or + # "void *" as the second argument to getpeername + gl_cv_socklen_t_equiv= + for arg2 in "struct sockaddr" void; do + for t in int size_t "unsigned int" "long int" "unsigned long int"; do + AC_TRY_COMPILE( + [#include + #include + + int getpeername (int, $arg2 *, $t *);], + [$t len; + getpeername (0, 0, &len);], + [gl_cv_socklen_t_equiv="$t"]) + test "$gl_cv_socklen_t_equiv" != "" && break + done + test "$gl_cv_socklen_t_equiv" != "" && break + done + ]) + if test "$gl_cv_socklen_t_equiv" = ""; then + AC_MSG_ERROR([Cannot find a type to use in place of socklen_t]) + fi + AC_MSG_RESULT([$gl_cv_socklen_t_equiv]) + AC_DEFINE_UNQUOTED([socklen_t], [$gl_cv_socklen_t_equiv], + [type to use in place of socklen_t if not defined])], + [#include + #if HAVE_SYS_SOCKET_H + # include + #elif HAVE_WS2TCPIP_H + # include + #endif])]) Added: trunk/m4/sys_socket_h.m4 =================================================================== --- trunk/m4/sys_socket_h.m4 2006-09-13 15:55:25 UTC (rev 200) +++ trunk/m4/sys_socket_h.m4 2006-09-14 11:17:33 UTC (rev 201) @@ -0,0 +1,23 @@ +# sys_socket_h.m4 serial 2 +dnl Copyright (C) 2005, 2006 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Simon Josefsson. + +AC_DEFUN([gl_HEADER_SYS_SOCKET], +[ + AC_CHECK_HEADERS_ONCE([sys/socket.h]) + if test $ac_cv_header_sys_socket_h = yes; then + SYS_SOCKET_H='' + else + dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make + dnl the check for those headers unconditional; yet cygwin reports + dnl that the headers are present but cannot be compiled (since on + dnl cygwin, all socket information should come from sys/socket.h). + AC_CHECK_HEADERS([winsock2.h ws2tcpip.h]) + SYS_SOCKET_H='sys/socket.h' + fi + AC_SUBST(SYS_SOCKET_H) +]) Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2006-09-13 15:55:25 UTC (rev 200) +++ trunk/src/ChangeLog 2006-09-14 11:17:33 UTC (rev 201) @@ -1,3 +1,15 @@ +2006-09-14 Werner Koch + + * assuan-io.c (_assuan_waitpid): New. Changed all waitpid calls + to this. + + * assuan.h (_ASSUAN_DEPRECATED): New internal macro. + (assuan_pipe_connect2): Declare deprecated. + (assuan_init_connected_socket_server): Declare deprecated. + + * assuan-connect.c (assuan_get_peercred): New. + * assuan-socket-server.c (accept_connection_bottom): Save uid and gid. + 2006-09-13 Werner Koch * assuan-client.c (assuan_transact): Need to map the error code. Modified: trunk/src/assuan-buffer.c =================================================================== --- trunk/src/assuan-buffer.c 2006-09-13 15:55:25 UTC (rev 200) +++ trunk/src/assuan-buffer.c 2006-09-14 11:17:33 UTC (rev 201) @@ -35,7 +35,7 @@ /* Extended version of write(2) to guarantee that all bytes are written. Returns 0 on success or -1 and ERRNO on failure. */ static int -writen (ASSUAN_CONTEXT ctx, const char *buffer, size_t length) +writen (assuan_context_t ctx, const char *buffer, size_t length) { while (length) { @@ -57,7 +57,7 @@ failure. EOF is indictated by setting the integer at address R_EOF. */ static int -readline (ASSUAN_CONTEXT ctx, char *buf, size_t buflen, +readline (assuan_context_t ctx, char *buf, size_t buflen, int *r_nread, int *r_eof) { size_t nleft = buflen; @@ -96,7 +96,7 @@ /* Function returns an Assuan error. */ int -_assuan_read_line (ASSUAN_CONTEXT ctx) +_assuan_read_line (assuan_context_t ctx) { char *line = ctx->inbound.line; int nread, atticlen; @@ -216,7 +216,7 @@ See also: assuan_pending_line(). */ assuan_error_t -assuan_read_line (ASSUAN_CONTEXT ctx, char **line, size_t *linelen) +assuan_read_line (assuan_context_t ctx, char **line, size_t *linelen) { assuan_error_t err; @@ -233,7 +233,7 @@ /* Return true if a full line is buffered (i.e. an entire line may be read without any I/O). */ int -assuan_pending_line (ASSUAN_CONTEXT ctx) +assuan_pending_line (assuan_context_t ctx) { return ctx && ctx->inbound.attic.pending; } @@ -300,7 +300,7 @@ assuan_error_t -assuan_write_line (ASSUAN_CONTEXT ctx, const char *line) +assuan_write_line (assuan_context_t ctx, const char *line) { size_t len; const char *s; @@ -329,7 +329,7 @@ int _assuan_cookie_write_data (void *cookie, const char *buffer, size_t orig_size) { - ASSUAN_CONTEXT ctx = cookie; + assuan_context_t ctx = cookie; size_t size = orig_size; char *line; size_t linelen; @@ -406,7 +406,7 @@ int _assuan_cookie_write_flush (void *cookie) { - ASSUAN_CONTEXT ctx = cookie; + assuan_context_t ctx = cookie; char *line; size_t linelen; @@ -462,7 +462,7 @@ **/ assuan_error_t -assuan_send_data (ASSUAN_CONTEXT ctx, const void *buffer, size_t length) +assuan_send_data (assuan_context_t ctx, const void *buffer, size_t length) { if (!ctx) return _assuan_error (ASSUAN_Invalid_Value); @@ -488,7 +488,7 @@ } assuan_error_t -assuan_sendfd (ASSUAN_CONTEXT ctx, int fd) +assuan_sendfd (assuan_context_t ctx, int fd) { if (! ctx->io->sendfd) return set_error (ctx, Not_Implemented, @@ -498,7 +498,7 @@ } assuan_error_t -assuan_receivefd (ASSUAN_CONTEXT ctx, int *fd) +assuan_receivefd (assuan_context_t ctx, int *fd) { if (! ctx->io->receivefd) return set_error (ctx, Not_Implemented, Modified: trunk/src/assuan-client.c =================================================================== --- trunk/src/assuan-client.c 2006-09-13 15:55:25 UTC (rev 200) +++ trunk/src/assuan-client.c 2006-09-14 11:17:33 UTC (rev 201) @@ -34,7 +34,7 @@ assuan_error_t -_assuan_read_from_server (ASSUAN_CONTEXT ctx, int *okay, int *off) +_assuan_read_from_server (assuan_context_t ctx, int *okay, int *off) { char *line; int linelen; @@ -130,7 +130,7 @@ * will altter return an Assuan error (write erro in most cases). **/ assuan_error_t -assuan_transact (ASSUAN_CONTEXT ctx, +assuan_transact (assuan_context_t ctx, const char *command, int (*data_cb)(void *, const void *, size_t), void *data_cb_arg, Modified: trunk/src/assuan-connect.c =================================================================== --- trunk/src/assuan-connect.c 2006-09-13 15:55:25 UTC (rev 200) +++ trunk/src/assuan-connect.c 2006-09-14 11:17:33 UTC (rev 201) @@ -50,10 +50,30 @@ } } -/* Return the PID of the peer or -1 if not known. */ +/* Return the PID of the peer or -1 if not known. This function works + in some situations where assuan_get_ucred fails. */ pid_t assuan_get_pid (assuan_context_t ctx) { return (ctx && ctx->pid)? ctx->pid : -1; } + +/* 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. */ +assuan_error_t +assuan_get_peercred (assuan_context_t ctx, pid_t *pid, uid_t *uid, gid_t *gid) +{ + if (!ctx) + return _assuan_error (ASSUAN_Invalid_Value); + if (!ctx->peercred.valid) + return _assuan_error (ASSUAN_General_Error); + if (pid) + *pid = ctx->peercred.pid; + if (uid) + *uid = ctx->peercred.uid; + if (gid) + *gid = ctx->peercred.gid; + return 0; +} Modified: trunk/src/assuan-defs.h =================================================================== --- trunk/src/assuan-defs.h 2006-09-13 15:55:25 UTC (rev 200) +++ trunk/src/assuan-defs.h 2006-09-14 11:17:33 UTC (rev 201) @@ -67,7 +67,7 @@ struct cmdtbl_s { const char *name; - int (*handler)(ASSUAN_CONTEXT, char *line); + int (*handler)(assuan_context_t, char *line); }; @@ -76,13 +76,13 @@ struct assuan_io { /* Routine to read from input_fd. */ - ssize_t (*readfnc) (ASSUAN_CONTEXT, void *, size_t); + ssize_t (*readfnc) (assuan_context_t, void *, size_t); /* Routine to write to output_fd. */ - ssize_t (*writefnc) (ASSUAN_CONTEXT, const void *, size_t); + ssize_t (*writefnc) (assuan_context_t, const void *, size_t); /* Send a file descriptor. */ - assuan_error_t (*sendfd) (ASSUAN_CONTEXT, int); + assuan_error_t (*sendfd) (assuan_context_t, int); /* Receive a file descriptor. */ - assuan_error_t (*receivefd) (ASSUAN_CONTEXT, int *); + assuan_error_t (*receivefd) (assuan_context_t, int *); }; @@ -140,6 +140,12 @@ int listen_fd; /* The fd we are listening on (used by socket servers) */ int connected_fd; /* helper */ + struct { + 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; /* Used for Unix domain sockets. */ struct sockaddr_un myaddr; @@ -158,20 +164,20 @@ int pendingfdscount; /* Number of received descriptors. */ } uds; - void (*deinit_handler)(ASSUAN_CONTEXT); - int (*accept_handler)(ASSUAN_CONTEXT); - int (*finish_handler)(ASSUAN_CONTEXT); + void (*deinit_handler)(assuan_context_t); + int (*accept_handler)(assuan_context_t); + int (*finish_handler)(assuan_context_t); struct cmdtbl_s *cmdtbl; size_t cmdtbl_used; /* used entries */ size_t cmdtbl_size; /* allocated size of table */ - void (*bye_notify_fnc)(ASSUAN_CONTEXT); - void (*reset_notify_fnc)(ASSUAN_CONTEXT); - void (*cancel_notify_fnc)(ASSUAN_CONTEXT); - int (*option_handler_fnc)(ASSUAN_CONTEXT,const char*, const char*); - void (*input_notify_fnc)(ASSUAN_CONTEXT, const char *); - void (*output_notify_fnc)(ASSUAN_CONTEXT, const char *); + void (*bye_notify_fnc)(assuan_context_t); + void (*reset_notify_fnc)(assuan_context_t); + void (*cancel_notify_fnc)(assuan_context_t); + int (*option_handler_fnc)(assuan_context_t,const char*, const char*); + void (*input_notify_fnc)(assuan_context_t, const char *); + void (*output_notify_fnc)(assuan_context_t, const char *); int input_fd; /* set by INPUT command */ int output_fd; /* set by OUTPUT command */ @@ -181,8 +187,8 @@ }; /*-- assuan-pipe-server.c --*/ -int _assuan_new_context (ASSUAN_CONTEXT *r_ctx); -void _assuan_release_context (ASSUAN_CONTEXT ctx); +int _assuan_new_context (assuan_context_t *r_ctx); +void _assuan_release_context (assuan_context_t ctx); /*-- assuan-uds.c --*/ void _assuan_uds_close_fds (assuan_context_t ctx); @@ -191,17 +197,18 @@ /*-- assuan-handler.c --*/ -int _assuan_register_std_commands (ASSUAN_CONTEXT ctx); +int _assuan_register_std_commands (assuan_context_t ctx); /*-- assuan-buffer.c --*/ -int _assuan_read_line (ASSUAN_CONTEXT ctx); +int _assuan_read_line (assuan_context_t ctx); int _assuan_cookie_write_data (void *cookie, const char *buffer, size_t size); int _assuan_cookie_write_flush (void *cookie); assuan_error_t _assuan_write_line (assuan_context_t ctx, const char *prefix, const char *line, size_t len); /*-- assuan-client.c --*/ -assuan_error_t _assuan_read_from_server (ASSUAN_CONTEXT ctx, int *okay, int *off); +assuan_error_t _assuan_read_from_server (assuan_context_t ctx, + int *okay, int *off); /*-- assuan-error.c --*/ @@ -254,8 +261,10 @@ /*-- assuan-io.c --*/ -ssize_t _assuan_simple_read (ASSUAN_CONTEXT ctx, void *buffer, size_t size); -ssize_t _assuan_simple_write (ASSUAN_CONTEXT ctx, const void *buffer, +pid_t _assuan_waitpid (pid_t pid, int *status, int options); + +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); ssize_t _assuan_simple_sendmsg (assuan_context_t ctx, struct msghdr *msg); ssize_t _assuan_simple_recvmsg (assuan_context_t ctx, struct msghdr *msg); Modified: trunk/src/assuan-io.c =================================================================== --- trunk/src/assuan-io.c 2006-09-13 15:55:25 UTC (rev 200) +++ trunk/src/assuan-io.c 2006-09-14 11:17:33 UTC (rev 201) @@ -25,13 +25,16 @@ #include #include +#include #if HAVE_SYS_UIO_H -#include +# include #endif #include #include #ifdef HAVE_W32_SYSTEM -#include +# include +#else +# include #endif #include "assuan-defs.h" @@ -46,12 +49,14 @@ #ifndef _ASSUAN_NO_PTH +extern pid_t pth_waitpid (pid_t pid, int *status, int options); extern ssize_t pth_read (int fd, void *buffer, size_t size); extern ssize_t pth_write (int fd, const void *buffer, size_t size); extern int pth_fdmode (int, int); extern int pth_select(int, fd_set*, fd_set*, fd_set*, struct timeval*); #ifndef HAVE_W32_SYSTEM +#pragma weak pth_waitpid #pragma weak pth_read #pragma weak pth_write #pragma weak pth_fdmode @@ -84,6 +89,17 @@ } #endif /*_ASSUAN_NO_PTH*/ +#ifndef HAVE_W32_SYSTEM +pid_t +_assuan_waitpid (pid_t pid, int *status, int options) +{ +#ifdef _ASSUAN_NO_PTH + return waitpid (pid, status, options); +#else + return (pth_waitpid ? pth_waitpid : waitpid) (pid, status, options); +#endif +} +#endif ssize_t @@ -98,7 +114,7 @@ return pth_read ? pth_read (ctx->inbound.fd, buffer, size) : recv (ctx->inbound.fd, buffer, size, 0); # endif -# endif +#endif } ssize_t Modified: trunk/src/assuan-pipe-connect.c =================================================================== --- trunk/src/assuan-pipe-connect.c 2006-09-13 15:55:25 UTC (rev 200) +++ trunk/src/assuan-pipe-connect.c 2006-09-14 11:17:33 UTC (rev 201) @@ -126,7 +126,7 @@ #ifndef HAVE_W32_SYSTEM #ifndef _ASSUAN_USE_DOUBLE_FORK if (!ctx->flags.no_waitpid) - waitpid (ctx->pid, NULL, 0); + _assuan_waitpid (ctx->pid, NULL, 0); ctx->pid = -1; #endif #endif /*!HAVE_W32_SYSTEM*/ @@ -342,7 +342,7 @@ } #ifdef _ASSUAN_USE_DOUBLE_FORK - waitpid ((*ctx)->pid, NULL, 0); + _assuan_waitpid ((*ctx)->pid, NULL, 0); (*ctx)->pid = -1; #endif @@ -525,7 +525,7 @@ #ifdef _ASSUAN_USE_DOUBLE_FORK - waitpid ((*ctx)->pid, NULL, 0); + _assuan_waitpid ((*ctx)->pid, NULL, 0); (*ctx)->pid = -1; #endif @@ -824,13 +824,7 @@ } -/* Connect to a server over a pipe, creating the assuan context and - returning it in CTX. The server filename is NAME, the argument - vector in ARGV. FD_CHILD_LIST is a -1 terminated list of file - descriptors not to close in the child. ATFORK is called in the - child right after the fork; ATFORKVALUE is passed as the first - argument and 0 is passed as the second argument. The ATFORK - function should only act if the second value is 0. */ + assuan_error_t assuan_pipe_connect2 (assuan_context_t *ctx, const char *name, const char *const argv[], Modified: trunk/src/assuan-pipe-server.c =================================================================== --- trunk/src/assuan-pipe-server.c 2006-09-13 15:55:25 UTC (rev 200) +++ trunk/src/assuan-pipe-server.c 2006-09-14 11:17:33 UTC (rev 201) @@ -34,20 +34,20 @@ static void -deinit_pipe_server (ASSUAN_CONTEXT ctx) +deinit_pipe_server (assuan_context_t ctx) { /* nothing to do for this simple server */ } static int -accept_connection (ASSUAN_CONTEXT ctx) +accept_connection (assuan_context_t ctx) { /* This is a NOP for a pipe server */ return 0; } static int -finish_connection (ASSUAN_CONTEXT ctx) +finish_connection (assuan_context_t ctx) { /* This is a NOP for a pipe server */ return 0; @@ -56,13 +56,13 @@ /* Create a new context. Note that the handlers are set up for a pipe server/client - this way we don't need extra dummy functions */ int -_assuan_new_context (ASSUAN_CONTEXT *r_ctx) +_assuan_new_context (assuan_context_t *r_ctx) { static struct assuan_io io = { _assuan_simple_read, _assuan_simple_write, 0, 0 }; - ASSUAN_CONTEXT ctx; + assuan_context_t ctx; int rc; *r_ctx = NULL; @@ -104,14 +104,14 @@ int -assuan_init_pipe_server (ASSUAN_CONTEXT *r_ctx, int filedes[2]) +assuan_init_pipe_server (assuan_context_t *r_ctx, int filedes[2]) { int rc; rc = _assuan_new_context (r_ctx); if (!rc) { - ASSUAN_CONTEXT ctx = *r_ctx; + assuan_context_t ctx = *r_ctx; const char *s; unsigned long ul; @@ -162,7 +162,7 @@ void -_assuan_release_context (ASSUAN_CONTEXT ctx) +_assuan_release_context (assuan_context_t ctx) { if (ctx) { @@ -173,7 +173,7 @@ } void -assuan_deinit_server (ASSUAN_CONTEXT ctx) +assuan_deinit_server (assuan_context_t ctx) { if (ctx) { Modified: trunk/src/assuan-socket-server.c =================================================================== --- trunk/src/assuan-socket-server.c 2006-09-13 15:55:25 UTC (rev 200) +++ trunk/src/assuan-socket-server.c 2006-09-14 11:17:33 UTC (rev 201) @@ -43,16 +43,24 @@ { int fd = ctx->connected_fd; + ctx->peercred.valid = 0; #ifdef HAVE_SO_PEERCRED { - /* This overrides any already set PID if the function returns a - valid one. */ struct ucred cr; - int cl = sizeof cr; + socklen_t cl = sizeof cr; - if ( !getsockopt (fd, SOL_SOCKET, SO_PEERCRED, &cr, &cl) - && cr.pid != (pid_t)-1 && cr.pid ) - ctx->pid = cr.pid; + if ( !getsockopt (fd, SOL_SOCKET, SO_PEERCRED, &cr, &cl)) + { + ctx->peercred.pid = cr.pid; + ctx->peercred.uid = cr.uid; + ctx->peercred.gid = cr.gid; + ctx->peercred.valid = 1; + + /* This overrides any already set PID if the function returns + a valid one. */ + if (cr.pid != (pid_t)-1 && cr.pid) + ctx->pid = cr.pid; + } } #endif @@ -117,7 +125,8 @@ return assuan_init_socket_server_ext (r_ctx, listen_fd, 0); } -/* Initialize a server using the already accepted socket FD. */ +/* 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) { Modified: trunk/src/assuan.h =================================================================== --- trunk/src/assuan.h 2006-09-13 15:55:25 UTC (rev 200) +++ trunk/src/assuan.h 2006-09-14 11:17:33 UTC (rev 201) @@ -99,6 +99,7 @@ #define assuan_socket_connect_ext _ASSUAN_PREFIX(assuan_socket_connect_ext) #define assuan_disconnect _ASSUAN_PREFIX(assuan_disconnect) #define assuan_get_pid _ASSUAN_PREFIX(assuan_get_pid) +#define assuan_get_peercred _ASSUAN_PREFIX(assuan_get_peercred) #define assuan_transact _ASSUAN_PREFIX(assuan_transact) #define assuan_inquire _ASSUAN_PREFIX(assuan_inquire) #define assuan_read_line _ASSUAN_PREFIX(assuan_read_line) @@ -168,9 +169,25 @@ #endif #endif -#ifndef _ASSUAN_ONLY_GPG_ERRORS + +/* Check for compiler features. */ +#if __GNUC__ +#define _ASSUAN_GCC_VERSION (__GNUC__ * 10000 \ + + __GNUC_MINOR__ * 100 \ + + __GNUC_PATCHLEVEL__) + +#if _ASSUAN_GCC_VERSION > 30100 +#define _ASSUAN_DEPRECATED __attribute__ ((__deprecated__)) +#endif +#endif +#ifndef _ASSUAN_DEPRECATED +#define _ASSUAN_DEPRECATED +#endif + + /* Assuan error codes. These are only used by old applications or those applications which won't make use of libgpg-error. */ +#ifndef _ASSUAN_ONLY_GPG_ERRORS typedef enum { #ifndef _ASSUAN_IN_LIBASSUAN @@ -311,7 +328,7 @@ struct assuan_context_s; typedef struct assuan_context_s *assuan_context_t; #ifndef _ASSUAN_ONLY_GPG_ERRORS -typedef struct assuan_context_s *ASSUAN_CONTEXT; +typedef struct assuan_context_s *ASSUAN_CONTEXT _ASSUAN_DEPRECATED; #endif /*_ASSUAN_ONLY_GPG_ERRORS*/ /*-- assuan-handler.c --*/ @@ -366,7 +383,8 @@ /*-- assuan-socket-server.c --*/ int assuan_init_socket_server (assuan_context_t *r_ctx, int listen_fd); -int assuan_init_connected_socket_server (assuan_context_t *r_ctx, int 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, unsigned int flags); @@ -380,7 +398,7 @@ const char *const argv[], int *fd_child_list, void (*atfork) (void*, int), - void *atforkvalue); + void *atforkvalue) _ASSUAN_DEPRECATED; assuan_error_t assuan_pipe_connect_ext (assuan_context_t *ctx, const char *name, const char *const argv[], @@ -401,6 +419,8 @@ /*-- assuan-connect.c --*/ void assuan_disconnect (assuan_context_t ctx); pid_t assuan_get_pid (assuan_context_t ctx); +assuan_error_t assuan_get_peercred (assuan_context_t ctx, + pid_t *pid, uid_t *uid, gid_t *gid); /*-- assuan-client.c --*/ assuan_error_t Modified: trunk/tests/fdpassing.c =================================================================== --- trunk/tests/fdpassing.c 2006-09-13 15:55:25 UTC (rev 200) +++ trunk/tests/fdpassing.c 2006-09-14 11:17:33 UTC (rev 201) @@ -124,6 +124,9 @@ log_error ("assuan_accept failed: %s\n", assuan_strerror (rc)); break; } + + log_info ("client connected. Client's pid is %ld\n", + (long)assuan_get_pid (ctx)); rc = assuan_process (ctx); if (rc) @@ -151,9 +154,10 @@ FILE *fp; int i; - log_info ("client started\n"); + log_info ("client started. Servers's pid is %ld\n", + (long)assuan_get_pid (ctx)); - for (i=0; i < 8; i++) + for (i=0; i < 6; i++) { fp = fopen ("/etc/motd", "r"); if (!fp) From cvs at cvs.gnupg.org Thu Sep 14 13:23:01 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu Sep 14 12:38:07 2006 Subject: [svn] assuan - r202 - tags Message-ID: Author: wk Date: 2006-09-14 13:23:01 +0200 (Thu, 14 Sep 2006) New Revision: 202 Added: tags/libassuan-0.9.0/ Log: From cvs at cvs.gnupg.org Thu Sep 14 16:24:36 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu Sep 14 15:39:42 2006 Subject: [svn] gpg-error - r179 - in trunk: . lang/cl m4 po src tests Message-ID: Author: wk Date: 2006-09-14 16:24:34 +0200 (Thu, 14 Sep 2006) New Revision: 179 Added: trunk/m4/autobuild.m4 trunk/tests/t-syserror.c Modified: trunk/ChangeLog trunk/NEWS trunk/autogen.sh trunk/configure.ac trunk/lang/cl/gpg-error-package.lisp trunk/lang/cl/gpg-error.lisp trunk/m4/ChangeLog trunk/m4/Makefile.am trunk/po/ChangeLog trunk/po/de.po trunk/po/fr.po trunk/po/libgpg-error.pot trunk/po/pl.po trunk/po/ro.po trunk/po/vi.po trunk/src/code-from-errno.c trunk/src/gpg-error.h.in trunk/src/strerror.c trunk/tests/Makefile.am Log: Ready for a new release Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-09-08 10:06:27 UTC (rev 178) +++ trunk/ChangeLog 2006-09-14 14:24:34 UTC (rev 179) @@ -1,3 +1,27 @@ +2006-09-14 Werner Koch + + Released 1.4. + + * configure.ac: Set LT version to C3/A3/R0. + (AB_INIT): New. + + * autogen.sh (--build-w32): Better cross-compiler locating. + + * src/strerror.c (system_strerror_r): Made static. + + * tests/t-syserror.c: New. + * tests/Makefile.am (TESTS): Added new test. + + * lang/cl/gpg-error.lisp ("gpg_err_code_from_syserror"): New. + (gpg-err-code-from-syserror): New. + (gpg-error-from-syserror): New. + * lang/cl/gpg-error-package.lisp: Export new functions + + * src/gpg-error.h.in (gpg_error_from_syserror): New. + * src/code-from-errno.c (gpg_err_code_from_errno): Cosmetic change + to first check whether ERR is zero. + (gpg_err_code_from_syserror): New. + 2006-09-06 Werner Koch * src/err-codes.h.in: Add GPG_ERR_UNKNOWN_OPTION and Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-09-08 10:06:27 UTC (rev 178) +++ trunk/NEWS 2006-09-14 14:24:34 UTC (rev 179) @@ -1,4 +1,4 @@ -Noteworthy changes in version 1.4 (unreleased) +Noteworthy changes in version 1.4 (2006-09-14) ---------------------------------------------- * Support for Common Lisp is included. @@ -12,8 +12,13 @@ * New error source GPG_ERR_SOURCE_ANY to allow proper use of libgpg-error even if a specific source is not available. + * New convenience functions gpg_err_code_from_syserror and + gpg_error_from_syserror which make sure never to return 0. + * Interface changes relative to the 1.2 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + gpg_err_code_from_syserror NEW + gpg_error_from_syserror NEW GPG_ERR_SOURCE_ANY NEW GPG_ERR_MISSING_ERRNO NEW GPG_ERR_UNKNOWN_OPTION NEW Modified: trunk/autogen.sh =================================================================== --- trunk/autogen.sh 2006-09-08 10:06:27 UTC (rev 178) +++ trunk/autogen.sh 2006-09-14 14:24:34 UTC (rev 179) @@ -45,25 +45,21 @@ [ -z "$w32root" ] && w32root="$HOME/w32root" echo "Using $w32root as standard install directory" >&2 - # See whether we have the Debian cross compiler package or the - # old mingw32/cpd system - if i586-mingw32msvc-gcc --version >/dev/null 2>&1 ; then - host=i586-mingw32msvc - crossbindir=/usr/$host/bin - else - host=i386--mingw32 - if ! mingw32 --version >/dev/null; then - echo "We need at least version 0.3 of MingW32/CPD" >&2 - exit 1 - fi - crossbindir=`mingw32 --install-dir`/bin - # Old autoconf version required us to setup the environment - # with the proper tool names. - CC=`mingw32 --get-path gcc` - CPP=`mingw32 --get-path cpp` - AR=`mingw32 --get-path ar` - RANLIB=`mingw32 --get-path ranlib` - export CC CPP AR RANLIB + # Locate the cross compiler + crossbindir= + for host in i586-mingw32msvc i386-mingw32msvc; do + if ${host}-gcc --version >/dev/null 2>&1 ; then + crossbindir=/usr/${host}/bin + conf_CC="CC=${host}-gcc" + break; + fi + done + if [ -z "$crossbindir" ]; then + echo "Cross compiler kit not installed" >&2 + echo "Under Debian GNU/Linux, you may install it using" >&2 + echo " apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2 + echo "Stop." >&2 + exit 1 fi if [ -f "$tsdir/config.log" ]; then @@ -74,7 +70,7 @@ fi ./configure --enable-maintainer-mode --prefix=${w32root} \ - --host=i586-mingw32msvc --build=${build} + --host=${host} --build=${build} exit $? fi Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-09-08 10:06:27 UTC (rev 178) +++ trunk/configure.ac 2006-09-14 14:24:34 UTC (rev 179) @@ -21,18 +21,19 @@ # The following lines are used by ./autogen.sh. AC_PREREQ(2.59) min_automake_version="1.9.6" + # The gettext version is set below using AM_GNU_GETTEXT_VERSION # Version number: Remember to change it immediately *after* a release. -AC_INIT([libgpg-error],[1.4-cvs],[bug-gnupg@gnupg.org]) +AC_INIT([libgpg-error],[1.4],[bug-gnupg@gnupg.org]) # LT Version numbers, remember to change them just *before* a release. # (Code changed: REVISION++) # (Interfaces added/removed/changed: CURRENT++, REVISION=0) # (Interfaces added: AGE++) # (Interfaces removed: AGE=0) # Note that added error codes don't constitute an interface change. -LIBGPG_ERROR_LT_CURRENT=2 -LIBGPG_ERROR_LT_AGE=2 -LIBGPG_ERROR_LT_REVISION=1 +LIBGPG_ERROR_LT_CURRENT=3 +LIBGPG_ERROR_LT_AGE=3 +LIBGPG_ERROR_LT_REVISION=0 AC_SUBST(LIBGPG_ERROR_LT_CURRENT) AC_SUBST(LIBGPG_ERROR_LT_AGE) AC_SUBST(LIBGPG_ERROR_LT_REVISION) @@ -45,6 +46,7 @@ # We need to know about the host architecture to avoid spurious # warnings. AC_CANONICAL_HOST +AB_INIT # Checks for programs. AC_PROG_CC Modified: trunk/lang/cl/gpg-error-package.lisp =================================================================== --- trunk/lang/cl/gpg-error-package.lisp 2006-09-08 10:06:27 UTC (rev 178) +++ trunk/lang/cl/gpg-error-package.lisp 2006-09-14 14:24:34 UTC (rev 179) @@ -58,5 +58,7 @@ :gpg-strsource :gpg-err-code-from-errno :gpg-err-code-to-errno + :gpg-err-code-from-syserror :gpg-err-make-from-errno - :gpg-error-from-errno)) + :gpg-error-from-errno + :gpg-error-from-syserror)) Modified: trunk/lang/cl/gpg-error.lisp =================================================================== --- trunk/lang/cl/gpg-error.lisp 2006-09-08 10:06:27 UTC (rev 178) +++ trunk/lang/cl/gpg-error.lisp 2006-09-14 14:24:34 UTC (rev 179) @@ -109,6 +109,10 @@ (defcfun ("gpg_err_code_to_errno" c-gpg-err-code-to-errno) :int (code gpg-err-code-t)) +(defcfun ("gpg_err_code_from_syserror" + c-gpg-err-code-from-syserror) gpg-err-code-t + (void)) + ;;; Self-documenting convenience functions. ;;; See below. @@ -211,6 +215,13 @@ system error, 0 is returned." (c-gpg-err-code-to-errno (gpg-err-code code))) +(defun gpg-err-code-from-syserror () + "Retrieve the error code directly from the system ERRNO. If the system error + is not mapped, :gpg-err-unknown-errno is returned and + :gpg-err-missing-errno if ERRNO has the value 0." + (gpg-err-code-as-key (c-gpg-err-code-from-syserror))) + + ;;; Self-documenting convenience functions. (defun gpg-err-make-from-errno (source err) @@ -218,3 +229,7 @@ (defun gpg-error-from-errno (err) (gpg-error (gpg-err-code-from-errno err))) + +(defun gpg-error-from-syserror () + (gpg-error (gpg-err-code-from-syserror))) + Modified: trunk/m4/ChangeLog =================================================================== --- trunk/m4/ChangeLog 2006-09-08 10:06:27 UTC (rev 178) +++ trunk/m4/ChangeLog 2006-09-14 14:24:34 UTC (rev 179) @@ -1,3 +1,7 @@ +2006-09-14 Werner Koch + + * autobuild.m4: New. + 2006-03-14 gettextize * codeset.m4: Upgrade to gettext-0.14.5. Modified: trunk/m4/Makefile.am =================================================================== --- trunk/m4/Makefile.am 2006-09-08 10:06:27 UTC (rev 178) +++ trunk/m4/Makefile.am 2006-09-14 14:24:34 UTC (rev 179) @@ -1 +1,3 @@ EXTRA_DIST = glibc2.m4 intmax.m4 longdouble.m4 longlong.m4 printf-posix.m4 signed.m4 size_max.m4 wchar_t.m4 wint_t.m4 xsize.m4 ac_prog_cc_for_build.m4 nls.m4 po.m4 codeset.m4 gettext.m4 glibc21.m4 iconv.m4 intdiv0.m4 inttypes.m4 inttypes_h.m4 inttypes-pri.m4 isc-posix.m4 lcmessage.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 progtest.m4 stdint_h.m4 uintmax_t.m4 ulonglong.m4 + +EXTRA_DIST += autobuild.m4 Added: trunk/m4/autobuild.m4 =================================================================== --- trunk/m4/autobuild.m4 2006-09-08 10:06:27 UTC (rev 178) +++ trunk/m4/autobuild.m4 2006-09-14 14:24:34 UTC (rev 179) @@ -0,0 +1,34 @@ +# autobuild.m4 serial 2 (autobuild-3.3) +# Copyright (C) 2004 Simon Josefsson +# +# This file is free software, distributed under the terms of the GNU +# General Public License. As a special exception to the GNU General +# Public License, this file may be distributed as part of a program +# that contains a configuration script generated by Autoconf, under +# the same distribution terms as the rest of that program. +# +# This file can can be used in projects which are not available under +# the GNU General Public License or the GNU Library General Public +# License but which still want to provide support for Autobuild. + +# Usage: AB_INIT([MODE]). +AC_DEFUN([AB_INIT], +[ + AC_REQUIRE([AC_CANONICAL_BUILD]) + AC_REQUIRE([AC_CANONICAL_HOST]) + + AC_MSG_NOTICE([autobuild project... ${PACKAGE_NAME:-$PACKAGE}]) + AC_MSG_NOTICE([autobuild revision... ${PACKAGE_VERSION:-$VERSION}]) + hostname=`hostname` + if test "$hostname"; then + AC_MSG_NOTICE([autobuild hostname... $hostname]) + fi + ifelse([$1],[],,[AC_MSG_NOTICE([autobuild mode... $1])]) + date=`date +%Y%m%d-%H%M%S` + if test "$?" != 0; then + date=`date` + fi + if test "$date"; then + AC_MSG_NOTICE([autobuild timestamp... $date]) + fi +]) Modified: trunk/po/ChangeLog =================================================================== --- trunk/po/ChangeLog 2006-09-08 10:06:27 UTC (rev 178) +++ trunk/po/ChangeLog 2006-09-14 14:24:34 UTC (rev 179) @@ -1,3 +1,7 @@ +2006-09-14 Werner Koch + + * de.po: Updated. + 2006-09-08 Werner Koch * pl.po: Updated. Modified: trunk/po/de.po =================================================================== --- trunk/po/de.po 2006-09-08 10:06:27 UTC (rev 178) +++ trunk/po/de.po 2006-09-14 14:24:34 UTC (rev 179) @@ -5,10 +5,10 @@ # msgid "" msgstr "" -"Project-Id-Version: libgpg-error-1.0\n" +"Project-Id-Version: libgpg-error-1.4\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2006-03-14 12:56+0100\n" -"PO-Revision-Date: 2004-07-30 14:55+0200\n" +"POT-Creation-Date: 2006-09-14 14:58+0200\n" +"PO-Revision-Date: 2006-09-14 15:11+0200\n" "Last-Translator: Werner Koch \n" "Language-Team: none\n" "MIME-Version: 1.0\n" @@ -64,22 +64,26 @@ msgstr "GSTI" #: src/err-sources.h:40 +msgid "Any source" +msgstr "Unspezifische Quelle" + +#: src/err-sources.h:41 msgid "User defined source 1" msgstr "Benutzerdefinierte Quelle 1" -#: src/err-sources.h:41 +#: src/err-sources.h:42 msgid "User defined source 2" msgstr "Benutzerdefinierte Quelle 2" -#: src/err-sources.h:42 +#: src/err-sources.h:43 msgid "User defined source 3" msgstr "Benutzerdefinierte Quelle 3" -#: src/err-sources.h:43 +#: src/err-sources.h:44 msgid "User defined source 4" msgstr "Benutzerdefinierte Quelle 4" -#: src/err-sources.h:44 +#: src/err-sources.h:45 msgid "Unknown source" msgstr "Unbekannte Quelle" @@ -404,12 +408,12 @@ msgstr "Ungültige Daten" #: src/err-codes.h:108 -msgid "Assuan server fault" -msgstr "Assuan Serverfehler" +msgid "Unspecific Assuan server fault" +msgstr "Unspezifischer Assuan Serverfehler" #: src/err-codes.h:109 -msgid "Assuan error" -msgstr "Fehler in Assuan" +msgid "General Assuan error" +msgstr "Allgemeiner Assuan Fehler" #: src/err-codes.h:110 msgid "Invalid session key" @@ -768,149 +772,254 @@ msgstr "Ungültiger Request" #: src/err-codes.h:199 -#, fuzzy msgid "Unknown extension" -msgstr "Unbekannte S-expression" +msgstr "Unbekannte Erweiterung" #: src/err-codes.h:200 -#, fuzzy msgid "Unknown critical extension" -msgstr "Unbekannte S-expression" +msgstr "Unbekannte kritische Erweiterung" #: src/err-codes.h:201 -#, fuzzy msgid "Locked" -msgstr "Nicht gesperrt" +msgstr "Gesperrt" #: src/err-codes.h:202 +msgid "Unknown option" +msgstr "Unbekannte Option" + +#: src/err-codes.h:203 +msgid "Unknown command" +msgstr "Unbekanntes Kommando" + +#: src/err-codes.h:204 msgid "Buffer too short" msgstr "Datenpuffer zu kurz" -#: src/err-codes.h:203 +#: src/err-codes.h:205 msgid "Invalid length specifier in S-expression" msgstr "Ungültige Längeangabe in der S-expression" -#: src/err-codes.h:204 +#: src/err-codes.h:206 msgid "String too long in S-expression" msgstr "Zeichenkette in S-expression zu lang" -#: src/err-codes.h:205 +#: src/err-codes.h:207 msgid "Unmatched parentheses in S-expression" msgstr "Nich übereinstimmende Klammern in S-expression" -#: src/err-codes.h:206 +#: src/err-codes.h:208 msgid "S-expression not canonical" msgstr "S-expression ist nicht kanonisch" -#: src/err-codes.h:207 +#: src/err-codes.h:209 msgid "Bad character in S-expression" msgstr "Fehlerhaftes Zeichen in S-expression" -#: src/err-codes.h:208 +#: src/err-codes.h:210 msgid "Bad quotation in S-expression" msgstr "Fehlerhafte Zitierung in S-expression" -#: src/err-codes.h:209 +#: src/err-codes.h:211 msgid "Zero prefix in S-expression" msgstr "Null-Präfix in S-expression" -#: src/err-codes.h:210 +#: src/err-codes.h:212 msgid "Nested display hints in S-expression" msgstr "Verschachtelte \"Hints\" in S-expression" -#: src/err-codes.h:211 +#: src/err-codes.h:213 msgid "Unmatched display hints" msgstr "Nicht übereinstimmende \"Hints\"" -#: src/err-codes.h:212 +#: src/err-codes.h:214 msgid "Unexpected reserved punctuation in S-expression" msgstr "Unerwartetes reserviertes Zeichen in S-expression" -#: src/err-codes.h:213 +#: src/err-codes.h:215 msgid "Bad hexadecimal character in S-expression" msgstr "Falsches Hex-Zeichen in S-expression" -#: src/err-codes.h:214 +#: src/err-codes.h:216 msgid "Odd hexadecimal numbers in S-expression" msgstr "Ungerade Anzahl von Hex-Zeichen in S-expression" -#: src/err-codes.h:215 +#: src/err-codes.h:217 msgid "Bad octadecimal character in S-expression" msgstr "Falsches Oktal-Zeichen in S-expression" -#: src/err-codes.h:216 +#: src/err-codes.h:218 +msgid "General IPC error" +msgstr "Allgemeiner IPC Fehler" + +#: src/err-codes.h:219 +msgid "IPC accept call failed" +msgstr "IPC \"accept\" Aufruf fehlgeschlagen" + +#: src/err-codes.h:220 +msgid "IPC connect call failed" +msgstr "IPC \"connect\" Aufruf fehlgeschlagen" + +#: src/err-codes.h:221 +msgid "Invalid IPC response" +msgstr "Ungültige IPC Antwort" + +#: src/err-codes.h:222 +msgid "Invalid value passed to IPC" +msgstr "Ungültiger Wert an IPC übergeben" + +#: src/err-codes.h:223 +msgid "Incomplete line passed to IPC" +msgstr "Unvollständige Zeile an IPC übergeben" + +#: src/err-codes.h:224 +msgid "Line passed to IPC too long" +msgstr "An die IPC übergebene Zeile ist zu lang" + +#: src/err-codes.h:225 +msgid "Nested IPC commands" +msgstr "Verschachtelte IPC Kommandos" + +#: src/err-codes.h:226 +msgid "No data callback in IPC" +msgstr "Kein Daten vom IPC \"Callback\"" + +#: src/err-codes.h:227 +msgid "No inquire callback in IPC" +msgstr "Kein \"Inquire\" \"Callback\" für IPC gesetzt" + +#: src/err-codes.h:228 +msgid "Not an IPC server" +msgstr "Kein IPC Server" + +#: src/err-codes.h:229 +msgid "Not an IPC client" +msgstr "Kein IPC Client" + +#: src/err-codes.h:230 +msgid "Problem starting IPC server" +msgstr "Problem beim Starten des IPC Servers" + +#: src/err-codes.h:231 +msgid "IPC read error" +msgstr "IPC Lesefehler" + +#: src/err-codes.h:232 +msgid "IPC write error" +msgstr "IPC Schreibfehler" + +#: src/err-codes.h:233 +msgid "Too much data for IPC layer" +msgstr "Zu viele Daten für das IPC Ebene" + +#: src/err-codes.h:234 +msgid "Unexpected IPC command" +msgstr "Unerwartetes IPC Kommando" + +#: src/err-codes.h:235 +msgid "Unknown IPC command" +msgstr "Unbekanntes IPC Kommando" + +#: src/err-codes.h:236 +msgid "IPC syntax error" +msgstr "IPC Syntaxfehler" + +#: src/err-codes.h:237 +msgid "IPC call has been cancelled" +msgstr "Der IPC Aufruf wurde abgebrochen" + +#: src/err-codes.h:238 +msgid "No input source for IPC" +msgstr "Eingabequelle für IPC fehlt" + +#: src/err-codes.h:239 +msgid "No output source for IPC" +msgstr "Ausgabesenke für IPC fehlt" + +#: src/err-codes.h:240 +msgid "IPC parameter error" +msgstr "IPC Parameterfehler" + +#: src/err-codes.h:241 +msgid "Unknown IPC inquire" +msgstr "Unbekanntes IPC \"Inquire\"" + +#: src/err-codes.h:242 msgid "User defined error code 1" msgstr "Benutzerdefinierter Fehlercode 1" -#: src/err-codes.h:217 +#: src/err-codes.h:243 msgid "User defined error code 2" msgstr "Benutzerdefinierter Fehlercode 2" -#: src/err-codes.h:218 +#: src/err-codes.h:244 msgid "User defined error code 3" msgstr "Benutzerdefinierter Fehlercode 3" -#: src/err-codes.h:219 +#: src/err-codes.h:245 msgid "User defined error code 4" msgstr "Benutzerdefinierter Fehlercode 4" -#: src/err-codes.h:220 +#: src/err-codes.h:246 msgid "User defined error code 5" msgstr "Benutzerdefinierter Fehlercode 5" -#: src/err-codes.h:221 +#: src/err-codes.h:247 msgid "User defined error code 6" msgstr "Benutzerdefinierter Fehlercode 6" -#: src/err-codes.h:222 +#: src/err-codes.h:248 msgid "User defined error code 7" msgstr "Benutzerdefinierter Fehlercode 7" -#: src/err-codes.h:223 +#: src/err-codes.h:249 msgid "User defined error code 8" msgstr "Benutzerdefinierter Fehlercode 8" -#: src/err-codes.h:224 +#: src/err-codes.h:250 msgid "User defined error code 9" msgstr "Benutzerdefinierter Fehlercode 9" -#: src/err-codes.h:225 +#: src/err-codes.h:251 msgid "User defined error code 10" msgstr "Benutzerdefinierter Fehlercode 10" -#: src/err-codes.h:226 +#: src/err-codes.h:252 msgid "User defined error code 11" msgstr "Benutzerdefinierter Fehlercode 11" -#: src/err-codes.h:227 +#: src/err-codes.h:253 msgid "User defined error code 12" msgstr "Benutzerdefinierter Fehlercode 12" -#: src/err-codes.h:228 +#: src/err-codes.h:254 msgid "User defined error code 13" msgstr "Benutzerdefinierter Fehlercode 13" -#: src/err-codes.h:229 +#: src/err-codes.h:255 msgid "User defined error code 14" msgstr "Benutzerdefinierter Fehlercode 14" -#: src/err-codes.h:230 +#: src/err-codes.h:256 msgid "User defined error code 15" msgstr "Benutzerdefinierter Fehlercode 15" -#: src/err-codes.h:231 +#: src/err-codes.h:257 msgid "User defined error code 16" msgstr "Benutzerdefinierter Fehlercode 16" -#: src/err-codes.h:232 +#: src/err-codes.h:258 +msgid "System error w/o errno" +msgstr "Systemfehler ohne gesetzten Sytemfehlercode" + +#: src/err-codes.h:259 msgid "Unknown system error" msgstr "Unbekannter Systemfehler" -#: src/err-codes.h:233 +#: src/err-codes.h:260 msgid "End of file" msgstr "Dateiende" -#: src/err-codes.h:234 +#: src/err-codes.h:261 msgid "Unknown error code" msgstr "Unbekannter Fehlercode" @@ -923,3 +1032,6 @@ #, c-format msgid "%s: warning: could not recognize %s\n" msgstr "%s: Warnung: %s konnte nicht erkannt werden\n" + +#~ msgid "Assuan error" +#~ msgstr "Fehler in Assuan" Modified: trunk/po/fr.po =================================================================== --- trunk/po/fr.po 2006-09-08 10:06:27 UTC (rev 178) +++ trunk/po/fr.po 2006-09-14 14:24:34 UTC (rev 179) @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: libgpg-error 1.0\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2006-03-14 12:56+0100\n" +"POT-Creation-Date: 2006-09-14 14:58+0200\n" "PO-Revision-Date: 2005-08-18 16:48+0100\n" "Last-Translator: Stephane Roy \n" "Language-Team: French \n" @@ -64,22 +64,27 @@ msgstr "GSTI" #: src/err-sources.h:40 +#, fuzzy +msgid "Any source" +msgstr "Source inconnue" + +#: src/err-sources.h:41 msgid "User defined source 1" msgstr "Source 1 définie par l'utilisateur" -#: src/err-sources.h:41 +#: src/err-sources.h:42 msgid "User defined source 2" msgstr "Source 2 définie par l'utilisateur" -#: src/err-sources.h:42 +#: src/err-sources.h:43 msgid "User defined source 3" msgstr "Source 3 définie par l'utilisateur" -#: src/err-sources.h:43 +#: src/err-sources.h:44 msgid "User defined source 4" msgstr "Source 4 définie par l'utilisateur" -#: src/err-sources.h:44 +#: src/err-sources.h:45 msgid "Unknown source" msgstr "Source inconnue" @@ -404,12 +409,14 @@ msgstr "Donnée invalide" #: src/err-codes.h:108 -msgid "Assuan server fault" +#, fuzzy +msgid "Unspecific Assuan server fault" msgstr "Faute de serveur assuan" #: src/err-codes.h:109 -msgid "Assuan error" -msgstr "Erreur assuan" +#, fuzzy +msgid "General Assuan error" +msgstr "Erreur génerale" #: src/err-codes.h:110 msgid "Invalid session key" @@ -780,134 +787,256 @@ msgstr "Verrouillé" #: src/err-codes.h:202 +#, fuzzy +msgid "Unknown option" +msgstr "Extension inconnue" + +#: src/err-codes.h:203 +#, fuzzy +msgid "Unknown command" +msgstr "Code d'erreur inconnu" + +#: src/err-codes.h:204 msgid "Buffer too short" msgstr "Tampon trop court" -#: src/err-codes.h:203 +#: src/err-codes.h:205 msgid "Invalid length specifier in S-expression" msgstr "Longueur spécifiée dans la S-expression invalide" -#: src/err-codes.h:204 +#: src/err-codes.h:206 msgid "String too long in S-expression" msgstr "Chaîne trop longue dans la S-expression" -#: src/err-codes.h:205 +#: src/err-codes.h:207 msgid "Unmatched parentheses in S-expression" msgstr "Parenthèses non balancées dans la S-expression" -#: src/err-codes.h:206 +#: src/err-codes.h:208 msgid "S-expression not canonical" msgstr "S-expression non canonique" -#: src/err-codes.h:207 +#: src/err-codes.h:209 msgid "Bad character in S-expression" msgstr "Mauvais caractère dans la S-expression" -#: src/err-codes.h:208 +#: src/err-codes.h:210 msgid "Bad quotation in S-expression" msgstr "Mauvaise balance de guillemets dans la S-expression" -#: src/err-codes.h:209 +#: src/err-codes.h:211 msgid "Zero prefix in S-expression" msgstr "Préfixe nul dans la S-expression" -#: src/err-codes.h:210 +#: src/err-codes.h:212 msgid "Nested display hints in S-expression" msgstr "" -#: src/err-codes.h:211 +#: src/err-codes.h:213 msgid "Unmatched display hints" msgstr "" -#: src/err-codes.h:212 +#: src/err-codes.h:214 msgid "Unexpected reserved punctuation in S-expression" msgstr "Ponctuation réservée inattendue dans la S-expression" -#: src/err-codes.h:213 +#: src/err-codes.h:215 msgid "Bad hexadecimal character in S-expression" msgstr "Mauvais caractère hexadécimal dans la S-expression" -#: src/err-codes.h:214 +#: src/err-codes.h:216 msgid "Odd hexadecimal numbers in S-expression" msgstr "Nombre hexadécimal impair dans la S-expression" -#: src/err-codes.h:215 +#: src/err-codes.h:217 msgid "Bad octadecimal character in S-expression" msgstr "Mauvais caractère octadécimal dans la S-expression" -#: src/err-codes.h:216 +#: src/err-codes.h:218 +#, fuzzy +msgid "General IPC error" +msgstr "Erreur génerale" + +#: src/err-codes.h:219 +msgid "IPC accept call failed" +msgstr "" + +#: src/err-codes.h:220 +msgid "IPC connect call failed" +msgstr "" + +#: src/err-codes.h:221 +#, fuzzy +msgid "Invalid IPC response" +msgstr "Réponse invalide" + +#: src/err-codes.h:222 +#, fuzzy +msgid "Invalid value passed to IPC" +msgstr "Valeur invalide" + +#: src/err-codes.h:223 +#, fuzzy +msgid "Incomplete line passed to IPC" +msgstr "Ligne incomplète" + +#: src/err-codes.h:224 +#, fuzzy +msgid "Line passed to IPC too long" +msgstr "Ligne trop longue" + +#: src/err-codes.h:225 +msgid "Nested IPC commands" +msgstr "" + +#: src/err-codes.h:226 +msgid "No data callback in IPC" +msgstr "" + +#: src/err-codes.h:227 +msgid "No inquire callback in IPC" +msgstr "" + +#: src/err-codes.h:228 +msgid "Not an IPC server" +msgstr "" + +#: src/err-codes.h:229 +msgid "Not an IPC client" +msgstr "" + +#: src/err-codes.h:230 +msgid "Problem starting IPC server" +msgstr "" + +#: src/err-codes.h:231 +#, fuzzy +msgid "IPC read error" +msgstr "Erreur de carte" + +#: src/err-codes.h:232 +#, fuzzy +msgid "IPC write error" +msgstr "Erreur de carte" + +#: src/err-codes.h:233 +msgid "Too much data for IPC layer" +msgstr "" + +#: src/err-codes.h:234 +#, fuzzy +msgid "Unexpected IPC command" +msgstr "Balise inattendue" + +#: src/err-codes.h:235 +#, fuzzy +msgid "Unknown IPC command" +msgstr "Code d'erreur inconnu" + +#: src/err-codes.h:236 +#, fuzzy +msgid "IPC syntax error" +msgstr "Erreur de syntaxe" + +#: src/err-codes.h:237 +msgid "IPC call has been cancelled" +msgstr "" + +#: src/err-codes.h:238 +msgid "No input source for IPC" +msgstr "" + +#: src/err-codes.h:239 +msgid "No output source for IPC" +msgstr "" + +#: src/err-codes.h:240 +#, fuzzy +msgid "IPC parameter error" +msgstr "Erreur de carte" + +#: src/err-codes.h:241 +#, fuzzy +msgid "Unknown IPC inquire" +msgstr "Source inconnue" + +#: src/err-codes.h:242 msgid "User defined error code 1" msgstr "Code d'erreur 1 défini par l'utilisateur" -#: src/err-codes.h:217 +#: src/err-codes.h:243 msgid "User defined error code 2" msgstr "Code d'erreur 2 défini par l'utilisateur" -#: src/err-codes.h:218 +#: src/err-codes.h:244 msgid "User defined error code 3" msgstr "Code d'erreur 3 défini par l'utilisateur" -#: src/err-codes.h:219 +#: src/err-codes.h:245 msgid "User defined error code 4" msgstr "Code d'erreur 4 défini par l'utilisateur" -#: src/err-codes.h:220 +#: src/err-codes.h:246 msgid "User defined error code 5" msgstr "Code d'erreur 5 défini par l'utilisateur" -#: src/err-codes.h:221 +#: src/err-codes.h:247 msgid "User defined error code 6" msgstr "Code d'erreur 6 défini par l'utilisateur" -#: src/err-codes.h:222 +#: src/err-codes.h:248 msgid "User defined error code 7" msgstr "Code d'erreur 7 défini par l'utilisateur" -#: src/err-codes.h:223 +#: src/err-codes.h:249 msgid "User defined error code 8" msgstr "Code d'erreur 8 défini par l'utilisateur" -#: src/err-codes.h:224 +#: src/err-codes.h:250 msgid "User defined error code 9" msgstr "Code d'erreur 9 défini par l'utilisateur" -#: src/err-codes.h:225 +#: src/err-codes.h:251 msgid "User defined error code 10" msgstr "Code d'erreur 10 défini par l'utilisateur" -#: src/err-codes.h:226 +#: src/err-codes.h:252 msgid "User defined error code 11" msgstr "Code d'erreur 11 défini par l'utilisateur" -#: src/err-codes.h:227 +#: src/err-codes.h:253 msgid "User defined error code 12" msgstr "Code d'erreur 12 défini par l'utilisateur" -#: src/err-codes.h:228 +#: src/err-codes.h:254 msgid "User defined error code 13" msgstr "Code d'erreur 13 défini par l'utilisateur" -#: src/err-codes.h:229 +#: src/err-codes.h:255 msgid "User defined error code 14" msgstr "Code d'erreur 14 défini par l'utilisateur" -#: src/err-codes.h:230 +#: src/err-codes.h:256 msgid "User defined error code 15" msgstr "Code d'erreur 15 défini par l'utilisateur" -#: src/err-codes.h:231 +#: src/err-codes.h:257 msgid "User defined error code 16" msgstr "Code d'erreur 16 défini par l'utilisateur" -#: src/err-codes.h:232 +#: src/err-codes.h:258 +msgid "System error w/o errno" +msgstr "" + +#: src/err-codes.h:259 msgid "Unknown system error" msgstr "Erreur système inconnue" -#: src/err-codes.h:233 +#: src/err-codes.h:260 msgid "End of file" msgstr "Fin du fichier" -#: src/err-codes.h:234 +#: src/err-codes.h:261 msgid "Unknown error code" msgstr "Code d'erreur inconnu" @@ -920,3 +1049,6 @@ #, c-format msgid "%s: warning: could not recognize %s\n" msgstr "%s : attention : pourrait ne pas reconnaître %s\n" + +#~ msgid "Assuan error" +#~ msgstr "Erreur assuan" Modified: trunk/po/libgpg-error.pot =================================================================== --- trunk/po/libgpg-error.pot 2006-09-08 10:06:27 UTC (rev 178) +++ trunk/po/libgpg-error.pot 2006-09-14 14:24:34 UTC (rev 179) @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2006-03-14 12:56+0100\n" +"POT-Creation-Date: 2006-09-14 14:58+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -65,22 +65,26 @@ msgstr "" #: src/err-sources.h:40 +msgid "Any source" +msgstr "" + +#: src/err-sources.h:41 msgid "User defined source 1" msgstr "" -#: src/err-sources.h:41 +#: src/err-sources.h:42 msgid "User defined source 2" msgstr "" -#: src/err-sources.h:42 +#: src/err-sources.h:43 msgid "User defined source 3" msgstr "" -#: src/err-sources.h:43 +#: src/err-sources.h:44 msgid "User defined source 4" msgstr "" -#: src/err-sources.h:44 +#: src/err-sources.h:45 msgid "Unknown source" msgstr "" @@ -405,11 +409,11 @@ msgstr "" #: src/err-codes.h:108 -msgid "Assuan server fault" +msgid "Unspecific Assuan server fault" msgstr "" #: src/err-codes.h:109 -msgid "Assuan error" +msgid "General Assuan error" msgstr "" #: src/err-codes.h:110 @@ -781,134 +785,242 @@ msgstr "" #: src/err-codes.h:202 +msgid "Unknown option" +msgstr "" + +#: src/err-codes.h:203 +msgid "Unknown command" +msgstr "" + +#: src/err-codes.h:204 msgid "Buffer too short" msgstr "" -#: src/err-codes.h:203 +#: src/err-codes.h:205 msgid "Invalid length specifier in S-expression" msgstr "" -#: src/err-codes.h:204 +#: src/err-codes.h:206 msgid "String too long in S-expression" msgstr "" -#: src/err-codes.h:205 +#: src/err-codes.h:207 msgid "Unmatched parentheses in S-expression" msgstr "" -#: src/err-codes.h:206 +#: src/err-codes.h:208 msgid "S-expression not canonical" msgstr "" -#: src/err-codes.h:207 +#: src/err-codes.h:209 msgid "Bad character in S-expression" msgstr "" -#: src/err-codes.h:208 +#: src/err-codes.h:210 msgid "Bad quotation in S-expression" msgstr "" -#: src/err-codes.h:209 +#: src/err-codes.h:211 msgid "Zero prefix in S-expression" msgstr "" -#: src/err-codes.h:210 +#: src/err-codes.h:212 msgid "Nested display hints in S-expression" msgstr "" -#: src/err-codes.h:211 +#: src/err-codes.h:213 msgid "Unmatched display hints" msgstr "" -#: src/err-codes.h:212 +#: src/err-codes.h:214 msgid "Unexpected reserved punctuation in S-expression" msgstr "" -#: src/err-codes.h:213 +#: src/err-codes.h:215 msgid "Bad hexadecimal character in S-expression" msgstr "" -#: src/err-codes.h:214 +#: src/err-codes.h:216 msgid "Odd hexadecimal numbers in S-expression" msgstr "" -#: src/err-codes.h:215 +#: src/err-codes.h:217 msgid "Bad octadecimal character in S-expression" msgstr "" -#: src/err-codes.h:216 +#: src/err-codes.h:218 +msgid "General IPC error" +msgstr "" + +#: src/err-codes.h:219 +msgid "IPC accept call failed" +msgstr "" + +#: src/err-codes.h:220 +msgid "IPC connect call failed" +msgstr "" + +#: src/err-codes.h:221 +msgid "Invalid IPC response" +msgstr "" + +#: src/err-codes.h:222 +msgid "Invalid value passed to IPC" +msgstr "" + +#: src/err-codes.h:223 +msgid "Incomplete line passed to IPC" +msgstr "" + +#: src/err-codes.h:224 +msgid "Line passed to IPC too long" +msgstr "" + +#: src/err-codes.h:225 +msgid "Nested IPC commands" +msgstr "" + +#: src/err-codes.h:226 +msgid "No data callback in IPC" +msgstr "" + +#: src/err-codes.h:227 +msgid "No inquire callback in IPC" +msgstr "" + +#: src/err-codes.h:228 +msgid "Not an IPC server" +msgstr "" + +#: src/err-codes.h:229 +msgid "Not an IPC client" +msgstr "" + +#: src/err-codes.h:230 +msgid "Problem starting IPC server" +msgstr "" + +#: src/err-codes.h:231 +msgid "IPC read error" +msgstr "" + +#: src/err-codes.h:232 +msgid "IPC write error" +msgstr "" + +#: src/err-codes.h:233 +msgid "Too much data for IPC layer" +msgstr "" + +#: src/err-codes.h:234 +msgid "Unexpected IPC command" +msgstr "" + +#: src/err-codes.h:235 +msgid "Unknown IPC command" +msgstr "" + +#: src/err-codes.h:236 +msgid "IPC syntax error" +msgstr "" + +#: src/err-codes.h:237 +msgid "IPC call has been cancelled" +msgstr "" + +#: src/err-codes.h:238 +msgid "No input source for IPC" +msgstr "" + +#: src/err-codes.h:239 +msgid "No output source for IPC" +msgstr "" + +#: src/err-codes.h:240 +msgid "IPC parameter error" +msgstr "" + +#: src/err-codes.h:241 +msgid "Unknown IPC inquire" +msgstr "" + +#: src/err-codes.h:242 msgid "User defined error code 1" msgstr "" -#: src/err-codes.h:217 +#: src/err-codes.h:243 msgid "User defined error code 2" msgstr "" -#: src/err-codes.h:218 +#: src/err-codes.h:244 msgid "User defined error code 3" msgstr "" -#: src/err-codes.h:219 +#: src/err-codes.h:245 msgid "User defined error code 4" msgstr "" -#: src/err-codes.h:220 +#: src/err-codes.h:246 msgid "User defined error code 5" msgstr "" -#: src/err-codes.h:221 +#: src/err-codes.h:247 msgid "User defined error code 6" msgstr "" -#: src/err-codes.h:222 +#: src/err-codes.h:248 msgid "User defined error code 7" msgstr "" -#: src/err-codes.h:223 +#: src/err-codes.h:249 msgid "User defined error code 8" msgstr "" -#: src/err-codes.h:224 +#: src/err-codes.h:250 msgid "User defined error code 9" msgstr "" -#: src/err-codes.h:225 +#: src/err-codes.h:251 msgid "User defined error code 10" msgstr "" -#: src/err-codes.h:226 +#: src/err-codes.h:252 msgid "User defined error code 11" msgstr "" -#: src/err-codes.h:227 +#: src/err-codes.h:253 msgid "User defined error code 12" msgstr "" -#: src/err-codes.h:228 +#: src/err-codes.h:254 msgid "User defined error code 13" msgstr "" -#: src/err-codes.h:229 +#: src/err-codes.h:255 msgid "User defined error code 14" msgstr "" -#: src/err-codes.h:230 +#: src/err-codes.h:256 msgid "User defined error code 15" msgstr "" -#: src/err-codes.h:231 +#: src/err-codes.h:257 msgid "User defined error code 16" msgstr "" -#: src/err-codes.h:232 +#: src/err-codes.h:258 +msgid "System error w/o errno" +msgstr "" + +#: src/err-codes.h:259 msgid "Unknown system error" msgstr "" -#: src/err-codes.h:233 +#: src/err-codes.h:260 msgid "End of file" msgstr "" -#: src/err-codes.h:234 +#: src/err-codes.h:261 msgid "Unknown error code" msgstr "" Modified: trunk/po/pl.po =================================================================== --- trunk/po/pl.po 2006-09-08 10:06:27 UTC (rev 178) +++ trunk/po/pl.po 2006-09-14 14:24:34 UTC (rev 179) @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: libgpg-error 1.1\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2004-07-30 14:49+0200\n" +"POT-Creation-Date: 2006-09-14 14:58+0200\n" "PO-Revision-Date: 2005-07-04 17:42+0200\n" "Last-Translator: Jakub Bogusz \n" "Language-Team: Polish \n" @@ -64,22 +64,27 @@ msgstr "GSTI" #: src/err-sources.h:40 +#, fuzzy +msgid "Any source" +msgstr "Nieznane ¼ród³o" + +#: src/err-sources.h:41 msgid "User defined source 1" msgstr "Zdefiniowane przez u¿ytkownika ¼ród³o 1" -#: src/err-sources.h:41 +#: src/err-sources.h:42 msgid "User defined source 2" msgstr "Zdefiniowane przez u¿ytkownika ¼ród³o 2" -#: src/err-sources.h:42 +#: src/err-sources.h:43 msgid "User defined source 3" msgstr "Zdefiniowane przez u¿ytkownika ¼ród³o 3" -#: src/err-sources.h:43 +#: src/err-sources.h:44 msgid "User defined source 4" msgstr "Zdefiniowane przez u¿ytkownika ¼ród³o 4" -#: src/err-sources.h:44 +#: src/err-sources.h:45 msgid "Unknown source" msgstr "Nieznane ¼ród³o" @@ -404,12 +409,14 @@ msgstr "Niepoprawne dane" #: src/err-codes.h:108 -msgid "Assuan server fault" +#, fuzzy +msgid "Unspecific Assuan server fault" msgstr "Niepowodzenie serwera assuan" #: src/err-codes.h:109 -msgid "Assuan error" -msgstr "B³±d assuan" +#, fuzzy +msgid "General Assuan error" +msgstr "B³±d ogólny" #: src/err-codes.h:110 msgid "Invalid session key" @@ -768,143 +775,283 @@ msgstr "Niepoprawne ¿±danie" #: src/err-codes.h:199 +#, fuzzy +msgid "Unknown extension" +msgstr "Nieznane S-wyra¿enie" + +#: src/err-codes.h:200 +#, fuzzy +msgid "Unknown critical extension" +msgstr "Nieznane S-wyra¿enie" + +#: src/err-codes.h:201 +#, fuzzy +msgid "Locked" +msgstr "Nie zablokowany" + +#: src/err-codes.h:202 +#, fuzzy +msgid "Unknown option" +msgstr "Nieznany host" + +#: src/err-codes.h:203 +#, fuzzy +msgid "Unknown command" +msgstr "Nieznany kod b³êdu" + +#: src/err-codes.h:204 msgid "Buffer too short" msgstr "Bufor zbyt ma³y" -#: src/err-codes.h:200 +#: src/err-codes.h:205 msgid "Invalid length specifier in S-expression" msgstr "Niepoprawne okre¶lenie d³ugo¶ci w S-wyra¿eniu" -#: src/err-codes.h:201 +#: src/err-codes.h:206 msgid "String too long in S-expression" msgstr "Zbyt d³ugi ³añcuch w S-wyra¿eniu" -#: src/err-codes.h:202 +#: src/err-codes.h:207 msgid "Unmatched parentheses in S-expression" msgstr "Niedopasowane nawiasy w S-wyra¿eniu" -#: src/err-codes.h:203 +#: src/err-codes.h:208 msgid "S-expression not canonical" msgstr "S-wyra¿enie nie kanoniczne" -#: src/err-codes.h:204 +#: src/err-codes.h:209 msgid "Bad character in S-expression" msgstr "B³êdny znak w S-wyra¿eniu" -#: src/err-codes.h:205 +#: src/err-codes.h:210 msgid "Bad quotation in S-expression" msgstr "B³êdne cytowanie w S-wyra¿eniu" -#: src/err-codes.h:206 +#: src/err-codes.h:211 msgid "Zero prefix in S-expression" msgstr "Zerowy prefiks w S-wyra¿eniu" -#: src/err-codes.h:207 +#: src/err-codes.h:212 msgid "Nested display hints in S-expression" msgstr "Zagnie¿d¿one podpowiedzi wy¶wietlania w S-wyra¿eniu" -#: src/err-codes.h:208 +#: src/err-codes.h:213 msgid "Unmatched display hints" msgstr "Niedopasowane podpowiedzi wy¶wietlania" -#: src/err-codes.h:209 +#: src/err-codes.h:214 msgid "Unexpected reserved punctuation in S-expression" msgstr "Nieoczekiwany zarezerwowany znak w S-wyra¿eniu" -#: src/err-codes.h:210 +#: src/err-codes.h:215 msgid "Bad hexadecimal character in S-expression" msgstr "B³êdny znak szesnastkowy w S-wyra¿eniu" -#: src/err-codes.h:211 +#: src/err-codes.h:216 msgid "Odd hexadecimal numbers in S-expression" msgstr "Nieparzysta liczba cyfr szesnastkowych w S-wyra¿eniu" -#: src/err-codes.h:212 +#: src/err-codes.h:217 msgid "Bad octadecimal character in S-expression" msgstr "B³êdny znak ósemkowy w S-wyra¿eniu" -#: src/err-codes.h:213 +#: src/err-codes.h:218 +#, fuzzy +msgid "General IPC error" +msgstr "B³±d ogólny" + +#: src/err-codes.h:219 +msgid "IPC accept call failed" +msgstr "" + +#: src/err-codes.h:220 +msgid "IPC connect call failed" +msgstr "" + +#: src/err-codes.h:221 +#, fuzzy +msgid "Invalid IPC response" +msgstr "Niepoprawna odpowied¼" + +#: src/err-codes.h:222 +#, fuzzy +msgid "Invalid value passed to IPC" +msgstr "Niepoprawna warto¶æ" + +#: src/err-codes.h:223 +#, fuzzy +msgid "Incomplete line passed to IPC" +msgstr "Niekompletna linia" + +#: src/err-codes.h:224 +#, fuzzy +msgid "Line passed to IPC too long" +msgstr "Linia zbyt d³uga" + +#: src/err-codes.h:225 +msgid "Nested IPC commands" +msgstr "" + +#: src/err-codes.h:226 +msgid "No data callback in IPC" +msgstr "" + +#: src/err-codes.h:227 +msgid "No inquire callback in IPC" +msgstr "" + +#: src/err-codes.h:228 +msgid "Not an IPC server" +msgstr "" + +#: src/err-codes.h:229 +msgid "Not an IPC client" +msgstr "" + +#: src/err-codes.h:230 +msgid "Problem starting IPC server" +msgstr "" + +#: src/err-codes.h:231 +#, fuzzy +msgid "IPC read error" +msgstr "B³±d karty" + +#: src/err-codes.h:232 +#, fuzzy +msgid "IPC write error" +msgstr "B³±d karty" + +#: src/err-codes.h:233 +msgid "Too much data for IPC layer" +msgstr "" + +#: src/err-codes.h:234 +#, fuzzy +msgid "Unexpected IPC command" +msgstr "Nieoczekiwany znacznik" + +#: src/err-codes.h:235 +#, fuzzy +msgid "Unknown IPC command" +msgstr "Nieznany kod b³êdu" + +#: src/err-codes.h:236 +#, fuzzy +msgid "IPC syntax error" +msgstr "B³±d sk³adni" + +#: src/err-codes.h:237 +msgid "IPC call has been cancelled" +msgstr "" + +#: src/err-codes.h:238 +msgid "No input source for IPC" +msgstr "" + +#: src/err-codes.h:239 +msgid "No output source for IPC" +msgstr "" + +#: src/err-codes.h:240 +#, fuzzy +msgid "IPC parameter error" +msgstr "B³±d karty" + +#: src/err-codes.h:241 +#, fuzzy +msgid "Unknown IPC inquire" +msgstr "Nieznane ¼ród³o" + +#: src/err-codes.h:242 msgid "User defined error code 1" msgstr "Zdefiniowany przez u¿ytkownika kod b³êdu 1" -#: src/err-codes.h:214 +#: src/err-codes.h:243 msgid "User defined error code 2" msgstr "Zdefiniowany przez u¿ytkownika kod b³êdu 2" -#: src/err-codes.h:215 +#: src/err-codes.h:244 msgid "User defined error code 3" msgstr "Zdefiniowany przez u¿ytkownika kod b³êdu 3" -#: src/err-codes.h:216 +#: src/err-codes.h:245 msgid "User defined error code 4" msgstr "Zdefiniowany przez u¿ytkownika kod b³êdu 4" -#: src/err-codes.h:217 +#: src/err-codes.h:246 msgid "User defined error code 5" msgstr "Zdefiniowany przez u¿ytkownika kod b³êdu 5" -#: src/err-codes.h:218 +#: src/err-codes.h:247 msgid "User defined error code 6" msgstr "Zdefiniowany przez u¿ytkownika kod b³êdu 6" -#: src/err-codes.h:219 +#: src/err-codes.h:248 msgid "User defined error code 7" msgstr "Zdefiniowany przez u¿ytkownika kod b³êdu 7" -#: src/err-codes.h:220 +#: src/err-codes.h:249 msgid "User defined error code 8" msgstr "Zdefiniowany przez u¿ytkownika kod b³êdu 8" -#: src/err-codes.h:221 +#: src/err-codes.h:250 msgid "User defined error code 9" msgstr "Zdefiniowany przez u¿ytkownika kod b³êdu 9" -#: src/err-codes.h:222 +#: src/err-codes.h:251 msgid "User defined error code 10" msgstr "Zdefiniowany przez u¿ytkownika kod b³êdu 10" -#: src/err-codes.h:223 +#: src/err-codes.h:252 msgid "User defined error code 11" msgstr "Zdefiniowany przez u¿ytkownika kod b³êdu 11" -#: src/err-codes.h:224 +#: src/err-codes.h:253 msgid "User defined error code 12" msgstr "Zdefiniowany przez u¿ytkownika kod b³êdu 12" -#: src/err-codes.h:225 +#: src/err-codes.h:254 msgid "User defined error code 13" msgstr "Zdefiniowany przez u¿ytkownika kod b³êdu 13" -#: src/err-codes.h:226 +#: src/err-codes.h:255 msgid "User defined error code 14" msgstr "Zdefiniowany przez u¿ytkownika kod b³êdu 14" -#: src/err-codes.h:227 +#: src/err-codes.h:256 msgid "User defined error code 15" msgstr "Zdefiniowany przez u¿ytkownika kod b³êdu 15" -#: src/err-codes.h:228 +#: src/err-codes.h:257 msgid "User defined error code 16" msgstr "Zdefiniowany przez u¿ytkownika kod b³êdu 16" -#: src/err-codes.h:229 +#: src/err-codes.h:258 +msgid "System error w/o errno" +msgstr "" + +#: src/err-codes.h:259 msgid "Unknown system error" msgstr "Nieznany b³±d systemu" -#: src/err-codes.h:230 +#: src/err-codes.h:260 msgid "End of file" msgstr "Koniec pliku" -#: src/err-codes.h:231 +#: src/err-codes.h:261 msgid "Unknown error code" msgstr "Nieznany kod b³êdu" -#: src/gpg-error.c:281 +#: src/gpg-error.c:456 #, c-format msgid "Usage: %s GPG-ERROR [...]\n" msgstr "Sk³adnia: %s B£¡D-GPG [...]\n" -#: src/gpg-error.c:302 +#: src/gpg-error.c:477 #, c-format msgid "%s: warning: could not recognize %s\n" msgstr "%s: uwaga: nie rozpoznano %s\n" + +#~ msgid "Assuan error" +#~ msgstr "B³±d assuan" Modified: trunk/po/ro.po =================================================================== --- trunk/po/ro.po 2006-09-08 10:06:27 UTC (rev 178) +++ trunk/po/ro.po 2006-09-14 14:24:34 UTC (rev 179) @@ -9,7 +9,7 @@ msgstr "" "Project-Id-Version: libgpg-error 1.1\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2006-03-14 12:56+0100\n" +"POT-Creation-Date: 2006-09-14 14:58+0200\n" "PO-Revision-Date: 2005-06-30 12:00-0500\n" "Last-Translator: Laurentiu Buzdugan \n" "Language-Team: Romanian \n" @@ -67,22 +67,27 @@ msgstr "GSTI" #: src/err-sources.h:40 +#, fuzzy +msgid "Any source" +msgstr "Sursã necunoscutã" + +#: src/err-sources.h:41 msgid "User defined source 1" msgstr "Sursã definitã de utilizator 1" -#: src/err-sources.h:41 +#: src/err-sources.h:42 msgid "User defined source 2" msgstr "Sursã definitã de utilizator 2" -#: src/err-sources.h:42 +#: src/err-sources.h:43 msgid "User defined source 3" msgstr "Sursã definitã de utilizator 3" -#: src/err-sources.h:43 +#: src/err-sources.h:44 msgid "User defined source 4" msgstr "Sursã definitã de utilizator 4" -#: src/err-sources.h:44 +#: src/err-sources.h:45 msgid "Unknown source" msgstr "Sursã necunoscutã" @@ -407,12 +412,14 @@ msgstr "Date invalide" #: src/err-codes.h:108 -msgid "Assuan server fault" +#, fuzzy +msgid "Unspecific Assuan server fault" msgstr "Eroare server Assuan" #: src/err-codes.h:109 -msgid "Assuan error" -msgstr "Eroare Assuan" +#, fuzzy +msgid "General Assuan error" +msgstr "Eroare generalã" #: src/err-codes.h:110 msgid "Invalid session key" @@ -786,134 +793,256 @@ msgstr "Neforþat(ã)" #: src/err-codes.h:202 +#, fuzzy +msgid "Unknown option" +msgstr "Expresie-S necunoscutã" + +#: src/err-codes.h:203 +#, fuzzy +msgid "Unknown command" +msgstr "Cod de eroare necunoscut" + +#: src/err-codes.h:204 msgid "Buffer too short" msgstr "Buffer prea scurt" -#: src/err-codes.h:203 +#: src/err-codes.h:205 msgid "Invalid length specifier in S-expression" msgstr "Specificarea lungimii invalidã în expresia-S" -#: src/err-codes.h:204 +#: src/err-codes.h:206 msgid "String too long in S-expression" msgstr "ªir prea lung în expresia-S" -#: src/err-codes.h:205 +#: src/err-codes.h:207 msgid "Unmatched parentheses in S-expression" msgstr "Parantezã fãrã pereche în expresia-S" -#: src/err-codes.h:206 +#: src/err-codes.h:208 msgid "S-expression not canonical" msgstr "Expresia-S nu este canonicã" -#: src/err-codes.h:207 +#: src/err-codes.h:209 msgid "Bad character in S-expression" msgstr "Caracter invalid în expresia-S" -#: src/err-codes.h:208 +#: src/err-codes.h:210 msgid "Bad quotation in S-expression" msgstr "Ghilimele incorecte în expresia-S" -#: src/err-codes.h:209 +#: src/err-codes.h:211 msgid "Zero prefix in S-expression" msgstr "Prefix zero în expresia-S" -#: src/err-codes.h:210 +#: src/err-codes.h:212 msgid "Nested display hints in S-expression" msgstr "Indicaþii de afiºare încuibãrite în expresia-S" -#: src/err-codes.h:211 +#: src/err-codes.h:213 msgid "Unmatched display hints" msgstr "Indicaþii de afiºare fãrã pereche" -#: src/err-codes.h:212 +#: src/err-codes.h:214 msgid "Unexpected reserved punctuation in S-expression" msgstr "Punctuaþie rezervatã neaºteptatã în expresia-S" -#: src/err-codes.h:213 +#: src/err-codes.h:215 msgid "Bad hexadecimal character in S-expression" msgstr "Caracter hexazecimal incorect în expresia-S" -#: src/err-codes.h:214 +#: src/err-codes.h:216 msgid "Odd hexadecimal numbers in S-expression" msgstr "Numere hexazecimale ciudate în expresia-S" -#: src/err-codes.h:215 +#: src/err-codes.h:217 msgid "Bad octadecimal character in S-expression" msgstr "Caracter octal incorect în expresia-S" -#: src/err-codes.h:216 +#: src/err-codes.h:218 +#, fuzzy +msgid "General IPC error" +msgstr "Eroare generalã" + +#: src/err-codes.h:219 +msgid "IPC accept call failed" +msgstr "" + +#: src/err-codes.h:220 +msgid "IPC connect call failed" +msgstr "" + +#: src/err-codes.h:221 +#, fuzzy +msgid "Invalid IPC response" +msgstr "Rãspuns invalid" + +#: src/err-codes.h:222 +#, fuzzy +msgid "Invalid value passed to IPC" +msgstr "Valoare invalidã" + +#: src/err-codes.h:223 +#, fuzzy +msgid "Incomplete line passed to IPC" +msgstr "Linie incompletã" + +#: src/err-codes.h:224 +#, fuzzy +msgid "Line passed to IPC too long" +msgstr "Linie prea lungã" + +#: src/err-codes.h:225 +msgid "Nested IPC commands" +msgstr "" + +#: src/err-codes.h:226 +msgid "No data callback in IPC" +msgstr "" + +#: src/err-codes.h:227 +msgid "No inquire callback in IPC" +msgstr "" + +#: src/err-codes.h:228 +msgid "Not an IPC server" +msgstr "" + +#: src/err-codes.h:229 +msgid "Not an IPC client" +msgstr "" + +#: src/err-codes.h:230 +msgid "Problem starting IPC server" +msgstr "" + +#: src/err-codes.h:231 +#, fuzzy +msgid "IPC read error" +msgstr "Eroare card" + +#: src/err-codes.h:232 +#, fuzzy +msgid "IPC write error" +msgstr "Eroare card" + +#: src/err-codes.h:233 +msgid "Too much data for IPC layer" +msgstr "" + +#: src/err-codes.h:234 +#, fuzzy +msgid "Unexpected IPC command" +msgstr "Etichetã neaºteptatã" + +#: src/err-codes.h:235 +#, fuzzy +msgid "Unknown IPC command" +msgstr "Cod de eroare necunoscut" + +#: src/err-codes.h:236 +#, fuzzy +msgid "IPC syntax error" +msgstr "Eroare de sintaxã" + +#: src/err-codes.h:237 +msgid "IPC call has been cancelled" +msgstr "" + +#: src/err-codes.h:238 +msgid "No input source for IPC" +msgstr "" + +#: src/err-codes.h:239 +msgid "No output source for IPC" +msgstr "" + +#: src/err-codes.h:240 +#, fuzzy +msgid "IPC parameter error" +msgstr "Eroare card" + +#: src/err-codes.h:241 +#, fuzzy +msgid "Unknown IPC inquire" +msgstr "Sursã necunoscutã" + +#: src/err-codes.h:242 msgid "User defined error code 1" msgstr "Cod de eroare definit de utilizator 1" -#: src/err-codes.h:217 +#: src/err-codes.h:243 msgid "User defined error code 2" msgstr "Cod de eroare definit de utilizator 2" -#: src/err-codes.h:218 +#: src/err-codes.h:244 msgid "User defined error code 3" msgstr "Cod de eroare definit de utilizator 3" -#: src/err-codes.h:219 +#: src/err-codes.h:245 msgid "User defined error code 4" msgstr "Cod de eroare definit de utilizator 4" -#: src/err-codes.h:220 +#: src/err-codes.h:246 msgid "User defined error code 5" msgstr "Cod de eroare definit de utilizator 5" -#: src/err-codes.h:221 +#: src/err-codes.h:247 msgid "User defined error code 6" msgstr "Cod de eroare definit de utilizator 6" -#: src/err-codes.h:222 +#: src/err-codes.h:248 msgid "User defined error code 7" msgstr "Cod de eroare definit de utilizator 7" -#: src/err-codes.h:223 +#: src/err-codes.h:249 msgid "User defined error code 8" msgstr "Cod de eroare definit de utilizator 8" -#: src/err-codes.h:224 +#: src/err-codes.h:250 msgid "User defined error code 9" msgstr "Cod de eroare definit de utilizator 9" -#: src/err-codes.h:225 +#: src/err-codes.h:251 msgid "User defined error code 10" msgstr "Cod de eroare definit de utilizator 10" -#: src/err-codes.h:226 +#: src/err-codes.h:252 msgid "User defined error code 11" msgstr "Cod de eroare definit de utilizator 11" -#: src/err-codes.h:227 +#: src/err-codes.h:253 msgid "User defined error code 12" msgstr "Cod de eroare definit de utilizator 12" -#: src/err-codes.h:228 +#: src/err-codes.h:254 msgid "User defined error code 13" msgstr "Cod de eroare definit de utilizator 13" -#: src/err-codes.h:229 +#: src/err-codes.h:255 msgid "User defined error code 14" msgstr "Cod de eroare definit de utilizator 14" -#: src/err-codes.h:230 +#: src/err-codes.h:256 msgid "User defined error code 15" msgstr "Cod de eroare definit de utilizator 15" -#: src/err-codes.h:231 +#: src/err-codes.h:257 msgid "User defined error code 16" msgstr "Cod de eroare definit de utilizator 16" -#: src/err-codes.h:232 +#: src/err-codes.h:258 +msgid "System error w/o errno" +msgstr "" + +#: src/err-codes.h:259 msgid "Unknown system error" msgstr "Eroare de sistem necunoscutã" -#: src/err-codes.h:233 +#: src/err-codes.h:260 msgid "End of file" msgstr "Sfârºit de fiºier" -#: src/err-codes.h:234 +#: src/err-codes.h:261 msgid "Unknown error code" msgstr "Cod de eroare necunoscut" @@ -926,3 +1055,6 @@ #, c-format msgid "%s: warning: could not recognize %s\n" msgstr "%s: avertisment: nu am putut recunoaºte %s\n" + +#~ msgid "Assuan error" +#~ msgstr "Eroare Assuan" Modified: trunk/po/vi.po =================================================================== --- trunk/po/vi.po 2006-09-08 10:06:27 UTC (rev 178) +++ trunk/po/vi.po 2006-09-14 14:24:34 UTC (rev 179) @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: libgpg-error-1.1\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2006-03-14 12:56+0100\n" +"POT-Creation-Date: 2006-09-14 14:58+0200\n" "PO-Revision-Date: 2006-01-08 16:33+1030\n" "Last-Translator: Clytie Siddall \n" "Language-Team: Vietnamese \n" @@ -65,22 +65,27 @@ msgstr "GSTI" #: src/err-sources.h:40 +#, fuzzy +msgid "Any source" +msgstr "Nguồn lạ" + +#: src/err-sources.h:41 msgid "User defined source 1" msgstr "Nguồn tá»± định nghÄ©a 1" -#: src/err-sources.h:41 +#: src/err-sources.h:42 msgid "User defined source 2" msgstr "Nguồn tá»± định nghÄ©a 2" -#: src/err-sources.h:42 +#: src/err-sources.h:43 msgid "User defined source 3" msgstr "Nguồn tá»± định nghÄ©a 3" -#: src/err-sources.h:43 +#: src/err-sources.h:44 msgid "User defined source 4" msgstr "Nguồn tá»± định nghÄ©a 4" -#: src/err-sources.h:44 +#: src/err-sources.h:45 msgid "Unknown source" msgstr "Nguồn lạ" @@ -409,12 +414,14 @@ msgstr "Dữ liệu không hợp lệ" #: src/err-codes.h:108 -msgid "Assuan server fault" +#, fuzzy +msgid "Unspecific Assuan server fault" msgstr "Lá»—i máy phục vụ Assuan" #: src/err-codes.h:109 -msgid "Assuan error" -msgstr "Lá»—i Assuan" +#, fuzzy +msgid "General Assuan error" +msgstr "Lá»—i chung" #: src/err-codes.h:110 msgid "Invalid session key" @@ -790,134 +797,256 @@ msgstr "ChÆ°a khóa" #: src/err-codes.h:202 +#, fuzzy +msgid "Unknown option" +msgstr "Biểu thức S lạ" + +#: src/err-codes.h:203 +#, fuzzy +msgid "Unknown command" +msgstr "Mã lá»—i lạ" + +#: src/err-codes.h:204 msgid "Buffer too short" msgstr "Vùng đệm quá ngắn" -#: src/err-codes.h:203 +#: src/err-codes.h:205 msgid "Invalid length specifier in S-expression" msgstr "Äiá»u ghi rõ Ä‘á»™ dài không hợp lệ trong biểu thức S" -#: src/err-codes.h:204 +#: src/err-codes.h:206 msgid "String too long in S-expression" msgstr "Chuá»—i quá dài trong biểu thức S" -#: src/err-codes.h:205 +#: src/err-codes.h:207 msgid "Unmatched parentheses in S-expression" msgstr "Có ngoặc chÆ°a khá»›p trong biểu thức S" -#: src/err-codes.h:206 +#: src/err-codes.h:208 msgid "S-expression not canonical" msgstr "Biểu thức S không phải chuẩn tắc" -#: src/err-codes.h:207 +#: src/err-codes.h:209 msgid "Bad character in S-expression" msgstr "Ký tá»± sai trong biểu thức S" -#: src/err-codes.h:208 +#: src/err-codes.h:210 msgid "Bad quotation in S-expression" msgstr "Äoạn trích dẫn sai trong biểu thức S" -#: src/err-codes.h:209 +#: src/err-codes.h:211 msgid "Zero prefix in S-expression" msgstr "Tiá»n tố số không trong biểu thức S" -#: src/err-codes.h:210 +#: src/err-codes.h:212 msgid "Nested display hints in S-expression" msgstr "Có mẹo hiển thị lồng nhau trong biểu thức S" -#: src/err-codes.h:211 +#: src/err-codes.h:213 msgid "Unmatched display hints" msgstr "Có mẹo hiển thị chÆ°a khá»›p" -#: src/err-codes.h:212 +#: src/err-codes.h:214 msgid "Unexpected reserved punctuation in S-expression" msgstr "Có dấu chấm câu đã dành riêng bất ngá» trong biểu thức S" -#: src/err-codes.h:213 +#: src/err-codes.h:215 msgid "Bad hexadecimal character in S-expression" msgstr "Ký tá»± thập lục sai trong biểu thức S" -#: src/err-codes.h:214 +#: src/err-codes.h:216 msgid "Odd hexadecimal numbers in S-expression" msgstr "Có số thập lục lẻ trong biểu thức S" -#: src/err-codes.h:215 +#: src/err-codes.h:217 msgid "Bad octadecimal character in S-expression" msgstr "Ký tá»± bát phân trong biểu thức S" -#: src/err-codes.h:216 +#: src/err-codes.h:218 +#, fuzzy +msgid "General IPC error" +msgstr "Lá»—i chung" + +#: src/err-codes.h:219 +msgid "IPC accept call failed" +msgstr "" + +#: src/err-codes.h:220 +msgid "IPC connect call failed" +msgstr "" + +#: src/err-codes.h:221 +#, fuzzy +msgid "Invalid IPC response" +msgstr "Äáp ứng không hợp lệ" + +#: src/err-codes.h:222 +#, fuzzy +msgid "Invalid value passed to IPC" +msgstr "Giá trị không hợp lệ" + +#: src/err-codes.h:223 +#, fuzzy +msgid "Incomplete line passed to IPC" +msgstr "Dòng chÆ°a xong" + +#: src/err-codes.h:224 +#, fuzzy +msgid "Line passed to IPC too long" +msgstr "Dòng quá dài" + +#: src/err-codes.h:225 +msgid "Nested IPC commands" +msgstr "" + +#: src/err-codes.h:226 +msgid "No data callback in IPC" +msgstr "" + +#: src/err-codes.h:227 +msgid "No inquire callback in IPC" +msgstr "" + +#: src/err-codes.h:228 +msgid "Not an IPC server" +msgstr "" + +#: src/err-codes.h:229 +msgid "Not an IPC client" +msgstr "" + +#: src/err-codes.h:230 +msgid "Problem starting IPC server" +msgstr "" + +#: src/err-codes.h:231 +#, fuzzy +msgid "IPC read error" +msgstr "Lá»—i thẻ" + +#: src/err-codes.h:232 +#, fuzzy +msgid "IPC write error" +msgstr "Lá»—i thẻ" + +#: src/err-codes.h:233 +msgid "Too much data for IPC layer" +msgstr "" + +#: src/err-codes.h:234 +#, fuzzy +msgid "Unexpected IPC command" +msgstr "Thẻ (tag) bất ngá»" + +#: src/err-codes.h:235 +#, fuzzy +msgid "Unknown IPC command" +msgstr "Mã lá»—i lạ" + +#: src/err-codes.h:236 +#, fuzzy +msgid "IPC syntax error" +msgstr "Lá»—i cú pháp" + +#: src/err-codes.h:237 +msgid "IPC call has been cancelled" +msgstr "" + +#: src/err-codes.h:238 +msgid "No input source for IPC" +msgstr "" + +#: src/err-codes.h:239 +msgid "No output source for IPC" +msgstr "" + +#: src/err-codes.h:240 +#, fuzzy +msgid "IPC parameter error" +msgstr "Lá»—i thẻ" + +#: src/err-codes.h:241 +#, fuzzy +msgid "Unknown IPC inquire" +msgstr "Nguồn lạ" + +#: src/err-codes.h:242 msgid "User defined error code 1" msgstr "Mã lá»—i tá»± định nghÄ©a 1" -#: src/err-codes.h:217 +#: src/err-codes.h:243 msgid "User defined error code 2" msgstr "Mã lá»—i tá»± định nghÄ©a 2" -#: src/err-codes.h:218 +#: src/err-codes.h:244 msgid "User defined error code 3" msgstr "Mã lá»—i tá»± định nghÄ©a 3" -#: src/err-codes.h:219 +#: src/err-codes.h:245 msgid "User defined error code 4" msgstr "Mã lá»—i tá»± định nghÄ©a 4" -#: src/err-codes.h:220 +#: src/err-codes.h:246 msgid "User defined error code 5" msgstr "Mã lá»—i tá»± định nghÄ©a 5" -#: src/err-codes.h:221 +#: src/err-codes.h:247 msgid "User defined error code 6" msgstr "Mã lá»—i tá»± định nghÄ©a 6" -#: src/err-codes.h:222 +#: src/err-codes.h:248 msgid "User defined error code 7" msgstr "Mã lá»—i tá»± định nghÄ©a 7" -#: src/err-codes.h:223 +#: src/err-codes.h:249 msgid "User defined error code 8" msgstr "Mã lá»—i tá»± định nghÄ©a 8" -#: src/err-codes.h:224 +#: src/err-codes.h:250 msgid "User defined error code 9" msgstr "Mã lá»—i tá»± định nghÄ©a 9" -#: src/err-codes.h:225 +#: src/err-codes.h:251 msgid "User defined error code 10" msgstr "Mã lá»—i tá»± định nghÄ©a 10" -#: src/err-codes.h:226 +#: src/err-codes.h:252 msgid "User defined error code 11" msgstr "Mã lá»—i tá»± định nghÄ©a 11" -#: src/err-codes.h:227 +#: src/err-codes.h:253 msgid "User defined error code 12" msgstr "Mã lá»—i tá»± định nghÄ©a 12" -#: src/err-codes.h:228 +#: src/err-codes.h:254 msgid "User defined error code 13" msgstr "Mã lá»—i tá»± định nghÄ©a 13" -#: src/err-codes.h:229 +#: src/err-codes.h:255 msgid "User defined error code 14" msgstr "Mã lá»—i tá»± định nghÄ©a 14" -#: src/err-codes.h:230 +#: src/err-codes.h:256 msgid "User defined error code 15" msgstr "Mã lá»—i tá»± định nghÄ©a 15" -#: src/err-codes.h:231 +#: src/err-codes.h:257 msgid "User defined error code 16" msgstr "Mã lá»—i tá»± định nghÄ©a 16" -#: src/err-codes.h:232 +#: src/err-codes.h:258 +msgid "System error w/o errno" +msgstr "" + +#: src/err-codes.h:259 msgid "Unknown system error" msgstr "Gặp lá»—i hệ thống lạ" -#: src/err-codes.h:233 +#: src/err-codes.h:260 msgid "End of file" msgstr "Kết thức tập tin" -#: src/err-codes.h:234 +#: src/err-codes.h:261 msgid "Unknown error code" msgstr "Mã lá»—i lạ" @@ -930,3 +1059,6 @@ #, c-format msgid "%s: warning: could not recognize %s\n" msgstr "%s: cảnh báo : không thể nhận ra %s\n" + +#~ msgid "Assuan error" +#~ msgstr "Lá»—i Assuan" Modified: trunk/src/code-from-errno.c =================================================================== --- trunk/src/code-from-errno.c 2006-09-08 10:06:27 UTC (rev 178) +++ trunk/src/code-from-errno.c 2006-09-14 14:24:34 UTC (rev 179) @@ -22,6 +22,8 @@ #include #endif +#include + #include #include "code-from-errno.h" @@ -32,13 +34,36 @@ gpg_err_code_t gpg_err_code_from_errno (int err) { - int idx = errno_to_idx (err); + int idx; if (!err) return GPG_ERR_NO_ERROR; + idx = errno_to_idx (err); + if (idx < 0) return GPG_ERR_UNKNOWN_ERRNO; return GPG_ERR_SYSTEM_ERROR | err_code_from_index[idx]; } + + +/* Retrieve the error code directly from the ERRNO variable. This + returns GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped + (report this) and GPG_ERR_MISSING_ERRNO if ERRNO has the value 0. */ +gpg_err_code_t +gpg_err_code_from_syserror (void) +{ + int err = errno; + int idx; + + if (!err) + return GPG_ERR_MISSING_ERRNO; + + idx = errno_to_idx (err); + + if (idx < 0) + return GPG_ERR_UNKNOWN_ERRNO; + + return GPG_ERR_SYSTEM_ERROR | err_code_from_index[idx]; +} Modified: trunk/src/gpg-error.h.in =================================================================== --- trunk/src/gpg-error.h.in 2006-09-08 10:06:27 UTC (rev 178) +++ trunk/src/gpg-error.h.in 2006-09-14 14:24:34 UTC (rev 179) @@ -212,7 +212,7 @@ /* Retrieve the error code for the system error ERR. This returns GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped (report - this). */ + this). */ gpg_err_code_t gpg_err_code_from_errno (int err); @@ -220,6 +220,14 @@ if CODE is not a system error code. */ int gpg_err_code_to_errno (gpg_err_code_t code); + +/* Retrieve the error code directly from the ERRNO variable. This + returns GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped + (report this) and GPG_ERR_MISSING_ERRNO if ERRNO has the value 0. */ +gpg_err_code_t gpg_err_code_from_syserror (void); + + + /* Self-documenting convenience functions. */ @@ -236,6 +244,12 @@ return gpg_error (gpg_err_code_from_errno (err)); } +static GPG_ERR_INLINE gpg_error_t +gpg_error_from_syserror (void) +{ + return gpg_error (gpg_err_code_from_syserror ()); +} + #ifdef __cplusplus } #endif Modified: trunk/src/strerror.c =================================================================== --- trunk/src/strerror.c 2006-09-08 10:06:27 UTC (rev 178) +++ trunk/src/strerror.c 2006-09-14 14:24:34 UTC (rev 179) @@ -61,7 +61,7 @@ to a resource shortage, set *STR to NULL and return 1. If this call fails because the error number is not valid, don't set *STR and return 0. */ -int +static int system_strerror_r (int no, char *buf, size_t buflen) { char *errstr; @@ -89,7 +89,7 @@ #else /* STRERROR_R_CHAR_P */ /* Now the POSIX version. */ -int +static int system_strerror_r (int no, char *buf, size_t buflen) { return strerror_r (no, buf, buflen); @@ -102,7 +102,7 @@ version. Maybe we are even lucky and the system's strerror() is already thread-safe. */ -int +static int system_strerror_r (int no, char *buf, size_t buflen) { char *errstr = strerror (no); Modified: trunk/tests/Makefile.am =================================================================== --- trunk/tests/Makefile.am 2006-09-08 10:06:27 UTC (rev 178) +++ trunk/tests/Makefile.am 2006-09-14 14:24:34 UTC (rev 179) @@ -19,7 +19,7 @@ ## Process this file with automake to produce Makefile.in -TESTS = t-strerror +TESTS = t-strerror t-syserror INCLUDES = -I$(top_builddir)/src Added: trunk/tests/t-syserror.c =================================================================== --- trunk/tests/t-syserror.c 2006-09-08 10:06:27 UTC (rev 178) +++ trunk/tests/t-syserror.c 2006-09-14 14:24:34 UTC (rev 179) @@ -0,0 +1,84 @@ +/* t-syserror.c - System error specific regression test. + Copyright (C) 2006 g10 Code GmbH + + This file is part of libgpg-error. + + libgpg-error 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 2.1 of + the License, or (at your option) any later version. + + libgpg-error 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with libgpgme-error; if not, write to the Free + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ + + +#if HAVE_CONFIG_H +#include +#endif + +#include +#if HAVE_STDLIB_H +#include +#endif +#include + +#include + +int +main (int argc, char *argv[]) +{ + FILE *fp; + int save_errno; + gpg_err_code_t ec; + + fp = fopen ("/does-not-exist/110761/nowhere.foo", "r"); + if (fp) + { + fclose (fp); + fp = fopen (" no this file does not exists foo 4711", "r"); + } + if (fp) + { + fprintf (stderr, "unable to run test\n"); + return 1; + } + save_errno = errno; + + ec = gpg_err_code_from_syserror (); + if (ec != GPG_ERR_ENOENT) + { + fprintf (stderr, "fopen failed with bad code: %d\n", save_errno); + return 1; + } + + if (ec != gpg_err_code_from_errno (save_errno)) + { + fprintf (stderr, "oops at %d\n",__LINE__); + return 1; + } + + errno = 0; + + ec = gpg_err_code_from_syserror (); + if (ec != GPG_ERR_MISSING_ERRNO) + { + fprintf (stderr, "oops at %d\n",__LINE__); + return 1; + } + + if ( gpg_err_code_from_errno (0) ) + { + fprintf (stderr, "oops at %d\n",__LINE__); + return 1; + } + + + return 0; +} From cvs at cvs.gnupg.org Thu Sep 14 16:35:00 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu Sep 14 15:50:03 2006 Subject: [svn] gpg-error - r180 - tags Message-ID: Author: wk Date: 2006-09-14 16:35:00 +0200 (Thu, 14 Sep 2006) New Revision: 180 Added: tags/libgpg-error-1.4/ Log: From cvs at cvs.gnupg.org Thu Sep 14 16:40:20 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu Sep 14 15:55:23 2006 Subject: [svn] gpg-error - r181 - trunk Message-ID: Author: wk Date: 2006-09-14 16:40:20 +0200 (Thu, 14 Sep 2006) New Revision: 181 Modified: trunk/NEWS trunk/configure.ac Log: Post release updates Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-09-14 14:35:00 UTC (rev 180) +++ trunk/NEWS 2006-09-14 14:40:20 UTC (rev 181) @@ -1,3 +1,8 @@ +Noteworthy changes in version 1.5 +---------------------------------------------- + + + Noteworthy changes in version 1.4 (2006-09-14) ---------------------------------------------- Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-09-14 14:35:00 UTC (rev 180) +++ trunk/configure.ac 2006-09-14 14:40:20 UTC (rev 181) @@ -24,7 +24,7 @@ # The gettext version is set below using AM_GNU_GETTEXT_VERSION # Version number: Remember to change it immediately *after* a release. -AC_INIT([libgpg-error],[1.4],[bug-gnupg@gnupg.org]) +AC_INIT([libgpg-error],[1.5-cvs],[bug-gnupg@gnupg.org]) # LT Version numbers, remember to change them just *before* a release. # (Code changed: REVISION++) # (Interfaces added/removed/changed: CURRENT++, REVISION=0) From cvs at cvs.gnupg.org Thu Sep 14 18:50:41 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu Sep 14 18:05:46 2006 Subject: [svn] GnuPG - r4249 - in trunk: . agent common g10 kbx scd sm tools Message-ID: Author: wk Date: 2006-09-14 18:50:33 +0200 (Thu, 14 Sep 2006) New Revision: 4249 Modified: trunk/ChangeLog trunk/Makefile.am trunk/NEWS trunk/README trunk/acinclude.m4 trunk/agent/ChangeLog trunk/agent/call-pinentry.c trunk/agent/call-scd.c trunk/agent/command-ssh.c trunk/agent/command.c trunk/agent/divert-scd.c trunk/agent/findkey.c trunk/agent/preset-passphrase.c trunk/common/ChangeLog trunk/common/asshelp.c trunk/common/b64enc.c trunk/common/exechelp.c trunk/common/http.c trunk/common/iobuf.c trunk/common/miscellaneous.c trunk/common/util.h trunk/configure.ac trunk/g10/ChangeLog trunk/g10/call-agent.c trunk/g10/dearmor.c trunk/g10/decrypt.c trunk/g10/encode.c trunk/g10/exec.c trunk/g10/gpg.c trunk/g10/keydb.c trunk/g10/keygen.c trunk/g10/keyring.c trunk/g10/keyserver.c trunk/g10/openfile.c trunk/g10/plaintext.c trunk/g10/sign.c trunk/g10/tdbio.c trunk/g10/verify.c trunk/kbx/ChangeLog trunk/kbx/keybox-openpgp.c trunk/scd/ChangeLog trunk/scd/app-openpgp.c trunk/scd/app-p15.c trunk/scd/app.c trunk/scd/command.c trunk/scd/iso7816.c trunk/sm/ChangeLog trunk/sm/base64.c trunk/sm/certchain.c trunk/sm/export.c trunk/sm/import.c trunk/sm/keylist.c trunk/sm/qualified.c trunk/tools/ChangeLog trunk/tools/gpgkey2ssh.c Log: Take advantage of newer gpg-error features. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/ChangeLog 2006-09-14 16:50:33 UTC (rev 4249) @@ -1,3 +1,11 @@ +2006-09-14 Werner Koch + + Replaced all call gpg_error_from_errno(errno) by + gpg_error_from_syserror(). + + * configure.ac: Build gpg by default. + (GNUPG_SYS_SO_PEERCRED): Removed. + 2006-09-13 Werner Koch * autogen.sh: Better detection of the cross compiler kit. Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/Makefile.am 2006-09-14 16:50:33 UTC (rev 4249) @@ -24,7 +24,7 @@ AUTOMAKE_OPTIONS = dist-bzip2 DISTCHECK_CONFIGURE_FLAGS = --enable-gpg -EXTRA_DIST = scripts/config.rpath autogen.sh README.CVS +EXTRA_DIST = scripts/config.rpath autogen.sh README.SVN DISTCLEANFILES = g10defs.h if BUILD_GPGSM Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/NEWS 2006-09-14 16:50:33 UTC (rev 4249) @@ -2,7 +2,7 @@ ------------------------------------------------- * Regular man pages for most tools are now build directly from the - texinfo source. + Texinfo source. * The gpg code from 1.4.5 has been fully merged into this release. The configure option --enable-gpg is still required to build this Modified: trunk/README =================================================================== --- trunk/README 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/README 2006-09-14 16:50:33 UTC (rev 4249) @@ -5,9 +5,7 @@ GnuPG 1.9 is the future version of GnuPG; it is based on some gnupg-1.3 code and the previous newpg package. It will eventually lead to a -GnuPG 2.0 release. Note that GnuPG 1.4 and 1.9 are not always in sync -and thus features and bug fixes done in 1.4 are not necessary -available in 1.9. +GnuPG 2.0 release. You should use this GnuPG version if you want to use the gpg-agent or gpgsm (the S/MIME variant of gpg). Note that the gpg-agent is also Modified: trunk/acinclude.m4 =================================================================== --- trunk/acinclude.m4 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/acinclude.m4 2006-09-14 16:50:33 UTC (rev 4249) @@ -157,26 +157,7 @@ -# Check for the getsockopt SO_PEERCRED -AC_DEFUN([GNUPG_SYS_SO_PEERCRED], - [ AC_MSG_CHECKING(for SO_PEERCRED) - AC_CACHE_VAL(gnupg_cv_sys_so_peercred, - [AC_TRY_COMPILE([#include ], - [struct ucred cr; - int cl = sizeof cr; - getsockopt (1, SOL_SOCKET, SO_PEERCRED, &cr, &cl);], - gnupg_cv_sys_so_peercred=yes, - gnupg_cv_sys_so_peercred=no) - ]) - AC_MSG_RESULT($gnupg_cv_sys_so_peercred) - if test $gnupg_cv_sys_so_peercred = yes; then - AC_DEFINE(HAVE_SO_PEERCRED, 1, - [Defined if SO_PEERCRED is supported (Linux)]) - fi - ]) - - # GNUPG_BUILD_PROGRAM(NAME,DEFAULT) # Add a --enable-NAME option to configure an set the # shell variable build_NAME either to "yes" or "no". DEFAULT must Modified: trunk/agent/ChangeLog =================================================================== --- trunk/agent/ChangeLog 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/agent/ChangeLog 2006-09-14 16:50:33 UTC (rev 4249) @@ -1,3 +1,14 @@ +2006-09-14 Werner Koch + + Replaced all call gpg_error_from_errno(errno) by + gpg_error_from_syserror(). + + * call-pinentry.c (start_pinentry): Replaced pipe_connect2 by + pipe_connect_ext. + * call-scd.c (start_scd): Ditto. + * command.c (start_command_handler): Replaced + init_connected_socket_server by init_socket_server_ext. + 2006-09-13 Werner Koch * preset-passphrase.c (main) [W32]: Check for WSAStartup error. Modified: trunk/agent/call-pinentry.c =================================================================== --- trunk/agent/call-pinentry.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/agent/call-pinentry.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -238,8 +238,8 @@ no_close_list[i] = -1; /* Connect to the pinentry and perform initial handshaking */ - rc = assuan_pipe_connect2 (&ctx, opt.pinentry_program, argv, - no_close_list, atfork_cb, NULL); + rc = assuan_pipe_connect_ext (&ctx, opt.pinentry_program, argv, + no_close_list, atfork_cb, NULL, 0); if (rc) { log_error ("can't connect to the PIN entry module: %s\n", @@ -649,7 +649,7 @@ popup_tid = pth_spawn (tattr, popup_message_thread, NULL); if (!popup_tid) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error ("error spawning popup message handler: %s\n", strerror (errno) ); pth_attr_destroy (tattr); Modified: trunk/agent/call-scd.c =================================================================== --- trunk/agent/call-scd.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/agent/call-scd.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -217,7 +217,7 @@ { ctrl->scd_local = xtrycalloc (1, sizeof *ctrl->scd_local); if (!ctrl->scd_local) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); ctrl->scd_local->ctrl_backlink = ctrl; ctrl->scd_local->next_local = scd_local_list; scd_local_list = ctrl->scd_local; @@ -316,8 +316,8 @@ no_close_list[i] = -1; /* Connect to the pinentry and perform initial handshaking */ - rc = assuan_pipe_connect2 (&ctx, opt.scdaemon_program, argv, - no_close_list, atfork_cb, NULL); + rc = assuan_pipe_connect_ext (&ctx, opt.scdaemon_program, argv, + no_close_list, atfork_cb, NULL, 0); if (rc) { log_error ("can't connect to the SCdaemon: %s\n", Modified: trunk/agent/command-ssh.c =================================================================== --- trunk/agent/command-ssh.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/agent/command-ssh.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -294,7 +294,7 @@ if (ret == EOF) { if (es_ferror (stream)) - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); else err = gpg_error (GPG_ERR_EOF); *b = 0; @@ -317,7 +317,7 @@ ret = es_fputc (b, stream); if (ret == EOF) - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); else err = 0; @@ -335,7 +335,7 @@ ret = es_read (stream, buffer, sizeof (buffer), &bytes_read); if (ret) - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); else { if (bytes_read != sizeof (buffer)) @@ -368,7 +368,7 @@ ret = es_write (stream, buffer, sizeof (buffer), NULL); if (ret) - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); else err = 0; @@ -385,7 +385,7 @@ ret = es_read (stream, buffer, size, &bytes_read); if (ret) - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); else { if (bytes_read != size) @@ -406,7 +406,7 @@ ret = es_write (stream, buffer, size, NULL); if (ret) - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); else err = 0; @@ -438,7 +438,7 @@ buffer = xtrymalloc (length + 1); if (! buffer) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto out; } @@ -587,13 +587,13 @@ if (ret || (! bytes_read)) { if (ret) - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); break; } ret = es_write (dst, buffer, bytes_read, NULL); if (ret) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); break; } } @@ -623,21 +623,21 @@ stream = es_fopen (filename, "r"); if (! stream) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto out; } ret = fstat (es_fileno (stream), &statbuf); if (ret) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto out; } buffer_new = xtrymalloc (statbuf.st_size); if (! buffer_new) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto out; } @@ -865,7 +865,7 @@ mpis = xtrycalloc (elems_n + 1, sizeof *mpis ); if (!mpis) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto out; } @@ -1040,7 +1040,7 @@ sexp_template = xtrymalloc (sexp_template_n); if (! sexp_template) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto out; } @@ -1048,7 +1048,7 @@ arg_list = xtrymalloc (sizeof (*arg_list) * (2 + elems_n + 1)); if (! arg_list) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto out; } @@ -1153,7 +1153,7 @@ mpis_new = xtrycalloc (elems_n + 1, sizeof *mpis_new ); if (!mpis_new) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto out; } @@ -1204,7 +1204,7 @@ comment_new = make_cstring (data, data_n); if (! comment_new) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto out; } @@ -1401,7 +1401,7 @@ stream = es_mopen (NULL, 0, 0, 1, NULL, NULL, "r+"); if (! stream) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto out; } @@ -1417,7 +1417,7 @@ blob_size_new = es_ftell (stream); if (blob_size_new == -1) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto out; } @@ -1428,7 +1428,7 @@ blob_new = xtrymalloc (blob_size_new); if (! blob_new) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto out; } @@ -1520,7 +1520,7 @@ blob_stream = es_mopen (NULL, 0, 0, 1, NULL, NULL, "r+"); if (! blob_stream) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto out; } @@ -1684,7 +1684,7 @@ shadow_info = make_shadow_info (serialno, authkeyid); if (!shadow_info) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); xfree (pkbuf); gcry_sexp_release (s_pk); xfree (serialno); @@ -1734,7 +1734,7 @@ *cardsn = xtryasprintf ("cardno:%s", serialno); if (!*cardsn) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); xfree (pkbuf); gcry_sexp_release (s_pk); xfree (serialno); @@ -1801,7 +1801,7 @@ key_blobs = es_mopen (NULL, 0, 0, 1, NULL, NULL, "r+"); if (! key_blobs) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto out; } @@ -1925,7 +1925,7 @@ ret = es_fseek (key_blobs, 0, SEEK_SET); if (ret) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto out; } @@ -2032,7 +2032,7 @@ stream = es_mopen (NULL, 0, 0, 1, NULL, NULL, "r+"); if (! stream) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto out; } @@ -2046,7 +2046,7 @@ identifier = make_cstring (identifier_raw, identifier_n); if (! identifier) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto out; } @@ -2064,7 +2064,7 @@ mpis = xtrycalloc (elems_n + 1, sizeof *mpis); if (!mpis) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto out; } @@ -2098,21 +2098,21 @@ sig_blob_n = es_ftell (stream); if (sig_blob_n == -1) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto out; } sig_blob = xtrymalloc (sig_blob_n); if (! sig_blob) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto out; } ret = es_fseek (stream, 0, SEEK_SET); if (ret) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto out; } @@ -2269,7 +2269,7 @@ comment_new = make_cstring (data, data_n); if (! comment_new) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto out; } @@ -2299,7 +2299,7 @@ buffer_new = xtrymalloc_secure (buffer_new_n); if (! buffer_new) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto out; } @@ -2356,7 +2356,7 @@ "within gpg-agent's key storage"), comment ? comment : "?") < 0) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto out; } @@ -2364,7 +2364,7 @@ pi = gcry_calloc_secure (1, sizeof (*pi) + 100 + 1); if (!pi) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto out; } pi->max_length = 100; @@ -2720,13 +2720,13 @@ request = es_mopen (NULL, 0, 0, 1, gcry_realloc, gcry_free, "r+"); if (! request) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto out; } ret = es_setvbuf (request, NULL, _IONBF, 0); if (ret) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto out; } err = stream_write_data (request, request_data + 1, request_data_size - 1); @@ -2737,7 +2737,7 @@ response = es_mopen (NULL, 0, 0, 1, NULL, NULL, "r+"); if (! response) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto out; } @@ -2853,7 +2853,7 @@ stream_sock = es_fdopen (sock_client, "r+"); if (!stream_sock) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); log_error (_("failed to create stream from socket: %s\n"), gpg_strerror (err)); goto out; @@ -2863,7 +2863,7 @@ ret = es_setvbuf (stream_sock, NULL, _IONBF, 0); if (ret) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); log_error (_("failed to disable buffering " "on socket stream: %s\n"), gpg_strerror (err)); goto out; Modified: trunk/agent/command.c =================================================================== --- trunk/agent/command.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/agent/command.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -585,7 +585,7 @@ assert (len); buf = xtrymalloc (len); if (!buf) - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); else { len = gcry_sexp_sprint (s_pkey, GCRYSEXP_FMT_CANON, buf, len); @@ -1038,7 +1038,7 @@ { vl = xtrymalloc (sizeof *vl + strlen (key) + valuelen); if (!vl) - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); else { vl->len = valuelen; @@ -1221,11 +1221,11 @@ } else if (listen_fd != -1) { - rc = assuan_init_socket_server (&ctx, listen_fd); + rc = assuan_init_socket_server_ext (&ctx, listen_fd, 0); } else { - rc = assuan_init_connected_socket_server (&ctx, fd); + rc = assuan_init_socket_server_ext (&ctx, fd, 2); ctrl.connection_fd = fd; } if (rc) Modified: trunk/agent/divert-scd.c =================================================================== --- trunk/agent/divert-scd.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/agent/divert-scd.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -248,7 +248,7 @@ again: pi = gcry_calloc_secure (1, sizeof (*pi) + maxbuf + 10); if (!pi) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); pi->max_length = maxbuf-1; pi->min_digits = 0; /* we want a real passphrase */ pi->max_digits = 8; @@ -264,7 +264,7 @@ pi2 = gcry_calloc_secure (1, sizeof (*pi) + maxbuf + 10); if (!pi2) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); xfree (pi); return rc; } Modified: trunk/agent/findkey.c =================================================================== --- trunk/agent/findkey.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/agent/findkey.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -215,7 +215,7 @@ { *result = out = xtrymalloc (out_len + 1); if (!out) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); } } @@ -270,7 +270,7 @@ pi = gcry_calloc_secure (1, sizeof (*pi) + 100); if (!pi) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); pi->max_length = 100; pi->min_digits = 0; /* we want a real passphrase */ pi->max_digits = 8; @@ -318,7 +318,7 @@ fp = fopen (fname, "rb"); if (!fp) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error ("can't open `%s': %s\n", fname, strerror (errno)); xfree (fname); return rc; @@ -326,7 +326,7 @@ if (fstat (fileno(fp), &st)) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error ("can't stat `%s': %s\n", fname, strerror (errno)); xfree (fname); fclose (fp); @@ -337,7 +337,7 @@ buf = xtrymalloc (buflen+1); if (!buf || fread (buf, buflen, 1, fp) != 1) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error ("error reading `%s': %s\n", fname, strerror (errno)); xfree (fname); fclose (fp); @@ -394,7 +394,7 @@ buf = xtrymalloc (len); if (!buf) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); gcry_sexp_release (s_skey); return rc; } @@ -435,7 +435,7 @@ shouldn't be a problem. */ char *tmp = xtrymalloc (comment_length+1); if (!tmp) - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); else { memcpy (tmp, comment, comment_length); @@ -593,7 +593,7 @@ array = xtrycalloc (strlen(elems) + 1, sizeof *array); if (!array) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); gcry_sexp_release (list); gcry_sexp_release (s_skey); return rc; @@ -655,7 +655,7 @@ format = xtrymalloc (15+7*strlen (elems)+10+15+1+1); if (!format) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); for (i=0; array[i]; i++) gcry_mpi_release (array[i]); xfree (array); Modified: trunk/agent/preset-passphrase.c =================================================================== --- trunk/agent/preset-passphrase.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/agent/preset-passphrase.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -144,7 +144,7 @@ case SPWQ_NO_AGENT: return gpg_error (GPG_ERR_NO_AGENT); case SPWQ_SYS_ERROR: - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); case SPWQ_GENERAL_ERROR: default: return gpg_error (GPG_ERR_GENERAL); @@ -165,7 +165,7 @@ if (!dst) { log_error ("can not escape string: %s\n", - gpg_strerror (gpg_error_from_errno (errno))); + gpg_strerror (gpg_error_from_syserror ())); return NULL; } @@ -199,7 +199,7 @@ if (rc < 0) { log_error ("reading passphrase failed: %s\n", - gpg_strerror (gpg_error_from_errno (errno))); + gpg_strerror (gpg_error_from_syserror ())); return; } passphrase[rc] = '\0'; @@ -230,7 +230,7 @@ if (rc < 0) { log_error ("caching passphrase failed: %s\n", - gpg_strerror (gpg_error_from_errno (errno))); + gpg_strerror (gpg_error_from_syserror ())); return; } if (!opt_passphrase) @@ -258,7 +258,7 @@ if (rc < 0) { log_error ("clearing passphrase failed: %s\n", - gpg_strerror (gpg_error_from_errno (errno))); + gpg_strerror (gpg_error_from_syserror ())); return; } free (line); Modified: trunk/common/ChangeLog =================================================================== --- trunk/common/ChangeLog 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/common/ChangeLog 2006-09-14 16:50:33 UTC (rev 4249) @@ -1,3 +1,11 @@ +2006-09-14 Werner Koch + + * util.h (out_of_core): Use new gpg_error_from_syserror function. + + * http.c (init_sockets): Changed it to require 2.2 unless it is + build within gnupg 1 where we require 1.1 (and not anymore allow + for 1.0). + 2006-09-07 Werner Koch * exechelp.c (gnupg_spawn_process): Factor out post fork code to .. Modified: trunk/common/asshelp.c =================================================================== --- trunk/common/asshelp.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/common/asshelp.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -44,7 +44,7 @@ if (!value || !*value) err = 0; /* Avoid sending empty strings. */ else if (asprintf (&optstr, "OPTION %s=%s", name, value ) < 0) - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); else { err = assuan_transact (ctx, optstr, NULL, NULL, NULL, NULL, NULL, NULL); @@ -116,7 +116,7 @@ { old_lc = strdup (old_lc); if (!old_lc) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); } dft_lc = setlocale (LC_CTYPE, ""); #endif @@ -142,7 +142,7 @@ { old_lc = strdup (old_lc); if (!old_lc) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); } dft_lc = setlocale (LC_MESSAGES, ""); #endif Modified: trunk/common/b64enc.c =================================================================== --- trunk/common/b64enc.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/common/b64enc.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -57,7 +57,7 @@ { state->title = xtrystrdup (title); if (!state->title) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); } return 0; } @@ -130,7 +130,7 @@ return 0; write_error: - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); } gpg_error_t @@ -200,7 +200,7 @@ goto cleanup; write_error: - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); cleanup: if (state->title) Modified: trunk/common/exechelp.c =================================================================== --- trunk/common/exechelp.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/common/exechelp.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -96,7 +96,7 @@ buf = p = xtrymalloc (n); if (!buf) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); /* fixme: PGMNAME may not contain spaces etc. */ p = stpcpy (p, pgmname); @@ -342,7 +342,7 @@ } if (!*statusfile) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); log_error (_("can't fdopen pipe for reading: %s\n"), gpg_strerror (err)); CloseHandle (pi.hProcess); return err; @@ -366,7 +366,7 @@ if (pipe (rp) == -1) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); log_error (_("error creating a pipe: %s\n"), strerror (errno)); return err; } @@ -378,7 +378,7 @@ #endif if (*pid == (pid_t)(-1)) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); log_error (_("error forking process: %s\n"), strerror (errno)); close (rp[0]); close (rp[1]); @@ -399,7 +399,7 @@ *statusfile = fdopen (rp[0], "r"); if (!*statusfile) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); log_error (_("can't fdopen pipe for reading: %s\n"), strerror (errno)); kill (*pid, SIGTERM); *pid = (pid_t)(-1); @@ -528,7 +528,7 @@ return gpg_error (GPG_ERR_BUG); if (access (pgmname, X_OK)) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); #ifdef USE_GNU_PTH pid = pth_fork? pth_fork () : fork (); @@ -538,7 +538,7 @@ if (pid == (pid_t)(-1)) { log_error (_("error forking process: %s\n"), strerror (errno)); - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); } if (!pid) { Modified: trunk/common/http.c =================================================================== --- trunk/common/http.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/common/http.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -200,6 +200,16 @@ #ifdef HAVE_W32_SYSTEM + +#if GNUPG_MAJOR_VERSION == 1 +#define REQ_WINSOCK_MAJOR 1 +#define REQ_WINSOCK_MINOR 1 +#else +#define REQ_WINSOCK_MAJOR 2 +#define REQ_WINSOCK_MINOR 2 +#endif + + static void deinit_sockets (void) { @@ -215,16 +225,18 @@ if (initialized) return; - if ( WSAStartup( 0x0101, &wsdata ) ) + if ( WSAStartup( MAKEWORD (REQ_WINSOCK_MINOR, REQ_WINSOCK_MAJOR), &wsdata ) ) { log_error ("error initializing socket library: ec=%d\n", (int)WSAGetLastError () ); return; } - if ( wsdata.wVersion < 0x0001 ) + if ( LOBYTE(wsdata.wVersion) != REQ_WINSOCK_MAJOR + || HIBYTE(wsdata.wVersion) != REQ_WINSOCK_MINOR ) { - log_error ("socket library version is %x.%x - but 1.1 needed\n", - LOBYTE(wsdata.wVersion), HIBYTE(wsdata.wVersion)); + log_error ("socket library version is %x.%x - but %d.%d needed\n", + LOBYTE(wsdata.wVersion), HIBYTE(wsdata.wVersion) + REQ_WINSOCK_MAJOR, REQ_WINSOCK_MINOR); WSACleanup(); return; } @@ -313,7 +325,7 @@ /* Create the handle. */ hd = xtrycalloc (1, sizeof *hd); if (!hd) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); hd->sock = -1; hd->req_type = reqtype; hd->flags = flags; @@ -383,7 +395,7 @@ { hd->sock = dup (hd->sock); if (hd->sock == -1) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); } P_ES(fclose) (hd->fp_write); hd->fp_write = NULL; @@ -401,7 +413,7 @@ cookie = xtrycalloc (1, sizeof *cookie); if (!cookie) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); cookie->fd = hd->sock; if (hd->uri->use_tls) cookie->tls_session = hd->tls_context; @@ -410,13 +422,13 @@ if (!hd->fp_read) { xfree (cookie); - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); } } #else /*!HTTP_USE_ESTREAM*/ hd->fp_read = fdopen (hd->sock, "r"); if (!hd->fp_read) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); #endif /*!HTTP_USE_ESTREAM*/ err = parse_response (hd); @@ -851,7 +863,7 @@ uri->auth, strlen(uri->auth)); if (!proxy_authstr) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); http_release_parsed_uri (uri); return err; } @@ -919,7 +931,7 @@ if (!myauth) { xfree (proxy_authstr); - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); } remove_escapes (myauth); } @@ -937,13 +949,13 @@ if (!authstr) { xfree (proxy_authstr); - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); } } p = build_rel_path (hd->uri); if (!p) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); request = xtrymalloc (2 * strlen (server) + strlen (p) @@ -952,7 +964,7 @@ + 100); if (!request) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); xfree (p); xfree (authstr); xfree (proxy_authstr); @@ -997,7 +1009,7 @@ cookie = xtrycalloc (1, sizeof *cookie); if (!cookie) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto leave; } cookie->fd = hd->sock; @@ -1011,10 +1023,10 @@ if (!hd->fp_write) { xfree (cookie); - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); } else if (es_fputs (request, hd->fp_write) || es_fflush (hd->fp_write)) - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); else err = 0; } @@ -1030,7 +1042,7 @@ { hd->fp_write = fdopen (hd->sock, "w"); if (!hd->fp_write) - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); } #endif /*!HTTP_USE_ESTREAM*/ @@ -1237,7 +1249,7 @@ n += strlen (hd->headers->value); p = xtrymalloc (n+1); if (!p) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); strcpy (stpcpy (p, hd->headers->value), line); xfree (hd->headers->value); hd->headers->value = p; @@ -1262,7 +1274,7 @@ it is a comma separated list and merge them. */ p = xtrymalloc (strlen (h->value) + 1 + strlen (value)+ 1); if (!p) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); strcpy (stpcpy (stpcpy (p, h->value), ","), value); xfree (h->value); h->value = p; @@ -1272,13 +1284,13 @@ /* Append a new header. */ h = xtrymalloc (sizeof *h + strlen (line)); if (!h) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); strcpy (h->name, line); h->value = xtrymalloc (strlen (value)+1); if (!h->value) { xfree (h); - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); } strcpy (h->value, value); h->next = hd->headers; @@ -1334,7 +1346,7 @@ len = my_read_line (hd->fp_read, &hd->buffer, &hd->buffer_size, &maxlen); line = hd->buffer; if (!line) - return gpg_error_from_errno (errno); /* Out of core. */ + return gpg_error_from_syserror (); /* Out of core. */ if (!maxlen) return gpg_error (GPG_ERR_TRUNCATED); /* Line has been truncated. */ if (!len) @@ -1378,7 +1390,7 @@ len = my_read_line (hd->fp_read, &hd->buffer, &hd->buffer_size, &maxlen); line = hd->buffer; if (!line) - return gpg_error_from_errno (errno); /* Out of core. */ + return gpg_error_from_syserror (); /* Out of core. */ /* Note, that we can silently ignore truncated lines. */ if (!len) return gpg_error (GPG_ERR_EOF); @@ -1700,7 +1712,7 @@ continue; } log_info ("network write failed: %s\n", strerror (errno)); - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); } #endif /*!HAVE_W32_SYSTEM*/ nleft -= nwritten; Modified: trunk/common/iobuf.c =================================================================== --- trunk/common/iobuf.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/common/iobuf.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -392,7 +392,7 @@ } else if (ferror (f) && errno != EPIPE) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error ("%s: read error: %s\n", a->fname, strerror (errno)); } *ret_len = nbytes; @@ -406,7 +406,7 @@ nbytes = fwrite (buf, 1, size, f); if (ferror (f)) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error ("%s: write error: %s\n", a->fname, strerror (errno)); } } @@ -481,7 +481,7 @@ { /* error */ if (errno != EPIPE) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error ("%s: read error: %s\n", a->fname, strerror (errno)); } @@ -543,7 +543,7 @@ while (n != -1 && nbytes); if (n == -1) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error ("%s: write error: %s\n", a->fname, strerror (errno)); } nbytes = p - buf; @@ -849,14 +849,14 @@ { /* write stuff from the buffer */ assert (n == OP_MIN_PARTIAL_CHUNK); if (iobuf_write (chain, a->buffer, n)) - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); a->buflen = 0; nbytes -= n; } if ((n = nbytes) > blen) n = blen; if (n && iobuf_write (chain, p, n)) - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); p += n; nbytes -= n; } @@ -935,7 +935,7 @@ { log_error ("block_filter: write error: %s\n", strerror (errno)); - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); } xfree (a->buffer); a->buffer = NULL; @@ -1649,7 +1649,7 @@ if (len < a->d.size) { if (ferror (fp)) - a->error = gpg_error_from_errno (errno); + a->error = gpg_error_from_syserror (); } a->d.len = len; a->d.start = 0; Modified: trunk/common/miscellaneous.c =================================================================== --- trunk/common/miscellaneous.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/common/miscellaneous.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -99,7 +99,7 @@ a = iobuf_open( s ); if ( a == NULL ) { - *ret_rc = gpg_error_from_errno (errno); + *ret_rc = gpg_error_from_syserror (); return 0; } Modified: trunk/common/util.h =================================================================== --- trunk/common/util.h 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/common/util.h 2006-09-14 16:50:33 UTC (rev 4249) @@ -71,9 +71,7 @@ static inline gpg_error_t out_of_core (void) { - return gpg_error (errno - ? gpg_err_code_from_errno(errno) - : GPG_ERR_MISSING_ERRNO); + return gpg_error_from_syserror (); } /* A type to hold the ISO time. Note that this this is the same as Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/configure.ac 2006-09-14 16:50:33 UTC (rev 4249) @@ -76,7 +76,7 @@ disable_keyserver_path=no -GNUPG_BUILD_PROGRAM(gpg, no) +GNUPG_BUILD_PROGRAM(gpg, yes) GNUPG_BUILD_PROGRAM(gpgsm, yes) GNUPG_BUILD_PROGRAM(agent, yes) GNUPG_BUILD_PROGRAM(scdaemon, yes) @@ -946,12 +946,7 @@ AC_MSG_WARN([Hmmm, something is wrong with the sizes - using defaults]); fi -# -# fixme: do we really need this - it should be encapsulated in libassuan -# -GNUPG_SYS_SO_PEERCRED - # # Checks for library functions. # Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/g10/ChangeLog 2006-09-14 16:50:33 UTC (rev 4249) @@ -1,3 +1,8 @@ +2006-09-14 Werner Koch + + Replaced all call gpg_error_from_errno(errno) by + gpg_error_from_syserror(). + 2006-09-13 Werner Koch * gpg.c (main): Made --require-cross-certification the default. Modified: trunk/g10/call-agent.c =================================================================== --- trunk/g10/call-agent.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/g10/call-agent.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -104,7 +104,7 @@ if (fflush (NULL)) { - gpg_error_t tmperr = gpg_error_from_errno (errno); + gpg_error_t tmperr = gpg_error_from_syserror (); log_error ("error flushing pending output: %s\n", strerror (errno)); return tmperr; } @@ -191,7 +191,7 @@ char *optstr; if (asprintf (&optstr, "OPTION display=%s", opt.display ? opt.display : dft_display) < 0) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); rc = assuan_transact (agent_ctx, optstr, NULL, NULL, NULL, NULL, NULL, NULL); free (optstr); @@ -209,7 +209,7 @@ char *optstr; if (asprintf (&optstr, "OPTION ttyname=%s", opt.ttyname ? opt.ttyname : dft_ttyname) < 0) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); rc = assuan_transact (agent_ctx, optstr, NULL, NULL, NULL, NULL, NULL, NULL); free (optstr); @@ -222,7 +222,7 @@ char *optstr; if (asprintf (&optstr, "OPTION ttytype=%s", opt.ttyname ? opt.ttytype : dft_ttytype) < 0) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); rc = assuan_transact (agent_ctx, optstr, NULL, NULL, NULL, NULL, NULL, NULL); free (optstr); @@ -235,7 +235,7 @@ { old_lc = strdup (old_lc); if (!old_lc) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); } dft_lc = setlocale (LC_CTYPE, ""); @@ -245,7 +245,7 @@ char *optstr; if (asprintf (&optstr, "OPTION lc-ctype=%s", opt.lc_ctype ? opt.lc_ctype : dft_lc) < 0) - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); else { rc = assuan_transact (agent_ctx, optstr, NULL, NULL, NULL, NULL, NULL, @@ -268,7 +268,7 @@ { old_lc = strdup (old_lc); if (!old_lc) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); } dft_lc = setlocale (LC_MESSAGES, ""); #endif @@ -277,7 +277,7 @@ char *optstr; if (asprintf (&optstr, "OPTION lc-messages=%s", opt.lc_messages ? opt.lc_messages : dft_lc) < 0) - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); else { rc = assuan_transact (agent_ctx, optstr, NULL, NULL, NULL, NULL, NULL, Modified: trunk/g10/dearmor.c =================================================================== --- trunk/g10/dearmor.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/g10/dearmor.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -58,7 +58,7 @@ errno = EPERM; } if (!inp) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error(_("can't open `%s': %s\n"), fname? fname: "[stdin]", strerror(errno) ); goto leave; @@ -107,7 +107,7 @@ errno = EPERM; } if (!inp) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error(_("can't open `%s': %s\n"), fname? fname: "[stdin]", strerror(errno) ); goto leave; Modified: trunk/g10/decrypt.c =================================================================== --- trunk/g10/decrypt.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/g10/decrypt.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -66,7 +66,7 @@ errno = EPERM; } if( !fp ) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error (_("can't open `%s': %s\n"), print_fname_stdin(filename), gpg_strerror (rc)); return rc; Modified: trunk/g10/encode.c =================================================================== --- trunk/g10/encode.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/g10/encode.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -189,7 +189,7 @@ errno = EPERM; } if( !inp ) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error(_("can't open `%s': %s\n"), filename? filename: "[stdin]", strerror(errno) ); return rc; @@ -481,7 +481,7 @@ errno = EPERM; } if( !inp ) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error(_("can't open `%s': %s\n"), filename? filename: "[stdin]", gpg_strerror (rc) ); Modified: trunk/g10/exec.c =================================================================== --- trunk/g10/exec.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/g10/exec.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -441,7 +441,7 @@ (*info)->tochild=fdopen(to[1],binary?"wb":"w"); if((*info)->tochild==NULL) { - ret = gpg_error_from_errno (errno); + ret = gpg_error_from_syserror (); close(to[1]); goto fail; } @@ -451,7 +451,7 @@ (*info)->fromchild=iobuf_fdopen(from[0],"r"); if((*info)->fromchild==NULL) { - ret = gpg_error_from_errno (errno); + ret = gpg_error_from_syserror (); close(from[0]); goto fail; } @@ -476,7 +476,7 @@ (*info)->tochild=fopen((*info)->tempfile_in,binary?"wb":"w"); if((*info)->tochild==NULL) { - ret = gpg_error_from_errno (errno); + ret = gpg_error_from_syserror (); log_error(_("can't create `%s': %s\n"), (*info)->tempfile_in,strerror(errno)); goto fail; @@ -550,7 +550,7 @@ } if(info->fromchild==NULL) { - ret = gpg_error_from_errno (errno); + ret = gpg_error_from_syserror (); log_error(_("unable to read external program response: %s\n"), strerror(errno)); goto fail; Modified: trunk/g10/gpg.c =================================================================== --- trunk/g10/gpg.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/g10/gpg.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -1834,7 +1834,7 @@ opt.rfc2440_text=1; opt.def_sig_expire="0"; opt.def_cert_expire="0"; - opt.require_cross_cert = 1; + opt.flags.require_cross_cert = 1; set_homedir ( default_homedir () ); /* Check whether we have a config file on the command line. */ Modified: trunk/g10/keydb.c =================================================================== --- trunk/g10/keydb.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/g10/keydb.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -112,7 +112,7 @@ } if (access (filename, F_OK)) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); *last_slash_in_filename = DIRSEP_C; goto leave; } @@ -166,7 +166,7 @@ umask (oldmask); if (!iobuf) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error ( _("error creating keyring `%s': %s\n"), filename, strerror(errno)); goto leave; Modified: trunk/g10/keygen.c =================================================================== --- trunk/g10/keygen.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/g10/keygen.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -3732,7 +3732,7 @@ umask (oldmask); if (!fp) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error (_("can't create backup file `%s': %s\n"), fname, strerror(errno) ); xfree (fname); Modified: trunk/g10/keyring.c =================================================================== --- trunk/g10/keyring.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/g10/keyring.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -661,7 +661,7 @@ hd->current.iobuf = iobuf_open (hd->current.kr->fname); if (!hd->current.iobuf) { - hd->current.error = gpg_error_from_errno (errno); + hd->current.error = gpg_error_from_syserror (); log_error(_("can't open `%s'\n"), hd->current.kr->fname ); return hd->current.error; } @@ -1200,7 +1200,7 @@ umask(oldmask); if (!*r_fp) { - int rc = gpg_error_from_errno (errno); + int rc = gpg_error_from_syserror (); log_error(_("can't create `%s': %s\n"), tmpfname, strerror(errno) ); xfree (tmpfname); xfree (bakfname); @@ -1232,7 +1232,7 @@ #endif if (rename (fname, bakfname) ) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error ("renaming `%s' to `%s' failed: %s\n", fname, bakfname, strerror(errno) ); return rc; @@ -1247,7 +1247,7 @@ unregister_secured_file (fname); if (rename (tmpfname, fname) ) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error (_("renaming `%s' to `%s' failed: %s\n"), tmpfname, fname, strerror(errno) ); register_secured_file (fname); @@ -1317,7 +1317,7 @@ iobuf_put (fp, 0); /* unused */ if (iobuf_put (fp, cacheval)) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error ("writing sigcache packet failed\n"); return rc; } @@ -1362,7 +1362,7 @@ { if (iobuf_close (tmpfp)) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error ("error closing `%s': %s\n", tmpfilename, strerror (errno)); goto leave; @@ -1442,7 +1442,7 @@ { if (iobuf_close (tmpfp)) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error ("error closing `%s': %s\n", tmpfilename, strerror (errno)); goto leave; @@ -1486,7 +1486,7 @@ /* Open the source file. Because we do a rename, we have to check the permissions of the file */ if (access (fname, W_OK)) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); fp = iobuf_open (fname); if (mode == 1 && !fp && errno == ENOENT) { @@ -1504,7 +1504,7 @@ umask(oldmask); if( !newfp ) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error (_("can't create `%s': %s\n"), fname, strerror(errno)); return rc; } @@ -1521,7 +1521,7 @@ } } if( iobuf_close(newfp) ) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error ("%s: close failed: %s\n", fname, strerror(errno)); return rc; } @@ -1530,7 +1530,7 @@ if( !fp ) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error(_("can't open `%s': %s\n"), fname, strerror(errno) ); goto leave; } @@ -1613,12 +1613,12 @@ /* close both files */ if( iobuf_close(fp) ) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error("%s: close failed: %s\n", fname, strerror(errno) ); goto leave; } if( iobuf_close(newfp) ) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error("%s: close failed: %s\n", tmpfname, strerror(errno) ); goto leave; } Modified: trunk/g10/keyserver.c =================================================================== --- trunk/g10/keyserver.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/g10/keyserver.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -1406,7 +1406,7 @@ maxlen=1024; if(iobuf_read_line(spawn->fromchild,&line,&buflen,&maxlen)==0) { - ret = gpg_error_from_errno (errno); + ret = gpg_error_from_syserror (); goto fail; /* i.e. EOF */ } Modified: trunk/g10/openfile.c =================================================================== --- trunk/g10/openfile.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/g10/openfile.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -184,7 +184,7 @@ if( iobuf_is_pipe_filename (iname) && !opt.outfile ) { *a = iobuf_create(NULL); if( !*a ) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error(_("can't open `%s': %s\n"), "[stdout]", strerror(errno) ); } else if( opt.verbose ) @@ -261,7 +261,7 @@ *a = iobuf_create( name ); if( !*a ) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error(_("can't create `%s': %s\n"), name, strerror(errno) ); } else if( opt.verbose ) Modified: trunk/g10/plaintext.c =================================================================== --- trunk/g10/plaintext.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/g10/plaintext.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -132,12 +132,12 @@ else if (is_secured_filename (fname)) { errno = EPERM; - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error(_("error creating `%s': %s\n"), fname, strerror(errno) ); goto leave; } else if( !(fp = fopen(fname,"wb")) ) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error(_("error creating `%s': %s\n"), fname, strerror(errno) ); goto leave; } @@ -187,7 +187,7 @@ if( convert ) { /* text mode */ for( ; pt->len; pt->len-- ) { if( (c = iobuf_get(pt->buf)) == -1 ) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error ("problem reading source (%u bytes remaining)\n", (unsigned)pt->len); goto leave; @@ -210,7 +210,7 @@ else if( putc( c, fp ) == EOF ) { if (ferror (fp)) - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); else rc = gpg_error (GPG_ERR_EOF); log_error ("error writing to `%s': %s\n", @@ -226,7 +226,7 @@ int len = pt->len > 32768 ? 32768 : pt->len; len = iobuf_read( pt->buf, buffer, len ); if( len == -1 ) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error ("problem reading source (%u bytes remaining)\n", (unsigned)pt->len); xfree( buffer ); @@ -246,7 +246,7 @@ } else if( fwrite( buffer, 1, len, fp ) != len ) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error ("error writing to `%s': %s\n", fname, strerror(errno) ); xfree( buffer ); @@ -279,7 +279,7 @@ else if( putc( c, fp ) == EOF ) { if ( ferror (fp ) ) - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); else rc = gpg_error (GPG_ERR_EOF); log_error("error writing to `%s': %s\n", @@ -317,7 +317,7 @@ goto leave; } else if( fwrite( buffer, 1, len, fp ) != len ) { - rc = (errno? gpg_error_from_errno (errno) + rc = (errno? gpg_error_from_syserror () : gpg_error (GPG_ERR_INTERNAL)); log_error ("error writing to `%s': %s\n", fname, strerror(errno) ); @@ -345,7 +345,7 @@ } else if( putc( c, fp ) == EOF ) { - rc = (errno? gpg_error_from_errno (errno) + rc = (errno? gpg_error_from_syserror () : gpg_error (GPG_ERR_INTERNAL)); log_error ("error writing to `%s': %s\n", fname, strerror(errno) ); @@ -385,7 +385,7 @@ } if( fp && fp != stdout && fclose(fp) ) { - rc = (errno? gpg_error_from_errno (errno) + rc = (errno? gpg_error_from_syserror () : gpg_error (GPG_ERR_INTERNAL)); log_error ("error closing `%s': %s\n", fname, strerror(errno) ); fp = NULL; @@ -487,7 +487,7 @@ } else if( !fp ) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error(_("can't open `%s': %s\n"), answer, strerror(errno)); goto leave; } @@ -544,7 +544,7 @@ errno = EPERM; } if( !fp ) { - int rc = gpg_error_from_errno (errno); + int rc = gpg_error_from_syserror (); log_error(_("can't open signed data `%s'\n"), print_fname_stdin(sl->d)); return rc; Modified: trunk/g10/sign.c =================================================================== --- trunk/g10/sign.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/g10/sign.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -808,7 +808,7 @@ } if( !inp ) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error (_("can't open `%s': %s\n"), fname? fname: "[stdin]", strerror(errno) ); goto leave; @@ -826,7 +826,7 @@ out = iobuf_create( outfile ); if( !out ) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error(_("can't create `%s': %s\n"), outfile, strerror(errno) ); goto leave; } @@ -1003,7 +1003,7 @@ } if( !inp ) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error(_("can't open `%s': %s\n"), sl->d,strerror(errno)); goto leave; @@ -1116,7 +1116,7 @@ errno = EPERM; } if( !inp ) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error (_("can't open `%s': %s\n"), fname? fname: "[stdin]", strerror(errno) ); goto leave; @@ -1132,7 +1132,7 @@ out = iobuf_create( outfile ); if( !out ) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error(_("can't create `%s': %s\n"), outfile, strerror(errno) ); goto leave; } @@ -1268,7 +1268,7 @@ errno = EPERM; } if( !inp ) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error (_("can't open `%s': %s\n"), fname? fname: "[stdin]", strerror(errno) ); goto leave; Modified: trunk/g10/tdbio.c =================================================================== --- trunk/g10/tdbio.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/g10/tdbio.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -126,14 +126,14 @@ int n; if( lseek( db_fd, r->recno * TRUST_RECORD_LEN, SEEK_SET ) == -1 ) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); log_error(_("trustdb rec %lu: lseek failed: %s\n"), r->recno, strerror(errno) ); return err; } n = write( db_fd, r->data, TRUST_RECORD_LEN); if( n != TRUST_RECORD_LEN ) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); log_error(_("trustdb rec %lu: write failed (n=%d): %s\n"), r->recno, n, strerror(errno) ); return err; @@ -1162,7 +1162,7 @@ buf = get_record_from_cache( recnum ); if( !buf ) { if( lseek( db_fd, recnum * TRUST_RECORD_LEN, SEEK_SET ) == -1 ) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); log_error(_("trustdb: lseek failed: %s\n"), strerror(errno) ); return err; } @@ -1171,7 +1171,7 @@ return -1; /* eof */ } else if( n != TRUST_RECORD_LEN ) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); log_error(_("trustdb: read failed (n=%d): %s\n"), n, strerror(errno) ); return err; @@ -1435,14 +1435,14 @@ rec.recnum = recnum; rc = 0; if( lseek( db_fd, recnum * TRUST_RECORD_LEN, SEEK_SET ) == -1 ) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error(_("trustdb rec %lu: lseek failed: %s\n"), recnum, strerror(errno) ); } else { int n = write( db_fd, &rec, TRUST_RECORD_LEN); if( n != TRUST_RECORD_LEN ) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error(_("trustdb rec %lu: write failed (n=%d): %s\n"), recnum, n, strerror(errno) ); } Modified: trunk/g10/verify.c =================================================================== --- trunk/g10/verify.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/g10/verify.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -98,7 +98,7 @@ errno = EPERM; } if( !fp ) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error(_("can't open `%s': %s\n"), print_fname_stdin(sigfile), strerror (errno)); return rc; @@ -154,7 +154,7 @@ errno = EPERM; } if( !fp ) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error(_("can't open `%s': %s\n"), print_fname_stdin(name), strerror (errno)); print_file_status( STATUS_FILE_ERROR, name, 1 ); Modified: trunk/kbx/ChangeLog =================================================================== --- trunk/kbx/ChangeLog 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/kbx/ChangeLog 2006-09-14 16:50:33 UTC (rev 4249) @@ -1,3 +1,8 @@ +2006-09-14 Werner Koch + + Replaced all call gpg_error_from_errno(errno) by + gpg_error_from_syserror(). + 2005-10-08 Marcus Brinkmann * Makefile.am (kbxutil_LDADD): Add ../gl/libgnu.a after Modified: trunk/kbx/keybox-openpgp.c =================================================================== --- trunk/kbx/keybox-openpgp.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/kbx/keybox-openpgp.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -405,7 +405,7 @@ u = xtrycalloc (1, sizeof *u); if (!u) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); break; } u->off = data - image_start; @@ -447,7 +447,7 @@ k = xtrycalloc (1, sizeof *k); if (!k) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); break; } err = parse_key (data, datalen, k); Modified: trunk/scd/ChangeLog =================================================================== --- trunk/scd/ChangeLog 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/scd/ChangeLog 2006-09-14 16:50:33 UTC (rev 4249) @@ -1,3 +1,11 @@ +2006-09-14 Werner Koch + + Replaced all call gpg_error_from_errno(errno) by + gpg_error_from_syserror(). + + * command.c (scd_command_handler): Replaced + init_connected_socket_server by init_socket_server_ext. + 2006-09-07 Werner Koch * command.c (update_reader_status_file): Execute an event handler Modified: trunk/scd/app-openpgp.c =================================================================== --- trunk/scd/app-openpgp.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/scd/app-openpgp.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -566,7 +566,7 @@ n = 6 + 2 + mlen + 2 + elen; p = buffer = xtrymalloc (3 + n); if (!buffer) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); *p++ = 0x99; /* ctb */ *p++ = n >> 8; /* 2 byte length header */ @@ -880,7 +880,7 @@ break; /* EOF. */ if (i < 0) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto leave; /* Error. */ } if (!max_length) @@ -1036,7 +1036,7 @@ mbuf = xtrymalloc ( mlen + 1); if (!mbuf) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto leave; } *mbuf = 0; @@ -1049,7 +1049,7 @@ ebuf = xtrymalloc ( elen + 1); if (!ebuf) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto leave; } *ebuf = 0; @@ -1091,7 +1091,7 @@ fpr); if (ret < 0) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto leave; } @@ -1099,7 +1099,7 @@ free (command); if (!fp) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); log_error ("running gpg failed: %s\n", gpg_strerror (err)); goto leave; } @@ -1120,7 +1120,7 @@ keybuf = xtrymalloc (50 + 2*35 + mlen + elen + 1); if (!keybuf) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto leave; } @@ -1260,7 +1260,7 @@ *pk = xtrymalloc (*pklen); if (!*pk) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); *pklen = 0; return err; } @@ -1819,7 +1819,7 @@ template = tp = xtrymalloc_secure (template_len); if (!template) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto leave; } *tp++ = 0xC0; @@ -2185,7 +2185,7 @@ prompt = malloc (strlen (PROMPTSTRING) + 50); if (!prompt) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); sprintf (prompt, PROMPTSTRING, sigcount); rc = pincb (pincb_arg, prompt, &pinvalue); free (prompt); Modified: trunk/scd/app-p15.c =================================================================== --- trunk/scd/app-p15.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/scd/app-p15.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -520,7 +520,7 @@ objidlen /= 2; objid = xtrymalloc (objidlen); if (!objid) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); for (s=certid, i=0; i < objidlen; i++, s+=2) objid[i] = xtoi_2 (s); *r_objid = objid; @@ -1130,14 +1130,14 @@ + objlen/2 * sizeof(unsigned short))); if (!prkdf) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto leave; } prkdf->objidlen = objidlen; prkdf->objid = xtrymalloc (objidlen); if (!prkdf->objid) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); xfree (prkdf); goto leave; } @@ -1148,7 +1148,7 @@ prkdf->authid = xtrymalloc (authidlen); if (!prkdf->authid) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); xfree (prkdf->objid); xfree (prkdf); goto leave; @@ -1416,14 +1416,14 @@ + objlen/2 * sizeof(unsigned short))); if (!cdf) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto leave; } cdf->objidlen = objidlen; cdf->objid = xtrymalloc (objidlen); if (!cdf->objid) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); xfree (cdf); goto leave; } @@ -2135,7 +2135,7 @@ continue; /* Ready. */ no_core: - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); release_aodf_object (aodf); goto leave; @@ -2272,7 +2272,7 @@ app->app_local->serialno = xtrymalloc (objlen); if (!app->app_local->serialno) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto leave; } memcpy (app->app_local->serialno, p, objlen); @@ -2368,7 +2368,7 @@ buf = xtrymalloc (9 + certinfo->objidlen*2 + 1); if (!buf) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); p = stpcpy (buf, "P15"); if (app->app_local->home_df) { @@ -2463,7 +2463,7 @@ buf = xtrymalloc (9 + keyinfo->objidlen*2 + 1); if (!buf) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); p = stpcpy (buf, "P15"); if (app->app_local->home_df) { @@ -2544,7 +2544,7 @@ { *r_cert = xtrymalloc (cdf->imagelen); if (!*r_cert) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); memcpy (*r_cert, cdf->image, cdf->imagelen); *r_certlen = cdf->imagelen; return 0; @@ -2687,7 +2687,7 @@ { buf = xtrymalloc (9 + prkdf->objidlen*2 + 1); if (!buf) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); p = stpcpy (buf, "P15"); if (app->app_local->home_df) { @@ -3059,7 +3059,7 @@ paddedpin = xtrymalloc (aodf->stored_length+1); if (!paddedpin) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); xfree (pinvalue); return err; } @@ -3087,7 +3087,7 @@ paddedpin = xtrymalloc (aodf->stored_length+1); if (!paddedpin) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); xfree (pinvalue); return err; } @@ -3345,7 +3345,7 @@ app->app_local = xtrycalloc (1, sizeof *app->app_local); if (!app->app_local) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); goto leave; } Modified: trunk/scd/app.c =================================================================== --- trunk/scd/app.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/scd/app.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -69,7 +69,7 @@ { if (!pth_mutex_init (&lock_table[slot].lock)) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); log_error ("error initializing mutex: %s\n", strerror (errno)); return err; } @@ -80,7 +80,7 @@ if (!pth_mutex_acquire (&lock_table[slot].lock, 0, NULL)) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); log_error ("failed to acquire APP lock for slot %d: %s\n", slot, strerror (errno)); return err; @@ -278,7 +278,7 @@ app = xtrycalloc (1, sizeof *app); if (!app) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); log_info ("error allocating context: %s\n", gpg_strerror (err)); unlock_reader (slot); return err; @@ -480,7 +480,7 @@ buf = xtrymalloc (app->serialnolen * 2 + 1); if (!buf) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); for (p=buf, i=0; i < app->serialnolen; p +=2, i++) sprintf (p, "%02X", app->serialno[i]); *p = 0; Modified: trunk/scd/command.c =================================================================== --- trunk/scd/command.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/scd/command.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -1504,7 +1504,7 @@ apdu = hex_to_buffer (line, &apdulen); if (!apdu) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); goto leave; } if (apdulen) @@ -1603,7 +1603,7 @@ } else { - rc = assuan_init_connected_socket_server (&ctx, fd); + rc = assuan_init_socket_server_ext (&ctx, fd, 2); } if (rc) { Modified: trunk/scd/iso7816.c =================================================================== --- trunk/scd/iso7816.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/scd/iso7816.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -677,7 +677,7 @@ unsigned char *p = xtryrealloc (*result, *resultlen + bufferlen); if (!p) { - gpg_error_t err = gpg_error_from_errno (errno); + gpg_error_t err = gpg_error_from_syserror (); xfree (buffer); xfree (*result); *result = NULL; Modified: trunk/sm/ChangeLog =================================================================== --- trunk/sm/ChangeLog 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/sm/ChangeLog 2006-09-14 16:50:33 UTC (rev 4249) @@ -1,3 +1,8 @@ +2006-09-14 Werner Koch + + Replaced all call gpg_error_from_errno(errno) by + gpg_error_from_syserror(). + 2006-09-13 Werner Koch * keylist.c (list_internal_keys): Print marker line to FP and not Modified: trunk/sm/base64.c =================================================================== --- trunk/sm/base64.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/sm/base64.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -451,7 +451,7 @@ parm->base64.idx = idx; parm->base64.quad_count = quad_count; - return ferror (fp) ? gpg_error_from_errno (errno) : 0; + return ferror (fp) ? gpg_error_from_syserror () : 0; } static int Modified: trunk/sm/certchain.c =================================================================== --- trunk/sm/certchain.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/sm/certchain.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -351,7 +351,7 @@ pattern = xtrymalloc (strlen (s)+2); if (!pattern) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); strcpy (stpcpy (pattern, "/"), s); add_to_strlist (&names, pattern); xfree (pattern); Modified: trunk/sm/export.c =================================================================== --- trunk/sm/export.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/sm/export.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -117,7 +117,7 @@ /* Insert that fingerprint. */ t = xtrymalloc (sizeof *t); if (!t) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); memcpy (t->fpr, fpr+1, 19); t->next = table[idx]; table[idx] = t; @@ -558,14 +558,14 @@ infp = tmpfile (); if (!infp) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); log_error (_("error creating temporary file: %s\n"), strerror (errno)); goto cleanup; } if (fwrite (certimg, certimglen, 1, infp) != 1) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); log_error (_("error writing to temporary file: %s\n"), strerror (errno)); goto cleanup; @@ -574,7 +574,7 @@ outfp = tmpfile (); if (!outfp) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); log_error (_("error creating temporary file: %s\n"), strerror (errno)); goto cleanup; } Modified: trunk/sm/import.c =================================================================== --- trunk/sm/import.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/sm/import.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -521,7 +521,7 @@ tmpfp = tmpfile (); if (!tmpfp) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); log_error (_("error creating temporary file: %s\n"), strerror (errno)); goto cleanup; } @@ -529,7 +529,7 @@ { if (nread && fwrite (buffer, nread, 1, tmpfp) != 1) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); log_error (_("error writing to temporary file: %s\n"), strerror (errno)); goto cleanup; @@ -546,7 +546,7 @@ certfp = tmpfile (); if (!certfp) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); log_error (_("error creating temporary file: %s\n"), strerror (errno)); goto cleanup; } Modified: trunk/sm/keylist.c =================================================================== --- trunk/sm/keylist.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/sm/keylist.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -1164,7 +1164,7 @@ desc = xtrycalloc (ndesc, sizeof *desc); if (!ndesc) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); log_error ("out of core\n"); goto leave; } Modified: trunk/sm/qualified.c =================================================================== --- trunk/sm/qualified.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/sm/qualified.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -70,7 +70,7 @@ listfp = fopen (listname, "r"); if (!listfp && errno != ENOENT) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); log_error (_("can't open `%s': %s\n"), listname, gpg_strerror (err)); return err; } @@ -85,7 +85,7 @@ { if (feof (listfp)) return gpg_error (GPG_ERR_EOF); - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); } if (!*line || line[strlen(line)-1] != '\n') @@ -234,7 +234,7 @@ "to create or verify such signatures.\n"), opt.qualsig_approval? "":"\n" ) < 0 ) - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); else err = 0; @@ -251,7 +251,7 @@ buffer = p = xtrymalloc (strlen (name) * 3 + 1); if (!buffer) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); free (name); return err; } @@ -324,7 +324,7 @@ "Note, that this certificate will NOT create a " "qualified signature!"), subject? subject:"?") < 0 ) - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); else err = 0; @@ -341,7 +341,7 @@ buffer = p = xtrymalloc (strlen (name) * 3 + 1); if (!buffer) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); free (name); return err; } Modified: trunk/tools/ChangeLog =================================================================== --- trunk/tools/ChangeLog 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/tools/ChangeLog 2006-09-14 16:50:33 UTC (rev 4249) @@ -1,5 +1,8 @@ 2006-09-12 Werner Koch + Replaced all call gpg_error_from_errno(errno) by + gpg_error_from_syserror(). + * gpg-connect-agent.c (read_and_print_response): With verbosity level 2 also print comment lines. Modified: trunk/tools/gpgkey2ssh.c =================================================================== --- trunk/tools/gpgkey2ssh.c 2006-09-13 15:57:30 UTC (rev 4248) +++ trunk/tools/gpgkey2ssh.c 2006-09-14 16:50:33 UTC (rev 4249) @@ -85,7 +85,7 @@ break; /* EOF. */ if (i < 0) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto leave; /* Error. */ } if (!max_length) From cvs at cvs.gnupg.org Fri Sep 15 20:53:38 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri Sep 15 20:08:36 2006 Subject: [svn] GnuPG - r4250 - in trunk: . agent common doc doc/examples scd Message-ID: Author: wk Date: 2006-09-15 20:53:37 +0200 (Fri, 15 Sep 2006) New Revision: 4250 Added: trunk/common/convert.c trunk/common/t-convert.c trunk/doc/examples/README trunk/doc/examples/trustlist.txt Modified: trunk/NEWS trunk/agent/ChangeLog trunk/agent/agent.h trunk/agent/command.c trunk/agent/gpg-agent.c trunk/agent/trustlist.c trunk/autogen.sh trunk/common/ChangeLog trunk/common/Makefile.am trunk/common/util.h trunk/doc/Makefile.am trunk/doc/gpg-agent.texi trunk/scd/ChangeLog Log: Allow for a global trustlist. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-09-14 16:50:33 UTC (rev 4249) +++ trunk/NEWS 2006-09-15 18:53:37 UTC (rev 4250) @@ -26,7 +26,9 @@ * gpg-connect-agent has new options to utilize descriptor passing. + * A global trustlist may now be used. See doc/examples/trustlist.txt. + Noteworthy changes in version 1.9.22 (2006-07-27) ------------------------------------------------- Modified: trunk/agent/ChangeLog =================================================================== --- trunk/agent/ChangeLog 2006-09-14 16:50:33 UTC (rev 4249) +++ trunk/agent/ChangeLog 2006-09-15 18:53:37 UTC (rev 4250) @@ -1,3 +1,8 @@ +2006-09-15 Werner Koch + + * trustlist.c: Entirely rewritten. + (agent_trustlist_housekeeping): Removed and removed all calls. + 2006-09-14 Werner Koch Replaced all call gpg_error_from_errno(errno) by Modified: trunk/agent/agent.h =================================================================== --- trunk/agent/agent.h 2006-09-14 16:50:33 UTC (rev 4249) +++ trunk/agent/agent.h 2006-09-15 18:53:37 UTC (rev 4250) @@ -252,11 +252,10 @@ /*-- trustlist.c --*/ -int agent_istrusted (const char *fpr); -int agent_listtrusted (void *assuan_context); -int agent_marktrusted (ctrl_t ctrl, const char *name, - const char *fpr, int flag); -void agent_trustlist_housekeeping (void); +gpg_error_t agent_istrusted (const char *fpr); +gpg_error_t agent_listtrusted (void *assuan_context); +gpg_error_t agent_marktrusted (ctrl_t ctrl, const char *name, + const char *fpr, int flag); void agent_reload_trustlist (void); Modified: trunk/agent/command.c =================================================================== --- trunk/agent/command.c 2006-09-14 16:50:33 UTC (rev 4249) +++ trunk/agent/command.c 2006-09-15 18:53:37 UTC (rev 4250) @@ -153,7 +153,7 @@ static size_t percent_plus_unescape (char *string) { - unsigned char *p = string; + unsigned char *p = (unsigned char *)string; size_t n = 0; while (*string) @@ -240,7 +240,7 @@ char *p; char fpr[41]; - /* parse the fingerprint value */ + /* Parse the fingerprint value. */ for (p=line,n=0; hexdigitp (p); p++, n++) ; if (*p || !(n == 40 || n == 32)) Modified: trunk/agent/gpg-agent.c =================================================================== --- trunk/agent/gpg-agent.c 2006-09-14 16:50:33 UTC (rev 4249) +++ trunk/agent/gpg-agent.c 2006-09-15 18:53:37 UTC (rev 4250) @@ -1427,11 +1427,6 @@ log_info (_("handler 0x%lx for fd %d started\n"), (long)pth_self (), fd); - /* FIXME: Move this housekeeping into a ticker function. Calling it - for each connection should work but won't work anymore if our - clients start to keep connections. */ - agent_trustlist_housekeeping (); - start_command_handler (-1, fd); if (opt.verbose) log_info (_("handler 0x%lx for fd %d terminated\n"), @@ -1451,8 +1446,6 @@ log_info (_("ssh handler 0x%lx for fd %d started\n"), (long)pth_self (), fd); - agent_trustlist_housekeeping (); - start_command_handler_ssh (fd); if (opt.verbose) log_info (_("ssh handler 0x%lx for fd %d terminated\n"), Modified: trunk/agent/trustlist.c =================================================================== --- trunk/agent/trustlist.c 2006-09-14 16:50:33 UTC (rev 4249) +++ trunk/agent/trustlist.c 2006-09-15 18:53:37 UTC (rev 4250) @@ -1,5 +1,5 @@ /* trustlist.c - Maintain the list of trusted keys - * Copyright (C) 2002, 2004 Free Software Foundation, Inc. + * Copyright (C) 2002, 2004, 2006 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -28,213 +28,347 @@ #include #include #include +#include #include "agent.h" #include /* fixme: need a way to avoid assuan calls here */ #include "i18n.h" -static const char headerblurb[] = -"# This is the list of trusted keys. Comment lines, like this one, as\n" -"# well as empty lines are ignored. The entire file may be integrity\n" -"# protected by the use of a MAC, so changing the file does not make\n" -"# sense without the knowledge of the MAC key. Lines do have a length\n" -"# limit but this is not serious limitation as the format of the\n" -"# entries is fixed and checked by gpg-agent: A non-comment line starts\n" -"# with optional white spaces, followed by the SHA-1 fingerpint in hex,\n" -"# optionally followed by a flag character which my either be 'P', 'S'\n" -"# or '*'. Additional data, delimited by white space, is ignored.\n" -"#\n" -"# NOTE: You should give the gpg-agent a HUP after editing this file.\n" -"\n"; +/* A structure to store the information from the trust file. */ +struct trustitem_s +{ + int keyflag; /* The keyflag: '*', 'P' or 'S'. */ + unsigned char fpr[20]; /* The binary fingerprint. */ +}; +typedef struct trustitem_s trustitem_t; -static FILE *trustfp; -static int trustfp_used; /* Counter to track usage of TRUSTFP. */ -static int reload_trustlist_pending; +/* Malloced table and its allocated size with all trust items. */ +static trustitem_t *trusttable; +static size_t trusttablesize; +/* A mutex used to protect the table. */ +static pth_mutex_t trusttable_lock = PTH_MUTEX_INIT; -static int -open_list (int append) -{ - char *fname; - fname = make_filename (opt.homedir, "trustlist.txt", NULL); - trustfp = fopen (fname, append? "a+":"r"); - if (!trustfp && errno == ENOENT) - { - trustfp = fopen (fname, "wx"); - if (!trustfp) - { - gpg_error_t tmperr = gpg_error (gpg_err_code_from_errno (errno)); - log_error ("can't create `%s': %s\n", fname, strerror (errno)); - xfree (fname); - return tmperr; - } - fputs (headerblurb, trustfp); - fclose (trustfp); - trustfp = fopen (fname, append? "a+":"r"); - } +static const char headerblurb[] = +"# This is the list of trusted keys. Comment lines, like this one, as\n" +"# well as empty lines are ignored. Lines have a length limit but this\n" +"# is not serious limitation as the format of the entries is fixed and\n" +"# checked by gpg-agent. A non-comment line starts with optional white\n" +"# space, followed by the SHA-1 fingerpint in hex, optionally followed\n" +"# by a flag character which my either be 'P', 'S' or '*'. You should\n" +"# give the gpg-agent a HUP after editing this file.\n" +"\n\n" +"# Include the default trust list\n" +"include-default\n" +"\n"; - if (!trustfp) - { - gpg_error_t tmperr = gpg_error (gpg_err_code_from_errno (errno)); - log_error ("can't open `%s': %s\n", fname, strerror (errno)); - xfree (fname); - return tmperr; - } - /*FIXME: check the MAC */ - return 0; + +static void +lock_trusttable (void) +{ + if (!pth_mutex_acquire (&trusttable_lock, 0, NULL)) + log_fatal ("failed to acquire mutex in %s\n", __FILE__); } +static void +unlock_trusttable (void) +{ + if (!pth_mutex_release (&trusttable_lock)) + log_fatal ("failed to release mutex in %s\n", __FILE__); +} -/* Read the trustlist and return entry by entry. KEY must point to a - buffer of at least 41 characters. KEYFLAG does return either 'P', - 'S' or '*'. - Reading a valid entry returns 0, EOF returns -1 any other error - returns the appropriate error code. */ -static int -read_list (char *key, int *keyflag) +static gpg_error_t +read_one_trustfile (const char *fname, int allow_include, + trustitem_t **addr_of_table, + size_t *addr_of_tablesize, + int *addr_of_tableidx) { - int rc; - int c, i, j; + gpg_error_t err = 0; + FILE *fp; + int n, c; char *p, line[256]; - - if (!trustfp) + trustitem_t *table, *ti; + int tableidx; + size_t tablesize; + int lnr = 0; + + table = *addr_of_table; + tablesize = *addr_of_tablesize; + tableidx = *addr_of_tableidx; + + fp = fopen (fname, "r"); + if (!fp) { - rc = open_list (0); - if (rc) - return rc; + err = gpg_error_from_syserror (); + log_error (_("error opening `%s': %s\n"), fname, gpg_strerror (err)); + goto leave; } - do + while (fgets (line, DIM(line)-1, fp)) { - if (!fgets (line, DIM(line)-1, trustfp) ) - { - if (feof (trustfp)) - return -1; - return gpg_error (gpg_err_code_from_errno (errno)); - } + lnr++; if (!*line || line[strlen(line)-1] != '\n') { - /* eat until end of line */ - while ( (c=getc (trustfp)) != EOF && c != '\n') + /* Eat until end of line. */ + while ( (c=getc (fp)) != EOF && c != '\n') ; - return gpg_error (*line? GPG_ERR_LINE_TOO_LONG - : GPG_ERR_INCOMPLETE_LINE); + err = gpg_error (*line? GPG_ERR_LINE_TOO_LONG + : GPG_ERR_INCOMPLETE_LINE); + log_error (_("file `%s', line %d: %s\n"), + fname, lnr, gpg_strerror (err)); + continue; } + line[strlen(line)-1] = 0; /* Chop the LF. */ /* Allow for empty lines and spaces */ for (p=line; spacep (p); p++) ; + if (!*p || *p == '#') + continue; + + if (!strncmp (p, "include-default", 15) + && (!p[15] || spacep (p+15))) + { + char *etcname; + gpg_error_t err2; + + if (!allow_include) + { + log_error (_("statement \"%s\" ignored in `%s', line %d\n"), + "include-default", fname, lnr); + continue; + } + /* fixme: Should check for trailing garbage. */ + + etcname = make_filename (GNUPG_SYSCONFDIR, "trustlist.txt", NULL); + if ( !strcmp (etcname, fname) ) /* Same file. */ + log_info (_("statement \"%s\" ignored in `%s', line %d\n"), + "include-default", fname, lnr); + else if ( access (etcname, F_OK) && errno == ENOENT ) + { + /* A non existent system trustlist is not an error. + Just print a note. */ + log_info (_("system trustlist `%s' not available\n"), etcname); + } + else + { + err2 = read_one_trustfile (etcname, 0, + &table, &tablesize, &tableidx); + if (err2) + err = err2; + } + xfree (etcname); + + continue; + } + + if (tableidx == tablesize) /* Need more space. */ + { + trustitem_t *tmp; + size_t tmplen; + + tmplen = tablesize + 20; + tmp = xtryrealloc (table, tmplen * sizeof *table); + if (!tmp) + { + err = gpg_error_from_syserror (); + goto leave; + } + table = tmp; + tablesize = tmplen; + } + + ti = table + tableidx; + + n = hexcolon2bin (p, ti->fpr, 20); + if (n < 0) + { + log_error (_("bad fingerprint in `%s', line %d\n"), fname, lnr); + err = gpg_error (GPG_ERR_BAD_DATA); + continue; + } + p += n; + for (; spacep (p); p++) + ; + + if (!*p) + ti->keyflag = '*'; + else if ( *p == 'P' || *p == 'p') + ti->keyflag = 'P'; + else if ( *p == 'S' || *p == 's') + ti->keyflag = 'S'; + else if ( *p == '*') + ti->keyflag = '*'; + else + { + log_error (_("invalid keyflag in `%s', line %d\n"), fname, lnr); + err = gpg_error (GPG_ERR_BAD_DATA); + continue; + } + p++; + if ( *p && !spacep (p) ) + { + log_error (_("invalid keyflag in `%s', line %d\n"), fname, lnr); + err = gpg_error (GPG_ERR_BAD_DATA); + continue; + } + /* Fixme: need to check for trailing garbage. */ + tableidx++; } - while (!*p || *p == '\n' || *p == '#'); - - for (i=j=0; (p[i] == ':' || hexdigitp (p+i)) && j < 40; i++) - if ( p[i] != ':' ) - key[j++] = p[i] >= 'a'? (p[i] & 0xdf): p[i]; - key[j] = 0; - if (j!=40 || !(spacep (p+i) || p[i] == '\n')) + if ( !err && !feof (fp) ) { - log_error ("invalid formatted fingerprint in trustlist\n"); - return gpg_error (GPG_ERR_BAD_DATA); + err = gpg_error_from_syserror (); + log_error (_("error reading `%s', line %d: %s\n"), + fname, lnr, gpg_strerror (err)); } - assert (p[i]); - if (p[i] == '\n') - *keyflag = '*'; - else + + leave: + if (fp) + fclose (fp); + *addr_of_table = table; + *addr_of_tablesize = tablesize; + *addr_of_tableidx = tableidx; + return err; +} + + +/* Read the trust files and update the global table on success. */ +static gpg_error_t +read_trustfiles (void) +{ + gpg_error_t err; + trustitem_t *table, *ti; + int tableidx; + size_t tablesize; + char *fname; + int allow_include = 1; + + tablesize = 10; + table = xtrycalloc (tablesize, sizeof *table); + if (!table) + return gpg_error_from_syserror (); + tableidx = 0; + + fname = make_filename (opt.homedir, "trustlist.txt", NULL); + if ( access (fname, F_OK) ) { - i++; - if ( p[i] == 'P' || p[i] == 'p') - *keyflag = 'P'; - else if ( p[i] == 'S' || p[i] == 's') - *keyflag = 'S'; - else if ( p[i] == '*') - *keyflag = '*'; + if ( errno == ENOENT ) + ; /* Silently ignore a non-existing trustfile. */ else { - log_error ("invalid keyflag in trustlist\n"); - return gpg_error (GPG_ERR_BAD_DATA); + err = gpg_error_from_syserror (); + log_error (_("error opening `%s': %s\n"), fname, gpg_strerror (err)); } - i++; - if ( !(spacep (p+i) || p[i] == '\n')) - { - log_error ("invalid keyflag in trustlist\n"); - return gpg_error (GPG_ERR_BAD_DATA); - } + xfree (fname); + fname = make_filename (GNUPG_SYSCONFDIR, "trustlist.txt", NULL); + allow_include = 0; } + err = read_one_trustfile (fname, allow_include, + &table, &tablesize, &tableidx); + xfree (fname); + if (err) + { + xfree (table); + return err; + } + + /* Fixme: we should drop duplicates and sort the table. */ + + ti = xtryrealloc (table, tableidx * sizeof *table); + if (!ti) + { + xfree (table); + return err; + } + + lock_trusttable (); + xfree (trusttable); + trusttable = table; + trusttablesize = tableidx; + unlock_trusttable (); return 0; } + + /* Check whether the given fpr is in our trustdb. We expect FPR to be an all uppercase hexstring of 40 characters. */ -int +gpg_error_t agent_istrusted (const char *fpr) { - int rc; - static char key[41]; - int keyflag; + gpg_error_t err; + trustitem_t *ti; + size_t len; + unsigned char fprbin[20]; - trustfp_used++; - if (trustfp) - rewind (trustfp); - while (!(rc=read_list (key, &keyflag))) + if ( hexcolon2bin (fpr, fprbin, 20) < 0 ) + return gpg_error (GPG_ERR_INV_VALUE); + + if (!trusttable) { - if (!strcmp (key, fpr)) + err = read_trustfiles (); + if (err) { - trustfp_used--; - return 0; + log_error (_("error reading list of trusted root certificates\n")); + return err; } } - if (rc != -1) + + if (trusttable) { - /* Error in the trustdb - close it to give the user a chance for - correction */ - if (trustfp) - fclose (trustfp); - trustfp = NULL; + for (ti=trusttable, len = trusttablesize; len; ti++, len--) + if (!memcmp (ti->fpr, fprbin, 20)) + return 0; /* Trusted. */ } - trustfp_used--; - return rc; + return gpg_error (GPG_ERR_NOT_TRUSTED); } /* Write all trust entries to FP. */ -int +gpg_error_t agent_listtrusted (void *assuan_context) { - int rc; - static char key[51]; - int keyflag; + trustitem_t *ti; + char key[51]; + gpg_error_t err; + size_t len; - trustfp_used++; - if (trustfp) - rewind (trustfp); - while (!(rc=read_list (key, &keyflag))) + if (!trusttable) { - key[40] = ' '; - key[41] = keyflag; - key[42] = '\n'; - assuan_send_data (assuan_context, key, 43); - assuan_send_data (assuan_context, NULL, 0); /* flush */ - } - if (rc == -1) - rc = 0; - if (rc) + err = read_trustfiles (); + if (err) + { + log_error (_("error reading list of trusted root certificates\n")); + return err; + } + } + + if (trusttable) { - /* Error in the trustdb - close it to give the user a chance for - correction */ - if (trustfp) - fclose (trustfp); - trustfp = NULL; + /* We need to lock the table because the scheduler may interrupt + assuan_send_data and an other thread may then re-read the table. */ + lock_trusttable (); + for (ti=trusttable, len = trusttablesize; len; ti++, len--) + { + bin2hex (ti->fpr, 20, key); + key[40] = ' '; + key[41] = ti->keyflag; + key[42] = '\n'; + assuan_send_data (assuan_context, key, 43); + assuan_send_data (assuan_context, NULL, 0); /* flush */ + } + unlock_trusttable (); } - trustfp_used--; - return rc; + + return 0; } @@ -245,52 +379,36 @@ actually gets inserted, the user is asked by means of the pin-entry whether this is actual wants he want to do. */ -int +gpg_error_t agent_marktrusted (ctrl_t ctrl, const char *name, const char *fpr, int flag) { - int rc; - static char key[41]; - int keyflag; + gpg_error_t err = 0; char *desc; char *fname; + FILE *fp; /* Check whether we are at all allowed to modify the trustlist. This is useful so that the trustlist may be a symlink to a global trustlist with only admin priviliges to modify it. Of course this is not a secure way of denying access, but it avoids the - usual clicking on an Okay buttun thing most users are used to. */ + usual clicking on an Okay button most users are used to. */ fname = make_filename (opt.homedir, "trustlist.txt", NULL); - rc = access (fname, W_OK); - if (rc && errno != ENOENT) + if ( access (fname, W_OK) && errno != ENOENT) { xfree (fname); return gpg_error (GPG_ERR_EPERM); } xfree (fname); - trustfp_used++; - if (trustfp) - rewind (trustfp); - while (!(rc=read_list (key, &keyflag))) + if (!agent_istrusted (fpr)) { - if (!strcmp (key, fpr)) - return 0; + return 0; /* We already got this fingerprint. Silently return + success. */ } - if (trustfp) - fclose (trustfp); - trustfp = NULL; - if (rc != -1) - { - trustfp_used--; - return rc; /* Error in the trustlist. */ - } /* This feature must explicitly been enabled. */ if (!opt.allow_mark_trusted) - { - trustfp_used--; - return gpg_error (GPG_ERR_NOT_SUPPORTED); - } + return gpg_error (GPG_ERR_NOT_SUPPORTED); /* Insert a new one. */ if (asprintf (&desc, @@ -307,21 +425,15 @@ " \"%s\"%%0A" "has the fingerprint:%%0A" " %s"), name, fpr) < 0 ) - { - trustfp_used--; - return out_of_core (); - } + return out_of_core (); /* TRANSLATORS: "Correct" is the label of a button and intended to be hit if the fingerprint matches the one of the CA. The other button is "the default "Cancel" of the Pinentry. */ - rc = agent_get_confirmation (ctrl, desc, _("Correct"), NULL); + err = agent_get_confirmation (ctrl, desc, _("Correct"), NULL); free (desc); - if (rc) - { - trustfp_used--; - return rc; - } + if (err) + return err; if (asprintf (&desc, /* TRANSLATORS: This prompt is shown by the Pinentry @@ -336,83 +448,78 @@ " \"%s\"%%0A" "to correctly certify user certificates?"), name) < 0 ) - { - trustfp_used--; - return out_of_core (); - } - rc = agent_get_confirmation (ctrl, desc, _("Yes"), _("No")); + return out_of_core (); + + err = agent_get_confirmation (ctrl, desc, _("Yes"), _("No")); free (desc); - if (rc) + if (err) + return err; + + /* Now check again to avoid duplicates. We take the lock to make + sure that nobody else plays with our file. Frankly we don't work + with the trusttable but using this lock is just fine for our + purpose. */ + lock_trusttable (); + if (!agent_istrusted (fpr)) { - trustfp_used--; - return rc; + unlock_trusttable (); + return 0; } - /* Now check again to avoid duplicates. Also open in append mode now. */ - rc = open_list (1); - if (rc) + + fname = make_filename (opt.homedir, "trustlist.txt", NULL); + if ( access (fname, F_OK) && errno == ENOENT) { - trustfp_used--; - return rc; - } - rewind (trustfp); - while (!(rc=read_list (key, &keyflag))) - { - if (!strcmp (key, fpr)) + fp = fopen (fname, "wx"); /* Warning: "x" is a GNU extension. */ + if (!fp) { - trustfp_used--; - return 0; + err = gpg_error_from_syserror (); + log_error ("can't create `%s': %s\n", fname, gpg_strerror (err)); + xfree (fname); + unlock_trusttable (); + return err; } + fputs (headerblurb, fp); + fclose (fp); } - if (rc != -1) + fp = fopen (fname, "a+"); + if (!fp) { - if (trustfp) - fclose (trustfp); - trustfp = NULL; - trustfp_used--; - return rc; /* Error in the trustlist. */ + err = gpg_error_from_syserror (); + log_error ("can't open `%s': %s\n", fname, gpg_strerror (err)); + xfree (fname); + unlock_trusttable (); + return err; } - rc = 0; /* Append the key. */ - fflush (trustfp); - fputs ("\n# ", trustfp); - print_sanitized_string (trustfp, name, 0); - fprintf (trustfp, "\n%s %c\n", fpr, flag); - if (ferror (trustfp)) - rc = gpg_error (gpg_err_code_from_errno (errno)); + fputs ("\n# ", fp); + print_sanitized_string (fp, name, 0); + fprintf (fp, "\n%s %c\n", fpr, flag); + if (ferror (fp)) + err = gpg_error_from_syserror (); - /* close because we are in append mode */ - if (fclose (trustfp)) - rc = gpg_error (gpg_err_code_from_errno (errno)); - trustfp = NULL; - trustfp_used--; - return rc; -} + if (fclose (fp)) + err = gpg_error_from_syserror (); - -void -agent_trustlist_housekeeping (void) -{ - if (reload_trustlist_pending && !trustfp_used) - { - if (trustfp) - { - fclose (trustfp); - trustfp = NULL; - } - reload_trustlist_pending = 0; - } + if (!err) + agent_reload_trustlist (); + xfree (fname); + unlock_trusttable (); + return err; } -/* Not all editors are editing files in place, thus a changes - trustlist.txt won't be recognozed if we keep the file descriptor - open. This function may be used to explicitly close that file - descriptor, which will force a reopen in turn. */ +/* This function may be called to force reloading of the + trustlist. */ void agent_reload_trustlist (void) { - reload_trustlist_pending = 1; - agent_trustlist_housekeeping (); + /* All we need to do is to delete the trusttable. At the next + access it will get re-read. */ + lock_trusttable (); + xfree (trusttable); + trusttable = NULL; + trusttablesize = 0; + unlock_trusttable (); } Modified: trunk/autogen.sh =================================================================== --- trunk/autogen.sh 2006-09-14 16:50:33 UTC (rev 4249) +++ trunk/autogen.sh 2006-09-15 18:53:37 UTC (rev 4250) @@ -153,4 +153,4 @@ echo "Running autoconf..." $AUTOCONF -echo "You may now run \"./configure --enable-maintainer-mode && make\"." +echo "You may now run \"./configure --sysconfdir=/etc --enable-maintainer-mode && make\"." Modified: trunk/common/ChangeLog =================================================================== --- trunk/common/ChangeLog 2006-09-14 16:50:33 UTC (rev 4249) +++ trunk/common/ChangeLog 2006-09-15 18:53:37 UTC (rev 4250) @@ -1,3 +1,10 @@ +2006-09-15 Werner Koch + + * convert.c: New. + (hexcolon2bin): New. + (bin2hex, bin2hexcolon, do_binhex): New. + * t-convert.c: New + 2006-09-14 Werner Koch * util.h (out_of_core): Use new gpg_error_from_syserror function. Modified: trunk/common/Makefile.am =================================================================== --- trunk/common/Makefile.am 2006-09-14 16:50:33 UTC (rev 4249) +++ trunk/common/Makefile.am 2006-09-15 18:53:37 UTC (rev 4250) @@ -21,6 +21,8 @@ ## Process this file with automake to produce Makefile.in noinst_LIBRARIES = libcommon.a libsimple-pwquery.a +noinst_PROGRAMS = $(module_tests) +TESTS = $(module_tests) AM_CPPFLAGS = -I$(top_srcdir)/gl @@ -39,6 +41,7 @@ gettime.c \ yesno.c \ b64enc.c \ + convert.c \ miscellaneous.c \ xasprintf.c \ xreadline.c \ @@ -60,3 +63,15 @@ libsimple_pwquery_a_SOURCES = \ simple-pwquery.c simple-pwquery.h asshelp.c asshelp.h + +# +# Module tests +# +module_tests = t-convert + +t_common_ldadd = ../jnlib/libjnlib.a ../common/libcommon.a ../gl/libgnu.a \ + $(LIBGCRYPT_LIBS) $(GPG_ERROR_LIBS) + +t_convert_DEPENDENCIES = convert.c +t_convert_LDADD = $(t_common_ldadd) + Added: trunk/common/convert.c =================================================================== --- trunk/common/convert.c 2006-09-14 16:50:33 UTC (rev 4249) +++ trunk/common/convert.c 2006-09-15 18:53:37 UTC (rev 4250) @@ -0,0 +1,136 @@ +/* convert.c - Hex conversion functions. + * Copyright (C) 2006 Free Software Foundation, Inc. + * + * This file is part of GnuPG. + * + * GnuPG 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. + * + * GnuPG 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + */ + +#include +#include +#include +#include + +#include "util.h" + + +#define tohex(n) ((n) < 10 ? ((n) + '0') : (((n) - 10) + 'A')) + + +/* Convert STRING consisting of hex characters into its binary representation + and store that at BUFFER. BUFFER needs to be of LENGTH bytes. The + function check that the STRING will convert exactly to LENGTH + bytes. Colons inbetween the hex digits are allowed, if one colon + has been given a colon is expected very 2 characters. The string + is delimited by either end of string or a white space character. + The function returns -1 on error or the length of the parsed + string. */ +int +hexcolon2bin (const char *string, void *buffer, size_t length) +{ + int i; + const char *s = string; + int need_colon = 0; + + for (i=0; i < length; ) + { + if (i==1 && *s == ':') /* Skip colons between hex digits. */ + { + need_colon = 1; + s++; + } + else if (need_colon && *s == ':') + s++; + else if (need_colon) + return -1; /* Colon expected. */ + if (!hexdigitp (s) || !hexdigitp (s+1)) + return -1; /* Invalid hex digits. */ + ((unsigned char*)buffer)[i++] = xtoi_2 (s); + s += 2; + } + if (*s == ':') + return -1; /* Trailing colons are not allowed. */ + if (*s && (!isascii (*s) || !isspace (*s)) ) + return -1; /* Not followed by Nul or white space. */ + if (i != length) + return -1; /* Not of expected length. */ + if (*s) + s++; /* Skip the delimiter. */ + return s - string; +} + + + +static char * +do_bin2hex (const void *buffer, size_t length, char *stringbuf, int with_colon) +{ + const unsigned char *s; + char *p; + + if (!stringbuf) + { + /* Not really correct for with_colon but we don't care about the + one wasted byte. */ + size_t n = with_colon? 3:2; + size_t nbytes = n * length + 1; + if (length && (nbytes-1) / n != length) + { + errno = ENOMEM; + return NULL; + } + stringbuf = xtrymalloc (nbytes); + if (!stringbuf) + return NULL; + } + + for (s = buffer, p = stringbuf; length; length--, s++) + { + if (with_colon && s != buffer) + *p++ = ':'; + *p++ = tohex ((*s>>4)&15); + *p++ = tohex (*s&15); + } + *p = 0; + + return stringbuf; +} + + +/* Convert LENGTH bytes of data in BUFFER into hex encoding and store + that at the provided STRINGBUF. STRINGBUF must be allocated of at + least (2*LENGTH+1) bytes or be NULL so that the function mallocs an + appropriate buffer. Returns STRINGBUF or NULL on error (which may + only occur if STRINGBUF has been NULL and the internal malloc + failed). */ +char * +bin2hex (const void *buffer, size_t length, char *stringbuf) +{ + return do_bin2hex (buffer, length, stringbuf, 0); +} + +/* Convert LENGTH bytes of data in BUFFER into hex encoding and store + that at the provided STRINGBUF. STRINGBUF must be allocated of at + least (3*LENGTH+1) bytes or be NULL so that the function mallocs an + appropriate buffer. Returns STRINGBUF or NULL on error (which may + only occur if STRINGBUF has been NULL and the internal malloc + failed). */ +char * +bin2hexcolon (const void *buffer, size_t length, char *stringbuf) +{ + return do_bin2hex (buffer, length, stringbuf, 1); +} + + Added: trunk/common/t-convert.c =================================================================== --- trunk/common/t-convert.c 2006-09-14 16:50:33 UTC (rev 4249) +++ trunk/common/t-convert.c 2006-09-15 18:53:37 UTC (rev 4250) @@ -0,0 +1,204 @@ +/* t-convert.c - Module test for convert.c + * Copyright (C) 2006 Free Software Foundation, Inc. + * + * This file is part of GnuPG. + * + * GnuPG 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. + * + * GnuPG 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + */ + +#include +#include +#include + +#include "util.h" + +#define pass() do { ; } while(0) +#define fail(a) do { fprintf (stderr, "%s:%d: test %d failed\n",\ + __FILE__,__LINE__, (a)); \ + exit (1); \ + } while(0) + + +static void +test_hexcolon2bin (void) +{ + static const char *valid[] = { + "00112233445566778899aabbccddeeff11223344", + "00112233445566778899AABBCCDDEEFF11223344", + "00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:11:22:33:44", + "00112233445566778899AABBCCDDEEFF11223344 blah", + "00112233445566778899AABBCCDDEEFF11223344\tblah", + "00112233445566778899AABBCCDDEEFF11223344\nblah", + NULL + }; + static const char *invalid[] = { + "00112233445566778899aabbccddeeff1122334", + "00112233445566778899AABBCCDDEEFF1122334", + "00112233445566778899AABBCCDDEEFG11223344", + ":00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:11:22:33:44", + "00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:11:22:33:44:", + "00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:11:22:3344", + "00:1122:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:11:22:33:44", + "0011:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:11:22:33:44", + "00 11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:11:22:33:44", + "00:11 22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:11:22:33:44", + "00112233445566778899aabbccddeeff112233445", + "00112233445566778899aabbccddeeff1122334455", + "00112233445566778899aabbccddeeff11223344blah", + NULL + }; + static const char *valid2[] = { + "00", + "00 x", + NULL + }; + static const char *invalid2[] = { + "", + "0", + "00:", + ":00", + "0:0", + "00x", + " 00", + NULL + }; + unsigned char buffer[20]; + int len; + int i; + + + for (i=0; valid[i]; i++) + { + len = hexcolon2bin (valid[i], buffer, sizeof buffer); + if (len < 0) + fail (i); + if (memcmp (buffer, ("\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xaa" + "\xbb\xcc\xdd\xee\xff\x11\x22\x33\x44"), 20)) + fail (i); + } + if (hexcolon2bin (valid[0], buffer, sizeof buffer) != 40) + fail (0); + if (hexcolon2bin (valid[3], buffer, sizeof buffer) != 41) + fail (0); + + for (i=0; invalid[i]; i++) + { + len = hexcolon2bin (invalid[i], buffer, sizeof buffer); + if (!(len < 0)) + fail (i); + } + + for (i=0; valid2[i]; i++) + { + len = hexcolon2bin (valid2[i], buffer, 1); + if (len < 0) + fail (i); + if (memcmp (buffer, "\x00", 1)) + fail (i); + } + if (hexcolon2bin (valid2[0], buffer, 1) != 2) + fail (0); + if (hexcolon2bin (valid2[1], buffer, 1) != 3) + fail (0); + + for (i=0; invalid2[i]; i++) + { + len = hexcolon2bin (invalid2[i], buffer, 1); + if (!(len < 0)) + fail (i); + } + + +} + + + +static void +test_bin2hex (void) +{ + char stuff[20+1] = ("\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xaa" + "\xbb\xcc\xdd\xee\xff\x01\x10\x02\xa3"); + char hexstuff[] = "00112233445566778899AABBCCDDEEFF011002A3"; + char buffer[2*20+1]; + char *p; + + p = bin2hex (stuff, 20, buffer); + if (!p) + fail (0); + if (p != buffer) + fail (0); + if (strcmp (buffer, hexstuff)) + fail (0); + + p = bin2hex (stuff, 20, NULL); + if (!p) + fail (0); + if (strcmp (p, hexstuff)) + fail (0); + + p = bin2hex (stuff, (size_t)(-1), NULL); + if (p) + fail (0); + if (errno != ENOMEM) + fail (1); +} + + +static void +test_bin2hexcolon (void) +{ + char stuff[20+1] = ("\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xaa" + "\xbb\xcc\xdd\xee\xff\x01\x10\x02\xa3"); + char hexstuff[] = ("00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF" + ":01:10:02:A3"); + char buffer[3*20+1]; + char *p; + + p = bin2hexcolon (stuff, 20, buffer); + if (!p) + fail (0); + if (p != buffer) + fail (0); + if (strcmp (buffer, hexstuff)) + fail (0); + + p = bin2hexcolon (stuff, 20, NULL); + if (!p) + fail (0); + if (strcmp (p, hexstuff)) + fail (0); + + p = bin2hexcolon (stuff, (size_t)(-1), NULL); + if (p) + fail (0); + if (errno != ENOMEM) + fail (1); +} + + + + +int +main (int argc, char **argv) +{ + + test_hexcolon2bin (); + test_bin2hex (); + test_bin2hexcolon (); + + return 0; +} + Modified: trunk/common/util.h =================================================================== --- trunk/common/util.h 2006-09-14 16:50:33 UTC (rev 4249) +++ trunk/common/util.h 2006-09-15 18:53:37 UTC (rev 4250) @@ -144,6 +144,12 @@ unsigned char *make_simple_sexp_from_hexstr (const char *line, size_t *nscanned); +/*-- convert.c --*/ +int hexcolon2bin (const char *string, void *buffer, size_t length); +char *bin2hex (const void *buffer, size_t length, char *stringbuf); +char *bin2hexcolon (const void *buffer, size_t length, char *stringbuf); + + /*-- homedir.c --*/ const char *default_homedir (void); Modified: trunk/doc/Makefile.am =================================================================== --- trunk/doc/Makefile.am 2006-09-14 16:50:33 UTC (rev 4249) +++ trunk/doc/Makefile.am 2006-09-15 18:53:37 UTC (rev 4250) @@ -19,7 +19,7 @@ ## Process this file with automake to produce Makefile.in -examples=examples/scd-event +examples = examples/README examples/scd-event examples/trustlist.txt EXTRA_DIST = DETAILS HACKING TRANSLATE OpenPGP KEYSERVER samplekeys.asc \ gnupg-badge-openpgp.eps gnupg-badge-openpgp.jpg \ Added: trunk/doc/examples/README =================================================================== --- trunk/doc/examples/README 2006-09-14 16:50:33 UTC (rev 4249) +++ trunk/doc/examples/README 2006-09-15 18:53:37 UTC (rev 4250) @@ -0,0 +1,9 @@ +Files in this directory: + + +scd-event A handler script used with scdaemon + +trustlist.txt A list of trustworthy root certificates + (Please check yourself whether you actually trust them) + + Added: trunk/doc/examples/trustlist.txt =================================================================== --- trunk/doc/examples/trustlist.txt 2006-09-14 16:50:33 UTC (rev 4249) +++ trunk/doc/examples/trustlist.txt 2006-09-15 18:53:37 UTC (rev 4250) @@ -0,0 +1,46 @@ +# This is the global list of trusted keys. Comment lines, like this +# one, as well as empty lines are ignored. Lines have a length limit +# but this is not serious limitation as the format of the entries is +# fixed and checked by gpg-agent. A non-comment line starts with +# optional white space, followed by the SHA-1 fingerpint in hex, +# optionally followed by a flag character which my either be 'P', 'S' +# or '*'. This file will be read by gpg-agent if no local trustlist +# is available or if the statement "include-default" is used in the +# local list. You should give the gpg-agent(s) a HUP after editing +# this file. + + +#Serial number: 32D18D +# Issuer: /CN=6R-Ca 1:PN/NameDistinguisher=1/O=Regulierungsbeh?orde +# f?ur Telekommunikation und Post/C=DE +EA:8D:99:DD:36:AA:2D:07:1A:3C:7B:69:00:9E:51:B9:4A:2E:E7:60 S + +#Serial number: 00C48C8D +# Issuer: /CN=7R-CA 1:PN/NameDistinguisher=1/O=Regulierungsbeh?orde +# f?ur Telekommunikation und Post/C=DE +DB:45:3D:1B:B0:1A:F3:23:10:6B:DE:D0:09:61:57:AA:F4:25:E0:5B S + +#Serial number: 01 +# Issuer: /CN=8R-CA 1:PN/O=Regulierungsbeh?rde f?r +# Telekommunikation und Post/C=DE +42:6A:F6:78:30:E9:CE:24:5B:EF:41:A2:C1:A8:51:DA:C5:0A:6D:F5 S + +#Serial number: 02 +# Issuer: /CN=9R-CA 1:PN/O=Regulierungsbeh?rde f?r +# Telekommunikation und Post/C=DE +75:9A:4A:CE:7C:DA:7E:89:1B:B2:72:4B:E3:76:EA:47:3A:96:97:24 S + +#Serial number: 2A +# Issuer: /CN=10R-CA 1:PN/O=Bundesnetzagentur/C=DE +31:C9:D2:E6:31:4D:0B:CC:2C:1A:45:00:A6:6B:97:98:27:18:8E:CD S + +#Serial number: 2D +# Issuer: /CN=11R-CA 1:PN/O=Bundesnetzagentur/C=DE +A0:8B:DF:3B:AA:EE:3F:9D:64:6C:47:81:23:21:D4:A6:18:81:67:1D S + +#Serial number: 00 +# Issuer: /CN=CA Cert Signing Authority/OU=http:\x2f\x2fwww. +# cacert.org/O=Root CA/EMail=support@cacert.org +13:5C:EC:36:F4:9C:B8:E9:3B:1A:B2:70:CD:80:88:46:76:CE:8F:33 S + + Modified: trunk/doc/gpg-agent.texi =================================================================== --- trunk/doc/gpg-agent.texi 2006-09-14 16:50:33 UTC (rev 4249) +++ trunk/doc/gpg-agent.texi 2006-09-15 18:53:37 UTC (rev 4250) @@ -467,17 +467,22 @@ DC:BD:69:25:48:BD:BB:7E:31:6E:BB:80:D3:00:80:35:D4:F8:A6:CD S @end example - Before entering a key into this file, you need to ensure its - authenticity. How to do this depends on your organisation; your - administrator might have already entered those keys which are deemed - trustworthy enough into this file. Places where to look for the - fingerprint of a root certificate are letters received from the CA or - the website of the CA (after making 100% sure that this is indeed the - website of that CA). You may want to consider allowing interactive - updates of this file by using the @xref{option --allow-mark-trusted}. - This is however not as secure as maintaining this file manually. It is - even advisable to change the permissions to read-only so that this file - can't be changed inadvertently. +Before entering a key into this file, you need to ensure its +authenticity. How to do this depends on your organisation; your +administrator might have already entered those keys which are deemed +trustworthy enough into this file. Places where to look for the +fingerprint of a root certificate are letters received from the CA or +the website of the CA (after making 100% sure that this is indeed the +website of that CA). You may want to consider allowing interactive +updates of this file by using the @xref{option --allow-mark-trusted}. +This is however not as secure as maintaining this file manually. It is +even advisable to change the permissions to read-only so that this file +can't be changed inadvertently. + +As a special feature a line @code{include-default} will include a global +list of trusted certificates (e.g. @file{/etc/gnupg/trustlist.txt}). +This global list is also used if the local list ios not available. + @item sshcontrol Modified: trunk/scd/ChangeLog =================================================================== --- trunk/scd/ChangeLog 2006-09-14 16:50:33 UTC (rev 4249) +++ trunk/scd/ChangeLog 2006-09-15 18:53:37 UTC (rev 4250) @@ -52,7 +52,7 @@ * pcsc-wrapper.c (handle_open, handle_close): Reset card and protocol on error/close. - (handle_status): Don't set the stae if the state is unknown. + (handle_status): Don't set the state if the state is unknown. (handle_reset): Ignore an error if already disconnected. May happen due to system wake-up after hibernation. Suggested by Bob Dunlop. From cvs at cvs.gnupg.org Mon Sep 18 11:28:59 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon Sep 18 10:43:40 2006 Subject: [svn] GnuPG - r4251 - in trunk: . doc sm Message-ID: Author: wk Date: 2006-09-18 11:28:58 +0200 (Mon, 18 Sep 2006) New Revision: 4251 Added: trunk/doc/com-certs.pem Modified: trunk/NEWS trunk/doc/ChangeLog trunk/doc/Makefile.am trunk/sm/ChangeLog trunk/sm/gpgsm.c trunk/sm/keydb.c trunk/sm/keydb.h Log: Added common certificates. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-09-15 18:53:37 UTC (rev 4250) +++ trunk/NEWS 2006-09-18 09:28:58 UTC (rev 4251) @@ -28,7 +28,10 @@ * A global trustlist may now be used. See doc/examples/trustlist.txt. + * When creating a new pubring.kbx keybox common certificates are + imported. + Noteworthy changes in version 1.9.22 (2006-07-27) ------------------------------------------------- Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2006-09-15 18:53:37 UTC (rev 4250) +++ trunk/doc/ChangeLog 2006-09-18 09:28:58 UTC (rev 4251) @@ -1,3 +1,7 @@ +2006-09-18 Werner Koch + + * com-certs.pem: New. + 2006-09-13 Werner Koch * gpg.texi (GPG Esoteric Options): Fixed typo in Modified: trunk/doc/Makefile.am =================================================================== --- trunk/doc/Makefile.am 2006-09-15 18:53:37 UTC (rev 4250) +++ trunk/doc/Makefile.am 2006-09-18 09:28:58 UTC (rev 4251) @@ -37,7 +37,7 @@ info_TEXINFOS = gnupg.texi -dist_pkgdata_DATA = qualified.txt FAQ faq.html +dist_pkgdata_DATA = qualified.txt FAQ faq.html com-certs.pem gnupg_TEXINFOS = \ gpg.texi gpgsm.texi gpg-agent.texi scdaemon.texi assuan.texi \ Added: trunk/doc/com-certs.pem =================================================================== --- trunk/doc/com-certs.pem 2006-09-15 18:53:37 UTC (rev 4250) +++ trunk/doc/com-certs.pem 2006-09-18 09:28:58 UTC (rev 4251) @@ -0,0 +1,199 @@ +# Common certificates for initial keybox creation. + +Issuer ...: /CN=CA Cert Signing Authority/OU=http:\x2f\x2fwww.cacert.org/O=Root CA/EMail=support@cacert.org +Serial ...: 00 +Subject ..: /CN=CA Cert Signing Authority/OU=http:\x2f\x2fwww.cacert.org/O=Root CA/EMail=support@cacert.org + +-----BEGIN CERTIFICATE----- +MIIHPTCCBSWgAwIBAgIBADANBgkqhkiG9w0BAQQFADB5MRAwDgYDVQQKEwdSb290 +IENBMR4wHAYDVQQLExVodHRwOi8vd3d3LmNhY2VydC5vcmcxIjAgBgNVBAMTGUNB +IENlcnQgU2lnbmluZyBBdXRob3JpdHkxITAfBgkqhkiG9w0BCQEWEnN1cHBvcnRA +Y2FjZXJ0Lm9yZzAeFw0wMzAzMzAxMjI5NDlaFw0zMzAzMjkxMjI5NDlaMHkxEDAO +BgNVBAoTB1Jvb3QgQ0ExHjAcBgNVBAsTFWh0dHA6Ly93d3cuY2FjZXJ0Lm9yZzEi +MCAGA1UEAxMZQ0EgQ2VydCBTaWduaW5nIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJ +ARYSc3VwcG9ydEBjYWNlcnQub3JnMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC +CgKCAgEAziLA4kZ97DYoB1CW8qAzQIxL8TtmPzHlawI229Z89vGIj053NgVBlfkJ +8BLPRoZzYLdufujAWGSuzbCtRRcMY/pnCujW0r8+55jE8Ez64AO7NV1sId6eINm6 +zWYyN3L69wj1x81YyY7nDl7qPv4coRQKFWyGhFtkZip6qUtTefWIonvuLwphK42y +fk1WpRPs6tqSnqxEQR5YYGUFZvjARL3LlPdCfgv3ZWiYUQXw8wWRBB0bF4LsyFe7 +w2t6iPGwcswlWyCR7BYCEo8y6RcYSNDHBS4CMEK4JZwFaz+qOqfrU0j36NK2B5jc +G8Y0f3/JHIJ6BVgrCFvzOKKrF11myZjXnhCLotLddJr3cQxyYN/Nb5gznZY0dj4k +epKwDpUeb+agRThHqtdB7Uq3EvbXG4OKDy7YCbZZ16oE/9KTfWgu3YtLq1i6L43q +laegw1SJpfvbi1EinbLDvhG+LJGGi5Z4rSDTii8aP8bQUWWHIbEZAWV/RRyH9XzQ +QUxPKZgh/TMfdQwEUfoZd9vUFBzugcMd9Zi3aQaRIt0AUMyBMawSB3s42mhb5ivU +fslfrejrckzzAeVLIL+aplfKkQABi6F1ITe1Yw1nPkZPcCBnzsXWWdsC4PDSy826 +YreQQejdIOQpvGQpQsgi3Hia/0PsmBsJUUtaWsJx8cTLc6nloQsCAwEAAaOCAc4w +ggHKMB0GA1UdDgQWBBQWtTIb1Mfz4OaO873SsDrusjkY0TCBowYDVR0jBIGbMIGY +gBQWtTIb1Mfz4OaO873SsDrusjkY0aF9pHsweTEQMA4GA1UEChMHUm9vdCBDQTEe +MBwGA1UECxMVaHR0cDovL3d3dy5jYWNlcnQub3JnMSIwIAYDVQQDExlDQSBDZXJ0 +IFNpZ25pbmcgQXV0aG9yaXR5MSEwHwYJKoZIhvcNAQkBFhJzdXBwb3J0QGNhY2Vy +dC5vcmeCAQAwDwYDVR0TAQH/BAUwAwEB/zAyBgNVHR8EKzApMCegJaAjhiFodHRw +czovL3d3dy5jYWNlcnQub3JnL3Jldm9rZS5jcmwwMAYJYIZIAYb4QgEEBCMWIWh0 +dHBzOi8vd3d3LmNhY2VydC5vcmcvcmV2b2tlLmNybDA0BglghkgBhvhCAQgEJxYl +aHR0cDovL3d3dy5jYWNlcnQub3JnL2luZGV4LnBocD9pZD0xMDBWBglghkgBhvhC +AQ0ESRZHVG8gZ2V0IHlvdXIgb3duIGNlcnRpZmljYXRlIGZvciBGUkVFIGhlYWQg +b3ZlciB0byBodHRwOi8vd3d3LmNhY2VydC5vcmcwDQYJKoZIhvcNAQEEBQADggIB +ACjH7pyCArpcgBLKNQodgW+JapnM8mgPf6fhjViVPr3yBsOQWqy1YPaZQwGjiHCc +nWKdpIevZ1gNMDY75q1I08t0AoZxPuIrA2jxNGJARjtT6ij0rPtmlVOKTV39O9lg +18p5aTuxZZKmxoGCXJzN600BiqXfEVWqFcofN8CCmHBh22p8lqOOLlQ+TyGpkO/c +gr/c6EWtTZBzCDyUZbAEmXZ/4rzCahWqlwQ3JNgelE5tDlG+1sSPypZt90Pf6DBl +Jzt7u0NDY8RD97LsaMzhGY4i+5jhe1o+ATc7iwiwovOVThrLm82asduycPAtStvY +sONvRUgzEv/+PDIqVPfE94rwiCPCR/5kenHA0R6mY7AHfqQv0wGP3J8rtsYIqQ+T +SCX8Ev2fQtzzxD72V7DX3WnRBnc0CkvSyqD/HMaMyRa+xMwyN2hzXwj7UfdJUzYF +CpUCTPJ5GhD22Dp1nPMd8aINcGeGG7MW9S/lpOt5hvk9C8JzC6WZrG/8Z7jlLwum +GCSNe9FINSkYQKyTYOGWhlC0elnYjyELn8+CkcY7v2vcB5G5l1YjqrZslMZIBjzk +zk6q5PYvCdxTby78dOs6Y5nCpqyJvKeyRKANihDjbPIky/qbn3BHLt4Ui9SyIAmW +omTxJBzcoTWcFbLUvFUufQb1nA5V9FrWk9p2rSVzTMVD +-----END CERTIFICATE----- + +Issuer ...: /CN=6R-Ca 1:PN/NameDistinguisher=1/O=RegulierungsbehÈorde fÈur Telekommunikation und Post/C=DE +Serial ...: 32D18D +Subject ..: /CN=6R-Ca 1:PN/NameDistinguisher=1/O=RegulierungsbehÈorde fÈur Telekommunikation und Post/C=DE + +-----BEGIN CERTIFICATE----- +MIICaDCCAdSgAwIBAgIDMtGNMAoGBiskAwMBAgUAMG8xCzAJBgNVBAYTAkRFMT0w +OwYDVQQKFDRSZWd1bGllcnVuZ3NiZWjIb3JkZSBmyHVyIFRlbGVrb21tdW5pa2F0 +aW9uIHVuZCBQb3N0MSEwDAYHAoIGAQoHFBMBMTARBgNVBAMUCjZSLUNhIDE6UE4w +IhgPMjAwMTAyMDEwOTUyMTdaGA8yMDA1MDYwMTA5NTIxN1owbzELMAkGA1UEBhMC +REUxPTA7BgNVBAoUNFJlZ3VsaWVydW5nc2JlaMhvcmRlIGbIdXIgVGVsZWtvbW11 +bmlrYXRpb24gdW5kIFBvc3QxITAMBgcCggYBCgcUEwExMBEGA1UEAxQKNlItQ2Eg +MTpQTjCBoTANBgkqhkiG9w0BAQEFAAOBjwAwgYsCgYEAg6KrFSTNXKqe+2GKGeW2 +wTmbVeflNkp5H/YxA9K1zmEn5XjKm0S0jH4Wfms6ipPlURVaFwTfnB1s++AnJAWf +mayaE9BP/pdIY6WtZGgW6aZc32VDMCMKPWyBNyagsJVDmzlakIA5cXBVa7Xqqd3P +ew8i2feMnQXcqHfDv02CW88CBQDAAAABoxIwEDAOBgNVHQ8BAf8EBAMCAQYwCgYG +KyQDAwECBQADgYEAOkqkUwdaTCt8wcJLA2zLuOwL5ADHMWLhv6gr5zEF+VckA6qe +IVLVf8e7fYlRmzQd+5OJcGglCQJLGT+ZplI3Mjnrd4plkoTNKV4iOzBcvJD7K4tn +XPvs9wCFcC7QU7PLvc1FDsAlr7e4wyefZRDL+wbqNfI7QZTSF1ubLd9AzeQ= +-----END CERTIFICATE----- + +Issuer ...: /CN=10R-CA 1:PN/O=Bundesnetzagentur/C=DE +Serial ...: 2A +Subject ..: /CN=10R-CA 1:PN/O=Bundesnetzagentur/C=DE + +-----BEGIN CERTIFICATE----- +MIIDoTCCAw2gAwIBAgIBKjAKBgYrJAMDAQIFADA/MQswCQYDVQQGEwJERTEaMBgG +A1UECgwRQnVuZGVzbmV0emFnZW50dXIxFDASBgNVBAMMCzEwUi1DQSAxOlBOMB4X +DTA1MDgwMzE1MzAzNloXDTA3MTIzMTE1MDkyM1owPzELMAkGA1UEBhMCREUxGjAY +BgNVBAoMEUJ1bmRlc25ldHphZ2VudHVyMRQwEgYDVQQDDAsxMFItQ0EgMTpQTjCB +oDANBgkqhkiG9w0BAQEFAAOBjgAwgYoCgYEAiHXC5/hw6rYNc/4cilHLjd/SqwS3 +4LaogQHZVFciyYJ0+5gAfca/kLnPEvOUuYSYNfb2ar0e/iDPxZAAEfqfVGuRT9Pa +R7hWvPiZUFpoGcNvyOVxKuM9Iyx/i1wan/wS6u12QIgGBUek5ig1+TTwuuNcanlW +kQPuodHs+BoUGHMCBEAAAIGjggGwMIIBrDAOBgNVHQ8BAf8EBAMCAgQwGAYIKwYB +BQUHAQMEDDAKMAgGBgQAjkYBATBKBggrBgEFBQcBAQQ+MDwwOgYIKwYBBQUHMAGG +Lmh0dHA6Ly9vY3NwLm5yY2EtZHMuZGU6ODA4MC9vY3NwLW9jc3ByZXNwb25kZXIw +EgYDVR0gBAswCTAHBgUrJAgBATCBsQYDVR0fBIGpMIGmMIGjoIGgoIGdhoGabGRh +cDovL2xkYXAubnJjYS1kcy5kZTozODkvQ049Q1JMLE89QnVuZGVzbmV0emFnZW50 +dXIsQz1ERSxkYz1sZGFwLGRjPW5yY2EtZHMsZGM9ZGU/Y2VydGlmaWNhdGVSZXZv +Y2F0aW9uTGlzdDtiaW5hcnk/YmFzZT9vYmplY3RDbGFzcz1jUkxEaXN0cmlidXRp +b25Qb2ludDAbBgkrBgEEAcBtAwUEDjAMBgorBgEEAcBtAwUBMA8GA1UdEwEB/wQF +MAMBAf8wHwYDVR0jBBgwFoAUw8916sARU0UT/pdlYwBpUwKWuWQwHQYDVR0OBBYE +FMPPderAEVNFE/6XZWMAaVMClrlkMAoGBiskAwMBAgUAA4GBAGXK8m/O9KmfaZuA +1GzMyasIHx8Lu+V0da8NTZzAmqAl+44MtS4QNcZdtxsDvOcqHHs1Tosh9D398hSG +hXd6gjniKWxMKvjL8TQKu999QIn6YKLCowjUYpp8v4B9X8jNa9vJy2EzoPOBmdWT +l5hhXfvWpPe68kN9zaEmcDO+m60H +-----END CERTIFICATE----- + +Issuer ...: /CN=9R-CA 1:PN/O=Regulierungsbehörde für Telekommunikation und Post/C=DE +Serial ...: 02 +Subject ..: /CN=9R-CA 1:PN/O=Regulierungsbehörde für Telekommunikation und Post/C=DE + +-----BEGIN CERTIFICATE----- +MIIEEjCCA36gAwIBAgIBAjAKBgYrJAMDAQIFADBhMQswCQYDVQQGEwJERTE9MDsG +A1UECgw0UmVndWxpZXJ1bmdzYmVow7ZyZGUgZsO8ciBUZWxla29tbXVuaWthdGlv +biB1bmQgUG9zdDETMBEGA1UEAwwKOVItQ0EgMTpQTjAeFw0wNDExMjUxNDU5MTFa +Fw0wNzEyMzExNDU2NTlaMGExCzAJBgNVBAYTAkRFMT0wOwYDVQQKDDRSZWd1bGll +cnVuZ3NiZWjDtnJkZSBmw7xyIFRlbGVrb21tdW5pa2F0aW9uIHVuZCBQb3N0MRMw +EQYDVQQDDAo5Ui1DQSAxOlBOMIGgMA0GCSqGSIb3DQEBAQUAA4GOADCBigKBgQCN +0ECEO2KjPsHBz2cmOSePEmKEH33Q/vRUl1u8D2Uus3txZgqRvCs0F7HzAtDJKSap +C1+qj5t1R4g8jrlWwsqi+oOc3bpUuPMLo+ys9PG7ODK+xZuwFlezO6rj30mEj+y0 +HMxCaTAedim2J5CmWcqQtATGGzwqYHEVFYo0y5kuuQIEQAAAgaOCAd0wggHZMA4G +A1UdDwEB/wQEAwICBDAYBggrBgEFBQcBAwQMMAowCAYGBACORgEBMEoGCCsGAQUF +BwEBBD4wPDA6BggrBgEFBQcwAYYuaHR0cDovL29jc3AubnJjYS1kcy5kZTo4MDgw +L29jc3Atb2NzcHJlc3BvbmRlcjASBgNVHSAECzAJMAcGBSskCAEBMIHeBgNVHR8E +gdYwgdMwgdCggc2ggcqGgcdsZGFwOi8vbGRhcC5ucmNhLWRzLmRlOjM4OS9DTj1D +UkwsTz1SZWd1bGllcnVuZ3NiZWglRjZyZGUlMjBmJUZDciUyMFRlbGVrb21tdW5p +a2F0aW9uJTIwdW5kJTIwUG9zdCxDPURFLGRjPWxkYXAsZGM9bnJjYS1kcyxkYz1k +ZT9jZXJ0aWZpY2F0ZVJldm9jYXRpb25MaXN0O2JpbmFyeT9iYXNlP29iamVjdENs +YXNzPWNSTERpc3RyaWJ1dGlvblBvaW50MBsGCSsGAQQBwG0DBQQOMAwGCisGAQQB +wG0DBQEwDwYDVR0TAQH/BAUwAwEB/zAfBgNVHSMEGDAWgBRnBgT5ZxC7e1vJLBj+ +92+P1kZrJzAdBgNVHQ4EFgQUZwYE+WcQu3tbySwY/vdvj9ZGaycwCgYGKyQDAwEC +BQADgYEACAnkgbAd47VgJqu5CY3B6AlxbGkor2guYHXO+KgBkQeXDVWt4ZvN9hY2 +blhPMc/sLv+Tmg9zjyzjqQdxhWXUDoctorBny8LQQQvMqAtc8qk6DL+X0heq1U2k +s1e8wj9AUGOfvmSL/r1BWPzLOCWay2bHQCQ1sU5QnvNbmJO21GI= +-----END CERTIFICATE----- + +Issuer ...: /CN=11R-CA 1:PN/O=Bundesnetzagentur/C=DE +Serial ...: 2D +Subject ..: /CN=11R-CA 1:PN/O=Bundesnetzagentur/C=DE + +-----BEGIN CERTIFICATE----- +MIIDoTCCAw2gAwIBAgIBLTAKBgYrJAMDAQIFADA/MQswCQYDVQQGEwJERTEaMBgG +A1UECgwRQnVuZGVzbmV0emFnZW50dXIxFDASBgNVBAMMCzExUi1DQSAxOlBOMB4X +DTA1MDgwMzE4MDk0OVoXDTA3MTIzMTE4MDQyOFowPzELMAkGA1UEBhMCREUxGjAY +BgNVBAoMEUJ1bmRlc25ldHphZ2VudHVyMRQwEgYDVQQDDAsxMVItQ0EgMTpQTjCB +oDANBgkqhkiG9w0BAQEFAAOBjgAwgYoCgYEAkodoSFtoGjJphYloxQLsmyOe/M5h +UpURxSkop41MtGlrHeOeQsxMSRdCJInwjLKZg9Pxd92QFsB3f6AJUGTO7z6PJ/ST ++m0EBksoPtciWLYtlRXtD/RK6mUB7CG5CfqK6AUHbWtXW6mNAZLoJOd0jLsQCUi8 +XmHP92vfmW2ptSkCBEAAAIGjggGwMIIBrDAOBgNVHQ8BAf8EBAMCAgQwGAYIKwYB +BQUHAQMEDDAKMAgGBgQAjkYBATBKBggrBgEFBQcBAQQ+MDwwOgYIKwYBBQUHMAGG +Lmh0dHA6Ly9vY3NwLm5yY2EtZHMuZGU6ODA4MC9vY3NwLW9jc3ByZXNwb25kZXIw +EgYDVR0gBAswCTAHBgUrJAgBATCBsQYDVR0fBIGpMIGmMIGjoIGgoIGdhoGabGRh +cDovL2xkYXAubnJjYS1kcy5kZTozODkvQ049Q1JMLE89QnVuZGVzbmV0emFnZW50 +dXIsQz1ERSxkYz1sZGFwLGRjPW5yY2EtZHMsZGM9ZGU/Y2VydGlmaWNhdGVSZXZv +Y2F0aW9uTGlzdDtiaW5hcnk/YmFzZT9vYmplY3RDbGFzcz1jUkxEaXN0cmlidXRp +b25Qb2ludDAbBgkrBgEEAcBtAwUEDjAMBgorBgEEAcBtAwUBMA8GA1UdEwEB/wQF +MAMBAf8wHwYDVR0jBBgwFoAUXYAPovSdSBb8oBS7lEJmWSK6incwHQYDVR0OBBYE +FF2AD6L0nUgW/KAUu5RCZlkiuop3MAoGBiskAwMBAgUAA4GBAIxx56h5+p2lqK0v +hRVwkWAAPduspH4U9q7QsFIWbEkFe+2TcXx7MV9NAUe4kN9MsN9CEgSSeLDfpIFA +uyHndqgmDaqXmWSDl2QutHQwSj8a04bSNbY7s0FUCMqrr/465Rf6quIWi7qXhwDe +yDmXv3nzPTGVM3F+aavJCybjJ1qk +-----END CERTIFICATE----- + +Issuer ...: /CN=8R-CA 1:PN/O=Regulierungsbehörde für Telekommunikation und Post/C=DE +Serial ...: 01 +Subject ..: /CN=8R-CA 1:PN/O=Regulierungsbehörde für Telekommunikation und Post/C=DE + +-----BEGIN CERTIFICATE----- +MIIEEjCCA36gAwIBAgIBATAKBgYrJAMDAQIFADBhMQswCQYDVQQGEwJERTE9MDsG +A1UECgw0UmVndWxpZXJ1bmdzYmVow7ZyZGUgZsO8ciBUZWxla29tbXVuaWthdGlv +biB1bmQgUG9zdDETMBEGA1UEAwwKOFItQ0EgMTpQTjAeFw0wNDExMjUxNDEwMzda +Fw0wNzEyMzExNDA0MDNaMGExCzAJBgNVBAYTAkRFMT0wOwYDVQQKDDRSZWd1bGll +cnVuZ3NiZWjDtnJkZSBmw7xyIFRlbGVrb21tdW5pa2F0aW9uIHVuZCBQb3N0MRMw +EQYDVQQDDAo4Ui1DQSAxOlBOMIGgMA0GCSqGSIb3DQEBAQUAA4GOADCBigKBgQCS +DvtngJbI4K8sbCHFfCalXaDa7xgc2pdsL2oQlgZygt1EY5ZgZB93JThnDSaDzdLj +ZIPrXJLxCOLq6Kmxj63V9p9WUaF5nz/6PVRMmLzI7cvh5QDjsX4ZmEzm/it7e/YH +vC1Yiw5bTULjwVZ27vqO64mhplQM3HKVgk6FX51XnwIEQAAAgaOCAd0wggHZMA4G +A1UdDwEB/wQEAwICBDAYBggrBgEFBQcBAwQMMAowCAYGBACORgEBMEoGCCsGAQUF +BwEBBD4wPDA6BggrBgEFBQcwAYYuaHR0cDovL29jc3AubnJjYS1kcy5kZTo4MDgw +L29jc3Atb2NzcHJlc3BvbmRlcjASBgNVHSAECzAJMAcGBSskCAEBMIHeBgNVHR8E +gdYwgdMwgdCggc2ggcqGgcdsZGFwOi8vbGRhcC5ucmNhLWRzLmRlOjM4OS9DTj1D +UkwsTz1SZWd1bGllcnVuZ3NiZWglRjZyZGUlMjBmJUZDciUyMFRlbGVrb21tdW5p +a2F0aW9uJTIwdW5kJTIwUG9zdCxDPURFLGRjPWxkYXAsZGM9bnJjYS1kcyxkYz1k +ZT9jZXJ0aWZpY2F0ZVJldm9jYXRpb25MaXN0O2JpbmFyeT9iYXNlP29iamVjdENs +YXNzPWNSTERpc3RyaWJ1dGlvblBvaW50MBsGCSsGAQQBwG0DBQQOMAwGCisGAQQB +wG0DBQEwDwYDVR0TAQH/BAUwAwEB/zAfBgNVHSMEGDAWgBTuKY5dMBMWc1wFL/fr +arlCuHKNBDAdBgNVHQ4EFgQU7imOXTATFnNcBS/362q5QrhyjQQwCgYGKyQDAwEC +BQADgYEAbDMwH4zJB/0qgmbBWvvCGJsm9lmLzLdOcB8HCm1EvlCLqaCX7TwoUuBN +voxU9OHt1wAbChNP+ueDmI/0u2KRNv6/t4cOB8d4navwsW5nmknSzdZ6UZTUfmCr +n6XIdUtl2hkiFlQpCvCIBFj/+PjQRMdovRN42EQ9XVhb5B2MGv8= +-----END CERTIFICATE----- + +Issuer ...: /CN=7R-CA 1:PN/NameDistinguisher=1/O=RegulierungsbehÈorde fÈur Telekommunikation und Post/C=DE +Serial ...: 00C48C8D +Subject ..: /CN=7R-CA 1:PN/NameDistinguisher=1/O=RegulierungsbehÈorde fÈur Telekommunikation und Post/C=DE + +-----BEGIN CERTIFICATE----- +MIICaTCCAdWgAwIBAgIEAMSMjTAKBgYrJAMDAQIFADBvMQswCQYDVQQGEwJERTE9 +MDsGA1UEChQ0UmVndWxpZXJ1bmdzYmVoyG9yZGUgZsh1ciBUZWxla29tbXVuaWth +dGlvbiB1bmQgUG9zdDEhMAwGBwKCBgEKBxQTATEwEQYDVQQDFAo3Ui1DQSAxOlBO +MCIYDzIwMDExMDE1MTExNTE1WhgPMjAwNjAyMTUxMTE1MTVaMG8xCzAJBgNVBAYT +AkRFMT0wOwYDVQQKFDRSZWd1bGllcnVuZ3NiZWjIb3JkZSBmyHVyIFRlbGVrb21t +dW5pa2F0aW9uIHVuZCBQb3N0MSEwDAYHAoIGAQoHFBMBMTARBgNVBAMUCjdSLUNB +IDE6UE4wgaEwDQYJKoZIhvcNAQEBBQADgY8AMIGLAoGBAIqJA/4+pRD+BXsRd+ej +qVObXlKRhn1CoyKxVwR3O/RtE1M4FcajKDdT1p1pLULyqPBE2roMS5D/f83192gE +Mw1uGZIusehg6n8tPQIJPkSb4X22yM0ZFeLAQXKNJ+98e03xv/TU4Fa//elPiPs/ +9Y99Gm6DOvTpCxIY8QK9Pxm7AgUAwAAAAaMSMBAwDgYDVR0PAQH/BAQDAgEGMAoG +BiskAwMBAgUAA4GBADnITH+fLD0qsWcAncwPztzTAnqUw9O0+yvfmxvEU0zcJRuF +Tl8DK+/aKp4SwVhRJZlWxenHzkjWynsUXBUv878gizllRpA7265REyHQki4NnxAi +OGxEVGe/NbGeU88Pgnk7alhtdA/Ty8/WX9a3U/0G4pLaJppxGSm+ypQZ0XOY +-----END CERTIFICATE----- Modified: trunk/sm/ChangeLog =================================================================== --- trunk/sm/ChangeLog 2006-09-15 18:53:37 UTC (rev 4250) +++ trunk/sm/ChangeLog 2006-09-18 09:28:58 UTC (rev 4251) @@ -1,3 +1,8 @@ +2006-09-18 Werner Koch + + * gpgsm.c (main): Use this to import standard certificates. + * keydb.c (keydb_add_resource): New arg AUTO_CREATED. + 2006-09-14 Werner Koch Replaced all call gpg_error_from_errno(errno) by Modified: trunk/sm/gpgsm.c =================================================================== --- trunk/sm/gpgsm.c 2006-09-15 18:53:37 UTC (rev 4250) +++ trunk/sm/gpgsm.c 2006-09-18 09:28:58 UTC (rev 4251) @@ -1299,10 +1299,29 @@ if (!cmd && opt.fingerprint && !with_fpr) set_cmd (&cmd, aListKeys); - if (!nrings && default_keyring) /* add default keybox */ - keydb_add_resource ("pubring.kbx", 0, 0); + if (!nrings && default_keyring) /* Add default keybox. */ + { + int created; + + keydb_add_resource ("pubring.kbx", 0, 0, &created); + if (created) + { + /* Import the standard certificates for a new default keybox. */ + char *filelist[2]; + + filelist[0] = make_filename (GNUPG_DATADIR, "com-certs.pem", NULL); + filelist[1] = NULL; + if (!access (filelist[0], F_OK)) + { + log_info (_("importing common certificates `%s'\n"), + filelist[0]); + gpgsm_import_files (&ctrl, 1, filelist, open_read); + } + xfree (filelist[0]); + } + } for (sl = nrings; sl; sl = sl->next) - keydb_add_resource (sl->d, 0, 0); + keydb_add_resource (sl->d, 0, 0, NULL); FREE_STRLIST(nrings); if (!do_not_setup_keys) Modified: trunk/sm/keydb.c =================================================================== --- trunk/sm/keydb.c 2006-09-15 18:53:37 UTC (rev 4250) +++ trunk/sm/keydb.c 2006-09-18 09:28:58 UTC (rev 4251) @@ -71,13 +71,12 @@ /* * Register a resource (which currently may only be a keybox file). - * The first keybox which is added by this function is - * created if it does not exist. - * Note: this function may be called before secure memory is - * available. + * The first keybox which is added by this function is created if it + * does not exist. If AUTO_CREATED is not NULL it will be set to true + * if the function has created a a new keybox. */ int -keydb_add_resource (const char *url, int force, int secret) +keydb_add_resource (const char *url, int force, int secret, int *auto_created) { static int any_secret, any_public; const char *resname = url; @@ -87,6 +86,9 @@ KeydbResourceType rt = KEYDB_RESOURCE_TYPE_NONE; const char *created_fname = NULL; + if (auto_created) + *auto_created = 0; + /* Do we have an URL? gnupg-kbx:filename := this is a plain keybox filename := See what is is, but create as plain keybox. @@ -195,6 +197,8 @@ if (!opt.quiet) log_info (_("keybox `%s' created\n"), filename); created_fname = filename; + if (auto_created) + *auto_created = 1; } fclose (fp); fp = NULL; Modified: trunk/sm/keydb.h =================================================================== --- trunk/sm/keydb.h 2006-09-15 18:53:37 UTC (rev 4250) +++ trunk/sm/keydb.h 2006-09-18 09:28:58 UTC (rev 4251) @@ -33,7 +33,8 @@ /*-- keydb.c --*/ -int keydb_add_resource (const char *url, int force, int secret); +int keydb_add_resource (const char *url, int force, int secret, + int *auto_created); KEYDB_HANDLE keydb_new (int secret); void keydb_release (KEYDB_HANDLE hd); int keydb_set_ephemeral (KEYDB_HANDLE hd, int yes); From cvs at cvs.gnupg.org Mon Sep 18 15:23:20 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon Sep 18 14:38:04 2006 Subject: [svn] GnuPG - r4252 - in trunk: . doc po Message-ID: Author: wk Date: 2006-09-18 15:23:18 +0200 (Mon, 18 Sep 2006) New Revision: 4252 Modified: trunk/ChangeLog trunk/Makefile.am trunk/NEWS trunk/configure.ac trunk/doc/gpgsm.texi trunk/po/de.po Log: Ready for another release Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-09-18 09:28:58 UTC (rev 4251) +++ trunk/ChangeLog 2006-09-18 13:23:18 UTC (rev 4252) @@ -1,3 +1,11 @@ +2006-09-18 Werner Koch + + Released 1.9.23. + + * configure.ac (--enable-agent-only): Donot build tools and doc + (--disable-tools,--disable-doc): New. + * Makefile.am (SUBDIRS): Allow to conditional build tools and doc. + 2006-09-14 Werner Koch Replaced all call gpg_error_from_errno(errno) by Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2006-09-18 09:28:58 UTC (rev 4251) +++ trunk/Makefile.am 2006-09-18 13:23:18 UTC (rev 4252) @@ -56,6 +56,16 @@ else scd = endif +if BUILD_TOOLS +scd = tools +else +scd = +endif +if BUILD_DOC +scd = doc +else +scd = +endif if HAVE_W32_SYSTEM tests = @@ -64,7 +74,7 @@ endif SUBDIRS = m4 intl gl jnlib common ${kbx} \ - ${gpg} ${keyserver} ${sm} ${agent} ${scd} tools po doc ${tests} + ${gpg} ${keyserver} ${sm} ${agent} ${scd} ${tools} po ${doc} ${tests} dist-hook: @set -e; \ Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-09-18 09:28:58 UTC (rev 4251) +++ trunk/NEWS 2006-09-18 13:23:18 UTC (rev 4252) @@ -1,4 +1,4 @@ -Noteworthy changes in version 1.9.23 +Noteworthy changes in version 1.9.23 (2006-09-18) ------------------------------------------------- * Regular man pages for most tools are now build directly from the @@ -7,7 +7,8 @@ * The gpg code from 1.4.5 has been fully merged into this release. The configure option --enable-gpg is still required to build this gpg part. For production use of OpenPGP the gpg version 1.4.5 is - still recommended. + still recommended. Note, that gpg will be installed under the name + gpg2 to allow coexisting with an 1.4.x gpg. * API change in gpg-agent's pkdecrypt command. Thus an older gpgsm may not be used with the current gpg-agent. Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-09-18 09:28:58 UTC (rev 4251) +++ trunk/configure.ac 2006-09-18 13:23:18 UTC (rev 4252) @@ -27,7 +27,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], [1.9.23]) -m4_define([my_issvn], [yes]) +m4_define([my_issvn], [no]) m4_define([svn_revision], m4_esyscmd([echo -n $((svn info 2>/dev/null \ @@ -80,6 +80,8 @@ GNUPG_BUILD_PROGRAM(gpgsm, yes) GNUPG_BUILD_PROGRAM(agent, yes) GNUPG_BUILD_PROGRAM(scdaemon, yes) +GNUPG_BUILD_PROGRAM(tools, yes) +GNUPG_BUILD_PROGRAM(doc, yes) GNUPG_BUILD_PROGRAM(symcryptrun, no) AC_SUBST(PACKAGE) @@ -154,7 +156,6 @@ AC_HELP_STRING([--enable-agent-only],[build only the gpg-agent]), build_agent_only=$enableval) - # SELinux support includes tracking of sensitive files to avoid # leaking their contents through processing these files by gpg itself AC_MSG_CHECKING([whether SELinux support is requested]) @@ -1218,6 +1219,8 @@ build_gpg=no build_gpgsm=no build_scdaemon=no + build_tools=no + build_doc=no fi @@ -1225,6 +1228,8 @@ AM_CONDITIONAL(BUILD_GPGSM, test "$build_gpgsm" = "yes") AM_CONDITIONAL(BUILD_AGENT, test "$build_agent" = "yes") AM_CONDITIONAL(BUILD_SCDAEMON, test "$build_scdaemon" = "yes") +AM_CONDITIONAL(BUILD_TOOLS, test "$build_tools" = "yes") +AM_CONDITIONAL(BUILD_DOC, test "$build_doc" = "yes") AM_CONDITIONAL(BUILD_SYMCRYPTRUN, test "$build_symcryptrun" = "yes") AM_CONDITIONAL(RUN_GPG_TESTS, Modified: trunk/doc/gpgsm.texi =================================================================== --- trunk/doc/gpgsm.texi 2006-09-18 09:28:58 UTC (rev 4251) +++ trunk/doc/gpgsm.texi 2006-09-18 13:23:18 UTC (rev 4252) @@ -849,13 +849,16 @@ successful @code{ENCRYPT} command. @example - INPUT FD=@var{n} [--armor|--base64|--binary] + INPUT FD[=@var{n}] [--armor|--base64|--binary] @end example Set the file descriptor for the message to be encrypted to @var{n}. Obviously the pipe must be open at that point, the server establishes its own end. If the server returns an error the client should consider -this session failed. +this session failed. If @var{n} is not given, this commands uses the +last file descriptor passed to the application. +@xref{fun-assuan_sendfd, ,the assuan_sendfd function,assuan,the Libassuan +manual}, on how to do descriptor passing. The @code{--armor} option may be used to advice the server that the input data is in @acronym{PEM} format, @code{--base64} advices that a @@ -865,7 +868,7 @@ correct. @example - OUTPUT FD=@var{n} [--armor|--base64] + OUTPUT FD[=@var{n}] [--armor|--base64] @end example Set the file descriptor to be used for the output (i.e. the encrypted @@ -923,13 +926,13 @@ Signing is usually done with these commands: @example - INPUT FD=@var{n} [--armor|--base64|--binary] + INPUT FD[=@var{n}] [--armor|--base64|--binary] @end example This tells @command{GPGSM} to read the data to sign from file descriptor @var{n}. @example - OUTPUT FD=@var{m} [--armor|--base64] + OUTPUT FD[=@var{m}] [--armor|--base64] @end example Write the output to file descriptor @var{m}. If a detached signature is Modified: trunk/po/de.po =================================================================== --- trunk/po/de.po 2006-09-18 09:28:58 UTC (rev 4251) +++ trunk/po/de.po 2006-09-18 13:23:18 UTC (rev 4252) @@ -10,7 +10,7 @@ msgstr "" "Project-Id-Version: gnupg2 1.9.18\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2006-09-06 17:28+0200\n" +"POT-Creation-Date: 2006-09-18 14:18+0200\n" "PO-Revision-Date: 2006-06-20 20:04+0200\n" "Last-Translator: Werner Koch \n" "Language-Team: de\n" @@ -34,12 +34,12 @@ msgid "run in daemon mode (background)" msgstr "Im Daemon Modus ausf?hren" -#: agent/gpg-agent.c:113 kbx/kbxutil.c:82 scd/scdaemon.c:107 sm/gpgsm.c:333 +#: agent/gpg-agent.c:113 kbx/kbxutil.c:82 scd/scdaemon.c:107 sm/gpgsm.c:334 #: tools/gpgconf.c:63 msgid "verbose" msgstr "ausf?hrlich" -#: agent/gpg-agent.c:114 kbx/kbxutil.c:83 scd/scdaemon.c:108 sm/gpgsm.c:334 +#: agent/gpg-agent.c:114 kbx/kbxutil.c:83 scd/scdaemon.c:108 sm/gpgsm.c:335 msgid "be somewhat more quiet" msgstr "Etwas weniger Ausgaben erzeugen" @@ -63,7 +63,7 @@ msgid "do not grab keyboard and mouse" msgstr "Tastatur und Maus nicht \"grabben\"" -#: agent/gpg-agent.c:124 scd/scdaemon.c:120 sm/gpgsm.c:336 +#: agent/gpg-agent.c:124 scd/scdaemon.c:120 sm/gpgsm.c:337 msgid "use a log file for the server" msgstr "Logausgaben in eine Datei umlenken" @@ -116,12 +116,12 @@ msgstr "|DATEI|Schreibe die Umgebungsvariabeln auf DATEI" #: agent/gpg-agent.c:236 agent/protect-tool.c:143 scd/scdaemon.c:188 -#: sm/gpgsm.c:513 tools/gpgconf.c:86 +#: sm/gpgsm.c:516 tools/gpgconf.c:86 msgid "Please report bugs to <" msgstr "Fehlerberichte bitte an <" #: agent/gpg-agent.c:236 agent/protect-tool.c:143 scd/scdaemon.c:188 -#: sm/gpgsm.c:513 tools/gpgconf.c:86 +#: sm/gpgsm.c:516 tools/gpgconf.c:86 msgid ">.\n" msgstr ">.\n" @@ -147,30 +147,30 @@ msgid "out of core while allocating %lu bytes" msgstr "" -#: agent/gpg-agent.c:334 scd/scdaemon.c:262 sm/gpgsm.c:642 +#: agent/gpg-agent.c:334 scd/scdaemon.c:262 sm/gpgsm.c:645 #, c-format msgid "invalid debug-level `%s' given\n" msgstr "ung?ltige Debugebene `%s' angegeben\n" #: agent/gpg-agent.c:505 agent/protect-tool.c:1073 kbx/kbxutil.c:432 -#: scd/scdaemon.c:354 sm/gpgsm.c:763 +#: scd/scdaemon.c:354 sm/gpgsm.c:766 #, c-format msgid "libgcrypt is too old (need %s, have %s)\n" msgstr "" "Die Bibliothek \"libgcrypt\" is zu alt (ben?tigt wird %s, vorhanden ist %s)\n" -#: agent/gpg-agent.c:599 scd/scdaemon.c:431 sm/gpgsm.c:865 +#: agent/gpg-agent.c:599 scd/scdaemon.c:431 sm/gpgsm.c:868 #, c-format msgid "NOTE: no default option file `%s'\n" msgstr "Notiz: Voreingestellte Konfigurationsdatei `%s' fehlt\n" #: agent/gpg-agent.c:604 agent/gpg-agent.c:1115 scd/scdaemon.c:436 -#: sm/gpgsm.c:869 +#: sm/gpgsm.c:872 #, c-format msgid "option file `%s': %s\n" msgstr "Konfigurationsdatei `%s': %s\n" -#: agent/gpg-agent.c:612 scd/scdaemon.c:444 sm/gpgsm.c:876 +#: agent/gpg-agent.c:612 scd/scdaemon.c:444 sm/gpgsm.c:879 #, c-format msgid "reading options from `%s'\n" msgstr "Optionen werden aus `%s' gelesen\n" @@ -230,40 +230,40 @@ msgid "handler 0x%lx for fd %d started\n" msgstr "Handhabungsroutine 0x%lx f?r fd %d gestartet\n" -#: agent/gpg-agent.c:1437 +#: agent/gpg-agent.c:1432 #, c-format msgid "handler 0x%lx for fd %d terminated\n" msgstr "Handhabungsroutine 0x%lx f?r den fd %d beendet\n" -#: agent/gpg-agent.c:1451 +#: agent/gpg-agent.c:1446 #, c-format msgid "ssh handler 0x%lx for fd %d started\n" msgstr "SSH Handhabungsroutine 0x%lx f?r fd %d gestartet\n" -#: agent/gpg-agent.c:1458 +#: agent/gpg-agent.c:1451 #, c-format msgid "ssh handler 0x%lx for fd %d terminated\n" msgstr "SSH Handhabungsroutine 0x%lx f?r fd %d beendet\n" -#: agent/gpg-agent.c:1552 scd/scdaemon.c:1110 +#: agent/gpg-agent.c:1545 scd/scdaemon.c:1110 #, c-format msgid "pth_select failed: %s - waiting 1s\n" msgstr "pth_select() Aufruf fehlgeschlagen: %s - warte 1s\n" -#: agent/gpg-agent.c:1636 scd/scdaemon.c:1167 +#: agent/gpg-agent.c:1629 scd/scdaemon.c:1167 #, c-format msgid "%s %s stopped\n" msgstr "%s %s angehalten\n" -#: agent/gpg-agent.c:1657 +#: agent/gpg-agent.c:1650 msgid "no gpg-agent running in this session\n" msgstr "Der gpg-agent l?uft nicht f?r diese Session\n" -#: agent/gpg-agent.c:1667 common/simple-pwquery.c:324 sm/call-agent.c:144 +#: agent/gpg-agent.c:1660 common/simple-pwquery.c:324 sm/call-agent.c:144 msgid "malformed GPG_AGENT_INFO environment variable\n" msgstr "Die Variable GPG_AGENT_INFO ist fehlerhaft\n" -#: agent/gpg-agent.c:1679 common/simple-pwquery.c:336 sm/call-agent.c:156 +#: agent/gpg-agent.c:1672 common/simple-pwquery.c:336 sm/call-agent.c:156 #, c-format msgid "gpg-agent protocol version %d is not supported\n" msgstr "Das gpg-agent Protocol %d wird nicht unterst?tzt\n" @@ -402,6 +402,46 @@ msgid "Passphrase" msgstr "Mantra" +#: agent/trustlist.c:109 agent/trustlist.c:267 +#, fuzzy, c-format +msgid "error opening `%s': %s\n" +msgstr "Fehler beim Erstellen von `%s': %s\n" + +#: agent/trustlist.c:124 +#, fuzzy, c-format +msgid "file `%s', line %d: %s\n" +msgstr "Konfigurationsdatei `%s': %s\n" + +#: agent/trustlist.c:144 agent/trustlist.c:152 +#, fuzzy, c-format +msgid "statement \"%s\" ignored in `%s', line %d\n" +msgstr "Ung?ltiger Landescode in `%s', Zeile %d\n" + +#: agent/trustlist.c:158 +#, c-format +msgid "system trustlist `%s' not available\n" +msgstr "" + +#: agent/trustlist.c:193 +#, fuzzy, c-format +msgid "bad fingerprint in `%s', line %d\n" +msgstr "Der Fingerabdruck in `%s', Zeile %d is fehlerhaft formatiert\n" + +#: agent/trustlist.c:211 agent/trustlist.c:218 +#, fuzzy, c-format +msgid "invalid keyflag in `%s', line %d\n" +msgstr "Ung?ltiger Landescode in `%s', Zeile %d\n" + +#: agent/trustlist.c:228 +#, fuzzy, c-format +msgid "error reading `%s', line %d: %s\n" +msgstr "Fehler beim Erstellen von `%s': %s\n" + +#: agent/trustlist.c:320 agent/trustlist.c:349 +#, fuzzy +msgid "error reading list of trusted root certificates\n" +msgstr "Fehler beim speichern des Zertifikats\n" + #. TRANSLATORS: This prompt is shown by the Pinentry #. and has one special property: A "%%0A" is used by #. Pinentry to insert a line break. The double @@ -411,7 +451,7 @@ #. second "%s" gets replaced by a hexdecimal #. fingerprint string whereas the first one receives #. the name as store in the certificate. -#: agent/trustlist.c:306 +#: agent/trustlist.c:424 #, c-format msgid "" "Please verify that the certificate identified as:%%0A \"%s\"%%0Ahas the " @@ -423,7 +463,7 @@ #. TRANSLATORS: "Correct" is the label of a button and intended to #. be hit if the fingerprint matches the one of the CA. The other #. button is "the default "Cancel" of the Pinentry. -#: agent/trustlist.c:318 +#: agent/trustlist.c:433 msgid "Correct" msgstr "Korrekt" @@ -435,7 +475,7 @@ #. plain % sign, you need to encode it as "%%25". The #. "%s" gets replaced by the name as store in the #. certificate. -#: agent/trustlist.c:335 +#: agent/trustlist.c:447 #, c-format msgid "" "Do you ultimately trust%%0A \"%s\"%%0Ato correctly certify user " @@ -444,11 +484,11 @@ "Wenn Sie vollst?ndiges Vertrauen haben, da?%%0A \"%s\"%%" "0ABenutzerzertifikate verl??lich zertifiziert, so antworten Sie mit \"Ja\"" -#: agent/trustlist.c:343 +#: agent/trustlist.c:453 msgid "Yes" msgstr "Ja" -#: agent/trustlist.c:343 +#: agent/trustlist.c:453 msgid "No" msgstr "Nein" @@ -499,7 +539,7 @@ msgid "you found a bug ... (%s:%d)\n" msgstr "Sie haben einen Bug (Softwarefehler) gefunden ... (%s:%d)\n" -#: kbx/kbxutil.c:69 sm/gpgsm.c:241 tools/gpgconf.c:54 +#: kbx/kbxutil.c:69 sm/gpgsm.c:242 tools/gpgconf.c:54 msgid "" "@Commands:\n" " " @@ -507,7 +547,7 @@ "@Kommandos:\n" " " -#: kbx/kbxutil.c:77 sm/gpgsm.c:276 tools/gpgconf.c:60 +#: kbx/kbxutil.c:77 sm/gpgsm.c:277 tools/gpgconf.c:60 msgid "" "@\n" "Options:\n" @@ -517,7 +557,7 @@ "Optionen:\n" " " -#: kbx/kbxutil.c:84 sm/gpgsm.c:342 tools/gpgconf.c:65 +#: kbx/kbxutil.c:84 sm/gpgsm.c:343 tools/gpgconf.c:65 msgid "do not make any changes" msgstr "Keine ?nderungen durchf?hren" @@ -553,7 +593,7 @@ msgid "run in multi server mode (foreground)" msgstr "Im Multiserver Modus ausf?hren" -#: scd/scdaemon.c:111 sm/gpgsm.c:354 +#: scd/scdaemon.c:111 sm/gpgsm.c:355 msgid "read options from file" msgstr "Konfigurationsoptionen aus Datei lesen" @@ -1035,7 +1075,7 @@ msgid "certificate `%s' not found: %s\n" msgstr "Zertifikat `%s' nicht gefunden: %s\n" -#: sm/delete.c:113 sm/keydb.c:1380 sm/keydb.c:1473 +#: sm/delete.c:113 sm/keydb.c:1384 sm/keydb.c:1477 #, c-format msgid "error locking keybox: %s\n" msgstr "Fehler beim Sperren der Keybox: %s\n" @@ -1063,47 +1103,47 @@ msgid "no valid recipients given\n" msgstr "Keine g?ltigen Empf?nger angegeben\n" -#: sm/gpgsm.c:243 +#: sm/gpgsm.c:244 msgid "|[FILE]|make a signature" msgstr "|[DATEI]|Erzeuge eine Signatur" -#: sm/gpgsm.c:244 +#: sm/gpgsm.c:245 msgid "|[FILE]|make a clear text signature" msgstr "|[DATEI]|Erzeuge eine Klartextsignatur" -#: sm/gpgsm.c:245 +#: sm/gpgsm.c:246 msgid "make a detached signature" msgstr "Erzeuge eine abgetrennte Signatur" -#: sm/gpgsm.c:246 +#: sm/gpgsm.c:247 msgid "encrypt data" msgstr "Verschl?ssele die Daten" -#: sm/gpgsm.c:247 +#: sm/gpgsm.c:248 msgid "encryption only with symmetric cipher" msgstr "Verschl?sselung nur mit symmetrischem Algrithmus" -#: sm/gpgsm.c:248 +#: sm/gpgsm.c:249 msgid "decrypt data (default)" msgstr "Enschl?ssele die Daten" -#: sm/gpgsm.c:249 +#: sm/gpgsm.c:250 msgid "verify a signature" msgstr "?berpr?fen einer Signatur" -#: sm/gpgsm.c:251 +#: sm/gpgsm.c:252 msgid "list keys" msgstr "Schl?ssel anzeigen" -#: sm/gpgsm.c:252 +#: sm/gpgsm.c:253 msgid "list external keys" msgstr "Externe Schl?ssel anzeigen" -#: sm/gpgsm.c:253 +#: sm/gpgsm.c:254 msgid "list secret keys" msgstr "Geheime Schl?ssel anzeigen" -#: sm/gpgsm.c:254 +#: sm/gpgsm.c:255 msgid "list certificate chain" msgstr "Schl?ssel mit Zertifikatekette anzeigen" @@ -1155,151 +1195,151 @@ msgid "change a passphrase" msgstr "Das Mantra (Passphrase) ?ndern" -#: sm/gpgsm.c:278 +#: sm/gpgsm.c:279 msgid "create ascii armored output" msgstr "Ausgabe mit ASCII H?lle wird erzeugt" -#: sm/gpgsm.c:280 +#: sm/gpgsm.c:281 msgid "create base-64 encoded output" msgstr "Ausgabe im Basis-64 format erzeugen" -#: sm/gpgsm.c:282 +#: sm/gpgsm.c:283 msgid "assume input is in PEM format" msgstr "Eingabedaten sind im PEM Format" -#: sm/gpgsm.c:284 +#: sm/gpgsm.c:285 msgid "assume input is in base-64 format" msgstr "Eingabedaten sind im Basis-64 Format" -#: sm/gpgsm.c:286 +#: sm/gpgsm.c:287 msgid "assume input is in binary format" msgstr "Eingabedaten sind im Bin?rformat" -#: sm/gpgsm.c:288 +#: sm/gpgsm.c:289 msgid "|NAME|encrypt for NAME" msgstr "|NAME|Verschl?sseln f?r NAME" -#: sm/gpgsm.c:291 +#: sm/gpgsm.c:292 msgid "use system's dirmngr if available" msgstr "Benutze den System Dirmngr when verf?gbar" -#: sm/gpgsm.c:292 +#: sm/gpgsm.c:293 msgid "never consult a CRL" msgstr "Niemals eine CRL konsultieren" -#: sm/gpgsm.c:299 +#: sm/gpgsm.c:300 msgid "check validity using OCSP" msgstr "Die G?ltigkeit mittels OCSP pr?fen" -#: sm/gpgsm.c:302 +#: sm/gpgsm.c:303 msgid "|N|number of certificates to include" msgstr "|N|Sende N Zertifikate mit" -#: sm/gpgsm.c:305 +#: sm/gpgsm.c:306 msgid "|FILE|take policy information from FILE" msgstr "|DATEI|Richtlinieninformationen DATEI entnehmen" -#: sm/gpgsm.c:308 +#: sm/gpgsm.c:309 msgid "do not check certificate policies" msgstr "Zertikikatrichtlinien nicht ?berpr?fen" -#: sm/gpgsm.c:312 +#: sm/gpgsm.c:313 msgid "fetch missing issuer certificates" msgstr "Fehlende Zertifikate automatisch holen" -#: sm/gpgsm.c:316 +#: sm/gpgsm.c:317 msgid "|NAME|use NAME as default recipient" msgstr "|NAME|Benutze NAME als voreingestellten Empf?nger" -#: sm/gpgsm.c:318 +#: sm/gpgsm.c:319 msgid "use the default key as default recipient" msgstr "Benuzte voreingestellten Schl?ssel als Standardempf?nger" -#: sm/gpgsm.c:324 +#: sm/gpgsm.c:325 msgid "use this user-id to sign or decrypt" msgstr "Benuzte diese Benutzer ID zum Signieren oder Entschl?sseln" -#: sm/gpgsm.c:327 +#: sm/gpgsm.c:328 msgid "|N|set compress level N (0 disables)" msgstr "|N|Benutze Komprimierungsstufe N" -#: sm/gpgsm.c:329 +#: sm/gpgsm.c:330 msgid "use canonical text mode" msgstr "Kanonischen Textmodus benutzen" -#: sm/gpgsm.c:332 tools/gpgconf.c:62 +#: sm/gpgsm.c:333 tools/gpgconf.c:62 msgid "use as output file" msgstr "als Ausgabedatei benutzen" -#: sm/gpgsm.c:335 +#: sm/gpgsm.c:336 msgid "don't use the terminal at all" msgstr "Das Terminal ?berhaupt nicht benutzen" -#: sm/gpgsm.c:339 +#: sm/gpgsm.c:340 msgid "force v3 signatures" msgstr "Version 3 Signaturen erzwingen" -#: sm/gpgsm.c:340 +#: sm/gpgsm.c:341 msgid "always use a MDC for encryption" msgstr "Immer das MDC Verfahren zum verschl?sseln mitbenutzen" -#: sm/gpgsm.c:345 +#: sm/gpgsm.c:346 msgid "batch mode: never ask" msgstr "Stapelverarbeitungs Modus: Nie nachfragen" -#: sm/gpgsm.c:346 +#: sm/gpgsm.c:347 msgid "assume yes on most questions" msgstr "\"Ja\" auf die meisten Anfragen annehmen" -#: sm/gpgsm.c:347 +#: sm/gpgsm.c:348 msgid "assume no on most questions" msgstr "\"Nein\" auf die meisten Anfragen annehmen" -#: sm/gpgsm.c:349 +#: sm/gpgsm.c:350 msgid "add this keyring to the list of keyrings" msgstr "Diesen Keyring in die Liste der Keyrings aufnehmen" -#: sm/gpgsm.c:350 +#: sm/gpgsm.c:351 msgid "add this secret keyring to the list" msgstr "Diese geheimen Keyring in die Liste aufnehmen" -#: sm/gpgsm.c:351 +#: sm/gpgsm.c:352 msgid "|NAME|use NAME as default secret key" msgstr "|NAME|Benutze NAME als voreingestellten Schl?ssel" -#: sm/gpgsm.c:352 +#: sm/gpgsm.c:353 msgid "|HOST|use this keyserver to lookup keys" msgstr "|HOST|Benutze HOST als Schl?sselserver" -#: sm/gpgsm.c:353 +#: sm/gpgsm.c:354 msgid "|NAME|set terminal charset to NAME" msgstr "|NAME|Den Zeichensatz f?r das Terminal auf NAME setzen" -#: sm/gpgsm.c:357 +#: sm/gpgsm.c:358 msgid "|LEVEL|set the debugging level to LEVEL" msgstr "|NAME|Die Debugstufe auf NAME setzen" -#: sm/gpgsm.c:365 +#: sm/gpgsm.c:366 msgid "|FD|write status info to this FD" msgstr "|FD|Statusinformationen auf Dateidescriptor FD schreiben" -#: sm/gpgsm.c:372 +#: sm/gpgsm.c:373 msgid "|FILE|load extension module FILE" msgstr "|DATEI|Das Erweiterungsmodul DATEI laden" -#: sm/gpgsm.c:378 +#: sm/gpgsm.c:379 msgid "|NAME|use cipher algorithm NAME" msgstr "|NAME|Den Verschl?sselungsalgrithmus NAME benutzen" -#: sm/gpgsm.c:380 +#: sm/gpgsm.c:381 msgid "|NAME|use message digest algorithm NAME" msgstr "|NAME|Den Hashalgorithmus NAME benutzen" -#: sm/gpgsm.c:382 +#: sm/gpgsm.c:383 msgid "|N|use compress algorithm N" msgstr "|N|Den Kompressionsalgorithmus Nummer N benutzen" -#: sm/gpgsm.c:390 +#: sm/gpgsm.c:391 msgid "" "@\n" "(See the man page for a complete listing of all commands and options)\n" @@ -1307,7 +1347,7 @@ "@\n" "(Die \"man\" Seite beschreibt alle Kommands und Optionen)\n" -#: sm/gpgsm.c:393 +#: sm/gpgsm.c:394 msgid "" "@\n" "Examples:\n" @@ -1327,11 +1367,11 @@ " --list-keys [Namen] Schl?ssel anzeigenn\n" " --fingerprint [Namen] \"Fingerabdr?cke\" anzeigen\\n\n" -#: sm/gpgsm.c:516 +#: sm/gpgsm.c:519 msgid "Usage: gpgsm [options] [files] (-h for help)" msgstr "Gebrauch: gpgsm [Optionen] [Dateien] (-h f?r Hilfe)" -#: sm/gpgsm.c:519 +#: sm/gpgsm.c:522 msgid "" "Syntax: gpgsm [options] [files]\n" "sign, check, encrypt or decrypt using the S/MIME protocol\n" @@ -1340,7 +1380,7 @@ "Gebrauch: gpgsm [Optionen] [Dateien]\n" "Signieren, pr?fen, ver- und entschl?sseln mittels S/MIME protocol\n" -#: sm/gpgsm.c:526 +#: sm/gpgsm.c:529 msgid "" "\n" "Supported algorithms:\n" @@ -1348,50 +1388,55 @@ "\n" "Unterst?tzte Algorithmen:\n" -#: sm/gpgsm.c:613 +#: sm/gpgsm.c:616 msgid "usage: gpgsm [options] " msgstr "Gebrauch: gpgsm [Optionen] " -#: sm/gpgsm.c:678 +#: sm/gpgsm.c:681 msgid "conflicting commands\n" msgstr "Widersprechende Kommandos\n" -#: sm/gpgsm.c:694 +#: sm/gpgsm.c:697 #, c-format msgid "can't encrypt to `%s': %s\n" msgstr "Verschl?sseln f?r `%s' nicht m?glich: %s\n" -#: sm/gpgsm.c:768 +#: sm/gpgsm.c:771 #, c-format msgid "libksba is too old (need %s, have %s)\n" msgstr "Die Bibliothek Libksba is nicht aktuell (ben?tige %s, habe %s)\n" -#: sm/gpgsm.c:1230 +#: sm/gpgsm.c:1234 msgid "WARNING: program may create a core file!\n" msgstr "WARNUNG: Programm k?nnte eine core-dump-Datei schreiben!\n" -#: sm/gpgsm.c:1247 +#: sm/gpgsm.c:1251 msgid "WARNING: running with faked system time: " msgstr "WARNUNG: Ausf?hrung mit gef?lschter Systemzeit: " -#: sm/gpgsm.c:1273 +#: sm/gpgsm.c:1277 msgid "selected cipher algorithm is invalid\n" msgstr "Das ausgew?hlte Verschl?sselungsverfahren ist ung?ltig\n" -#: sm/gpgsm.c:1281 +#: sm/gpgsm.c:1285 msgid "selected digest algorithm is invalid\n" msgstr "Das ausgew?hlte Hashverfahren ist ung?ltig\n" -#: sm/gpgsm.c:1311 +#: sm/gpgsm.c:1316 +#, fuzzy, c-format +msgid "importing common certificates `%s'\n" +msgstr "Fehler beim Importieren des Zertifikats: %s\n" + +#: sm/gpgsm.c:1334 #, c-format msgid "can't sign using `%s': %s\n" msgstr "Signieren mit `%s' nicht m?glich: %s\n" -#: sm/gpgsm.c:1495 +#: sm/gpgsm.c:1518 msgid "this command has not yet been implemented\n" msgstr "Dieses Kommando wurde noch nicht implementiert\n" -#: sm/gpgsm.c:1740 sm/gpgsm.c:1777 sm/qualified.c:74 +#: sm/gpgsm.c:1754 sm/gpgsm.c:1791 sm/qualified.c:74 #, c-format msgid "can't open `%s': %s\n" msgstr "Datei `%s' kann nicht ge?ffnet werden: %s\n" @@ -1459,59 +1504,59 @@ msgid "error reading input: %s\n" msgstr "Fehler beim Lesen der Eingabe: %s\n" -#: sm/keydb.c:188 +#: sm/keydb.c:190 #, c-format msgid "error creating keybox `%s': %s\n" msgstr "Die \"Keybox\" `%s' konnte nicht erstellt werden: %s\n" -#: sm/keydb.c:191 +#: sm/keydb.c:193 msgid "you may want to start the gpg-agent first\n" msgstr "Sie sollten zuerst den gpg-agent starten\n" -#: sm/keydb.c:196 +#: sm/keydb.c:198 #, c-format msgid "keybox `%s' created\n" msgstr "Die \"Keybox\" `%s' wurde erstellt\n" -#: sm/keydb.c:219 +#: sm/keydb.c:223 #, c-format msgid "can't create lock for `%s'\n" msgstr "Datei `%s' konnte nicht gesperrt werden\n" -#: sm/keydb.c:1300 sm/keydb.c:1366 +#: sm/keydb.c:1304 sm/keydb.c:1370 msgid "failed to get the fingerprint\n" msgstr "Kann den Fingerprint nicht ermitteln\n" -#: sm/keydb.c:1307 sm/keydb.c:1373 +#: sm/keydb.c:1311 sm/keydb.c:1377 msgid "failed to allocate keyDB handle\n" msgstr "Kann keinen KeyDB Handler bereitstellen\n" -#: sm/keydb.c:1328 +#: sm/keydb.c:1332 #, c-format msgid "problem looking for existing certificate: %s\n" msgstr "Problem bei der Suche nach vorhandenem Zertifikat: %s\n" -#: sm/keydb.c:1336 +#: sm/keydb.c:1340 #, c-format msgid "error finding writable keyDB: %s\n" msgstr "Fehler bei der Suche nach einer schreibbaren KeyDB: %s\n" -#: sm/keydb.c:1344 +#: sm/keydb.c:1348 #, c-format msgid "error storing certificate: %s\n" msgstr "Fehler beim Speichern des Zertifikats: %s\n" -#: sm/keydb.c:1388 +#: sm/keydb.c:1392 #, c-format msgid "problem re-searching certificate: %s\n" msgstr "Problem bei Wiederfinden des Zertifikats: %s\n" -#: sm/keydb.c:1397 sm/keydb.c:1485 +#: sm/keydb.c:1401 sm/keydb.c:1489 #, c-format msgid "error getting stored flags: %s\n" msgstr "Fehler beim Holen der gespeicherten Flags: %s\n" -#: sm/keydb.c:1406 sm/keydb.c:1496 +#: sm/keydb.c:1410 sm/keydb.c:1500 #, c-format msgid "error storing flags: %s\n" msgstr "Fehler beim Speichern der Flags: %s\n" From cvs at cvs.gnupg.org Mon Sep 18 15:38:14 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon Sep 18 14:52:53 2006 Subject: [svn] GnuPG - r4253 - tags Message-ID: Author: wk Date: 2006-09-18 15:38:13 +0200 (Mon, 18 Sep 2006) New Revision: 4253 Added: tags/gnupg-1.9.23/ Log: From cvs at cvs.gnupg.org Mon Sep 18 16:08:28 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon Sep 18 15:23:08 2006 Subject: [svn] GnuPG - r4254 - trunk Message-ID: Author: wk Date: 2006-09-18 16:08:27 +0200 (Mon, 18 Sep 2006) New Revision: 4254 Modified: trunk/NEWS trunk/configure.ac Log: Post release updates Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-09-18 13:38:13 UTC (rev 4253) +++ trunk/NEWS 2006-09-18 14:08:27 UTC (rev 4254) @@ -1,3 +1,8 @@ +Noteworthy changes in version 1.9.24 +------------------------------------------------- + + + Noteworthy changes in version 1.9.23 (2006-09-18) ------------------------------------------------- Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-09-18 13:38:13 UTC (rev 4253) +++ trunk/configure.ac 2006-09-18 14:08:27 UTC (rev 4254) @@ -26,8 +26,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.9.23]) -m4_define([my_issvn], [no]) +m4_define([my_version], [1.9.90]) +m4_define([my_issvn], [yes]) m4_define([svn_revision], m4_esyscmd([echo -n $((svn info 2>/dev/null \ From cvs at cvs.gnupg.org Mon Sep 18 20:01:21 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon Sep 18 19:16:05 2006 Subject: [svn] gpg-error - r182 - in trunk: . src Message-ID: Author: wk Date: 2006-09-18 20:01:21 +0200 (Mon, 18 Sep 2006) New Revision: 182 Modified: trunk/ChangeLog trunk/src/gpg-error.def Log: Added missing function. Reported by Simon Josefsson Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-09-14 14:40:20 UTC (rev 181) +++ trunk/ChangeLog 2006-09-18 18:01:21 UTC (rev 182) @@ -1,3 +1,7 @@ +2006-09-18 Werner Koch + + * src/gpg-error.def: Added gpg_err_code_from_syserror. + 2006-09-14 Werner Koch Released 1.4. Modified: trunk/src/gpg-error.def =================================================================== --- trunk/src/gpg-error.def 2006-09-14 14:40:20 UTC (rev 181) +++ trunk/src/gpg-error.def 2006-09-18 18:01:21 UTC (rev 182) @@ -6,3 +6,6 @@ gpg_err_code_from_errno @4 gpg_err_code_to_errno @5 gpg_err_init @6 + gpg_err_code_from_syserror @7 + + From cvs at cvs.gnupg.org Tue Sep 19 12:16:59 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue Sep 19 11:31:36 2006 Subject: [svn] assuan - r203 - trunk/src Message-ID: Author: marcus Date: 2006-09-19 12:16:59 +0200 (Tue, 19 Sep 2006) New Revision: 203 Modified: trunk/src/ChangeLog trunk/src/assuan-defs.h Log: 2006-09-19 Marcus Brinkmann * assuan-defs.h (unsetenv): Define correctly. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2006-09-14 11:23:01 UTC (rev 202) +++ trunk/src/ChangeLog 2006-09-19 10:16:59 UTC (rev 203) @@ -1,3 +1,7 @@ +2006-09-19 Marcus Brinkmann + + * assuan-defs.h (unsetenv): Define correctly. + 2006-09-14 Werner Koch * assuan-io.c (_assuan_waitpid): New. Changed all waitpid calls Modified: trunk/src/assuan-defs.h =================================================================== --- trunk/src/assuan-defs.h 2006-09-14 11:23:01 UTC (rev 202) +++ trunk/src/assuan-defs.h 2006-09-19 10:16:59 UTC (rev 203) @@ -294,7 +294,7 @@ #endif #ifndef HAVE_SETENV #define setenv _assuan_setenv -#define unsetenv _assuan_setenv +#define unsetenv _assuan_unsetenv #define clearenv _assuan_clearenv int setenv (const char *name, const char *value, int replace); #endif From cvs at cvs.gnupg.org Tue Sep 19 12:17:51 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue Sep 19 11:32:26 2006 Subject: [svn] assuan - r204 - trunk/src Message-ID: Author: marcus Date: 2006-09-19 12:17:51 +0200 (Tue, 19 Sep 2006) New Revision: 204 Modified: trunk/src/ChangeLog trunk/src/assuan-buffer.c trunk/src/assuan-client.c trunk/src/assuan-defs.h trunk/src/mkerrors Log: 2006-09-19 Marcus Brinkmann * mkerrors (_assuan_error): Change return type to assuan_error_t. * assuan-buffer.c (_assuan_read_line): Change return type to assuan_error_t. Map returned value of -1. (_assuan_write_line): Change type of RC to assuan_error_t. * assuan-defs.h (_assuan_read_line, _assuan_error): Likewise for prototypes. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2006-09-19 10:16:59 UTC (rev 203) +++ trunk/src/ChangeLog 2006-09-19 10:17:51 UTC (rev 204) @@ -1,5 +1,12 @@ 2006-09-19 Marcus Brinkmann + * mkerrors (_assuan_error): Change return type to assuan_error_t. + * assuan-buffer.c (_assuan_read_line): Change return type to + assuan_error_t. Map returned value of -1. + (_assuan_write_line): Change type of RC to assuan_error_t. + * assuan-defs.h (_assuan_read_line, _assuan_error): Likewise for + prototypes. + * assuan-defs.h (unsetenv): Define correctly. 2006-09-14 Werner Koch Modified: trunk/src/assuan-buffer.c =================================================================== --- trunk/src/assuan-buffer.c 2006-09-19 10:16:59 UTC (rev 203) +++ trunk/src/assuan-buffer.c 2006-09-19 10:17:51 UTC (rev 204) @@ -95,7 +95,7 @@ /* Function returns an Assuan error. */ -int +assuan_error_t _assuan_read_line (assuan_context_t ctx) { char *line = ctx->inbound.line; @@ -104,7 +104,7 @@ char *endp = 0; if (ctx->inbound.eof) - return -1; + return _assuan_error (-1); atticlen = ctx->inbound.attic.linelen; if (atticlen) @@ -243,7 +243,7 @@ _assuan_write_line (assuan_context_t ctx, const char *prefix, const char *line, size_t len) { - int rc = 0; + assuan_error_t rc = 0; size_t prefixlen = prefix? strlen (prefix):0; /* Make sure that the line is short enough. */ Modified: trunk/src/assuan-client.c =================================================================== --- trunk/src/assuan-client.c 2006-09-19 10:16:59 UTC (rev 203) +++ trunk/src/assuan-client.c 2006-09-19 10:17:51 UTC (rev 204) @@ -139,7 +139,8 @@ int (*status_cb)(void*, const char *), void *status_cb_arg) { - int rc, okay, off; + assuan_error_t rc; + int okay, off; char *line; int linelen; Modified: trunk/src/assuan-defs.h =================================================================== --- trunk/src/assuan-defs.h 2006-09-19 10:16:59 UTC (rev 203) +++ trunk/src/assuan-defs.h 2006-09-19 10:17:51 UTC (rev 204) @@ -200,7 +200,7 @@ int _assuan_register_std_commands (assuan_context_t ctx); /*-- assuan-buffer.c --*/ -int _assuan_read_line (assuan_context_t ctx); +assuan_error_t _assuan_read_line (assuan_context_t ctx); int _assuan_cookie_write_data (void *cookie, const char *buffer, size_t size); int _assuan_cookie_write_flush (void *cookie); assuan_error_t _assuan_write_line (assuan_context_t ctx, const char *prefix, @@ -215,7 +215,7 @@ /* Map error codes as used in this implementaion to the libgpg-error codes. */ -int _assuan_error (int oldcode); +assuan_error_t _assuan_error (int oldcode); /* Extrac the erro code from A. This works for both the old and the new style error codes. This needs to be whenever an error code is Modified: trunk/src/mkerrors =================================================================== --- trunk/src/mkerrors 2006-09-19 10:16:59 UTC (rev 203) +++ trunk/src/mkerrors 2006-09-19 10:17:51 UTC (rev 204) @@ -52,7 +52,7 @@ /* Helper to map old style Assuan error codes to gpg-error codes. This is used internally to keep an compatible ABI. */ -int +assuan_error_t _assuan_error (int oldcode) { unsigned int n; From cvs at cvs.gnupg.org Tue Sep 19 12:31:31 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue Sep 19 11:46:07 2006 Subject: [svn] assuan - r205 - trunk/src Message-ID: Author: marcus Date: 2006-09-19 12:31:31 +0200 (Tue, 19 Sep 2006) New Revision: 205 Modified: trunk/src/ChangeLog trunk/src/assuan.h Log: 2006-09-19 Marcus Brinkmann * assuan.h (enum): Avoid trailing comma in enumerator list. Ugh. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2006-09-19 10:17:51 UTC (rev 204) +++ trunk/src/ChangeLog 2006-09-19 10:31:31 UTC (rev 205) @@ -1,5 +1,7 @@ 2006-09-19 Marcus Brinkmann + * assuan.h (enum): Avoid trailing comma in enumerator list. Ugh. + * mkerrors (_assuan_error): Change return type to assuan_error_t. * assuan-buffer.c (_assuan_read_line): Change return type to assuan_error_t. Map returned value of -1. Modified: trunk/src/assuan.h =================================================================== --- trunk/src/assuan.h 2006-09-19 10:17:51 UTC (rev 204) +++ trunk/src/assuan.h 2006-09-19 10:31:31 UTC (rev 205) @@ -241,8 +241,9 @@ ASSUAN_Invalid_Data = 117, #endif ASSUAN_Unexpected_Command = 118, - ASSUAN_Too_Much_Data = 119, + ASSUAN_Too_Much_Data = 119 #ifndef _ASSUAN_IN_LIBASSUAN + , /* Avoid trailing comma in enumerator list. */ ASSUAN_Inquire_Unknown = 120, ASSUAN_Inquire_Error = 121, ASSUAN_Invalid_Option = 122, From cvs at cvs.gnupg.org Tue Sep 19 12:34:16 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue Sep 19 11:48:49 2006 Subject: [svn] assuan - r206 - trunk/src Message-ID: Author: marcus Date: 2006-09-19 12:34:16 +0200 (Tue, 19 Sep 2006) New Revision: 206 Modified: trunk/src/ChangeLog trunk/src/assuan-pipe-connect.c trunk/src/assuan-socket.c Log: 2006-09-19 Marcus Brinkmann * assuan-pipe-connect.c: Add hacks for Slowaris. * assuan-socket.c: Likewise here. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2006-09-19 10:31:31 UTC (rev 205) +++ trunk/src/ChangeLog 2006-09-19 10:34:16 UTC (rev 206) @@ -1,5 +1,8 @@ 2006-09-19 Marcus Brinkmann + * assuan-pipe-connect.c: Add hacks for Slowaris. + * assuan-socket.c: Likewise here. + * assuan.h (enum): Avoid trailing comma in enumerator list. Ugh. * mkerrors (_assuan_error): Change return type to assuan_error_t. Modified: trunk/src/assuan-pipe-connect.c =================================================================== --- trunk/src/assuan-pipe-connect.c 2006-09-19 10:31:31 UTC (rev 205) +++ trunk/src/assuan-pipe-connect.c 2006-09-19 10:34:16 UTC (rev 206) @@ -39,6 +39,18 @@ #include "assuan-defs.h" +/* Hacks for Slowaris. */ +#ifndef PF_LOCAL +# ifdef PF_UNIX +# define PF_LOCAL PF_UNIX +# else +# define PF_LOCAL AF_UNIX +# endif +#endif +#ifndef AF_LOCAL +# define AF_LOCAL AF_UNIX +#endif + #ifdef _POSIX_OPEN_MAX #define MAX_OPEN_FDS _POSIX_OPEN_MAX #else Modified: trunk/src/assuan-socket.c =================================================================== --- trunk/src/assuan-socket.c 2006-09-19 10:31:31 UTC (rev 205) +++ trunk/src/assuan-socket.c 2006-09-19 10:34:16 UTC (rev 206) @@ -30,6 +30,18 @@ #endif #include "assuan-defs.h" +/* Hacks for Slowaris. */ +#ifndef PF_LOCAL +# ifdef PF_UNIX +# define PF_LOCAL PF_UNIX +# else +# define PF_LOCAL AF_UNIX +# endif +#endif +#ifndef AF_LOCAL +# define AF_LOCAL AF_UNIX +#endif + int _assuan_close (int fd) { From cvs at cvs.gnupg.org Tue Sep 19 12:46:58 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue Sep 19 12:01:36 2006 Subject: [svn] assuan - r207 - in trunk: . tests Message-ID: Author: marcus Date: 2006-09-19 12:46:58 +0200 (Tue, 19 Sep 2006) New Revision: 207 Added: trunk/tests/motd Modified: trunk/ChangeLog trunk/tests/Makefile.am trunk/tests/fdpassing.c Log: 2006-09-19 Marcus Brinkmann * tests/fdpassing.c (MOTD): New macro. * tests/Makefile.am (AM_CPPFLAGS): New variable. * tests/motd: New file. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-09-19 10:34:16 UTC (rev 206) +++ trunk/ChangeLog 2006-09-19 10:46:58 UTC (rev 207) @@ -1,3 +1,9 @@ +2006-09-19 Marcus Brinkmann + + * tests/fdpassing.c (MOTD): New macro. + * tests/Makefile.am (AM_CPPFLAGS): New variable. + * tests/motd: New file. + 2006-09-14 Werner Koch Released 0.9.0. Modified: trunk/tests/Makefile.am =================================================================== --- trunk/tests/Makefile.am 2006-09-19 10:34:16 UTC (rev 206) +++ trunk/tests/Makefile.am 2006-09-19 10:46:58 UTC (rev 207) @@ -29,6 +29,7 @@ TESTS = fdpassing +AM_CPPFLAGS = -DSRCDIR=$(srcdir) AM_CFLAGS = # $(GPG_ERROR_CFLAGS) noinst_HEADERS = common.h Modified: trunk/tests/fdpassing.c =================================================================== --- trunk/tests/fdpassing.c 2006-09-19 10:34:16 UTC (rev 206) +++ trunk/tests/fdpassing.c 2006-09-19 10:46:58 UTC (rev 207) @@ -32,6 +32,13 @@ #include "../src/assuan.h" #include "common.h" +#ifndef SRCDIR +#define SRCDIR "/etc" +#endif +#define STRINGIFY2(str) #str +#define STRINGIFY(str) STRINGIFY2(str) +#define MOTD STRINGIFY(SRCDIR) "/motd" + /* @@ -159,10 +166,10 @@ for (i=0; i < 6; i++) { - fp = fopen ("/etc/motd", "r"); + fp = fopen (MOTD, "r"); if (!fp) { - log_error ("failed to open `%s': %s\n", "/etc/motd", + log_error ("failed to open `%s': %s\n", MOTD, strerror (errno)); return -1; } Added: trunk/tests/motd =================================================================== --- trunk/tests/motd 2006-09-19 10:34:16 UTC (rev 206) +++ trunk/tests/motd 2006-09-19 10:46:58 UTC (rev 207) @@ -0,0 +1,9 @@ +Big Brother trust@unlimited.com 0.4.2-TC #1 PREEMPT Thu Aug 3 02:52:00 UTC 2006 TC Lockinos + +The programs included monitor each and every keystroke by its users +and report them back for evaluation. Use of this software is entirely +voluntary, but non-compliance results in reducing the machine to an +expensive paper-weight. + +There is no warranty whatsoever, and should we have made a mistake, we will +come and sue you for taking advantage of that. From cvs at cvs.gnupg.org Tue Sep 19 12:58:49 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue Sep 19 12:13:28 2006 Subject: [svn] assuan - r208 - in trunk: . doc src tests Message-ID: Author: wk Date: 2006-09-19 12:58:48 +0200 (Tue, 19 Sep 2006) New Revision: 208 Modified: trunk/ChangeLog trunk/NEWS trunk/configure.ac trunk/doc/Makefile.am trunk/doc/assuan.texi trunk/src/ChangeLog trunk/src/assuan-defs.h trunk/src/assuan-pipe-connect.c trunk/src/assuan-socket-server.c trunk/src/assuan.h trunk/src/mkerrors trunk/tests/Makefile.am trunk/tests/fdpassing.c Log: Fixed problems Nelson H. F. Beebe reported when doing build tests on several platforms. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-09-19 10:46:58 UTC (rev 207) +++ trunk/ChangeLog 2006-09-19 10:58:48 UTC (rev 208) @@ -1,3 +1,10 @@ +2006-09-19 Werner Koch + + * tests/fdpassing.c: Reverted Marcus changes. + (client): New arg FNAME to replace hardwired file name. + (main): Pass motd to client. + * tests/Makefile.am (AM_CPPFLAGS): Removed. + 2006-09-19 Marcus Brinkmann * tests/fdpassing.c (MOTD): New macro. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-09-19 10:46:58 UTC (rev 207) +++ trunk/NEWS 2006-09-19 10:58:48 UTC (rev 208) @@ -1,3 +1,7 @@ +Noteworthy changes in version 0.9.1 +------------------------------------------------ + + Noteworthy changes in version 0.9.0 (2006-09-14) ------------------------------------------------ Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-09-19 10:46:58 UTC (rev 207) +++ trunk/configure.ac 2006-09-19 10:58:48 UTC (rev 208) @@ -25,7 +25,7 @@ # Version number: Remember to change it immediately *after* a release. # Add a "-cvs" prefix for non-released code. -AC_INIT(libassuan, 0.9.0, gnupg-devel@gnupg.org) +AC_INIT(libassuan, 0.9.1-cvs, gnupg-devel@gnupg.org) # Note, that this is not yet available as a shared library. PACKAGE=$PACKAGE_NAME Modified: trunk/doc/Makefile.am =================================================================== --- trunk/doc/Makefile.am 2006-09-19 10:46:58 UTC (rev 207) +++ trunk/doc/Makefile.am 2006-09-19 10:58:48 UTC (rev 208) @@ -23,3 +23,12 @@ assuan_TEXINFOS = lgpl.texi gpl.texi + +online: assuan.html assuan.pdf + set -e; \ + echo "Uploading current manuals to www.gnupg.org ..."; \ + user=werner ; \ + (cd assuan.html && rsync -vr --exclude='.svn' . \ + $${user}@cvs.gnupg.org:webspace/manuals/assuan/ ); \ + rsync -v assuan.pdf $${user}@cvs.gnupg.org:webspace/manuals/ + Modified: trunk/doc/assuan.texi =================================================================== --- trunk/doc/assuan.texi 2006-09-19 10:46:58 UTC (rev 207) +++ trunk/doc/assuan.texi 2006-09-19 10:58:48 UTC (rev 208) @@ -745,6 +745,7 @@ /* 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")). */ +@anchor{fun-assuan_sendfd} assuan_error_t assuan_sendfd (assuan_context_t ctx, int fd); assuan_error_t assuan_receivefd (assuan_context_t ctx, int *fd); Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2006-09-19 10:46:58 UTC (rev 207) +++ trunk/src/ChangeLog 2006-09-19 10:58:48 UTC (rev 208) @@ -1,3 +1,13 @@ +2006-09-19 Werner Koch + + * assuan-defs.h (putc_unlocked): Add prototype. + + * assuan-socket-server.c (accept_connection): Made LEN a socklen_t. + + * assuan.h: Replaced assuan error code enum by simple defines and + made assuan_error_t an int. + * mkerrors: Changed parser accordingly. + 2006-09-19 Marcus Brinkmann * assuan-pipe-connect.c: Add hacks for Slowaris. @@ -895,7 +905,7 @@ * assuan-defs.h: Add space in the context for this. - Copyright 2001, 2002 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/src/assuan-defs.h =================================================================== --- trunk/src/assuan-defs.h 2006-09-19 10:46:58 UTC (rev 207) +++ trunk/src/assuan-defs.h 2006-09-19 10:58:48 UTC (rev 208) @@ -298,8 +298,10 @@ #define clearenv _assuan_clearenv int setenv (const char *name, const char *value, int replace); #endif +#ifndef HAVE_PUTC_UNLOCKED +int putc_unlocked (int c, FILE *stream) +#endif - #define DIM(v) (sizeof(v)/sizeof((v)[0])) #define DIMof(type,member) DIM(((type *)0)->member) Modified: trunk/src/assuan-pipe-connect.c =================================================================== --- trunk/src/assuan-pipe-connect.c 2006-09-19 10:46:58 UTC (rev 207) +++ trunk/src/assuan-pipe-connect.c 2006-09-19 10:58:48 UTC (rev 208) @@ -51,6 +51,7 @@ # define AF_LOCAL AF_UNIX #endif + #ifdef _POSIX_OPEN_MAX #define MAX_OPEN_FDS _POSIX_OPEN_MAX #else @@ -332,7 +333,7 @@ setenv ("_assuan_pipe_connect_pid", mypidstr, 1); /* Make sure that we never pass a connection fd variable - when using a simple pipe. */ + when using a simple pipe. */ unsetenv ("_assuan_connection_fd"); execv (name, (char *const *) argv); Modified: trunk/src/assuan-socket-server.c =================================================================== --- trunk/src/assuan-socket-server.c 2006-09-19 10:46:58 UTC (rev 207) +++ trunk/src/assuan-socket-server.c 2006-09-19 10:58:48 UTC (rev 208) @@ -85,7 +85,7 @@ { int fd; struct sockaddr_un clnt_addr; - size_t len = sizeof clnt_addr; + socklen_t len = sizeof clnt_addr; fd = accept (ctx->listen_fd, (struct sockaddr*)&clnt_addr, &len ); if (fd == -1) Modified: trunk/src/assuan.h =================================================================== --- trunk/src/assuan.h 2006-09-19 10:46:58 UTC (rev 207) +++ trunk/src/assuan.h 2006-09-19 10:58:48 UTC (rev 208) @@ -188,105 +188,103 @@ /* Assuan error codes. These are only used by old applications or those applications which won't make use of libgpg-error. */ #ifndef _ASSUAN_ONLY_GPG_ERRORS -typedef enum -{ #ifndef _ASSUAN_IN_LIBASSUAN - ASSUAN_No_Error = 0, +#define ASSUAN_No_Error 0 #endif - ASSUAN_General_Error = 1, - ASSUAN_Out_Of_Core = 2, - ASSUAN_Invalid_Value = 3, +#define ASSUAN_General_Error 1 +#define ASSUAN_Out_Of_Core 2 +#define ASSUAN_Invalid_Value 3 #ifndef _ASSUAN_IN_LIBASSUAN - ASSUAN_Timeout = 4, +#define ASSUAN_Timeout 4 #endif - ASSUAN_Read_Error = 5, - ASSUAN_Write_Error = 6, - ASSUAN_Problem_Starting_Server = 7, - ASSUAN_Not_A_Server = 8, +#define ASSUAN_Read_Error 5 +#define ASSUAN_Write_Error 6 +#define ASSUAN_Problem_Starting_Server 7 +#define ASSUAN_Not_A_Server 8 #ifndef _ASSUAN_IN_LIBASSUAN - ASSUAN_Not_A_Client = 9, +#define ASSUAN_Not_A_Client 9 #endif - ASSUAN_Nested_Commands = 10, - ASSUAN_Invalid_Response = 11, - ASSUAN_No_Data_Callback = 12, - ASSUAN_No_Inquire_Callback = 13, - ASSUAN_Connect_Failed = 14, - ASSUAN_Accept_Failed = 15, +#define ASSUAN_Nested_Commands 10 +#define ASSUAN_Invalid_Response 11 +#define ASSUAN_No_Data_Callback 12 +#define ASSUAN_No_Inquire_Callback 13 +#define ASSUAN_Connect_Failed 14 +#define ASSUAN_Accept_Failed 15 /* Error codes above 99 are meant as status codes */ - ASSUAN_Not_Implemented = 100, - ASSUAN_Server_Fault = 101, +#define ASSUAN_Not_Implemented 100 +#define ASSUAN_Server_Fault 101 #ifndef _ASSUAN_IN_LIBASSUAN - ASSUAN_Invalid_Command = 102, +#define ASSUAN_Invalid_Command 102 #endif - ASSUAN_Unknown_Command = 103, - ASSUAN_Syntax_Error = 104, +#define ASSUAN_Unknown_Command 103 +#define ASSUAN_Syntax_Error 104 #ifndef _ASSUAN_IN_LIBASSUAN - ASSUAN_Parameter_Error = 105, +#define ASSUAN_Parameter_Error 105 #endif - ASSUAN_Parameter_Conflict = 106, - ASSUAN_Line_Too_Long = 107, - ASSUAN_Line_Not_Terminated = 108, +#define ASSUAN_Parameter_Conflict 106 +#define ASSUAN_Line_Too_Long 107 +#define ASSUAN_Line_Not_Terminated 108 #ifndef _ASSUAN_IN_LIBASSUAN - ASSUAN_No_Input = 109, - ASSUAN_No_Output = 110, +#define ASSUAN_No_Input 109 +#define ASSUAN_No_Output 110 #endif - ASSUAN_Canceled = 111, +#define ASSUAN_Canceled 111 #ifndef _ASSUAN_IN_LIBASSUAN - ASSUAN_Unsupported_Algorithm = 112, - ASSUAN_Server_Resource_Problem = 113, - ASSUAN_Server_IO_Error = 114, - ASSUAN_Server_Bug = 115, - ASSUAN_No_Data_Available = 116, - ASSUAN_Invalid_Data = 117, +#define ASSUAN_Unsupported_Algorithm 112 +#define ASSUAN_Server_Resource_Problem 113 +#define ASSUAN_Server_IO_Error 114 +#define ASSUAN_Server_Bug 115 +#define ASSUAN_No_Data_Available 116 +#define ASSUAN_Invalid_Data 117 #endif - ASSUAN_Unexpected_Command = 118, - ASSUAN_Too_Much_Data = 119 +#define ASSUAN_Unexpected_Command 118 +#define ASSUAN_Too_Much_Data 119 #ifndef _ASSUAN_IN_LIBASSUAN - , /* Avoid trailing comma in enumerator list. */ - ASSUAN_Inquire_Unknown = 120, - ASSUAN_Inquire_Error = 121, - ASSUAN_Invalid_Option = 122, - ASSUAN_Invalid_Index = 123, - ASSUAN_Unexpected_Status = 124, - ASSUAN_Unexpected_Data = 125, - ASSUAN_Invalid_Status = 126, - ASSUAN_Locale_Problem = 127, - ASSUAN_Not_Confirmed = 128, +#define ASSUAN_Inquire_Unknown 120 +#define ASSUAN_Inquire_Error 121 +#define ASSUAN_Invalid_Option 122 +#define ASSUAN_Invalid_Index 123 +#define ASSUAN_Unexpected_Status 124 +#define ASSUAN_Unexpected_Data 125 +#define ASSUAN_Invalid_Status 126 +#define ASSUAN_Locale_Problem 127 +#define ASSUAN_Not_Confirmed 128 /* Warning: Don't use the Error codes, below they are deprecated. */ - ASSUAN_Bad_Certificate = 201, - ASSUAN_Bad_Certificate_Chain = 202, - ASSUAN_Missing_Certificate = 203, - ASSUAN_Bad_Signature = 204, - ASSUAN_No_Agent = 205, - ASSUAN_Agent_Error = 206, - ASSUAN_No_Public_Key = 207, - ASSUAN_No_Secret_Key = 208, - ASSUAN_Invalid_Name = 209, +#define ASSUAN_Bad_Certificate 201 +#define ASSUAN_Bad_Certificate_Chain 202 +#define ASSUAN_Missing_Certificate 203 +#define ASSUAN_Bad_Signature 204 +#define ASSUAN_No_Agent 205 +#define ASSUAN_Agent_Error 206 +#define ASSUAN_No_Public_Key 207 +#define ASSUAN_No_Secret_Key 208 +#define ASSUAN_Invalid_Name 209 - ASSUAN_Cert_Revoked = 301, - ASSUAN_No_CRL_For_Cert = 302, - ASSUAN_CRL_Too_Old = 303, - ASSUAN_Not_Trusted = 304, +#define ASSUAN_Cert_Revoked 301 +#define ASSUAN_No_CRL_For_Cert 302 +#define ASSUAN_CRL_Too_Old 303 +#define ASSUAN_Not_Trusted 304 - ASSUAN_Card_Error = 401, - ASSUAN_Invalid_Card = 402, - ASSUAN_No_PKCS15_App = 403, - ASSUAN_Card_Not_Present = 404, - ASSUAN_Invalid_Id = 405, +#define ASSUAN_Card_Error 401 +#define ASSUAN_Invalid_Card 402 +#define ASSUAN_No_PKCS15_App 403 +#define ASSUAN_Card_Not_Present 404 +#define ASSUAN_Invalid_Id 405 /* Error codes in the range 1000 to 9999 may be used by applications at their own discretion. */ - ASSUAN_USER_ERROR_FIRST = 1000, - ASSUAN_USER_ERROR_LAST = 9999 +#define ASSUAN_USER_ERROR_FIRST 1000 +#define ASSUAN_USER_ERROR_LAST 9999 #endif -} assuan_error_t; -typedef assuan_error_t AssuanError; /* Deprecated. */ +typedef int assuan_error_t; +typedef assuan_error_t AssuanError _ASSUAN_DEPRECATED; + /* This is a list of pre-registered ASSUAN commands */ -/* NOTE, these command IDs are now deprectated and solely exists for +/* Note, these command IDs are now deprectated and solely exists for compatibility reasons. */ typedef enum { Modified: trunk/src/mkerrors =================================================================== --- trunk/src/mkerrors 2006-09-19 10:46:58 UTC (rev 207) +++ trunk/src/mkerrors 2006-09-19 10:58:48 UTC (rev 208) @@ -140,7 +140,7 @@ * Return value: String with the error description. **/ const char * -assuan_strerror (AssuanError err) +assuan_strerror (assuan_error_t err) { const char *s; static char buf[50]; @@ -150,11 +150,10 @@ EOF awk ' -/ASSUAN_No_Error/ { okay=1 } -!okay {next} -/}/ { exit 0 } -/^#/ {next} -/ASSUAN_[A-Za-z_]*/ { print_code($1) } +/ASSUAN_No_Error/ { okay=1 } +!okay {next} +/^#define[ ]+ASSUAN_[A-Za-z_]*/ { print_code($2) } +/ASSUAN_USER_ERROR_LAST/ { exit 0 } function print_code( s ) Modified: trunk/tests/Makefile.am =================================================================== --- trunk/tests/Makefile.am 2006-09-19 10:46:58 UTC (rev 207) +++ trunk/tests/Makefile.am 2006-09-19 10:58:48 UTC (rev 208) @@ -29,7 +29,6 @@ TESTS = fdpassing -AM_CPPFLAGS = -DSRCDIR=$(srcdir) AM_CFLAGS = # $(GPG_ERROR_CFLAGS) noinst_HEADERS = common.h Modified: trunk/tests/fdpassing.c =================================================================== --- trunk/tests/fdpassing.c 2006-09-19 10:46:58 UTC (rev 207) +++ trunk/tests/fdpassing.c 2006-09-19 10:58:48 UTC (rev 208) @@ -32,13 +32,6 @@ #include "../src/assuan.h" #include "common.h" -#ifndef SRCDIR -#define SRCDIR "/etc" -#endif -#define STRINGIFY2(str) #str -#define STRINGIFY(str) STRINGIFY2(str) -#define MOTD STRINGIFY(SRCDIR) "/motd" - /* @@ -65,7 +58,6 @@ log_error ("fdopen failed on input fd: %s\n", strerror (errno)); return ASSUAN_General_Error; } - log_info ("printing input to stdout:\n"); nbytes = 0; while ( (c=getc (fp)) != -1) { @@ -155,7 +147,7 @@ /* Client main. If true is returned, a disconnect has not been done. */ static int -client (assuan_context_t ctx) +client (assuan_context_t ctx, const char *fname) { int rc; FILE *fp; @@ -166,10 +158,10 @@ for (i=0; i < 6; i++) { - fp = fopen (MOTD, "r"); + fp = fopen (fname, "r"); if (!fp) { - log_error ("failed to open `%s': %s\n", MOTD, + log_error ("failed to open `%s': %s\n", fname, strerror (errno)); return -1; } @@ -217,16 +209,13 @@ main (int argc, char **argv) { int last_argc = -1; - const char *srcdir = getenv ("srcdir"); assuan_context_t ctx; int err; int no_close_fds[2]; const char *arglist[10]; int is_server = 0; int with_exec = 0; - - if (!srcdir) - srcdir = "."; + char *fname = prepend_srcdir ("motd"); if (argc) { @@ -269,6 +258,7 @@ } } + assuan_set_assuan_log_prefix (log_prefix); assuan_set_assuan_log_stream (stderr); @@ -304,7 +294,7 @@ } else { - if (client (ctx)) + if (client (ctx, fname)) { log_info ("waiting for server to terminate...\n"); assuan_disconnect (ctx); From cvs at cvs.gnupg.org Tue Sep 19 13:00:46 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue Sep 19 12:15:29 2006 Subject: [svn] assuan - r209 - in trunk: . tests Message-ID: Author: wk Date: 2006-09-19 13:00:46 +0200 (Tue, 19 Sep 2006) New Revision: 209 Modified: trunk/ChangeLog trunk/tests/Makefile.am Log: distribute motd Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-09-19 10:58:48 UTC (rev 208) +++ trunk/ChangeLog 2006-09-19 11:00:46 UTC (rev 209) @@ -4,6 +4,7 @@ (client): New arg FNAME to replace hardwired file name. (main): Pass motd to client. * tests/Makefile.am (AM_CPPFLAGS): Removed. + (EXTRA_DIST): Add motd. 2006-09-19 Marcus Brinkmann Modified: trunk/tests/Makefile.am =================================================================== --- trunk/tests/Makefile.am 2006-09-19 10:58:48 UTC (rev 208) +++ trunk/tests/Makefile.am 2006-09-19 11:00:46 UTC (rev 209) @@ -22,7 +22,7 @@ TESTS_ENVIRONMENT = -EXTRA_DIST = +EXTRA_DIST = motd BUILT_SOURCES = CLEANFILES = From cvs at cvs.gnupg.org Tue Sep 19 15:34:49 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue Sep 19 14:49:28 2006 Subject: [svn] assuan - r210 - trunk/src Message-ID: Author: marcus Date: 2006-09-19 15:34:48 +0200 (Tue, 19 Sep 2006) New Revision: 210 Modified: trunk/src/ChangeLog trunk/src/assuan.h Log: 2006-09-19 Marcus Brinkmann * assuan.h (assuan_init_socket_server_ext) [_ASSUAN_EXT_SYM_PREFIX]: Fix typo in macro. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2006-09-19 11:00:46 UTC (rev 209) +++ trunk/src/ChangeLog 2006-09-19 13:34:48 UTC (rev 210) @@ -1,3 +1,8 @@ +2006-09-19 Marcus Brinkmann + + * assuan.h (assuan_init_socket_server_ext) + [_ASSUAN_EXT_SYM_PREFIX]: Fix typo in macro. + 2006-09-19 Werner Koch * assuan-defs.h (putc_unlocked): Add prototype. Modified: trunk/src/assuan.h =================================================================== --- trunk/src/assuan.h 2006-09-19 11:00:46 UTC (rev 209) +++ trunk/src/assuan.h 2006-09-19 13:34:48 UTC (rev 210) @@ -92,7 +92,7 @@ #define assuan_init_connected_socket_server \ _ASSUAN_PREFIX(assuan_init_connected_socket_server) #define assuan_init_socket_server_ext \ - _ASSUAN_PREFIX(assuan_init_socket_server-ext) + _ASSUAN_PREFIX(assuan_init_socket_server_ext) #define assuan_pipe_connect _ASSUAN_PREFIX(assuan_pipe_connect) #define assuan_pipe_connect_ext _ASSUAN_PREFIX(assuan_pipe_connect_ext) #define assuan_socket_connect _ASSUAN_PREFIX(assuan_socket_connect) From cvs at cvs.gnupg.org Tue Sep 19 16:53:30 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue Sep 19 16:08:05 2006 Subject: [svn] GnuPG - r4255 - trunk/keyserver Message-ID: Author: wk Date: 2006-09-19 16:53:30 +0200 (Tue, 19 Sep 2006) New Revision: 4255 Added: trunk/keyserver/no-libgcrypt.c Modified: trunk/keyserver/ChangeLog trunk/keyserver/Makefile.am Log: Added stub library Modified: trunk/keyserver/ChangeLog =================================================================== --- trunk/keyserver/ChangeLog 2006-09-18 14:08:27 UTC (rev 4254) +++ trunk/keyserver/ChangeLog 2006-09-19 14:53:30 UTC (rev 4255) @@ -1,3 +1,8 @@ +2006-09-19 Werner Koch + + * no-libgcrypt.c: New. Taken from ../tools. + * Makefile.am: Add no-libgcrypt to all sources. + 2006-09-06 Marcus Brinkmann * Makefile.am (AM_CFLAGS): Add $(GPG_ERROR_CFLAGS). Modified: trunk/keyserver/Makefile.am =================================================================== --- trunk/keyserver/Makefile.am 2006-09-18 14:08:27 UTC (rev 4254) +++ trunk/keyserver/Makefile.am 2006-09-19 14:53:30 UTC (rev 4255) @@ -35,10 +35,10 @@ needed_libs = ../gl/libgnu.a ../common/libcommon.a ../jnlib/libjnlib.a other_libs = $(LIBICONV) $(LIBINTL) $(CAPLIBS) -gpg2keys_ldap_SOURCES = gpgkeys_ldap.c ksutil.c ksutil.h -gpg2keys_hkp_SOURCES = gpgkeys_hkp.c ksutil.c ksutil.h -gpg2keys_finger_SOURCES = gpgkeys_finger.c ksutil.c ksutil.h -gpg2keys_curl_SOURCES = gpgkeys_curl.c ksutil.c ksutil.h +gpg2keys_ldap_SOURCES = gpgkeys_ldap.c ksutil.c ksutil.h no-libgcrypt.c +gpg2keys_hkp_SOURCES = gpgkeys_hkp.c ksutil.c ksutil.h no-libgcrypt.c +gpg2keys_finger_SOURCES = gpgkeys_finger.c ksutil.c ksutil.h no-libgcrypt.c +gpg2keys_curl_SOURCES = gpgkeys_curl.c ksutil.c ksutil.h no-libgcrypt.c gpg2keys_ldap_CPPFLAGS = $(LDAP_CPPFLAGS) $(AM_CPPFLAGS) Added: trunk/keyserver/no-libgcrypt.c =================================================================== --- trunk/keyserver/no-libgcrypt.c 2006-09-18 14:08:27 UTC (rev 4254) +++ trunk/keyserver/no-libgcrypt.c 2006-09-19 14:53:30 UTC (rev 4255) @@ -0,0 +1,113 @@ +/* no-libgcrypt.c - Replacement functions for libgcrypt. + * Copyright (C) 2003 Free Software Foundation, Inc. + * + * This file is part of GnuPG. + * + * GnuPG 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. + * + * GnuPG 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + */ + +#include +#include +#include +#include +#include + +#include "../common/util.h" +#include "i18n.h" + + +/* Replace libgcrypt's malloc functions which are used by + ../jnlib/libjnlib.a . ../common/util.h defines macros to map them + to xmalloc etc. */ +static void +out_of_memory (void) +{ + fprintf (stderr, "error allocating enough memory: %s\n", strerror (errno)); + exit (2); +} + + +void * +gcry_malloc (size_t n) +{ + return malloc (n); +} + +void * +gcry_xmalloc (size_t n) +{ + void *p = malloc (n); + if (!p) + out_of_memory (); + return p; +} + +char * +gcry_strdup (const char *string) +{ + return malloc (strlen (string)+1); +} + + +void * +gcry_realloc (void *a, size_t n) +{ + return realloc (a, n); +} + +void * +gcry_xrealloc (void *a, size_t n) +{ + void *p = realloc (a, n); + if (!p) + out_of_memory (); + return p; +} + + + +void * +gcry_calloc (size_t n, size_t m) +{ + return calloc (n, m); +} + +void * +gcry_xcalloc (size_t n, size_t m) +{ + void *p = calloc (n, m); + if (!p) + out_of_memory (); + return p; +} + + +char * +gcry_xstrdup (const char *string) +{ + void *p = malloc (strlen (string)+1); + if (!p) + out_of_memory (); + strcpy( p, string ); + return p; +} + +void +gcry_free (void *a) +{ + if (a) + free (a); +} From cvs at cvs.gnupg.org Tue Sep 19 18:25:51 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue Sep 19 17:40:27 2006 Subject: [svn] GnuPG - r4256 - in trunk: . doc Message-ID: Author: wk Date: 2006-09-19 18:25:51 +0200 (Tue, 19 Sep 2006) New Revision: 4256 Modified: trunk/TODO trunk/doc/ChangeLog trunk/doc/Makefile.am trunk/doc/gpg.texi Log: Some restructuring Modified: trunk/TODO =================================================================== --- trunk/TODO 2006-09-19 14:53:30 UTC (rev 4255) +++ trunk/TODO 2006-09-19 16:25:51 UTC (rev 4256) @@ -119,4 +119,5 @@ * Extend selinux support to other modules - +* Missing dependencies on libcommon. + parallel builds fail. Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2006-09-19 14:53:30 UTC (rev 4255) +++ trunk/doc/ChangeLog 2006-09-19 16:25:51 UTC (rev 4256) @@ -1,3 +1,9 @@ +2006-09-19 Werner Koch + + * gpg.texi: Some restructuring. + + * Makefile.am (online): New target. + 2006-09-18 Werner Koch * com-certs.pem: New. Modified: trunk/doc/Makefile.am =================================================================== --- trunk/doc/Makefile.am 2006-09-19 14:53:30 UTC (rev 4255) +++ trunk/doc/Makefile.am 2006-09-19 16:25:51 UTC (rev 4256) @@ -125,3 +125,12 @@ fi; \ fi + +online: gnupg.html gnupg.pdf + set -e; \ + echo "Uploading current manuals to www.gnupg.org ..."; \ + user=werner ; \ + (cd gnupg.html && rsync -vr --exclude='.svn' . \ + $${user}@cvs.gnupg.org:webspace/manuals/gnupg/ ); \ + rsync -v gnupg.pdf $${user}@cvs.gnupg.org:webspace/manuals/ + Modified: trunk/doc/gpg.texi =================================================================== --- trunk/doc/gpg.texi 2006-09-19 14:53:30 UTC (rev 4255) +++ trunk/doc/gpg.texi 2006-09-19 16:25:51 UTC (rev 4256) @@ -800,7 +800,7 @@ Please remember that option parsing stops as soon as a non-option is encountered, you can explicitly stop parsing by using the special option -"--". +@code{--}. @c ******************************************* @c ******** CONFIGURATION OPTIONS ********** @@ -813,163 +813,274 @@ @table @gnupgtabopt -@item XXX -foo +@item --default-key @var{name} +@opindex default-key +Use @var{name} as the default key to sign with. If this option is not +used, the default key is the first key found in the secret keyring. +Note that -u or --local-user overrides this option. -@end table +@item --default-recipient @var{name} +@opindex default-recipient +Use @var{name} as default recipient if option --recipient is not used +and don't ask if this is a valid one. @var{name} must be non-empty. +@item --default-recipient-self +@opindex default-recipient-self +Use the default key as default recipient if option --recipient is not +used and don't ask if this is a valid one. The default key is the first +one from the secret keyring or the one set with --default-key. -@c ******************************************* -@c ******** KEY RELATED OPTIONS ************ -@c ******************************************* -@node GPG Key related Options -@subsection Key related options +@item --no-default-recipient +@opindex no-default-recipient +Reset --default-recipient and --default-recipient-self. -@table @gnupgtabopt +@item -v, --verbose +@opindex verbose +Give more information during processing. If used +twice, the input data is listed in detail. -@item XXX -foo +@item --no-verbose +@opindex no-verbose +Reset verbose level to 0. -@end table +@item -q, --quiet +@opindex quiet +Try to be as quiet as possible. -@c ******************************************* -@c ******** INPUT AND OUTPUT *************** -@c ******************************************* -@node GPG Input and Output -@subsection Input and Output +@item --list-options @code{parameters} +@opindex list-options +This is a space or comma delimited string that gives options used when +listing keys and signatures (that is, --list-keys, --list-sigs, +--list-public-keys, --list-secret-keys, and the --edit-key functions). +Options can be prepended with a `no-' to give the opposite meaning. +The options are: -@table @gnupgtabopt +@table @asis -@item XXX -foo +@item show-photos +@opindex list-options:show-photos +Causes --list-keys, --list-sigs, --list-public-keys, and +--list-secret-keys to display any photo IDs attached to the key. +Defaults to no. See also --photo-viewer. +@item show-policy-urls +@opindex list-options:show-policy-urls +Show policy URLs in the --list-sigs or --check-sigs listings. +Defaults to no. + +@item show-notations +@itemx show-std-notations +@itemx show-user-notations +@opindex list-options:show-notations +@opindex list-options:show-std-notations +@opindex list-options:show-user-notations +Show all, IETF standard, or user-defined signature notations in the +--list-sigs or --check-sigs listings. Defaults to no. + +@item show-keyserver-urls + +Show any preferred keyserver URL in the --list-sigs or --check-sigs +listings. Defaults to no. + +@item show-uid-validity +Display the calculated validity of user IDs during key listings. +Defaults to no. + +@item show-unusable-uids +Show revoked and expired user IDs in key listings. Defaults to no. + +@item show-unusable-subkeys +Show revoked and expired subkeys in key listings. Defaults to no. + +@item show-keyring +Display the keyring name at the head of key listings to show which +keyring a given key resides on. Defaults to no. + +@item show-sig-expire +Show signature expiration dates (if any) during --list-sigs or +--check-sigs listings. Defaults to no. + +@item show-sig-subpackets +Include signature subpackets in the key listing. This option can take +an optional argument list of the subpackets to list. If no argument +is passed, list all subpackets. Defaults to no. This option is only +meaningful when using --with-colons along with --list-sigs or +--check-sigs. @end table -@c ******************************************* -@c ******** OPENPGP OPTIONS **************** -@c ******************************************* -@node OpenPGP Options -@subsection OpenPGP protocol specific options. +@item --verify-options @code{parameters} +This is a space or comma delimited string that gives options used when +verifying signatures. Options can be prepended with a `no-' to give +the opposite meaning. The options are: -@table @gnupgtabopt +@table @asis -@item XXX -foo +@item show-photos +Display any photo IDs present on the key that issued the signature. +Defaults to no. See also --photo-viewer. +@item show-policy-urls +Show policy URLs in the signature being verified. Defaults to no. + +@item show-notations +@itemx show-std-notations +@itemx show-user-notations +Show all, IETF standard, or user-defined signature notations in the +signature being verified. Defaults to IETF standard. + +@item show-keyserver-urls +Show any preferred keyserver URL in the signature being verified. +Defaults to no. + +@item show-uid-validity +Display the calculated validity of the user IDs on the key that issued +the signature. Defaults to no. + +@item show-unusable-uids +Show revoked and expired user IDs during signature verification. +Defaults to no. + +@item pka-lookups +Enable PKA lookups to verify sender addresses. Note that PKA is based +on DNS, and so enabling this option may disclose information on when +and what signatures are verified or to whom data is encrypted. This +is similar to the "web bug" described for the auto-key-retrieve +feature. + +@item pka-trust-increase +Raise the trust in a signature to full if the signature passes PKA +validation. This option is only meaningful if pka-lookups is set. @end table -@c ******************************************* -@c ******** ESOTERIC OPTIONS *************** -@c ******************************************* -@node GPG Esoteric Options -@subsection Doing things one usually don't want to do. +@item --enable-dsa2 +@itemx --disable-dsa2 +Enables new-style DSA keys which (unlike the old style) may be larger +than 1024 bit and use hashes other than SHA-1 and RIPEMD/160. Note +that very few programs currently support these keys and signatures +from them. -@table @gnupgtabopt +@item --photo-viewer @code{string} +This is the command line that should be run to view a photo ID. "%i" +will be expanded to a filename containing the photo. "%I" does the +same, except the file will not be deleted once the viewer exits. +Other flags are "%k" for the key ID, "%K" for the long key ID, "%f" +for the key fingerprint, "%t" for the extension of the image type +(e.g. "jpg"), "%T" for the MIME type of the image (e.g. "image/jpeg"), +and "%%" for an actual percent sign. If neither %i or %I are present, +then the photo will be supplied to the viewer on standard input. -@item XXX -foo +The default viewer is "xloadimage -fork -quiet -title 'KeyID 0x%k' +stdin". Note that if your image viewer program is not secure, then +executing it from GnuPG does not make it secure. +@item --exec-path @code{string} +Sets a list of directories to search for photo viewers and keyserver +helpers. If not provided, keyserver helpers use the compiled-in +default directory, and photo viewers use the $PATH environment +variable. +Note, that on W32 system this value is ignored when searching for +keyserver helpers. -@item --armor -@itemx -a -@opindex armor -Create ASCII armored output. The default is to create the binary -OpenPGP format. +@item --keyring @code{file} +Add @code{file} to the current list of keyrings. If @code{file} begins +with a tilde and a slash, these are replaced by the $HOME +directory. If the filename does not contain a slash, it is assumed to +be in the GnuPG home directory ("~/.gnupg" if --homedir or $GNUPGHOME +is not used). -@item --output @var{file} -@itemx -o @var{file} -@opindex output -Write output to @var{file}. +Note that this adds a keyring to the current list. If the intent is +to use the specified keyring alone, use --keyring along with +--no-default-keyring. -@item --max-output @code{n} -@opindex max-output -This option sets a limit on the number of bytes that will be generated -when processing a file. Since OpenPGP supports various levels of -compression, it is possible that the plaintext of a given message may be -significantly larger than the original OpenPGP message. While GnuPG -works properly with such messages, there is often a desire to set a -maximum file size that will be generated before processing is forced to -stop by the OS limits. Defaults to 0, which means "no limit". +@item --secret-keyring @code{file} +Same as --keyring but for the secret keyrings. -@item --mangle-dos-filenames -@itemx --no-mangle-dos-filenames -@opindex mangle-dos-filenames -@opindex no-mangle-dos-filenames -Older version of Windows cannot handle filenames with more than one -dot. --mangle-dos-filenames causes GnuPG to replace (rather than add to) -the extension of an output filename to avoid this problem. This option -is off by default and has no effect on non-Windows platforms. +@item --primary-keyring @code{file} +Designate @code{file} as the primary public keyring. This means that +newly imported keys (via --import or keyserver --recv-from) will go to +this keyring. -@item --local-user @var{name} -@itemx -u -@opindex local-user -Use @var{name} as the key to sign with. Note that this option overrides ---default-key. +@item --trustdb-name @code{file} +Use @code{file} instead of the default trustdb. If @code{file} begins +with a tilde and a slash, these are replaced by the $HOME +directory. If the filename does not contain a slash, it is assumed to +be in the GnuPG home directory ("~/.gnupg" if --homedir or $GNUPGHOME +is not used). -@item --default-key @var{name} -@opindex default-key -Use @var{name} as the default key to sign with. If this option is not -used, the default key is the first key found in the secret keyring. -Note that -u or --local-user overrides this option. +@include opt-homedir.texi -@item --recipient @var{name} -@itemx -r -@opindex recipient -Encrypt for user id @var{name}. If this option or --hidden-recipient is -not specified, GnuPG asks for the user-id unless --default-recipient is -given. -@item --hidden-recipient @var{name} -@itemx -R -@opindex hidden-recipient -Encrypt for user ID @var{name}, but hide the key ID of this user's -key. This option helps to hide the receiver of the message and is a -limited countermeasure against traffic analysis. If this option or ---recipient is not specified, GnuPG asks for the user ID unless ---default-recipient is given. +@item --pcsc-driver @code{file} +Use @code{file} to access the smartcard reader. The current default is +`libpcsclite.so.1' for GLIBC based systems, +`/System/Library/Frameworks/PCSC.framework/PCSC' for MAC OS X, +`winscard.dll' for Windows and `libpcsclite.so' for other systems. -@item --default-recipient @var{name} -@opindex default-recipient -Use @var{name} as default recipient if option --recipient is not used -and don't ask if this is a valid one. @var{name} must be non-empty. +@item --disable-ccid +Disable the integrated support for CCID compliant readers. This +allows to fall back to one of the other drivers even if the internal +CCID driver can handle the reader. Note, that CCID support is only +available if libusb was available at build time. -@item --default-recipient-self -@opindex default-recipient-self -Use the default key as default recipient if option --recipient is not -used and don't ask if this is a valid one. The default key is the first -one from the secret keyring or the one set with --default-key. +@item --reader-port @code{number_or_string} +This option may be used to specify the port of the card terminal. A +value of 0 refers to the first serial device; add 32768 to access USB +devices. The default is 32768 (first USB device). PC/SC or CCID +readers might need a string here; run the program in verbose mode to get +a list of available readers. The default is then the first reader +found. -@item --no-default-recipient -@opindex no-default-recipient -Reset --default-recipient and --default-recipient-self. +@item --display-charset @code{name} +Set the name of the native character set. This is used to convert +some informational strings like user IDs to the proper UTF-8 encoding. +Note that this has nothing to do with the character set of data to be +encrypted or signed; GnuPG does not recode user supplied data. If +this option is not used, the default character set is determined from +the current locale. A verbosity level of 3 shows the chosen set. +Valid values for @code{name} are: -@item --encrypt-to @code{name} -Same as --recipient but this one is intended for use -in the options file and may be used with -your own user-id as an "encrypt-to-self". These keys -are only used when there are other recipients given -either by use of --recipient or by the asked user id. -No trust checking is performed for these user ids and -even disabled keys can be used. +@table @asis -@item --hidden-encrypt-to @code{name} -Same as --hidden-recipient but this one is intended for use in the -options file and may be used with your own user-id as a hidden -"encrypt-to-self". These keys are only used when there are other -recipients given either by use of --recipient or by the asked user id. -No trust checking is performed for these user ids and even disabled -keys can be used. +@item iso-8859-1 +This is the Latin 1 set. -@item --no-encrypt-to -Disable the use of all --encrypt-to and --hidden-encrypt-to keys. +@item iso-8859-2 +The Latin 2 set. -@item -v, --verbose -Give more information during processing. If used -twice, the input data is listed in detail. +@item iso-8859-15 +This is currently an alias for +the Latin 1 set. -@item -q, --quiet -Try to be as quiet as possible. +@item koi8-r +The usual Russian set (rfc1489). +@item utf-8 +Bypass all translations and assume +that the OS uses native UTF-8 encoding. +@end table + +@item --utf8-strings +@itemx --no-utf8-strings +Assume that command line arguments are given as UTF8 strings. The +default (--no-utf8-strings) is to assume that arguments are encoded in +the character set as specified by --display-charset. These options +affect all following arguments. Both options may be used multiple +times. + +@item --options @code{file} +Read options from @code{file} and do not try to read +them from the default options file in the homedir +(see --homedir). This option is ignored if used +in an options file. + +@item --no-options +Shortcut for "--options /dev/null". This option is +detected before an attempt to open an option file. +Using this option will also prevent the creation of a +"~./gnupg" homedir. + + + @item -z @code{n} @itemx --compress-level @code{n} @itemx --bzip2-compress-level @code{n} @@ -988,45 +1099,17 @@ circumstances when the file was originally compressed at a high --bzip2-compress-level. -@item -t, --textmode -@itemx --no-textmode -Treat input files as text and store them in the OpenPGP canonical text -form with standard "CRLF" line endings. This also sets the necessary -flags to inform the recipient that the encrypted or signed data is -text and may need its line endings converted back to whatever the -local system uses. This option is useful when communicating between -two platforms that have different line ending conventions (UNIX-like -to Mac, Mac to Windows, etc). --no-textmode disables this option, and -is the default. -If -t (but not --textmode) is used together with armoring and signing, -this enables clearsigned messages. This kludge is needed for -command-line compatibility with command-line versions of PGP; normally -you would use --sign or --clearsign to select the type of the -signature. -@item -n, --dry-run -Don't make any changes (this is not completely implemented). +@item --mangle-dos-filenames +@itemx --no-mangle-dos-filenames +@opindex mangle-dos-filenames +@opindex no-mangle-dos-filenames +Older version of Windows cannot handle filenames with more than one +dot. --mangle-dos-filenames causes GnuPG to replace (rather than add to) +the extension of an output filename to avoid this problem. This option +is off by default and has no effect on non-Windows platforms. -@item -i, --interactive -Prompt before overwriting any files. - -@item --batch -@itemx --no-batch -Use batch mode. Never ask, do not allow interactive commands. ---no-batch disables this option. - -@item --no-tty -Make sure that the TTY (terminal) is never used for any output. -This option is needed in some cases because GnuPG sometimes prints -warnings to the TTY if --batch is used. - -@item --yes -Assume "yes" on most questions. - -@item --no -Assume "no" on most questions. - @item --ask-cert-level @itemx --no-ask-cert-level When making a key signature, prompt for a certification level. If @@ -1108,9 +1191,6 @@ exists. @end table -@item --always-trust -Identical to `--trust-model always'. This option is deprecated. - @item --auto-key-locate @code{parameters} @itemx --no-auto-key-locate GnuPG can automatically locate and retrieve keys as needed using this @@ -1163,7 +1243,7 @@ Most keyservers synchronize with each other, so there is generally no need to send keys to more than one server. The keyserver -"hkp://subkeys.pgp.net" uses round robin DNS to give a different +@code{hkp://subkeys.pgp.net} uses round robin DNS to give a different keyserver each time you use it. @item --keyserver-options @code{name=value1 } @@ -1253,6 +1333,268 @@ Defaults to 16384 bytes. @end table +@item --completes-needed @code{n} +Number of completely trusted users to introduce a new +key signer (defaults to 1). + +@item --marginals-needed @code{n} +Number of marginally trusted users to introduce a new +key signer (defaults to 3) + +@item --max-cert-depth @code{n} +Maximum depth of a certification chain (default is 5). + +@item --simple-sk-checksum +Secret keys are integrity protected by using a SHA-1 checksum. This +method is part of the upcoming enhanced OpenPGP specification but +GnuPG already uses it as a countermeasure against certain attacks. +Old applications don't understand this new format, so this option may +be used to switch back to the old behaviour. Using this option bears +a security risk. Note that using this option only takes effect when +the secret key is encrypted - the simplest way to make this happen is +to change the passphrase on the key (even changing it to the same +value is acceptable). + +@item --no-sig-cache +Do not cache the verification status of key signatures. +Caching gives a much better performance in key listings. However, if +you suspect that your public keyring is not save against write +modifications, you can use this option to disable the caching. It +probably does not make sense to disable it because all kind of damage +can be done if someone else has write access to your public keyring. + +@item --no-sig-create-check +GnuPG normally verifies each signature right after creation to protect +against bugs and hardware malfunctions which could leak out bits from +the secret key. This extra verification needs some time (about 115% +for DSA keys), and so this option can be used to disable it. +However, due to the fact that the signature creation needs manual +interaction, this performance penalty does not matter in most settings. + +@item --auto-check-trustdb +@itemx --no-auto-check-trustdb +If GnuPG feels that its information about the Web of Trust has to be +updated, it automatically runs the --check-trustdb command internally. +This may be a time consuming process. --no-auto-check-trustdb +disables this option. + +@item --use-agent +@itemx --no-use-agent +Try to use the GnuPG-Agent. Please note that this agent is still under +development. With this option, GnuPG first tries to connect to the +agent before it asks for a passphrase. --no-use-agent disables this +option. + +@item --gpg-agent-info +Override the value of the environment variable +@samp{GPG_AGENT_INFO}. This is only used when --use-agent has been given + +@item --lock-once +Lock the databases the first time a lock is requested +and do not release the lock until the process +terminates. + +@item --lock-multiple +Release the locks every time a lock is no longer +needed. Use this to override a previous --lock-once +from a config file. + +@item --lock-never +Disable locking entirely. This option should be used only in very +special environments, where it can be assured that only one process +is accessing those files. A bootable floppy with a stand-alone +encryption system will probably use this. Improper usage of this +option may lead to data and key corruption. + +@item --exit-on-status-write-error +This option will cause write errors on the status FD to immediately +terminate the process. That should in fact be the default but it +never worked this way and thus we need an option to enable this, so +that the change won't break applications which close their end of a +status fd connected pipe too early. Using this option along with +--enable-progress-filter may be used to cleanly cancel long running +gpg operations. + +@item --limit-card-insert-tries @code{n} +With @code{n} greater than 0 the number of prompts asking to insert a +smartcard gets limited to N-1. Thus with a value of 1 gpg won't at +all ask to insert a card if none has been inserted at startup. This +option is useful in the configuration file in case an application does +not know about the smartcard support and waits ad infinitum for an +inserted card. + +@item --no-random-seed-file +GnuPG uses a file to store its internal random pool over invocations. +This makes random generation faster; however sometimes write operations +are not desired. This option can be used to achieve that with the cost of +slower random generation. + +@item --no-greeting +Suppress the initial copyright message. + +@item --no-secmem-warning +Suppress the warning about "using insecure memory". + +@item --no-permission-warning +Suppress the warning about unsafe file and home directory (--homedir) +permissions. Note that the permission checks that GnuPG performs are +not intended to be authoritative, but rather they simply warn about +certain common permission problems. Do not assume that the lack of a +warning means that your system is secure. + +Note that the warning for unsafe --homedir permissions cannot be +suppressed in the gpg.conf file, as this would allow an attacker to +place an unsafe gpg.conf file in place, and use this file to suppress +warnings about itself. The --homedir permissions warning may only be +suppressed on the command line. + +@item --no-mdc-warning +Suppress the warning about missing MDC integrity protection. + +@item --require-secmem +@itemx --no-require-secmem +Refuse to run if GnuPG cannot get secure memory. Defaults to no +(i.e. run, but give a warning). + + +@item --require-cross-certification +@itemx --no-require-cross-certification +When verifying a signature made from a subkey, ensure that the cross +certification "back signature" on the subkey is present and valid. +This protects against a subtle attack against subkeys that can sign. +Defaults to --require-cross-certification for @command{gpg2}. + +@item --expert +@itemx --no-expert +Allow the user to do certain nonsensical or "silly" things like +signing an expired or revoked key, or certain potentially incompatible +things like generating unusual key types. This also disables certain +warning messages about potentially incompatible actions. As the name +implies, this option is for experts only. If you don't fully +understand the implications of what it allows you to do, leave this +off. --no-expert disables this option. + + + + +@end table + + +@c ******************************************* +@c ******** KEY RELATED OPTIONS ************ +@c ******************************************* +@node GPG Key related Options +@subsection Key related options + +@table @gnupgtabopt + +@item --recipient @var{name} +@itemx -r +@opindex recipient +Encrypt for user id @var{name}. If this option or --hidden-recipient is +not specified, GnuPG asks for the user-id unless --default-recipient is +given. + +@item --hidden-recipient @var{name} +@itemx -R +@opindex hidden-recipient +Encrypt for user ID @var{name}, but hide the key ID of this user's +key. This option helps to hide the receiver of the message and is a +limited countermeasure against traffic analysis. If this option or +--recipient is not specified, GnuPG asks for the user ID unless +--default-recipient is given. + +@item --encrypt-to @code{name} +Same as --recipient but this one is intended for use +in the options file and may be used with +your own user-id as an "encrypt-to-self". These keys +are only used when there are other recipients given +either by use of --recipient or by the asked user id. +No trust checking is performed for these user ids and +even disabled keys can be used. + +@item --hidden-encrypt-to @code{name} +Same as --hidden-recipient but this one is intended for use in the +options file and may be used with your own user-id as a hidden +"encrypt-to-self". These keys are only used when there are other +recipients given either by use of --recipient or by the asked user id. +No trust checking is performed for these user ids and even disabled +keys can be used. + +@item --no-encrypt-to +Disable the use of all --encrypt-to and --hidden-encrypt-to keys. + +@item --group @code{name=value1 } +Sets up a named group, which is similar to aliases in email programs. +Any time the group name is a recipient (-r or --recipient), it will be +expanded to the values specified. Multiple groups with the same name +are automatically merged into a single group. + +The values are @code{key IDs} or fingerprints, but any key description +is accepted. Note that a value with spaces in it will be treated as +two different values. Note also there is only one level of expansion +- you cannot make an group that points to another group. When used +from the command line, it may be necessary to quote the argument to +this option to prevent the shell from treating it as multiple +arguments. + +@item --ungroup @code{name} +Remove a given entry from the --group list. + +@item --no-groups +Remove all entries from the --group list. + +@item --local-user @var{name} +@itemx -u +@opindex local-user +Use @var{name} as the key to sign with. Note that this option overrides +--default-key. + +@item --try-all-secrets +Don't look at the key ID as stored in the message but try all secret +keys in turn to find the right decryption key. This option forces the +behaviour as used by anonymous recipients (created by using +--throw-keyids) and might come handy in case where an encrypted +message contains a bogus key ID. + + + + + +@end table + +@c ******************************************* +@c ******** INPUT AND OUTPUT *************** +@c ******************************************* +@node GPG Input and Output +@subsection Input and Output + +@table @gnupgtabopt + +@item --armor +@itemx -a +@opindex armor +Create ASCII armored output. The default is to create the binary +OpenPGP format. + +@item --no-armor +Assume the input data is not in ASCII armored format. + +@item --output @var{file} +@itemx -o @var{file} +@opindex output +Write output to @var{file}. + +@item --max-output @code{n} +@opindex max-output +This option sets a limit on the number of bytes that will be generated +when processing a file. Since OpenPGP supports various levels of +compression, it is possible that the plaintext of a given message may be +significantly larger than the original OpenPGP message. While GnuPG +works properly with such messages, there is often a desire to set a +maximum file size that will be generated before processing is forced to +stop by the OS limits. Defaults to 0, which means "no limit". + @item --import-options @code{parameters} This is a space or comma delimited string that gives options for importing keys. Options can be prepended with a `no-' to give the @@ -1335,257 +1677,239 @@ that the local copy of the key is not modified. Defaults to no. @end table -@item --list-options @code{parameters} -This is a space or comma delimited string that gives options used when -listing keys and signatures (that is, --list-keys, --list-sigs, ---list-public-keys, --list-secret-keys, and the --edit-key functions). -Options can be prepended with a `no-' to give the opposite meaning. -The options are: +@item --with-colons +@opindex with-colons +Print key listings delimited by colons. Note that the output will be +encoded in UTF-8 regardless of any --display-charset setting. This +format is useful when GnuPG is called from scripts and other programs +as it is easily machine parsed. The details of this format are +documented in the file @file{doc/DETAILS}, which is included in the GnuPG +source distribution. -@table @asis +@item --fixed-list-mode +@opindex fixed-list-mode +Do not merge primary user ID and primary key in --with-colon listing +mode and print all timestamps as seconds since 1970-01-01. -@item show-photos -Causes --list-keys, --list-sigs, --list-public-keys, and ---list-secret-keys to display any photo IDs attached to the key. -Defaults to no. See also --photo-viewer. +@item --with-fingerprint +@opindex with-fingerprint +Same as the command --fingerprint but changes only the format of the output +and may be used together with another command. -@item show-policy-urls -Show policy URLs in the --list-sigs or --check-sigs listings. -Defaults to no. -@item show-notations -@itemx show-std-notations -@itemx show-user-notations -Show all, IETF standard, or user-defined signature notations in the ---list-sigs or --check-sigs listings. Defaults to no. +@end table -@item show-keyserver-urls -Show any preferred keyserver URL in the --list-sigs or --check-sigs -listings. Defaults to no. +@c ******************************************* +@c ******** OPENPGP OPTIONS **************** +@c ******************************************* +@node OpenPGP Options +@subsection OpenPGP protocol specific options. -@item show-uid-validity -Display the calculated validity of user IDs during key listings. -Defaults to no. +@table @gnupgtabopt -@item show-unusable-uids -Show revoked and expired user IDs in key listings. Defaults to no. +@item -t, --textmode +@itemx --no-textmode +Treat input files as text and store them in the OpenPGP canonical text +form with standard "CRLF" line endings. This also sets the necessary +flags to inform the recipient that the encrypted or signed data is +text and may need its line endings converted back to whatever the +local system uses. This option is useful when communicating between +two platforms that have different line ending conventions (UNIX-like +to Mac, Mac to Windows, etc). --no-textmode disables this option, and +is the default. -@item show-unusable-subkeys -Show revoked and expired subkeys in key listings. Defaults to no. +If -t (but not --textmode) is used together with armoring and signing, +this enables clearsigned messages. This kludge is needed for +command-line compatibility with command-line versions of PGP; normally +you would use --sign or --clearsign to select the type of the +signature. -@item show-keyring -Display the keyring name at the head of key listings to show which -keyring a given key resides on. Defaults to no. -@item show-sig-expire -Show signature expiration dates (if any) during --list-sigs or ---check-sigs listings. Defaults to no. -@item show-sig-subpackets -Include signature subpackets in the key listing. This option can take -an optional argument list of the subpackets to list. If no argument -is passed, list all subpackets. Defaults to no. This option is only -meaningful when using --with-colons along with --list-sigs or ---check-sigs. -@end table -@item --verify-options @code{parameters} -This is a space or comma delimited string that gives options used when -verifying signatures. Options can be prepended with a `no-' to give -the opposite meaning. The options are: +@item --force-v3-sigs +@itemx --no-force-v3-sigs +OpenPGP states that an implementation should generate v4 signatures +but PGP versions 5 through 7 only recognize v4 signatures on key +material. This option forces v3 signatures for signatures on data. +Note that this option overrides --ask-sig-expire, as v3 signatures +cannot have expiration dates. --no-force-v3-sigs disables this +option. -@table @asis +@item --force-v4-certs +@itemx --no-force-v4-certs +Always use v4 key signatures even on v3 keys. This option also +changes the default hash algorithm for v3 RSA keys from MD5 to SHA-1. +--no-force-v4-certs disables this option. -@item show-photos -Display any photo IDs present on the key that issued the signature. -Defaults to no. See also --photo-viewer. +@item --force-mdc +Force the use of encryption with a modification detection code. This +is always used with the newer ciphers (those with a blocksize greater +than 64 bits), or if all of the recipient keys indicate MDC support in +their feature flags. -@item show-policy-urls -Show policy URLs in the signature being verified. Defaults to no. +@item --disable-mdc +Disable the use of the modification detection code. Note that by +using this option, the encrypted message becomes vulnerable to a +message modification attack. -@item show-notations -@itemx show-std-notations -@itemx show-user-notations -Show all, IETF standard, or user-defined signature notations in the -signature being verified. Defaults to IETF standard. +@item --personal-cipher-preferences @code{string} +Set the list of personal cipher preferences to @code{string}, this list +should be a string similar to the one printed by the command "pref" in +the edit menu. This allows the user to factor in their own preferred +algorithms when algorithms are chosen via recipient key preferences. +The most highly ranked cipher in this list is also used for the +--symmetric encryption command. -@item show-keyserver-urls -Show any preferred keyserver URL in the signature being verified. -Defaults to no. +@item --personal-digest-preferences @code{string} +Set the list of personal digest preferences to @code{string}, this list +should be a string similar to the one printed by the command "pref" in +the edit menu. This allows the user to factor in their own preferred +algorithms when algorithms are chosen via recipient key preferences. +The most highly ranked digest algorithm in this list is algo used when +signing without encryption (e.g. --clearsign or --sign). The default +value is SHA-1. -@item show-uid-validity -Display the calculated validity of the user IDs on the key that issued -the signature. Defaults to no. +@item --personal-compress-preferences @code{string} +Set the list of personal compression preferences to @code{string}, this +list should be a string similar to the one printed by the command +"pref" in the edit menu. This allows the user to factor in their own +preferred algorithms when algorithms are chosen via recipient key +preferences. The most highly ranked algorithm in this list is also +used when there are no recipient keys to consider (e.g. --symmetric). -@item show-unusable-uids -Show revoked and expired user IDs during signature verification. -Defaults to no. -@item pka-lookups -Enable PKA lookups to verify sender addresses. Note that PKA is based -on DNS, and so enabling this option may disclose information on when -and what signatures are verified or to whom data is encrypted. This -is similar to the "web bug" described for the auto-key-retrieve -feature. -@item pka-trust-increase -Raise the trust in a signature to full if the signature passes PKA -validation. This option is only meaningful if pka-lookups is set. -@end table +@item --s2k-cipher-algo @code{name} +Use @code{name} as the cipher algorithm used to protect secret keys. +The default cipher is CAST5. This cipher is also used for +conventional encryption if --personal-cipher-preferences and +--cipher-algo is not given. -@item --enable-dsa2 -@itemx --disable-dsa2 -Enables new-style DSA keys which (unlike the old style) may be larger -than 1024 bit and use hashes other than SHA-1 and RIPEMD/160. Note -that very few programs currently support these keys and signatures -from them. +@item --s2k-digest-algo @code{name} +Use @code{name} as the digest algorithm used to mangle the passphrases. +The default algorithm is SHA-1. -@item --show-photos -@itemx --no-show-photos -Causes --list-keys, --list-sigs, --list-public-keys, ---list-secret-keys, and verifying a signature to also display the -photo ID attached to the key, if any. See also --photo-viewer. These -options are deprecated. Use `--list-options [no-]show-photos' and/or -`--verify-options [no-]show-photos' instead. +@item --s2k-mode @code{n} +Selects how passphrases are mangled. If @code{n} is 0 a plain +passphrase (which is not recommended) will be used, a 1 adds a salt to +the passphrase and a 3 (the default) iterates the whole process a +couple of times. Unless --rfc1991 is used, this mode is also used for +conventional encryption. -@item --photo-viewer @code{string} -This is the command line that should be run to view a photo ID. "%i" -will be expanded to a filename containing the photo. "%I" does the -same, except the file will not be deleted once the viewer exits. -Other flags are "%k" for the key ID, "%K" for the long key ID, "%f" -for the key fingerprint, "%t" for the extension of the image type -(e.g. "jpg"), "%T" for the MIME type of the image (e.g. "image/jpeg"), -and "%%" for an actual percent sign. If neither %i or %I are present, -then the photo will be supplied to the viewer on standard input. -The default viewer is "xloadimage -fork -quiet -title 'KeyID 0x%k' -stdin". Note that if your image viewer program is not secure, then -executing it from GnuPG does not make it secure. -@item --exec-path @code{string} -Sets a list of directories to search for photo viewers and keyserver -helpers. If not provided, keyserver helpers use the compiled-in -default directory, and photo viewers use the $PATH environment -variable. -Note, that on W32 system this value is ignored when searching for -keyserver helpers. +@end table -@item --show-keyring -Display the keyring name at the head of key listings to show which -keyring a given key resides on. This option is deprecated: use -`--list-options [no-]show-keyring' instead. +@c *************************** +@c ******* Compliance ******** +@c *************************** +@subsection Compliance options -@item --keyring @code{file} -Add @code{file} to the current list of keyrings. If @code{file} begins -with a tilde and a slash, these are replaced by the $HOME -directory. If the filename does not contain a slash, it is assumed to -be in the GnuPG home directory ("~/.gnupg" if --homedir or $GNUPGHOME -is not used). +These options control what GnuPG is compliant to. Only one of these +options may be active at a time. Note that the default setting of +this is nearly always the correct one. See the INTEROPERABILITY WITH +OTHER OPENPGP PROGRAMS section below before using one of these +options. -Note that this adds a keyring to the current list. If the intent is -to use the specified keyring alone, use --keyring along with ---no-default-keyring. +@table @gnupgtabopt -@item --secret-keyring @code{file} -Same as --keyring but for the secret keyrings. +@item --gnupg +@opindex gnupg +Use standard GnuPG behavior. This is essentially OpenPGP behavior +(see --openpgp), but with some additional workarounds for common +compatibility problems in different versions of PGP. This is the +default option, so it is not generally needed, but it may be useful to +override a different compliance option in the gpg.conf file. -@item --primary-keyring @code{file} -Designate @code{file} as the primary public keyring. This means that -newly imported keys (via --import or keyserver --recv-from) will go to -this keyring. +@item --openpgp +@opindex openpgp +Reset all packet, cipher and digest options to strict OpenPGP +behavior. Use this option to reset all previous options like +--rfc1991, --force-v3-sigs, --s2k-*, --cipher-algo, --digest-algo and +--compress-algo to OpenPGP compliant values. All PGP workarounds are +disabled. -@item --trustdb-name @code{file} -Use @code{file} instead of the default trustdb. If @code{file} begins -with a tilde and a slash, these are replaced by the $HOME -directory. If the filename does not contain a slash, it is assumed to -be in the GnuPG home directory ("~/.gnupg" if --homedir or $GNUPGHOME -is not used). +@item --rfc2440 +opindex rfc2440 +Reset all packet, cipher and digest options to strict RFC-2440 +behavior. Note that this is currently the same thing as --openpgp. -@include opt-homedir.texi +@item --rfc1991 +@opindex rfc1991 +Try to be more RFC-1991 (PGP 2.x) compliant. +@item --pgp2 +@opindex pgp2 +Set up all options to be as PGP 2.x compliant as possible, and warn if +an action is taken (e.g. encrypting to a non-RSA key) that will create +a message that PGP 2.x will not be able to handle. Note that `PGP +2.x' here means `MIT PGP 2.6.2'. There are other versions of PGP 2.x +available, but the MIT release is a good common baseline. -@item --pcsc-driver @code{file} -Use @code{file} to access the smartcard reader. The current default is -`libpcsclite.so.1' for GLIBC based systems, -`/System/Library/Frameworks/PCSC.framework/PCSC' for MAC OS X, -`winscard.dll' for Windows and `libpcsclite.so' for other systems. +This option implies `--rfc1991 --disable-mdc --no-force-v4-certs +--no-sk-comment --escape-from-lines --force-v3-sigs +--no-ask-sig-expire --no-ask-cert-expire --cipher-algo IDEA +--digest-algo MD5 --compress-algo 1'. It also disables --textmode +when encrypting. -@item --ctapi-driver @code{file} -Use @code{file} to access the smartcard reader. The current default -is `libtowitoko.so'. Note that the use of this interface is -deprecated; it may be removed in future releases. +@item --pgp6 +@opindex pgp6 +Set up all options to be as PGP 6 compliant as possible. This +restricts you to the ciphers IDEA (if the IDEA plugin is installed), +3DES, and CAST5, the hashes MD5, SHA1 and RIPEMD160, and the +compression algorithms none and ZIP. This also disables +--throw-keyids, and making signatures with signing subkeys as PGP 6 +does not understand signatures made by signing subkeys. -@item --disable-ccid -Disable the integrated support for CCID compliant readers. This -allows to fall back to one of the other drivers even if the internal -CCID driver can handle the reader. Note, that CCID support is only -available if libusb was available at build time. +This option implies `--disable-mdc --no-sk-comment --escape-from-lines +--force-v3-sigs --no-ask-sig-expire' -@item --reader-port @code{number_or_string} -This option may be used to specify the port of the card terminal. A -value of 0 refers to the first serial device; add 32768 to access USB -devices. The default is 32768 (first USB device). PC/SC or CCID -readers might need a string here; run the program in verbose mode to get -a list of available readers. The default is then the first reader -found. +@item --pgp7 +@opindex pgp7 +Set up all options to be as PGP 7 compliant as possible. This is +identical to --pgp6 except that MDCs are not disabled, and the list of +allowable ciphers is expanded to add AES128, AES192, AES256, and +TWOFISH. -@item --display-charset @code{name} -Set the name of the native character set. This is used to convert -some informational strings like user IDs to the proper UTF-8 encoding. -Note that this has nothing to do with the character set of data to be -encrypted or signed; GnuPG does not recode user supplied data. If -this option is not used, the default character set is determined from -the current locale. A verbosity level of 3 shows the chosen set. -Valid values for @code{name} are: +@item --pgp8 +@opindex pgp8 +Set up all options to be as PGP 8 compliant as possible. PGP 8 is a +lot closer to the OpenPGP standard than previous versions of PGP, so +all this does is disable --throw-keyids and set --escape-from-lines. +All algorithms are allowed except for the SHA224, SHA384, and SHA512 +digests. -@table @asis +@end table -@item iso-8859-1 -This is the Latin 1 set. -@item iso-8859-2 -The Latin 2 set. +@c ******************************************* +@c ******** ESOTERIC OPTIONS *************** +@c ******************************************* +@node GPG Esoteric Options +@subsection Doing things one usually don't want to do. -@item iso-8859-15 -This is currently an alias for -the Latin 1 set. +@table @gnupgtabopt -@item koi8-r -The usual Russian set (rfc1489). +@item -n +@itemx --dry-run +@opindex dry-run +Don't make any changes (this is not completely implemented). -@item utf-8 -Bypass all translations and assume -that the OS uses native UTF-8 encoding. -@end table +@item --list-only +Changes the behaviour of some commands. This is like --dry-run but +different in some cases. The semantic of this command may be extended in +the future. Currently it only skips the actual decryption pass and +therefore enables a fast listing of the encryption keys. -@item --utf8-strings -@itemx --no-utf8-strings -Assume that command line arguments are given as UTF8 strings. The -default (--no-utf8-strings) is to assume that arguments are encoded in -the character set as specified by --display-charset. These options -affect all following arguments. Both options may be used multiple -times. +@item -i +@itemx --interactive +@opindex interactive +Prompt before overwriting any files. -@item --options @code{file} -Read options from @code{file} and do not try to read -them from the default options file in the homedir -(see --homedir). This option is ignored if used -in an options file. - -@item --no-options -Shortcut for "--options /dev/null". This option is -detected before an attempt to open an option file. -Using this option will also prevent the creation of a -"~./gnupg" homedir. - -@item --load-extension @code{name} -Load an extension module. If @code{name} does not contain a slash it is -searched for in the directory configured when GnuPG was built -(generally "/usr/local/lib/gnupg"). Extensions are not generally -useful anymore, and the use of this option is deprecated. - -@item --debug @code{flags} -Set debugging flags. All flags are or-ed and @code{flags} may +@item --debug @var{flags} +@opindex debug +Set debugging flags. All flags are or-ed and @var{flags} may be given in C syntax (e.g. 0x0042). @item --debug-all @@ -1669,13 +1993,6 @@ meaningful when making a key signature (certification), and %c is only meaningful when using the OpenPGP smartcard. -@item --show-notation -@itemx --no-show-notation -Show signature notations in the --list-sigs or --check-sigs listings -as well as when verifying a signature with a notation in it. These -options are deprecated. Use `--list-options [no-]show-notation' -and/or `--verify-options [no-]show-notation' instead. - @item --sig-policy-url @code{string} @itemx --cert-policy-url @code{string} @itemx --set-policy-url @code{string} @@ -1687,13 +2004,6 @@ The same %-expandos used for notation data are available here as well. -@item --show-policy-url -@itemx --no-show-policy-url -Show policy URLs in the --list-sigs or --check-sigs listings as well -as when verifying a signature with a policy URL in it. These options -are deprecated. Use `--list-options [no-]show-policy-url' and/or -`--verify-options [no-]show-policy-url' instead. - @item --sig-keyserver-url @code{string} Use @code{string} as a preferred keyserver URL for data signatures. If you prefix it with an exclamation mark, the keyserver URL packet will @@ -1719,17 +2029,6 @@ Try to create a file with a name as embedded in the data. This can be a dangerous option as it allows to overwrite files. Defaults to no. -@item --completes-needed @code{n} -Number of completely trusted users to introduce a new -key signer (defaults to 1). - -@item --marginals-needed @code{n} -Number of marginally trusted users to introduce a new -key signer (defaults to 3) - -@item --max-cert-depth @code{n} -Maximum depth of a certification chain (default is 5). - @item --cipher-algo @code{name} Use @code{name} as cipher algorithm. Running the program with the command --version yields a list of supported algorithms. If this is @@ -1776,34 +2075,6 @@ users will not be able to use the key signatures you make, or quite possibly your entire key. -@item --s2k-cipher-algo @code{name} -Use @code{name} as the cipher algorithm used to protect secret keys. -The default cipher is CAST5. This cipher is also used for -conventional encryption if --personal-cipher-preferences and ---cipher-algo is not given. - -@item --s2k-digest-algo @code{name} -Use @code{name} as the digest algorithm used to mangle the passphrases. -The default algorithm is SHA-1. - -@item --s2k-mode @code{n} -Selects how passphrases are mangled. If @code{n} is 0 a plain -passphrase (which is not recommended) will be used, a 1 adds a salt to -the passphrase and a 3 (the default) iterates the whole process a -couple of times. Unless --rfc1991 is used, this mode is also used for -conventional encryption. - -@item --simple-sk-checksum -Secret keys are integrity protected by using a SHA-1 checksum. This -method is part of the upcoming enhanced OpenPGP specification but -GnuPG already uses it as a countermeasure against certain attacks. -Old applications don't understand this new format, so this option may -be used to switch back to the old behaviour. Using this option bears -a security risk. Note that using this option only takes effect when -the secret key is encrypted - the simplest way to make this happen is -to change the passphrase on the key (even changing it to the same -value is acceptable). - @item --disable-cipher-algo @code{name} Never allow the use of @code{name} as cipher algorithm. The given name will not be checked so that a later loaded algorithm @@ -1814,29 +2085,6 @@ The given name will not be checked so that a later loaded algorithm will still get disabled. -@item --no-sig-cache -Do not cache the verification status of key signatures. -Caching gives a much better performance in key listings. However, if -you suspect that your public keyring is not save against write -modifications, you can use this option to disable the caching. It -probably does not make sense to disable it because all kind of damage -can be done if someone else has write access to your public keyring. - -@item --no-sig-create-check -GnuPG normally verifies each signature right after creation to protect -against bugs and hardware malfunctions which could leak out bits from -the secret key. This extra verification needs some time (about 115% -for DSA keys), and so this option can be used to disable it. -However, due to the fact that the signature creation needs manual -interaction, this performance penalty does not matter in most settings. - -@item --auto-check-trustdb -@itemx --no-auto-check-trustdb -If GnuPG feels that its information about the Web of Trust has to be -updated, it automatically runs the --check-trustdb command internally. -This may be a time consuming process. --no-auto-check-trustdb -disables this option. - @item --throw-keyids @itemx --no-throw-keyids Do not put the recipient key IDs into encrypted messages. This helps @@ -1893,111 +2141,6 @@ Same as --command-fd, except the commands are read out of file @code{file} -@item --use-agent -@itemx --no-use-agent -Try to use the GnuPG-Agent. Please note that this agent is still under -development. With this option, GnuPG first tries to connect to the -agent before it asks for a passphrase. --no-use-agent disables this -option. - -@item --gpg-agent-info -Override the value of the environment variable -@samp{GPG_AGENT_INFO}. This is only used when --use-agent has been given - -@item Compliance options -These options control what GnuPG is compliant to. Only one of these -options may be active at a time. Note that the default setting of -this is nearly always the correct one. See the INTEROPERABILITY WITH -OTHER OPENPGP PROGRAMS section below before using one of these -options. - -@table @asis - -@item --gnupg -Use standard GnuPG behavior. This is essentially OpenPGP behavior -(see --openpgp), but with some additional workarounds for common -compatibility problems in different versions of PGP. This is the -default option, so it is not generally needed, but it may be useful to -override a different compliance option in the gpg.conf file. - -@item --openpgp -Reset all packet, cipher and digest options to strict OpenPGP -behavior. Use this option to reset all previous options like ---rfc1991, --force-v3-sigs, --s2k-*, --cipher-algo, --digest-algo and ---compress-algo to OpenPGP compliant values. All PGP workarounds are -disabled. - -@item --rfc2440 -Reset all packet, cipher and digest options to strict RFC-2440 -behavior. Note that this is currently the same thing as --openpgp. - -@item --rfc1991 -Try to be more RFC-1991 (PGP 2.x) compliant. - -@item --pgp2 -Set up all options to be as PGP 2.x compliant as possible, and warn if -an action is taken (e.g. encrypting to a non-RSA key) that will create -a message that PGP 2.x will not be able to handle. Note that `PGP -2.x' here means `MIT PGP 2.6.2'. There are other versions of PGP 2.x -available, but the MIT release is a good common baseline. - -This option implies `--rfc1991 --disable-mdc --no-force-v4-certs ---no-sk-comment --escape-from-lines --force-v3-sigs ---no-ask-sig-expire --no-ask-cert-expire --cipher-algo IDEA ---digest-algo MD5 --compress-algo 1'. It also disables --textmode -when encrypting. - -@item --pgp6 -Set up all options to be as PGP 6 compliant as possible. This -restricts you to the ciphers IDEA (if the IDEA plugin is installed), -3DES, and CAST5, the hashes MD5, SHA1 and RIPEMD160, and the -compression algorithms none and ZIP. This also disables ---throw-keyids, and making signatures with signing subkeys as PGP 6 -does not understand signatures made by signing subkeys. - -This option implies `--disable-mdc --no-sk-comment --escape-from-lines ---force-v3-sigs --no-ask-sig-expire' - -@item --pgp7 -Set up all options to be as PGP 7 compliant as possible. This is -identical to --pgp6 except that MDCs are not disabled, and the list of -allowable ciphers is expanded to add AES128, AES192, AES256, and -TWOFISH. - -@item --pgp8 -Set up all options to be as PGP 8 compliant as possible. PGP 8 is a -lot closer to the OpenPGP standard than previous versions of PGP, so -all this does is disable --throw-keyids and set --escape-from-lines. -All algorithms are allowed except for the SHA224, SHA384, and SHA512 -digests. -@end table - -@item --force-v3-sigs -@itemx --no-force-v3-sigs -OpenPGP states that an implementation should generate v4 signatures -but PGP versions 5 through 7 only recognize v4 signatures on key -material. This option forces v3 signatures for signatures on data. -Note that this option overrides --ask-sig-expire, as v3 signatures -cannot have expiration dates. --no-force-v3-sigs disables this -option. - -@item --force-v4-certs -@itemx --no-force-v4-certs -Always use v4 key signatures even on v3 keys. This option also -changes the default hash algorithm for v3 RSA keys from MD5 to SHA-1. ---no-force-v4-certs disables this option. - -@item --force-mdc -Force the use of encryption with a modification detection code. This -is always used with the newer ciphers (those with a blocksize greater -than 64 bits), or if all of the recipient keys indicate MDC support in -their feature flags. - -@item --disable-mdc -Disable the use of the modification detection code. Note that by -using this option, the encrypted message becomes vulnerable to a -message modification attack. - @item --allow-non-selfsigned-uid @itemx --no-allow-non-selfsigned-uid Allow the import and use of keys with user IDs which are not @@ -2037,79 +2180,6 @@ However, be aware that a MDC protection failure may also mean that the message was tampered with intentionally by an attacker. -@item --lock-once -Lock the databases the first time a lock is requested -and do not release the lock until the process -terminates. - -@item --lock-multiple -Release the locks every time a lock is no longer -needed. Use this to override a previous --lock-once -from a config file. - -@item --lock-never -Disable locking entirely. This option should be used only in very -special environments, where it can be assured that only one process -is accessing those files. A bootable floppy with a stand-alone -encryption system will probably use this. Improper usage of this -option may lead to data and key corruption. - -@item --exit-on-status-write-error -This option will cause write errors on the status FD to immediately -terminate the process. That should in fact be the default but it -never worked this way and thus we need an option to enable this, so -that the change won't break applications which close their end of a -status fd connected pipe too early. Using this option along with ---enable-progress-filter may be used to cleanly cancel long running -gpg operations. - -@item --limit-card-insert-tries @code{n} -With @code{n} greater than 0 the number of prompts asking to insert a -smartcard gets limited to N-1. Thus with a value of 1 gpg won't at -all ask to insert a card if none has been inserted at startup. This -option is useful in the configuration file in case an application does -not know about the smartcard support and waits ad infinitum for an -inserted card. - -@item --no-random-seed-file -GnuPG uses a file to store its internal random pool over invocations. -This makes random generation faster; however sometimes write operations -are not desired. This option can be used to achieve that with the cost of -slower random generation. - -@item --no-verbose -Reset verbose level to 0. - -@item --no-greeting -Suppress the initial copyright message. - -@item --no-secmem-warning -Suppress the warning about "using insecure memory". - -@item --no-permission-warning -Suppress the warning about unsafe file and home directory (--homedir) -permissions. Note that the permission checks that GnuPG performs are -not intended to be authoritative, but rather they simply warn about -certain common permission problems. Do not assume that the lack of a -warning means that your system is secure. - -Note that the warning for unsafe --homedir permissions cannot be -suppressed in the gpg.conf file, as this would allow an attacker to -place an unsafe gpg.conf file in place, and use this file to suppress -warnings about itself. The --homedir permissions warning may only be -suppressed on the command line. - -@item --no-mdc-warning -Suppress the warning about missing MDC integrity protection. - -@item --require-secmem -@itemx --no-require-secmem -Refuse to run if GnuPG cannot get secure memory. Defaults to no -(i.e. run, but give a warning). - -@item --no-armor -Assume the input data is not in ASCII armored format. - @item --no-default-keyring Do not add the default keyrings to the list of keyrings. Note that GnuPG will not operate without any keyrings, so if you use this option @@ -2122,21 +2192,9 @@ used to make the decryption faster if the signature verification is not needed. -@item --with-colons -Print key listings delimited by colons. Note that the output will be -encoded in UTF-8 regardless of any --display-charset setting. This -format is useful when GnuPG is called from scripts and other programs -as it is easily machine parsed. The details of this format are -documented in the file doc/DETAILS, which is included in the GnuPG -source distribution. - @item --with-key-data Print key listings delimited by colons (like --with-colons) and print the public key data. -@item --with-fingerprint -Same as the command --fingerprint but changes only the format of the output -and may be used together with another command. - @item --fast-list-mode Changes the output of the list commands to work faster; this is achieved by leaving some parts empty. Some applications don't need the user ID and @@ -2144,16 +2202,6 @@ can get a faster listing. The exact behaviour of this option may change in future versions. -@item --fixed-list-mode -Do not merge primary user ID and primary key in --with-colon listing -mode and print all timestamps as seconds since 1970-01-01. - -@item --list-only -Changes the behaviour of some commands. This is like --dry-run but -different in some cases. The semantic of this command may be extended in -the future. Currently it only skips the actual decryption pass and -therefore enables a fast listing of the encryption keys. - @item --no-literal This is not for normal use. Use the source to see for what it might be useful. @@ -2177,13 +2225,6 @@ content of an encrypted message; using this option you can do this without handing out the secret key. -@item --require-cross-certification -@itemx --no-require-cross-certification -When verifying a signature made from a subkey, ensure that the cross -certification "back signature" on the subkey is present and valid. -This protects against a subtle attack against subkeys that can sign. -Defaults to --require-cross-certification for @command{gpg2}. - @item --ask-sig-expire @itemx --no-ask-sig-expire When making a data signature, prompt for an expiration time. If this @@ -2214,26 +2255,9 @@ (for example "2m" for two months, or "5y" for five years), or an absolute date in the form YYYY-MM-DD. Defaults to "0". -@item --expert -@itemx --no-expert -Allow the user to do certain nonsensical or "silly" things like -signing an expired or revoked key, or certain potentially incompatible -things like generating unusual key types. This also disables certain -warning messages about potentially incompatible actions. As the name -implies, this option is for experts only. If you don't fully -understand the implications of what it allows you to do, leave this -off. --no-expert disables this option. - @item --allow-secret-key-import This is an obsolete option and is not used anywhere. -@item --try-all-secrets -Don't look at the key ID as stored in the message but try all secret -keys in turn to find the right decryption key. This option forces the -behaviour as used by anonymous recipients (created by using ---throw-keyids) and might come handy in case where an encrypted -message contains a bogus key ID. - @item --allow-multisig-verification Allow verification of concatenated signed messages. This will run a signature verification for each data+signature block. There are some @@ -2248,55 +2272,10 @@ @item --no-expensive-trust-checks Experimental use only. -@item --group @code{name=value1 } -Sets up a named group, which is similar to aliases in email programs. -Any time the group name is a recipient (-r or --recipient), it will be -expanded to the values specified. Multiple groups with the same name -are automatically merged into a single group. - -The values are @code{key IDs} or fingerprints, but any key description -is accepted. Note that a value with spaces in it will be treated as -two different values. Note also there is only one level of expansion -- you cannot make an group that points to another group. When used -from the command line, it may be necessary to quote the argument to -this option to prevent the shell from treating it as multiple -arguments. - -@item --ungroup @code{name} -Remove a given entry from the --group list. - -@item --no-groups -Remove all entries from the --group list. - @item --preserve-permissions Don't change the permissions of a secret keyring back to user read/write only. Use this option only if you really know what you are doing. -@item --personal-cipher-preferences @code{string} -Set the list of personal cipher preferences to @code{string}, this list -should be a string similar to the one printed by the command "pref" in -the edit menu. This allows the user to factor in their own preferred -algorithms when algorithms are chosen via recipient key preferences. -The most highly ranked cipher in this list is also used for the ---symmetric encryption command. - -@item --personal-digest-preferences @code{string} -Set the list of personal digest preferences to @code{string}, this list -should be a string similar to the one printed by the command "pref" in -the edit menu. This allows the user to factor in their own preferred -algorithms when algorithms are chosen via recipient key preferences. -The most highly ranked digest algorithm in this list is algo used when -signing without encryption (e.g. --clearsign or --sign). The default -value is SHA-1. - -@item --personal-compress-preferences @code{string} -Set the list of personal compression preferences to @code{string}, this -list should be a string similar to the one printed by the command -"pref" in the edit menu. This allows the user to factor in their own -preferred algorithms when algorithms are chosen via recipient key -preferences. The most highly ranked algorithm in this list is also -used when there are no recipient keys to consider (e.g. --symmetric). - @item --default-preference-list @code{string} @opindex default-preference-list Set the list of default preferences to @code{string}. This preference @@ -2320,9 +2299,58 @@ @end table +@c ******************************* +@c ******* Deprecated ************ +@c ******************************* +@subsection Deprecated options +@table @gnupgtabopt +@item --load-extension @code{name} +Load an extension module. If @code{name} does not contain a slash it is +searched for in the directory configured when GnuPG was built +(generally "/usr/local/lib/gnupg"). Extensions are not generally +useful anymore, and the use of this option is deprecated. +@item --show-photos +@itemx --no-show-photos +Causes --list-keys, --list-sigs, --list-public-keys, +--list-secret-keys, and verifying a signature to also display the +photo ID attached to the key, if any. See also --photo-viewer. These +options are deprecated. Use `--list-options [no-]show-photos' and/or +`--verify-options [no-]show-photos' instead. + +@item --show-keyring +Display the keyring name at the head of key listings to show which +keyring a given key resides on. This option is deprecated: use +`--list-options [no-]show-keyring' instead. + +@item --ctapi-driver @code{file} +Use @code{file} to access the smartcard reader. The current default +is `libtowitoko.so'. Note that the use of this interface is +deprecated; it may be removed in future releases. + +@item --always-trust +Identical to `--trust-model always'. This option is deprecated. + +@item --show-notation +@itemx --no-show-notation +Show signature notations in the --list-sigs or --check-sigs listings +as well as when verifying a signature with a notation in it. These +options are deprecated. Use `--list-options [no-]show-notation' +and/or `--verify-options [no-]show-notation' instead. + +@item --show-policy-url +@itemx --no-show-policy-url +Show policy URLs in the --list-sigs or --check-sigs listings as well +as when verifying a signature with a policy URL in it. These options +are deprecated. Use `--list-options [no-]show-policy-url' and/or +`--verify-options [no-]show-policy-url' instead. + + +@end table + + @c ******************************************* @c *************** **************** @c *************** FILES **************** From cvs at cvs.gnupg.org Wed Sep 20 13:01:52 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed Sep 20 12:16:43 2006 Subject: [svn] GnuPG - r4257 - in trunk: . agent doc g10 include kbx keyserver sm tools Message-ID: Author: wk Date: 2006-09-20 13:01:49 +0200 (Wed, 20 Sep 2006) New Revision: 4257 Added: trunk/doc/texi.css trunk/include/Makefile.am Removed: trunk/include/distfiles trunk/include/errors.h trunk/include/http.h trunk/include/i18n.h trunk/include/memory.h trunk/include/mpi.h trunk/include/util.h Modified: trunk/ChangeLog trunk/Makefile.am trunk/TODO trunk/agent/ChangeLog trunk/agent/Makefile.am trunk/configure.ac trunk/doc/ChangeLog trunk/doc/Makefile.am trunk/doc/debugging.texi trunk/doc/gnupg.texi trunk/g10/ChangeLog trunk/g10/call-agent.c trunk/include/ChangeLog trunk/kbx/ChangeLog trunk/kbx/Makefile.am trunk/keyserver/Makefile.am trunk/sm/ChangeLog trunk/sm/Makefile.am trunk/tools/ChangeLog trunk/tools/Makefile.am Log: Cleanups. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-09-19 16:25:51 UTC (rev 4256) +++ trunk/ChangeLog 2006-09-20 11:01:49 UTC (rev 4257) @@ -1,3 +1,8 @@ +2006-09-20 Werner Koch + + * Makefile.am (dist-hook): Removed distfiles cruft. + (SUBDIRS): Added include + 2006-09-18 Werner Koch Released 1.9.23. Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2006-09-19 16:25:51 UTC (rev 4256) +++ trunk/Makefile.am 2006-09-20 11:01:49 UTC (rev 4257) @@ -73,19 +73,10 @@ tests = tests endif -SUBDIRS = m4 intl gl jnlib common ${kbx} \ +SUBDIRS = m4 intl gl include jnlib common ${kbx} \ ${gpg} ${keyserver} ${sm} ${agent} ${scd} ${tools} po ${doc} ${tests} dist-hook: - @set -e; \ - for file in `cd $(top_srcdir); \ - find scripts include -type f -name distfiles`; do \ - dir=`dirname $$file` ; $(mkinstalldirs) $(distdir)/$$dir ; \ - for i in distfiles `cat $(top_srcdir)/$$file` ; do \ - ln $(top_srcdir)/$$dir/$$i $(distdir)/$$dir/$$i 2> /dev/null \ - || cp -p $(top_srcdir)/$$dir/$$i $(distdir)/$$dir/$$i; \ - done ; \ - done echo "$(VERSION)" > $(distdir)/VERSION Modified: trunk/TODO =================================================================== --- trunk/TODO 2006-09-19 16:25:51 UTC (rev 4256) +++ trunk/TODO 2006-09-20 11:01:49 UTC (rev 4257) @@ -119,5 +119,3 @@ * Extend selinux support to other modules -* Missing dependencies on libcommon. - parallel builds fail. Modified: trunk/agent/ChangeLog =================================================================== --- trunk/agent/ChangeLog 2006-09-19 16:25:51 UTC (rev 4256) +++ trunk/agent/ChangeLog 2006-09-20 11:01:49 UTC (rev 4257) @@ -1,3 +1,7 @@ +2006-09-20 Werner Koch + + * Makefile.am: Changes to allow parallel make runs. + 2006-09-15 Werner Koch * trustlist.c: Entirely rewritten. Modified: trunk/agent/Makefile.am =================================================================== --- trunk/agent/Makefile.am 2006-09-19 16:25:51 UTC (rev 4256) +++ trunk/agent/Makefile.am 2006-09-20 11:01:49 UTC (rev 4257) @@ -47,9 +47,12 @@ learncard.c -gpg_agent_LDADD = ../jnlib/libjnlib.a ../common/libcommon.a ../gl/libgnu.a \ +common_libs = ../jnlib/libjnlib.a ../common/libcommon.a ../gl/libgnu.a +pwquery_libs = ../common/libsimple-pwquery.a + +gpg_agent_LDADD = $(common_libs) \ $(LIBGCRYPT_LIBS) $(PTH_LIBS) $(LIBASSUAN_LIBS) \ - $(GPG_ERROR_LIBS) @LIBINTL@ $(NETLIBS) + $(GPG_ERROR_LIBS) $(LIBINTL) $(NETLIBS) gpg_protect_tool_SOURCES = \ protect-tool.c \ @@ -57,9 +60,8 @@ minip12.c minip12.h # Needs $(NETLIBS) for libsimple-pwquery.la. -gpg_protect_tool_LDADD = ../common/libsimple-pwquery.a \ - ../jnlib/libjnlib.a ../common/libcommon.a ../gl/libgnu.a \ - $(LIBGCRYPT_LIBS) -lgpg-error @LIBINTL@ $(NETLIBS) +gpg_protect_tool_LDADD = $(pwquery_libs) $(common_libs) \ + $(LIBGCRYPT_LIBS) -lgpg-error $(LIBINTL) $(NETLIBS) if HAVE_W32_SYSTEM gpg_protect_tool_LDADD += -lwsock32 endif @@ -68,20 +70,24 @@ preset-passphrase.c # Needs $(NETLIBS) for libsimple-pwquery.la. -gpg_preset_passphrase_LDADD = ../common/libsimple-pwquery.a \ - ../jnlib/libjnlib.a ../common/libcommon.a ../gl/libgnu.a \ +gpg_preset_passphrase_LDADD = $(pwquery_libs) $(common_libs) \ $(LIBGCRYPT_LIBS) -lgpg-error @LIBINTL@ $(NETLIBS) if HAVE_W32_SYSTEM gpg_preset_passphrase_LDADD += -lwsock32 endif +# Make sure that all libs are build before we use them. This is +# important for things like make -j2. +$(PROGRAMS): $(common_libs) $(pwquery_libs) + + # # Module tests # TESTS = t-protect -t_common_ldadd = ../jnlib/libjnlib.a ../common/libcommon.a ../gl/libgnu.a \ - $(LIBGCRYPT_LIBS) -lgpg-error @LIBINTL@ +t_common_ldadd = $(common_libs) \ + $(LIBGCRYPT_LIBS) -lgpg-error $(LIBINTL) t_protect_SOURCES = t-protect.c protect.c t_protect_LDADD = $(t_common_ldadd) Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-09-19 16:25:51 UTC (rev 4256) +++ trunk/configure.ac 2006-09-20 11:01:49 UTC (rev 4257) @@ -1308,6 +1308,7 @@ po/Makefile.in intl/Makefile gl/Makefile +include/Makefile jnlib/Makefile common/Makefile kbx/Makefile Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2006-09-19 16:25:51 UTC (rev 4256) +++ trunk/doc/ChangeLog 2006-09-20 11:01:49 UTC (rev 4257) @@ -1,3 +1,9 @@ +2006-09-20 Werner Koch + + * texi.css: New. Note that the current vesion of makeinfo has a + bug while copying the @import directive. A pacth has been send to + upstream. + 2006-09-19 Werner Koch * gpg.texi: Some restructuring. Modified: trunk/doc/Makefile.am =================================================================== --- trunk/doc/Makefile.am 2006-09-19 16:25:51 UTC (rev 4256) +++ trunk/doc/Makefile.am 2006-09-20 11:01:49 UTC (rev 4257) @@ -28,7 +28,7 @@ gnupg-card-architecture.pdf \ faq.raw FAQ faq.html gnupg7.texi \ opt-homedir.texi see-also-note.texi specify-user-id.texi \ - $(examples) + texi.css $(examples) BUILT_SOURCES = gnupg-card-architecture.eps gnupg-card-architecture.png \ gnupg-card-architecture.pdf FAQ faq.html @@ -44,7 +44,7 @@ tools.texi debugging.texi glossary.texi contrib.texi gpl.texi \ sysnotes.texi gnupg-card-architecture.fig -AM_MAKEFINFOFLAGS = -I $(srcdir) +AM_MAKEINFOFLAGS = -I $(srcdir) --css-include=$(srcdir)/texi.css YAT2M_OPTIONS = -I $(srcdir) \ --release "GnuPG @PACKAGE_VERSION@" --source "GNU Privacy Guard" Modified: trunk/doc/debugging.texi =================================================================== --- trunk/doc/debugging.texi 2006-09-19 16:25:51 UTC (rev 4256) +++ trunk/doc/debugging.texi 2006-09-20 11:01:49 UTC (rev 4257) @@ -9,8 +9,8 @@ there is a need to track down problems. We call this debugging in a reminiscent to the moth jamming a relay in a Mark II box back in 1947. -Most of the probelsm a merely configuration and user problems but -nevertheless there are the most annoying ones and reposnible for may +Most of the problems a merely configuration and user problems but +nevertheless there are the most annoying ones and reponsible for many gray hairs. We try to give some guidelines here on how to identify and solve the problem at hand. Modified: trunk/doc/gnupg.texi =================================================================== --- trunk/doc/gnupg.texi 2006-09-19 16:25:51 UTC (rev 4256) +++ trunk/doc/gnupg.texi 2006-09-20 11:01:49 UTC (rev 4257) @@ -30,8 +30,8 @@ @iftex Published by the Free Software Foundation@* -59 Temple Place - Suite 330@* -Boston, MA 02111-1307 USA +51 Franklin St, Fifth Floor@* +Boston, MA 02110-1301 USA @end iftex Copyright @copyright{} 2002, 2004, 2005, 2006 Free Software Foundation, Inc. Added: trunk/doc/texi.css =================================================================== --- trunk/doc/texi.css 2006-09-19 16:25:51 UTC (rev 4256) +++ trunk/doc/texi.css 2006-09-20 11:01:49 UTC (rev 4257) @@ -0,0 +1,6 @@ +/* The gnupg.org standard stylesheet. */ + @import url(/share/site.css); + + + + Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2006-09-19 16:25:51 UTC (rev 4256) +++ trunk/g10/ChangeLog 2006-09-20 11:01:49 UTC (rev 4257) @@ -1,3 +1,8 @@ +2006-09-20 Werner Koch + + * call-agent.c: Include asshelp.h. + (start_agent): Use send_pinentry_environment. + 2006-09-14 Werner Koch Replaced all call gpg_error_from_errno(errno) by Modified: trunk/g10/call-agent.c =================================================================== --- trunk/g10/call-agent.c 2006-09-19 16:25:51 UTC (rev 4256) +++ trunk/g10/call-agent.c 2006-09-20 11:01:49 UTC (rev 4257) @@ -41,6 +41,7 @@ #include "membuf.h" #include "options.h" #include "i18n.h" +#include "asshelp.h" #include "call-agent.h" #ifndef DBG_ASSUAN @@ -81,11 +82,6 @@ int rc = 0; char *infostr, *p; assuan_context_t ctx; - char *dft_display = NULL; - char *dft_ttyname = NULL; - char *dft_ttytype = NULL; - char *old_lc = NULL; - char *dft_lc = NULL; if (agent_ctx) return 0; /* fixme: We need a context for each thread or serialize @@ -177,123 +173,13 @@ if (DBG_ASSUAN) log_debug ("connection to agent established\n"); - rc = assuan_transact (agent_ctx, "RESET", NULL, NULL, NULL, NULL, NULL, NULL); + rc = assuan_transact (agent_ctx, "RESET", NULL, NULL, NULL, NULL, NULL,NULL); if (rc) return rc; -#ifdef __GNUC__ -#warning put this code into common/asshelp.c -#endif - - dft_display = getenv ("DISPLAY"); - if (opt.display || dft_display) - { - char *optstr; - if (asprintf (&optstr, "OPTION display=%s", - opt.display ? opt.display : dft_display) < 0) - return gpg_error_from_syserror (); - rc = assuan_transact (agent_ctx, optstr, NULL, NULL, NULL, NULL, NULL, - NULL); - free (optstr); - if (rc) - return rc; - } - if (!opt.ttyname) - { - dft_ttyname = getenv ("GPG_TTY"); - if ((!dft_ttyname || !*dft_ttyname) && ttyname (0)) - dft_ttyname = ttyname (0); - } - if (opt.ttyname || dft_ttyname) - { - char *optstr; - if (asprintf (&optstr, "OPTION ttyname=%s", - opt.ttyname ? opt.ttyname : dft_ttyname) < 0) - return gpg_error_from_syserror (); - rc = assuan_transact (agent_ctx, optstr, NULL, NULL, NULL, NULL, NULL, - NULL); - free (optstr); - if (rc) - return rc; - } - dft_ttytype = getenv ("TERM"); - if (opt.ttytype || (dft_ttyname && dft_ttytype)) - { - char *optstr; - if (asprintf (&optstr, "OPTION ttytype=%s", - opt.ttyname ? opt.ttytype : dft_ttytype) < 0) - return gpg_error_from_syserror (); - rc = assuan_transact (agent_ctx, optstr, NULL, NULL, NULL, NULL, NULL, - NULL); - free (optstr); - if (rc) - return rc; - } -#if defined(HAVE_SETLOCALE) && defined(LC_CTYPE) - old_lc = setlocale (LC_CTYPE, NULL); - if (old_lc) - { - old_lc = strdup (old_lc); - if (!old_lc) - return gpg_error_from_syserror (); - - } - dft_lc = setlocale (LC_CTYPE, ""); -#endif - if (opt.lc_ctype || (dft_ttyname && dft_lc)) - { - char *optstr; - if (asprintf (&optstr, "OPTION lc-ctype=%s", - opt.lc_ctype ? opt.lc_ctype : dft_lc) < 0) - rc = gpg_error_from_syserror (); - else - { - rc = assuan_transact (agent_ctx, optstr, NULL, NULL, NULL, NULL, NULL, - NULL); - free (optstr); - } - } -#if defined(HAVE_SETLOCALE) && defined(LC_CTYPE) - if (old_lc) - { - setlocale (LC_CTYPE, old_lc); - free (old_lc); - } -#endif - if (rc) - return rc; -#if defined(HAVE_SETLOCALE) && defined(LC_MESSAGES) - old_lc = setlocale (LC_MESSAGES, NULL); - if (old_lc) - { - old_lc = strdup (old_lc); - if (!old_lc) - return gpg_error_from_syserror (); - } - dft_lc = setlocale (LC_MESSAGES, ""); -#endif - if (opt.lc_messages || (dft_ttyname && dft_lc)) - { - char *optstr; - if (asprintf (&optstr, "OPTION lc-messages=%s", - opt.lc_messages ? opt.lc_messages : dft_lc) < 0) - rc = gpg_error_from_syserror (); - else - { - rc = assuan_transact (agent_ctx, optstr, NULL, NULL, NULL, NULL, NULL, - NULL); - free (optstr); - } - } -#if defined(HAVE_SETLOCALE) && defined(LC_MESSAGES) - if (old_lc) - { - setlocale (LC_MESSAGES, old_lc); - free (old_lc); - } -#endif - - return rc; + return send_pinentry_environment (agent_ctx, GPG_ERR_SOURCE_DEFAULT, + opt.display, opt.ttyname, opt.ttytype, + opt.lc_ctype, opt.lc_messages); } Modified: trunk/include/ChangeLog =================================================================== --- trunk/include/ChangeLog 2006-09-19 16:25:51 UTC (rev 4256) +++ trunk/include/ChangeLog 2006-09-20 11:01:49 UTC (rev 4257) @@ -1,3 +1,9 @@ +2006-09-20 Werner Koch + + * errors.h, http.h, memory.h, mpi.h, util.h, i18n.h: Removed. + * Makefile.am: New. + * distfiles: Removed. + 2006-08-16 Werner Koch * keyserver.h: Moved to ../common. Added: trunk/include/Makefile.am =================================================================== --- trunk/include/Makefile.am 2006-09-19 16:25:51 UTC (rev 4256) +++ trunk/include/Makefile.am 2006-09-20 11:01:49 UTC (rev 4257) @@ -0,0 +1 @@ +EXTRA_DIST = cipher.h types.h host2net.h _regex.h Deleted: trunk/include/distfiles Deleted: trunk/include/errors.h Deleted: trunk/include/http.h Deleted: trunk/include/i18n.h Deleted: trunk/include/memory.h Deleted: trunk/include/mpi.h Deleted: trunk/include/util.h Modified: trunk/kbx/ChangeLog =================================================================== --- trunk/kbx/ChangeLog 2006-09-19 16:25:51 UTC (rev 4256) +++ trunk/kbx/ChangeLog 2006-09-20 11:01:49 UTC (rev 4257) @@ -1,3 +1,7 @@ +2006-09-20 Werner Koch + + * Makefile.am ($(PROGRAMS): New. + 2006-09-14 Werner Koch Replaced all call gpg_error_from_errno(errno) by Modified: trunk/kbx/Makefile.am =================================================================== --- trunk/kbx/Makefile.am 2006-09-19 16:25:51 UTC (rev 4256) +++ trunk/kbx/Makefile.am 2006-09-20 11:01:49 UTC (rev 4257) @@ -50,3 +50,4 @@ $(KSBA_LIBS) $(LIBGCRYPT_LIBS) \ -lgpg-error $(LIBINTL) ../common/libcommon.a +$(PROGRAMS) : ../jnlib/libjnlib.a ../gl/libgnu.a ../common/libcommon.a Modified: trunk/keyserver/Makefile.am =================================================================== --- trunk/keyserver/Makefile.am 2006-09-19 16:25:51 UTC (rev 4256) +++ trunk/keyserver/Makefile.am 2006-09-20 11:01:49 UTC (rev 4257) @@ -32,7 +32,7 @@ libexec_SCRIPTS = $(GPGKEYS_MAILTO) noinst_SCRIPTS = gpgkeys_test -needed_libs = ../gl/libgnu.a ../common/libcommon.a ../jnlib/libjnlib.a +common_libs = ../gl/libgnu.a ../common/libcommon.a ../jnlib/libjnlib.a other_libs = $(LIBICONV) $(LIBINTL) $(CAPLIBS) gpg2keys_ldap_SOURCES = gpgkeys_ldap.c ksutil.c ksutil.h no-libgcrypt.c @@ -42,18 +42,18 @@ gpg2keys_ldap_CPPFLAGS = $(LDAP_CPPFLAGS) $(AM_CPPFLAGS) -gpg2keys_ldap_LDADD = $(needed_libs) $(LDAPLIBS) $(NETLIBS) \ +gpg2keys_ldap_LDADD = $(common_libs) $(LDAPLIBS) $(NETLIBS) \ $(other_libs) $(W32LIBS) -gpg2keys_finger_LDADD = $(needed_libs) $(LIBGCRYPT_LIBS) \ +gpg2keys_finger_LDADD = $(common_libs) $(LIBGCRYPT_LIBS) \ $(NETLIBS) $(other_libs) $(W32LIBS) if FAKE_CURL gpg2keys_curl_SOURCES += curl-shim.c curl-shim.h -gpg2keys_curl_LDADD = $(needed_libs) $(NETLIBS) $(DNSLIBS) \ +gpg2keys_curl_LDADD = $(common_libs) $(NETLIBS) $(DNSLIBS) \ $(other_libs) $(W32LIBS) gpg2keys_hkp_SOURCES += curl-shim.c curl-shim.h -gpg2keys_hkp_LDADD = $(needed_libs) $(NETLIBS) $(DNSLIBS) \ +gpg2keys_hkp_LDADD = $(common_libs) $(NETLIBS) $(DNSLIBS) \ $(other_libs) $(W32LIBS) else gpg2keys_curl_CPPFLAGS = $(LIBCURL_CPPFLAGS) $(AM_CPPFLAGS) @@ -62,3 +62,8 @@ gpg2keys_hkp_LDADD = $(LIBCURL) $(GETOPT) endif +# Make sure that all libs are build before we use them. This is +# important for things like make -j2. +$(PROGRAMS): $(common_libs) + + Modified: trunk/sm/ChangeLog =================================================================== --- trunk/sm/ChangeLog 2006-09-19 16:25:51 UTC (rev 4256) +++ trunk/sm/ChangeLog 2006-09-20 11:01:49 UTC (rev 4257) @@ -1,3 +1,7 @@ +2006-09-20 Werner Koch + + * Makefile.am: Changes to allow parallel make runs. + 2006-09-18 Werner Koch * gpgsm.c (main): Use this to import standard certificates. Modified: trunk/sm/Makefile.am =================================================================== --- trunk/sm/Makefile.am 2006-09-19 16:25:51 UTC (rev 4256) +++ trunk/sm/Makefile.am 2006-09-20 11:01:49 UTC (rev 4257) @@ -54,9 +54,18 @@ qualified.c -gpgsm_LDADD = ../jnlib/libjnlib.a ../kbx/libkeybox.a \ - ../common/libcommon.a ../gl/libgnu.a \ +common_libs = ../jnlib/libjnlib.a ../kbx/libkeybox.a \ + ../common/libcommon.a ../gl/libgnu.a + +gpgsm_LDADD = $(common_libs) \ $(LIBGCRYPT_LIBS) $(KSBA_LIBS) $(LIBASSUAN_LIBS) -lgpg-error \ $(LIBINTL) $(PTH_LIBS) $(ZLIBS) +# Make sure that all libs are build before we use them. This is +# important for things like make -j2. +$(PROGRAMS): $(common_libs) + + + + Modified: trunk/tools/ChangeLog =================================================================== --- trunk/tools/ChangeLog 2006-09-19 16:25:51 UTC (rev 4256) +++ trunk/tools/ChangeLog 2006-09-20 11:01:49 UTC (rev 4257) @@ -1,3 +1,7 @@ +2006-09-20 Werner Koch + + * Makefile.am: Changes to allow parallel make runs. + 2006-09-12 Werner Koch Replaced all call gpg_error_from_errno(errno) by Modified: trunk/tools/Makefile.am =================================================================== --- trunk/tools/Makefile.am 2006-09-19 16:25:51 UTC (rev 4256) +++ trunk/tools/Makefile.am 2006-09-20 11:01:49 UTC (rev 4257) @@ -51,6 +51,7 @@ noinst_PROGRAMS = clean-sat mk-tdata make-dns-cert common_libs = ../jnlib/libjnlib.a ../common/libcommon.a ../gl/libgnu.a +pwquery_libs = ../common/libsimple-pwquery.a gpgsplit_LDADD = $(common_libs) $(LIBGCRYPT_LIBS) $(GPG_ERROR_LIBS) $(ZLIBS) @@ -58,24 +59,20 @@ # jnlib/common sucks in gpg-error, will they, nil they (some compilers # do not eliminate the supposed-to-be-unused-inline-functions). -gpgconf_LDADD = ../jnlib/libjnlib.a ../common/libcommon.a \ - ../gl/libgnu.a $(LIBINTL) $(GPG_ERROR_LIBS) +gpgconf_LDADD = $(common_libs) $(LIBINTL) $(GPG_ERROR_LIBS) gpgparsemail_SOURCES = gpgparsemail.c rfc822parse.c rfc822parse.h gpgparsemail_LDADD = symcryptrun_SOURCES = symcryptrun.c -symcryptrun_LDADD = $(LIBUTIL_LIBS) ../jnlib/libjnlib.a \ - ../common/libcommon.a ../gl/libgnu.a \ - ../common/libsimple-pwquery.a $(LIBGCRYPT_LIBS) \ - $(GPG_ERROR_LIBS) $(LIBINTL) +symcryptrun_LDADD = $(LIBUTIL_LIBS) $(common_libs) $(pwquery_libs) \ + $(LIBGCRYPT_LIBS) $(GPG_ERROR_LIBS) $(LIBINTL) watchgnupg_SOURCES = watchgnupg.c watchgnupg_LDADD = $(NETLIBS) gpg_connect_agent_SOURCES = gpg-connect-agent.c no-libgcrypt.c -gpg_connect_agent_LDADD = ../jnlib/libjnlib.a \ - ../common/libcommon.a ../gl/libgnu.a \ +gpg_connect_agent_LDADD = $(common_libs) \ $(LIBASSUAN_LIBS) $(GPG_ERROR_LIBS) $(LIBINTL) gpgkey2ssh_SOURCES = gpgkey2ssh.c @@ -86,3 +83,7 @@ $(LIBGCRYPT_LIBS) $(GPG_ERROR_LIBS) +# Make sure that all libs are build before we use them. This is +# important for things like make -j2. +$(PROGRAMS): $(common_libs) $(pwquery_libs) + From cvs at cvs.gnupg.org Thu Sep 21 15:30:49 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu Sep 21 14:45:14 2006 Subject: [svn] GnuPG - r4258 - in trunk: common doc g10 sm Message-ID: Author: wk Date: 2006-09-21 15:30:45 +0200 (Thu, 21 Sep 2006) New Revision: 4258 Added: trunk/common/common-defs.h Modified: trunk/common/ChangeLog trunk/common/Makefile.am trunk/common/iobuf.c trunk/common/ttyio.c trunk/common/ttyio.h trunk/common/util.h trunk/doc/gpgsm.texi trunk/doc/yat2m.c trunk/g10/ChangeLog trunk/g10/Makefile.am trunk/g10/card-util.c trunk/g10/comment.c trunk/g10/gpg.c trunk/g10/gpgv.c trunk/g10/keyedit.c trunk/g10/signal.c trunk/sm/ChangeLog trunk/sm/gpgsm.c Log: Various updates Modified: trunk/common/ChangeLog =================================================================== --- trunk/common/ChangeLog 2006-09-20 11:01:49 UTC (rev 4257) +++ trunk/common/ChangeLog 2006-09-21 13:30:45 UTC (rev 4258) @@ -1,3 +1,13 @@ +2006-09-21 Werner Koch + + * ttyio.c (tty_private_set_rl_hooks): New. + (tty_enable_completion, tty_disable_completion): Use a hook to + enable readline support. Now always available. + (tty_cleanup_rl_after_signal): New. + + * ttyio.h: Removed readline specific stuff. Included util.h. + * common-defs.h: New. + 2006-09-15 Werner Koch * convert.c: New. Modified: trunk/common/Makefile.am =================================================================== --- trunk/common/Makefile.am 2006-09-20 11:01:49 UTC (rev 4257) +++ trunk/common/Makefile.am 2006-09-21 13:30:45 UTC (rev 4258) @@ -20,7 +20,7 @@ ## Process this file with automake to produce Makefile.in -noinst_LIBRARIES = libcommon.a libsimple-pwquery.a +noinst_LIBRARIES = libcommon.a libsimple-pwquery.a libgpgrl.a noinst_PROGRAMS = $(module_tests) TESTS = $(module_tests) @@ -30,6 +30,7 @@ $(PTH_CFLAGS) libcommon_a_SOURCES = \ + common-defs.h \ util.h i18n.h \ errors.h \ openpgpdefs.h \ @@ -63,6 +64,8 @@ libsimple_pwquery_a_SOURCES = \ simple-pwquery.c simple-pwquery.h asshelp.c asshelp.h +libgpgrl_a_SOURCES = \ + gpgrlhelp.c # # Module tests Added: trunk/common/common-defs.h =================================================================== --- trunk/common/common-defs.h 2006-09-20 11:01:49 UTC (rev 4257) +++ trunk/common/common-defs.h 2006-09-21 13:30:45 UTC (rev 4258) @@ -0,0 +1,32 @@ +/* common-defs.h - Private declarations for common/ + * Copyright (C) 2006 Free Software Foundation, Inc. + * + * This file is part of GnuPG. + * + * GnuPG 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. + * + * GnuPG 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + */ + +#ifndef GNUPG_COMMON_COMMON_DEFS_H +#define GNUPG_COMMON_COMMON_DEFS_H + +/*-- ttyio.c --*/ +void tty_private_set_rl_hooks (void (*set_completer) (rl_completion_func_t*), + void (*inhibit_completion) (int), + void (*cleanup_after_signal) (void) ); + + + +#endif /*GNUPG_COMMON_COMMON_DEFS_H*/ Modified: trunk/common/iobuf.c =================================================================== --- trunk/common/iobuf.c 2006-09-20 11:01:49 UTC (rev 4257) +++ trunk/common/iobuf.c 2006-09-21 13:30:45 UTC (rev 4258) @@ -39,7 +39,6 @@ #include #endif /* __riscos__ */ -#include "memory.h" #include "util.h" #include "iobuf.h" Modified: trunk/common/ttyio.c =================================================================== --- trunk/common/ttyio.c 2006-09-20 11:01:49 UTC (rev 4257) +++ trunk/common/ttyio.c 2006-09-21 13:30:45 UTC (rev 4258) @@ -47,15 +47,10 @@ #endif #include #include -#ifdef HAVE_LIBREADLINE -#include -#include -#endif - #include "util.h" -#include "memory.h" #include "ttyio.h" +#include "common-defs.h" #define CONTROL_D ('D' - 'A' + 1) @@ -82,8 +77,13 @@ static int restore_termios; #endif +/* Hooks set by gpgrlhelp.c if required. */ +static void (*my_rl_set_completer) (rl_completion_func_t *); +static void (*my_rl_inhibit_completion) (int); +static void (*my_rl_cleanup_after_signal) (void); + /* This is a wrapper around ttyname so that we can use it even when the standard streams are redirected. It figures the name out the first time and returns it in a statically allocated buffer. */ @@ -181,34 +181,6 @@ } -#ifdef HAVE_LIBREADLINE -void -tty_enable_completion(rl_completion_func_t *completer) -{ -/* if( no_terminal ) */ -/* return; */ - -/* if( !initialized ) */ -/* init_ttyfp(); */ - -/* rl_attempted_completion_function=completer; */ -/* rl_inhibit_completion=0; */ -} - -void -tty_disable_completion(void) -{ -/* if( no_terminal ) */ -/* return; */ - -/* if( !initialized ) */ -/* init_ttyfp(); */ - -/* rl_inhibit_completion=1; */ -} -#endif /*HAVE_LIBREADLINE*/ - - int tty_batchmode( int onoff ) { @@ -597,3 +569,48 @@ xfree(p); return yes; } + + +/* Called by gnupg_rl_initialize to setup the reradline support. */ +void +tty_private_set_rl_hooks (void (*set_completer) (rl_completion_func_t*), + void (*inhibit_completion) (int), + void (*cleanup_after_signal) (void)) +{ + my_rl_set_completer = set_completer; + my_rl_inhibit_completion = inhibit_completion; + my_rl_cleanup_after_signal = cleanup_after_signal; +} + + +void +tty_enable_completion (rl_completion_func_t *completer) +{ + if (no_terminal || !my_rl_set_completer ) + return; + + if (!initialized) + init_ttyfp(); + + my_rl_set_completer (completer); +} + +void +tty_disable_completion (void) +{ + if (no_terminal || !my_rl_inhibit_completion) + return; + + if (!initialized) + init_ttyfp(); + + my_rl_inhibit_completion (1); +} + + +void +tty_cleanup_rl_after_signal (void) +{ + if (my_rl_cleanup_after_signal) + my_rl_cleanup_after_signal (); +} Modified: trunk/common/ttyio.h =================================================================== --- trunk/common/ttyio.h 2006-09-20 11:01:49 UTC (rev 4257) +++ trunk/common/ttyio.h 2006-09-21 13:30:45 UTC (rev 4258) @@ -21,11 +21,9 @@ #ifndef GNUPG_COMMON_TTYIO_H #define GNUPG_COMMON_TTYIO_H -#ifdef HAVE_LIBREADLINE -#include -#include -#endif +#include "util.h" /* Make sure our readline typedef is available. */ + const char *tty_get_ttyname (void); int tty_batchmode (int onoff); #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 ) @@ -46,16 +44,9 @@ int tty_get_answer_is_yes (const char *prompt); int tty_no_terminal (int onoff); -#ifdef HAVE_LIBREADLINE -void tty_enable_completion(rl_completion_func_t *completer); -void tty_disable_completion(void); -#else -/* Use a macro to stub out these functions since a macro has no need - to typedef a "rl_completion_func_t" which would be undefined - without readline. */ -#define tty_enable_completion(x) -#define tty_disable_completion() -#endif +void tty_enable_completion (rl_completion_func_t *completer); +void tty_disable_completion (void); +void tty_cleanup_rl_after_signal (void); #endif /*GNUPG_COMMON_TTYIO_H*/ Modified: trunk/common/util.h =================================================================== --- trunk/common/util.h 2006-09-20 11:01:49 UTC (rev 4257) +++ trunk/common/util.h 2006-09-21 13:30:45 UTC (rev 4258) @@ -45,6 +45,13 @@ #include "../jnlib/dotlock.h" #include "../jnlib/utf8conv.h" +/* We need this type even if we are not using libreadline and or we + did not include libreadline in the current file. */ +#ifndef GNUPG_LIBREADLINE_H_INCLUDED +typedef char **rl_completion_func_t (const char *, int, int); +#endif /*!GNUPG_LIBREADLINE_H_INCLUDED*/ + + /* Handy malloc macros - please use only them. */ #define xtrymalloc(a) gcry_malloc ((a)) #define xtrymalloc_secure(a) gcry_malloc_secure ((a)) @@ -153,6 +160,8 @@ /*-- homedir.c --*/ const char *default_homedir (void); +/*-- gpgrlhelp.c --*/ +void gnupg_rl_initialize (void); /*-- miscellaneous.c --*/ Modified: trunk/doc/gpgsm.texi =================================================================== --- trunk/doc/gpgsm.texi 2006-09-20 11:01:49 UTC (rev 4257) +++ trunk/doc/gpgsm.texi 2006-09-21 13:30:45 UTC (rev 4258) @@ -189,7 +189,9 @@ Same as @option{--list-keys} but also prints all keys making up the chain. -@item --dump-keys +@item --dump-cert +@itemx --dump-keys +@opindex dump-cert @opindex dump-keys List all available certificates stored in the local key database using a format useful mainly for debugging. Modified: trunk/doc/yat2m.c =================================================================== --- trunk/doc/yat2m.c 2006-09-20 11:01:49 UTC (rev 4257) +++ trunk/doc/yat2m.c 2006-09-21 13:30:45 UTC (rev 4258) @@ -822,7 +822,7 @@ lnr++; if (!n || line[n-1] != '\n') { - err ("%s:$d: trailing linefeed missing, line too long or " + err ("%s:%d: trailing linefeed missing, line too long or " "embedded Nul character", fname, lnr); break; } Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2006-09-20 11:01:49 UTC (rev 4257) +++ trunk/g10/ChangeLog 2006-09-21 13:30:45 UTC (rev 4258) @@ -1,3 +1,14 @@ +2006-09-21 Werner Koch + + * signal.c (got_fatal_signal): Replaced readline stuff by a tty + function. + + * Makefile.am (LDADD): Include libgpgrl.a. + + * gpg.c (main): Call gpg_rl_initialize. + + * keyedit.c: Removed double inclusion of stdio.h. + 2006-09-20 Werner Koch * call-agent.c: Include asshelp.h. Modified: trunk/g10/Makefile.am =================================================================== --- trunk/g10/Makefile.am 2006-09-20 11:01:49 UTC (rev 4257) +++ trunk/g10/Makefile.am 2006-09-21 13:30:45 UTC (rev 4258) @@ -108,12 +108,13 @@ # ks-db.h \ # $(common_source) -LDADD = $(needed_libs) $(ZLIBS) $(DNSLIBS) $(LIBREADLINE) \ +LDADD = $(needed_libs) ../common/libgpgrl.a \ + $(ZLIBS) $(DNSLIBS) $(LIBREADLINE) \ $(LIBINTL) $(CAPLIBS) $(W32LIBS) gpg2_LDADD = $(LIBGCRYPT_LIBS) $(LDADD) $(LIBASSUAN_LIBS) $(GPG_ERROR_LIBS) gpgv2_LDADD = $(LIBGCRYPT_LIBS) $(LDADD) $(LIBASSUAN_LIBS) $(GPG_ERROR_LIBS) -$(PROGRAMS): $(needed_libs) +$(PROGRAMS): $(needed_libs) ../common/libgpgrl.a install-data-local: $(mkinstalldirs) $(DESTDIR)$(pkgdatadir) Modified: trunk/g10/card-util.c =================================================================== --- trunk/g10/card-util.c 2006-09-20 11:01:49 UTC (rev 4257) +++ trunk/g10/card-util.c 2006-09-21 13:30:45 UTC (rev 4258) @@ -38,6 +38,7 @@ #include "keyserver-internal.h" #if GNUPG_MAJOR_VERSION == 1 # ifdef HAVE_LIBREADLINE +# define GNUPG_LIBREADLINE_H_INCLUDED # include # include # endif /*HAVE_LIBREADLINE*/ Modified: trunk/g10/comment.c =================================================================== --- trunk/g10/comment.c 2006-09-20 11:01:49 UTC (rev 4257) +++ trunk/g10/comment.c 2006-09-21 13:30:45 UTC (rev 4258) @@ -30,7 +30,6 @@ #include "packet.h" #include "errors.h" #include "iobuf.h" -#include "memory.h" #include "util.h" #include "main.h" #include "keydb.h" Modified: trunk/g10/gpg.c =================================================================== --- trunk/g10/gpg.c 2006-09-20 11:01:49 UTC (rev 4257) +++ trunk/g10/gpg.c 2006-09-21 13:30:45 UTC (rev 4258) @@ -1771,7 +1771,8 @@ when adding any stuff between here and the call to secmem_init() somewhere after the option parsing. */ reopen_std (); - trap_unaligned(); + trap_unaligned (); + gnupg_rl_initialize (); set_strusage (my_strusage); gcry_control (GCRYCTL_SUSPEND_SECMEM_WARN); /* We don't need any locking in libgcrypt unless we use any kind of Modified: trunk/g10/gpgv.c =================================================================== --- trunk/g10/gpgv.c 2006-09-20 11:01:49 UTC (rev 4257) +++ trunk/g10/gpgv.c 2006-09-21 13:30:45 UTC (rev 4258) @@ -31,7 +31,7 @@ #include /* for setmode() */ #endif #ifdef HAVE_LIBREADLINE -#include +#define GNUPG_LIBREADLINE_H_INCLUDED #include #endif Modified: trunk/g10/keyedit.c =================================================================== --- trunk/g10/keyedit.c 2006-09-20 11:01:49 UTC (rev 4257) +++ trunk/g10/keyedit.c 2006-09-21 13:30:45 UTC (rev 4258) @@ -28,7 +28,7 @@ #include #include #ifdef HAVE_LIBREADLINE -#include +#define GNUPG_LIBREADLINE_H_INCLUDED #include #endif Modified: trunk/g10/signal.c =================================================================== --- trunk/g10/signal.c 2006-09-20 11:01:49 UTC (rev 4257) +++ trunk/g10/signal.c 2006-09-21 13:30:45 UTC (rev 4258) @@ -28,10 +28,6 @@ #include #include #include -#ifdef HAVE_LIBREADLINE -#include -#include -#endif #include "gpg.h" #include "options.h" @@ -86,10 +82,7 @@ gcry_control (GCRYCTL_TERM_SECMEM ); -#ifdef HAVE_LIBREADLINE - rl_free_line_state (); - rl_cleanup_after_signal (); -#endif + tty_cleanup_rl_after_signal (); /* Better don't translate these messages. */ write(2, "\n", 1 ); Modified: trunk/sm/ChangeLog =================================================================== --- trunk/sm/ChangeLog 2006-09-20 11:01:49 UTC (rev 4257) +++ trunk/sm/ChangeLog 2006-09-21 13:30:45 UTC (rev 4258) @@ -1,5 +1,7 @@ 2006-09-20 Werner Koch + * gpgsm.c: Add alias command --dump-cert. + * Makefile.am: Changes to allow parallel make runs. 2006-09-18 Werner Koch Modified: trunk/sm/gpgsm.c =================================================================== --- trunk/sm/gpgsm.c 2006-09-20 11:01:49 UTC (rev 4257) +++ trunk/sm/gpgsm.c 2006-09-21 13:30:45 UTC (rev 4258) @@ -268,6 +268,7 @@ { aPasswd, "passwd", 256, N_("change a passphrase")}, { aGPGConfList, "gpgconf-list", 256, "@" }, + { aDumpKeys, "dump-cert", 256, "@"}, { aDumpKeys, "dump-keys", 256, "@"}, { aDumpChain, "dump-chain", 256, "@"}, { aDumpExternalKeys, "dump-external-keys", 256, "@"}, From cvs at cvs.gnupg.org Fri Sep 22 13:39:47 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri Sep 22 12:54:06 2006 Subject: [svn] GnuPG - r4259 - in trunk: . common keyserver tools Message-ID: Author: wk Date: 2006-09-22 13:39:45 +0200 (Fri, 22 Sep 2006) New Revision: 4259 Modified: trunk/AUTHORS trunk/ChangeLog trunk/common/ChangeLog trunk/common/common-defs.h trunk/common/i18n.h trunk/common/ttyio.c trunk/keyserver/ChangeLog trunk/keyserver/Makefile.am trunk/keyserver/curl-shim.c trunk/keyserver/curl-shim.h trunk/keyserver/gpgkeys_curl.c trunk/keyserver/gpgkeys_finger.c trunk/keyserver/gpgkeys_hkp.c trunk/keyserver/gpgkeys_ldap.c trunk/keyserver/ksutil.c trunk/keyserver/ksutil.h trunk/tools/ChangeLog trunk/tools/no-libgcrypt.c Log: Clarified cURL and OpenLDAP license issues. Made readline support work. Modified: trunk/AUTHORS =================================================================== --- trunk/AUTHORS 2006-09-21 13:30:45 UTC (rev 4258) +++ trunk/AUTHORS 2006-09-22 11:39:45 UTC (rev 4259) @@ -125,9 +125,35 @@ The RPM specs file scripts/gnupg.spec has been contributed by several people. - Copyright 1998, 1999, 2000, 2001, 2002, 2004, - 2005 Free Software Foundation, Inc. +Copyright +========= + +GnuPG is distributed under the GNU General Public License, version 2 +or later. A few files are under the Lesser General Public License, a +few other files carry the all permissive license note as found at the +bottom of this file. Certain files in keyserver/ allow one specific +exception: + + In addition, as a special exception, the Free Software Foundation + gives permission to link the code of the keyserver helper tools: + gpgkeys_ldap, gpgkeys_curl and gpgkeys_hkp with the OpenSSL + project's "OpenSSL" library (or with modified versions of it that + use the same license as the "OpenSSL" library), and distribute the + linked executables. You must obey the GNU General Public License + in all respects for all of the code used other than "OpenSSL". If + you modify this file, you may extend this exception to your version + of the file, but you are not obligated to do so. If you do not + wish to do so, delete this exception statement from your version. + +Note that the gpgkeys_* binaries are currently installed under the +name gpg2keys_*. + +========= + + Copyright 1998, 1999, 2000, 2001, 2002, 2004, 2005, + 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 modifications, as long as this notice is preserved. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-09-21 13:30:45 UTC (rev 4258) +++ trunk/ChangeLog 2006-09-22 11:39:45 UTC (rev 4259) @@ -1,3 +1,7 @@ +2006-09-22 Werner Koch + + * AUTHORS: Add information about used licenses. + 2006-09-20 Werner Koch * Makefile.am (dist-hook): Removed distfiles cruft. Modified: trunk/common/ChangeLog =================================================================== --- trunk/common/ChangeLog 2006-09-21 13:30:45 UTC (rev 4258) +++ trunk/common/ChangeLog 2006-09-22 11:39:45 UTC (rev 4259) @@ -1,3 +1,10 @@ +2006-09-22 Werner Koch + + * i18n.h: Changed license to an all permissive one. + + * ttyio.c (tty_get): We need to use readline too. Added two more + hooks. + 2006-09-21 Werner Koch * ttyio.c (tty_private_set_rl_hooks): New. Modified: trunk/common/common-defs.h =================================================================== --- trunk/common/common-defs.h 2006-09-21 13:30:45 UTC (rev 4258) +++ trunk/common/common-defs.h 2006-09-22 11:39:45 UTC (rev 4259) @@ -23,9 +23,12 @@ #define GNUPG_COMMON_COMMON_DEFS_H /*-- ttyio.c --*/ -void tty_private_set_rl_hooks (void (*set_completer) (rl_completion_func_t*), +void tty_private_set_rl_hooks (void (*init_stream) (FILE *), + void (*set_completer) (rl_completion_func_t*), void (*inhibit_completion) (int), - void (*cleanup_after_signal) (void) ); + void (*cleanup_after_signal) (void), + char *(*readline_fun) (const char*), + void (*add_history_fun) (const char*)); Modified: trunk/common/i18n.h =================================================================== --- trunk/common/i18n.h 2006-09-21 13:30:45 UTC (rev 4258) +++ trunk/common/i18n.h 2006-09-22 11:39:45 UTC (rev 4259) @@ -1,22 +1,14 @@ /* i18n.h * Copyright (C) 1998, 2001 Free Software Foundation, Inc. * - * This file is part of GnuPG. - * - * GnuPG 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. - * - * GnuPG 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. + * 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 GNUPG_COMMON_I18N_H Modified: trunk/common/ttyio.c =================================================================== --- trunk/common/ttyio.c 2006-09-21 13:30:45 UTC (rev 4258) +++ trunk/common/ttyio.c 2006-09-22 11:39:45 UTC (rev 4259) @@ -81,9 +81,11 @@ static void (*my_rl_set_completer) (rl_completion_func_t *); static void (*my_rl_inhibit_completion) (int); static void (*my_rl_cleanup_after_signal) (void); +static void (*my_rl_init_stream) (FILE *); +static char *(*my_rl_readline) (const char*); +static void (*my_rl_add_history) (const char*); - /* This is a wrapper around ttyname so that we can use it even when the standard streams are redirected. It figures the name out the first time and returns it in a statically allocated buffer. */ @@ -174,6 +176,10 @@ exit(2); } #endif + + if (my_rl_init_stream) + my_rl_init_stream (ttyfp); + #ifdef HAVE_TCGETATTR atexit( cleanup ); #endif @@ -520,7 +526,39 @@ char * tty_get( const char *prompt ) { - return do_get( prompt, 0 ); + if (!batchmode && !no_terminal && my_rl_readline && my_rl_add_history) + { + char *line; + char *buf; + + if (!initialized) + init_ttyfp(); + + last_prompt_len = 0; + + line = my_rl_readline (prompt?prompt:""); + + /* We need to copy it to memory controlled by our malloc + implementations; further we need to convert an EOF to our + convention. */ + buf = xmalloc(line? strlen(line)+1:2); + if (line) + { + strcpy (buf, line); + trim_spaces (buf); + if (strlen (buf) > 2 ) + my_rl_add_history (line); /* Note that we test BUF but add LINE. */ + free (line); + } + else + { + buf[0] = CONTROL_D; + buf[1] = 0; + } + return buf; + } + else + return do_get ( prompt, 0 ); } char * @@ -573,13 +611,19 @@ /* Called by gnupg_rl_initialize to setup the reradline support. */ void -tty_private_set_rl_hooks (void (*set_completer) (rl_completion_func_t*), +tty_private_set_rl_hooks (void (*init_stream) (FILE *), + void (*set_completer) (rl_completion_func_t*), void (*inhibit_completion) (int), - void (*cleanup_after_signal) (void)) + void (*cleanup_after_signal) (void), + char *(*readline_fun) (const char*), + void (*add_history_fun) (const char*)) { + my_rl_init_stream = init_stream; my_rl_set_completer = set_completer; my_rl_inhibit_completion = inhibit_completion; my_rl_cleanup_after_signal = cleanup_after_signal; + my_rl_readline = readline_fun; + my_rl_add_history = add_history_fun; } Modified: trunk/keyserver/ChangeLog =================================================================== --- trunk/keyserver/ChangeLog 2006-09-21 13:30:45 UTC (rev 4258) +++ trunk/keyserver/ChangeLog 2006-09-22 11:39:45 UTC (rev 4259) @@ -1,3 +1,25 @@ +2006-09-22 Werner Koch + + * gpgkeys_curl.c, gpgkeys_hkp.c, gpgkeys_ldap.c, curl-shim.c: + * curl-shim.h, ksutil.c, ksutil.h: Add special license exception + for OpenSSL. This helps to avoid license conflicts if OpenLDAP or + cURL is linked against OpenSSL and we would thus indirectly link + to OpenSSL. This is considered a bug fix and forgives all + possible violations, pertaining to this issue, possibly occured in + the past. + + * Makefile.am (gpg2keys_ldap_LDADD): For license reasons do not + link against common_libs. + (gpg2keys_curl_LDADD, gpg2keys_hkp_LDADD): Ditto. + * ksutil.c (ks_hextobyte, ks_toupper, ks_strcasecmp): New. + Identical to the ascii_foo versions from jnlib. + * gpgkeys_ldap.c: Include assert.h. + (main): Replace BUG by assert. + (build_attrs): Use ks_hextobyte and ks_strcasecmp. + + * gpgkeys_finger.c (get_key): Resolved signed/unisgned char + mismatch. + 2006-09-19 Werner Koch * no-libgcrypt.c: New. Taken from ../tools. Modified: trunk/keyserver/Makefile.am =================================================================== --- trunk/keyserver/Makefile.am 2006-09-21 13:30:45 UTC (rev 4258) +++ trunk/keyserver/Makefile.am 2006-09-22 11:39:45 UTC (rev 4259) @@ -18,6 +18,10 @@ ## Process this file with automake to produce Makefile.in +# Note that we have renamed the resulting binaries to from gpgkeys_foo +# to gpg2keys_foo to allow for a non-conflicting installation of +# gnupg1 and gnupg2. Having the same names for the helpers would +# otherwise lead to trouble when to uninstall one of them. EXTRA_PROGRAMS = gpg2keys_ldap gpg2keys_hkp gpg2keys_finger gpg2keys_curl EXTRA_SCRIPTS = gpg2keys_mailto @@ -32,7 +36,7 @@ libexec_SCRIPTS = $(GPGKEYS_MAILTO) noinst_SCRIPTS = gpgkeys_test -common_libs = ../gl/libgnu.a ../common/libcommon.a ../jnlib/libjnlib.a +common_libs = ../gl/libgnu.a ../common/libcommon.a ../jnlib/libjnlib.a other_libs = $(LIBICONV) $(LIBINTL) $(CAPLIBS) gpg2keys_ldap_SOURCES = gpgkeys_ldap.c ksutil.c ksutil.h no-libgcrypt.c @@ -42,7 +46,7 @@ gpg2keys_ldap_CPPFLAGS = $(LDAP_CPPFLAGS) $(AM_CPPFLAGS) -gpg2keys_ldap_LDADD = $(common_libs) $(LDAPLIBS) $(NETLIBS) \ +gpg2keys_ldap_LDADD = $(LDAPLIBS) $(NETLIBS) \ $(other_libs) $(W32LIBS) gpg2keys_finger_LDADD = $(common_libs) $(LIBGCRYPT_LIBS) \ @@ -50,10 +54,10 @@ if FAKE_CURL gpg2keys_curl_SOURCES += curl-shim.c curl-shim.h -gpg2keys_curl_LDADD = $(common_libs) $(NETLIBS) $(DNSLIBS) \ +gpg2keys_curl_LDADD = $(NETLIBS) $(DNSLIBS) \ $(other_libs) $(W32LIBS) gpg2keys_hkp_SOURCES += curl-shim.c curl-shim.h -gpg2keys_hkp_LDADD = $(common_libs) $(NETLIBS) $(DNSLIBS) \ +gpg2keys_hkp_LDADD = $(NETLIBS) $(DNSLIBS) \ $(other_libs) $(W32LIBS) else gpg2keys_curl_CPPFLAGS = $(LIBCURL_CPPFLAGS) $(AM_CPPFLAGS) Modified: trunk/keyserver/curl-shim.c =================================================================== --- trunk/keyserver/curl-shim.c 2006-09-21 13:30:45 UTC (rev 4258) +++ trunk/keyserver/curl-shim.c 2006-09-22 11:39:45 UTC (rev 4259) @@ -19,6 +19,17 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. + * + * In addition, as a special exception, the Free Software Foundation + * gives permission to link the code of the keyserver helper tools: + * gpgkeys_ldap, gpgkeys_curl and gpgkeys_hkp with the OpenSSL + * project's "OpenSSL" library (or with modified versions of it that + * use the same license as the "OpenSSL" library), and distribute the + * linked executables. You must obey the GNU General Public License + * in all respects for all of the code used other than "OpenSSL". If + * you modify this file, you may extend this exception to your version + * of the file, but you are not obligated to do so. If you do not + * wish to do so, delete this exception statement from your version. */ #include Modified: trunk/keyserver/curl-shim.h =================================================================== --- trunk/keyserver/curl-shim.h 2006-09-21 13:30:45 UTC (rev 4258) +++ trunk/keyserver/curl-shim.h 2006-09-22 11:39:45 UTC (rev 4259) @@ -17,6 +17,17 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. + * + * In addition, as a special exception, the Free Software Foundation + * gives permission to link the code of the keyserver helper tools: + * gpgkeys_ldap, gpgkeys_curl and gpgkeys_hkp with the OpenSSL + * project's "OpenSSL" library (or with modified versions of it that + * use the same license as the "OpenSSL" library), and distribute the + * linked executables. You must obey the GNU General Public License + * in all respects for all of the code used other than "OpenSSL". If + * you modify this file, you may extend this exception to your version + * of the file, but you are not obligated to do so. If you do not + * wish to do so, delete this exception statement from your version. */ #ifndef _CURL_SHIM_H_ Modified: trunk/keyserver/gpgkeys_curl.c =================================================================== --- trunk/keyserver/gpgkeys_curl.c 2006-09-21 13:30:45 UTC (rev 4258) +++ trunk/keyserver/gpgkeys_curl.c 2006-09-22 11:39:45 UTC (rev 4259) @@ -17,6 +17,17 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. + * + * In addition, as a special exception, the Free Software Foundation + * gives permission to link the code of the keyserver helper tools: + * gpgkeys_ldap, gpgkeys_curl and gpgkeys_hkp with the OpenSSL + * project's "OpenSSL" library (or with modified versions of it that + * use the same license as the "OpenSSL" library), and distribute the + * linked executables. You must obey the GNU General Public License + * in all respects for all of the code used other than "OpenSSL". If + * you modify this file, you may extend this exception to your version + * of the file, but you are not obligated to do so. If you do not + * wish to do so, delete this exception statement from your version. */ #include Modified: trunk/keyserver/gpgkeys_finger.c =================================================================== --- trunk/keyserver/gpgkeys_finger.c 2006-09-21 13:30:45 UTC (rev 4258) +++ trunk/keyserver/gpgkeys_finger.c 2006-09-22 11:39:45 UTC (rev 4259) @@ -325,13 +325,13 @@ if(gotit) { - print_nocr(output,line); - if (!strncmp(line,END,strlen(END))) + print_nocr(output, (const char*)line); + if (!strncmp((char*)line,END,strlen(END))) break; } - else if(!strncmp(line,BEGIN,strlen(BEGIN))) + else if(!strncmp((char*)line,BEGIN,strlen(BEGIN))) { - print_nocr(output,line); + print_nocr(output, (const char*)line); gotit=1; } } Modified: trunk/keyserver/gpgkeys_hkp.c =================================================================== --- trunk/keyserver/gpgkeys_hkp.c 2006-09-21 13:30:45 UTC (rev 4258) +++ trunk/keyserver/gpgkeys_hkp.c 2006-09-22 11:39:45 UTC (rev 4259) @@ -17,6 +17,17 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. + * + * In addition, as a special exception, the Free Software Foundation + * gives permission to link the code of the keyserver helper tools: + * gpgkeys_ldap, gpgkeys_curl and gpgkeys_hkp with the OpenSSL + * project's "OpenSSL" library (or with modified versions of it that + * use the same license as the "OpenSSL" library), and distribute the + * linked executables. You must obey the GNU General Public License + * in all respects for all of the code used other than "OpenSSL". If + * you modify this file, you may extend this exception to your version + * of the file, but you are not obligated to do so. If you do not + * wish to do so, delete this exception statement from your version. */ #include Modified: trunk/keyserver/gpgkeys_ldap.c =================================================================== --- trunk/keyserver/gpgkeys_ldap.c 2006-09-21 13:30:45 UTC (rev 4258) +++ trunk/keyserver/gpgkeys_ldap.c 2006-09-22 11:39:45 UTC (rev 4259) @@ -17,6 +17,17 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. + * + * In addition, as a special exception, the Free Software Foundation + * gives permission to link the code of the keyserver helper tools: + * gpgkeys_ldap, gpgkeys_curl and gpgkeys_hkp with the OpenSSL + * project's "OpenSSL" library (or with modified versions of it that + * use the same license as the "OpenSSL" library), and distribute the + * linked executables. You must obey the GNU General Public License + * in all respects for all of the code used other than "OpenSSL". If + * you modify this file, you may extend this exception to your version + * of the file, but you are not obligated to do so. If you do not + * wish to do so, delete this exception statement from your version. */ #include @@ -29,6 +40,7 @@ #endif #include #include +#include #ifdef _WIN32 #include @@ -355,7 +367,7 @@ if((record=strsep(&line,":"))==NULL) return; - if(ascii_strcasecmp("pub",record)==0) + if(ks_strcasecmp("pub",record)==0) { char *tok; int disabled=0,revoked=0; @@ -461,7 +473,7 @@ make_one_attr(modlist,"pgpDisabled",disabled?"1":"0"); make_one_attr(modlist,"pgpRevoked",revoked?"1":"0"); } - else if(ascii_strcasecmp("sub",record)==0) + else if(ks_strcasecmp("sub",record)==0) { char *tok; @@ -499,7 +511,7 @@ /* Ignore the rest of the items for subkeys since the LDAP schema doesn't store them. */ } - else if(ascii_strcasecmp("uid",record)==0) + else if(ks_strcasecmp("uid",record)==0) { char *userid,*tok; @@ -520,7 +532,7 @@ while(*tok) if(tok[0]=='%' && tok[1] && tok[2]) { - if((userid[i]=hextobyte(&tok[1]))==-1) + if((userid[i]=ks_hextobyte(&tok[1]))==-1) userid[i]='?'; i++; @@ -536,7 +548,7 @@ make_one_attr(modlist,"pgpUserID",userid); } - else if(ascii_strcasecmp("sig",record)==0) + else if(ks_strcasecmp("sig",record)==0) { char *tok; @@ -2325,7 +2337,7 @@ free(searchkey); } else - BUG(); + assert (!"bad action"); if(!failed) ret=KEYSERVER_OK; Modified: trunk/keyserver/ksutil.c =================================================================== --- trunk/keyserver/ksutil.c 2006-09-21 13:30:45 UTC (rev 4258) +++ trunk/keyserver/ksutil.c 2006-09-22 11:39:45 UTC (rev 4259) @@ -17,6 +17,17 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. + * + * In addition, as a special exception, the Free Software Foundation + * gives permission to link the code of the keyserver helper tools: + * gpgkeys_ldap, gpgkeys_curl and gpgkeys_hkp with the OpenSSL + * project's "OpenSSL" library (or with modified versions of it that + * use the same license as the "OpenSSL" library), and distribute the + * linked executables. You must obey the GNU General Public License + * in all respects for all of the code used other than "OpenSSL". If + * you modify this file, you may extend this exception to your version + * of the file, but you are not obligated to do so. If you do not + * wish to do so, delete this exception statement from your version. */ #include @@ -538,3 +549,55 @@ ctx->flags.done=1; } } + + +int +ks_hextobyte (const char *s) +{ + int c; + + if ( *s >= '0' && *s <= '9' ) + c = 16 * (*s - '0'); + else if ( *s >= 'A' && *s <= 'F' ) + c = 16 * (10 + *s - 'A'); + else if ( *s >= 'a' && *s <= 'f' ) + c = 16 * (10 + *s - 'a'); + else + return -1; + s++; + if ( *s >= '0' && *s <= '9' ) + c += *s - '0'; + else if ( *s >= 'A' && *s <= 'F' ) + c += 10 + *s - 'A'; + else if ( *s >= 'a' && *s <= 'f' ) + c += 10 + *s - 'a'; + else + return -1; + return c; +} + + +/* Non localized version of toupper. */ +int +ks_toupper (int c) +{ + if (c >= 'a' && c <= 'z') + c &= ~0x20; + return c; +} + + +/* Non localized version of strcasecmp. */ +int +ks_strcasecmp (const char *a, const char *b) +{ + if (a == b) + return 0; + + for (; *a && *b; a++, b++) + { + if (*a != *b && ks_toupper (*a) != ks_toupper (*b)) + break; + } + return *a == *b? 0 : (ks_toupper (*a) - ks_toupper (*b)); +} Modified: trunk/keyserver/ksutil.h =================================================================== --- trunk/keyserver/ksutil.h 2006-09-21 13:30:45 UTC (rev 4258) +++ trunk/keyserver/ksutil.h 2006-09-22 11:39:45 UTC (rev 4259) @@ -1,14 +1,14 @@ /* ksutil.h * Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. * - * This file is part of GNUPG. + * This file is part of GnuPG. * - * GNUPG is free software; you can redistribute it and/or modify + * GnuPG 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. * - * GNUPG is distributed in the hope that it will be useful, + * GnuPG 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. @@ -17,6 +17,17 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. + * + * In addition, as a special exception, the Free Software Foundation + * gives permission to link the code of the keyserver helper tools: + * gpgkeys_ldap, gpgkeys_curl and gpgkeys_hkp with the OpenSSL + * project's "OpenSSL" library (or with modified versions of it that + * use the same license as the "OpenSSL" library), and distribute the + * linked executables. You must obey the GNU General Public License + * in all respects for all of the code used other than "OpenSSL". If + * you modify this file, you may extend this exception to your version + * of the file, but you are not obligated to do so. If you do not + * wish to do so, delete this exception statement from your version. */ #ifndef _KSUTIL_H_ @@ -127,4 +138,9 @@ size_t curl_writer(const void *ptr,size_t size,size_t nmemb,void *cw_ctx); void curl_writer_finalize(struct curl_writer_ctx *ctx); +int ks_hextobyte (const char *s); +int ks_toupper (int c); +int ks_strcasecmp (const char *a, const char *b); + + #endif /* !_KSUTIL_H_ */ Modified: trunk/tools/ChangeLog =================================================================== --- trunk/tools/ChangeLog 2006-09-21 13:30:45 UTC (rev 4258) +++ trunk/tools/ChangeLog 2006-09-22 11:39:45 UTC (rev 4259) @@ -1,3 +1,7 @@ +2006-09-22 Werner Koch + + * no-libgcrypt.c: Changed license to a simple all permissive one. + 2006-09-20 Werner Koch * Makefile.am: Changes to allow parallel make runs. Modified: trunk/tools/no-libgcrypt.c =================================================================== --- trunk/tools/no-libgcrypt.c 2006-09-21 13:30:45 UTC (rev 4258) +++ trunk/tools/no-libgcrypt.c 2006-09-22 11:39:45 UTC (rev 4259) @@ -1,22 +1,14 @@ /* no-libgcrypt.c - Replacement functions for libgcrypt. * Copyright (C) 2003 Free Software Foundation, Inc. * - * This file is part of GnuPG. - * - * GnuPG 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. - * - * GnuPG 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. + * 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. */ #include From cvs at cvs.gnupg.org Fri Sep 22 14:29:37 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Fri Sep 22 13:43:54 2006 Subject: [svn] gpgme - r1181 - trunk/gpgme Message-ID: Author: marcus Date: 2006-09-22 14:29:36 +0200 (Fri, 22 Sep 2006) New Revision: 1181 Modified: trunk/gpgme/ChangeLog trunk/gpgme/keylist.c Log: 2006-09-22 Marcus Brinkmann * keylist.c (keylist_colon_handler): Move debug output after initialising KEY. Modified: trunk/gpgme/ChangeLog =================================================================== --- trunk/gpgme/ChangeLog 2006-09-19 14:01:54 UTC (rev 1180) +++ trunk/gpgme/ChangeLog 2006-09-22 12:29:36 UTC (rev 1181) @@ -1,3 +1,8 @@ +2006-09-22 Marcus Brinkmann + + * keylist.c (keylist_colon_handler): Move debug output after + initialising KEY. + 2006-07-29 Marcus Brinkmann * gpgme-config.in (Options): Add NETLIBS. Modified: trunk/gpgme/keylist.c =================================================================== --- trunk/gpgme/keylist.c 2006-09-19 14:01:54 UTC (rev 1180) +++ trunk/gpgme/keylist.c 2006-09-22 12:29:36 UTC (rev 1181) @@ -386,9 +386,6 @@ gpgme_subkey_t subkey = NULL; gpgme_key_sig_t keysig = NULL; - DEBUG3 ("keylist_colon_handler ctx = %p, key = %p, line = %s\n", - ctx, key, line ? line : "(null)"); - err = _gpgme_op_data_lookup (ctx, OPDATA_KEYLIST, &hook, -1, NULL); opd = hook; if (err) @@ -396,6 +393,9 @@ key = opd->tmp_key; + DEBUG3 ("keylist_colon_handler ctx = %p, key = %p, line = %s\n", + ctx, key, line ? line : "(null)"); + if (!line) { /* End Of File. */ From cvs at cvs.gnupg.org Fri Sep 22 16:38:39 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri Sep 22 15:52:57 2006 Subject: [svn] GnuPG - r4260 - in trunk: doc keyserver Message-ID: Author: wk Date: 2006-09-22 16:38:38 +0200 (Fri, 22 Sep 2006) New Revision: 4260 Modified: trunk/doc/ChangeLog trunk/doc/gnupg7.texi trunk/doc/gpg.texi trunk/doc/yat2m.c trunk/keyserver/ChangeLog trunk/keyserver/no-libgcrypt.c Log: Improved yat2m. Tweaked gpg.texti to be used for gpg1 and gpg2. Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2006-09-22 11:39:45 UTC (rev 4259) +++ trunk/doc/ChangeLog 2006-09-22 14:38:38 UTC (rev 4260) @@ -1,3 +1,15 @@ +2006-09-22 Werner Koch + + * gpg.texi: Make some parts depend on the "gpgone" set + command. This allows us to use the same source for gpg1 and gpg2. + + * yat2m.c (parse_file): Better parsing of @ifset and ifclear. + (main): Allow definition of "-D gpgone". + (parse_file): Allow macro definitions. + (proc_texi_cmd): Expand macros. + (proc_texi_buffer): Process commands terminated by the closing + brace of the enclosing command. + 2006-09-20 Werner Koch * texi.css: New. Note that the current vesion of makeinfo has a Modified: trunk/doc/gnupg7.texi =================================================================== --- trunk/doc/gnupg7.texi 2006-09-22 11:39:45 UTC (rev 4259) +++ trunk/doc/gnupg7.texi 2006-09-22 14:38:38 UTC (rev 4260) @@ -18,6 +18,7 @@ @command{gpg2}. @command{gpg-agent} is a passphrase and private key daemon which may also emulate the @command{ssh-agent}. @mansect see also +@command{gpg}(1), @command{gpg2}(1), @command{gpgv}(1), @command{gpgsm}(1), Modified: trunk/doc/gpg.texi =================================================================== --- trunk/doc/gpg.texi 2006-09-22 11:39:45 UTC (rev 4259) +++ trunk/doc/gpg.texi 2006-09-22 14:38:38 UTC (rev 4260) @@ -9,7 +9,36 @@ @cindex command options @cindex options, GPG command +@c Begin GnuPG 1.x specific stuff +@ifset gpgone +@macro gpgname +gpg +@end macro +@manpage gpg.1 +@ifset manverb +.B gpg +\- OpenPGP encryption and signing tool +@end ifset +@mansect synopsis +@ifset manverb +.B gpg +.RB [ \-\-homedir +.IR dir ] +.RB [ \-\-options +.IR file ] +.RI [ options ] +.I command +.RI [ args ] +@end ifset +@end ifset +@c End GnuPG 1.x specific stuff + +@c Begin GnuPG 2 specific stuff +@ifclear gpgone +@macro gpgname +gpg2 +@end macro @manpage gpg2.1 @ifset manverb .B gpg2 @@ -27,14 +56,22 @@ .I command .RI [ args ] @end ifset +@end ifclear +@c Begin GnuPG 2 specific stuff @mansect description -@command{gpg2} is the OpenPGP part of the GNU Privacy Guard (GnuPG). It +@command{@gpgname} is the OpenPGP part of the GNU Privacy Guard (GnuPG). It is a tool to provide digital encryption and signing services using the -OpenPGP standard. @command{gpg2} features complete key management and +OpenPGP standard. @command{@gpgname} features complete key management and all bells and whistles you can expect from a decent OpenPGP implementation. +@ifset gpgone +This is the standa alone version of @command{gpg}. For desktop use you +shoul consider using @command{gpg2}. +@end ifset + +@ifclear gpgone In contrast to the standalone version @command{gpg}, which is more suited for server and embedded platforms, this version is installed under the name @command{gpg2} and more targeted to the desktop as it @@ -43,12 +80,15 @@ the same system. If you need to use different configuration files, you should make use of something like @file{gpg.conf-2} instead of just @file{gpg.conf}. +@end ifclear @manpause -Documentation for the old standard @command{gpg} is available as man page -man page and at @inforef{Top,GnuPG 1,gpg}. +@ifclear gpgone +Documentation for the old standard @command{gpg} is available as a man +page and at @inforef{Top,GnuPG 1,gpg}. +@end ifclear -@xref{Option Index}, for an index to @command{GPG}'s commands and options. +@xref{Option Index}, for an index to @command{@gpgname}'s commands and options. @mancont @menu @@ -76,7 +116,7 @@ Commands are not distinguished from options execpt for the fact that only one command is allowed. -@code{gpg2} may be run with no commands, in which case it will +@command{@gpgname} may be run with no commands, in which case it will perform a reasonable action depending on the type of file it is given as input (an encrypted message is decrypted, a signature is verified, a file containing keys is listed). @@ -778,7 +818,7 @@ @node GPG Options @section Option Summary -@command{GPG} comes features a bunch of options to control the exact +@command{@gpgname} comes features a bunch of options to control the exact behaviour and to change the default configuration. @menu @@ -1380,10 +1420,15 @@ @item --use-agent @itemx --no-use-agent -Try to use the GnuPG-Agent. Please note that this agent is still under -development. With this option, GnuPG first tries to connect to the +@ifclear gpgone +This is dummy option. @command{@gpgname} always requires the agent. +@end ifclear +@ifset gpgone +Try to use the GnuPG-Agent. +With this option, GnuPG first tries to connect to the agent before it asks for a passphrase. --no-use-agent disables this option. +@end ifset @item --gpg-agent-info Override the value of the environment variable @@ -1462,7 +1507,7 @@ When verifying a signature made from a subkey, ensure that the cross certification "back signature" on the subkey is present and valid. This protects against a subtle attack against subkeys that can sign. -Defaults to --require-cross-certification for @command{gpg2}. +Defaults to --require-cross-certification for @command{@gpgname}. @item --expert @itemx --no-expert @@ -2361,14 +2406,14 @@ @section Configuration files There are a few configuration files to control certain aspects of -@command{gpg2}'s operation. Unless noted, they are expected in the +@command{@gpgname}'s operation. Unless noted, they are expected in the current home directory (@pxref{option --homedir}). @table @file @item gpg.conf @cindex gpgsm.conf -This is the standard configuration file read by @command{gpg2} on +This is the standard configuration file read by @command{@gpgname} on startup. It may contain any valid long option; the leading two dashes may not be entered and the option may not be abbreviated. This default name may be changed on the command line (@pxref{option @@ -2382,9 +2427,9 @@ start up with a working configuration. For existing users the a small helper script is provided to create these files (@pxref{addgnupghome}). -For internal purposes @command{gpg2} creates and maintaines a few other +For internal purposes @command{@gpgname} creates and maintaines a few other files; They all live in in the current home directory (@pxref{option ---homedir}). Only the @command{gpg2} may modify these files. +--homedir}). Only the @command{@gpgname} may modify these files. @table @file Modified: trunk/doc/yat2m.c =================================================================== --- trunk/doc/yat2m.c 2006-09-22 11:39:45 UTC (rev 4259) +++ trunk/doc/yat2m.c 2006-09-22 14:38:38 UTC (rev 4260) @@ -105,11 +105,27 @@ static const char *opt_include; static int opt_store; +/* The only define we understand is -D gpgone. Thus we need a simple + boolean tro track it. */ +static int gpgone_defined; /* Flag to keep track whether any error occurred. */ static int any_error; +/* Object to keep macro definitions. */ +struct macro_s +{ + struct macro_s *next; + char *value; /* Malloced value. */ + char name[1]; +}; +typedef struct macro_s *macro_t; + +/* List of all defined macros. */ +static macro_t macrolist; + + /* Object to store one line of content. */ struct line_buffer_s { @@ -468,8 +484,6 @@ { "bullet", 0, "* " }, { "end", 4 }, { "quotation",1, ".RS\n\\fB" }, - { "ifset", 1 }, - { "ifclear", 1 }, { NULL } }; size_t n; @@ -551,8 +565,20 @@ } else { - inf ("texinfo command `%s' not supported (%.*s)", command, - ((s = memchr (rest, '\n', len)), (s? (s-rest) : len)), rest); + macro_t m; + + for (m = macrolist; m ; m = m->next) + if (!strcmp (m->name, command)) + break; + if (m) + { + proc_texi_buffer (fp, m->value, strlen (m->value), + table_level, eol_action); + ignore_args = 1; /* Parameterized macros are not yet supported. */ + } + else + inf ("texinfo command `%s' not supported (%.*s)", command, + ((s = memchr (rest, '\n', len)), (s? (s-rest) : len)), rest); } if (*rest == '{') @@ -654,6 +680,16 @@ else putc (*s, fp); } + + if (in_cmd > 1) + { + cmdbuf[cmdidx] = 0; + n = proc_texi_cmd (fp, cmdbuf, s, len, table_level, eol_action); + assert (n <= len); + s += n; len -= n; + s--; len++; + in_cmd = 0; + } } @@ -808,10 +844,23 @@ { char *line; int lnr = 0; + /* Fixme: The follwing state variables don't carry over to include + files. */ int in_verbatim = 0; int skip_to_end = 0; /* Used to skip over menu entries. */ int skip_sect_line = 0; /* Skip after @mansect. */ + int ifset_nesting = 0; /* How often a ifset has been seen. */ + int ifclear_nesting = 0; /* How often a ifclear has been seen. */ + int in_gpgone = 0; /* Keep track of "@ifset gpgone" parts. */ + int not_in_gpgone = 0; /* Keep track of "@ifclear gpgone" parts. */ + int not_in_man = 0; /* Keep track of "@ifclear isman" parts. */ + /* Helper to define a macro. */ + char *macroname = NULL; + char *macrovalue = NULL; + size_t macrovaluesize = 0; + size_t macrovalueused = 0; + line = xmalloc (LINESIZE); while (fgets (line, LINESIZE, fp)) { @@ -828,6 +877,63 @@ } line[--n] = 0; + if (*line == '@') + { + for (p=line+1, n=1; *p && *p != ' ' && *p != '\t'; p++) + n++; + while (*p == ' ' || *p == '\t') + p++; + } + else + p = line; + + /* Take action on macro. */ + if (macroname) + { + if (n == 4 && !memcmp (line, "@end", 4) + && (line[4]==' '||line[4]=='\t'||!line[4]) + && !strncmp (p, "macro", 5) + && (p[5]==' '||p[5]=='\t'||!p[5])) + { + macro_t m; + + if (macrovalueused) + macrovalue[--macrovalueused] = 0; /* Kill the last LF. */ + macrovalue[macrovalueused] = 0; /* Terminate macro. */ + macrovalue = xrealloc (macrovalue, macrovalueused+1); + + for (m= macrolist; m; m = m->next) + if (!strcmp (m->name, macroname)) + break; + if (m) + free (m->value); + else + { + m = xcalloc (1, sizeof *m + strlen (macroname)); + strcpy (m->name, macroname); + m->next = macrolist; + macrolist = m; + } + m->value = macrovalue; + macrovalue = NULL; + free (macroname); + macroname = NULL; + } + else + { + if (macrovalueused + strlen (line) + 2 >= macrovaluesize) + { + macrovaluesize += strlen (line) + 256; + macrovalue = xrealloc (macrovalue, macrovaluesize); + } + strcpy (macrovalue+macrovalueused, line); + macrovalueused += strlen (line); + macrovalue[macrovalueused++] = '\n'; + } + continue; + } + + if (n >= 5 && !memcmp (line, "@node", 5) && (line[5]==' '||line[5]=='\t'||!line[5])) { @@ -849,37 +955,116 @@ few macros used to control this as well as one @ifset command. Parts we know about are saved away into containers separate for each section. */ + + /* First process ifset/ifclear commands. */ if (*line == '@') { - for (p=line+1, n=1; *p && *p != ' ' && *p != '\t'; p++) - n++; - while (*p == ' ' || *p == '\t') - p++; + if (n == 6 && !memcmp (line, "@ifset", 6) + && (line[6]==' '||line[6]=='\t')) + { + ifset_nesting++; + if (!strncmp (p, "manverb", 7) && (p[7]==' '||p[7]=='\t'||!p[7])) + { + if (in_verbatim) + err ("%s:%d: nested \"@ifset manverb\"", fname, lnr); + else + in_verbatim = ifset_nesting; + } + else if (!strncmp (p, "gpgone", 6) + && (p[6]==' '||p[6]=='\t'||!p[6])) + { + if (in_gpgone) + err ("%s:%d: nested \"@ifset gpgone\"", fname, lnr); + else + in_gpgone = ifset_nesting; + } + continue; + } + else if (n == 4 && !memcmp (line, "@end", 4) + && (line[4]==' '||line[4]=='\t') + && !strncmp (p, "ifset", 5) + && (p[5]==' '||p[5]=='\t'||!p[5])) + { + if (in_verbatim && ifset_nesting == in_verbatim) + in_verbatim = 0; + if (in_gpgone && ifset_nesting == in_gpgone) + in_gpgone = 0; + + if (ifset_nesting) + ifset_nesting--; + else + err ("%s:%d: unbalanced \"@end ifset\"", fname, lnr); + continue; + } + else if (n == 8 && !memcmp (line, "@ifclear", 8) + && (line[8]==' '||line[8]=='\t')) + { + ifclear_nesting++; + + if (!strncmp (p, "gpgone", 6) + && (p[6]==' '||p[6]=='\t'||!p[6])) + { + if (not_in_gpgone) + err ("%s:%d: nested \"@ifclear gpgone\"", fname, lnr); + else + not_in_gpgone = ifclear_nesting; + } + + else if (!strncmp (p, "isman", 5) + && (p[5]==' '||p[5]=='\t'||!p[5])) + { + if (not_in_man) + err ("%s:%d: nested \"@ifclear isman\"", fname, lnr); + else + not_in_man = ifclear_nesting; + } + + continue; + } + else if (n == 4 && !memcmp (line, "@end", 4) + && (line[4]==' '||line[4]=='\t') + && !strncmp (p, "ifclear", 7) + && (p[7]==' '||p[7]=='\t'||!p[7])) + { + if (not_in_gpgone && ifclear_nesting == not_in_gpgone) + not_in_gpgone = 0; + if (not_in_man && ifclear_nesting == not_in_man) + not_in_man = 0; + + if (ifclear_nesting) + ifclear_nesting--; + else + err ("%s:%d: unbalanced \"@end ifclear\"", fname, lnr); + continue; + } + } + + /* Take action on ifset/ifclear. */ + if ( (in_gpgone && !gpgone_defined) + || (not_in_gpgone && gpgone_defined) + || not_in_man) + continue; + + /* Process commands. */ + if (*line == '@') + { if (skip_to_end && n == 4 && !memcmp (line, "@end", 4) && (line[4]==' '||line[4]=='\t'||!line[4])) { skip_to_end = 0; } - else if (n == 6 && !memcmp (line, "@ifset", 6) - && !strncmp (p, "manverb", 7) && (p[7]==' '||p[7]=='\t'||!p[7])) + else if (in_verbatim) { - if (in_verbatim) - err ("%s:%d: nested \"@ifset manverb\"", fname, lnr); - else - in_verbatim = 1; + got_line = 1; } - else if (in_verbatim && n == 4 && !memcmp (line, "@end", 4) - && !strncmp (p, "ifset", 5) - && (p[5]==' '||p[5]=='\t'||!p[5])) + else if (n == 6 && !memcmp (line, "@macro", 6)) { - in_verbatim = 0; + macroname = xstrdup (p); + macrovalue = xmalloc ((macrovaluesize = 1024)); + macrovalueused = 0; } - else if (in_verbatim) - { - got_line = 1; - } else if (n == 8 && !memcmp (line, "@manpage", 8)) { free (*section_name); @@ -923,11 +1108,6 @@ { skip_to_end = 1; } - else if (n == 8 && !memcmp (line, "@ifclear", 8) - && !strncmp (p, "isman", 5) && (p[5]==' '||p[5]=='\t'||!p[5])) - { - skip_to_end = 1; - } else if (n == 8 && !memcmp (line, "@include", 8) && (line[8]==' '||line[8]=='\t'||!line[8])) { @@ -956,6 +1136,11 @@ } free (incname); } + else if (n == 4 && !memcmp (line, "@bye", 4) + && (line[4]==' '||line[4]=='\t'||!line[4])) + { + break; + } else if (!skip_to_end) got_line = 1; } @@ -970,6 +1155,8 @@ } if (ferror (fp)) err ("%s:%d: read error: %s", fname, lnr, strerror (errno)); + free (macroname); + free (macrovalue); free (line); } @@ -979,6 +1166,14 @@ { char *section_name = NULL; /* Name of the current section or NULL if not in a section. */ + while (macrolist) + { + macro_t m = macrolist->next; + free (m->value); + free (m); + macrolist = m; + } + parse_file (fname, fp, §ion_name, 0); free (section_name); finish_page (); @@ -1017,7 +1212,8 @@ " --verbose enable extra informational output\n" " --debug enable additional debug output\n" " --help display this help and exit\n" - " -I DIR also search in include DIR\n\n" + " -I DIR also search in include DIR\n" + " -D gpgone the only useable define\n\n" "With no FILE, or when FILE is -, read standard input.\n\n" "Report bugs to ."); exit (0); @@ -1091,6 +1287,16 @@ argc--; argv++; } } + else if (!strcmp (*argv, "-D")) + { + argc--; argv++; + if (argc) + { + if (!strcmp (*argv, "gpgone")) + gpgone_defined = 1; + argc--; argv++; + } + } } if (argc > 1) Modified: trunk/keyserver/ChangeLog =================================================================== --- trunk/keyserver/ChangeLog 2006-09-22 11:39:45 UTC (rev 4259) +++ trunk/keyserver/ChangeLog 2006-09-22 14:38:38 UTC (rev 4260) @@ -7,6 +7,8 @@ to OpenSSL. This is considered a bug fix and forgives all possible violations, pertaining to this issue, possibly occured in the past. + + * no-libgcrypt.c: Changed license to a simple all permissive one. * Makefile.am (gpg2keys_ldap_LDADD): For license reasons do not link against common_libs. Modified: trunk/keyserver/no-libgcrypt.c =================================================================== --- trunk/keyserver/no-libgcrypt.c 2006-09-22 11:39:45 UTC (rev 4259) +++ trunk/keyserver/no-libgcrypt.c 2006-09-22 14:38:38 UTC (rev 4260) @@ -1,22 +1,13 @@ /* no-libgcrypt.c - Replacement functions for libgcrypt. * Copyright (C) 2003 Free Software Foundation, Inc. * - * This file is part of GnuPG. - * - * GnuPG 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. - * - * GnuPG 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. + * 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. */ #include From cvs at cvs.gnupg.org Fri Sep 22 20:15:19 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri Sep 22 19:29:40 2006 Subject: [svn] GnuPG - r4261 - in trunk: . doc jnlib po Message-ID: Author: wk Date: 2006-09-22 20:15:18 +0200 (Fri, 22 Sep 2006) New Revision: 4261 Added: trunk/doc/instguide.texi Removed: trunk/doc/assuan.texi Modified: trunk/NEWS trunk/TODO trunk/configure.ac trunk/doc/ChangeLog trunk/doc/Makefile.am trunk/doc/glossary.texi trunk/doc/gnupg.texi trunk/jnlib/ChangeLog trunk/jnlib/utf8conv.c trunk/po/de.po Log: Added iconv support and doc cleanups. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-09-22 14:38:38 UTC (rev 4260) +++ trunk/NEWS 2006-09-22 18:15:18 UTC (rev 4261) @@ -1,8 +1,11 @@ -Noteworthy changes in version 1.9.24 +Noteworthy changes in version 1.9.90 ------------------------------------------------- + * Made readline work for gpg. + * Cleanups und minor bug fixes. + Noteworthy changes in version 1.9.23 (2006-09-18) ------------------------------------------------- Modified: trunk/TODO =================================================================== --- trunk/TODO 2006-09-22 14:38:38 UTC (rev 4260) +++ trunk/TODO 2006-09-22 18:15:18 UTC (rev 4261) @@ -77,10 +77,6 @@ ** Add a test to check the extkeyusage. -* doc/ -** Explain how to setup a root CA key as trusted -** Explain how trustlist.txt might be managed. - * Windows port ** gpgsm's LISTKEYS does not yet work Fix is to change everything to libestream @@ -90,12 +86,10 @@ * sm/ ** check that we issue NO_SECKEY xxx if a -u key was not found - We don't. The messages retruned are also wrong (recipient vs. signer). + We don't. The messages returned are also wrong (recipient vs. signer). * jnlib/ ** provide jnlib_malloc and try to remove all jnlib_xmalloc. -** Extend utf8conv.c to make use of iconv. - Need to merge with the code in 1.4/util/strgutil.c. * g10/ ** issue a NO_SECKEY xxxx if a -u key was not found. @@ -109,13 +103,5 @@ As soon as we switch to libgcrypt 1.3 we should remove the hard coded constant in random_is_faked. - -* common/ -** ttyio - Add completion support. -** yesno - Update to gpg 1.4.3 version - - * Extend selinux support to other modules Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-09-22 14:38:38 UTC (rev 4260) +++ trunk/configure.ac 2006-09-22 18:15:18 UTC (rev 4261) @@ -895,9 +895,6 @@ AC_HEADER_STDC AC_CHECK_HEADERS([string.h unistd.h langinfo.h termio.h locale.h getopt.h]) AC_CHECK_HEADERS([pwd.h inttypes.h]) -# Note that we do not check for iconv here because this is done anyway -# by the gettext checks and thus it allows us to disable the use of -# iconv by using --disable-nls. # Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2006-09-22 14:38:38 UTC (rev 4260) +++ trunk/doc/ChangeLog 2006-09-22 18:15:18 UTC (rev 4261) @@ -1,5 +1,9 @@ 2006-09-22 Werner Koch + * instguide.texi (Installation): New. + * assuan.texi (Assuan): Removed. Use the libassuan manual instead. + * gnupg.texi: Reflect these changes. + * gpg.texi: Make some parts depend on the "gpgone" set command. This allows us to use the same source for gpg1 and gpg2. Modified: trunk/doc/Makefile.am =================================================================== --- trunk/doc/Makefile.am 2006-09-22 14:38:38 UTC (rev 4260) +++ trunk/doc/Makefile.am 2006-09-22 18:15:18 UTC (rev 4261) @@ -40,7 +40,7 @@ dist_pkgdata_DATA = qualified.txt FAQ faq.html com-certs.pem gnupg_TEXINFOS = \ - gpg.texi gpgsm.texi gpg-agent.texi scdaemon.texi assuan.texi \ + gpg.texi gpgsm.texi gpg-agent.texi scdaemon.texi instguide.texi \ tools.texi debugging.texi glossary.texi contrib.texi gpl.texi \ sysnotes.texi gnupg-card-architecture.fig Deleted: trunk/doc/assuan.texi Modified: trunk/doc/glossary.texi =================================================================== --- trunk/doc/glossary.texi 2006-09-22 14:38:38 UTC (rev 4260) +++ trunk/doc/glossary.texi 2006-09-22 18:15:18 UTC (rev 4261) @@ -13,7 +13,7 @@ certificates. @item CRL - The @emph{Certificate Revocation List} is a list containing + The @emph{Certificate Revocation List} is a list containing certificates revoked by the issuer. @item Keygrip Modified: trunk/doc/gnupg.texi =================================================================== --- trunk/doc/gnupg.texi 2006-09-22 14:38:38 UTC (rev 4260) +++ trunk/doc/gnupg.texi 2006-09-22 18:15:18 UTC (rev 4261) @@ -114,6 +114,8 @@ @end ifnottex @menu +* Installation:: A short installation guide. + * Invoking GPG:: Using the OpenPGP protocol. * Invoking GPGSM:: Using the S/MIME protocol. * Invoking GPG-AGENT:: How to launch the secret key daemon. @@ -124,7 +126,7 @@ * System Notes:: Notes pertaining to certain OSes. * Debugging:: How to solve problems -* Assuan:: Description of the Assuan protocol. + * Copying:: GNU General Public License says how you can copy and share GnuPG * Contributors:: People who have contributed to GnuPG. @@ -148,6 +150,8 @@ @end ifhtml +@include instguide.texi + @include gpg.texi @include gpgsm.texi @include gpg-agent.texi @@ -165,7 +169,6 @@ @include debugging.texi -@include assuan.texi @include gpl.texi @include contrib.texi Added: trunk/doc/instguide.texi =================================================================== --- trunk/doc/instguide.texi 2006-09-22 14:38:38 UTC (rev 4260) +++ trunk/doc/instguide.texi 2006-09-22 18:15:18 UTC (rev 4261) @@ -0,0 +1,19 @@ +@c instguide.texi - Installation guide for GnuPG +@c Copyright (C) 2006 Free Software Foundation, Inc. +@c This is part of the GnuPG manual. +@c For copying conditions, see the file gnupg.texi. + +@node Installation +@chapter A short installation guide. + +[to be written] + +Tell how to setup the system, install certificates, how dirmngr relates +to GnuPG etc. + +** Explain how to setup a root CA key as trusted +** Explain how trustlist.txt might be managed. + + + + Modified: trunk/jnlib/ChangeLog =================================================================== --- trunk/jnlib/ChangeLog 2006-09-22 14:38:38 UTC (rev 4260) +++ trunk/jnlib/ChangeLog 2006-09-22 18:15:18 UTC (rev 4261) @@ -1,3 +1,9 @@ +2006-09-22 Werner Koch + + * utf8conv.c: Reworked to match the gnupg 1.4.5 code. This now + requires iconv support but this is reasonable for all modern + systems. + 2006-08-29 Werner Koch * logging.c (do_logv): Emit a missing LF for fatal errors. Modified: trunk/jnlib/utf8conv.c =================================================================== --- trunk/jnlib/utf8conv.c 2006-09-22 14:38:38 UTC (rev 4260) +++ trunk/jnlib/utf8conv.c 2006-09-22 18:15:18 UTC (rev 4261) @@ -28,101 +28,225 @@ #ifdef HAVE_LANGINFO_CODESET #include #endif +#include +#include #include "libjnlib-config.h" #include "stringhelp.h" #include "utf8conv.h" +#ifndef MB_LEN_MAX +#define MB_LEN_MAX 16 +#endif -static ushort koi8_unicode[128] = { - 0x2500, 0x2502, 0x250c, 0x2510, 0x2514, 0x2518, 0x251c, 0x2524, - 0x252c, 0x2534, 0x253c, 0x2580, 0x2584, 0x2588, 0x258c, 0x2590, - 0x2591, 0x2592, 0x2593, 0x2320, 0x25a0, 0x2219, 0x221a, 0x2248, - 0x2264, 0x2265, 0x00a0, 0x2321, 0x00b0, 0x00b2, 0x00b7, 0x00f7, - 0x2550, 0x2551, 0x2552, 0x0451, 0x2553, 0x2554, 0x2555, 0x2556, - 0x2557, 0x2558, 0x2559, 0x255a, 0x255b, 0x255c, 0x255d, 0x255e, - 0x255f, 0x2560, 0x2561, 0x0401, 0x2562, 0x2563, 0x2564, 0x2565, - 0x2566, 0x2567, 0x2568, 0x2569, 0x256a, 0x256b, 0x256c, 0x00a9, - 0x044e, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433, - 0x0445, 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, - 0x043f, 0x044f, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432, - 0x044c, 0x044b, 0x0437, 0x0448, 0x044d, 0x0449, 0x0447, 0x044a, - 0x042e, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413, - 0x0425, 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, - 0x041f, 0x042f, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412, - 0x042c, 0x042b, 0x0417, 0x0428, 0x042d, 0x0429, 0x0427, 0x042a -}; +static const char *active_charset_name = "iso-8859-1"; +static unsigned short *active_charset; +static int no_translation; /* Set to true if we let simply pass through. */ +static int use_iconv; /* iconv comversion fucntions required. */ -static ushort latin2_unicode[128] = { - 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, - 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F, - 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, - 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F, - 0x00A0, 0x0104, 0x02D8, 0x0141, 0x00A4, 0x013D, 0x015A, 0x00A7, - 0x00A8, 0x0160, 0x015E, 0x0164, 0x0179, 0x00AD, 0x017D, 0x017B, - 0x00B0, 0x0105, 0x02DB, 0x0142, 0x00B4, 0x013E, 0x015B, 0x02C7, - 0x00B8, 0x0161, 0x015F, 0x0165, 0x017A, 0x02DD, 0x017E, 0x017C, - 0x0154, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7, - 0x010C, 0x00C9, 0x0118, 0x00CB, 0x011A, 0x00CD, 0x00CE, 0x010E, - 0x0110, 0x0143, 0x0147, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x00D7, - 0x0158, 0x016E, 0x00DA, 0x0170, 0x00DC, 0x00DD, 0x0162, 0x00DF, - 0x0155, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x013A, 0x0107, 0x00E7, - 0x010D, 0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F, - 0x0111, 0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7, - 0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9 -}; -static const char *active_charset_name = "iso-8859-1"; -static ushort *active_charset = NULL; -static int no_translation = 0; +/* Error handler for iconv failures. This is needed to not clutter the + output with repeated diagnostics about a missing conversion. */ +static void +handle_iconv_error (const char *to, const char *from, int use_fallback) +{ + if (errno == EINVAL) + { + static int shown1, shown2; + int x; + if (to && !strcmp (to, "utf-8")) + { + x = shown1; + shown1 = 1; + } + else + { + x = shown2; + shown2 = 1; + } + + if (!x) + log_info (_("conversion from `%s' to `%s' not available\n"), + from, to); + } + else + { + static int shown; + + if (!shown) + log_info (_("iconv_open failed: %s\n"), strerror (errno)); + shown = 1; + } + + if (use_fallback) + { + /* To avoid further error messages we fallback to Latin-1 for the + native encoding. This is justified as one can expect that on a + utf-8 enabled system nl_langinfo() will work and thus we won't + never get to here. Thus Latin-1 seems to be a reasonable + default. */ + active_charset_name = "iso-8859-1"; + no_translation = 0; + active_charset = NULL; + use_iconv = 0; + } +} + + int set_native_charset (const char *newset) { - if (!newset) + const char *full_newset; + + if (!newset) + { +#ifdef HABE_W32_SYSTEM + static char codepage[30]; + unsigned int cpno; + const char *aliases; + + /* We are a console program thus we need to use the + GetConsoleOutputCP function and not the the GetACP which + would give the codepage for a GUI program. Note this is not + a bulletproof detection because GetConsoleCP might return a + different one for console input. Not sure how to cope with + that. If the console Code page is not known we fall back to + the system code page. */ + cpno = GetConsoleOutputCP (); + if (!cpno) + cpno = GetACP (); + sprintf (codepage, "CP%u", cpno ); + /* Resolve alias. We use a long string string and not the usual + array to optimize if the code is taken to a DSO. Taken from + libiconv 1.9.2. */ + newset = codepage; + for (aliases = ("CP936" "\0" "GBK" "\0" + "CP1361" "\0" "JOHAB" "\0" + "CP20127" "\0" "ASCII" "\0" + "CP20866" "\0" "KOI8-R" "\0" + "CP21866" "\0" "KOI8-RU" "\0" + "CP28591" "\0" "ISO-8859-1" "\0" + "CP28592" "\0" "ISO-8859-2" "\0" + "CP28593" "\0" "ISO-8859-3" "\0" + "CP28594" "\0" "ISO-8859-4" "\0" + "CP28595" "\0" "ISO-8859-5" "\0" + "CP28596" "\0" "ISO-8859-6" "\0" + "CP28597" "\0" "ISO-8859-7" "\0" + "CP28598" "\0" "ISO-8859-8" "\0" + "CP28599" "\0" "ISO-8859-9" "\0" + "CP28605" "\0" "ISO-8859-15" "\0" + "CP65001" "\0" "UTF-8" "\0"); + *aliases; + aliases += strlen (aliases) + 1, aliases += strlen (aliases) + 1) + { + if (!strcmp (codepage, aliases) ||(*aliases == '*' && !aliases[1])) + { + newset = aliases + strlen (aliases) + 1; + break; + } + } + +#else /*!HAVE_W32_SYSTEM*/ + #ifdef HAVE_LANGINFO_CODESET - newset = nl_langinfo (CODESET); -#else - newset = "8859-1"; -#endif + newset = nl_langinfo (CODESET); +#else /*!HAVE_LANGINFO_CODESET*/ + /* Try to get the used charset from environment variables. */ + static char codepage[30]; + const char *lc, *dot, *mod; + strcpy (codepage, "iso-8859-1"); + lc = getenv ("LC_ALL"); + if (!lc || !*lc) + { + lc = getenv ("LC_CTYPE"); + if (!lc || !*lc) + lc = getenv ("LANG"); + } + if (lc && *lc) + { + dot = strchr (lc, '.'); + if (dot) + { + mod = strchr (++dot, '@'); + if (!mod) + mod = dot + strlen (dot); + if (mod - dot < sizeof codepage && dot != mod) + { + memcpy (codepage, dot, mod - dot); + codepage [mod - dot] = 0; + } + } + } + newset = codepage; +#endif /*!HAVE_LANGINFO_CODESET*/ +#endif /*!HAVE_W32_SYSTEM*/ + } + + full_newset = newset; if (strlen (newset) > 3 && !ascii_memcasecmp (newset, "iso", 3)) { newset += 3; if (*newset == '-' || *newset == '_') - newset++; + newset++; } - if (!*newset - || !ascii_strcasecmp (newset, "8859-1") - || !ascii_strcasecmp (newset, "8859-15")) + /* Note that we silently assume that plain ASCII is actually meant + as Latin-1. This makes sense because many Unix system don't have + their locale set up properly and thus would get annoying error + messages and we have to handle all the "bug" reports. Latin-1 has + always been the character set used for 8 bit characters on Unix + systems. */ + if ( !*newset + || !ascii_strcasecmp (newset, "8859-1" ) + || !ascii_strcasecmp (newset, "646" ) + || !ascii_strcasecmp (newset, "ASCII" ) + || !ascii_strcasecmp (newset, "ANSI_X3.4-1968" ) + ) { active_charset_name = "iso-8859-1"; no_translation = 0; active_charset = NULL; + use_iconv = 0; } - else if (!ascii_strcasecmp (newset, "8859-2")) + else if ( !ascii_strcasecmp (newset, "utf8" ) + || !ascii_strcasecmp(newset, "utf-8") ) { - active_charset_name = "iso-8859-2"; - no_translation = 0; - active_charset = latin2_unicode; - } - else if (!ascii_strcasecmp (newset, "koi8-r")) - { - active_charset_name = "koi8-r"; - no_translation = 0; - active_charset = koi8_unicode; - } - else if (!ascii_strcasecmp (newset, "utf8") - || !ascii_strcasecmp (newset, "utf-8")) - { active_charset_name = "utf-8"; no_translation = 1; active_charset = NULL; + use_iconv = 0; } else - return -1; + { + iconv_t cd; + +#ifdef HAVE_W32_SYSTEM + if (load_libiconv ()) + return -1; +#endif /*HAVE_W32_SYSTEM*/ + + cd = iconv_open (full_newset, "utf-8"); + if (cd == (iconv_t)-1) + { + handle_iconv_error (full_newset, "utf-8", 0); + return -1; + } + iconv_close (cd); + cd = iconv_open ("utf-8", full_newset); + if (cd == (iconv_t)-1) + { + handle_iconv_error ("utf-8", full_newset, 0); + return -1; + } + iconv_close (cd); + active_charset_name = full_newset; + no_translation = 0; + active_charset = NULL; + use_iconv = 1; + } return 0; } @@ -132,10 +256,9 @@ return active_charset_name; } -/**************** - * Convert string, which is in native encoding to UTF8 and return the - * new allocated UTF8 string. - */ + +/* Convert string, which is in native encoding to UTF8 and return a + new allocated UTF-8 string. */ char * native_to_utf8 (const char *orig_string) { @@ -147,51 +270,22 @@ if (no_translation) { + /* Already utf-8 encoded. */ buffer = jnlib_xstrdup (orig_string); } - else if (active_charset) + else if (!active_charset && !use_iconv) { + /* For Latin-1 we can avoid the iconv overhead. */ for (s = string; *s; s++) { length++; if (*s & 0x80) - length += 2; /* we may need 3 bytes */ - } - buffer = jnlib_xmalloc (length + 1); - for (p = (unsigned char *)buffer, s = string; *s; s++) - { - if ((*s & 0x80)) - { - ushort val = active_charset[*s & 0x7f]; - if (val < 0x0800) - { - *p++ = 0xc0 | ((val >> 6) & 0x1f); - *p++ = 0x80 | (val & 0x3f); - } - else - { - *p++ = 0xe0 | ((val >> 12) & 0x0f); - *p++ = 0x80 | ((val >> 6) & 0x3f); - *p++ = 0x80 | (val & 0x3f); - } - } - else - *p++ = *s; - } - *p = 0; - } - else - { - for (s = string; *s; s++) - { - length++; - if (*s & 0x80) length++; } buffer = jnlib_xmalloc (length + 1); for (p = (unsigned char *)buffer, s = string; *s; s++) { - if (*s & 0x80) + if ( (*s & 0x80 )) { *p++ = 0xc0 | ((*s >> 6) & 3); *p++ = 0x80 | (*s & 0x3f); @@ -201,22 +295,68 @@ } *p = 0; } + else + { + /* Need to use iconv. */ + iconv_t cd; + const char *inptr; + char *outptr; + size_t inbytes, outbytes; + + cd = iconv_open ("utf-8", active_charset_name); + if (cd == (iconv_t)-1) + { + handle_iconv_error ("utf-8", active_charset_name, 1); + return native_to_utf8 (string); + } + + for (s=string; *s; s++ ) + { + length++; + if ((*s & 0x80)) + length += 5; /* We may need up to 6 bytes for the utf8 output. */ + } + buffer = jnlib_xmalloc (length + 1); + + inptr = string; + inbytes = strlen (string); + outptr = buffer; + outbytes = length; + if ( iconv (cd, (ICONV_CONST char **)&inptr, &inbytes, + &outptr, &outbytes) == (size_t)-1) + { + static int shown; + + if (!shown) + log_info (_("conversion from `%s' to `%s' failed: %s\n"), + active_charset_name, "utf-8", strerror (errno)); + shown = 1; + /* We don't do any conversion at all but use the strings as is. */ + strcpy (buffer, string); + } + else /* Success. */ + { + *outptr = 0; + /* We could realloc the buffer now but I doubt that it makes + much sense given that it will get freed anyway soon + after. */ + } + iconv_close (cd); + } return buffer; } -/* Convert string, which is in UTF8 to native encoding. Replace - * illegal encodings by some "\xnn" and quote all control - * characters. A character with value DELIM will always be quoted, it - * must be a vanilla ASCII character. */ -char * -utf8_to_native (const char *string, size_t length, int delim) + +static char * +do_utf8_to_native (const char *string, size_t length, int delim, + int with_iconv) { int nleft; int i; unsigned char encbuf[8]; int encidx; - const byte *s; + const unsigned char *s; size_t n; char *buffer = NULL; char *p = NULL; @@ -224,19 +364,20 @@ size_t slen; int resync = 0; - /* 1. pass (p==NULL): count the extended utf-8 characters */ - /* 2. pass (p!=NULL): create string */ + /* First pass (p==NULL): count the extended utf-8 characters. */ + /* Second pass (p!=NULL): create string. */ for (;;) { for (slen = length, nleft = encidx = 0, n = 0, - s = (const unsigned char *)string; slen; + s = (const unsigned char *)string; + slen; s++, slen--) { if (resync) { if (!(*s < 128 || (*s >= 0xc0 && *s <= 0xfd))) { - /* still invalid */ + /* Still invalid. */ if (p) { sprintf (p, "\\x%02x", *s); @@ -250,45 +391,23 @@ if (!nleft) { if (!(*s & 0x80)) - { /* plain ascii */ - if (*s < 0x20 || *s == 0x7f || *s == delim || - (delim && *s == '\\')) + { + /* Plain ascii. */ + if ( delim != -1 + && (*s < 0x20 || *s == 0x7f || *s == delim + || (delim && *s == '\\'))) { n++; if (p) *p++ = '\\'; switch (*s) { - case '\n': - n++; - if (p) - *p++ = 'n'; - break; - case '\r': - n++; - if (p) - *p++ = 'r'; - break; - case '\f': - n++; - if (p) - *p++ = 'f'; - break; - case '\v': - n++; - if (p) - *p++ = 'v'; - break; - case '\b': - n++; - if (p) - *p++ = 'b'; - break; - case 0: - n++; - if (p) - *p++ = '0'; - break; + case '\n': n++; if ( p ) *p++ = 'n'; break; + case '\r': n++; if ( p ) *p++ = 'r'; break; + case '\f': n++; if ( p ) *p++ = 'f'; break; + case '\v': n++; if ( p ) *p++ = 'v'; break; + case '\b': n++; if ( p ) *p++ = 'b'; break; + case 0: n++; if ( p ) *p++ = '0'; break; default: n += 3; if (p) @@ -306,43 +425,43 @@ n++; } } - else if ((*s & 0xe0) == 0xc0) - { /* 110x xxxx */ + else if ((*s & 0xe0) == 0xc0) /* 110x xxxx */ + { val = *s & 0x1f; nleft = 1; encidx = 0; encbuf[encidx++] = *s; } - else if ((*s & 0xf0) == 0xe0) - { /* 1110 xxxx */ + else if ((*s & 0xf0) == 0xe0) /* 1110 xxxx */ + { val = *s & 0x0f; nleft = 2; encidx = 0; encbuf[encidx++] = *s; } - else if ((*s & 0xf8) == 0xf0) - { /* 1111 0xxx */ + else if ((*s & 0xf8) == 0xf0) /* 1111 0xxx */ + { val = *s & 0x07; nleft = 3; encidx = 0; encbuf[encidx++] = *s; } - else if ((*s & 0xfc) == 0xf8) - { /* 1111 10xx */ + else if ((*s & 0xfc) == 0xf8) /* 1111 10xx */ + { val = *s & 0x03; nleft = 4; encidx = 0; encbuf[encidx++] = *s; } - else if ((*s & 0xfe) == 0xfc) - { /* 1111 110x */ + else if ((*s & 0xfe) == 0xfc) /* 1111 110x */ + { val = *s & 0x01; nleft = 5; encidx = 0; encbuf[encidx++] = *s; } - else - { /* invalid encoding: print as \xnn */ + else /* Invalid encoding: print as \xNN. */ + { if (p) { sprintf (p, "\\x%02x", *s); @@ -352,8 +471,8 @@ resync = 1; } } - else if (*s < 0x80 || *s >= 0xc0) - { /* invalid */ + else if (*s < 0x80 || *s >= 0xc0) /* Invalid utf-8 */ + { if (p) { for (i = 0; i < encidx; i++) @@ -374,8 +493,8 @@ encbuf[encidx++] = *s; val <<= 6; val |= *s & 0x3f; - if (!--nleft) - { /* ready */ + if (!--nleft) /* Ready. */ + { if (no_translation) { if (p) @@ -386,43 +505,41 @@ n += encidx; encidx = 0; } - else if (active_charset) - { /* table lookup */ - for (i = 0; i < 128; i++) - { - if (active_charset[i] == val) - break; - } - if (i < 128) - { /* we can print this one */ - if (p) - *p++ = i + 128; - n++; - } - else - { /* we do not have a translation: print utf8 */ - if (p) - { - for (i = 0; i < encidx; i++) - { - sprintf (p, "\\x%02x", encbuf[i]); - p += 4; - } - } - n += encidx * 4; - encidx = 0; - } - } - else - { /* native set */ + else if (with_iconv) + { + /* Our strategy for using iconv is a bit strange + but it better keeps compatibility with + previous versions in regard to how invalid + encodings are displayed. What we do is to + keep the utf-8 as is and have the real + translation step then at the end. Yes, I + know that this is ugly. However we are short + of the 1.4 release and for this branch we + should not mess too much around with iconv + things. One reason for this is that we don't + know enough about non-GNU iconv + implementation and want to minimize the risk + of breaking the code on too many platforms. */ + if ( p ) + { + for (i=0; i < encidx; i++ ) + *p++ = encbuf[i]; + } + n += encidx; + encidx = 0; + } + else /* Latin-1 case. */ + { if (val >= 0x80 && val < 256) { - n++; /* we can simply print this character */ + /* We can simply print this character */ + n++; if (p) *p++ = val; } else - { /* we do not have a translation: print utf8 */ + { + /* We do not have a translation: print utf8. */ if (p) { for (i = 0; i < encidx; i++) @@ -440,13 +557,78 @@ } } if (!buffer) - { /* allocate the buffer after the first pass */ + { + /* Allocate the buffer after the first pass. */ buffer = p = jnlib_xmalloc (n + 1); } - else + else if (with_iconv) + { + /* Note: See above for comments. */ + iconv_t cd; + const char *inptr; + char *outbuf, *outptr; + size_t inbytes, outbytes; + + *p = 0; /* Terminate the buffer. */ + + cd = iconv_open (active_charset_name, "utf-8"); + if (cd == (iconv_t)-1) + { + handle_iconv_error (active_charset_name, "utf-8", 1); + jnlib_free (buffer); + return utf8_to_native (string, length, delim); + } + + /* Allocate a new buffer large enough to hold all possible + encodings. */ + n = p - buffer + 1; + inbytes = n - 1;; + inptr = buffer; + outbytes = n * MB_LEN_MAX; + if (outbytes / MB_LEN_MAX != n) + BUG (); /* Actually an overflow. */ + outbuf = outptr = jnlib_xmalloc (outbytes); + if ( iconv (cd, (ICONV_CONST char **)&inptr, &inbytes, + &outptr, &outbytes) == (size_t)-1) + { + static int shown; + + if (!shown) + log_info (_("conversion from `%s' to `%s' failed: %s\n"), + "utf-8", active_charset_name, strerror (errno)); + shown = 1; + /* Didn't worked out. Try again but without iconv. */ + jnlib_free (buffer); + buffer = NULL; + jnlib_free (outbuf); + outbuf = do_utf8_to_native (string, length, delim, 0); + } + else /* Success. */ + { + *outptr = 0; /* Make sure it is a string. */ + /* We could realloc the buffer now but I doubt that it + makes much sense given that it will get freed + anyway soon after. */ + jnlib_free (buffer); + } + iconv_close (cd); + return outbuf; + } + else /* Not using iconv. */ { - *p = 0; /* make a string */ + *p = 0; /* Make sure it is a string. */ return buffer; } } } + +/* Convert string, which is in UTF-8 to native encoding. Replace + illegal encodings by some "\xnn" and quote all control + characters. A character with value DELIM will always be quoted, it + must be a vanilla ASCII character. A DELIM value of -1 is special: + it disables all quoting of control characters. */ +char * +utf8_to_native (const char *string, size_t length, int delim) +{ + return do_utf8_to_native (string, length, delim, use_iconv); +} Modified: trunk/po/de.po =================================================================== --- trunk/po/de.po 2006-09-22 14:38:38 UTC (rev 4260) +++ trunk/po/de.po 2006-09-22 18:15:18 UTC (rev 4261) @@ -10,7 +10,7 @@ msgstr "" "Project-Id-Version: gnupg2 1.9.18\n" "Report-Msgid-Bugs-To: translations@gnupg.org\n" -"POT-Creation-Date: 2006-09-18 14:18+0200\n" +"POT-Creation-Date: 2006-09-22 19:24+0200\n" "PO-Revision-Date: 2006-06-20 20:04+0200\n" "Last-Translator: Werner Koch \n" "Language-Team: de\n" @@ -34,12 +34,12 @@ msgid "run in daemon mode (background)" msgstr "Im Daemon Modus ausf?hren" -#: agent/gpg-agent.c:113 kbx/kbxutil.c:82 scd/scdaemon.c:107 sm/gpgsm.c:334 +#: agent/gpg-agent.c:113 kbx/kbxutil.c:82 scd/scdaemon.c:107 sm/gpgsm.c:335 #: tools/gpgconf.c:63 msgid "verbose" msgstr "ausf?hrlich" -#: agent/gpg-agent.c:114 kbx/kbxutil.c:83 scd/scdaemon.c:108 sm/gpgsm.c:335 +#: agent/gpg-agent.c:114 kbx/kbxutil.c:83 scd/scdaemon.c:108 sm/gpgsm.c:336 msgid "be somewhat more quiet" msgstr "Etwas weniger Ausgaben erzeugen" @@ -63,7 +63,7 @@ msgid "do not grab keyboard and mouse" msgstr "Tastatur und Maus nicht \"grabben\"" -#: agent/gpg-agent.c:124 scd/scdaemon.c:120 sm/gpgsm.c:337 +#: agent/gpg-agent.c:124 scd/scdaemon.c:120 sm/gpgsm.c:338 msgid "use a log file for the server" msgstr "Logausgaben in eine Datei umlenken" @@ -116,12 +116,12 @@ msgstr "|DATEI|Schreibe die Umgebungsvariabeln auf DATEI" #: agent/gpg-agent.c:236 agent/protect-tool.c:143 scd/scdaemon.c:188 -#: sm/gpgsm.c:516 tools/gpgconf.c:86 +#: sm/gpgsm.c:517 tools/gpgconf.c:86 msgid "Please report bugs to <" msgstr "Fehlerberichte bitte an <" #: agent/gpg-agent.c:236 agent/protect-tool.c:143 scd/scdaemon.c:188 -#: sm/gpgsm.c:516 tools/gpgconf.c:86 +#: sm/gpgsm.c:517 tools/gpgconf.c:86 msgid ">.\n" msgstr ">.\n" @@ -147,30 +147,30 @@ msgid "out of core while allocating %lu bytes" msgstr "" -#: agent/gpg-agent.c:334 scd/scdaemon.c:262 sm/gpgsm.c:645 +#: agent/gpg-agent.c:334 scd/scdaemon.c:262 sm/gpgsm.c:646 #, c-format msgid "invalid debug-level `%s' given\n" msgstr "ung?ltige Debugebene `%s' angegeben\n" #: agent/gpg-agent.c:505 agent/protect-tool.c:1073 kbx/kbxutil.c:432 -#: scd/scdaemon.c:354 sm/gpgsm.c:766 +#: scd/scdaemon.c:354 sm/gpgsm.c:767 #, c-format msgid "libgcrypt is too old (need %s, have %s)\n" msgstr "" "Die Bibliothek \"libgcrypt\" is zu alt (ben?tigt wird %s, vorhanden ist %s)\n" -#: agent/gpg-agent.c:599 scd/scdaemon.c:431 sm/gpgsm.c:868 +#: agent/gpg-agent.c:599 scd/scdaemon.c:431 sm/gpgsm.c:869 #, c-format msgid "NOTE: no default option file `%s'\n" msgstr "Notiz: Voreingestellte Konfigurationsdatei `%s' fehlt\n" #: agent/gpg-agent.c:604 agent/gpg-agent.c:1115 scd/scdaemon.c:436 -#: sm/gpgsm.c:872 +#: sm/gpgsm.c:873 #, c-format msgid "option file `%s': %s\n" msgstr "Konfigurationsdatei `%s': %s\n" -#: agent/gpg-agent.c:612 scd/scdaemon.c:444 sm/gpgsm.c:879 +#: agent/gpg-agent.c:612 scd/scdaemon.c:444 sm/gpgsm.c:880 #, c-format msgid "reading options from `%s'\n" msgstr "Optionen werden aus `%s' gelesen\n" @@ -547,7 +547,7 @@ "@Kommandos:\n" " " -#: kbx/kbxutil.c:77 sm/gpgsm.c:277 tools/gpgconf.c:60 +#: kbx/kbxutil.c:77 sm/gpgsm.c:278 tools/gpgconf.c:60 msgid "" "@\n" "Options:\n" @@ -557,7 +557,7 @@ "Optionen:\n" " " -#: kbx/kbxutil.c:84 sm/gpgsm.c:343 tools/gpgconf.c:65 +#: kbx/kbxutil.c:84 sm/gpgsm.c:344 tools/gpgconf.c:65 msgid "do not make any changes" msgstr "Keine ?nderungen durchf?hren" @@ -593,7 +593,7 @@ msgid "run in multi server mode (foreground)" msgstr "Im Multiserver Modus ausf?hren" -#: scd/scdaemon.c:111 sm/gpgsm.c:355 +#: scd/scdaemon.c:111 sm/gpgsm.c:356 msgid "read options from file" msgstr "Konfigurationsoptionen aus Datei lesen" @@ -1195,151 +1195,151 @@ msgid "change a passphrase" msgstr "Das Mantra (Passphrase) ?ndern" -#: sm/gpgsm.c:279 +#: sm/gpgsm.c:280 msgid "create ascii armored output" msgstr "Ausgabe mit ASCII H?lle wird erzeugt" -#: sm/gpgsm.c:281 +#: sm/gpgsm.c:282 msgid "create base-64 encoded output" msgstr "Ausgabe im Basis-64 format erzeugen" -#: sm/gpgsm.c:283 +#: sm/gpgsm.c:284 msgid "assume input is in PEM format" msgstr "Eingabedaten sind im PEM Format" -#: sm/gpgsm.c:285 +#: sm/gpgsm.c:286 msgid "assume input is in base-64 format" msgstr "Eingabedaten sind im Basis-64 Format" -#: sm/gpgsm.c:287 +#: sm/gpgsm.c:288 msgid "assume input is in binary format" msgstr "Eingabedaten sind im Bin?rformat" -#: sm/gpgsm.c:289 +#: sm/gpgsm.c:290 msgid "|NAME|encrypt for NAME" msgstr "|NAME|Verschl?sseln f?r NAME" -#: sm/gpgsm.c:292 +#: sm/gpgsm.c:293 msgid "use system's dirmngr if available" msgstr "Benutze den System Dirmngr when verf?gbar" -#: sm/gpgsm.c:293 +#: sm/gpgsm.c:294 msgid "never consult a CRL" msgstr "Niemals eine CRL konsultieren" -#: sm/gpgsm.c:300 +#: sm/gpgsm.c:301 msgid "check validity using OCSP" msgstr "Die G?ltigkeit mittels OCSP pr?fen" -#: sm/gpgsm.c:303 +#: sm/gpgsm.c:304 msgid "|N|number of certificates to include" msgstr "|N|Sende N Zertifikate mit" -#: sm/gpgsm.c:306 +#: sm/gpgsm.c:307 msgid "|FILE|take policy information from FILE" msgstr "|DATEI|Richtlinieninformationen DATEI entnehmen" -#: sm/gpgsm.c:309 +#: sm/gpgsm.c:310 msgid "do not check certificate policies" msgstr "Zertikikatrichtlinien nicht ?berpr?fen" -#: sm/gpgsm.c:313 +#: sm/gpgsm.c:314 msgid "fetch missing issuer certificates" msgstr "Fehlende Zertifikate automatisch holen" -#: sm/gpgsm.c:317 +#: sm/gpgsm.c:318 msgid "|NAME|use NAME as default recipient" msgstr "|NAME|Benutze NAME als voreingestellten Empf?nger" -#: sm/gpgsm.c:319 +#: sm/gpgsm.c:320 msgid "use the default key as default recipient" msgstr "Benuzte voreingestellten Schl?ssel als Standardempf?nger" -#: sm/gpgsm.c:325 +#: sm/gpgsm.c:326 msgid "use this user-id to sign or decrypt" msgstr "Benuzte diese Benutzer ID zum Signieren oder Entschl?sseln" -#: sm/gpgsm.c:328 +#: sm/gpgsm.c:329 msgid "|N|set compress level N (0 disables)" msgstr "|N|Benutze Komprimierungsstufe N" -#: sm/gpgsm.c:330 +#: sm/gpgsm.c:331 msgid "use canonical text mode" msgstr "Kanonischen Textmodus benutzen" -#: sm/gpgsm.c:333 tools/gpgconf.c:62 +#: sm/gpgsm.c:334 tools/gpgconf.c:62 msgid "use as output file" msgstr "als Ausgabedatei benutzen" -#: sm/gpgsm.c:336 +#: sm/gpgsm.c:337 msgid "don't use the terminal at all" msgstr "Das Terminal ?berhaupt nicht benutzen" -#: sm/gpgsm.c:340 +#: sm/gpgsm.c:341 msgid "force v3 signatures" msgstr "Version 3 Signaturen erzwingen" -#: sm/gpgsm.c:341 +#: sm/gpgsm.c:342 msgid "always use a MDC for encryption" msgstr "Immer das MDC Verfahren zum verschl?sseln mitbenutzen" -#: sm/gpgsm.c:346 +#: sm/gpgsm.c:347 msgid "batch mode: never ask" msgstr "Stapelverarbeitungs Modus: Nie nachfragen" -#: sm/gpgsm.c:347 +#: sm/gpgsm.c:348 msgid "assume yes on most questions" msgstr "\"Ja\" auf die meisten Anfragen annehmen" -#: sm/gpgsm.c:348 +#: sm/gpgsm.c:349 msgid "assume no on most questions" msgstr "\"Nein\" auf die meisten Anfragen annehmen" -#: sm/gpgsm.c:350 +#: sm/gpgsm.c:351 msgid "add this keyring to the list of keyrings" msgstr "Diesen Keyring in die Liste der Keyrings aufnehmen" -#: sm/gpgsm.c:351 +#: sm/gpgsm.c:352 msgid "add this secret keyring to the list" msgstr "Diese geheimen Keyring in die Liste aufnehmen" -#: sm/gpgsm.c:352 +#: sm/gpgsm.c:353 msgid "|NAME|use NAME as default secret key" msgstr "|NAME|Benutze NAME als voreingestellten Schl?ssel" -#: sm/gpgsm.c:353 +#: sm/gpgsm.c:354 msgid "|HOST|use this keyserver to lookup keys" msgstr "|HOST|Benutze HOST als Schl?sselserver" -#: sm/gpgsm.c:354 +#: sm/gpgsm.c:355 msgid "|NAME|set terminal charset to NAME" msgstr "|NAME|Den Zeichensatz f?r das Terminal auf NAME setzen" -#: sm/gpgsm.c:358 +#: sm/gpgsm.c:359 msgid "|LEVEL|set the debugging level to LEVEL" msgstr "|NAME|Die Debugstufe auf NAME setzen" -#: sm/gpgsm.c:366 +#: sm/gpgsm.c:367 msgid "|FD|write status info to this FD" msgstr "|FD|Statusinformationen auf Dateidescriptor FD schreiben" -#: sm/gpgsm.c:373 +#: sm/gpgsm.c:374 msgid "|FILE|load extension module FILE" msgstr "|DATEI|Das Erweiterungsmodul DATEI laden" -#: sm/gpgsm.c:379 +#: sm/gpgsm.c:380 msgid "|NAME|use cipher algorithm NAME" msgstr "|NAME|Den Verschl?sselungsalgrithmus NAME benutzen" -#: sm/gpgsm.c:381 +#: sm/gpgsm.c:382 msgid "|NAME|use message digest algorithm NAME" msgstr "|NAME|Den Hashalgorithmus NAME benutzen" -#: sm/gpgsm.c:383 +#: sm/gpgsm.c:384 msgid "|N|use compress algorithm N" msgstr "|N|Den Kompressionsalgorithmus Nummer N benutzen" -#: sm/gpgsm.c:391 +#: sm/gpgsm.c:392 msgid "" "@\n" "(See the man page for a complete listing of all commands and options)\n" @@ -1347,7 +1347,7 @@ "@\n" "(Die \"man\" Seite beschreibt alle Kommands und Optionen)\n" -#: sm/gpgsm.c:394 +#: sm/gpgsm.c:395 msgid "" "@\n" "Examples:\n" @@ -1367,11 +1367,11 @@ " --list-keys [Namen] Schl?ssel anzeigenn\n" " --fingerprint [Namen] \"Fingerabdr?cke\" anzeigen\\n\n" -#: sm/gpgsm.c:519 +#: sm/gpgsm.c:520 msgid "Usage: gpgsm [options] [files] (-h for help)" msgstr "Gebrauch: gpgsm [Optionen] [Dateien] (-h f?r Hilfe)" -#: sm/gpgsm.c:522 +#: sm/gpgsm.c:523 msgid "" "Syntax: gpgsm [options] [files]\n" "sign, check, encrypt or decrypt using the S/MIME protocol\n" @@ -1380,7 +1380,7 @@ "Gebrauch: gpgsm [Optionen] [Dateien]\n" "Signieren, pr?fen, ver- und entschl?sseln mittels S/MIME protocol\n" -#: sm/gpgsm.c:529 +#: sm/gpgsm.c:530 msgid "" "\n" "Supported algorithms:\n" @@ -1388,55 +1388,55 @@ "\n" "Unterst?tzte Algorithmen:\n" -#: sm/gpgsm.c:616 +#: sm/gpgsm.c:617 msgid "usage: gpgsm [options] " msgstr "Gebrauch: gpgsm [Optionen] " -#: sm/gpgsm.c:681 +#: sm/gpgsm.c:682 msgid "conflicting commands\n" msgstr "Widersprechende Kommandos\n" -#: sm/gpgsm.c:697 +#: sm/gpgsm.c:698 #, c-format msgid "can't encrypt to `%s': %s\n" msgstr "Verschl?sseln f?r `%s' nicht m?glich: %s\n" -#: sm/gpgsm.c:771 +#: sm/gpgsm.c:772 #, c-format msgid "libksba is too old (need %s, have %s)\n" msgstr "Die Bibliothek Libksba is nicht aktuell (ben?tige %s, habe %s)\n" -#: sm/gpgsm.c:1234 +#: sm/gpgsm.c:1235 msgid "WARNING: program may create a core file!\n" msgstr "WARNUNG: Programm k?nnte eine core-dump-Datei schreiben!\n" -#: sm/gpgsm.c:1251 +#: sm/gpgsm.c:1252 msgid "WARNING: running with faked system time: " msgstr "WARNUNG: Ausf?hrung mit gef?lschter Systemzeit: " -#: sm/gpgsm.c:1277 +#: sm/gpgsm.c:1278 msgid "selected cipher algorithm is invalid\n" msgstr "Das ausgew?hlte Verschl?sselungsverfahren ist ung?ltig\n" -#: sm/gpgsm.c:1285 +#: sm/gpgsm.c:1286 msgid "selected digest algorithm is invalid\n" msgstr "Das ausgew?hlte Hashverfahren ist ung?ltig\n" -#: sm/gpgsm.c:1316 +#: sm/gpgsm.c:1317 #, fuzzy, c-format msgid "importing common certificates `%s'\n" msgstr "Fehler beim Importieren des Zertifikats: %s\n" -#: sm/gpgsm.c:1334 +#: sm/gpgsm.c:1335 #, c-format msgid "can't sign using `%s': %s\n" msgstr "Signieren mit `%s' nicht m?glich: %s\n" -#: sm/gpgsm.c:1518 +#: sm/gpgsm.c:1519 msgid "this command has not yet been implemented\n" msgstr "Dieses Kommando wurde noch nicht implementiert\n" -#: sm/gpgsm.c:1754 sm/gpgsm.c:1791 sm/qualified.c:74 +#: sm/gpgsm.c:1755 sm/gpgsm.c:1792 sm/qualified.c:74 #, c-format msgid "can't open `%s': %s\n" msgstr "Datei `%s' kann nicht ge?ffnet werden: %s\n" From cvs at cvs.gnupg.org Sun Sep 24 01:32:44 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Sun Sep 24 00:46:56 2006 Subject: [svn] GnuPG - r4262 - trunk/scd Message-ID: Author: marcus Date: 2006-09-24 01:32:44 +0200 (Sun, 24 Sep 2006) New Revision: 4262 Modified: trunk/scd/ChangeLog trunk/scd/app-openpgp.c Log: 2006-09-24 Marcus Brinkmann * app-openpgp.c (do_sign): Advance INDATA by the SHA1 resp. RMD160 prefix length. Modified: trunk/scd/ChangeLog =================================================================== --- trunk/scd/ChangeLog 2006-09-22 18:15:18 UTC (rev 4261) +++ trunk/scd/ChangeLog 2006-09-23 23:32:44 UTC (rev 4262) @@ -1,3 +1,8 @@ +2006-09-24 Marcus Brinkmann + + * app-openpgp.c (do_sign): Advance INDATA by the SHA1 resp. RMD160 + prefix length. + 2006-09-14 Werner Koch Replaced all call gpg_error_from_errno(errno) by Modified: trunk/scd/app-openpgp.c =================================================================== --- trunk/scd/app-openpgp.c 2006-09-22 18:15:18 UTC (rev 4261) +++ trunk/scd/app-openpgp.c 2006-09-23 23:32:44 UTC (rev 4262) @@ -2116,10 +2116,16 @@ ; else if (indatalen == (15 + 20) && hashalgo == GCRY_MD_SHA1 && !memcmp (indata, sha1_prefix, 15)) - ; + { + indata += 15; + indatalen -= 15; + } else if (indatalen == (15 + 20) && hashalgo == GCRY_MD_RMD160 && !memcmp (indata, rmd160_prefix, 15)) - ; + { + indata += 15; + indatalen -= 15; + } else { log_error (_("card does not support digest algorithm %s\n"), From cvs at cvs.gnupg.org Mon Sep 25 10:21:45 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon Sep 25 09:35:59 2006 Subject: [svn] GnuPG - r4265 - tags Message-ID: Author: wk Date: 2006-09-25 10:21:44 +0200 (Mon, 25 Sep 2006) New Revision: 4265 Added: tags/gnupg-1.9.90/ Log: Released 1.9.90 Copied: tags/gnupg-1.9.90 (from rev 4264, trunk) From cvs at cvs.gnupg.org Mon Sep 25 16:57:01 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon Sep 25 16:11:00 2006 Subject: [svn] gpgme - r1182 - in trunk: . doc gpgme Message-ID: Author: marcus Date: 2006-09-25 16:57:00 +0200 (Mon, 25 Sep 2006) New Revision: 1182 Modified: trunk/NEWS trunk/doc/ChangeLog trunk/doc/gpgme.texi trunk/gpgme/ChangeLog trunk/gpgme/data-mem.c Log: doc/ 2006-09-25 Marcus Brinkmann * gpgme.texi (Destroying Data Buffers): Clarify that gpgme_data_release_and_get_mem destroys DH unconditionally. gpgme/ 2006-09-25 Marcus Brinkmann * data-mem.c (gpgme_data_release_and_get_mem): Release the data object properly. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-09-22 12:29:36 UTC (rev 1181) +++ trunk/NEWS 2006-09-25 14:57:00 UTC (rev 1182) @@ -1,6 +1,8 @@ Noteworthy changes in version 1.1.3 (unreleased) ------------------------------------------------ + * Fixed a memory leak in gpgme_data_release_and_get_mem. + * Interface changes relative to the 1.1.1 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2006-09-22 12:29:36 UTC (rev 1181) +++ trunk/doc/ChangeLog 2006-09-25 14:57:00 UTC (rev 1182) @@ -1,3 +1,8 @@ +2006-09-25 Marcus Brinkmann + + * gpgme.texi (Destroying Data Buffers): Clarify that + gpgme_data_release_and_get_mem destroys DH unconditionally. + 2005-03-24 Marcus Brinkmann * gpgme.texi (Library Version Check): Make example code compatible Modified: trunk/doc/gpgme.texi =================================================================== --- trunk/doc/gpgme.texi 2006-09-22 12:29:36 UTC (rev 1181) +++ trunk/doc/gpgme.texi 2006-09-25 14:57:00 UTC (rev 1182) @@ -1719,7 +1719,8 @@ made for this purpose. In case an error returns, or there is no suitable data buffer that can -be returned to the user, the function will return @code{NULL}. +be returned to the user, the function will return @code{NULL}. In any +case, the data object @var{dh} is destroyed. @end deftypefun Modified: trunk/gpgme/ChangeLog =================================================================== --- trunk/gpgme/ChangeLog 2006-09-22 12:29:36 UTC (rev 1181) +++ trunk/gpgme/ChangeLog 2006-09-25 14:57:00 UTC (rev 1182) @@ -1,3 +1,8 @@ +2006-09-25 Marcus Brinkmann + + * data-mem.c (gpgme_data_release_and_get_mem): Release the data + object properly. + 2006-09-22 Marcus Brinkmann * keylist.c (keylist_colon_handler): Move debug output after Modified: trunk/gpgme/data-mem.c =================================================================== --- trunk/gpgme/data-mem.c 2006-09-22 12:29:36 UTC (rev 1181) +++ trunk/gpgme/data-mem.c 2006-09-25 14:57:00 UTC (rev 1182) @@ -210,20 +210,32 @@ char *str = NULL; if (!dh || dh->cbs != &mem_cbs) - return NULL; + { + gpgme_data_release (dh); + return NULL; + } str = dh->data.mem.buffer; if (!str && dh->data.mem.orig_buffer) { str = malloc (dh->data.mem.length); if (!str) - return NULL; + { + gpgme_data_release (dh); + return NULL; + } memcpy (str, dh->data.mem.orig_buffer, dh->data.mem.length); } + else + /* Prevent mem_release from releasing the buffer memory. We must + not fail from this point. */ + dh->data.mem.buffer = NULL; if (r_len) *r_len = dh->data.mem.length; + gpgme_data_release (dh); + return str; } From cvs at cvs.gnupg.org Tue Sep 26 12:00:14 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue Sep 26 11:14:07 2006 Subject: [svn] GnuPG - r4267 - in trunk: . sm Message-ID: Author: wk Date: 2006-09-26 12:00:12 +0200 (Tue, 26 Sep 2006) New Revision: 4267 Modified: trunk/NEWS trunk/sm/ChangeLog trunk/sm/certchain.c Log: Finished implementation of the "relax" flag. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2006-09-25 18:29:20 UTC (rev 4266) +++ trunk/NEWS 2006-09-26 10:00:12 UTC (rev 4267) @@ -1,7 +1,10 @@ Noteworthy changes in version 1.9.91 ------------------------------------------------- + * New "relax" flag for trustlist.txt to allow root CA certificates + without BasicContraints. + Noteworthy changes in version 1.9.90 (2006-09-25) ------------------------------------------------- Modified: trunk/sm/ChangeLog =================================================================== --- trunk/sm/ChangeLog 2006-09-25 18:29:20 UTC (rev 4266) +++ trunk/sm/ChangeLog 2006-09-26 10:00:12 UTC (rev 4267) @@ -1,3 +1,9 @@ +2006-09-26 Werner Koch + + * certchain.c (gpgsm_validate_chain): More changes for the relax + feature. Use certificate reference counting instead of the old + explicit tests. Added a missing free. + 2006-09-25 Werner Koch * gpgsm.h (struct rootca_flags_s): New. Modified: trunk/sm/certchain.c =================================================================== --- trunk/sm/certchain.c 2006-09-25 18:29:20 UTC (rev 4266) +++ trunk/sm/certchain.c 2006-09-26 10:00:12 UTC (rev 4267) @@ -695,10 +695,15 @@ gpgsm_dump_cert ("target", cert); subject_cert = cert; + ksba_cert_ref (subject_cert); maxdepth = 50; for (;;) { + int is_root; + gpg_error_t istrusted_rc; + struct rootca_flags_s rootca_flags; + xfree (issuer); xfree (subject); issuer = ksba_cert_get_issuer (subject_cert, 0); @@ -711,6 +716,20 @@ goto leave; } + /* Is this a self-issued certificate (i.e. the root certificate)? */ + is_root = (subject && !strcmp (issuer, subject)); + if (is_root) + { + /* Check early whether the certificate is listed as trusted. + We used to do this only later but changed it to call the + check right here so that we can access special flags + associated with that specific root certificate. */ + istrusted_rc = gpgsm_agent_istrusted (ctrl, subject_cert, + &rootca_flags); + } + + + /* Check the validity period. */ { ksba_isotime_t not_before, not_after; @@ -762,10 +781,12 @@ } } + /* Assert that we understand all critical extensions. */ rc = unknown_criticals (subject_cert, listmode, fp); if (rc) goto leave; + /* Do a policy check. */ if (!opt.no_policy_check) { rc = check_cert_policy (subject_cert, listmode, fp); @@ -780,23 +801,14 @@ /* Is this a self-issued certificate? */ - if (subject && !strcmp (issuer, subject)) - { /* Yes. */ - gpg_error_t istrusted_rc; - struct rootca_flags_s rootca_flags; - - /* Check early whether the certificate is listed as trusted. - We used to do this only later but changed it to call the - check right here so that we can access special flags - associated with that specific root certificate. */ - istrusted_rc = gpgsm_agent_istrusted (ctrl, subject_cert, - &rootca_flags); - - /* Note, that we could save the following signature check - because nobody would be so dump to set up a faked chain - and fail in creating a valid self-signed certificate. */ - if (gpgsm_check_cert_sig (subject_cert, subject_cert) ) + if (is_root) + { + if (!istrusted_rc) + ; /* No need to check the certificate for a trusted one. */ + else if (gpgsm_check_cert_sig (subject_cert, subject_cert) ) { + /* We only check the signature if the certificate is not + trusted for better diagnostics. */ do_list (1, lm, fp, _("self-signed certificate has a BAD signature")); if (DBG_X509) @@ -920,6 +932,7 @@ break; /* Okay: a self-signed certicate is an end-point. */ } + /* Take care that the chain does not get too long. */ depth++; if (depth > maxdepth) { @@ -928,7 +941,7 @@ goto leave; } - /* find the next cert up the tree */ + /* Find the next cert up the tree. */ keydb_search_reset (kh); rc = find_up (kh, subject_cert, issuer, 0); if (rc) @@ -1013,10 +1026,38 @@ goto leave; } + is_root = 0; + istrusted_rc = -1; + + /* Check that a CA is allowed to issue certificates. */ { int chainlen; + rc = allowed_ca (issuer_cert, &chainlen, listmode, fp); if (rc) + { + /* Not allowed. Check whether this is a trusted root + certificate and whether we allow special exceptions. + We could carry the result of the test over to the + regular root check at the top of the loop but for + clarity we won't do that. Given that the majority of + certificates carry proper BasicContraints our way of + overriding an error in the way is justified for + performance reasons. */ + if (gpgsm_is_root_cert (issuer_cert)) + { + is_root = 1; + istrusted_rc = gpgsm_agent_istrusted (ctrl, issuer_cert, + &rootca_flags); + if (!istrusted_rc && rootca_flags.relax) + { + /* Ignore the error due to the relax flag. */ + rc = 0; + chainlen = -1; + } + } + } + if (rc) goto leave; if (chainlen >= 0 && (depth - 1) > chainlen) { @@ -1028,6 +1069,7 @@ } } + /* Is the certificate allowed to sign other certificates. */ if (!listmode) { rc = gpgsm_cert_use_cert_p (issuer_cert); @@ -1041,9 +1083,14 @@ } } - /* Check for revocations etc. */ + /* Check for revocations etc. Note that for a root certioficate + this test is done a second time later. This should eventually + be fixed. */ if ((flags & 1)) rc = 0; + else if (is_root && (opt.no_trusted_cert_crl_check + || (!istrusted_rc && rootca_flags.relax))) + ; else rc = is_cert_still_valid (ctrl, lm, fp, subject_cert, issuer_cert, @@ -1054,8 +1101,10 @@ if (opt.verbose && !listmode) log_info ("certificate is good\n"); - + + /* For the next round the current issuer becomes the new subject. */ keydb_search_reset (kh); + ksba_cert_release (subject_cert); subject_cert = issuer_cert; issuer_cert = NULL; } /* End chain traversal. */ @@ -1110,10 +1159,10 @@ if (r_exptime) gnupg_copy_time (r_exptime, exptime); xfree (issuer); + xfree (subject); keydb_release (kh); ksba_cert_release (issuer_cert); - if (subject_cert != cert) - ksba_cert_release (subject_cert); + ksba_cert_release (subject_cert); return rc; } From cvs at cvs.gnupg.org Tue Sep 26 16:15:20 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue Sep 26 15:29:13 2006 Subject: [svn] GnuPG - r4268 - in branches/STABLE-BRANCH-1-4: doc g10 keyserver scripts Message-ID: Author: wk Date: 2006-09-26 16:15:17 +0200 (Tue, 26 Sep 2006) New Revision: 4268 Modified: branches/STABLE-BRANCH-1-4/doc/DETAILS branches/STABLE-BRANCH-1-4/g10/ChangeLog branches/STABLE-BRANCH-1-4/g10/skclist.c branches/STABLE-BRANCH-1-4/keyserver/ChangeLog branches/STABLE-BRANCH-1-4/keyserver/Makefile.am branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_curl.c branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_finger.c branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_hkp.c branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_ldap.c branches/STABLE-BRANCH-1-4/keyserver/ksutil.c branches/STABLE-BRANCH-1-4/keyserver/ksutil.h branches/STABLE-BRANCH-1-4/scripts/ChangeLog branches/STABLE-BRANCH-1-4/scripts/autogen.sh Log: Allow to build w/o curl. Modified: branches/STABLE-BRANCH-1-4/doc/DETAILS =================================================================== --- branches/STABLE-BRANCH-1-4/doc/DETAILS 2006-09-26 10:00:12 UTC (rev 4267) +++ branches/STABLE-BRANCH-1-4/doc/DETAILS 2006-09-26 14:15:17 UTC (rev 4268) @@ -1,4 +1,7 @@ -*- text -*- + +NOTE: The definitive reference is the file from the SVN trunk. + Format of colon listings ======================== First an example: Modified: branches/STABLE-BRANCH-1-4/g10/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/g10/ChangeLog 2006-09-26 10:00:12 UTC (rev 4267) +++ branches/STABLE-BRANCH-1-4/g10/ChangeLog 2006-09-26 14:15:17 UTC (rev 4268) @@ -1,3 +1,8 @@ +2006-08-21 Werner Koch + + * skclist.c (is_insecure): Also test for uppercase version of the + insecure string. + 2006-07-31 Werner Koch * openfile.c (open_outfile) [USE_ONLY_8DOT3]: Search backwards for Modified: branches/STABLE-BRANCH-1-4/g10/skclist.c =================================================================== --- branches/STABLE-BRANCH-1-4/g10/skclist.c 2006-09-26 10:00:12 UTC (rev 4267) +++ branches/STABLE-BRANCH-1-4/g10/skclist.c 2006-09-26 14:15:17 UTC (rev 4268) @@ -69,7 +69,8 @@ continue; /* skip attribute packets */ if ( strstr( id->name, "(insecure!)" ) || strstr( id->name, "not secure" ) - || strstr( id->name, "do not use" ) ) { + || strstr( id->name, "do not use" ) + || strstr( id->name, "(INSECURE!)" ) ) { insecure = 1; break; } Modified: branches/STABLE-BRANCH-1-4/keyserver/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/keyserver/ChangeLog 2006-09-26 10:00:12 UTC (rev 4267) +++ branches/STABLE-BRANCH-1-4/keyserver/ChangeLog 2006-09-26 14:15:17 UTC (rev 4268) @@ -1,3 +1,19 @@ +2006-09-26 Werner Koch + + * gpgkeys_finger.c (get_key): Cast away signed/unsigned char ptr + mismatches. + + * ksutil.c (ks_hextobyte, ks_toupper, ks_strcasecmp): New. Use + them instead of there ascii_foo counterparts. + * gpgkeys_ldap.c (main): Replaced BUG by assert. + + * gpgkeys_curl.c, gpgkeys_hkp.c, gpgkeys_ldap.c, ksutil.c: + * ksutil.h: Add special license exception for OpenSSL. This helps + to avoid license conflicts if OpenLDAP or cURL is linked against + OpenSSL and we would thus indirectly link to OpenSSL. This is + considered a bug fix and forgives all possible violations, + pertaining to this issue, possibly occured in the past. + 2006-07-26 David Shaw * Makefile.am: Fix missing include path for gpgkeys_finger (needs Modified: branches/STABLE-BRANCH-1-4/keyserver/Makefile.am =================================================================== --- branches/STABLE-BRANCH-1-4/keyserver/Makefile.am 2006-09-26 10:00:12 UTC (rev 4267) +++ branches/STABLE-BRANCH-1-4/keyserver/Makefile.am 2006-09-26 14:15:17 UTC (rev 4268) @@ -36,7 +36,7 @@ other_libs = $(LIBICONV) $(LIBINTL) $(CAPLIBS) gpgkeys_ldap_CPPFLAGS = @LDAP_CPPFLAGS@ -gpgkeys_ldap_LDADD = ../util/libutil.a @LDAPLIBS@ @NETLIBS@ $(other_libs) @GETOPT@ @W32LIBS@ +gpgkeys_ldap_LDADD = @LDAPLIBS@ @NETLIBS@ $(other_libs) @GETOPT@ @W32LIBS@ gpgkeys_finger_LDADD = ../util/libutil.a @NETLIBS@ $(other_libs) @GETOPT@ @W32LIBS@ Modified: branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_curl.c =================================================================== --- branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_curl.c 2006-09-26 10:00:12 UTC (rev 4267) +++ branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_curl.c 2006-09-26 14:15:17 UTC (rev 4268) @@ -17,6 +17,17 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. + * + * In addition, as a special exception, the Free Software Foundation + * gives permission to link the code of the keyserver helper tools: + * gpgkeys_ldap, gpgkeys_curl and gpgkeys_hkp with the OpenSSL + * project's "OpenSSL" library (or with modified versions of it that + * use the same license as the "OpenSSL" library), and distribute the + * linked executables. You must obey the GNU General Public License + * in all respects for all of the code used other than "OpenSSL". If + * you modify this file, you may extend this exception to your version + * of the file, but you are not obligated to do so. If you do not + * wish to do so, delete this exception statement from your version. */ #include Modified: branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_finger.c =================================================================== --- branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_finger.c 2006-09-26 10:00:12 UTC (rev 4267) +++ branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_finger.c 2006-09-26 14:15:17 UTC (rev 4268) @@ -324,13 +324,13 @@ if(gotit) { - print_nocr(output,line); - if (!strncmp(line,END,strlen(END))) + print_nocr (output, (const char*)line); + if (!strncmp((char*)line,END,strlen(END))) break; } - else if(!strncmp(line,BEGIN,strlen(BEGIN))) + else if(!strncmp((char*)line,BEGIN,strlen(BEGIN))) { - print_nocr(output,line); + print_nocr(output, (const char*)line); gotit=1; } } Modified: branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_hkp.c =================================================================== --- branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_hkp.c 2006-09-26 10:00:12 UTC (rev 4267) +++ branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_hkp.c 2006-09-26 14:15:17 UTC (rev 4268) @@ -17,6 +17,17 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. + * + * In addition, as a special exception, the Free Software Foundation + * gives permission to link the code of the keyserver helper tools: + * gpgkeys_ldap, gpgkeys_curl and gpgkeys_hkp with the OpenSSL + * project's "OpenSSL" library (or with modified versions of it that + * use the same license as the "OpenSSL" library), and distribute the + * linked executables. You must obey the GNU General Public License + * in all respects for all of the code used other than "OpenSSL". If + * you modify this file, you may extend this exception to your version + * of the file, but you are not obligated to do so. If you do not + * wish to do so, delete this exception statement from your version. */ #include Modified: branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_ldap.c =================================================================== --- branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_ldap.c 2006-09-26 10:00:12 UTC (rev 4267) +++ branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_ldap.c 2006-09-26 14:15:17 UTC (rev 4268) @@ -17,6 +17,17 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. + * + * In addition, as a special exception, the Free Software Foundation + * gives permission to link the code of the keyserver helper tools: + * gpgkeys_ldap, gpgkeys_curl and gpgkeys_hkp with the OpenSSL + * project's "OpenSSL" library (or with modified versions of it that + * use the same license as the "OpenSSL" library), and distribute the + * linked executables. You must obey the GNU General Public License + * in all respects for all of the code used other than "OpenSSL". If + * you modify this file, you may extend this exception to your version + * of the file, but you are not obligated to do so. If you do not + * wish to do so, delete this exception statement from your version. */ #include @@ -29,6 +40,7 @@ #endif #include #include +#include #ifdef _WIN32 #include @@ -355,7 +367,7 @@ if((record=strsep(&line,":"))==NULL) return; - if(ascii_strcasecmp("pub",record)==0) + if (ks_strcasecmp("pub",record)==0) { char *tok; int disabled=0,revoked=0; @@ -461,7 +473,7 @@ make_one_attr(modlist,"pgpDisabled",disabled?"1":"0"); make_one_attr(modlist,"pgpRevoked",revoked?"1":"0"); } - else if(ascii_strcasecmp("sub",record)==0) + else if (ks_strcasecmp("sub",record)==0) { char *tok; @@ -499,7 +511,7 @@ /* Ignore the rest of the items for subkeys since the LDAP schema doesn't store them. */ } - else if(ascii_strcasecmp("uid",record)==0) + else if (ks_strcasecmp("uid",record)==0) { char *userid,*tok; @@ -520,7 +532,7 @@ while(*tok) if(tok[0]=='%' && tok[1] && tok[2]) { - if((userid[i]=hextobyte(&tok[1]))==-1) + if((userid[i]=ks_hextobyte(&tok[1]))==-1) userid[i]='?'; i++; @@ -536,7 +548,7 @@ make_one_attr(modlist,"pgpUserID",userid); } - else if(ascii_strcasecmp("sig",record)==0) + else if(ks_strcasecmp("sig",record)==0) { char *tok; @@ -2325,7 +2337,7 @@ free(searchkey); } else - BUG(); + assert (!"invalid action"); if(!failed) ret=KEYSERVER_OK; Modified: branches/STABLE-BRANCH-1-4/keyserver/ksutil.c =================================================================== --- branches/STABLE-BRANCH-1-4/keyserver/ksutil.c 2006-09-26 10:00:12 UTC (rev 4267) +++ branches/STABLE-BRANCH-1-4/keyserver/ksutil.c 2006-09-26 14:15:17 UTC (rev 4268) @@ -17,6 +17,17 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. + * + * In addition, as a special exception, the Free Software Foundation + * gives permission to link the code of the keyserver helper tools: + * gpgkeys_ldap, gpgkeys_curl and gpgkeys_hkp with the OpenSSL + * project's "OpenSSL" library (or with modified versions of it that + * use the same license as the "OpenSSL" library), and distribute the + * linked executables. You must obey the GNU General Public License + * in all respects for all of the code used other than "OpenSSL". If + * you modify this file, you may extend this exception to your version + * of the file, but you are not obligated to do so. If you do not + * wish to do so, delete this exception statement from your version. */ #include @@ -538,3 +549,54 @@ ctx->flags.done=1; } } + +int +ks_hextobyte (const char *s) +{ + int c; + + if ( *s >= '0' && *s <= '9' ) + c = 16 * (*s - '0'); + else if ( *s >= 'A' && *s <= 'F' ) + c = 16 * (10 + *s - 'A'); + else if ( *s >= 'a' && *s <= 'f' ) + c = 16 * (10 + *s - 'a'); + else + return -1; + s++; + if ( *s >= '0' && *s <= '9' ) + c += *s - '0'; + else if ( *s >= 'A' && *s <= 'F' ) + c += 10 + *s - 'A'; + else if ( *s >= 'a' && *s <= 'f' ) + c += 10 + *s - 'a'; + else + return -1; + return c; +} + + +/* Non localized version of toupper. */ +int +ks_toupper (int c) +{ + if (c >= 'a' && c <= 'z') + c &= ~0x20; + return c; +} + + +/* Non localized version of strcasecmp. */ +int +ks_strcasecmp (const char *a, const char *b) +{ + if (a == b) + return 0; + + for (; *a && *b; a++, b++) + { + if (*a != *b && ks_toupper (*a) != ks_toupper (*b)) + break; + } + return *a == *b? 0 : (ks_toupper (*a) - ks_toupper (*b)); +} Modified: branches/STABLE-BRANCH-1-4/keyserver/ksutil.h =================================================================== --- branches/STABLE-BRANCH-1-4/keyserver/ksutil.h 2006-09-26 10:00:12 UTC (rev 4267) +++ branches/STABLE-BRANCH-1-4/keyserver/ksutil.h 2006-09-26 14:15:17 UTC (rev 4268) @@ -17,6 +17,17 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. + * + * In addition, as a special exception, the Free Software Foundation + * gives permission to link the code of the keyserver helper tools: + * gpgkeys_ldap, gpgkeys_curl and gpgkeys_hkp with the OpenSSL + * project's "OpenSSL" library (or with modified versions of it that + * use the same license as the "OpenSSL" library), and distribute the + * linked executables. You must obey the GNU General Public License + * in all respects for all of the code used other than "OpenSSL". If + * you modify this file, you may extend this exception to your version + * of the file, but you are not obligated to do so. If you do not + * wish to do so, delete this exception statement from your version. */ #ifndef _KSUTIL_H_ @@ -127,4 +138,9 @@ size_t curl_writer(const void *ptr,size_t size,size_t nmemb,void *cw_ctx); void curl_writer_finalize(struct curl_writer_ctx *ctx); +int ks_hextobyte (const char *s); +int ks_toupper (int c); +int ks_strcasecmp (const char *a, const char *b); + + #endif /* !_KSUTIL_H_ */ Modified: branches/STABLE-BRANCH-1-4/scripts/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/scripts/ChangeLog 2006-09-26 10:00:12 UTC (rev 4267) +++ branches/STABLE-BRANCH-1-4/scripts/ChangeLog 2006-09-26 14:15:17 UTC (rev 4268) @@ -1,3 +1,7 @@ +2006-09-13 Werner Koch + + * autogen.sh: Better detection of the cross compiler. + 2006-04-03 Werner Koch * w32installer.nsi: Install curl and not http keyserver helper. Modified: branches/STABLE-BRANCH-1-4/scripts/autogen.sh =================================================================== --- branches/STABLE-BRANCH-1-4/scripts/autogen.sh 2006-09-26 10:00:12 UTC (rev 4267) +++ branches/STABLE-BRANCH-1-4/scripts/autogen.sh 2006-09-26 14:15:17 UTC (rev 4268) @@ -51,34 +51,26 @@ fi build=`$tsdir/scripts/config.guess` - # See whether we have the Debian cross compiler package or the - # old mingw32/cpd system - if i586-mingw32msvc-gcc --version >/dev/null 2>&1 ; then - host=i586-mingw32msvc - crossbindir=/usr/$host/bin - conf_CC="CC=${host}-gcc" - else - host=i386--mingw32 - if ! mingw32 --version >/dev/null; then - echo "We need at least version 0.3 of MingW32/CPD" >&2 - exit 1 - fi - echo "MingW32/CPD is no longer supported" >&2 - exit 1 - # crossbindir=`mingw32 --install-dir`/bin - # # Old autoconf version required us to setup the environment - # # with the proper tool names. - # CC=`mingw32 --get-path gcc` - # CPP=`mingw32 --get-path cpp` - # AR=`mingw32 --get-path ar` - # RANLIB=`mingw32 --get-path ranlib` - # export CC CPP AR RANLIB - # conf_CC="" + # Locate the cross compiler + crossbindir= + for host in i586-mingw32msvc i386-mingw32msvc; do + if ${host}-gcc --version >/dev/null 2>&1 ; then + crossbindir=/usr/${host}/bin + conf_CC="CC=${host}-gcc" + break; + fi + done + if [ -z "$crossbindir" ]; then + echo "Cross compiler kit not installed" >&2 + echo "Under Debian GNU/Linux, you may install it using" >&2 + echo " apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2 + echo "Stop." >&2 + exit 1 fi if [ -f "$tsdir/config.log" ]; then if ! head $tsdir/config.log | grep "$host" >/dev/null; then - echo "Pease run a 'make distclean' first" >&2 + echo "Please run a 'make distclean' first" >&2 exit 1 fi fi From cvs at cvs.gnupg.org Tue Sep 26 16:35:25 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue Sep 26 15:49:17 2006 Subject: [svn] GnuPG - r4269 - in trunk: doc keyserver Message-ID: Author: wk Date: 2006-09-26 16:35:24 +0200 (Tue, 26 Sep 2006) New Revision: 4269 Modified: trunk/doc/gpgsm.texi trunk/keyserver/ChangeLog trunk/keyserver/Makefile.am trunk/keyserver/curl-shim.c trunk/keyserver/curl-shim.h Log: Made buliding w/o curl work Modified: trunk/doc/gpgsm.texi =================================================================== --- trunk/doc/gpgsm.texi 2006-09-26 14:15:17 UTC (rev 4268) +++ trunk/doc/gpgsm.texi 2006-09-26 14:35:24 UTC (rev 4269) @@ -377,8 +377,11 @@ certificates into a CRL. The disable option may be used to switch this extra check off. Due to the caching done by the Dirmngr, there won't be any noticeable performance gain. Note, that this also disables possible -OCSP checks for trusted root certificates. +OCSP checks for trusted root certificates. A more specific way of +disabling this check is by adding the ``relax'' keyword to the root CA +line of the @file{trustlist.txt} + @item --force-crl-refresh @opindex force-crl-refresh Tell the dirmngr to reload the CRL for each request. For better Modified: trunk/keyserver/ChangeLog =================================================================== --- trunk/keyserver/ChangeLog 2006-09-26 14:15:17 UTC (rev 4268) +++ trunk/keyserver/ChangeLog 2006-09-26 14:35:24 UTC (rev 4269) @@ -1,3 +1,14 @@ +2006-09-26 Werner Koch + + * curl-shim.c: Adjusted for changes in http.c. + (curl_easy_perform): Changed LINE from unsigned char* to char*. + + * Makefile.am (gpg2keys_curl_LDADD, gpg2keys_hkp_LDADD) + [FAKE_CURL]: Need to link against common_libs and pth. + + * curl-shim.h, curl-shim.c: Removed license exception as not + needed here. + 2006-09-22 Werner Koch * gpgkeys_curl.c, gpgkeys_hkp.c, gpgkeys_ldap.c, curl-shim.c: Modified: trunk/keyserver/Makefile.am =================================================================== --- trunk/keyserver/Makefile.am 2006-09-26 14:15:17 UTC (rev 4268) +++ trunk/keyserver/Makefile.am 2006-09-26 14:35:24 UTC (rev 4269) @@ -54,11 +54,13 @@ if FAKE_CURL gpg2keys_curl_SOURCES += curl-shim.c curl-shim.h -gpg2keys_curl_LDADD = $(NETLIBS) $(DNSLIBS) \ - $(other_libs) $(W32LIBS) +gpg2keys_curl_CPPFLAGS = $(AM_CPPFLAGS) +gpg2keys_curl_LDADD = $(common_libs) $(GPG_ERROR_LIBS) $(NETLIBS) $(DNSLIBS) \ + $(other_libs) $(PTH_LIBS) $(W32LIBS) gpg2keys_hkp_SOURCES += curl-shim.c curl-shim.h -gpg2keys_hkp_LDADD = $(NETLIBS) $(DNSLIBS) \ - $(other_libs) $(W32LIBS) +gpg2keys_hkp_CPPFLAGS = $(AM_CPPFLAGS) +gpg2keys_hkp_LDADD = $(common_libs) $(GPG_ERROR_LIBS) $(NETLIBS) $(DNSLIBS) \ + $(other_libs) $(PTH_LIBS) $(W32LIBS) else gpg2keys_curl_CPPFLAGS = $(LIBCURL_CPPFLAGS) $(AM_CPPFLAGS) gpg2keys_curl_LDADD = $(LIBCURL) $(GETOPT) Modified: trunk/keyserver/curl-shim.c =================================================================== --- trunk/keyserver/curl-shim.c 2006-09-26 14:15:17 UTC (rev 4268) +++ trunk/keyserver/curl-shim.c 2006-09-26 14:35:24 UTC (rev 4269) @@ -19,17 +19,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. - * - * In addition, as a special exception, the Free Software Foundation - * gives permission to link the code of the keyserver helper tools: - * gpgkeys_ldap, gpgkeys_curl and gpgkeys_hkp with the OpenSSL - * project's "OpenSSL" library (or with modified versions of it that - * use the same license as the "OpenSSL" library), and distribute the - * linked executables. You must obey the GNU General Public License - * in all respects for all of the code used other than "OpenSSL". If - * you modify this file, you may extend this exception to your version - * of the file, but you are not obligated to do so. If you do not - * wish to do so, delete this exception statement from your version. */ #include @@ -114,7 +103,7 @@ { if (curl) { - http_close (curl->hd); + http_close (curl->hd, 0); free(curl); } } @@ -210,7 +199,7 @@ curl->status = http_get_status_code (curl->hd); if (!rc && curl->flags.failonerror && curl->status>=300) err = CURLE_HTTP_RETURNED_ERROR; - http_close(curl->hd); + http_close (curl->hd, 0); curl->hd = NULL; } } @@ -229,7 +218,7 @@ else { unsigned int maxlen = 1024, buflen, len; - unsigned char *line = NULL; + char *line = NULL; while ((len = es_read_line (http_get_read_ptr (curl->hd), &line, &buflen, &maxlen))) @@ -247,34 +236,29 @@ } es_free (line); - http_close(curl->hd); + http_close(curl->hd, 0); curl->hd = NULL; } } else { - http_close (curl->hd); + http_close (curl->hd, 0); curl->hd = NULL; } } } - switch(rc) + switch(gpg_err_code (rc)) { case 0: break; - case G10ERR_INVALID_URI: + case GPG_ERR_INV_URI: err=CURLE_UNSUPPORTED_PROTOCOL; break; - case G10ERR_NETWORK: - errstr=strerror(errno); - err=CURLE_COULDNT_CONNECT; - break; - default: - errstr=g10_errstr(rc); + errstr=gpg_strerror (rc); err=CURLE_COULDNT_CONNECT; break; } Modified: trunk/keyserver/curl-shim.h =================================================================== --- trunk/keyserver/curl-shim.h 2006-09-26 14:15:17 UTC (rev 4268) +++ trunk/keyserver/curl-shim.h 2006-09-26 14:35:24 UTC (rev 4269) @@ -17,17 +17,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * USA. - * - * In addition, as a special exception, the Free Software Foundation - * gives permission to link the code of the keyserver helper tools: - * gpgkeys_ldap, gpgkeys_curl and gpgkeys_hkp with the OpenSSL - * project's "OpenSSL" library (or with modified versions of it that - * use the same license as the "OpenSSL" library), and distribute the - * linked executables. You must obey the GNU General Public License - * in all respects for all of the code used other than "OpenSSL". If - * you modify this file, you may extend this exception to your version - * of the file, but you are not obligated to do so. If you do not - * wish to do so, delete this exception statement from your version. */ #ifndef _CURL_SHIM_H_ From cvs at cvs.gnupg.org Tue Sep 26 19:32:28 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue Sep 26 18:46:19 2006 Subject: [svn] GnuPG - r4270 - trunk/agent Message-ID: Author: wk Date: 2006-09-26 19:32:28 +0200 (Tue, 26 Sep 2006) New Revision: 4270 Modified: trunk/agent/ChangeLog trunk/agent/command.c trunk/agent/learncard.c Log: let cmd learn also return KEYPAIRINFO Modified: trunk/agent/ChangeLog =================================================================== --- trunk/agent/ChangeLog 2006-09-26 14:35:24 UTC (rev 4269) +++ trunk/agent/ChangeLog 2006-09-26 17:32:28 UTC (rev 4270) @@ -1,3 +1,8 @@ +2006-09-26 Werner Koch + + * learncard.c (agent_handle_learn): Send back the keypair + information. + 2006-09-25 Werner Koch * trustlist.c (read_one_trustfile): Allow extra flags. Modified: trunk/agent/command.c =================================================================== --- trunk/agent/command.c 2006-09-26 14:35:24 UTC (rev 4269) +++ trunk/agent/command.c 2006-09-26 17:32:28 UTC (rev 4270) @@ -1183,6 +1183,8 @@ return 0; } + + /* Tell the assuan library about our commands */ static int Modified: trunk/agent/learncard.c =================================================================== --- trunk/agent/learncard.c 2006-09-26 14:35:24 UTC (rev 4269) +++ trunk/agent/learncard.c 2006-09-26 17:32:28 UTC (rev 4270) @@ -360,6 +360,12 @@ if (item->no_cert) continue; /* No public key yet available. */ + if (assuan_context) + { + agent_write_status (ctrl, "KEYPAIRINFO", + item->hexgrip, item->id, NULL); + } + for (p=item->hexgrip, i=0; i < 20; p += 2, i++) grip[i] = xtoi_2 (p); From cvs at cvs.gnupg.org Wed Sep 27 15:58:14 2006 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed Sep 27 15:12:02 2006 Subject: [svn] GnuPG - r4271 - trunk/common Message-ID: Author: wk Date: 2006-09-27 15:58:13 +0200 (Wed, 27 Sep 2006) New Revision: 4271 Added: trunk/common/gpgrlhelp.c Modified: trunk/common/ChangeLog trunk/common/iobuf.c trunk/common/iobuf.h trunk/common/util.h Log: Add missing file and other changes. Modified: trunk/common/ChangeLog =================================================================== --- trunk/common/ChangeLog 2006-09-26 17:32:28 UTC (rev 4270) +++ trunk/common/ChangeLog 2006-09-27 13:58:13 UTC (rev 4271) @@ -1,3 +1,15 @@ +2006-09-27 Werner Koch + + * util.h: Do not include strsep.h and strpbrk.h. + (isascii): Removed as it is now in jnlib. + + * iobuf.c (pop_filter, underflow, iobuf_close): Free the unget + buffer. + +2006-09-27 Florian Weimer (wk) + + * iobuf.c (iobuf_unread): New. + 2006-09-22 Werner Koch * i18n.h: Changed license to an all permissive one. Added: trunk/common/gpgrlhelp.c =================================================================== --- trunk/common/gpgrlhelp.c 2006-09-26 17:32:28 UTC (rev 4270) +++ trunk/common/gpgrlhelp.c 2006-09-27 13:58:13 UTC (rev 4271) @@ -0,0 +1,88 @@ +/* gpgrlhelp.c - A readline wrapper. + * Copyright (C) 2006 Free Software Foundation, Inc. + * + * This file is part of GnuPG. + * + * GnuPG 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. + * + * GnuPG 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + */ + +/* This module may by used by applications to initializes readline + support. It is required so that we can have hooks in other parts + of libcommon without actually requing to link against + libreadline. It works along ttyio.c which a proper part of + libcommon. */ + +#include +#include +#include + +#ifdef HAVE_LIBREADLINE +#define GNUPG_LIBREADLINE_H_INCLUDED +#include +#include +#endif + +#include "util.h" +#include "common-defs.h" + + +static void +set_completer (rl_completion_func_t *completer) +{ + rl_attempted_completion_function = completer; + rl_inhibit_completion = 0; +} + +static void +inhibit_completion (int value) +{ + rl_inhibit_completion = value; +} + +static void +cleanup_after_signal (void) +{ + rl_free_line_state (); + rl_cleanup_after_signal (); +} + +static void +init_stream (FILE *fp) +{ + rl_catch_signals = 0; + rl_instream = rl_outstream = fp; + rl_inhibit_completion = 1; +} + + +/* Initialize our readline code. This should be called as early as + possible as it is actually a constructur. */ +void +gnupg_rl_initialize (void) +{ + tty_private_set_rl_hooks (init_stream, + set_completer, + inhibit_completion, + cleanup_after_signal, + readline, + add_history); + rl_readline_name = "GnuPG"; + +} + + + + Modified: trunk/common/iobuf.c =================================================================== --- trunk/common/iobuf.c 2006-09-26 17:32:28 UTC (rev 4270) +++ trunk/common/iobuf.c 2006-09-27 13:58:13 UTC (rev 4271) @@ -1037,6 +1037,7 @@ { memset (a->d.buf, 0, a->d.size); /* erase the buffer */ xfree (a->d.buf); + xfree (a->unget.buf); } xfree (a); } @@ -1538,6 +1539,7 @@ b = a->chain; assert (b); xfree (a->d.buf); + xfree (a->unget.buf); xfree (a->real_fname); memcpy (a, b, sizeof *a); xfree (b); @@ -1579,6 +1581,7 @@ */ b = a->chain; xfree (a->d.buf); + xfree (a->unget.buf); xfree (a->real_fname); memcpy (a, b, sizeof *a); xfree (b); @@ -1621,6 +1624,7 @@ log_debug ("iobuf-%d.%d: pop `%s' in underflow\n", a->no, a->subno, a->desc); xfree (a->d.buf); + xfree (a->unget.buf); xfree (a->real_fname); memcpy (a, b, sizeof *a); xfree (b); @@ -1695,6 +1699,7 @@ log_debug ("iobuf-%d.%d: pop `%s' in underflow (!len)\n", a->no, a->subno, a->desc); xfree (a->d.buf); + xfree (a->unget.buf); xfree (a->real_fname); memcpy (a, b, sizeof *a); xfree (b); @@ -1859,6 +1864,31 @@ } + +/* This is a verly limited unget fucntion for an iobuf. It does only + work in certain cases and should be used with care. */ +void +iobuf_unread (iobuf_t a, const unsigned char *buf, unsigned int buflen) +{ + unsigned int new_len; + + if (!buflen) + return; + + /* We always relocate the buffer, which is not optimal. However, + the code is easier to read this way, and it is not on the fast + path. */ + if ( !a->unget.buf ) + a->unget.size = a->unget.start = a->unget.len = 0; + + new_len = a->unget.len + buflen; + a->unget.buf = xrealloc(a->unget.buf, new_len); + memcpy(a->unget.buf + a->unget.len, buf, buflen); + a->unget.len = new_len; + a->nofast |= 2; +} + + /**************** * Have a look at the iobuf. * NOTE: This only works in special cases. Modified: trunk/common/iobuf.h =================================================================== --- trunk/common/iobuf.h 2006-09-26 17:32:28 UTC (rev 4270) +++ trunk/common/iobuf.h 2006-09-27 13:58:13 UTC (rev 4271) @@ -44,18 +44,21 @@ { int use; /* 1 input , 2 output, 3 temp */ off_t nlimit; - off_t nbytes; /* used together with nlimit */ - off_t ntotal; /* total bytes read (position of stream) */ - int nofast; /* used by the iobuf_get() */ + off_t nbytes; /* Used together with nlimit. */ + off_t ntotal; /* Total bytes read (position of stream). */ + int nofast; /* Used by the iobuf_get (). */ + /* bit 0 (LSB): slow path because of limit. */ + /* bit 1: slow path because of unread. */ void *directfp; struct { - size_t size; /* allocated size */ - size_t start; /* number of invalid bytes at the begin of the buffer */ - size_t len; /* currently filled to this size */ + size_t size; /* Allocated size */ + size_t start; /* Number of invalid bytes at the + begin of the buffer */ + size_t len; /* Currently filled to this size */ byte *buf; - } - d; + } d; + int filter_eof; int error; int (*filter) (void *opaque, int control, @@ -77,8 +80,7 @@ begin of the buffer */ size_t len; /* currently filled to this size */ byte *buf; - } - unget; + } unget; }; #ifndef EXTERN_UNLESS_MAIN_MODULE @@ -124,6 +126,7 @@ int iobuf_readbyte (iobuf_t a); int iobuf_read (iobuf_t a, void *buf, unsigned buflen); +void iobuf_unread (iobuf_t a, const unsigned char *buf, unsigned int buflen); unsigned iobuf_read_line (iobuf_t a, byte ** addr_of_buffer, unsigned *length_of_buffer, unsigned *max_length); int iobuf_peek (iobuf_t a, byte * buf, unsigned buflen); Modified: trunk/common/util.h =================================================================== --- trunk/common/util.h 2006-09-26 17:32:28 UTC (rev 4270) +++ trunk/common/util.h 2006-09-27 13:58:13 UTC (rev 4271) @@ -28,8 +28,6 @@ #include /* We need gpg_error_t. */ /* Common GNUlib includes (-I ../gl/). */ -#include "strpbrk.h" -#include "strsep.h" #include "vasprintf.h" @@ -196,13 +194,6 @@ }; #endif /* !HAVE_TTYNAME */ -#ifndef HAVE_ISASCII -static inline int -isascii (int c) -{ - return (((c) & ~0x7f) == 0); -} -#endif /* !HAVE_ISASCII */ /*-- Macros to replace ctype ones to avoid locale problems. --*/ #define spacep(p) (*(p) == ' ' || *(p) == '\t') From cvs at cvs.gnupg.org Wed Sep 27 16:56:27 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Wed Sep 27 16:10:18 2006 Subject: [svn] GnuPG - r4272 - trunk Message-ID: Author: marcus Date: 2006-09-27 16:56:26 +0200 (Wed, 27 Sep 2006) New Revision: 4272 Modified: trunk/ChangeLog trunk/Makefile.am Log: 2006-09-27 Marcus Brinkmann * Makefile.am: Fix cut & paste error. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-09-27 13:58:13 UTC (rev 4271) +++ trunk/ChangeLog 2006-09-27 14:56:26 UTC (rev 4272) @@ -1,3 +1,7 @@ +2006-09-27 Marcus Brinkmann + + * Makefile.am: Fix cut & paste error. + 2006-09-25 Werner Koch Released 1.9.90. Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2006-09-27 13:58:13 UTC (rev 4271) +++ trunk/Makefile.am 2006-09-27 14:56:26 UTC (rev 4272) @@ -57,14 +57,14 @@ scd = endif if BUILD_TOOLS -scd = tools +tools = tools else -scd = +tools = endif if BUILD_DOC -scd = doc +doc = doc else -scd = +doc = endif if HAVE_W32_SYSTEM From cvs at cvs.gnupg.org Thu Sep 28 18:27:23 2006 From: cvs at cvs.gnupg.org (svn author marcus) Date: Thu Sep 28 17:41:12 2006 Subject: [svn] assuan - r211 - trunk/src Message-ID: Author: marcus Date: 2006-09-28 18:27:23 +0200 (Thu, 28 Sep 2006) New Revision: 211 Modified: trunk/src/ChangeLog trunk/src/assuan-client.c Log: 2006-09-28 Marcus Brinkmann * assuan-client.c (assuan_transact): Do not convert error on status line, it is already a gpg-error. Do convert ASSUAN_Server_Fault. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2006-09-19 13:34:48 UTC (rev 210) +++ trunk/src/ChangeLog 2006-09-28 16:27:23 UTC (rev 211) @@ -1,3 +1,9 @@ +2006-09-28 Marcus Brinkmann + + * assuan-client.c (assuan_transact): Do not convert error on + status line, it is already a gpg-error. Do convert + ASSUAN_Server_Fault. + 2006-09-19 Marcus Brinkmann * assuan.h (assuan_init_socket_server_ext) Modified: trunk/src/assuan-client.c =================================================================== --- trunk/src/assuan-client.c 2006-09-19 13:34:48 UTC (rev 210) +++ trunk/src/assuan-client.c 2006-09-28 16:27:23 UTC (rev 211) @@ -161,9 +161,9 @@ if (!okay) { - rc = _assuan_error (atoi (line)); + rc = atoi (line); if (rc < 100) - rc = ASSUAN_Server_Fault; + rc = _assuan_error (ASSUAN_Server_Fault); } else if (okay == 2) { From cvs at cvs.gnupg.org Thu Sep 28 21:30:04 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Thu Sep 28 20:43:45 2006 Subject: [svn] GnuPG - r4273 - branches/STABLE-BRANCH-1-4/keyserver Message-ID: Author: dshaw Date: 2006-09-28 21:30:03 +0200 (Thu, 28 Sep 2006) New Revision: 4273 Modified: branches/STABLE-BRANCH-1-4/keyserver/ChangeLog branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_ldap.c branches/STABLE-BRANCH-1-4/keyserver/ksutil.c branches/STABLE-BRANCH-1-4/keyserver/ksutil.h Log: * gpgkeys_ldap.c (build_attrs), ksutil.c (ks_toupper, ks_strcasecmp), ksutil.h: Remove the need for strcasecmp as the field tags are always lowercase. Modified: branches/STABLE-BRANCH-1-4/keyserver/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/keyserver/ChangeLog 2006-09-27 14:56:26 UTC (rev 4272) +++ branches/STABLE-BRANCH-1-4/keyserver/ChangeLog 2006-09-28 19:30:03 UTC (rev 4273) @@ -1,3 +1,9 @@ +2006-09-28 David Shaw + + * gpgkeys_ldap.c (build_attrs), ksutil.c (ks_toupper, + ks_strcasecmp), ksutil.h: Remove the need for strcasecmp as the + field tags are always lowercase. + 2006-09-26 Werner Koch * gpgkeys_finger.c (get_key): Cast away signed/unsigned char ptr Modified: branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_ldap.c =================================================================== --- branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_ldap.c 2006-09-27 14:56:26 UTC (rev 4272) +++ branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_ldap.c 2006-09-28 19:30:03 UTC (rev 4273) @@ -367,7 +367,7 @@ if((record=strsep(&line,":"))==NULL) return; - if (ks_strcasecmp("pub",record)==0) + if (strcmp("pub",record)==0) { char *tok; int disabled=0,revoked=0; @@ -473,7 +473,7 @@ make_one_attr(modlist,"pgpDisabled",disabled?"1":"0"); make_one_attr(modlist,"pgpRevoked",revoked?"1":"0"); } - else if (ks_strcasecmp("sub",record)==0) + else if (strcmp("sub",record)==0) { char *tok; @@ -511,7 +511,7 @@ /* Ignore the rest of the items for subkeys since the LDAP schema doesn't store them. */ } - else if (ks_strcasecmp("uid",record)==0) + else if (strcmp("uid",record)==0) { char *userid,*tok; @@ -548,7 +548,7 @@ make_one_attr(modlist,"pgpUserID",userid); } - else if(ks_strcasecmp("sig",record)==0) + else if(strcmp("sig",record)==0) { char *tok; Modified: branches/STABLE-BRANCH-1-4/keyserver/ksutil.c =================================================================== --- branches/STABLE-BRANCH-1-4/keyserver/ksutil.c 2006-09-27 14:56:26 UTC (rev 4272) +++ branches/STABLE-BRANCH-1-4/keyserver/ksutil.c 2006-09-28 19:30:03 UTC (rev 4273) @@ -574,29 +574,3 @@ return -1; return c; } - - -/* Non localized version of toupper. */ -int -ks_toupper (int c) -{ - if (c >= 'a' && c <= 'z') - c &= ~0x20; - return c; -} - - -/* Non localized version of strcasecmp. */ -int -ks_strcasecmp (const char *a, const char *b) -{ - if (a == b) - return 0; - - for (; *a && *b; a++, b++) - { - if (*a != *b && ks_toupper (*a) != ks_toupper (*b)) - break; - } - return *a == *b? 0 : (ks_toupper (*a) - ks_toupper (*b)); -} Modified: branches/STABLE-BRANCH-1-4/keyserver/ksutil.h =================================================================== --- branches/STABLE-BRANCH-1-4/keyserver/ksutil.h 2006-09-27 14:56:26 UTC (rev 4272) +++ branches/STABLE-BRANCH-1-4/keyserver/ksutil.h 2006-09-28 19:30:03 UTC (rev 4273) @@ -139,8 +139,5 @@ void curl_writer_finalize(struct curl_writer_ctx *ctx); int ks_hextobyte (const char *s); -int ks_toupper (int c); -int ks_strcasecmp (const char *a, const char *b); - #endif /* !_KSUTIL_H_ */ From cvs at cvs.gnupg.org Thu Sep 28 21:36:59 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Thu Sep 28 20:50:35 2006 Subject: [svn] GnuPG - r4274 - in branches/STABLE-BRANCH-1-4: include keyserver util Message-ID: Author: dshaw Date: 2006-09-28 21:36:55 +0200 (Thu, 28 Sep 2006) New Revision: 4274 Added: branches/STABLE-BRANCH-1-4/include/compat.h branches/STABLE-BRANCH-1-4/util/compat.c Modified: branches/STABLE-BRANCH-1-4/include/ChangeLog branches/STABLE-BRANCH-1-4/include/util.h branches/STABLE-BRANCH-1-4/keyserver/ChangeLog branches/STABLE-BRANCH-1-4/keyserver/Makefile.am branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_ldap.c branches/STABLE-BRANCH-1-4/keyserver/ksutil.c branches/STABLE-BRANCH-1-4/keyserver/ksutil.h branches/STABLE-BRANCH-1-4/util/ChangeLog branches/STABLE-BRANCH-1-4/util/Makefile.am branches/STABLE-BRANCH-1-4/util/miscutil.c Log: Put in the basic wiring (just hextobyte for now) for a libcompat.a that can contain replacement files that can be linked to keyserver helpers without bringing in the whole libutil.a. libutil.a contains a complete copy of libcompat.a so we only need to link to one of them. Modified: branches/STABLE-BRANCH-1-4/include/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/include/ChangeLog 2006-09-28 19:30:03 UTC (rev 4273) +++ branches/STABLE-BRANCH-1-4/include/ChangeLog 2006-09-28 19:36:55 UTC (rev 4274) @@ -1,3 +1,9 @@ +2006-09-28 David Shaw + + * compat.h: New, used for libcompat.a functions. + + * util.h: Includes compat.h. + 2006-04-20 David Shaw * cipher.h: Add dsa2_generate(); Added: branches/STABLE-BRANCH-1-4/include/compat.h =================================================================== --- branches/STABLE-BRANCH-1-4/include/compat.h 2006-09-28 19:30:03 UTC (rev 4273) +++ branches/STABLE-BRANCH-1-4/include/compat.h 2006-09-28 19:36:55 UTC (rev 4274) @@ -0,0 +1,6 @@ +#ifndef _COMPAT_H_ +#define _COMPAT_H_ + +int hextobyte( const char *s ); + +#endif /* !_COMPAT_H_ */ Modified: branches/STABLE-BRANCH-1-4/include/util.h =================================================================== --- branches/STABLE-BRANCH-1-4/include/util.h 2006-09-28 19:30:03 UTC (rev 4273) +++ branches/STABLE-BRANCH-1-4/include/util.h 2006-09-28 19:36:55 UTC (rev 4274) @@ -30,8 +30,8 @@ #include "errors.h" #include "types.h" #include "mpi.h" +#include "compat.h" - typedef struct { int *argc; /* pointer to argc (value subject to change) */ char ***argv; /* pointer to argv (value subject to change) */ @@ -164,7 +164,6 @@ int answer_is_yes_no_quit( const char *s ); int answer_is_okay_cancel (const char *s, int def_answer); int match_multistr(const char *multistr,const char *match); -int hextobyte( const char *s ); /*-- strgutil.c --*/ void free_strlist( STRLIST sl ); Modified: branches/STABLE-BRANCH-1-4/keyserver/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/keyserver/ChangeLog 2006-09-28 19:30:03 UTC (rev 4273) +++ branches/STABLE-BRANCH-1-4/keyserver/ChangeLog 2006-09-28 19:36:55 UTC (rev 4274) @@ -1,5 +1,10 @@ 2006-09-28 David Shaw + * Makefile.am: Link gpgkeys_ldap to libcompat.a. + + * gpgkeys_ldap.c, ksutil.h, ksutil.c: Remove hextobyte instead of + ks_hextobyte as it is provided by libcompat now. + * gpgkeys_ldap.c (build_attrs), ksutil.c (ks_toupper, ks_strcasecmp), ksutil.h: Remove the need for strcasecmp as the field tags are always lowercase. Modified: branches/STABLE-BRANCH-1-4/keyserver/Makefile.am =================================================================== --- branches/STABLE-BRANCH-1-4/keyserver/Makefile.am 2006-09-28 19:30:03 UTC (rev 4273) +++ branches/STABLE-BRANCH-1-4/keyserver/Makefile.am 2006-09-28 19:36:55 UTC (rev 4274) @@ -36,7 +36,7 @@ other_libs = $(LIBICONV) $(LIBINTL) $(CAPLIBS) gpgkeys_ldap_CPPFLAGS = @LDAP_CPPFLAGS@ -gpgkeys_ldap_LDADD = @LDAPLIBS@ @NETLIBS@ $(other_libs) @GETOPT@ @W32LIBS@ +gpgkeys_ldap_LDADD = ../util/libcompat.a @LDAPLIBS@ @NETLIBS@ $(other_libs) @GETOPT@ @W32LIBS@ gpgkeys_finger_LDADD = ../util/libutil.a @NETLIBS@ $(other_libs) @GETOPT@ @W32LIBS@ Modified: branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_ldap.c =================================================================== --- branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_ldap.c 2006-09-28 19:30:03 UTC (rev 4273) +++ branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_ldap.c 2006-09-28 19:36:55 UTC (rev 4274) @@ -532,7 +532,7 @@ while(*tok) if(tok[0]=='%' && tok[1] && tok[2]) { - if((userid[i]=ks_hextobyte(&tok[1]))==-1) + if((userid[i]=hextobyte(&tok[1]))==-1) userid[i]='?'; i++; Modified: branches/STABLE-BRANCH-1-4/keyserver/ksutil.c =================================================================== --- branches/STABLE-BRANCH-1-4/keyserver/ksutil.c 2006-09-28 19:30:03 UTC (rev 4273) +++ branches/STABLE-BRANCH-1-4/keyserver/ksutil.c 2006-09-28 19:36:55 UTC (rev 4274) @@ -549,28 +549,3 @@ ctx->flags.done=1; } } - -int -ks_hextobyte (const char *s) -{ - int c; - - if ( *s >= '0' && *s <= '9' ) - c = 16 * (*s - '0'); - else if ( *s >= 'A' && *s <= 'F' ) - c = 16 * (10 + *s - 'A'); - else if ( *s >= 'a' && *s <= 'f' ) - c = 16 * (10 + *s - 'a'); - else - return -1; - s++; - if ( *s >= '0' && *s <= '9' ) - c += *s - '0'; - else if ( *s >= 'A' && *s <= 'F' ) - c += 10 + *s - 'A'; - else if ( *s >= 'a' && *s <= 'f' ) - c += 10 + *s - 'a'; - else - return -1; - return c; -} Modified: branches/STABLE-BRANCH-1-4/keyserver/ksutil.h =================================================================== --- branches/STABLE-BRANCH-1-4/keyserver/ksutil.h 2006-09-28 19:30:03 UTC (rev 4273) +++ branches/STABLE-BRANCH-1-4/keyserver/ksutil.h 2006-09-28 19:36:55 UTC (rev 4274) @@ -138,6 +138,4 @@ size_t curl_writer(const void *ptr,size_t size,size_t nmemb,void *cw_ctx); void curl_writer_finalize(struct curl_writer_ctx *ctx); -int ks_hextobyte (const char *s); - #endif /* !_KSUTIL_H_ */ Modified: branches/STABLE-BRANCH-1-4/util/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/util/ChangeLog 2006-09-28 19:30:03 UTC (rev 4273) +++ branches/STABLE-BRANCH-1-4/util/ChangeLog 2006-09-28 19:36:55 UTC (rev 4274) @@ -1,3 +1,11 @@ +2006-09-28 David Shaw + + * Makefile.am: Build libcompat.a for keyserver helpers. libutil.a + always contains everything in libcompat.a, so we only need to link + to one or the other. + + * miscutil.c: Move hextobyte to new file compat.c. + 2006-07-31 Werner Koch * iobuf.c (iobuf_ioctl, fd_cache_invalidate): Allow closing all Modified: branches/STABLE-BRANCH-1-4/util/Makefile.am =================================================================== --- branches/STABLE-BRANCH-1-4/util/Makefile.am 2006-09-28 19:30:03 UTC (rev 4273) +++ branches/STABLE-BRANCH-1-4/util/Makefile.am 2006-09-28 19:36:55 UTC (rev 4274) @@ -20,11 +20,12 @@ INCLUDES = -I.. -I$(top_srcdir)/include -I$(top_srcdir)/intl -noinst_LIBRARIES = libutil.a +noinst_LIBRARIES = libutil.a libcompat.a libutil_a_SOURCES = logger.c fileutil.c miscutil.c strgutil.c \ ttyio.c argparse.c memory.c secmem.c errors.c iobuf.c \ - dotlock.c http.c pka.c membuf.c cert.c + dotlock.c http.c pka.c membuf.c cert.c \ + $(libcompat_a_SOURCES) if USE_SIMPLE_GETTEXT libutil_a_SOURCES+=simple-gettext.c @@ -52,10 +53,18 @@ EXTRA_libutil_a_SOURCES = regcomp.c regexec.c regex_internal.c \ regex_internal.h -# LIBOBJS is for the replacement functions +# LIBOBJS and libcompat.a are for the replacement functions and +# similar simple stuff. They're segregated in libcompat so we can +# link it to the keyserver helpers which have different licensing. +# libutil.a, by definition, includes everything that libcompat.a does. + libutil_a_DEPENDENCIES = @LIBOBJS@ libutil_a_LIBADD = @LIBOBJS@ +libcompat_a_SOURCES=compat.c +libcompat_a_DEPENDENCIES = @LIBOBJS@ +libcompat_a_LIBADD = @LIBOBJS@ + http-test: http.c cc -DHAVE_CONFIG_H -I. -I. -I.. $(INCLUDES) $(LDFLAGS) -g -Wall \ -DTEST -o http-test http.c libutil.a @LIBINTL@ @DNSLIBS@ @CAPLIBS@ Added: branches/STABLE-BRANCH-1-4/util/compat.c =================================================================== --- branches/STABLE-BRANCH-1-4/util/compat.c 2006-09-28 19:30:03 UTC (rev 4273) +++ branches/STABLE-BRANCH-1-4/util/compat.c 2006-09-28 19:36:55 UTC (rev 4274) @@ -0,0 +1,24 @@ +int +hextobyte (const char *s) +{ + int c; + + if ( *s >= '0' && *s <= '9' ) + c = 16 * (*s - '0'); + else if ( *s >= 'A' && *s <= 'F' ) + c = 16 * (10 + *s - 'A'); + else if ( *s >= 'a' && *s <= 'f' ) + c = 16 * (10 + *s - 'a'); + else + return -1; + s++; + if ( *s >= '0' && *s <= '9' ) + c += *s - '0'; + else if ( *s >= 'A' && *s <= 'F' ) + c += 10 + *s - 'A'; + else if ( *s >= 'a' && *s <= 'f' ) + c += 10 + *s - 'a'; + else + return -1; + return c; +} Modified: branches/STABLE-BRANCH-1-4/util/miscutil.c =================================================================== --- branches/STABLE-BRANCH-1-4/util/miscutil.c 2006-09-28 19:30:03 UTC (rev 4273) +++ branches/STABLE-BRANCH-1-4/util/miscutil.c 2006-09-28 19:36:55 UTC (rev 4274) @@ -453,28 +453,3 @@ return 0; } - -int -hextobyte( const char *s ) -{ - int c; - - if( *s >= '0' && *s <= '9' ) - c = 16 * (*s - '0'); - else if( *s >= 'A' && *s <= 'F' ) - c = 16 * (10 + *s - 'A'); - else if( *s >= 'a' && *s <= 'f' ) - c = 16 * (10 + *s - 'a'); - else - return -1; - s++; - if( *s >= '0' && *s <= '9' ) - c += *s - '0'; - else if( *s >= 'A' && *s <= 'F' ) - c += 10 + *s - 'A'; - else if( *s >= 'a' && *s <= 'f' ) - c += 10 + *s - 'a'; - else - return -1; - return c; -} From cvs at cvs.gnupg.org Thu Sep 28 21:53:20 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Thu Sep 28 21:06:57 2006 Subject: [svn] GnuPG - r4275 - in branches/STABLE-BRANCH-1-4: . include keyserver util Message-ID: Author: dshaw Date: 2006-09-28 21:53:17 +0200 (Thu, 28 Sep 2006) New Revision: 4275 Added: branches/STABLE-BRANCH-1-4/util/strsep.c Modified: branches/STABLE-BRANCH-1-4/ChangeLog branches/STABLE-BRANCH-1-4/configure.ac branches/STABLE-BRANCH-1-4/include/ChangeLog branches/STABLE-BRANCH-1-4/include/compat.h branches/STABLE-BRANCH-1-4/include/util.h branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_ldap.c branches/STABLE-BRANCH-1-4/util/ChangeLog branches/STABLE-BRANCH-1-4/util/strgutil.c Log: Move strsep() and ascii_isspace() to libcompat. Modified: branches/STABLE-BRANCH-1-4/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/ChangeLog 2006-09-28 19:36:55 UTC (rev 4274) +++ branches/STABLE-BRANCH-1-4/ChangeLog 2006-09-28 19:53:17 UTC (rev 4275) @@ -1,3 +1,8 @@ +2006-09-28 David Shaw + + * configure.ac: Move strsep to AC_REPLACE_FUNCS so it will end up + in libcompat. + 2006-08-01 Werner Koch Released 1.4.5. Modified: branches/STABLE-BRANCH-1-4/configure.ac =================================================================== --- branches/STABLE-BRANCH-1-4/configure.ac 2006-09-28 19:36:55 UTC (rev 4274) +++ branches/STABLE-BRANCH-1-4/configure.ac 2006-09-28 19:53:17 UTC (rev 4275) @@ -891,13 +891,13 @@ AC_FUNC_FSEEKO AC_FUNC_VPRINTF AC_FUNC_FORK -AC_CHECK_FUNCS(strerror stpcpy strsep strlwr tcgetattr strtoul mmap) +AC_CHECK_FUNCS(strerror stpcpy strlwr tcgetattr strtoul mmap) AC_CHECK_FUNCS(strcasecmp strncasecmp ctermid times unsetenv getpwnam getpwuid) AC_CHECK_FUNCS(memmove gettimeofday getrusage setrlimit clock_gettime) AC_CHECK_FUNCS(atexit raise getpagesize strftime nl_langinfo setlocale) AC_CHECK_FUNCS(waitpid wait4 sigaction sigprocmask rand pipe stat getaddrinfo) AC_CHECK_FUNCS(fcntl ftruncate) -AC_REPLACE_FUNCS(mkdtemp timegm isascii memrchr) +AC_REPLACE_FUNCS(mkdtemp timegm isascii memrchr strsep) AC_CHECK_TYPES([struct sigaction, sigset_t],,,[#include ]) Modified: branches/STABLE-BRANCH-1-4/include/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/include/ChangeLog 2006-09-28 19:36:55 UTC (rev 4274) +++ branches/STABLE-BRANCH-1-4/include/ChangeLog 2006-09-28 19:53:17 UTC (rev 4275) @@ -1,5 +1,8 @@ 2006-09-28 David Shaw + * compat.h: Move strsep prototype and ascii_isspace macro to from + util.h. + * compat.h: New, used for libcompat.a functions. * util.h: Includes compat.h. Modified: branches/STABLE-BRANCH-1-4/include/compat.h =================================================================== --- branches/STABLE-BRANCH-1-4/include/compat.h 2006-09-28 19:36:55 UTC (rev 4274) +++ branches/STABLE-BRANCH-1-4/include/compat.h 2006-09-28 19:53:17 UTC (rev 4275) @@ -1,6 +1,14 @@ #ifndef _COMPAT_H_ #define _COMPAT_H_ +/* Note this isn't identical to a C locale isspace() without \f and + \v, but works for the purposes used here. */ +#define ascii_isspace(a) ((a)==' ' || (a)=='\n' || (a)=='\r' || (a)=='\t') + int hextobyte( const char *s ); +#ifndef HAVE_STRSEP +char *strsep (char **stringp, const char *delim); +#endif + #endif /* !_COMPAT_H_ */ Modified: branches/STABLE-BRANCH-1-4/include/util.h =================================================================== --- branches/STABLE-BRANCH-1-4/include/util.h 2006-09-28 19:36:55 UTC (rev 4274) +++ branches/STABLE-BRANCH-1-4/include/util.h 2006-09-28 19:53:17 UTC (rev 4275) @@ -206,9 +206,6 @@ #ifndef HAVE_STRLWR char *strlwr(char *a); #endif -#ifndef HAVE_STRSEP -char *strsep (char **stringp, const char *delim); -#endif #ifndef HAVE_STRCASECMP int strcasecmp( const char *, const char *b); #endif @@ -297,10 +294,6 @@ *(p) <= 'F'? (*(p)-'A'+10):(*(p)-'a'+10)) #define xtoi_2(p) ((xtoi_1(p) * 16) + xtoi_1((p)+1)) -/* Note this isn't identical to a C locale isspace() without \f and - \v, but works for the purposes used here. */ -#define ascii_isspace(a) ((a)==' ' || (a)=='\n' || (a)=='\r' || (a)=='\t') - /******* RISC OS stuff ***********/ #ifdef __riscos__ int riscos_load_module(const char *name, const char * const path[], int fatal); Modified: branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_ldap.c =================================================================== --- branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_ldap.c 2006-09-28 19:36:55 UTC (rev 4274) +++ branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_ldap.c 2006-09-28 19:53:17 UTC (rev 4275) @@ -54,7 +54,7 @@ #include #endif -#include "util.h" +#include "compat.h" #include "keyserver.h" #include "ksutil.h" Modified: branches/STABLE-BRANCH-1-4/util/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/util/ChangeLog 2006-09-28 19:36:55 UTC (rev 4274) +++ branches/STABLE-BRANCH-1-4/util/ChangeLog 2006-09-28 19:53:17 UTC (rev 4275) @@ -1,5 +1,7 @@ 2006-09-28 David Shaw + * strgutil.c (strsep): Move to strsep.c for AC_REPLACE_FUNCS. + * Makefile.am: Build libcompat.a for keyserver helpers. libutil.a always contains everything in libcompat.a, so we only need to link to one or the other. Modified: branches/STABLE-BRANCH-1-4/util/strgutil.c =================================================================== --- branches/STABLE-BRANCH-1-4/util/strgutil.c 2006-09-28 19:36:55 UTC (rev 4274) +++ branches/STABLE-BRANCH-1-4/util/strgutil.c 2006-09-28 19:53:17 UTC (rev 4275) @@ -1158,56 +1158,6 @@ } #endif - -#ifndef HAVE_STRSEP -/* code taken from glibc-2.2.1/sysdeps/generic/strsep.c */ -char * -strsep (char **stringp, const char *delim) -{ - char *begin, *end; - - begin = *stringp; - if (begin == NULL) - return NULL; - - /* A frequent case is when the delimiter string contains only one - character. Here we don't need to call the expensive `strpbrk' - function and instead work using `strchr'. */ - if (delim[0] == '\0' || delim[1] == '\0') - { - char ch = delim[0]; - - if (ch == '\0') - end = NULL; - else - { - if (*begin == ch) - end = begin; - else if (*begin == '\0') - end = NULL; - else - end = strchr (begin + 1, ch); - } - } - else - /* Find the end of the token. */ - end = strpbrk (begin, delim); - - if (end) - { - /* Terminate the token and set *STRINGP past NUL character. */ - *end++ = '\0'; - *stringp = end; - } - else - /* No more delimiters; this is the last token. */ - *stringp = NULL; - - return begin; -} -#endif /*HAVE_STRSEP*/ - - #ifndef HAVE_STRLWR char * strlwr(char *s) Added: branches/STABLE-BRANCH-1-4/util/strsep.c =================================================================== --- branches/STABLE-BRANCH-1-4/util/strsep.c 2006-09-28 19:36:55 UTC (rev 4274) +++ branches/STABLE-BRANCH-1-4/util/strsep.c 2006-09-28 19:53:17 UTC (rev 4275) @@ -0,0 +1,48 @@ +#include +#include + +/* code taken from glibc-2.2.1/sysdeps/generic/strsep.c */ +char * +strsep2 (char **stringp, const char *delim) +{ + char *begin, *end; + + begin = *stringp; + if (begin == NULL) + return NULL; + + /* A frequent case is when the delimiter string contains only one + character. Here we don't need to call the expensive `strpbrk' + function and instead work using `strchr'. */ + if (delim[0] == '\0' || delim[1] == '\0') + { + char ch = delim[0]; + + if (ch == '\0') + end = NULL; + else + { + if (*begin == ch) + end = begin; + else if (*begin == '\0') + end = NULL; + else + end = strchr (begin + 1, ch); + } + } + else + /* Find the end of the token. */ + end = strpbrk (begin, delim); + + if (end) + { + /* Terminate the token and set *STRINGP past NUL character. */ + *end++ = '\0'; + *stringp = end; + } + else + /* No more delimiters; this is the last token. */ + *stringp = NULL; + + return begin; +} From cvs at cvs.gnupg.org Thu Sep 28 22:12:33 2006 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Thu Sep 28 21:26:10 2006 Subject: [svn] GnuPG - r4276 - branches/STABLE-BRANCH-1-4/include Message-ID: Author: dshaw Date: 2006-09-28 22:12:32 +0200 (Thu, 28 Sep 2006) New Revision: 4276 Modified: branches/STABLE-BRANCH-1-4/include/distfiles Log: Add compat.h to distfiles Modified: branches/STABLE-BRANCH-1-4/include/distfiles =================================================================== --- branches/STABLE-BRANCH-1-4/include/distfiles 2006-09-28 19:53:17 UTC (rev 4275) +++ branches/STABLE-BRANCH-1-4/include/distfiles 2006-09-28 20:12:32 UTC (rev 4276) @@ -13,5 +13,6 @@ _regex.h dynload.h assuan.h +compat.h ChangeLog