From cvs at cvs.gnupg.org Thu Apr 1 15:24:56 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 01 Apr 2010 15:24:56 +0200 Subject: [svn] GnuPG - r5303 - trunk/g10 Message-ID: Author: wk Date: 2010-04-01 15:24:55 +0200 (Thu, 01 Apr 2010) New Revision: 5303 Modified: trunk/g10/ChangeLog trunk/g10/dearmor.c trunk/g10/decrypt.c trunk/g10/encrypt.c trunk/g10/exec.c trunk/g10/gpg.c trunk/g10/import.c trunk/g10/keydb.c trunk/g10/keyedit.c trunk/g10/keygen.c trunk/g10/keyring.c trunk/g10/openfile.c trunk/g10/photoid.c trunk/g10/plaintext.c trunk/g10/sign.c trunk/g10/tdbdump.c trunk/g10/tdbio.c trunk/g10/verify.c Log: Use gpg_err_set_errno to assign values to ERRNO. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2010-03-29 12:57:11 UTC (rev 5302) +++ trunk/g10/ChangeLog 2010-04-01 13:24:55 UTC (rev 5303) @@ -1,3 +1,7 @@ +2010-04-01 Werner Koch + + Use gpg_err_set_errno to set ERRNO. + 2010-03-26 Werner Koch * signal.c (pause_on_sigusr): Remove. It was used in ancient gpg Modified: trunk/g10/dearmor.c =================================================================== --- trunk/g10/dearmor.c 2010-03-29 12:57:11 UTC (rev 5302) +++ trunk/g10/dearmor.c 2010-04-01 13:24:55 UTC (rev 5303) @@ -53,7 +53,7 @@ { iobuf_close (inp); inp = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } if (!inp) { rc = gpg_error_from_syserror (); @@ -100,7 +100,7 @@ { iobuf_close (inp); inp = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } if (!inp) { rc = gpg_error_from_syserror (); Modified: trunk/g10/decrypt.c =================================================================== --- trunk/g10/decrypt.c 2010-03-29 12:57:11 UTC (rev 5302) +++ trunk/g10/decrypt.c 2010-04-01 13:24:55 UTC (rev 5303) @@ -59,7 +59,7 @@ { iobuf_close (fp); fp = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } if ( !fp ) { @@ -118,7 +118,7 @@ { iobuf_close (fp); fp = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } if (!fp) { @@ -228,7 +228,7 @@ { iobuf_close (fp); fp = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } if (!fp) { Modified: trunk/g10/encrypt.c =================================================================== --- trunk/g10/encrypt.c 2010-03-29 12:57:11 UTC (rev 5302) +++ trunk/g10/encrypt.c 2010-04-01 13:24:55 UTC (rev 5303) @@ -190,7 +190,7 @@ { iobuf_close (inp); inp = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } if (!inp) { @@ -531,7 +531,7 @@ { iobuf_close (inp); inp = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } if (!inp) { Modified: trunk/g10/exec.c =================================================================== --- trunk/g10/exec.c 2010-03-29 12:57:11 UTC (rev 5302) +++ trunk/g10/exec.c 2010-04-01 13:24:55 UTC (rev 5303) @@ -463,7 +463,7 @@ if( is_secured_filename ((*info)->tempfile_in) ) { (*info)->tochild = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } else (*info)->tochild=fopen((*info)->tempfile_in,binary?"wb":"w"); @@ -545,7 +545,7 @@ { iobuf_close (info->fromchild); info->fromchild = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } if(info->fromchild==NULL) { Modified: trunk/g10/gpg.c =================================================================== --- trunk/g10/gpg.c 2010-03-29 12:57:11 UTC (rev 5302) +++ trunk/g10/gpg.c 2010-04-01 13:24:55 UTC (rev 5303) @@ -1107,7 +1107,7 @@ /* if (is_secured_filename (fname)) */ /* { */ /* fd = -1; */ -/* errno = EPERM; */ +/* gpg_err_set_errno (EPERM); */ /* } */ /* else */ /* { */ @@ -2108,7 +2108,7 @@ { fclose (configfp); configfp = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } if( !configfp ) { if( default_config ) { @@ -4037,7 +4037,7 @@ { iobuf_close (a); a = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } if( !a ) log_error(_("can't open `%s'\n"), print_fname_stdin(fname)); @@ -4224,7 +4224,7 @@ { fclose (fp); fp = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } } if( !fp ) { Modified: trunk/g10/import.c =================================================================== --- trunk/g10/import.c 2010-03-29 12:57:11 UTC (rev 5302) +++ trunk/g10/import.c 2010-04-01 13:24:55 UTC (rev 5303) @@ -187,7 +187,7 @@ { iobuf_close (inp2); inp2 = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } if( !inp2 ) log_error(_("can't open `%s': %s\n"), fname, strerror(errno) ); Modified: trunk/g10/keydb.c =================================================================== --- trunk/g10/keydb.c 2010-03-29 12:57:11 UTC (rev 5302) +++ trunk/g10/keydb.c 2010-04-01 13:24:55 UTC (rev 5303) @@ -170,7 +170,7 @@ if (is_secured_filename (filename)) { iobuf = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } else iobuf = iobuf_create (filename); Modified: trunk/g10/keyedit.c =================================================================== --- trunk/g10/keyedit.c 2010-03-29 12:57:11 UTC (rev 5302) +++ trunk/g10/keyedit.c 2010-04-01 13:24:55 UTC (rev 5303) @@ -1971,7 +1971,7 @@ { iobuf_close (a); a = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } if (!a) { Modified: trunk/g10/keygen.c =================================================================== --- trunk/g10/keygen.c 2010-03-29 12:57:11 UTC (rev 5302) +++ trunk/g10/keygen.c 2010-04-01 13:24:55 UTC (rev 5303) @@ -2871,7 +2871,7 @@ { iobuf_close (fp); fp = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } if (!fp) { log_error (_("can't open `%s': %s\n"), fname, strerror(errno) ); @@ -3388,7 +3388,7 @@ if (is_secured_filename (outctrl->pub.fname) ) { outctrl->pub.stream = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } else outctrl->pub.stream = iobuf_create( outctrl->pub.fname ); @@ -3421,7 +3421,7 @@ if (is_secured_filename (outctrl->sec.fname) ) { outctrl->sec.stream = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } else outctrl->sec.stream = iobuf_create( outctrl->sec.fname ); @@ -4158,7 +4158,7 @@ if (is_secured_filename (fname)) { fp = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } else fp = iobuf_create (fname); Modified: trunk/g10/keyring.c =================================================================== --- trunk/g10/keyring.c 2010-03-29 12:57:11 UTC (rev 5302) +++ trunk/g10/keyring.c 2010-04-01 13:24:55 UTC (rev 5303) @@ -1226,7 +1226,7 @@ if (is_secured_filename (tmpfname)) { *r_fp = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } else *r_fp = iobuf_create (tmpfname); @@ -1558,7 +1558,7 @@ oldmask=umask(077); if (!secret && is_secured_filename (fname)) { newfp = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } else newfp = iobuf_create (fname); Modified: trunk/g10/openfile.c =================================================================== --- trunk/g10/openfile.c 2010-03-29 12:57:11 UTC (rev 5302) +++ trunk/g10/openfile.c 2010-04-01 13:24:55 UTC (rev 5303) @@ -284,7 +284,7 @@ if (is_secured_filename (name) ) { *a = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } else *a = iobuf_create (name); @@ -329,7 +329,7 @@ { iobuf_close (a); a = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } if( a && opt.verbose ) log_info(_("assuming signed data in `%s'\n"), buf ); @@ -366,7 +366,7 @@ { fclose (src); src = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } if( !src ) { log_info (_("can't open `%s': %s\n"), fname, strerror(errno) ); @@ -378,7 +378,7 @@ if ( is_secured_filename (fname) ) { dst = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } else dst = fopen( fname, "w" ); Modified: trunk/g10/photoid.c =================================================================== --- trunk/g10/photoid.c 2010-03-29 12:57:11 UTC (rev 5302) +++ trunk/g10/photoid.c 2010-04-01 13:24:55 UTC (rev 5303) @@ -110,7 +110,7 @@ { iobuf_close (file); file = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } if(!file) { Modified: trunk/g10/plaintext.c =================================================================== --- trunk/g10/plaintext.c 2010-03-29 12:57:11 UTC (rev 5302) +++ trunk/g10/plaintext.c 2010-04-01 13:24:55 UTC (rev 5303) @@ -158,7 +158,7 @@ ; else if (is_secured_filename (fname)) { - errno = EPERM; + gpg_err_set_errno (EPERM); rc = gpg_error_from_syserror (); log_error (_("error creating `%s': %s\n"), fname, strerror (errno)); goto leave; @@ -548,7 +548,7 @@ { iobuf_close (fp); fp = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } if (!fp && errno == ENOENT) { @@ -622,7 +622,7 @@ { iobuf_close (fp); fp = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } if (!fp) { @@ -654,7 +654,7 @@ if (is_secured_file (data_fd)) { fp = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } else fp = iobuf_fdopen_nc (data_fd, "rb"); Modified: trunk/g10/sign.c =================================================================== --- trunk/g10/sign.c 2010-03-29 12:57:11 UTC (rev 5302) +++ trunk/g10/sign.c 2010-04-01 13:24:55 UTC (rev 5303) @@ -783,7 +783,7 @@ { iobuf_close (inp); inp = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } if( !inp ) { @@ -799,7 +799,7 @@ if( outfile ) { if (is_secured_filename ( outfile )) { out = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } else out = iobuf_create( outfile ); @@ -978,7 +978,7 @@ { iobuf_close (inp); inp = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } if( !inp ) { @@ -1095,7 +1095,7 @@ { iobuf_close (inp); inp = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } if( !inp ) { rc = gpg_error_from_syserror (); @@ -1108,7 +1108,7 @@ if( outfile ) { if (is_secured_filename (outfile) ) { outfile = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } else out = iobuf_create( outfile ); @@ -1250,7 +1250,7 @@ { iobuf_close (inp); inp = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } if( !inp ) { rc = gpg_error_from_syserror (); Modified: trunk/g10/tdbdump.c =================================================================== --- trunk/g10/tdbdump.c 2010-03-29 12:57:11 UTC (rev 5302) +++ trunk/g10/tdbdump.c 2010-04-01 13:24:55 UTC (rev 5303) @@ -146,7 +146,7 @@ if (is_secured_file (fileno (fp))) { fclose (fp); - errno = EPERM; + gpg_err_set_errno (EPERM); log_error (_("can't open `%s': %s\n"), fname, strerror(errno) ); return; } Modified: trunk/g10/tdbio.c =================================================================== --- trunk/g10/tdbio.c 2010-03-29 12:57:11 UTC (rev 5302) +++ trunk/g10/tdbio.c 2010-04-01 13:24:55 UTC (rev 5303) @@ -539,7 +539,7 @@ oldmask=umask(077); if (is_secured_filename (fname)) { fp = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } else fp =fopen( fname, "wb" ); Modified: trunk/g10/verify.c =================================================================== --- trunk/g10/verify.c 2010-03-29 12:57:11 UTC (rev 5302) +++ trunk/g10/verify.c 2010-04-01 13:24:55 UTC (rev 5303) @@ -91,7 +91,7 @@ { iobuf_close (fp); fp = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } if( !fp ) { rc = gpg_error_from_syserror (); @@ -154,7 +154,7 @@ { iobuf_close (fp); fp = NULL; - errno = EPERM; + gpg_err_set_errno (EPERM); } if( !fp ) { rc = gpg_error_from_syserror (); From cvs at cvs.gnupg.org Tue Apr 6 12:37:14 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 06 Apr 2010 12:37:14 +0200 Subject: [svn] gcry - r1426 - in trunk: doc tests Message-ID: Author: wk Date: 2010-04-06 12:37:13 +0200 (Tue, 06 Apr 2010) New Revision: 1426 Modified: trunk/doc/gcrypt.texi trunk/tests/ChangeLog trunk/tests/aeswrap.c trunk/tests/basic.c trunk/tests/hmac.c Log: Typo fixes Modified: trunk/tests/ChangeLog =================================================================== --- trunk/tests/ChangeLog 2010-03-26 14:06:43 UTC (rev 1425) +++ trunk/tests/ChangeLog 2010-04-06 10:37:13 UTC (rev 1426) @@ -1,3 +1,7 @@ +2010-04-06 Brad Hards (wk) + + * aeswrap.c, hmac.c, basic.c: Typo fixes. + 2010-03-26 Werner Koch * basic.c (check_digests): Add tests for TIGER1 and TIGER2 from Modified: trunk/doc/gcrypt.texi =================================================================== --- trunk/doc/gcrypt.texi 2010-03-26 14:06:43 UTC (rev 1425) +++ trunk/doc/gcrypt.texi 2010-04-06 10:37:13 UTC (rev 1426) @@ -748,7 +748,7 @@ do this basic intialization is by calling gcry_check_version. @item GCRYCTL_INITIALIZATION_FINISHED; Arguments: none -This command tells the libray that the application has finished the +This command tells the library that the application has finished the intialization. @item GCRYCTL_INITIALIZATION_FINISHED_P; Arguments: none @@ -5464,7 +5464,7 @@ context is saved in the context and another block is generated to be returned to the caller. Each block is compared against the saved block and then stored in the context. If a duplicated block is -detected an error is signaled and the libray is put into the +detected an error is signaled and the library is put into the ``Fatal-Error'' state. (@code{random/@/random-fips.c:@/x931_aes_driver}) Modified: trunk/tests/aeswrap.c =================================================================== --- trunk/tests/aeswrap.c 2010-03-26 14:06:43 UTC (rev 1425) +++ trunk/tests/aeswrap.c 2010-04-06 10:37:13 UTC (rev 1426) @@ -69,14 +69,14 @@ err = gcry_cipher_open (&hd, algo, GCRY_CIPHER_MODE_AESWRAP, 0); if (err) { - fail ("gcrypt_cipher_open failed: %s\n", gpg_strerror (err)); + fail ("gcry_cipher_open failed: %s\n", gpg_strerror (err)); return; } err = gcry_cipher_setkey (hd, kek, keklen); if (err) { - fail ("grcy_cipher_setkey failed: %s\n", gpg_strerror (err)); + fail ("gcry_cipher_setkey failed: %s\n", gpg_strerror (err)); return; } @@ -87,7 +87,7 @@ err = gcry_cipher_encrypt (hd, outbuf, outbuflen, data, datalen); if (err) { - fail ("grcy_cipher_encrypt failed: %s\n", gpg_strerror (err)); + fail ("gcry_cipher_encrypt failed: %s\n", gpg_strerror (err)); return; } @@ -114,7 +114,7 @@ err = gcry_cipher_decrypt (hd, outbuf, outbuflen, expected, expectedlen); if (err) { - fail ("grcy_cipher_decrypt failed: %s\n", gpg_strerror (err)); + fail ("gcry_cipher_decrypt failed: %s\n", gpg_strerror (err)); return; } @@ -143,7 +143,7 @@ err = gcry_cipher_decrypt (hd, outbuf, outbuflen, expected, expectedlen); if (err) { - fail ("grcy_cipher_decrypt(2) failed: %s\n", gpg_strerror (err)); + fail ("gcry_cipher_decrypt(2) failed: %s\n", gpg_strerror (err)); return; } @@ -158,7 +158,7 @@ err = gcry_cipher_decrypt (hd, outbuf, outbuflen, expected, expectedlen); if (err) { - fail ("grcy_cipher_decrypt(3) failed: %s\n", gpg_strerror (err)); + fail ("gcry_cipher_decrypt(3) failed: %s\n", gpg_strerror (err)); return; } Modified: trunk/tests/basic.c =================================================================== --- trunk/tests/basic.c 2010-03-26 14:06:43 UTC (rev 1425) +++ trunk/tests/basic.c 2010-04-06 10:37:13 UTC (rev 1426) @@ -141,7 +141,7 @@ GCRY_CIPHER_MODE_CBC, GCRY_CIPHER_CBC_MAC); if (!hd) { - fail ("cbc-mac algo %d, grcy_open_cipher failed: %s\n", + fail ("cbc-mac algo %d, gcry_cipher_open failed: %s\n", tv[i].algo, gpg_strerror (err)); return; } @@ -264,7 +264,7 @@ GCRY_CIPHER_MODE_CBC, GCRY_CIPHER_CBC_CTS); if (err) { - fail ("aes-cbc-cts, grcy_open_cipher failed: %s\n", gpg_strerror (err)); + fail ("aes-cbc-cts, gcry_cipher_open failed: %s\n", gpg_strerror (err)); return; } @@ -417,7 +417,7 @@ err = gcry_cipher_open (&hdd, tv[i].algo, GCRY_CIPHER_MODE_CTR, 0); if (err) { - fail ("aes-ctr, grcy_open_cipher failed: %s\n", gpg_strerror (err)); + fail ("aes-ctr, gcry_cipher_open failed: %s\n", gpg_strerror (err)); return; } @@ -661,7 +661,7 @@ err = gcry_cipher_open (&hdd, tv[i].algo, GCRY_CIPHER_MODE_CFB, 0); if (err) { - fail ("aes-cfb, grcy_open_cipher failed: %s\n", gpg_strerror (err)); + fail ("aes-cfb, gcry_cipher_open failed: %s\n", gpg_strerror (err)); return; } @@ -823,7 +823,7 @@ err = gcry_cipher_open (&hdd, tv[i].algo, GCRY_CIPHER_MODE_OFB, 0); if (err) { - fail ("aes-ofb, grcy_open_cipher failed: %s\n", gpg_strerror (err)); + fail ("aes-ofb, gcry_cipher_open failed: %s\n", gpg_strerror (err)); return; } @@ -994,7 +994,7 @@ err = gcry_cipher_open (&hd, algo, mode, flags); if (err) { - fail ("algo %d, mode %d, grcy_open_cipher failed: %s\n", + fail ("algo %d, mode %d, gcry_cipher_open failed: %s\n", algo, mode, gpg_strerror (err)); return; } @@ -1174,14 +1174,14 @@ err = gcry_md_open (&hd, algo, 0); if (err) { - fail ("algo %d, grcy_md_open failed: %s\n", algo, gpg_strerror (err)); + fail ("algo %d, gcry_md_open failed: %s\n", algo, gpg_strerror (err)); return; } mdlen = gcry_md_get_algo_dlen (algo); if (mdlen < 1 || mdlen > 500) { - fail ("algo %d, grcy_md_get_algo_dlen failed: %d\n", algo, mdlen); + fail ("algo %d, gcry_md_get_algo_dlen failed: %d\n", algo, mdlen); return; } @@ -1495,14 +1495,14 @@ err = gcry_md_open (&hd, algo, GCRY_MD_FLAG_HMAC); if (err) { - fail ("algo %d, grcy_md_open failed: %s\n", algo, gpg_strerror (err)); + fail ("algo %d, gcry_md_open failed: %s\n", algo, gpg_strerror (err)); return; } mdlen = gcry_md_get_algo_dlen (algo); if (mdlen < 1 || mdlen > 500) { - fail ("algo %d, grcy_md_get_algo_dlen failed: %d\n", algo, mdlen); + fail ("algo %d, gcry_md_get_algo_dlen failed: %d\n", algo, mdlen); return; } Modified: trunk/tests/hmac.c =================================================================== --- trunk/tests/hmac.c 2010-03-26 14:06:43 UTC (rev 1425) +++ trunk/tests/hmac.c 2010-04-06 10:37:13 UTC (rev 1426) @@ -70,21 +70,21 @@ err = gcry_md_open (&hd, algo, GCRY_MD_FLAG_HMAC); if (err) { - fail ("algo %d, grcy_md_open failed: %s\n", algo, gpg_strerror (err)); + fail ("algo %d, gcry_md_open failed: %s\n", algo, gpg_strerror (err)); return; } mdlen = gcry_md_get_algo_dlen (algo); if (mdlen < 1 || mdlen > 500) { - fail ("algo %d, grcy_md_get_algo_dlen failed: %d\n", algo, mdlen); + fail ("algo %d, gcry_md_get_algo_dlen failed: %d\n", algo, mdlen); return; } err = gcry_md_setkey (hd, key, keylen); if (err) { - fail ("algo %d, grcy_md_setkey failed: %s\n", algo, gpg_strerror (err)); + fail ("algo %d, gcry_md_setkey failed: %s\n", algo, gpg_strerror (err)); return; } From cvs at cvs.gnupg.org Tue Apr 6 18:46:31 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 06 Apr 2010 18:46:31 +0200 Subject: [svn] assuan - r365 - trunk/src Message-ID: Author: wk Date: 2010-04-06 18:46:31 +0200 (Tue, 06 Apr 2010) New Revision: 365 Added: trunk/src/posix-fd-t.inc.h trunk/src/posix-includes.inc.h trunk/src/posix-sock-nonce.inc.h trunk/src/posix-sys-pth-impl.h trunk/src/posix-types.inc.h trunk/src/w32-fd-t.inc.h trunk/src/w32-includes.inc.h trunk/src/w32-sock-nonce.inc.h trunk/src/w32-sys-pth-impl.h trunk/src/w32-types.inc.h trunk/src/w32ce-fd-t.inc.h Modified: trunk/src/ChangeLog trunk/src/Makefile.am trunk/src/assuan.h.in trunk/src/mkheader.c Log: Removed sysdep stuff from assuan.h. fixed a problem for W32CE and Pth. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-03-30 18:54:03 UTC (rev 364) +++ trunk/src/ChangeLog 2010-04-06 16:46:31 UTC (rev 365) @@ -1,3 +1,20 @@ +2010-04-06 Werner Koch + + * posix-includes.inc.h, w32-includes.inc.h: New. + * posix-types.inc.h, w32-types.inc.h: New. + * posix-fd-t.inc.h, w32-fd-t.inc.h, w32ce-fd-t.inc.h: New. + * posix-sock-nonce.inc.h, w32-sock-nonce.inc.h: New. + * mkheader.c (write_special): Support them. + * Makefile.am (common_sources, assuan.h): Ditto + (parts_of_assuan_h): New. + + * w32-sys-pth-impl.h: Use gpg_err_set_errno. + + * assuan.h.in (_ASSUAN_SYSTEM_PTH_IMPL): Factor code out to .. + * posix-sys-pth-impl.h, w32-sys-pth-impl.h: New + * mkheader.c (write_special): Support them. + * Makefile.am (common_sources, assuan.h): Ditto + 2010-03-23 Werner Koch * assuan-error.c (_assuan_w32_strerror) [W32CE]: Print only the code. Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2010-03-30 18:54:03 UTC (rev 364) +++ trunk/src/Makefile.am 2010-04-06 16:46:31 UTC (rev 365) @@ -41,8 +41,16 @@ BUILT_SOURCES = assuan.h +parts_of_assuan_h = \ + posix-includes.inc.h w32-includes.inc.h \ + posix-types.inc.h w32-types.inc.h \ + posix-fd-t.inc.h w32-fd-t.inc.h w32ce-fd-t.inc.h \ + posix-sock-nonce.inc.h w32-sock-nonce.inc.h \ + posix-sys-pth-impl.h w32-sys-pth-impl.h \ + w32ce-add.h + common_sources = \ - assuan.h.in w32ce-add.h \ + assuan.h.in $(parts_of_assuan_h) \ assuan-defs.h \ assuan.c context.c system.c \ debug.c debug.h conversion.c sysutils.c \ @@ -130,6 +138,6 @@ mkheader: mkheader.c Makefile $(CC_FOR_BUILD) -I. -I$(srcdir) -o $@ $(srcdir)/mkheader.c -assuan.h: assuan.h.in mkheader w32ce-add.h +assuan.h: assuan.h.in mkheader $(parts_of_assuan_h) ./mkheader $(host_os) $(srcdir)/assuan.h.in >$@ Modified: trunk/src/assuan.h.in =================================================================== --- trunk/src/assuan.h.in 2010-03-30 18:54:03 UTC (rev 364) +++ trunk/src/assuan.h.in 2010-04-06 16:46:31 UTC (rev 365) @@ -29,18 +29,10 @@ #include #ifndef _ASSUAN_NO_SOCKET_WRAPPER -#ifdef _WIN32 -#include -#else -#include -#endif + at include:includes@ #endif /*!_ASSUAN_NO_SOCKET_WRAPPER*/ -#ifdef _WIN32 -typedef void *assuan_msghdr_t; -#else -typedef struct msghdr *assuan_msghdr_t; -#endif + at include:types@ #include @@ -79,71 +71,12 @@ struct assuan_context_s; typedef struct assuan_context_s *assuan_context_t; + at include:fd-t@ -/* Because we use system handles and not libc low level file - descriptors on W32, we need to declare them as HANDLE (which - actually is a plain pointer). This is required to eventually - support 64 bit Windows systems. */ -#ifdef _WIN32 -typedef void *assuan_fd_t; -#define ASSUAN_INVALID_FD ((void*)(-1)) -#define ASSUAN_INVALID_PID ((pid_t) -1) -static inline assuan_fd_t -assuan_fd_from_posix_fd (int fd) -{ -#ifdef __MINGW32CE__ - return (assuan_fd_t)(fd); -#else - if (fd < 0) - return ASSUAN_INVALID_FD; - else - return (assuan_fd_t) _get_osfhandle (fd); -#endif -} -#else -typedef int assuan_fd_t; -#define ASSUAN_INVALID_FD (-1) -#define ASSUAN_INVALID_PID ((pid_t) -1) -static inline assuan_fd_t -assuan_fd_from_posix_fd (int fd) -{ - return fd; -} -#endif - assuan_fd_t assuan_fdopen (int fd); + at include:sock-nonce@ -/* Assuan features an emulation of Unix domain sockets based on a - local TCP connections. To implement access permissions based on - file permissions a nonce is used which is expected by the server as - the first bytes received. This structure is used by the server to - save the nonce created initially by bind. On POSIX systems this is - a dummy operation. */ -struct assuan_sock_nonce_s -{ - size_t length; -#ifdef _WIN32 - char nonce[16]; -#endif -}; -typedef struct assuan_sock_nonce_s assuan_sock_nonce_t; - -/* Define the Unix domain socket structure for Windows. */ -#if defined(_WIN32) && !defined(_ASSUAN_NO_SOCKET_WRAPPER) -#ifndef AF_LOCAL -#define AF_LOCAL AF_UNIX -#endif -#define EADDRINUSE WSAEADDRINUSE -struct sockaddr_un -{ - short sun_family; - unsigned short sun_port; - struct in_addr sun_addr; - char sun_path[108-2-4]; -}; -#endif - /* Global interface. */ @@ -533,89 +466,7 @@ int __assuan_socketpair (assuan_context_t ctx, int _namespace, int style, int protocol, assuan_fd_t filedes[2]); -#ifdef _WIN32 -#define _ASSUAN_SYSTEM_PTH_IMPL \ - static int _assuan_pth_recvmsg (assuan_context_t ctx, assuan_fd_t fd, \ - assuan_msghdr_t msg, int flags) \ - { \ - (void) ctx; \ - errno = ENOSYS; \ - return -1; \ - } \ - static int _assuan_pth_sendmsg (assuan_context_t ctx, assuan_fd_t fd, \ - const assuan_msghdr_t msg, int flags) \ - { \ - (void) ctx; \ - errno = ENOSYS; \ - return -1; \ - } -#else -#define _ASSUAN_SYSTEM_PTH_IMPL \ - static int _assuan_pth_recvmsg (assuan_context_t ctx, assuan_fd_t fd, \ - assuan_msghdr_t msg, int flags) \ - { \ - /* Pth does not provide a recvmsg function. We implement it. */ \ - int ret; \ - int fdmode; \ - \ - (void) ctx; \ - fdmode = pth_fdmode (fd, PTH_FDMODE_POLL); \ - if (fdmode == PTH_FDMODE_ERROR) \ - { \ - errno = EBADF; \ - return -1; \ - } \ - if (fdmode == PTH_FDMODE_BLOCK) \ - { \ - fd_set fds; \ - \ - FD_ZERO (&fds); \ - FD_SET (fd, &fds); \ - while ((ret = pth_select (fd + 1, &fds, NULL, NULL, NULL)) < 0 \ - && errno == EINTR) \ - ; \ - if (ret < 0) \ - return -1; \ - } \ - \ - while ((ret = recvmsg (fd, msg, flags)) == -1 && errno == EINTR) \ - ; \ - return ret; \ - } \ - static int _assuan_pth_sendmsg (assuan_context_t ctx, assuan_fd_t fd, \ - const assuan_msghdr_t msg, int flags) \ - { \ - /* Pth does not provide a sendmsg function. We implement it. */ \ - int ret; \ - int fdmode; \ - \ - (void) ctx; \ - fdmode = pth_fdmode (fd, PTH_FDMODE_POLL); \ - if (fdmode == PTH_FDMODE_ERROR) \ - { \ - errno = EBADF; \ - return -1; \ - } \ - if (fdmode == PTH_FDMODE_BLOCK) \ - { \ - fd_set fds; \ - \ - FD_ZERO (&fds); \ - FD_SET (fd, &fds); \ - while ((ret = pth_select (fd + 1, NULL, &fds, NULL, NULL)) < 0 \ - && errno == EINTR) \ - ; \ - if (ret < 0) \ - return -1; \ - } \ - \ - while ((ret = sendmsg (fd, msg, flags)) == -1 && errno == EINTR) \ - ; \ - return ret; \ - } -#endif - #define ASSUAN_SYSTEM_PTH_IMPL \ static void _assuan_pth_usleep (assuan_context_t ctx, unsigned int usec) \ { (void) ctx; pth_usleep (usec); } \ @@ -625,7 +476,7 @@ static ssize_t _assuan_pth_write (assuan_context_t ctx, assuan_fd_t fd, \ const void *buffer, size_t size) \ { (void) ctx; return pth_write (fd, buffer, size); } \ - _ASSUAN_SYSTEM_PTH_IMPL \ + at include:sys-pth-impl@ static pid_t _assuan_pth_waitpid (assuan_context_t ctx, pid_t pid, \ int nowait, int *status, int options) \ { (void) ctx; \ Modified: trunk/src/mkheader.c =================================================================== --- trunk/src/mkheader.c 2010-03-30 18:54:03 UTC (rev 364) +++ trunk/src/mkheader.c 2010-04-06 16:46:31 UTC (rev 365) @@ -26,7 +26,7 @@ /* Include the file NAME form the source directory. The included file is not further expanded. It may have comments indicated by a - double hash masrk at the begin of a line. */ + double hash mark at the begin of a line. */ static void include_file (const char *fname, int lnr, const char *name) { @@ -54,7 +54,10 @@ while (fgets (line, LINESIZE, fp)) { if (line[0] == '#' && line[1] == '#') - ; + { + if (!strncmp (line+2, "EOF##", 5)) + break; /* Forced EOF. */ + } else fputs (line, stdout); } @@ -72,9 +75,46 @@ static int write_special (const char *fname, int lnr, const char *tag) { - if (!strcmp (tag, "include:w32ce-add")) + if (!strcmp (tag, "include:includes")) { + if (strstr (host_os, "mingw32")) + include_file (fname, lnr, "w32-includes.inc.h"); + else + include_file (fname, lnr, "posix-includes.inc.h"); + } + else if (!strcmp (tag, "include:types")) + { + if (strstr (host_os, "mingw32")) + include_file (fname, lnr, "w32-types.inc.h"); + else + include_file (fname, lnr, "posix-types.inc.h"); + } + else if (!strcmp (tag, "include:fd-t")) + { if (!strcmp (host_os, "mingw32ce")) + include_file (fname, lnr, "w32ce-fd-t.inc.h"); + else if (strstr (host_os, "mingw32")) + include_file (fname, lnr, "w32-fd-t.inc.h"); + else + include_file (fname, lnr, "posix-fd-t.inc.h"); + } + else if (!strcmp (tag, "include:sock-nonce")) + { + if (strstr (host_os, "mingw32")) + include_file (fname, lnr, "w32-sock-nonce.inc.h"); + else + include_file (fname, lnr, "posix-sock-nonce.inc.h"); + } + else if (!strcmp (tag, "include:sys-pth-impl")) + { + if (strstr (host_os, "mingw32")) + include_file (fname, lnr, "w32-sys-pth-impl.h"); + else + include_file (fname, lnr, "posix-sys-pth-impl.h"); + } + else if (!strcmp (tag, "include:w32ce-add")) + { + if (!strcmp (host_os, "mingw32ce")) include_file (fname, lnr, "w32ce-add.h"); } else @@ -157,16 +197,17 @@ s = strrchr (fname, '/'); printf ("Do not edit. Generated from %s by %s for %s.", s? s+1 : fname, PGM, host_os); + fputs (p2, stdout); + putchar ('\n'); } else if (!write_special (fname, lnr, p1)) { putchar ('@'); fputs (p1, stdout); putchar ('@'); + fputs (p2, stdout); + putchar ('\n'); } - - fputs (p2, stdout); - putchar ('\n'); } if (ferror (fp)) @@ -177,7 +218,7 @@ } fputs ("/*\n" - "Local Variables:\n" + "Loc" "al Variables:\n" "buffer-read-only: t\n" "End:\n" "*/\n", stdout); Added: trunk/src/posix-fd-t.inc.h =================================================================== --- trunk/src/posix-fd-t.inc.h (rev 0) +++ trunk/src/posix-fd-t.inc.h 2010-04-06 16:46:31 UTC (rev 365) @@ -0,0 +1,32 @@ +## posix-fd-t.inc.h - Include fragment to build assuan.h. +## Copyright (C) 2010 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, see . +## +## +## This file is included by the mkheader tool. Lines starting with +## a double hash mark are not copied to the destination file. + +typedef int assuan_fd_t; +#define ASSUAN_INVALID_FD (-1) +#define ASSUAN_INVALID_PID ((pid_t) -1) +static inline assuan_fd_t +assuan_fd_from_posix_fd (int fd) +{ + return fd; +} + +##EOF## Added: trunk/src/posix-includes.inc.h =================================================================== --- trunk/src/posix-includes.inc.h (rev 0) +++ trunk/src/posix-includes.inc.h 2010-04-06 16:46:31 UTC (rev 365) @@ -0,0 +1,23 @@ +## posix-includes.inc.h - Include fragment to build assuan.h. +## Copyright (C) 2010 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, see . +## +## +## This file is included by the mkheader tool. Lines starting with +## a double hash mark are not copied to the destination file. +#include +##EOF## Added: trunk/src/posix-sock-nonce.inc.h =================================================================== --- trunk/src/posix-sock-nonce.inc.h (rev 0) +++ trunk/src/posix-sock-nonce.inc.h 2010-04-06 16:46:31 UTC (rev 365) @@ -0,0 +1,32 @@ +## posix-sock-nonce.inc.h - Include fragment to build assuan.h. +## Copyright (C) 2010 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, see . +## +## +## This file is included by the mkheader tool. Lines starting with +## a double hash mark are not copied to the destination file. +/* Under Windows Assuan features an emulation of Unix domain sockets + based on a local TCP connections. To implement access permissions + based on file permissions a nonce is used which is expected by the + server as the first bytes received. On POSIX systems this is a + dummy structure. */ +struct assuan_sock_nonce_s +{ + size_t length; +}; +typedef struct assuan_sock_nonce_s assuan_sock_nonce_t; +##EOF## Added: trunk/src/posix-sys-pth-impl.h =================================================================== --- trunk/src/posix-sys-pth-impl.h (rev 0) +++ trunk/src/posix-sys-pth-impl.h 2010-04-06 16:46:31 UTC (rev 365) @@ -0,0 +1,88 @@ +## posix-sys-pth-impl.h - Include fragment to build assuan.h. +## Copyright (C) 2009, 2010 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, see . +## +## +## This file is included by the mkheader tool. Lines starting with +## a double hash mark are not copied to the destination file. +## +## Warning: This is a fragment of a macro - no empty lines please. + static int _assuan_pth_recvmsg (assuan_context_t ctx, assuan_fd_t fd, \ + assuan_msghdr_t msg, int flags) \ + { \ + /* Pth does not provide a recvmsg function. We implement it. */ \ + int ret; \ + int fdmode; \ + \ + (void) ctx; \ + fdmode = pth_fdmode (fd, PTH_FDMODE_POLL); \ + if (fdmode == PTH_FDMODE_ERROR) \ + { \ + errno = EBADF; \ + return -1; \ + } \ + if (fdmode == PTH_FDMODE_BLOCK) \ + { \ + fd_set fds; \ + \ + FD_ZERO (&fds); \ + FD_SET (fd, &fds); \ + while ((ret = pth_select (fd + 1, &fds, NULL, NULL, NULL)) < 0 \ + && errno == EINTR) \ + ; \ + if (ret < 0) \ + return -1; \ + } \ + \ + while ((ret = recvmsg (fd, msg, flags)) == -1 && errno == EINTR) \ + ; \ + return ret; \ + } \ + static int _assuan_pth_sendmsg (assuan_context_t ctx, assuan_fd_t fd, \ + const assuan_msghdr_t msg, int flags) \ + { \ + /* Pth does not provide a sendmsg function. We implement it. */ \ + int ret; \ + int fdmode; \ + \ + (void) ctx; \ + fdmode = pth_fdmode (fd, PTH_FDMODE_POLL); \ + if (fdmode == PTH_FDMODE_ERROR) \ + { \ + errno = EBADF; \ + return -1; \ + } \ + if (fdmode == PTH_FDMODE_BLOCK) \ + { \ + fd_set fds; \ + \ + FD_ZERO (&fds); \ + FD_SET (fd, &fds); \ + while ((ret = pth_select (fd + 1, NULL, &fds, NULL, NULL)) < 0 \ + && errno == EINTR) \ + ; \ + if (ret < 0) \ + return -1; \ + } \ + \ + while ((ret = sendmsg (fd, msg, flags)) == -1 && errno == EINTR) \ + ; \ + return ret; \ + } \ +##EOF## Force end-of file. + + Added: trunk/src/posix-types.inc.h =================================================================== --- trunk/src/posix-types.inc.h (rev 0) +++ trunk/src/posix-types.inc.h 2010-04-06 16:46:31 UTC (rev 365) @@ -0,0 +1,23 @@ +## posix-types.inc.h - Include fragment to build assuan.h. +## Copyright (C) 2010 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, see . +## +## +## This file is included by the mkheader tool. Lines starting with +## a double hash mark are not copied to the destination file. +typedef struct msghdr *assuan_msghdr_t; +##EOF## Added: trunk/src/w32-fd-t.inc.h =================================================================== --- trunk/src/w32-fd-t.inc.h (rev 0) +++ trunk/src/w32-fd-t.inc.h 2010-04-06 16:46:31 UTC (rev 365) @@ -0,0 +1,39 @@ +## w32-fd-t.inc.h - Include fragment to build assuan.h. +## Copyright (C) 2010 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, see . +## +## +## This file is included by the mkheader tool. Lines starting with +## a double hash mark are not copied to the destination file. + +/* Because we use system handles and not libc low level file + descriptors on W32, we need to declare them as HANDLE (which + actually is a plain pointer). This is required to eventually + support 64 bit Windows systems. */ +typedef void *assuan_fd_t; +#define ASSUAN_INVALID_FD ((void*)(-1)) +#define ASSUAN_INVALID_PID ((pid_t) -1) +static inline assuan_fd_t +assuan_fd_from_posix_fd (int fd) +{ + if (fd < 0) + return ASSUAN_INVALID_FD; + else + return (assuan_fd_t) _get_osfhandle (fd); +} + +##EOF## Added: trunk/src/w32-includes.inc.h =================================================================== --- trunk/src/w32-includes.inc.h (rev 0) +++ trunk/src/w32-includes.inc.h 2010-04-06 16:46:31 UTC (rev 365) @@ -0,0 +1,23 @@ +## w32-includes.inc.h - Include fragment to build assuan.h. +## Copyright (C) 2010 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, see . +## +## +## This file is included by the mkheader tool. Lines starting with +## a double hash mark are not copied to the destination file. +#include +##EOF## Added: trunk/src/w32-sock-nonce.inc.h =================================================================== --- trunk/src/w32-sock-nonce.inc.h (rev 0) +++ trunk/src/w32-sock-nonce.inc.h 2010-04-06 16:46:31 UTC (rev 365) @@ -0,0 +1,50 @@ +## w32-sock-nonce.inc.h - Include fragment to build assuan.h. +## Copyright (C) 2010 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, see . +## +## +## This file is included by the mkheader tool. Lines starting with +## a double hash mark are not copied to the destination file. + +/* Assuan features an emulation of Unix domain sockets based on local + TCP connections. To implement access permissions based on file + permissions a nonce is used which is expected by the server as the + first bytes received. This structure is used by the server to save + the nonce created initially by bind. */ +struct assuan_sock_nonce_s +{ + size_t length; + char nonce[16]; +}; +typedef struct assuan_sock_nonce_s assuan_sock_nonce_t; + +/* Define the Unix domain socket structure for Windows. */ +#ifndef _ASSUAN_NO_SOCKET_WRAPPER +# ifndef AF_LOCAL +# define AF_LOCAL AF_UNIX +# endif +# define EADDRINUSE WSAEADDRINUSE +struct sockaddr_un +{ + short sun_family; + unsigned short sun_port; + struct in_addr sun_addr; + char sun_path[108-2-4]; +}; +#endif + +##EOF## Added: trunk/src/w32-sys-pth-impl.h =================================================================== --- trunk/src/w32-sys-pth-impl.h (rev 0) +++ trunk/src/w32-sys-pth-impl.h 2010-04-06 16:46:31 UTC (rev 365) @@ -0,0 +1,39 @@ +## w32-sys-pth-impl.h - Include fragment to build assuan.h. +## Copyright (C) 2009, 2010 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, see . +## +## +## This file is included by the mkheader tool. Lines starting with +## a double hash mark are not copied to the destination file. +## +## Warning: This is a fragment of a macro - no empty lines please. + static int _assuan_pth_recvmsg (assuan_context_t ctx, assuan_fd_t fd, \ + assuan_msghdr_t msg, int flags) \ + { \ + (void) ctx; \ + gpg_err_set_errno (ENOSYS); \ + return -1; \ + } \ + static int _assuan_pth_sendmsg (assuan_context_t ctx, assuan_fd_t fd, \ + const assuan_msghdr_t msg, int flags) \ + { \ + (void) ctx; \ + gpg_err_set_errno (ENOSYS); \ + return -1; \ + } \ +##EOF## Force end-of file. + Added: trunk/src/w32-types.inc.h =================================================================== --- trunk/src/w32-types.inc.h (rev 0) +++ trunk/src/w32-types.inc.h 2010-04-06 16:46:31 UTC (rev 365) @@ -0,0 +1,23 @@ +## w32-types.inc.h - Include fragment to build assuan.h. +## Copyright (C) 2010 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, see . +## +## +## This file is included by the mkheader tool. Lines starting with +## a double hash mark are not copied to the destination file. +typedef void *assuan_msghdr_t; +##EOF## Added: trunk/src/w32ce-fd-t.inc.h =================================================================== --- trunk/src/w32ce-fd-t.inc.h (rev 0) +++ trunk/src/w32ce-fd-t.inc.h 2010-04-06 16:46:31 UTC (rev 365) @@ -0,0 +1,32 @@ +## w32ce-fd-t.inc.h - Include fragment to build assuan.h. +## Copyright (C) 2010 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, see . +## +## +## This file is included by the mkheader tool. Lines starting with +## a double hash mark are not copied to the destination file. + +typedef void *assuan_fd_t; +#define ASSUAN_INVALID_FD ((void*)(-1)) +#define ASSUAN_INVALID_PID ((pid_t) -1) +static inline assuan_fd_t +assuan_fd_from_posix_fd (int fd) +{ + return (assuan_fd_t)(fd); +} + +##EOF## From cvs at cvs.gnupg.org Mon Apr 12 23:00:15 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 12 Apr 2010 23:00:15 +0200 Subject: [svn] gcry - r1427 - in trunk: . cipher mpi random src tests Message-ID: Author: wk Date: 2010-04-12 23:00:13 +0200 (Mon, 12 Apr 2010) New Revision: 1427 Modified: trunk/ChangeLog trunk/cipher/ChangeLog trunk/cipher/ac.c trunk/cipher/cipher.c trunk/cipher/des.c trunk/cipher/ecc.c trunk/cipher/md.c trunk/cipher/primegen.c trunk/cipher/pubkey.c trunk/cipher/rfc2268.c trunk/cipher/rsa.c trunk/cipher/tiger.c trunk/cipher/twofish.c trunk/configure.ac trunk/mpi/ChangeLog trunk/mpi/longlong.h trunk/mpi/mpi-bit.c trunk/mpi/mpi-inline.c trunk/random/ChangeLog trunk/random/random-csprng.c trunk/random/random-fips.c trunk/random/random.c trunk/random/rndegd.c trunk/random/rndlinux.c trunk/random/rndunix.c trunk/random/rndw32.c trunk/src/ChangeLog trunk/src/fips.c trunk/src/g10lib.h trunk/src/gcryptrnd.c trunk/src/global.c trunk/src/hmac256.c trunk/src/module.c trunk/src/mpi.h trunk/src/secmem.c trunk/src/sexp.c trunk/tests/ChangeLog trunk/tests/ac-data.c trunk/tests/basic.c Log: Applied spelling fixes and more verbose test diagnositcs by Brad Hards. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-04-06 10:37:13 UTC (rev 1426) +++ trunk/ChangeLog 2010-04-12 21:00:13 UTC (rev 1427) @@ -1,3 +1,7 @@ +2010-04-12 Brad Hards (wk) + + * configure.ac: Print more verbose info at the end. + 2010-03-24 Werner Koch * configure.ac (USE_RNDW32CE): New. Modified: trunk/cipher/ChangeLog =================================================================== --- trunk/cipher/ChangeLog 2010-04-06 10:37:13 UTC (rev 1426) +++ trunk/cipher/ChangeLog 2010-04-12 21:00:13 UTC (rev 1427) @@ -1,3 +1,7 @@ +2010-04-12 Brad Hards (wk) + + Spelling fixes. + 2010-03-26 Werner Koch * tiger.c (asn): Unfetter the old TIGER from an OID. @@ -16,13 +20,13 @@ * sha512.c (ROTR, Ch, Maj, Sum0, Sum1): Turn macros into inline functions. - (transform): Partly Unroll to interweave the chain variables. + (transform): Partly unroll to interweave the chain variables. Suggested by Christian Grothoff. 2009-12-10 Werner Koch * Makefile.am (o_flag_munging): New. - (tiger.o, tiger.lo): Use it. + (tiger.o, tiger.lo): Use it. * cipher.c (do_ctr_encrypt): Add arg OUTBUFLEN. Check for suitable value. Add check for valid inputlen. Wipe temporary Modified: trunk/mpi/ChangeLog =================================================================== --- trunk/mpi/ChangeLog 2010-04-06 10:37:13 UTC (rev 1426) +++ trunk/mpi/ChangeLog 2010-04-12 21:00:13 UTC (rev 1427) @@ -1,3 +1,7 @@ +2010-04-12 Brad Hards (wk) + + Spelling fixes. + 2010-02-22 Aurelien Jarno (wk) * longlong.h (umul_ppmm) [__GNUC__ >= 4.4]: Patch according Modified: trunk/random/ChangeLog =================================================================== --- trunk/random/ChangeLog 2010-04-06 10:37:13 UTC (rev 1426) +++ trunk/random/ChangeLog 2010-04-12 21:00:13 UTC (rev 1427) @@ -1,3 +1,7 @@ +2010-04-12 Brad Hards (wk) + + Spelling fixes. + 2010-03-24 Werner Koch * rndw32.c: Revert all changes from 2010-01-21. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-04-06 10:37:13 UTC (rev 1426) +++ trunk/src/ChangeLog 2010-04-12 21:00:13 UTC (rev 1427) @@ -1,3 +1,7 @@ +2010-04-12 Brad Hards (wk) + + Spelling fixes. + 2010-03-15 Werner Koch * gcrypt.h.in: Add autoconf template to set generated file to Modified: trunk/tests/ChangeLog =================================================================== --- trunk/tests/ChangeLog 2010-04-06 10:37:13 UTC (rev 1426) +++ trunk/tests/ChangeLog 2010-04-12 21:00:13 UTC (rev 1427) @@ -1,3 +1,9 @@ +2010-04-12 Brad Hards (wk) + + * basic.c (check_cbc_mac_cipher): Print more info. + (main): Factor some code out to ... + (check_cipher_modes): .. new. + 2010-04-06 Brad Hards (wk) * aeswrap.c, hmac.c, basic.c: Typo fixes. Modified: trunk/cipher/ac.c =================================================================== --- trunk/cipher/ac.c 2010-04-06 10:37:13 UTC (rev 1426) +++ trunk/cipher/ac.c 2010-04-12 21:00:13 UTC (rev 1427) @@ -2499,7 +2499,7 @@ dencode_action_t; /* Encode or decode a message according to the the encoding method - METHOD; ACTION specifies wether the message that is contained in + METHOD; ACTION specifies whether the message that is contained in BUFFER_IN and of length BUFFER_IN_N should be encoded or decoded. The resulting message will be stored in a newly allocated buffer in BUFFER_OUT and BUFFER_OUT_N. */ Modified: trunk/cipher/cipher.c =================================================================== --- trunk/cipher/cipher.c 2010-04-06 10:37:13 UTC (rev 1426) +++ trunk/cipher/cipher.c 2010-04-12 21:00:13 UTC (rev 1427) @@ -118,7 +118,7 @@ /* This is the lock protecting CIPHERS_REGISTERED. */ static ath_mutex_t ciphers_registered_lock = ATH_MUTEX_INITIALIZER; -/* Flag to check wether the default ciphers have already been +/* Flag to check whether the default ciphers have already been registered. */ static int default_ciphers_registered; @@ -686,7 +686,7 @@ REGISTER_DEFAULT_CIPHERS; - /* Fetch the according module and check wether the cipher is marked + /* Fetch the according module and check whether the cipher is marked available for use. */ ath_mutex_lock (&ciphers_registered_lock); module = _gcry_module_lookup_id (ciphers_registered, algo); @@ -1972,7 +1972,7 @@ There are no values for CMD yet defined. - The fucntion always returns GPG_ERR_INV_OP. + The function always returns GPG_ERR_INV_OP. */ gcry_error_t @@ -2014,7 +2014,7 @@ Note: Because this function is in most cases used to return an integer value, we can make it easier for the caller to just look at the return value. The caller will in all cases consult the value - and thereby detecting whether a error occured or not (i.e. while + and thereby detecting whether a error occurred or not (i.e. while checking the block size) */ gcry_error_t Modified: trunk/cipher/des.c =================================================================== --- trunk/cipher/des.c 2010-04-06 10:37:13 UTC (rev 1426) +++ trunk/cipher/des.c 2010-04-12 21:00:13 UTC (rev 1427) @@ -106,7 +106,7 @@ * * if ( (error_msg = selftest()) ) * { - * fprintf(stderr, "An error in the DES/Tripple-DES implementation occured: %s\n", error_msg); + * fprintf(stderr, "An error in the DES/Triple-DES implementation occurred: %s\n", error_msg); * abort(); * } */ Modified: trunk/cipher/ecc.c =================================================================== --- trunk/cipher/ecc.c 2010-04-06 10:37:13 UTC (rev 1426) +++ trunk/cipher/ecc.c 2010-04-12 21:00:13 UTC (rev 1427) @@ -1266,7 +1266,7 @@ } /* Check that all parameters are known and normalize all MPIs (that - should not be required but we use an internal fucntion later and + should not be required but we use an internal function later and thus we better make 100% sure that they are normalized). */ for (idx = 0; idx < 6; idx++) if (!values[idx]) Modified: trunk/cipher/md.c =================================================================== --- trunk/cipher/md.c 2010-04-06 10:37:13 UTC (rev 1426) +++ trunk/cipher/md.c 2010-04-12 21:00:13 UTC (rev 1427) @@ -105,7 +105,7 @@ /* This is the lock protecting DIGESTS_REGISTERED. */ static ath_mutex_t digests_registered_lock = ATH_MUTEX_INITIALIZER; -/* Flag to check wether the default ciphers have already been +/* Flag to check whether the default ciphers have already been registered. */ static int default_digests_registered; @@ -1142,7 +1142,7 @@ * Note: Because this function is in most cases used to return an * integer value, we can make it easier for the caller to just look at * the return value. The caller will in all cases consult the value - * and thereby detecting whether a error occured or not (i.e. while checking + * and thereby detecting whether a error occurred or not (i.e. while checking * the block size) */ gcry_error_t Modified: trunk/cipher/primegen.c =================================================================== --- trunk/cipher/primegen.c 2010-04-06 10:37:13 UTC (rev 1426) +++ trunk/cipher/primegen.c 2010-04-12 21:00:13 UTC (rev 1427) @@ -988,7 +988,7 @@ /* Given ARRAY of size N with M elements set to true produce a modified array with the next permutation of M elements. Note, that ARRAY is used in a one-bit-per-byte approach. To detected the last - permutation it is useful to intialize the array with the first M + permutation it is useful to initialize the array with the first M element set to true and use this test: m_out_of_n (array, m, n); for (i = j = 0; i < n && j < m; i++) @@ -1170,7 +1170,7 @@ return gcry_error (err); } -/* Check wether the number X is prime. */ +/* Check whether the number X is prime. */ gcry_error_t gcry_prime_check (gcry_mpi_t x, unsigned int flags) { Modified: trunk/cipher/pubkey.c =================================================================== --- trunk/cipher/pubkey.c 2010-04-06 10:37:13 UTC (rev 1426) +++ trunk/cipher/pubkey.c 2010-04-12 21:00:13 UTC (rev 1427) @@ -85,7 +85,7 @@ /* This is the lock protecting PUBKEYS_REGISTERED. */ static ath_mutex_t pubkeys_registered_lock = ATH_MUTEX_INITIALIZER;; -/* Flag to check wether the default pubkeys have already been +/* Flag to check whether the default pubkeys have already been registered. */ static int default_pubkeys_registered; @@ -1567,7 +1567,7 @@ Do a PK encrypt operation Caller has to provide a public key as the SEXP pkey and data as a - SEXP with just one MPI in it. Alternativly S_DATA might be a + SEXP with just one MPI in it. Alternatively S_DATA might be a complex S-Expression, similar to the one used for signature verification. This provides a flag which allows to handle PKCS#1 block type 2 padding. The function returns a a sexp which may be @@ -2504,14 +2504,14 @@ GCRYCTL_GET_ALGO_USAGE: Return the usage glafs for the give algo. An invalid alog - does return 0. Disabled algos are ignored here becuase we + does return 0. Disabled algos are ignored here because we only want to know whether the algo is at all capable of the usage. Note: Because this function is in most cases used to return an integer value, we can make it easier for the caller to just look at the return value. The caller will in all cases consult the value - and thereby detecting whether a error occured or not (i.e. while + and thereby detecting whether a error occurred or not (i.e. while checking the block size) */ gcry_error_t gcry_pk_algo_info (int algorithm, int what, void *buffer, size_t *nbytes) Modified: trunk/cipher/rfc2268.c =================================================================== --- trunk/cipher/rfc2268.c 2010-04-06 10:37:13 UTC (rev 1426) +++ trunk/cipher/rfc2268.c 2010-04-12 21:00:13 UTC (rev 1427) @@ -22,7 +22,7 @@ /* This implementation was written by Nikos Mavroyanopoulos for GNUTLS * as a Libgcrypt module (gnutls/lib/x509/rc2.c) and later adapted for * direct use by Libgcrypt by Werner Koch. This implementation is - * only useful for pkcs#12 descryption. + * only useful for pkcs#12 decryption. * * The implementation here is based on Peter Gutmann's RRC.2 paper. */ Modified: trunk/cipher/rsa.c =================================================================== --- trunk/cipher/rsa.c 2010-04-06 10:37:13 UTC (rev 1426) +++ trunk/cipher/rsa.c 2010-04-12 21:00:13 UTC (rev 1427) @@ -582,7 +582,7 @@ /**************** - * Test wether the secret key is valid. + * Test whether the secret key is valid. * Returns: true if this is a valid key. */ static int @@ -952,7 +952,7 @@ gcry_mpi_mod (r, r, sk.n); /* Calculate inverse of r. It practically impossible that the - follwing test fails, thus we do not add code to release + following test fails, thus we do not add code to release allocated resources. */ if (!gcry_mpi_invm (ri, r, sk.n)) return GPG_ERR_INTERNAL; @@ -1063,7 +1063,7 @@ (e #010001#)) PKCS-15 says that for RSA only the modulus should be hashed - - however, it is not clear wether this is meant to use the raw bytes + however, it is not clear whether this is meant to use the raw bytes (assuming this is an unsigned integer) or whether the DER required 0 should be prefixed. We hash the raw bytes. */ static gpg_err_code_t Modified: trunk/cipher/tiger.c =================================================================== --- trunk/cipher/tiger.c 2010-04-06 10:37:13 UTC (rev 1426) +++ trunk/cipher/tiger.c 2010-04-12 21:00:13 UTC (rev 1427) @@ -878,7 +878,7 @@ -/* This is the fixed TIGER implemenation. */ +/* This is the fixed TIGER implementation. */ static byte asn1[19] = /* Object ID is 1.3.6.1.4.1.11591.12.2 */ { 0x30, 0x29, 0x30, 0x0d, 0x06, 0x09, 0x2b, 0x06, 0x01, 0x04, 0x01, 0xda, 0x47, 0x0c, 0x02, Modified: trunk/cipher/twofish.c =================================================================== --- trunk/cipher/twofish.c 2010-04-06 10:37:13 UTC (rev 1426) +++ trunk/cipher/twofish.c 2010-04-12 21:00:13 UTC (rev 1427) @@ -522,7 +522,7 @@ * preprocessed through q0 and q1 respectively; for longer keys they are the * output of previous stages. j is the index of the first key byte to use. * CALC_K computes a pair of subkeys for 128-bit Twofish, by calling CALC_K_2 - * twice, doing the Psuedo-Hadamard Transform, and doing the necessary + * twice, doing the Pseudo-Hadamard Transform, and doing the necessary * rotations. Its parameters are: a, the array to write the results into, * j, the index of the first output entry, k and l, the preprocessed indices * for index 2i, and m and n, the preprocessed indices for index 2i+1. Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2010-04-06 10:37:13 UTC (rev 1426) +++ trunk/configure.ac 2010-04-12 21:00:13 UTC (rev 1427) @@ -1188,10 +1188,14 @@ echo " Libgcrypt v${VERSION} has been configured as follows: - Platform: $PRINTABLE_OS_NAME ($host) + Platform: $PRINTABLE_OS_NAME ($host) + Enabled cipher algorithms: $enabled_ciphers + Enabled digest algorithms: $enabled_digests + Enabled pubkey algorithms: $enabled_pubkey_ciphers + Random number generator: $random + Using linux capabilities: $use_capabilities " - if test "$print_egd_notice" = "yes"; then cat < Author: marcus Date: 2010-04-13 03:06:18 +0200 (Tue, 13 Apr 2010) New Revision: 5304 Modified: trunk/po/ChangeLog trunk/po/POTFILES.in Log: 2010-04-13 Marcus Brinkmann * POTFILES.in: Replace common/exechelp.c by common/exechelp-posix.c, common/exechelp-w32.c and common/exechelp-w32ce.c. Modified: trunk/po/ChangeLog =================================================================== --- trunk/po/ChangeLog 2010-04-01 13:24:55 UTC (rev 5303) +++ trunk/po/ChangeLog 2010-04-13 01:06:18 UTC (rev 5304) @@ -1,3 +1,9 @@ +2010-04-13 Marcus Brinkmann + + * POTFILES.in: Replace common/exechelp.c by + common/exechelp-posix.c, common/exechelp-w32.c and + common/exechelp-w32ce.c. + 2009-10-16 Marcus Brinkmann * POTFILES.in: g10/encode.c was renamed to g10/encrypt.c, and Modified: trunk/po/POTFILES.in =================================================================== --- trunk/po/POTFILES.in 2010-04-01 13:24:55 UTC (rev 5303) +++ trunk/po/POTFILES.in 2010-04-13 01:06:18 UTC (rev 5304) @@ -10,7 +10,9 @@ agent/trustlist.c agent/findkey.c -common/exechelp.c +common/exechelp-posix.c +common/exechelp-w32.c +common/exechelp-w32ce.c common/http.c common/simple-pwquery.c common/sysutils.c From cvs at cvs.gnupg.org Wed Apr 14 02:12:16 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Wed, 14 Apr 2010 02:12:16 +0200 Subject: [svn] assuan - r366 - trunk/src Message-ID: Author: marcus Date: 2010-04-14 02:12:16 +0200 (Wed, 14 Apr 2010) New Revision: 366 Modified: trunk/src/ChangeLog trunk/src/Makefile.am Log: 2010-04-14 Marcus Brinkmann * Makefile.am (EXTRA_DIST): Add gpgcedev.def. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-04-06 16:46:31 UTC (rev 365) +++ trunk/src/ChangeLog 2010-04-14 00:12:16 UTC (rev 366) @@ -1,3 +1,7 @@ +2010-04-14 Marcus Brinkmann + + * Makefile.am (EXTRA_DIST): Add gpgcedev.def. + 2010-04-06 Werner Koch * posix-includes.inc.h, w32-includes.inc.h: New. Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2010-04-06 16:46:31 UTC (rev 365) +++ trunk/src/Makefile.am 2010-04-14 00:12:16 UTC (rev 366) @@ -18,7 +18,7 @@ ## Process this file with automake to produce Makefile.in EXTRA_DIST = libassuan-config.in libassuan.m4 libassuan.vers \ - versioninfo.rc.in libassuan.def mkheader.c + versioninfo.rc.in libassuan.def mkheader.c gpgcedev.def INCLUDES = -I.. -I$(top_srcdir)/include bin_SCRIPTS = libassuan-config From cvs at cvs.gnupg.org Wed Apr 14 11:35:43 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 14 Apr 2010 11:35:43 +0200 Subject: [svn] w32pth - r35 - trunk Message-ID: Author: wk Date: 2010-04-14 11:35:43 +0200 (Wed, 14 Apr 2010) New Revision: 35 Modified: trunk/ChangeLog trunk/w32-io.c trunk/w32-pth.c Log: Changes for W32CE Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-03-23 10:20:55 UTC (rev 34) +++ trunk/ChangeLog 2010-04-14 09:35:43 UTC (rev 35) @@ -1,3 +1,8 @@ +2010-04-08 Werner Koch + + * w32-io.c (reader, writer) [W32CE]: Take care of + ERROR_PIPE_NOT_CONNECTED. + 2010-03-23 Werner Koch * w32-io.c (create_pipe) [W32CE]: Change to new driver semantics. Modified: trunk/w32-io.c =================================================================== --- trunk/w32-io.c 2010-03-23 10:20:55 UTC (rev 34) +++ trunk/w32-io.c 2010-04-14 09:35:43 UTC (rev 35) @@ -352,6 +352,19 @@ ctx->eof = 1; TRACE_LOG ("got EOF (broken pipe)"); } +#ifdef HAVE_W32CE_SYSTEM + else if (ctx->error_code == ERROR_PIPE_NOT_CONNECTED + || ctx->error_code == ERROR_BUSY) + { + /* This may happen while one pipe end is still dangling + because the child process has not yet completed the + pipe creation. ERROR_BUSY has been seen as well, it + is propabaly returned by the device manager. */ + ctx->error_code = 0; + Sleep (100); + continue; + } +#endif else { ctx->error = 1; @@ -673,6 +686,19 @@ ctx->nbytes, &nwritten, NULL)) { ctx->error_code = (int) GetLastError (); +#ifdef HAVE_W32CE_SYSTEM + if (ctx->error_code == ERROR_PIPE_NOT_CONNECTED + || ctx->error_code == ERROR_BUSY) + { + /* This may happen while one pipe end is still dangling + because the child process has not yet completed the + pipe creation. ERROR_BUSY has been seen as well, it + is propabaly returned by the device manager. */ + ctx->error_code = 0; + Sleep (100); + continue; + } +#endif ctx->error = 1; TRACE_LOG1 ("write error: ec=%d", ctx->error_code); break; Modified: trunk/w32-pth.c =================================================================== --- trunk/w32-pth.c 2010-03-23 10:20:55 UTC (rev 34) +++ trunk/w32-pth.c 2010-04-14 09:35:43 UTC (rev 35) @@ -885,6 +885,27 @@ static int +pipe_is_not_connected (void) +{ +#ifdef HAVE_W32CE_SYSTEM + switch (GetLastError ()) + { + case ERROR_PIPE_NOT_CONNECTED: + /* This may happen while one pipe end is still dangling + because the child process has not yet completed the + pipe creation. */ + case ERROR_BUSY: + /* Returned by the device manager? */ + Sleep (100); + return 1; + + } +#endif + return 0; +} + + +static int do_pth_read (int fd, void * buffer, size_t size) { int n; @@ -901,13 +922,16 @@ if (n == -1 && WSAGetLastError () == WSAENOTSOCK) { DWORD nread = 0; - n = ReadFile ((HANDLE)fd, buffer, size, &nread, NULL); + + do + n = ReadFile ((HANDLE)fd, buffer, size, &nread, NULL); + while (!n && pipe_is_not_connected ()); if (!n) { char strerr[256]; if (DBG_ERROR) - fprintf (dbgfp, "%s: pth_read(%d) failed read from file: %s\n", + fprintf (dbgfp, "%s: pth_read(0x%x) ReadFile failed: %s\n", log_get_prefix (NULL), fd, w32_strerror (strerr, sizeof strerr)); n = -1; @@ -1014,7 +1038,7 @@ n = -1; set_errno (map_w32_to_errno (GetLastError ())); if (DBG_ERROR) - fprintf (dbgfp, "%s: pth_write(%d) failed in write: %s\n", + fprintf (dbgfp, "%s: pth_write(0x%x) failed in write: %s\n", log_get_prefix (NULL), fd, w32_strerror (strerr, sizeof strerr)); } @@ -1623,6 +1647,7 @@ int pth_join (pth_t hd, void **value) { +#warning fixme: We need to implement this. return TRUE; } From cvs at cvs.gnupg.org Wed Apr 14 11:40:45 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 14 Apr 2010 11:40:45 +0200 Subject: [svn] assuan - r367 - in trunk: doc src Message-ID: Author: wk Date: 2010-04-14 11:40:45 +0200 (Wed, 14 Apr 2010) New Revision: 367 Modified: trunk/doc/assuan.texi trunk/src/ChangeLog trunk/src/assuan-pipe-connect.c trunk/src/gpgcedev.c trunk/src/gpgcemgr.c trunk/src/system-w32.c trunk/src/system-w32ce.c trunk/src/system.c Log: Changes for W32CE Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-04-14 00:12:16 UTC (rev 366) +++ trunk/src/ChangeLog 2010-04-14 09:40:45 UTC (rev 367) @@ -2,6 +2,20 @@ * Makefile.am (EXTRA_DIST): Add gpgcedev.def. +2010-04-13 Werner Koch + + * gpgcedev.c (get_new_opnctx): Always clear IS_WRITE. + +2010-04-08 Werner Koch + + * gpgcedev.c (GPG_Read, GPG_Write): If the context is not + associated return ERROR_PIPE_NOT_CONNECTED. + * system-w32ce.c (__assuan_read, __assuan_write): Return EAGAIN for + ERROR_PIPE_NOT_CONNECTED. + + * assuan-pipe-connect.c (pipe_connect): Use + _assuan_close_inheritable also in the spawn error case. + 2010-04-06 Werner Koch * posix-includes.inc.h, w32-includes.inc.h: New. Modified: trunk/doc/assuan.texi =================================================================== --- trunk/doc/assuan.texi 2010-04-14 00:12:16 UTC (rev 366) +++ trunk/doc/assuan.texi 2010-04-14 09:40:45 UTC (rev 367) @@ -948,7 +948,7 @@ @deftypefun void assuan_ctx_set_system_hooks (@w{assuan_context_t @var{ctx}}, @w{assuan_system_hooks_t @var{system_hooks}}) Set the system hooks for context @var{ctx}. There is currently no way -to reset tot the default system hooks, create a new context for that. +to reset to the default system hooks, create a new context for that. @end deftypefun The following system hook collections are defined by the library for Modified: trunk/src/assuan-pipe-connect.c =================================================================== --- trunk/src/assuan-pipe-connect.c 2010-04-14 00:12:16 UTC (rev 366) +++ trunk/src/assuan-pipe-connect.c 2010-04-14 09:40:45 UTC (rev 367) @@ -190,8 +190,8 @@ { rc = gpg_err_code_from_syserror (); _assuan_close (ctx, rp[0]); - _assuan_close (ctx, rp[1]); - _assuan_close (ctx, wp[0]); + _assuan_close_inheritable (ctx, rp[1]); + _assuan_close_inheritable (ctx, wp[0]); _assuan_close (ctx, wp[1]); return _assuan_error (ctx, rc); } Modified: trunk/src/gpgcedev.c =================================================================== --- trunk/src/gpgcedev.c 2010-04-14 00:12:16 UTC (rev 366) +++ trunk/src/gpgcedev.c 2010-04-14 09:40:45 UTC (rev 367) @@ -169,6 +169,11 @@ opnctx = opnctx_table + idx; opnctx->assoc = NULL; opnctx->rvid = create_rendezvous_id (); + opnctx->is_write = 0; + opnctx->access_code = 0; + opnctx->share_mode = 0; + InitializeCriticalSection (&opnctx->critsect); + opnctx->locked = 0; opnctx->buffer_size = 512; opnctx->buffer = malloc (opnctx->buffer_size); if (!opnctx->buffer) @@ -182,7 +187,6 @@ opnctx->space_available = INVALID_HANDLE_VALUE; opnctx->inuse = 1; - InitializeCriticalSection (&opnctx->critsect); EnterCriticalSection (&opnctx->critsect); opnctx->locked = 1; @@ -437,11 +441,12 @@ if (rctx->is_write) { SetLastError (ERROR_INVALID_ACCESS); + log_debug ("GPG_Read(%p) -> invalid access\n", (void*)rctx); goto leave; } if (!rctx->assoc) { - SetLastError (ERROR_BROKEN_PIPE); + SetLastError (ERROR_PIPE_NOT_CONNECTED); goto leave; } @@ -508,11 +513,12 @@ if (!wctx->is_write) { SetLastError (ERROR_INVALID_ACCESS); + log_debug ("GPG_Write(%p) -> invalid access\n", (void*)wctx); goto leave; } if (!wctx->assoc) { - SetLastError (ERROR_BROKEN_PIPE); + SetLastError (ERROR_PIPE_NOT_CONNECTED); goto leave; } if (!count) @@ -601,6 +607,7 @@ if (!(peerctx->access_code & GENERIC_WRITE)) { SetLastError (ERROR_INVALID_ACCESS); + log_debug (" make_pipe(%p) write end -> invalid access\n", ctx); goto leave; } peerctx->space_available = CreateEvent (NULL, FALSE, FALSE, NULL); @@ -618,6 +625,7 @@ if (!(peerctx->access_code & GENERIC_READ)) { SetLastError (ERROR_INVALID_ACCESS); + log_debug (" make_pipe(%p) read_end -> invalid access\n", ctx); goto leave; } ctx->space_available = CreateEvent (NULL, FALSE, FALSE, NULL); @@ -632,6 +640,7 @@ else { SetLastError (ERROR_INVALID_ACCESS); + log_debug (" make_pipe(%p) no_access -> invalid access\n", ctx); goto leave; } Modified: trunk/src/gpgcemgr.c =================================================================== --- trunk/src/gpgcemgr.c 2010-04-14 00:12:16 UTC (rev 366) +++ trunk/src/gpgcemgr.c 2010-04-14 09:40:45 UTC (rev 367) @@ -1,4 +1,4 @@ -/* gpgcempg.c - Manager fopr GPG CE devices +/* gpgcempr.c - Manager for GPG CE devices Copyright (C) 2010 Free Software Foundation, Inc. This file is part of Assuan. Modified: trunk/src/system-w32.c =================================================================== --- trunk/src/system-w32.c 2010-04-14 00:12:16 UTC (rev 366) +++ trunk/src/system-w32.c 2010-04-14 09:40:45 UTC (rev 367) @@ -402,7 +402,8 @@ /* Note: We inherit all handles flagged as inheritable. This seems to be a security flaw but there seems to be no way of selecting - handles to inherit. */ + handles to inherit. A fix for this would be to use a helper + process like we have in gpgme. */ /* _assuan_log_printf ("CreateProcess, path=`%s' cmdline=`%s'\n", */ /* name, cmdline); */ if (!CreateProcess (name, /* Program to start. */ Modified: trunk/src/system-w32ce.c =================================================================== --- trunk/src/system-w32ce.c 2010-04-14 00:12:16 UTC (rev 366) +++ trunk/src/system-w32ce.c 2010-04-14 09:40:45 UTC (rev 367) @@ -301,6 +301,11 @@ gpg_err_set_errno (EPIPE); break; + case ERROR_PIPE_NOT_CONNECTED: + case ERROR_BUSY: + gpg_err_set_errno (EAGAIN); + break; + default: gpg_err_set_errno (EIO); } @@ -357,6 +362,11 @@ case ERROR_NO_DATA: gpg_err_set_errno (EPIPE); break; + + case ERROR_PIPE_NOT_CONNECTED: + case ERROR_BUSY: + gpg_err_set_errno (EAGAIN); + break; default: gpg_err_set_errno (EIO); @@ -505,9 +515,12 @@ Because an RVID of 0 is an invalid value and HANDLES will never have this value either, we test for this as well. */ - /* FIXME: CHECKOUT WHAT TO DO WITH STDERR HERE. WE NEED TO DEFINE - WHETHER THE FD_CHILD_LIST HAS HANDLES OR RENDEZVOUS IDS. */ - + /* FIXME: As long as we can't decide whether a handle is a real + handler or an rendezvous id we can't do anything with the + FD_CHILD_LIST. We can't do much with stderr either, thus we + better don't pass stderr to the child at all. If we would do so + and it is not a rendezvous id the client would run into + problems. */ fd = assuan_fd_from_posix_fd (fileno (stderr)); fdp = fd_child_list; if (fdp) @@ -517,7 +530,7 @@ } if (!fdp || *fdp == ASSUAN_INVALID_FD) fd_err_isnull = 1; - fd_err = fd; + fd_err = ASSUAN_INVALID_FD; if (build_w32_commandline (ctx, argv, fd_in, fd_out, fd_err, fd_err_isnull, &cmdline)) Modified: trunk/src/system.c =================================================================== --- trunk/src/system.c 2010-04-14 00:12:16 UTC (rev 366) +++ trunk/src/system.c 2010-04-14 09:40:45 UTC (rev 367) @@ -175,7 +175,7 @@ int _assuan_close_inheritable (assuan_context_t ctx, assuan_fd_t fd) { - TRACE1 (ctx, ASSUAN_LOG_SYSIO, "_assuan_close", ctx, + TRACE1 (ctx, ASSUAN_LOG_SYSIO, "_assuan_close_inheritable", ctx, "fd=0x%x", fd); #ifdef HAVE_W32CE_SYSTEM From cvs at cvs.gnupg.org Wed Apr 14 12:57:59 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 14 Apr 2010 12:57:59 +0200 Subject: [svn] gpg-error - r238 - in trunk: . src Message-ID: Author: wk Date: 2010-04-14 12:57:58 +0200 (Wed, 14 Apr 2010) New Revision: 238 Modified: trunk/ChangeLog trunk/src/Makefile.am trunk/src/init.c trunk/src/mkw32errmap.c Log: MAp some W32 error codes. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-03-15 12:21:59 UTC (rev 237) +++ trunk/ChangeLog 2010-04-14 10:57:58 UTC (rev 238) @@ -1,3 +1,11 @@ +2010-04-14 Werner Koch + + * src/init.c (_gpg_w32ce_get_errno): Add native error mapping. + * src/Makefile.am (mkw32errmap.map.c): New. + * src/mkw32errmap.c (struct table_s): Add field W32CODE2. + (table): Init this field. + (main): Add option --map. + 2010-03-15 Werner Koch * src/mkheader.awk: Add emacs local-var line. Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2010-03-15 12:21:59 UTC (rev 237) +++ trunk/src/Makefile.am 2010-04-14 10:57:58 UTC (rev 238) @@ -47,14 +47,14 @@ BUILT_SOURCES = err-sources.h err-codes.h code-to-errno.h code-from-errno.h \ err-sources-sym.h err-codes-sym.h errnos-sym.h gpg-error.h \ - gpg-error.def extra-h.in + gpg-error.def extra-h.in mkw32errmap.map.c -tmp_files = _mkerrcodes.h _gpg-error.def.h mkw32errmap.tab.h +tmp_files = _mkerrcodes.h _gpg-error.def.h mkw32errmap.tab.h mkw32errmap.map.c CLEANFILES = err-sources.h err-codes.h code-to-errno.h code-from-errno.h \ gpg-error.h mkerrcodes mkerrcodes.h gpg-error.def mkw32errmap.tab.h \ - err-sources-sym.h err-codes-sym.h errnos-sym.h gpg-extra/errno.h \ - extra-h.in $(tmp_files) + mkw32errmap.map.c err-sources-sym.h err-codes-sym.h errnos-sym.h \ + gpg-extra/errno.h extra-h.in $(tmp_files) if HAVE_W32_SYSTEM arch_sources = w32-gettext.c @@ -142,9 +142,14 @@ mkw32errmap.tab.h: Makefile mkw32errmap.c $(CPP) -DRESOLVE_MACROS $(srcdir)/mkw32errmap.c | \ grep '{&mkw32errmap_marker' >$@ +mkw32errmap.map.c: mkw32errmap + ./mkw32errmap --map > $@ gpg-extra/errno.h: mkw32errmap -$(MKDIR_P) gpg-extra ./mkw32errmap > $@ +else +mkw32errmap.map.c: + echo "/*dummy*/" > $@ endif # We use CC proper for preprocessing thus we have to convince it that Modified: trunk/src/init.c =================================================================== --- trunk/src/init.c 2010-03-15 12:21:59 UTC (rev 237) +++ trunk/src/init.c 2010-04-14 10:57:58 UTC (rev 238) @@ -31,6 +31,10 @@ #include "gettext.h" #include "init.h" +#ifdef HAVE_W32CE_SYSTEM +# include "mkw32errmap.map.c" /* Generated map_w32codes () */ +#endif + /* Locale directory support. */ @@ -239,12 +243,7 @@ int _gpg_w32ce_get_errno (void) { - int err; - - err = GetLastError (); - /* FIXME: Should we fold some W32 error codes into the same errno - value? */ - return err; + return map_w32codes ( GetLastError () ); } #endif /*HAVE_W32CE_SYSTEM*/ Modified: trunk/src/mkw32errmap.c =================================================================== --- trunk/src/mkw32errmap.c 2010-03-15 12:21:59 UTC (rev 237) +++ trunk/src/mkw32errmap.c 2010-04-14 10:57:58 UTC (rev 238) @@ -72,47 +72,45 @@ int *dummy; const char *name; int w32code; + int w32code2; }; struct table_s table[] = { #ifdef RESOLVE_MACROS -#define X(a,b) \ - {&mkw32errmap_marker, (a), (b)} - X( "EPERM", ERROR_CANNOT_MAKE ), - X( "ENOENT", ERROR_FILE_NOT_FOUND ), - X( "EINTR", ERROR_INVALID_AT_INTERRUPT_TIME ), - X( "EIO", ERROR_IO_DEVICE ), - X( "ENXIO", ERROR_FILE_INVALID ), - X( "EBADF", ERROR_INVALID_HANDLE ), - X( "EAGAIN", ERROR_MORE_DATA ), - /* FIXME: Add WSAEWOULDBLOCK */ +#define X(a,b,c) \ + {&mkw32errmap_marker, (a), (b), (c)} + X( "EPERM", ERROR_CANNOT_MAKE , 0 ), + X( "ENOENT", ERROR_FILE_NOT_FOUND , ERROR_PATH_NOT_FOUND ), + X( "EINTR", ERROR_INVALID_AT_INTERRUPT_TIME , 0 ), + X( "EIO", ERROR_IO_DEVICE , 0 ), + X( "ENXIO", ERROR_FILE_INVALID , 0 ), + X( "EBADF", ERROR_INVALID_HANDLE , 0 ), + X( "EAGAIN", ERROR_MORE_DATA , WSAEWOULDBLOCK ), - X( "ENOMEM", ERROR_NOT_ENOUGH_MEMORY ), - X( "EACCES", ERROR_ACCESS_DENIED ), - X( "EFAULT", ERROR_PROCESS_ABORTED ), - X( "EBUSY", ERROR_BUSY ), - X( "EEXIST", ERROR_FILE_EXISTS ), - /* FIXME: Add WSAEADDRINUSE. */ + X( "ENOMEM", ERROR_NOT_ENOUGH_MEMORY , 0 ), + X( "EACCES", ERROR_ACCESS_DENIED , 0 ), + X( "EFAULT", ERROR_PROCESS_ABORTED , 0 ), + X( "EBUSY", ERROR_BUSY , 0 ), + X( "EEXIST", ERROR_FILE_EXISTS , WSAEADDRINUSE ), - X( "EXDEV", ERROR_NOT_SAME_DEVICE ), - X( "ENODEV", ERROR_BAD_DEVICE ), - /* FIXME: ERROR_DEV_NOT_EXIST */ + X( "EXDEV", ERROR_NOT_SAME_DEVICE , 0 ), + X( "ENODEV", ERROR_BAD_DEVICE , ERROR_DEV_NOT_EXIST ), - X( "ENOTDIR",ERROR_DIRECTORY ), - X( "EINVAL", ERROR_INVALID_PARAMETER ), - X( "ENFILE", ERROR_NO_MORE_FILES ), - X( "EMFILE", ERROR_TOO_MANY_OPEN_FILES ), - X( "ENOSPC", ERROR_DISK_FULL ), - X( "EROFS", ERROR_WRITE_PROTECT ), - X( "EPIPE", ERROR_BROKEN_PIPE ), - X( "ERANGE", ERROR_ARITHMETIC_OVERFLOW ), - X( "EDEADLOCK",ERROR_POSSIBLE_DEADLOCK ), - X( "ENAMETOOLONG", ERROR_FILENAME_EXCED_RANGE ), - X( "ENOLCK", ERROR_SHARING_BUFFER_EXCEEDED ), - X( "ENOSYS", ERROR_NOT_SUPPORTED ), - X( "ENOTEMPTY",ERROR_DIR_NOT_EMPTY ), - X( "ESPIPE", ERROR_SEEK_ON_DEVICE ), + X( "ENOTDIR",ERROR_DIRECTORY , 0 ), + X( "EINVAL", ERROR_INVALID_PARAMETER , 0 ), + X( "ENFILE", ERROR_NO_MORE_FILES , 0 ), + X( "EMFILE", ERROR_TOO_MANY_OPEN_FILES , 0 ), + X( "ENOSPC", ERROR_DISK_FULL , 0 ), + X( "EROFS", ERROR_WRITE_PROTECT , 0 ), + X( "EPIPE", ERROR_BROKEN_PIPE , 0 ), + X( "ERANGE", ERROR_ARITHMETIC_OVERFLOW , 0 ), + X( "EDEADLOCK",ERROR_POSSIBLE_DEADLOCK , 0 ), + X( "ENAMETOOLONG", ERROR_FILENAME_EXCED_RANGE, 0 ), + X( "ENOLCK", ERROR_SHARING_BUFFER_EXCEEDED , 0 ), + X( "ENOSYS", ERROR_NOT_SUPPORTED , 0 ), + X( "ENOTEMPTY",ERROR_DIR_NOT_EMPTY , 0 ), + X( "ESPIPE", ERROR_SEEK_ON_DEVICE , 0 ), #if 0 /* FIXME: Find appropriate mappings. */ X( "EILSEQ", ), X( "EDOM", ), @@ -152,11 +150,29 @@ for (idx=0; table[idx].name; idx++) ; qsort (table, idx, sizeof *table, compare_table); + + if (argc == 2 && !strcmp (argv[1], "--map")) + { + fputs ("static int\n" + "map_w32codes (int err)\n" + "{\n" + " switch (err)\n" + " {\n", stdout ); + for (idx=0; table[idx].name; idx++) + if (table[idx].w32code2) + printf (" case %d: return %d;\n", + table[idx].w32code2, table[idx].w32code); + fputs (" default: return err;\n" + " }\n" + "}\n", stdout); + } + else + { + fputs (header_gpg_extra_errno_h, stdout); + for (idx=0; table[idx].name; idx++) + printf ("#define %-12s %5d\n", table[idx].name, table[idx].w32code); + fputs (footer_gpg_extra_errno_h, stdout); + } - fputs (header_gpg_extra_errno_h, stdout); - for (idx=0; table[idx].name; idx++) - printf ("#define %-12s %5d\n", table[idx].name, table[idx].w32code); - fputs (footer_gpg_extra_errno_h, stdout); - return 0; } From cvs at cvs.gnupg.org Wed Apr 14 13:20:11 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 14 Apr 2010 13:20:11 +0200 Subject: [svn] assuan - r368 - trunk/src Message-ID: Author: wk Date: 2010-04-14 13:20:11 +0200 (Wed, 14 Apr 2010) New Revision: 368 Modified: trunk/src/ChangeLog trunk/src/Makefile.am Log: Rename device driver during install Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-04-14 09:40:45 UTC (rev 367) +++ trunk/src/ChangeLog 2010-04-14 11:20:11 UTC (rev 368) @@ -1,3 +1,7 @@ +2010-04-14 Werner Koch + + * Makefile.am (install-exec-hook): Rename libgpgcedev-0.dll. + 2010-04-14 Marcus Brinkmann * Makefile.am (EXTRA_DIST): Add gpgcedev.def. Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2010-04-14 09:40:45 UTC (rev 367) +++ trunk/src/Makefile.am 2010-04-14 11:20:11 UTC (rev 368) @@ -133,6 +133,9 @@ libgpgcedev_la_DEPENDENCIES = gpgcedev.def gpgcemgr_SOURCES = gpgcemgr.c gpgcemgr_CPPFLAGS = $(AM_CPPFLAGS) +install-exec-hook: + mv -f $(DESTDIR)$(bindir)/libgpgcedev-0.dll \ + $(DESTDIR)$(bindir)/gpgcedev.dll endif mkheader: mkheader.c Makefile @@ -141,3 +144,4 @@ assuan.h: assuan.h.in mkheader $(parts_of_assuan_h) ./mkheader $(host_os) $(srcdir)/assuan.h.in >$@ + From cvs at cvs.gnupg.org Wed Apr 14 13:24:03 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 14 Apr 2010 13:24:03 +0200 Subject: [svn] GnuPG - r5305 - in trunk: . agent common g10 gl sm tools Message-ID: Author: wk Date: 2010-04-14 13:24:02 +0200 (Wed, 14 Apr 2010) New Revision: 5305 Modified: trunk/ChangeLog trunk/agent/ChangeLog trunk/agent/call-pinentry.c trunk/agent/call-scd.c trunk/agent/command-ssh.c trunk/agent/findkey.c trunk/agent/genkey.c trunk/agent/gpg-agent.c trunk/agent/protect-tool.c trunk/agent/protect.c trunk/agent/trustlist.c trunk/autogen.sh trunk/common/ChangeLog trunk/common/asshelp.c trunk/common/estream.c trunk/common/mischelp.c trunk/common/sysutils.c trunk/common/sysutils.h trunk/common/util.h trunk/common/w32help.h trunk/g10/ChangeLog trunk/g10/openfile.c trunk/gl/mkdtemp.c trunk/sm/ChangeLog trunk/sm/gpgsm.c trunk/sm/misc.c trunk/sm/sign.c trunk/tools/gpg-connect-agent.c Log: Whole lot of changes to support CE. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-04-13 01:06:18 UTC (rev 5304) +++ trunk/ChangeLog 2010-04-14 11:24:02 UTC (rev 5305) @@ -1,3 +1,9 @@ +2010-04-07 Werner Koch + + * autogen.sh: Take a .gnupg-autogen.rc file in account. + + * gl/mkdtemp.c (getpid) [W32CE]: New macro. + 2010-03-24 Werner Koch * configure.ac (AH_BOTTOM): Use /gnupg as the default homedir on Modified: trunk/agent/ChangeLog =================================================================== --- trunk/agent/ChangeLog 2010-04-13 01:06:18 UTC (rev 5304) +++ trunk/agent/ChangeLog 2010-04-14 11:24:02 UTC (rev 5305) @@ -1,3 +1,40 @@ +2010-04-14 Werner Koch + + * trustlist.c (read_one_trustfile): Use estream. + +2010-04-13 Werner Koch + + * findkey.c (read_key_file): Use estream. + (agent_write_private_key): Ditto. + +2010-04-07 Werner Koch + + * gpg-agent.c (handle_connections) [W32]: Assume that PTh support + the handle event. Use a dummy event for W32CE. + (get_agent_scd_notify_event) [W32CE]: Do not build. + + * call-pinentry.c: Remove setenv.h. Include sysutils.h. + (atfork_cb): s/setenv/gnupg_setenv/. + + * gpg-agent.c: Do not include setenv.h. + (main): s/unsetenv/gnupg_unsetenv/. + + * protect.c (calibrate_get_time) [W32CE]: Use GetThreadTimes. + +2010-04-06 Werner Koch + + * call-scd.c [!HAVE_SIGNAL_H]: Do not include signal.h. + + * findkey.c (agent_write_private_key): s/remove/gnupg_remove/. + + * command-ssh.c (search_control_file): Replace rewind by fseek and + clearerr. + * genkey.c (check_passphrase_pattern): Ditto. + + * gpg-agent.c [!HAVE_SIGNAL_H]: Do not include signal.h. + (remove_socket): s/remove/gnupg_remove/. + (create_private_keys_directory): Use gnupg_mkdir. + 2010-03-11 Werner Koch * gpg-agent.c: Include "asshelp.h". Modified: trunk/common/ChangeLog =================================================================== --- trunk/common/ChangeLog 2010-04-13 01:06:18 UTC (rev 5304) +++ trunk/common/ChangeLog 2010-04-14 11:24:02 UTC (rev 5305) @@ -1,3 +1,26 @@ +2010-04-14 Werner Koch + + * asshelp.c (setup_libassuan_logging): Read ASSUAN_DEBUG envvar. + (my_libassuan_log_handler): Use it. + * sysutils.c (_gnupg_getenv): Implement ASSUAN_DEBUG. + +2010-04-08 Werner Koch + + * w32help.h (_setmode, setmode) [W32CE]: Provide prototype and + macro. + +2010-04-07 Werner Koch + + * mischelp.c (timegm): Replace unsetenv/putenv by gnupg_unsetenv. + + * sysutils.c: Include setenv.h. + (gnupg_setenv, gnupg_unsetenv): New. + + +2010-04-06 Werner Koch + + * sysutils.c (gnupg_mkdir): New. + 2010-03-29 Werner Koch * init.c (sleep_on_exit): Change to 400ms. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2010-04-13 01:06:18 UTC (rev 5304) +++ trunk/g10/ChangeLog 2010-04-14 11:24:02 UTC (rev 5305) @@ -1,3 +1,8 @@ +2010-04-06 Werner Koch + + * openfile.c (mkdir): Remove. + (try_make_homedir): Use gnupg_mkdir. + 2010-04-01 Werner Koch Use gpg_err_set_errno to set ERRNO. Modified: trunk/sm/ChangeLog =================================================================== --- trunk/sm/ChangeLog 2010-04-13 01:06:18 UTC (rev 5304) +++ trunk/sm/ChangeLog 2010-04-14 11:24:02 UTC (rev 5305) @@ -1,3 +1,22 @@ +2010-04-14 Werner Koch + + * gpgsm.c (main) [W32CE]: Disable dirmngr for now. + +2010-04-13 Werner Koch + + * sign.c (gpgsm_sign): Do not check qualified status in + no-chain-validation mode. + +2010-04-08 Werner Koch + + * gpgsm.c (open_es_fread): Add arg mode. + (main) : Call with mode "r" instead of "rb". + +2010-04-07 Werner Koch + + * misc.c: Remove setenv.h. Include sysutils.h. + (setup_pinentry_env): s/setenv/gnupg_setenv/ + 2010-03-24 Werner Koch * Makefile.am (gpgsm_LDADD): Add extra_sys_libs. Modified: trunk/agent/call-pinentry.c =================================================================== --- trunk/agent/call-pinentry.c 2010-04-13 01:06:18 UTC (rev 5304) +++ trunk/agent/call-pinentry.c 2010-04-14 11:24:02 UTC (rev 5305) @@ -36,7 +36,7 @@ #include "agent.h" #include -#include "setenv.h" +#include "sysutils.h" #include "i18n.h" #ifdef _POSIX_OPEN_MAX @@ -190,7 +190,7 @@ { value = session_env_getenv (ctrl->session_env, name); if (value) - setenv (name, value, 1); + gnupg_setenv (name, value, 1); } } } @@ -276,7 +276,7 @@ if (!opt.pinentry_program || !*opt.pinentry_program) opt.pinentry_program = gnupg_module_name (GNUPG_MODULE_NAME_PINENTRY); - pgmname = opt.pinentry_program; + pgmname = opt.pinentry_program; if ( !(pgmname = strrchr (opt.pinentry_program, '/'))) pgmname = opt.pinentry_program; else Modified: trunk/agent/call-scd.c =================================================================== --- trunk/agent/call-scd.c 2010-04-13 01:06:18 UTC (rev 5304) +++ trunk/agent/call-scd.c 2010-04-14 11:24:02 UTC (rev 5305) @@ -25,7 +25,9 @@ #include #include #include -#include +#ifdef HAVE_SIGNAL_H +# include +#endif #include #include #ifndef HAVE_W32_SYSTEM @@ -385,7 +387,9 @@ xfree (databuf); } - /* Tell the scdaemon we want him to send us an event signal. */ + /* Tell the scdaemon we want him to send us an event signal. We + don't support this for W32CE. */ +#ifndef HAVE_W32CE_SYSTEM { char buf[100]; @@ -397,6 +401,7 @@ #endif assuan_transact (ctx, buf, NULL, NULL, NULL, NULL, NULL, NULL); } +#endif /*HAVE_W32CE_SYSTEM*/ primary_scd_ctx = ctx; primary_scd_ctx_reusable = 0; Modified: trunk/agent/command-ssh.c =================================================================== --- trunk/agent/command-ssh.c 2010-04-13 01:06:18 UTC (rev 5304) +++ trunk/agent/command-ssh.c 2010-04-14 11:24:02 UTC (rev 5305) @@ -721,7 +721,8 @@ assert (strlen (hexgrip) == 40 ); - rewind (fp); + fseek (fp, 0, SEEK_SET); + clearerr (fp); *r_disabled = 0; next_line: do Modified: trunk/agent/findkey.c =================================================================== --- trunk/agent/findkey.c 2010-04-13 01:06:18 UTC (rev 5304) +++ trunk/agent/findkey.c 2010-04-14 11:24:02 UTC (rev 5305) @@ -57,9 +57,8 @@ const void *buffer, size_t length, int force) { char *fname; - FILE *fp; + estream_t fp; char hexgrip[40+4+1]; - int fd; bin2hex (grip, 20, hexgrip); strcpy (hexgrip+40, ".key"); @@ -73,53 +72,30 @@ return gpg_error (GPG_ERR_GENERAL); } - /* In FORCE mode we would like to create FNAME but only if it does - not already exist. We cannot make this guarantee just using - POSIX (GNU provides the "x" opentype for fopen, however, this is - not portable). Thus, we use the more flexible open function and - then use fdopen to obtain a stream. */ - fd = open (fname, force? (O_CREAT | O_TRUNC | O_WRONLY | O_BINARY) - : (O_CREAT | O_EXCL | O_WRONLY | O_BINARY), - S_IRUSR | S_IWUSR -#ifndef HAVE_W32_SYSTEM - | S_IRGRP -#endif - ); - if (fd < 0) - fp = NULL; - else - { - fp = fdopen (fd, "wb"); - if (!fp) - { - int save_e = errno; - close (fd); - errno = save_e; - } - } - + /* FIXME: On POSIX systems we used include S_IRGRP as well. */ + fp = es_fopen (fname, force? "wb" : "wbx"); if (!fp) { - gpg_error_t tmperr = gpg_error (gpg_err_code_from_errno (errno)); - log_error ("can't create `%s': %s\n", fname, strerror (errno)); + gpg_error_t tmperr = gpg_error_from_syserror (); + log_error ("can't create `%s': %s\n", fname, gpg_strerror (tmperr)); xfree (fname); return tmperr; } - if (fwrite (buffer, length, 1, fp) != 1) + if (es_fwrite (buffer, length, 1, fp) != 1) { - gpg_error_t tmperr = gpg_error (gpg_err_code_from_errno (errno)); - log_error ("error writing `%s': %s\n", fname, strerror (errno)); - fclose (fp); - remove (fname); + gpg_error_t tmperr = gpg_error_from_syserror (); + log_error ("error writing `%s': %s\n", fname, gpg_strerror (tmperr)); + es_fclose (fp); + gnupg_remove (fname); xfree (fname); return tmperr; } - if ( fclose (fp) ) + if (es_fclose (fp)) { - gpg_error_t tmperr = gpg_error (gpg_err_code_from_errno (errno)); - log_error ("error closing `%s': %s\n", fname, strerror (errno)); - remove (fname); + gpg_error_t tmperr = gpg_error_from_syserror (); + log_error ("error closing `%s': %s\n", fname, gpg_strerror (tmperr)); + gnupg_remove (fname); xfree (fname); return tmperr; } @@ -425,7 +401,7 @@ { int rc; char *fname; - FILE *fp; + estream_t fp; struct stat st; unsigned char *buf; size_t buflen, erroff; @@ -438,7 +414,7 @@ strcpy (hexgrip+40, ".key"); fname = make_filename (opt.homedir, GNUPG_PRIVATE_KEYS_DIR, hexgrip, NULL); - fp = fopen (fname, "rb"); + fp = es_fopen (fname, "rb"); if (!fp) { rc = gpg_error_from_syserror (); @@ -448,31 +424,44 @@ return rc; } - if (fstat (fileno(fp), &st)) + if (fstat (es_fileno (fp), &st)) { rc = gpg_error_from_syserror (); log_error ("can't stat `%s': %s\n", fname, strerror (errno)); xfree (fname); - fclose (fp); + es_fclose (fp); return rc; } buflen = st.st_size; buf = xtrymalloc (buflen+1); - if (!buf || fread (buf, buflen, 1, fp) != 1) + if (!buf) { rc = gpg_error_from_syserror (); - log_error ("error reading `%s': %s\n", fname, strerror (errno)); + log_error ("error allocating %zu bytes for `%s': %s\n", + buflen, fname, strerror (errno)); xfree (fname); - fclose (fp); + es_fclose (fp); xfree (buf); return rc; + } + if (es_fread (buf, buflen, 1, fp) != 1) + { + rc = gpg_error_from_syserror (); + log_error ("error reading %zu bytes from `%s': %s\n", + buflen, fname, strerror (errno)); + xfree (fname); + es_fclose (fp); + xfree (buf); + return rc; + } + /* Convert the file into a gcrypt S-expression object. */ rc = gcry_sexp_sscan (&s_skey, &erroff, (char*)buf, buflen); xfree (fname); - fclose (fp); + es_fclose (fp); xfree (buf); if (rc) { Modified: trunk/agent/genkey.c =================================================================== --- trunk/agent/genkey.c 2010-04-13 01:06:18 UTC (rev 5304) +++ trunk/agent/genkey.c 2010-04-14 11:24:02 UTC (rev 5305) @@ -117,7 +117,8 @@ fclose (infp); return 1; /* Error - assume password should not be used. */ } - rewind (infp); + fseek (infp, 0, SEEK_SET); + clearerr (infp); i = 0; argv[i++] = "--null"; @@ -134,7 +135,8 @@ result = 0; /* Success; i.e. no match. */ /* Overwrite our temporary file. */ - rewind (infp); + fseek (infp, 0, SEEK_SET); + clearerr (infp); for (i=((strlen (pw)+99)/100)*100; i > 0; i--) putc ('\xff', infp); fflush (infp); Modified: trunk/agent/gpg-agent.c =================================================================== --- trunk/agent/gpg-agent.c 2010-04-13 01:06:18 UTC (rev 5304) +++ trunk/agent/gpg-agent.c 2010-04-14 11:24:02 UTC (rev 5305) @@ -1,6 +1,6 @@ /* gpg-agent.c - The GnuPG Agent - * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, - * 2006, 2007, 2009 Free Software Foundation, Inc. + * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, + * 2010 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -35,7 +35,9 @@ # include #endif /*!HAVE_W32_SYSTEM*/ #include -#include +#ifdef HAVE_SIGNAL_H +# include +#endif #include #define JNLIB_NEED_LOG_LOGV @@ -46,7 +48,6 @@ #include "i18n.h" #include "mkdtemp.h" /* Gnulib replacement. */ #include "sysutils.h" -#include "setenv.h" #include "gc-opt-flags.h" #include "exechelp.h" #include "asshelp.h" @@ -425,7 +426,7 @@ { char *p; - remove (name); + gnupg_remove (name); p = strrchr (name, '/'); if (p) { @@ -615,7 +616,7 @@ malloc_hooks.realloc = gcry_realloc; malloc_hooks.free = gcry_free; assuan_set_malloc_hooks (&malloc_hooks); - assuan_set_gpg_err_source (GPG_ERR_SOURCE_DEFAULT); + assuan_set_gpg_err_source (GPG_ERR_SOURCE_DEFAULT); assuan_set_system_hooks (ASSUAN_SYSTEM_PTH); assuan_sock_init (); setup_libassuan_logging (&opt.debug); @@ -994,7 +995,7 @@ exec the program given as arguments). */ #ifndef HAVE_W32_SYSTEM if (!opt.keep_display && !argc) - unsetenv ("DISPLAY"); + gnupg_unsetenv ("DISPLAY"); #endif @@ -1374,7 +1375,7 @@ /* Under W32, this function returns the handle of the scdaemon notification event. Calling it the first time creates that event. */ -#ifdef HAVE_W32_SYSTEM +#if defined(HAVE_W32_SYSTEM) && !defined(HAVE_W32CE_SYSTEM) void * get_agent_scd_notify_event (void) { @@ -1412,7 +1413,7 @@ log_debug ("returning notify handle %p\n", the_event); return the_event; } -#endif /*HAVE_W32_SYSTEM*/ +#endif /*HAVE_W32_SYSTEM && !HAVE_W32CE_SYSTEM*/ @@ -1510,7 +1511,7 @@ assuan_sock_close (fd); agent_exit (2); } - remove (name); + gnupg_remove (name); rc = assuan_sock_bind (fd, (struct sockaddr*) serv_addr, len); } if (rc != -1 @@ -1556,15 +1557,9 @@ fname = make_filename (home, GNUPG_PRIVATE_KEYS_DIR, NULL); if (stat (fname, &statbuf) && errno == ENOENT) { -#ifdef HAVE_W32_SYSTEM /*FIXME: Setup proper permissions. */ - if (!CreateDirectory (fname, NULL)) + if (gnupg_mkdir (fname, "-rwx")) log_error (_("can't create directory `%s': %s\n"), - fname, w32_strerror (-1) ); -#else - if (mkdir (fname, S_IRUSR|S_IWUSR|S_IXUSR )) - log_error (_("can't create directory `%s': %s\n"), fname, strerror (errno) ); -#endif else if (!opt.quiet) log_info (_("directory `%s' created\n"), fname); } @@ -1601,15 +1596,9 @@ #endif ) { -#ifdef HAVE_W32_SYSTEM - if (!CreateDirectory (home, NULL)) + if (gnupg_mkdir (home, "-rwx")) log_error (_("can't create directory `%s': %s\n"), - home, w32_strerror (-1) ); -#else - if (mkdir (home, S_IRUSR|S_IWUSR|S_IXUSR )) - log_error (_("can't create directory `%s': %s\n"), home, strerror (errno) ); -#endif else { if (!opt.quiet) @@ -1863,14 +1852,14 @@ pth_sigmask (SIG_UNBLOCK, &sigs, NULL); ev = pth_event (PTH_EVENT_SIGS, &sigs, &signo); #else -# ifdef PTH_EVENT_HANDLE - sigs = 0; - ev = pth_event (PTH_EVENT_HANDLE, get_agent_scd_notify_event ()); - signo = 0; -# else +# ifdef HAVE_W32CE_SYSTEM /* Use a dummy event. */ sigs = 0; ev = pth_event (PTH_EVENT_SIGS, &sigs, &signo); +# else + sigs = 0; + ev = pth_event (PTH_EVENT_HANDLE, get_agent_scd_notify_event ()); + signo = 0; # endif #endif time_ev = NULL; Modified: trunk/agent/protect-tool.c =================================================================== --- trunk/agent/protect-tool.c 2010-04-13 01:06:18 UTC (rev 5304) +++ trunk/agent/protect-tool.c 2010-04-14 11:24:02 UTC (rev 5305) @@ -1249,14 +1249,14 @@ { log_error ("error writing `%s': %s\n", fname, strerror (errno)); es_fclose (fp); - remove (fname); + gnupg_remove (fname); xfree (fname); return -1; } if (es_fclose (fp)) { log_error ("error closing `%s': %s\n", fname, strerror (errno)); - remove (fname); + gnupg_remove (fname); xfree (fname); return -1; } Modified: trunk/agent/protect.c =================================================================== --- trunk/agent/protect.c 2010-04-13 01:06:18 UTC (rev 5304) +++ trunk/agent/protect.c 2010-04-14 11:24:02 UTC (rev 5305) @@ -78,7 +78,11 @@ calibrate_get_time (struct calibrate_time_s *data) { #ifdef HAVE_W32_SYSTEM +# ifdef HAVE_W32CE_SYSTEM + GetThreadTimes (GetCurrentThread (), +# else GetProcessTimes (GetCurrentProcess (), +# endif &data->creation_time, &data->exit_time, &data->kernel_time, &data->user_time); #else Modified: trunk/agent/trustlist.c =================================================================== --- trunk/agent/trustlist.c 2010-04-13 01:06:18 UTC (rev 5304) +++ trunk/agent/trustlist.c 2010-04-14 11:24:02 UTC (rev 5305) @@ -116,7 +116,7 @@ int *addr_of_tableidx) { gpg_error_t err = 0; - FILE *fp; + estream_t fp; int n, c; char *p, line[256]; trustitem_t *table, *ti; @@ -128,7 +128,7 @@ tablesize = *addr_of_tablesize; tableidx = *addr_of_tableidx; - fp = fopen (fname, "r"); + fp = es_fopen (fname, "r"); if (!fp) { err = gpg_error_from_syserror (); @@ -136,14 +136,14 @@ goto leave; } - while (fgets (line, DIM(line)-1, fp)) + while (es_fgets (line, DIM(line)-1, fp)) { lnr++; if (!*line || line[strlen(line)-1] != '\n') { /* Eat until end of line. */ - while ( (c=getc (fp)) != EOF && c != '\n') + while ( (c=es_getc (fp)) != EOF && c != '\n') ; err = gpg_error (*line? GPG_ERR_LINE_TOO_LONG : GPG_ERR_INCOMPLETE_LINE); @@ -288,7 +288,7 @@ } tableidx++; } - if ( !err && !feof (fp) ) + if ( !err && !es_feof (fp) ) { err = gpg_error_from_syserror (); log_error (_("error reading `%s', line %d: %s\n"), @@ -296,8 +296,7 @@ } leave: - if (fp) - fclose (fp); + es_fclose (fp); *addr_of_table = table; *addr_of_tablesize = tablesize; *addr_of_tableidx = tableidx; Modified: trunk/autogen.sh =================================================================== --- trunk/autogen.sh 2010-04-13 01:06:18 UTC (rev 5304) +++ trunk/autogen.sh 2010-04-14 11:24:02 UTC (rev 5305) @@ -18,7 +18,7 @@ } check_version () { - if [ `("$1" --version || echo "0") | cvtver` -ge "$2" ]; then + if [ $(( `("$1" --version || echo "0") | cvtver` >= $2 )) = 1 ]; then return 0 fi echo "**Error**: "\`$1\'" not installed or too old." >&2 @@ -45,6 +45,24 @@ shift fi +# Begin list of optional variables sourced from ~/.gnupg-autogen.rc +w32_toolprefixes= +w32_extraoptions= +w32ce_toolprefixes= +w32ce_extraoptions= +amd64_toolprefixes= +# End list of optional variables sourced from ~/.gnupg-autogen.rc +# What follows are variables which are sourced but default to +# environment variables or lacking them hardcoded values. +#w32root= +#w32ce_root= +#amd64root= + +if [ -f "$HOME/.gnupg-autogen.rc" ]; then + echo "sourcing extra definitions from $HOME/.gnupg-autogen.rc" + . "$HOME/.gnupg-autogen.rc" +fi + # Convenience option to use certain configure options for some hosts. myhost="" myhostsub="" @@ -59,6 +77,10 @@ --build-amd64) myhost="amd64" ;; + --build*) + echo "**Error**: invalid build option $1" >&2 + exit 1 + ;; *) ;; esac @@ -76,16 +98,17 @@ fi build=`$tsdir/scripts/config.guess` - extraoptions="" case $myhostsub in ce) - [ -z "$w32root" ] && w32root="$HOME/w32ce_root" - toolprefixes="arm-mingw32ce" - extraoptions="--disable-scdaemon" + [ -z "$w32ce_root" ] && w32root="$HOME/w32ce_root" + toolprefixes="$w32ce_toolprefixes arm-mingw32ce" + extraoptions="--disable-scdaemon $w32ce_extraoptions" ;; *) [ -z "$w32root" ] && w32root="$HOME/w32root" - toolprefixes="i586-mingw32msvc i386-mingw32msvc mingw32" + toolprefixes="$w32_toolprefixes i586-mingw32msvc" + toolprefixes="$toolprefixes i386-mingw32msvc mingw32" + extraoptions="$w32_extraoptions" ;; esac echo "Using $w32root as standard install directory" >&2 @@ -146,10 +169,12 @@ [ -z "$amd64root" ] && amd64root="$HOME/amd64root" echo "Using $amd64root as standard install directory" >&2 + + toolprefixes="$amd64_toolprefixes x86_64-linux-gnu amd64-linux-gnu" # Locate the cross compiler crossbindir= - for host in x86_64-linux-gnu amd64-linux-gnu; do + for host in $toolprefixes ; do if ${host}-gcc --version >/dev/null 2>&1 ; then crossbindir=/usr/${host}/bin conf_CC="CC=${host}-gcc" @@ -224,7 +249,7 @@ cat < +#include "setenv.h" /* Gnulib replacement. */ + #include "util.h" #include "i18n.h" @@ -529,17 +531,122 @@ } +/* A wrapper around mkdir which takes a string for the mode argument. + This makes it easier to handle the mode argument which is not + defined on all systems. The format of the modestring is + "-rwxrwxrwx" + + '-' is a don't care or not set. 'r', 'w', 'x' are read allowed, + write allowed, execution allowed with the first group for the user, + the second for the group and the third for all others. If the + string is shorter than above the missing mode characters are meant + to be not set. */ +int +gnupg_mkdir (const char *name, const char *modestr) +{ +#ifdef HAVE_W32CE_SYSTEM + wchar_t *wname; + (void)modestr; + + wname = utf8_to_wchar (name); + if (!wname) + return -1; + if (!CreateDirectoryW (wname, NULL)) + { + xfree (wname); + return -1; /* ERRNO is automagically provided by gpg-error.h. */ + } + xfree (wname); + return 0; +#elif MKDIR_TAKES_ONE_ARG + (void)modestr; + /* Note: In the case of W32 we better use CreateDirectory and try to + set appropriate permissions. However using mkdir is easier + because this sets ERRNO. */ + return mkdir (name); +#else + mode_t mode = 0; + if (modestr && *modestr) + { + modestr++; + if (*modestr && *modestr++ == 'r') + mode |= S_IRUSR; + if (*modestr && *modestr++ == 'w') + mode |= S_IWUSR; + if (*modestr && *modestr++ == 'x') + mode |= S_IXUSR; + if (*modestr && *modestr++ == 'r') + mode |= S_IRGRP; + if (*modestr && *modestr++ == 'w') + mode |= S_IWGRP; + if (*modestr && *modestr++ == 'x') + mode |= S_IXGRP; + if (*modestr && *modestr++ == 'r') + mode |= S_IROTH; + if (*modestr && *modestr++ == 'w') + mode |= S_IWOTH; + if (*modestr && *modestr++ == 'x') + mode |= S_IXOTH; + } + return mkdir (home, mode) +#endif +} + + +int +gnupg_setenv (const char *name, const char *value, int overwrite) +{ #ifdef HAVE_W32CE_SYSTEM + (void)name; + (void)value; + (void)overwrite; + return 0; +#else + setenv (name, value, overwrite); +#endif +} + +int +gnupg_unsetenv (const char *name) +{ +#ifdef HAVE_W32CE_SYSTEM + (void)name; + return 0; +#else +# ifdef HAVE_UNSETENV + unsetenv (name); +# else + putenv (name); +# endif +#endif +} + + +#ifdef HAVE_W32CE_SYSTEM /* Replacement for getenv which takes care of the our use of getenv. The code is not thread safe but we expect it to work in all cases because it is called for the first time early enough. */ char * _gnupg_getenv (const char *name) { - (void)name; - return NULL; + static int initialized; + static char *assuan_debug; + + if (!initialized) + { + assuan_debug = read_w32_registry_string (NULL, + "\\Software\\GNU\\libassuan", + "debug"); + initialized = 1; + } + + if (!strcmp (name, "ASSUAN_DEBUG")) + return assuan_debug; + else + return NULL; } + #endif /*HAVE_W32CE_SYSTEM*/ Modified: trunk/common/sysutils.h =================================================================== --- trunk/common/sysutils.h 2010-04-13 01:06:18 UTC (rev 5304) +++ trunk/common/sysutils.h 2010-04-14 11:24:02 UTC (rev 5305) @@ -49,6 +49,9 @@ void gnupg_reopen_std (const char *pgmname); void gnupg_allow_set_foregound_window (pid_t pid); int gnupg_remove (const char *fname); +int gnupg_mkdir (const char *name, const char *modestr); +int gnupg_setenv (const char *name, const char *value, int overwrite); +int gnupg_unsetenv (const char *name); #ifdef HAVE_W32_SYSTEM Modified: trunk/common/util.h =================================================================== --- trunk/common/util.h 2010-04-13 01:06:18 UTC (rev 5304) +++ trunk/common/util.h 2010-04-14 11:24:02 UTC (rev 5305) @@ -298,6 +298,8 @@ #define getpid() GetCurrentProcessId () char *_gnupg_getenv (const char *name); /* See sysutils.c */ #define getenv(a) _gnupg_getenv ((a)) +char *_gnupg_setenv (const char *name); /* See sysutils.c */ +#define setenv(a,b,c) _gnupg_setenv ((a),(b),(c)) #endif Modified: trunk/common/w32help.h =================================================================== --- trunk/common/w32help.h 2010-04-13 01:06:18 UTC (rev 5304) +++ trunk/common/w32help.h 2010-04-14 11:24:02 UTC (rev 5305) @@ -28,5 +28,12 @@ const char *name, const char *value); +/* Other stuff. */ +#ifdef HAVE_W32CE_SYSTEM +/* Setmode is missing in cegcc but available since CE 5.0. */ +int _setmode (int handle, int mode); +# define setmode(a,b) _setmode ((a),(b)) +#endif /*HAVE_W32CE_SYSTEM*/ + #endif /*HAVE_W32_SYSTEM*/ #endif /*LIBJNLIB_MISCHELP_H*/ Modified: trunk/g10/openfile.c =================================================================== --- trunk/g10/openfile.c 2010-04-13 01:06:18 UTC (rev 5304) +++ trunk/g10/openfile.c 2010-04-14 11:24:02 UTC (rev 5305) @@ -56,10 +56,6 @@ #define CMP_FILENAME(a,b) strcmp( (a), (b) ) #endif -#ifdef MKDIR_TAKES_ONE_ARG -#undef mkdir -#define mkdir(a,b) mkdir(a) -#endif /* FIXME: Implement opt.interactive. */ @@ -444,12 +440,11 @@ #endif ) { - if ( mkdir (fname, S_IRUSR|S_IWUSR|S_IXUSR) ) + if (gnupg_mkdir (fname, "-rwx")) log_fatal ( _("can't create directory `%s': %s\n"), fname, strerror(errno) ); else if (!opt.quiet ) log_info ( _("directory `%s' created\n"), fname ); copy_options_file( fname ); - } } Modified: trunk/gl/mkdtemp.c =================================================================== --- trunk/gl/mkdtemp.c 2010-04-13 01:06:18 UTC (rev 5304) +++ trunk/gl/mkdtemp.c 2010-04-14 11:24:02 UTC (rev 5305) @@ -80,6 +80,11 @@ # include #endif +#ifdef HAVE_W32CE_SYSTEM +#include +#define getpid() GetCurrentProcessId () +#endif + #if !_LIBC # define __getpid getpid # define __gettimeofday gettimeofday Modified: trunk/sm/gpgsm.c =================================================================== --- trunk/sm/gpgsm.c 2010-04-13 01:06:18 UTC (rev 5304) +++ trunk/sm/gpgsm.c 2010-04-14 11:24:02 UTC (rev 5305) @@ -434,7 +434,7 @@ static void emergency_cleanup (void); static int check_special_filename (const char *fname, int for_write); static int open_read (const char *filename); -static estream_t open_es_fread (const char *filename); +static estream_t open_es_fread (const char *filename, const char *mode); static FILE *open_fwrite (const char *filename); static estream_t open_es_fwrite (const char *filename); static void run_protect_tool (int argc, char **argv); @@ -942,6 +942,11 @@ opt.homedir = default_homedir (); +#ifdef HAVE_W32CE_SYSTEM + opt.disable_dirmngr = 1; + opt.no_crl_check = 1; +#endif + /* First check whether we have a config file on the commandline */ orig_argc = argc; orig_argv = argv; @@ -1834,9 +1839,9 @@ if (opt.batch) { if (!argc) /* Create from stdin. */ - fpin = open_es_fread ("-"); + fpin = open_es_fread ("-", "r"); else if (argc == 1) /* From file. */ - fpin = open_es_fread (*argv); + fpin = open_es_fread (*argv, "r"); else wrong_args ("--gen-key --batch [parmfile]"); } @@ -2057,7 +2062,7 @@ /* Same as open_read but return an estream_t. */ static estream_t -open_es_fread (const char *filename) +open_es_fread (const char *filename, const char *mode) { int fd; estream_t fp; @@ -2068,7 +2073,7 @@ fd = check_special_filename (filename, 0); if (fd != -1) { - fp = es_fdopen_nc (fd, "rb"); + fp = es_fdopen_nc (fd, mode); if (!fp) { log_error ("es_fdopen(%d) failed: %s\n", fd, strerror (errno)); @@ -2076,7 +2081,7 @@ } return fp; } - fp = es_fopen (filename, "rb"); + fp = es_fopen (filename, mode); if (!fp) { log_error (_("can't open `%s': %s\n"), filename, strerror (errno)); Modified: trunk/sm/misc.c =================================================================== --- trunk/sm/misc.c 2010-04-13 01:06:18 UTC (rev 5304) +++ trunk/sm/misc.c 2010-04-14 11:24:02 UTC (rev 5305) @@ -30,7 +30,7 @@ #include "gpgsm.h" #include "i18n.h" -#include "setenv.h" +#include "sysutils.h" /* Setup the environment so that the pinentry is able to get all required information. This is used prior to an exec of the @@ -49,7 +49,7 @@ but print a warning. */ value = session_env_getenv (opt.session_env, "GPG_TTY"); if (value) - setenv ("GPG_TTY", value, 1); + gnupg_setenv ("GPG_TTY", value, 1); else if (!(lc=getenv ("GPG_TTY")) || !*lc) { log_error (_("GPG_TTY has not been set - " @@ -57,21 +57,21 @@ lc = ttyname (0); if (!lc) lc = "/dev/tty"; - setenv ("GPG_TTY", lc, 1); + gnupg_setenv ("GPG_TTY", lc, 1); } if (opt.lc_ctype) - setenv ("LC_CTYPE", opt.lc_ctype, 1); + gnupg_setenv ("LC_CTYPE", opt.lc_ctype, 1); #if defined(HAVE_SETLOCALE) && defined(LC_CTYPE) else if ( (lc = setlocale (LC_CTYPE, "")) ) - setenv ("LC_CTYPE", lc, 1); + gnupg_setenv ("LC_CTYPE", lc, 1); #endif if (opt.lc_messages) - setenv ("LC_MESSAGES", opt.lc_messages, 1); + gnupg_setenv ("LC_MESSAGES", opt.lc_messages, 1); #if defined(HAVE_SETLOCALE) && defined(LC_MESSAGES) else if ( (lc = setlocale (LC_MESSAGES, "")) ) - setenv ("LC_MESSAGES", lc, 1); + gnupg_setenv ("LC_MESSAGES", lc, 1); #endif iterator = 0; @@ -81,7 +81,7 @@ continue; /* Already set. */ value = session_env_getenv (opt.session_env, name); if (value) - setenv (name, value, 1); + gnupg_setenv (name, value, 1); } #endif /*!HAVE_W32_SYSTEM*/ Modified: trunk/sm/sign.c =================================================================== --- trunk/sm/sign.c 2010-04-13 01:06:18 UTC (rev 5304) +++ trunk/sm/sign.c 2010-04-14 11:24:02 UTC (rev 5305) @@ -503,31 +503,34 @@ /* Check whether one of the certificates is qualified. Note that we already validated the certificate and thus the user data stored flag must be available. */ - for (cl=signerlist; cl; cl = cl->next) + if (!opt.no_chain_validation) { - size_t buflen; - char buffer[1]; - - err = ksba_cert_get_user_data (cl->cert, "is_qualified", - &buffer, sizeof (buffer), &buflen); - if (err || !buflen) + for (cl=signerlist; cl; cl = cl->next) { - log_error (_("checking for qualified certificate failed: %s\n"), - gpg_strerror (err)); - rc = err; - goto leave; + size_t buflen; + char buffer[1]; + + err = ksba_cert_get_user_data (cl->cert, "is_qualified", + &buffer, sizeof (buffer), &buflen); + if (err || !buflen) + { + log_error (_("checking for qualified certificate failed: %s\n"), + gpg_strerror (err)); + rc = err; + goto leave; + } + if (*buffer) + err = gpgsm_qualified_consent (ctrl, cl->cert); + else + err = gpgsm_not_qualified_warning (ctrl, cl->cert); + if (err) + { + rc = err; + goto leave; + } } - if (*buffer) - err = gpgsm_qualified_consent (ctrl, cl->cert); - else - err = gpgsm_not_qualified_warning (ctrl, cl->cert); - if (err) - { - rc = err; - goto leave; - } } - + /* Prepare hashing (actually we are figuring out what we have set above). */ rc = gcry_md_open (&data_md, 0, 0); Modified: trunk/tools/gpg-connect-agent.c =================================================================== --- trunk/tools/gpg-connect-agent.c 2010-04-13 01:06:18 UTC (rev 5304) +++ trunk/tools/gpg-connect-agent.c 2010-04-14 11:24:02 UTC (rev 5305) @@ -210,12 +210,17 @@ for (;;) { buffer = xmalloc (size+1); +#ifdef HAVE_W32CE_SYSTEM + strcpy (buffer, "/"); + return buffer; +#else if (getcwd (buffer, size) == buffer) return buffer; xfree (buffer); if (errno != ERANGE) return NULL; size *= 2; +#endif } } @@ -989,7 +994,8 @@ if (fd >= 0 && fd < DIM (open_fd_table)) { open_fd_table[fd].inuse = 1; -#ifdef HAVE_W32_SYSTEM +#warning fixme: implement our pipe emulation. +#if defined(HAVE_W32_SYSTEM) && !defined(HAVE_W32CE_SYSTEM) { HANDLE prochandle, handle, newhandle; @@ -1197,7 +1203,11 @@ if (log_get_errorcount (0)) exit (2); +#ifdef HAVE_W32CE_SYSTEM + use_tty = 0; +#else use_tty = (isatty ( fileno (stdin)) && isatty (fileno (stdout))); +#endif if (opt.exec) { @@ -1890,7 +1900,11 @@ { if (d->is_prog) { +#ifdef HAVE_W32CE_SYSTEM + fp = NULL; +#else fp = popen (d->file, "r"); +#endif if (!fp) log_error ("error executing `%s': %s\n", d->file, strerror (errno)); @@ -1931,8 +1945,10 @@ ; else if (d->is_prog) { +#ifndef HAVE_W32CE_SYSTEM if (pclose (fp)) log_error ("error running `%s': %s\n", d->file, strerror (errno)); +#endif } else fclose (fp); From cvs at cvs.gnupg.org Wed Apr 14 13:28:54 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 14 Apr 2010 13:28:54 +0200 Subject: [svn] pinentry - r223 - in trunk: . assuan pinentry secmem w32 Message-ID: Author: wk Date: 2010-04-14 13:28:54 +0200 (Wed, 14 Apr 2010) New Revision: 223 Modified: trunk/ChangeLog trunk/NEWS trunk/assuan/assuan-buffer.c trunk/assuan/assuan-pipe-server.c trunk/autogen.sh trunk/configure.ac trunk/pinentry/pinentry.c trunk/pinentry/pinentry.h trunk/secmem/secmem.c trunk/secmem/util.c trunk/w32/Makefile.am trunk/w32/main.c trunk/w32/pinentry-w32.rc Log: The minimal W32 pinnetry may now be used for W32. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-03-03 14:42:33 UTC (rev 222) +++ trunk/ChangeLog 2010-04-14 11:28:54 UTC (rev 223) @@ -1,6 +1,38 @@ +2010-04-12 Werner Koch + + * w32/main.c (dlg_proc): Act on VK_RETURN. + + * w32/pinentry-w32.rc: Include config.h. Add basic support for + small screens as used with WindowsCE. + + * w32/Makefile.am (pinentry-w32.o): Add -I.. to the command. + +2010-04-08 Werner Koch + + * pinentry/pinentry.c [W32CE]: Do not include errno.h and + locale.h. + (pinentry_have_display) [W32CE]: Do not use getenv. + (pinentry_parse_opts) [W32CE]: No error diagnostics due to missing + errno. + (sleep) [W32CE]: New. + (option_handler) [W32CE]: Ignore option --debug-wait. + (getpid) [W32CE]: New. + (pinentry_loop): Use STDIN_FILENO and STDOUT_FILENO. + (pinentry_loop): Factor code out to ... + (pinentry_loop2): New. + * w32/main.c (w32_strerror) [W32CE]: Do not use FormatMessage. + (main) [W32CE]: Do not use LockSetForegroundWindow. + (set_dlg_item_text): Use wchar_t for static string. + * secmem/util.c [W32CE]: Do not include errno.h. + (xwrite) [W32CE]: Shortcut EINTR loop. + +2010-04-07 Werner Koch + + * autogen.sh: Modernized. + 2010-03-03 Werner Koch - Release 0.8.0. + Release 0.8.0. 2010-03-02 Werner Koch @@ -384,7 +416,7 @@ 2007-11-19 Bernhard Herzog (wk) * qt/pinentrydialog.cpp (PinEntryDialog): Fixed crash - + 2007-11-19 Werner Koch * gtk+-2/pinentry-gtk-2.c (create_window): Use again map-event and @@ -552,7 +584,7 @@ 2005-01-27 Werner Koch Released 0.7.2. - + * gtk+-2/Makefile.am: Removed padlock-keyhole.xpm. * configure.ac: Use AC_GNU_SOURCE instead of the custom define. @@ -576,21 +608,21 @@ (dlg_proc): Set 'result' to -1 to indicate cancel. (ok_button_clicked): Adjusted. Set 'result' to the len of the PIN to indicate success. - + 2004-12-22 Werner Koch * w32/main.c: Simplified. * w32/dialog.h, w32/dialog.c, w32/controller.h, w32/controller.c: Removed - + * w32/resource.h, w32/pinentry-w32.rc, w32/main.c, w32/dialog.h * w32/dialog.c, w32/controller.h, w32/controller.c * w32/Makefile.am: New. Based on Timo's work. Update to automake 1.9. - + * autogen.sh (configure_ac): Add --build-w32 option. - * Makefile.am: Support for the W32 pinentry. + * Makefile.am: Support for the W32 pinentry. * configure.ac: Ditto. Reformatted some error messages. Define the usual conditionals for W32. Check for a couple of more usually required headers. @@ -601,7 +633,7 @@ (pinentry_loop) [DOSISH]: Don't do uid check. * secmem/util.c [DOSISH]: Disable UID stuff. - + 2004-09-27 Marcus Brinkmann * acinclude.m4 (IU_LIB_NCURSES, IU_LIB_CURSES, IU_LIB_TERMCAP): @@ -642,7 +674,7 @@ (SUBDIRS): Add pinentry_gtk_2. Submitted by Albrecht Dress albrecht.dress at arcor.de. - + 2004-08-04 Werner Koch * pinentry/pinentry.c (usage): Print help to stdout. @@ -748,9 +780,9 @@ (pinentry_init): Add arg PGMNAME and store it. Use it at all marked placed instead of the constant "pinentry". (usage): Use it here too. - * curses/pinentry-curses.c (main): Call pinentry_init with our name. + * curses/pinentry-curses.c (main): Call pinentry_init with our name. * qt/main.cpp (main): Ditto. - * gtk/pinentry-gtk.c (main): Ditto. + * gtk/pinentry-gtk.c (main): Ditto. * configure.ac: Check for mmap. @@ -768,7 +800,7 @@ * qt/main.cpp (main): Ditto. Fixed typo. * gtk/pinentry-gtk.c: Include memory.h. - + 2003-12-20 Marcus Brinkmann * pinentry/pinentry.h (struct pinentry): New member PARENT_WID. @@ -834,7 +866,7 @@ * qt/pinentrydialog.h: Declare SecQString and SecQLineEdit classes. (class PinEntryDialog): Disable property text (for now). Adjust argument of setText and return value of text, as well as type of - _edit. + _edit. 2003-12-09 Werner Koch @@ -862,7 +894,7 @@ 2003-02-15 Steffen Hansen - * qt/pinentrydialog.h, qt/pinentrydialog.cpp: Added icons + * qt/pinentrydialog.h, qt/pinentrydialog.cpp: Added icons for error/non-error messages. 2003-02-07 Marcus Brinkmann @@ -871,7 +903,7 @@ 2003-02-04 Steffen Hansen - * qt/main.cpp: Work around '--display' option. This fixes + * qt/main.cpp: Work around '--display' option. This fixes the pinentry-qt problem reported by several people lately. 2003-01-24 Werner Koch @@ -905,7 +937,7 @@ 2002-11-08 Werner Koch - * pinentry/pinentry-curses.c (convert_utf8_string): Renamed to + * pinentry/pinentry-curses.c (convert_utf8_string): Renamed to * pinentry/pinentry.c (pinentry_utf8_to_local): this. Changed callers. (pinentry_local_to_utf8): New. @@ -930,7 +962,7 @@ * pinentry/pinentry.c: Include headers for getpid and sleep prototypes. - * secmem/util.h: Correctly declare functions taking no args. + * secmem/util.h: Correctly declare functions taking no args. * gtk/pinentry-gtk.c: Move gtk headers to the top to avoid compiler warnings about shadowing index etc. @@ -956,7 +988,7 @@ 2002-09-30 Werner Koch Released 0.6.5. - + * qt/pinentrycontroller.cpp (optionHandler): Make sure that a value is returned. * configure.ac: Use -Wall also for C++. @@ -976,12 +1008,12 @@ 2002-05-24 Werner Koch * AUTHORS: Added Marcus - * README: Fixed spelling of Quintuple-Agent. + * README: Fixed spelling of Quintuple-Agent. 2002-05-13 Marcus Brinkmann Released 0.6.2. - + * configure.ac: Set version number to 0.6.2. * NEWS: Add information for 0.6.2. * README: Update for release. @@ -1121,7 +1153,7 @@ * configure.ac: Use the new Qt checks instead the KDE checks. Replace "kde" with "qt" everywhere. * Makefile.am: Replace "kde" with "qt" everywhere. - + 2002-04-06 Marcus Brinkmann * acinclude.m4: Reworked the Qt and KDE checks, cutting out a lot @@ -1137,7 +1169,7 @@ 2002-04-05 Marcus Brinkmann Released 0.6.0. - + * configure.ac: Set version number to 0.6. * NEWS: Add information for 0.6.0. * secmem/Makefile.am (libsecmem_a_SOURCES): Replace secmem.h with memory. @@ -1295,7 +1327,7 @@ 2002-01-04 Werner Koch Released 0.5.0. - + * configure.ac: Bumbed version * util.h (xtoi_1, xtoi_2): New. @@ -1308,7 +1340,7 @@ 2001-12-07 Werner Koch New package gpinentry based on quintuple-agent. - + Removed all stuff except for the basic configuration stuff and what is needed to build gpinentry. Also removed i18n support. * gpinentry.c: Renamed from secret-query.c @@ -1409,7 +1441,7 @@ Close stdout (and stderr unless debugging) even when not forking, so that normal usage inside eval is still possible. (agent): Exit gracefully on HUP, so that logging out now kills the - agent. + agent. * README (Contact Information): Old URL - duh! (Using Secret Agent): We no longer fork per default. @@ -1495,7 +1527,7 @@ 1999-11-08 Robert Bihlmeyer - * agent.h (request_put): Add flags, deadline. Increase REQUEST_MAGIC. + * agent.h (request_put): Add flags, deadline. Increase REQUEST_MAGIC. (reply_get): Ditto, and increase REPLY_MAGIC. * agent.c (store): Store flags, deadline in reply. (do_put): Hand flags, deadline from request on to store(). @@ -1546,7 +1578,7 @@ (store): Set magic number in stored reply. (do_put): Set magic number in reply. (do_delete): Ditto. - (do_list): Ditto. + (do_list): Ditto. (agent): Check magic number in request. * agentlib.c: Adapted. (send_request): Set magic number in request. Check it in reply. @@ -1762,7 +1794,7 @@ (main): Use it. * Makefile.am (INCLUDES): Put GTK_FLAGS and GLIB_FLAGS here. It - is the easiest way for sources needing it, and it won't hurt those + is the easiest way for sources needing it, and it won't hurt those that don't. (agent.o): Explicit command removed accordingly. @@ -1848,7 +1880,7 @@ Make --debug switch cumulative. (cleanup): Shutdown secmem. (do_put): Use secmem for storage of secrets. - (do_delete): Use secmem_free(). Since this wipes the memory on its + (do_delete): Use secmem_free(). Since this wipes the memory on its own, wipe() is superflous now. (agent): Use secmem for inbound requests. (delete_secret): New function, takes part of do_delete's @@ -1880,7 +1912,7 @@ Include i18n.h. * agentlib.c: Include i18n.h - + * client.c (usage): New function. Usage-message made gettext-friendly. (xgetpass): Use perror() instead of fprintf(). @@ -1921,8 +1953,8 @@ Check for socklen_t. * acconfig.h: Added a definition for it. - * client.c: Include packaged getopt.h if the system doesn't provide - one. + * client.c: Include packaged getopt.h if the system doesn't provide + one. * agent.c: Ditto. (create_socket): Replace AF_FILE, PF_FILE with AF_LOCAL, PF_LOCAL for portability. @@ -1944,7 +1976,7 @@ * NEWS: Updated. - * Makefile.am (agent.o): Mentioning the source explicitly does not + * Makefile.am (agent.o): Mentioning the source explicitly does not work for srcdir!=builddir. * client.c (main): Function arguments are not always evaluated in @@ -1973,7 +2005,7 @@ * Makefile.am (client_SOURCES): Added agentlib.c, agentlib.h. * Makefile.am (INCLUDES): GLIB_CFLAGS moved again, this time to - the agent.o target. + the agent.o target. 1999-06-15 Robert Bihlmeyer @@ -2005,7 +2037,7 @@ (do_list): Use it. (do_put): The hash key was overwritten - strdup it. Construct a GET reply and save that in the hash. - (do_get): Just send the preconstructed reply if the id is present, + (do_get): Just send the preconstructed reply if the id is present, and failed_reply otherwise. (do_delete): Actually free the hashed stuff. @@ -2014,11 +2046,11 @@ * Makefile.am (EXTRA_DIST): Added autogen.sh, Thoughts, client-test. (TESTS): Added client-test. - (AUTOMAKE_OPTIONS): Added gnits. + (AUTOMAKE_OPTIONS): Added gnits. - - Copyright 2002, 2003 g10 Code GmbH + Copyright 2002, 2003, 2010 g10 Code GmbH + This file is free software; as a special exception the author gives unlimited permission to copy and/or distribute it, with or without modifications, as long as this notice is preserved. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2010-03-03 14:42:33 UTC (rev 222) +++ trunk/NEWS 2010-04-14 11:28:54 UTC (rev 223) @@ -1,3 +1,9 @@ +Noteworthy changes in version 0.8.1 (unreleased) +------------------------------------------------ + + * The W32 pinentry now supports WindowsCE. + + Noteworthy changes in version 0.8.0 (2010-03-03) ------------------------------------------------ Modified: trunk/assuan/assuan-buffer.c =================================================================== --- trunk/assuan/assuan-buffer.c 2010-03-03 14:42:33 UTC (rev 222) +++ trunk/assuan/assuan-buffer.c 2010-04-14 11:28:54 UTC (rev 223) @@ -22,19 +22,34 @@ #include #include #include -#include +#ifndef HAVE_W32CE_SYSTEM +# include +#endif #include #include #ifdef USE_GNU_PTH # include #endif +#ifdef HAVE_W32CE_SYSTEM +# include +#endif + #include "assuan-defs.h" #ifdef HAVE_JNLIB_LOGGING #include "../jnlib/logging.h" #endif +#ifdef HAVE_W32CE_SYSTEM +const char * +strerror (int e) +{ + return "error"; +} +static int errno; +#endif + static const char * my_log_prefix (void) { @@ -51,16 +66,25 @@ { while (length) { -#ifdef USE_GNU_PTH - int nwritten = pth_write (fd, buffer, length); + int nwritten; +#ifdef HAVE_W32CE_SYSTEM + do + { + if (!WriteFile ((HANDLE)fd, buffer, length, &nwritten, NULL)) + nwritten = -1; + } + while (nwritten == -1 && GetLastError () == ERROR_PIPE_NOT_CONNECTED); +#elif defined(USE_GNU_PTH) + nwritten = pth_write (fd, buffer, length); #else - int nwritten = write (fd, buffer, length); + nwritten = write (fd, buffer, length); #endif - if (nwritten < 0) { +#ifndef HAVE_W32CE_SYSTEM if (errno == EINTR) continue; +#endif return -1; /* write error */ } length -= nwritten; @@ -79,15 +103,25 @@ *r_nread = 0; while (nleft > 0) { -#ifdef USE_GNU_PTH - int n = pth_read (fd, buf, nleft); + int n; +#ifdef HAVE_W32CE_SYSTEM + do + { + if (!ReadFile ((HANDLE)fd, buf, nleft, &n, NULL)) + n = -1; + } + while (n == -1 && GetLastError () == ERROR_PIPE_NOT_CONNECTED); +#elif defined(USE_GNU_PTH) + n = pth_read (fd, buf, nleft); #else - int n = read (fd, buf, nleft); + n = read (fd, buf, nleft); #endif if (n < 0) { +#ifndef HAVE_W32CE_SYSTEM if (errno == EINTR) continue; +#endif return -1; /* read error */ } else if (!n) Modified: trunk/assuan/assuan-pipe-server.c =================================================================== --- trunk/assuan/assuan-pipe-server.c 2010-03-03 14:42:33 UTC (rev 222) +++ trunk/assuan/assuan-pipe-server.c 2010-04-14 11:28:54 UTC (rev 223) @@ -46,7 +46,7 @@ /* Create a new context. Note that the handlers are set up for a pipe - server/client - this wau we don't need extra dummy functions */ + server/client - this way we don't need extra dummy functions */ int _assuan_new_context (ASSUAN_CONTEXT *r_ctx) { Modified: trunk/autogen.sh =================================================================== --- trunk/autogen.sh 2010-03-03 14:42:33 UTC (rev 222) +++ trunk/autogen.sh 2010-04-14 11:28:54 UTC (rev 223) @@ -45,10 +45,48 @@ shift fi +# Begin list of optional variables sourced from ~/.gnupg-autogen.rc +w32_toolprefixes= +w32_extraoptions= +w32ce_toolprefixes= +w32ce_extraoptions= +amd64_toolprefixes= +# End list of optional variables sourced from ~/.gnupg-autogen.rc +# What follows are variables which are sourced but default to +# environment variables or lacking them hardcoded values. +#w32root= +#w32ce_root= +#amd64root= +if [ -f "$HOME/.gnupg-autogen.rc" ]; then + echo "sourcing extra definitions from $HOME/.gnupg-autogen.rc" + . "$HOME/.gnupg-autogen.rc" +fi + +# Convenience option to use certain configure options for some hosts. +myhost="" +myhostsub="" +case "$1" in + --build-w32) + myhost="w32" + ;; + --build-w32ce) + myhost="w32" + myhostsub="ce" + ;; + --build*) + echo "**Error**: invalid build option $1" >&2 + exit 1 + ;; + *) + ;; +esac + + + # ***** W32 build script ******* # Used to cross-compile for Windows. -if test "$1" = "--build-w32"; then +if [ "$myhost" = "w32" ]; then tmp=`dirname $0` tsdir=`cd "$tmp"; pwd` shift @@ -58,13 +96,26 @@ fi build=`$tsdir/config.guess` - [ -z "$w32root" ] && w32root="$HOME/w32root" + case $myhostsub in + ce) + [ -z "$w32ce_root" ] && w32root="$HOME/w32ce_root" + toolprefixes="$w32ce_toolprefixes arm-mingw32ce" + extraoptions="$w32ce_extraoptions --disable-pinentry-gtk2" + extraoptions="$extraoptions --disable-pinentry-qt4" + ;; + *) + [ -z "$w32root" ] && w32root="$HOME/w32root" + toolprefixes="$w32_toolprefixes i586-mingw32msvc" + toolprefixes="$toolprefixes i386-mingw32msvc mingw32" + extraoptions="$w32_extraoptions --enable-pinentry-gtk2" + ;; + esac echo "Using $w32root as standard install directory" >&2 # Locate the cross compiler crossbindir= - for host in i586-mingw32msvc i386-mingw32msvc mingw32; do + for host in $toolprefixes; do if ${host}-gcc --version >/dev/null 2>&1 ; then crossbindir=/usr/${host}/bin conf_CC="CC=${host}-gcc" @@ -73,8 +124,10 @@ 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 + if [ -z "$sub" ]; then + echo "Under Debian GNU/Linux, you may install it using" >&2 + echo " apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2 + fi echo "Stop." >&2 exit 1 fi @@ -89,11 +142,10 @@ ./configure --enable-maintainer-mode --prefix=${w32root} \ --host=${host} --build=${build} \ --disable-pinentry-gtk \ - --enable-pinentry-gtk2 \ --disable-pinentry-qt \ - --with-lib-prefix=${w32root} \ --with-libiconv-prefix=${w32root} \ - PKG_CONFIG_LIBDIR="$w32root/lib/pkgconfig" "$@" + PKG_CONFIG_LIBDIR="$w32root/lib/pkgconfig" \ + ${extraoptions} "$@" rc=$? exit $rc @@ -158,4 +210,6 @@ echo "Running autoconf${FORCE}..." $AUTOCONF${FORCE} -echo "You may now run \"./configure --enable-maintainer-mode && make\"." +echo "You may now run: + ./configure --enable-maintainer-mode && make +" Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2010-03-03 14:42:33 UTC (rev 222) +++ trunk/configure.ac 2010-04-14 11:28:54 UTC (rev 223) @@ -31,8 +31,8 @@ # specific feature can already be done under the assumption that the # SVN version is the most recent one in a branch. To disable the SVN # version for the real release, set the my_issvn macro to no. -m4_define(my_version, [0.8.0]) -m4_define(my_issvn, [no]) +m4_define(my_version, [0.8.1]) +m4_define(my_issvn, [yes]) m4_define([svn_revision], m4_esyscmd([printf "%d" $(svn info 2>/dev/null \ | sed -n '/^Revision:/ s/[^0-9]//gp'|head -1)])) @@ -71,14 +71,22 @@ have_dosish_system=no have_w32_system=no +have_w32ce_system=no case "${host}" in *-mingw32*) AC_DEFINE(USE_ONLY_8DOT3,1, - [set this to limit filenames to the 8.3 format]) - AC_DEFINE(HAVE_DRIVE_LETTERS,1, - [defined if we must run on a stupid file system]) + [Set this to limit filenames to the 8.3 format]) have_dosish_system=yes have_w32_system=yes + case "${host}" in + *-mingw32ce*) + have_w32ce_system=yes + ;; + *) + AC_DEFINE(HAVE_DRIVE_LETTERS,1, + [Defined if the OS supports drive letters.]) + ;; + esac ;; i?86-emx-os2 | i?86-*-os2*emx ) # OS/2 with the EMX environment @@ -103,8 +111,12 @@ if test "$have_w32_system" = yes; then AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system]) + if test "$have_w32ce_system" = yes; then + AC_DEFINE(HAVE_W32CE_SYSTEM,1,[Defined if we run on WindowsCE]) + fi fi AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes) +AM_CONDITIONAL(HAVE_W32CE_SYSTEM, test "$have_w32ce_system" = yes) Modified: trunk/pinentry/pinentry.c =================================================================== --- trunk/pinentry/pinentry.c 2010-03-03 14:42:33 UTC (rev 222) +++ trunk/pinentry/pinentry.c 2010-04-14 11:28:54 UTC (rev 223) @@ -21,16 +21,23 @@ #include #endif -#include +#ifndef HAVE_W32CE_SYSTEM +# include +#endif #include #include #include #include -#include +#ifndef HAVE_W32CE_SYSTEM +# include +#endif #ifdef HAVE_LANGINFO_H #include #endif #include +#ifdef HAVE_W32CE_SYSTEM +# include +#endif #if defined FALLBACK_CURSES || defined PINENTRY_CURSES || defined PINENTRY_GTK #include @@ -41,6 +48,9 @@ #include "secmem-util.h" #include "pinentry.h" +#ifdef HAVE_W32CE_SYSTEM +#define getpid() GetCurrentProcessId () +#endif /* Keep the name of our program here. */ static char this_pgmname[50]; @@ -87,7 +97,6 @@ }; - #if defined FALLBACK_CURSES || defined PINENTRY_CURSES || defined PINENTRY_GTK char * pinentry_utf8_to_local (char *lc_ctype, char *text) @@ -377,11 +386,13 @@ int pinentry_have_display (int argc, char **argv) { +#ifndef HAVE_W32CE_SYSTEM const char *s; s = getenv ("DISPLAY"); if (s && *s) return 1; +#endif for (; argc; argc--, argv++) if (!strcmp (*argv, "--display")) return 1; @@ -516,7 +527,9 @@ pinentry.display = strdup (optarg); if (!pinentry.display) { +#ifndef HAVE_W32CE_SYSTEM fprintf (stderr, "%s: %s\n", this_pgmname, strerror (errno)); +#endif exit (EXIT_FAILURE); } break; @@ -524,7 +537,9 @@ pinentry.ttyname = strdup (optarg); if (!pinentry.ttyname) { +#ifndef HAVE_W32CE_SYSTEM fprintf (stderr, "%s: %s\n", this_pgmname, strerror (errno)); +#endif exit (EXIT_FAILURE); } break; @@ -532,7 +547,9 @@ pinentry.ttytype = strdup (optarg); if (!pinentry.ttytype) { +#ifndef HAVE_W32CE_SYSTEM fprintf (stderr, "%s: %s\n", this_pgmname, strerror (errno)); +#endif exit (EXIT_FAILURE); } break; @@ -540,7 +557,9 @@ pinentry.lc_ctype = strdup (optarg); if (!pinentry.lc_ctype) { +#ifndef HAVE_W32CE_SYSTEM fprintf (stderr, "%s: %s\n", this_pgmname, strerror (errno)); +#endif exit (EXIT_FAILURE); } break; @@ -548,7 +567,9 @@ pinentry.lc_messages = strdup (optarg); if (!pinentry.lc_messages) { +#ifndef HAVE_W32CE_SYSTEM fprintf (stderr, "%s: %s\n", this_pgmname, strerror (errno)); +#endif exit (EXIT_FAILURE); } break; @@ -590,10 +611,12 @@ pinentry.grab = 1; else if (!strcmp (key, "debug-wait")) { +#ifndef HAVE_W32CE_SYSTEM fprintf (stderr, "%s: waiting for debugger - my pid is %u ...\n", this_pgmname, (unsigned int) getpid()); sleep (*value?atoi (value):5); fprintf (stderr, "%s: ... okay\n", this_pgmname); +#endif } else if (!strcmp (key, "display")) { @@ -908,7 +931,7 @@ } -/* Note that the option --one-button is hack to allow the use of old +/* Note that the option --one-button is a hack to allow the use of old pinentries while the caller is ignoring the result. Given that options have never been used or flagged as an error the new option is an easy way to enable the messsage mode while not requiring to @@ -1033,11 +1056,8 @@ } -/* Start the pinentry event loop. The program will start to process - Assuan commands until it is finished or an error occurs. If an - error occurs, -1 is returned. Otherwise, 0 is returned. */ int -pinentry_loop (void) +pinentry_loop2 (int infd, int outfd) { int rc; int filedes[2]; @@ -1052,8 +1072,8 @@ /* 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. */ - filedes[0] = 0; - filedes[1] = 1; + filedes[0] = infd; + filedes[1] = outfd; rc = assuan_init_pipe_server (&ctx, filedes); if (rc) { @@ -1098,3 +1118,13 @@ assuan_deinit_server (ctx); return 0; } + + +/* Start the pinentry event loop. The program will start to process + Assuan commands until it is finished or an error occurs. If an + error occurs, -1 is returned. Otherwise, 0 is returned. */ +int +pinentry_loop (void) +{ + return pinentry_loop2 (STDIN_FILENO, STDOUT_FILENO); +} Modified: trunk/pinentry/pinentry.h =================================================================== --- trunk/pinentry/pinentry.h 2010-03-03 14:42:33 UTC (rev 222) +++ trunk/pinentry/pinentry.h 2010-04-14 11:28:54 UTC (rev 223) @@ -147,7 +147,10 @@ error. Otherwise, 0 is returned. */ int pinentry_loop (void); +/* The same as above but allows to specify the i/o descriptors. */ +int pinentry_loop2 (int infd, int outfd); + /* Convert the UTF-8 encoded string TEXT to the encoding given in LC_CTYPE. Return NULL on error. */ char *pinentry_utf8_to_local (char *lc_ctype, char *text); Modified: trunk/secmem/secmem.c =================================================================== --- trunk/secmem/secmem.c 2010-03-03 14:42:33 UTC (rev 222) +++ trunk/secmem/secmem.c 2010-04-14 11:28:54 UTC (rev 223) @@ -21,7 +21,9 @@ #include #include #include +#ifndef HAVE_W32CE_SYSTEM #include +#endif #include #include #if defined(HAVE_MLOCK) || defined(HAVE_MMAP) Modified: trunk/secmem/util.c =================================================================== --- trunk/secmem/util.c 2010-03-03 14:42:33 UTC (rev 222) +++ trunk/secmem/util.c 2010-04-14 11:28:54 UTC (rev 223) @@ -19,7 +19,9 @@ #define _GNU_SOURCE 1 #include -#include +#ifdef HAVE_W32CE_SYSTEM +# include +#endif #include #include #include @@ -50,7 +52,13 @@ { do written = write (fd, ptr, todo); - while (written == -1 && errno == EINTR); + while ( +#ifdef HAVE_W32CE_SYSTEM + 0 +#else + written == -1 && errno == EINTR +#endif + ); if (written < 0) break; } Modified: trunk/w32/Makefile.am =================================================================== --- trunk/w32/Makefile.am 2010-03-03 14:42:33 UTC (rev 222) +++ trunk/w32/Makefile.am 2010-04-14 11:28:54 UTC (rev 223) @@ -36,5 +36,5 @@ pinentry-w32.o: pinentry-w32.rc resource.h - $(WINDRES) -v -o $@ $< + $(WINDRES) -I.. -v -o $@ $< Modified: trunk/w32/main.c =================================================================== --- trunk/w32/main.c 2010-03-03 14:42:33 UTC (rev 222) +++ trunk/w32/main.c 2010-04-14 11:28:54 UTC (rev 223) @@ -21,6 +21,10 @@ #include #define WINVER 0x0403 /* Required for SendInput. */ #include +#ifdef HAVE_W32CE_SYSTEM +# include +# include +#endif #include "pinentry.h" #include "memory.h" @@ -37,9 +41,10 @@ /* This function pointer gets initialized in main. */ +#ifndef HAVE_W32CE_SYSTEM static WINUSERAPI BOOL WINAPI (*lock_set_foreground_window)(UINT); +#endif - static int w32_cmd_handler (pinentry_t pe); static void ok_button_clicked (HWND dlg, pinentry_t pe); @@ -51,10 +56,12 @@ static int passphrase_ok; static int confirm_yes; -static FILE *debugfp; +/* The file descriptors for the loop. */ +static int w32_infd; +static int w32_outfd; -/* Connect this module to the pinnetry framework. */ +/* Connect this module to the pinentry framework. */ pinentry_cmd_handler_t pinentry_cmd_handler = w32_cmd_handler; @@ -66,13 +73,51 @@ if (ec == -1) ec = (int)GetLastError (); +#ifdef HAVE_W32CE_SYSTEM + /* There is only a wchar_t FormatMessage. It does not make much + sense to play the conversion game; we print only the code. */ + snprintf (strerr, sizeof strerr, "ec=%d", ec); +#else FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, ec, MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), strerr, sizeof strerr - 1, NULL); +#endif return strerr; } + +#ifdef HAVE_W32CE_SYSTEM +/* Create a pipe. WRITE_END shall have the opposite value of the one + pssed to _assuan_w32ce_prepare_pipe; see there for more + details. */ +#define GPGCEDEV_IOCTL_MAKE_PIPE \ + CTL_CODE (FILE_DEVICE_STREAMS, 2049, METHOD_BUFFERED, FILE_ANY_ACCESS) +static HANDLE +w32ce_finish_pipe (int rvid, int write_end) +{ + HANDLE hd; + + hd = CreateFile (L"GPG1:", write_end? GENERIC_WRITE : GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL,NULL); + if (hd != INVALID_HANDLE_VALUE) + { + if (!DeviceIoControl (hd, GPGCEDEV_IOCTL_MAKE_PIPE, + &rvid, sizeof rvid, NULL, 0, NULL, NULL)) + { + DWORD lastrc = GetLastError (); + CloseHandle (hd); + hd = INVALID_HANDLE_VALUE; + SetLastError (lastrc); + } + } + + return hd; +} +#endif /*HAVE_W32CE_SYSTEM*/ + + /* static HWND */ /* show_window_hierarchy (HWND parent, int level) */ /* { */ @@ -161,11 +206,32 @@ } +/* Raie the software input panel. */ +#ifdef HAVE_W32CE_SYSTEM +static void +raise_sip (HWND dlg) +{ + SIPINFO si; + + SetForegroundWindow (dlg); + + memset (&si, 0, sizeof si); + si.cbSize = sizeof si; + + if (SipGetInfo (&si)) + { + si.fdwFlags |= SIPF_ON; + SipSetInfo (&si); + } +} +#endif + /* Center the window CHILDWND with the desktop as its parent window. STYLE is passed as second arg to SetWindowPos.*/ static void center_window (HWND childwnd, HWND style) { +#ifndef HAVE_W32CE_SYSTEM HWND parwnd; RECT rchild, rparent; HDC hdc; @@ -199,6 +265,7 @@ if (style == HWND_TOPMOST || style == HWND_NOTOPMOST) flags = SWP_NOMOVE | SWP_NOSIZE; SetWindowPos (childwnd, style? style : NULL, xnew, ynew, 0, 0, flags); +#endif } @@ -206,6 +273,7 @@ static void move_mouse_and_click (HWND hwnd) { +#ifndef HAVE_W32CE_SYSTEM RECT rect; HDC hdc; int wscreen, hscreen, x, y, normx, normy; @@ -250,6 +318,7 @@ if ( SendInput (idx, inp, sizeof (INPUT)) != idx && debugfp ) fprintf (debugfp, "SendInput failed: %s\n", w32_strerror (-1)); +#endif } @@ -278,14 +347,14 @@ set_dlg_item_text (HWND dlg, int item, const char *string) { if (!string || !*string) - SetDlgItemText (dlg, item, ""); + SetDlgItemTextW (dlg, item, L""); else { wchar_t *wbuf; wbuf = utf8_to_wchar (string); if (!wbuf) - SetDlgItemText (dlg, item, "[out of core]"); + SetDlgItemTextW (dlg, item, L"[out of core]"); else { SetDlgItemTextW (dlg, item, wbuf); @@ -364,7 +433,7 @@ ShowWindow (dlg, SW_SHOW); move_mouse_and_click ( GetDlgItem (dlg, IDC_PINENT_PROMPT) ); - + raise_sip (dlg); break; case WM_COMMAND: @@ -384,6 +453,18 @@ break; } break; + + case WM_KEYDOWN: + if (wparam == VK_RETURN) + { + if (confirm_mode) + confirm_yes = 1; + else + ok_button_clicked (dlg, pe); + EndDialog (dlg, TRUE); + } + break; + } return FALSE; } @@ -451,19 +532,99 @@ } +/* WindowsCE uses a very strange way of handling the standard streams. + There is a function SetStdioPath to associate a standard stream + with a file or a device but what we really want is to use pipes as + standard streams. Despite that we implement pipes using a device, + we would have some limitations on the number of open pipes due to + the 3 character limit of device file name. Thus we don't take this + path. Another option would be to install a file system driver with + support for pipes; this would allow us to get rid of the device + name length limitation. However, with GnuPG we can get away be + redefining the standard streams and passing the handles to be used + on the command line. This has also the advantage that it makes + creating a process much easier and does not require the + SetStdioPath set and restore game. The caller needs to pass the + rendezvous ids using up to three options: + + -&S0= -&S1= -&S2= + + They are all optional but they must be the first arguments on the + command line. Parsing stops as soon as an invalid option is found. + These rendezvous ids are then used to finish the pipe creation.*/ +#ifdef HAVE_W32CE_SYSTEM +static void +parse_std_file_handles (int *argcp, char ***argvp) +{ + int argc = *argcp; + char **argv = *argvp; + const char *s; + int fd; + int i; + int fixup = 0; + + if (!argc) + return; + + for (argc--, argv++; argc; argc--, argv++) + { + s = *argv; + if (*s == '-' && s[1] == '&' && s[2] == 'S' + && (s[3] == '0' || s[3] == '1' || s[3] == '2') + && s[4] == '=' + && (strchr ("-01234567890", s[5]) || !strcmp (s+5, "null"))) + { + if (s[5] == 'n') + fd = (int)(-1); + else + fd = (int)w32ce_finish_pipe (atoi (s+5), s[3] != '0'); + if (s[3] == '0' && fd != -1) + w32_infd = fd; + else if (s[3] == '1' && fd != -1) + w32_outfd = fd; + fixup++; + } + else + break; + } + + if (fixup) + { + argc = *argcp; + argc -= fixup; + *argcp = argc; + + argv = *argvp; + for (i=1; i < argc; i++) + argv[i] = argv[i + fixup]; + for (; i < argc + fixup; i++) + argv[i] = NULL; + } + + +} +#endif /*HAVE_W32CE_SYSTEM*/ + + int main (int argc, char **argv) { +#ifndef HAVE_W32CE_SYSTEM void *handle; +#endif + w32_infd = STDIN_FILENO; + w32_outfd = STDOUT_FILENO; + +#ifdef HAVE_W32CE_SYSTEM + parse_std_file_handles (&argc, &argv); +#endif + pinentry_init (PGMNAME); /* Consumes all arguments. */ if (pinentry_parse_opts (argc, argv)) - { - printf ("pinentry-w32 (pinentry) " VERSION "\n"); - exit (EXIT_SUCCESS); - } + exit (EXIT_SUCCESS); /* debugfp = fopen ("pinentry.log", "w"); */ /* if (!debugfp) */ @@ -471,6 +632,7 @@ /* We need to load a function because that one is only available since W2000 but not in older NTs. */ +#ifndef HAVE_W32CE_SYSTEM handle = LoadLibrary ("user32.dll"); if (handle) { @@ -481,9 +643,13 @@ else CloseHandle (handle); } +#endif - if (pinentry_loop ()) + if (pinentry_loop2 (w32_infd, w32_outfd)) return 1; +#ifdef HAVE_W32CE_SYSTEM + Sleep (400); +#endif return 0; } Modified: trunk/w32/pinentry-w32.rc =================================================================== --- trunk/w32/pinentry-w32.rc 2010-03-03 14:42:33 UTC (rev 222) +++ trunk/w32/pinentry-w32.rc 2010-04-14 11:28:54 UTC (rev 223) @@ -1,5 +1,5 @@ -/* dialog.rc - Resource definitions - Copyright (C) 2004 g10 Code GmbH +/* dialog.rc - Resource definitions -*- c -*- + Copyright (C) 2004, 2010 g10 Code GmbH This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -16,7 +16,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ - +#include #include #include "resource.h" @@ -24,6 +24,26 @@ * Main dialog */ +#ifdef HAVE_W32CE_SYSTEM + +IDD_PINENT DIALOG DISCARDABLE 0, 0, 150, 100 +STYLE DS_MODALFRAME | DS_SYSMODAL | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Pinentry" +FONT 8, "MS Shell Dlg" +BEGIN + LTEXT "", IDC_PINENT_DESC, 2, 2, 140, 24 + LTEXT "", IDC_PINENT_ERR, 2, 30, 140, 12 + + LTEXT "", IDC_PINENT_PROMPT, 2, 56, 20, 12 + EDITTEXT IDC_PINENT_TEXT, 30, 56, 100, 12, ES_PASSWORD | ES_AUTOHSCROLL + + DEFPUSHBUTTON "O&K", IDOK, 2, 70, 50, 14 + PUSHBUTTON "&Cancel", IDCANCEL, 60, 70, 50, 14 + +END + +#else /* Standard Windows. */ + IDD_PINENT DIALOG DISCARDABLE 0, 0, 186, 125 STYLE DS_MODALFRAME | DS_SYSMODAL | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Pinentry" @@ -37,5 +57,6 @@ LTEXT "", IDC_PINENT_ERR, 6, 82, 170, 9 END +#endif /* Standard Windows. */ From cvs at cvs.gnupg.org Wed Apr 14 16:32:07 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 14 Apr 2010 16:32:07 +0200 Subject: [svn] gpg-error - r239 - trunk Message-ID: Author: wk Date: 2010-04-14 16:32:07 +0200 (Wed, 14 Apr 2010) New Revision: 239 Modified: trunk/autogen.sh Log: Updated. Modified: trunk/autogen.sh =================================================================== --- trunk/autogen.sh 2010-04-14 10:57:58 UTC (rev 238) +++ trunk/autogen.sh 2010-04-14 14:32:07 UTC (rev 239) @@ -35,6 +35,24 @@ shift fi +# Begin list of optional variables sourced from ~/.gnupg-autogen.rc +w32_toolprefixes= +w32_extraoptions= +w32ce_toolprefixes= +w32ce_extraoptions= +amd64_toolprefixes= +# End list of optional variables sourced from ~/.gnupg-autogen.rc +# What follows are variables which are sourced but default to +# environment variables or lacking them hardcoded values. +#w32root= +#w32ce_root= +#amd64root= + +if [ -f "$HOME/.gnupg-autogen.rc" ]; then + echo "sourcing extra definitions from $HOME/.gnupg-autogen.rc" + . "$HOME/.gnupg-autogen.rc" +fi + # Convenience option to use certain configure options for some hosts. myhost="" myhostsub="" @@ -46,8 +64,12 @@ myhost="w32" myhostsub="ce" ;; + --build*) + echo "**Error**: invalid build option $1" >&2 + exit 1 + ;; *) - ;; + ;; esac @@ -66,6 +88,7 @@ case $myhostsub in ce) + w32root="$w32ce_root" [ -z "$w32root" ] && w32root="$HOME/w32ce_root" toolprefixes="arm-mingw32ce" ;; From cvs at cvs.gnupg.org Wed Apr 14 16:32:19 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 14 Apr 2010 16:32:19 +0200 Subject: [svn] w32pth - r36 - trunk Message-ID: Author: wk Date: 2010-04-14 16:32:19 +0200 (Wed, 14 Apr 2010) New Revision: 36 Modified: trunk/autogen.sh Log: Udpated Modified: trunk/autogen.sh =================================================================== --- trunk/autogen.sh 2010-04-14 09:35:43 UTC (rev 35) +++ trunk/autogen.sh 2010-04-14 14:32:19 UTC (rev 36) @@ -35,6 +35,24 @@ shift fi +# Begin list of optional variables sourced from ~/.gnupg-autogen.rc +w32_toolprefixes= +w32_extraoptions= +w32ce_toolprefixes= +w32ce_extraoptions= +amd64_toolprefixes= +# End list of optional variables sourced from ~/.gnupg-autogen.rc +# What follows are variables which are sourced but default to +# environment variables or lacking them hardcoded values. +#w32root= +#w32ce_root= +#amd64root= + +if [ -f "$HOME/.gnupg-autogen.rc" ]; then + echo "sourcing extra definitions from $HOME/.gnupg-autogen.rc" + . "$HOME/.gnupg-autogen.rc" +fi + # Convenience option to use certain configure options for some hosts. myhost="" myhostsub="" @@ -46,8 +64,12 @@ myhost="w32" myhostsub="ce" ;; + --build*) + echo "**Error**: invalid build option $1" >&2 + exit 1 + ;; *) - ;; + ;; esac @@ -66,6 +88,7 @@ case $myhostsub in ce) + w32root="$w32ce_root" [ -z "$w32root" ] && w32root="$HOME/w32ce_root" toolprefixes="arm-mingw32ce" extra_options="--with-gpg-error-prefix=${w32root}" From cvs at cvs.gnupg.org Wed Apr 14 16:32:54 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 14 Apr 2010 16:32:54 +0200 Subject: [svn] gcry - r1428 - trunk Message-ID: Author: wk Date: 2010-04-14 16:32:53 +0200 (Wed, 14 Apr 2010) New Revision: 1428 Modified: trunk/autogen.sh Log: Updated Modified: trunk/autogen.sh =================================================================== --- trunk/autogen.sh 2010-04-12 21:00:13 UTC (rev 1427) +++ trunk/autogen.sh 2010-04-14 14:32:53 UTC (rev 1428) @@ -36,6 +36,24 @@ shift fi +# Begin list of optional variables sourced from ~/.gnupg-autogen.rc +w32_toolprefixes= +w32_extraoptions= +w32ce_toolprefixes= +w32ce_extraoptions= +amd64_toolprefixes= +# End list of optional variables sourced from ~/.gnupg-autogen.rc +# What follows are variables which are sourced but default to +# environment variables or lacking them hardcoded values. +#w32root= +#w32ce_root= +#amd64root= + +if [ -f "$HOME/.gnupg-autogen.rc" ]; then + echo "sourcing extra definitions from $HOME/.gnupg-autogen.rc" + . "$HOME/.gnupg-autogen.rc" +fi + # Convenience option to use certain configure options for some hosts. myhost="" myhostsub="" @@ -50,8 +68,12 @@ --build-amd64) myhost="amd64" ;; + --build*) + echo "**Error**: invalid build option $1" >&2 + exit 1 + ;; *) - ;; + ;; esac @@ -69,6 +91,7 @@ case $myhostsub in ce) + w32root="$w32ce_root" [ -z "$w32root" ] && w32root="$HOME/w32ce_root" toolprefixes="arm-mingw32ce" ;; From cvs at cvs.gnupg.org Wed Apr 14 16:33:14 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 14 Apr 2010 16:33:14 +0200 Subject: [svn] ksba - r316 - trunk Message-ID: Author: wk Date: 2010-04-14 16:33:14 +0200 (Wed, 14 Apr 2010) New Revision: 316 Modified: trunk/autogen.sh Log: Updated Modified: trunk/autogen.sh =================================================================== --- trunk/autogen.sh 2010-01-22 12:09:42 UTC (rev 315) +++ trunk/autogen.sh 2010-04-14 14:33:14 UTC (rev 316) @@ -35,6 +35,24 @@ shift fi +# Begin list of optional variables sourced from ~/.gnupg-autogen.rc +w32_toolprefixes= +w32_extraoptions= +w32ce_toolprefixes= +w32ce_extraoptions= +amd64_toolprefixes= +# End list of optional variables sourced from ~/.gnupg-autogen.rc +# What follows are variables which are sourced but default to +# environment variables or lacking them hardcoded values. +#w32root= +#w32ce_root= +#amd64root= + +if [ -f "$HOME/.gnupg-autogen.rc" ]; then + echo "sourcing extra definitions from $HOME/.gnupg-autogen.rc" + . "$HOME/.gnupg-autogen.rc" +fi + # Convenience option to use certain configure options for some hosts. myhost="" myhostsub="" @@ -46,8 +64,12 @@ myhost="w32" myhostsub="ce" ;; + --build*) + echo "**Error**: invalid build option $1" >&2 + exit 1 + ;; *) - ;; + ;; esac @@ -65,6 +87,7 @@ case $myhostsub in ce) + w32root="$w32ce_root" [ -z "$w32root" ] && w32root="$HOME/w32ce_root" toolprefixes="arm-mingw32ce" ;; From cvs at cvs.gnupg.org Wed Apr 14 16:33:25 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 14 Apr 2010 16:33:25 +0200 Subject: [svn] assuan - r369 - trunk Message-ID: Author: wk Date: 2010-04-14 16:33:25 +0200 (Wed, 14 Apr 2010) New Revision: 369 Modified: trunk/autogen.sh Log: Updated. Modified: trunk/autogen.sh =================================================================== --- trunk/autogen.sh 2010-04-14 11:20:11 UTC (rev 368) +++ trunk/autogen.sh 2010-04-14 14:33:25 UTC (rev 369) @@ -36,6 +36,24 @@ shift fi +# Begin list of optional variables sourced from ~/.gnupg-autogen.rc +w32_toolprefixes= +w32_extraoptions= +w32ce_toolprefixes= +w32ce_extraoptions= +amd64_toolprefixes= +# End list of optional variables sourced from ~/.gnupg-autogen.rc +# What follows are variables which are sourced but default to +# environment variables or lacking them hardcoded values. +#w32root= +#w32ce_root= +#amd64root= + +if [ -f "$HOME/.gnupg-autogen.rc" ]; then + echo "sourcing extra definitions from $HOME/.gnupg-autogen.rc" + . "$HOME/.gnupg-autogen.rc" +fi + # Convenience option to use certain configure options for some hosts. myhost="" myhostsub="" @@ -50,8 +68,12 @@ --build-amd64) myhost="amd64" ;; + --build*) + echo "**Error**: invalid build option $1" >&2 + exit 1 + ;; *) - ;; + ;; esac @@ -69,6 +91,7 @@ case $myhostsub in ce) + w32root="$w32ce_root" [ -z "$w32root" ] && w32root="$HOME/w32ce_root" toolprefixes="arm-mingw32ce" ;; From cvs at cvs.gnupg.org Wed Apr 14 16:34:39 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 14 Apr 2010 16:34:39 +0200 Subject: [svn] pinentry - r224 - trunk Message-ID: Author: wk Date: 2010-04-14 16:34:39 +0200 (Wed, 14 Apr 2010) New Revision: 224 Modified: trunk/autogen.sh Log: Updated Modified: trunk/autogen.sh =================================================================== --- trunk/autogen.sh 2010-04-14 11:28:54 UTC (rev 223) +++ trunk/autogen.sh 2010-04-14 14:34:39 UTC (rev 224) @@ -98,6 +98,7 @@ case $myhostsub in ce) + w32root="$w32ce_root" [ -z "$w32ce_root" ] && w32root="$HOME/w32ce_root" toolprefixes="$w32ce_toolprefixes arm-mingw32ce" extraoptions="$w32ce_extraoptions --disable-pinentry-gtk2" From cvs at cvs.gnupg.org Wed Apr 14 16:39:17 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 14 Apr 2010 16:39:17 +0200 Subject: [svn] GnuPG - r5306 - in trunk: . agent common g10 keyserver tools Message-ID: Author: wk Date: 2010-04-14 16:39:16 +0200 (Wed, 14 Apr 2010) New Revision: 5306 Modified: trunk/ChangeLog trunk/Makefile.am trunk/NEWS trunk/agent/ChangeLog trunk/agent/Makefile.am trunk/autogen.sh trunk/common/ChangeLog trunk/common/Makefile.am trunk/common/init.c trunk/common/sysutils.c trunk/common/util.h trunk/common/w32help.h trunk/configure.ac trunk/g10/ChangeLog trunk/g10/Makefile.am trunk/g10/compress.c trunk/g10/cpr.c trunk/g10/decrypt.c trunk/g10/exec.c trunk/g10/gpg.c trunk/g10/keygen.c trunk/g10/keyring.c trunk/g10/main.h trunk/g10/misc.c trunk/keyserver/ksutil.c trunk/tools/ChangeLog trunk/tools/Makefile.am trunk/tools/gpg-connect-agent.c Log: ./autogen.sh --build-w32ce does now succeed. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-04-14 11:24:02 UTC (rev 5305) +++ trunk/ChangeLog 2010-04-14 14:39:16 UTC (rev 5306) @@ -1,3 +1,12 @@ +2010-04-14 Werner Koch + + * Makefile.am (keyserver) [W32CE]: Do not build for now. + + * configure.ac (use_zip): New. + (--disable-zip): New option. + (HAVE_ZIP): New. + * autogen.sh : Disable ZIP. + 2010-04-07 Werner Koch * autogen.sh: Take a .gnupg-autogen.rc file in account. Modified: trunk/agent/ChangeLog =================================================================== --- trunk/agent/ChangeLog 2010-04-14 11:24:02 UTC (rev 5305) +++ trunk/agent/ChangeLog 2010-04-14 14:39:16 UTC (rev 5306) @@ -1,5 +1,8 @@ 2010-04-14 Werner Koch + * Makefile.am (libexec_PROGRAMS) [W32CE]: Do not build + gpg-preset-passphrase for now. + * trustlist.c (read_one_trustfile): Use estream. 2010-04-13 Werner Koch Modified: trunk/common/ChangeLog =================================================================== --- trunk/common/ChangeLog 2010-04-14 11:24:02 UTC (rev 5305) +++ trunk/common/ChangeLog 2010-04-14 14:39:16 UTC (rev 5306) @@ -1,5 +1,12 @@ 2010-04-14 Werner Koch + * Makefile.am (noinst_LIBRARIES) [W32CE]: Exclude libsimple-pwquery. + + * w32help.h (umask) [W32CE]: New. + + * sysutils.c (_gnupg_isatty): New. + * util.h (gnupg_isatty): New. + * asshelp.c (setup_libassuan_logging): Read ASSUAN_DEBUG envvar. (my_libassuan_log_handler): Use it. * sysutils.c (_gnupg_getenv): Implement ASSUAN_DEBUG. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2010-04-14 11:24:02 UTC (rev 5305) +++ trunk/g10/ChangeLog 2010-04-14 14:39:16 UTC (rev 5306) @@ -1,3 +1,19 @@ +2010-04-14 Werner Koch + + * cpr.c (myread) [W32CE]: Do not use raise. + + * misc.c (check_compress_algo): Rewrite to handle the new HAVE_ZIP. + * compress.c (push_compress_filter2): Ditto. + (init_compress, do_compress, init_uncompress, do_uncompress) + (compress_filter) [!HAVE_ZIP]: Do not build. + * main.h (DEFAULT_COMPRESS_ALGO): Depend on HAVE_ZIP. + * keygen.c (keygen_set_std_prefs): Use check_compress_algo also + for ZIP and ZLIB. + + * Makefile.am (install-exec-hook) [W32CE]: New. + (bin_PROGRAMS) [W32CE]: Do not build gpgv2. + (gpg2_LDADD): Add extra_syslibs. + 2010-04-06 Werner Koch * openfile.c (mkdir): Remove. Modified: trunk/tools/ChangeLog =================================================================== --- trunk/tools/ChangeLog 2010-04-14 11:24:02 UTC (rev 5305) +++ trunk/tools/ChangeLog 2010-04-14 14:39:16 UTC (rev 5306) @@ -1,3 +1,8 @@ +2010-04-14 Werner Koch + + * Makefile.am (bin_PROGRAMS) [W32CE]: Exclude gpgkey2ssh. + (noinst_PROGRAMS) [W32CE]: Don't build them. + 2010-03-25 Werner Koch * Makefile.am (opt_libassuan_libs) [W32CE]: New. Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2010-04-14 11:24:02 UTC (rev 5305) +++ trunk/Makefile.am 2010-04-14 14:39:16 UTC (rev 5306) @@ -34,7 +34,9 @@ if BUILD_GPG gpg = g10 +if !HAVE_W32CE_SYSTEM keyserver = keyserver +endif else gpg = keyserver = Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2010-04-14 11:24:02 UTC (rev 5305) +++ trunk/NEWS 2010-04-14 14:39:16 UTC (rev 5306) @@ -21,7 +21,7 @@ * New and changed passphrases are now created with an iteration count requiring about 100ms of CPU work. - * Ported to Windows CE. + * Support for Windows CE. Noteworthy changes in version 2.0.13 (2009-09-04) Modified: trunk/agent/Makefile.am =================================================================== --- trunk/agent/Makefile.am 2010-04-14 11:24:02 UTC (rev 5305) +++ trunk/agent/Makefile.am 2010-04-14 14:39:16 UTC (rev 5306) @@ -18,7 +18,11 @@ ## Process this file with automake to produce Makefile.in bin_PROGRAMS = gpg-agent -libexec_PROGRAMS = gpg-protect-tool gpg-preset-passphrase +libexec_PROGRAMS = gpg-protect-tool +if !HAVE_W32CE_SYSTEM +# fixme: Do no use simple-pwquery for preset-passphrase. +libexec_PROGRAMS += gpg-preset-passphrase +endif noinst_PROGRAMS = $(TESTS) # EXTRA_DIST = gpg-agent.ico gpg-agent-resource.rc Modified: trunk/autogen.sh =================================================================== --- trunk/autogen.sh 2010-04-14 11:24:02 UTC (rev 5305) +++ trunk/autogen.sh 2010-04-14 14:39:16 UTC (rev 5306) @@ -82,7 +82,7 @@ exit 1 ;; *) - ;; + ;; esac @@ -100,9 +100,10 @@ case $myhostsub in ce) - [ -z "$w32ce_root" ] && w32root="$HOME/w32ce_root" + w32root="$w32ce_root" + [ -z "$w32root" ] && w32root="$HOME/w32ce_root" toolprefixes="$w32ce_toolprefixes arm-mingw32ce" - extraoptions="--disable-scdaemon $w32ce_extraoptions" + extraoptions="--disable-scdaemon --disable-zip $w32ce_extraoptions" ;; *) [ -z "$w32root" ] && w32root="$HOME/w32root" Modified: trunk/common/Makefile.am =================================================================== --- trunk/common/Makefile.am 2010-04-14 11:24:02 UTC (rev 5305) +++ trunk/common/Makefile.am 2010-04-14 14:39:16 UTC (rev 5306) @@ -21,7 +21,10 @@ EXTRA_DIST = mkstrtable.awk exaudit.awk exstatus.awk \ audit-events.h status-codes.h README.jnlib ChangeLog.jnlib -noinst_LIBRARIES = libcommon.a libcommonpth.a libsimple-pwquery.a libgpgrl.a +noinst_LIBRARIES = libcommon.a libcommonpth.a libgpgrl.a +if !HAVE_W32CE_SYSTEM +noinst_LIBRARIES += libsimple-pwquery.a +endif noinst_PROGRAMS = $(jnlib_tests) $(module_tests) $(module_maint_tests) TESTS = $(jnlib_tests) $(module_tests) @@ -118,9 +121,11 @@ endif libcommonpth_a_CFLAGS = $(AM_CFLAGS) $(LIBASSUAN_CFLAGS) $(PTH_CFLAGS) +if !HAVE_W32CE_SYSTEM libsimple_pwquery_a_SOURCES = \ simple-pwquery.c simple-pwquery.h asshelp.c asshelp.h libsimple_pwquery_a_CFLAGS = $(AM_CFLAGS) $(LIBASSUAN_CFLAGS) +endif libgpgrl_a_SOURCES = \ gpgrlhelp.c Modified: trunk/common/init.c =================================================================== --- trunk/common/init.c 2010-04-14 11:24:02 UTC (rev 5305) +++ trunk/common/init.c 2010-04-14 14:39:16 UTC (rev 5306) @@ -30,11 +30,14 @@ #ifdef HAVE_PTH #include #endif +#ifdef HAVE_W32CE_SYSTEM +# include /* For _assuan_w32ce_finish_pipe. */ +#endif #include "util.h" + #ifdef HAVE_W32CE_SYSTEM -#include static void parse_std_file_handles (int *argcp, char ***argvp); static void sleep_on_exit (void) Modified: trunk/common/sysutils.c =================================================================== --- trunk/common/sysutils.c 2010-04-14 11:24:02 UTC (rev 5305) +++ trunk/common/sysutils.c 2010-04-14 14:39:16 UTC (rev 5306) @@ -623,7 +623,18 @@ #endif } +#ifdef HAVE_W32CE_SYSTEM +/* There is a isatty function declaration in cegcc but it does not + make sense, thus we redefine it. */ +int +_gnupg_isatty (int fd) +{ + (void)fd; + return 0; +} +#endif + #ifdef HAVE_W32CE_SYSTEM /* Replacement for getenv which takes care of the our use of getenv. The code is not thread safe but we expect it to work in all cases Modified: trunk/common/util.h =================================================================== --- trunk/common/util.h 2010-04-14 11:24:02 UTC (rev 5305) +++ trunk/common/util.h 2010-04-14 14:39:16 UTC (rev 5306) @@ -300,6 +300,10 @@ #define getenv(a) _gnupg_getenv ((a)) char *_gnupg_setenv (const char *name); /* See sysutils.c */ #define setenv(a,b,c) _gnupg_setenv ((a),(b),(c)) +int _gnupg_isatty (int fd); +#define gnupg_isatty(a) _gnupg_isatty ((a)) +#else +#define gnupg_isatty(a) isatty ((a)) #endif Modified: trunk/common/w32help.h =================================================================== --- trunk/common/w32help.h 2010-04-14 11:24:02 UTC (rev 5305) +++ trunk/common/w32help.h 2010-04-14 14:39:16 UTC (rev 5306) @@ -33,6 +33,15 @@ /* Setmode is missing in cegcc but available since CE 5.0. */ int _setmode (int handle, int mode); # define setmode(a,b) _setmode ((a),(b)) + +static inline int +umask (int a) +{ + (void)a; + return 0; +} + + #endif /*HAVE_W32CE_SYSTEM*/ #endif /*HAVE_W32_SYSTEM*/ Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2010-04-14 11:24:02 UTC (rev 5305) +++ trunk/configure.ac 2010-04-14 14:39:16 UTC (rev 5306) @@ -74,6 +74,7 @@ have_libusb=no have_adns=no +use_zip=yes use_bzip2=yes use_exec=yes disable_keyserver_path=no @@ -169,6 +170,16 @@ selinux_support=$enableval, selinux_support=no) AC_MSG_RESULT($selinux_support) +# Allow disabling of zip support. +# This is in general not a good idea because according to rfc4880 OpenPGP +# implementations SHOULD support ZLIB. +AC_MSG_CHECKING([whether to enable the ZIP and ZLIB compression algorithm]) +AC_ARG_ENABLE(zip, + AC_HELP_STRING([--disable-zip], + [disable the ZIP and ZLIB compression algorithm]), + use_zip=$enableval) +AC_MSG_RESULT($use_zip) + # Allow disabling of bzib2 support. # It is defined only after we confirm the library is available later AC_MSG_CHECKING([whether to enable the BZIP2 compression algorithm]) @@ -1210,21 +1221,26 @@ # when compiling a conftest (due to the "-lz" from LIBS). # Note that we combine zlib and bzlib2 in ZLIBS. # -_cppflags="${CPPFLAGS}" -_ldflags="${LDFLAGS}" -AC_ARG_WITH(zlib, - [ --with-zlib=DIR use libz in DIR],[ - if test -d "$withval"; then - CPPFLAGS="${CPPFLAGS} -I$withval/include" - LDFLAGS="${LDFLAGS} -L$withval/lib" - fi - ]) +if test "$use_zip" = yes ; then + _cppflags="${CPPFLAGS}" + _ldflags="${LDFLAGS}" + AC_ARG_WITH(zlib, + [ --with-zlib=DIR use libz in DIR],[ + if test -d "$withval"; then + CPPFLAGS="${CPPFLAGS} -I$withval/include" + LDFLAGS="${LDFLAGS} -L$withval/lib" + fi + ]) + + AC_CHECK_HEADER(zlib.h, + AC_CHECK_LIB(z, deflateInit2_, + ZLIBS="-lz", + CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}), + CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}) + + AC_DEFINE(HAVE_ZIP,1, [Defined if ZIP and ZLIB are supported]) +fi -AC_CHECK_HEADER(zlib.h, - AC_CHECK_LIB(z, deflateInit2_, - ZLIBS="-lz", - CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}), - CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}) # # Check whether we can support bzip2 Modified: trunk/g10/Makefile.am =================================================================== --- trunk/g10/Makefile.am 2010-04-14 11:24:02 UTC (rev 5305) +++ trunk/g10/Makefile.am 2010-04-14 14:39:16 UTC (rev 5306) @@ -1,5 +1,5 @@ # Copyright (C) 1998, 1999, 2000, 2001, 2002, -# 2003, 2006 Free Software Foundation, Inc. +# 2003, 2006, 2010 Free Software Foundation, Inc. # # This file is part of GnuPG. # @@ -29,7 +29,10 @@ needed_libs = $(libcommon) ../gl/libgnu.a -bin_PROGRAMS = gpg2 gpgv2 +bin_PROGRAMS = gpg2 +if !HAVE_W32CE_SYSTEM +bin_PROGRAMS += gpgv2 +endif noinst_PROGRAMS = $(module_tests) TESTS = $(module_tests) @@ -120,9 +123,9 @@ $(ZLIBS) $(DNSLIBS) $(LIBREADLINE) \ $(LIBINTL) $(CAPLIBS) $(NETLIBS) gpg2_LDADD = $(LDADD) $(LIBGCRYPT_LIBS) $(LIBASSUAN_LIBS) $(GPG_ERROR_LIBS) \ - $(LIBICONV) + $(LIBICONV) $(extra_sys_libs) gpgv2_LDADD = $(LDADD) $(LIBGCRYPT_LIBS) $(LIBASSUAN_LIBS) $(GPG_ERROR_LIBS) \ - $(LIBICONV) + $(LIBICONV) $(extra_sys_libs) t_common_ldadd = module_tests = t-rmd160 @@ -139,3 +142,11 @@ uninstall-local: - at rm $(DESTDIR)$(pkgdatadir)/gpg-conf.skel + + +# There has never been a gpg for WindowsCE, thus we don't need a gpg2 here +if HAVE_W32CE_SYSTEM +install-exec-hook: + mv -f $(DESTDIR)$(bindir)/gpg2$(EXEEXT) \ + $(DESTDIR)$(bindir)/gpg$(EXEEXT) +endif Modified: trunk/g10/compress.c =================================================================== --- trunk/g10/compress.c 2010-04-14 11:24:02 UTC (rev 5305) +++ trunk/g10/compress.c 2010-04-14 14:39:16 UTC (rev 5306) @@ -1,6 +1,6 @@ /* compress.c - compress filter * Copyright (C) 1998, 1999, 2000, 2001, 2002, - * 2003, 2006 Free Software Foundation, Inc. + * 2003, 2006, 2010 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -31,10 +31,12 @@ #include #include #include -#include -#if defined(__riscos__) && defined(USE_ZLIBRISCOS) -# include "zlib-riscos.h" -#endif +#ifdef HAVE_ZIP +# include +# if defined(__riscos__) && defined(USE_ZLIBRISCOS) +# include "zlib-riscos.h" +# endif +#endif #include "gpg.h" #include "util.h" @@ -55,6 +57,7 @@ int compress_filter_bz2( void *opaque, int control, IOBUF a, byte *buf, size_t *ret_len); +#ifdef HAVE_ZIP static void init_compress( compress_filter_context_t *zfx, z_stream *zs ) { @@ -285,8 +288,8 @@ *(char**)buf = "compress_filter"; return rc; } +#endif /*HAVE_ZIP*/ - static void release_context (compress_filter_context_t *ctx) { @@ -337,10 +340,12 @@ case COMPRESS_ALGO_NONE: break; +#ifdef HAVE_ZIP case COMPRESS_ALGO_ZIP: case COMPRESS_ALGO_ZLIB: iobuf_push_filter2(out,compress_filter,zfx,rel); break; +#endif #ifdef HAVE_BZIP2 case COMPRESS_ALGO_BZIP2: Modified: trunk/g10/cpr.c =================================================================== --- trunk/g10/cpr.c 2010-04-14 11:24:02 UTC (rev 5305) +++ trunk/g10/cpr.c 2010-04-14 14:39:16 UTC (rev 5306) @@ -24,7 +24,9 @@ #include #include #include -#include +#ifdef HAVE_SIGNAL_H +# include +#endif #include "gpg.h" #include "util.h" @@ -312,7 +314,9 @@ } else { /* Ctrl-D not caught - do something reasonable */ #ifdef HAVE_DOSISH_SYSTEM +#ifndef HAVE_W32CE_SYSTEM raise (SIGINT); /* nothing to hangup under DOS */ +#endif #else raise (SIGHUP); /* no more input data */ #endif Modified: trunk/g10/decrypt.c =================================================================== --- trunk/g10/decrypt.c 2010-04-14 11:24:02 UTC (rev 5305) +++ trunk/g10/decrypt.c 2010-04-14 14:39:16 UTC (rev 5306) @@ -131,7 +131,12 @@ return err; } +#ifdef HAVE_W32CE_SYSTEM +#warning Ned to fix this + opt.outfp = NULL; +#else opt.outfp = fdopen (dup (output_fd), "wb"); +#endif if (!opt.outfp) { char xname[64]; Modified: trunk/g10/exec.c =================================================================== --- trunk/g10/exec.c 2010-04-14 11:24:02 UTC (rev 5305) +++ trunk/g10/exec.c 2010-04-14 14:39:16 UTC (rev 5306) @@ -74,6 +74,9 @@ static int w32_system(const char *command) { +#ifdef HAVE_W32CE_SYSTEM +#warning Change this code to use common/exechelp.c +#else PROCESS_INFORMATION pi; STARTUPINFO si; char *string; @@ -99,6 +102,7 @@ xfree(string); return 0; +#endif } #endif @@ -106,6 +110,9 @@ int set_exec_path(const char *path) { +#ifdef HAVE_W32CE_SYSTEM +#warning Change this code to use common/exechelp.c +#else char *p; p=xmalloc(5+strlen(path)+1); @@ -123,6 +130,7 @@ return G10ERR_GENERAL; else return 0; +#endif } /* Makes a temp directory and filenames */ Modified: trunk/g10/gpg.c =================================================================== --- trunk/g10/gpg.c 2010-04-14 11:24:02 UTC (rev 5305) +++ trunk/g10/gpg.c 2010-04-14 14:39:16 UTC (rev 5306) @@ -1242,7 +1242,7 @@ Returns true if the item is unsafe. */ static int -check_permissions(const char *path,int item) +check_permissions (const char *path, int item) { #if defined(HAVE_STAT) && !defined(HAVE_DOSISH_SYSTEM) static int homedir_cache=-1; @@ -1428,9 +1428,11 @@ return ret; -#endif /* HAVE_STAT && !HAVE_DOSISH_SYSTEM */ - +#else /*!(HAVE_STAT && !HAVE_DOSISH_SYSTEM)*/ + (void)path; + (void)item; return 0; +#endif /*!(HAVE_STAT && !HAVE_DOSISH_SYSTEM)*/ } @@ -4028,8 +4030,10 @@ if( argc > 1 ) wrong_args(_("[filename]")); /* Issue some output for the unix newbie */ - if( !fname && !opt.outfile && isatty( fileno(stdin) ) - && isatty( fileno(stdout) ) && isatty( fileno(stderr) ) ) + if (!fname && !opt.outfile + && gnupg_isatty (fileno (stdin)) + && gnupg_isatty (fileno (stdout)) + && gnupg_isatty (fileno (stderr))) log_info(_("Go ahead and type your message ...\n")); a = iobuf_open(fname); Modified: trunk/g10/keygen.c =================================================================== --- trunk/g10/keygen.c 2010-04-14 11:24:02 UTC (rev 5305) +++ trunk/g10/keygen.c 2010-04-14 14:39:16 UTC (rev 5306) @@ -1,6 +1,6 @@ /* keygen.c - generate a key pair * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - * 2006, 2007, 2009 Free Software Foundation, Inc. + * 2006, 2007, 2009, 2010 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -374,15 +374,14 @@ if (!openpgp_md_test_algo (DIGEST_ALGO_SHA224)) strcat (dummy_string, "H11 "); + if(!check_compress_algo(COMPRESS_ALGO_ZLIB)) + strcat(dummy_string,"Z2 "); - /* ZLIB */ - strcat(dummy_string,"Z2 "); - if(!check_compress_algo(COMPRESS_ALGO_BZIP2)) strcat(dummy_string,"Z3 "); - /* ZIP */ - strcat(dummy_string,"Z1"); + if(!check_compress_algo(COMPRESS_ALGO_ZIP)) + strcat(dummy_string,"Z1"); string=dummy_string; } Modified: trunk/g10/keyring.c =================================================================== --- trunk/g10/keyring.c 2010-04-14 11:24:02 UTC (rev 5305) +++ trunk/g10/keyring.c 2010-04-14 14:39:16 UTC (rev 5306) @@ -1274,7 +1274,7 @@ if (!secret) { #if defined(HAVE_DOSISH_SYSTEM) || defined(__riscos__) - remove (bakfname); + gnupg_remove (bakfname); #endif if (rename (fname, bakfname) ) { @@ -1287,7 +1287,7 @@ /* then rename the file */ #if defined(HAVE_DOSISH_SYSTEM) || defined(__riscos__) - remove( fname ); + gnupg_remove( fname ); #endif if (secret) unregister_secured_file (fname); Modified: trunk/g10/main.h =================================================================== --- trunk/g10/main.h 2010-04-14 11:24:02 UTC (rev 5305) +++ trunk/g10/main.h 2010-04-14 14:39:16 UTC (rev 5306) @@ -33,9 +33,14 @@ #define DEFAULT_CIPHER_ALGO CIPHER_ALGO_CAST5 #define DEFAULT_DIGEST_ALGO DIGEST_ALGO_SHA1 -#define DEFAULT_COMPRESS_ALGO COMPRESS_ALGO_ZIP #define DEFAULT_S2K_DIGEST_ALGO DIGEST_ALGO_SHA1 +#ifdef HAVE_ZIP +# define DEFAULT_COMPRESS_ALGO COMPRESS_ALGO_ZIP +#else +# define DEFAULT_COMPRESS_ALGO COMPRESS_ALGO_NONE +#endif + #define S2K_DIGEST_ALGO (opt.s2k_digest_algo?opt.s2k_digest_algo:DEFAULT_S2K_DIGEST_ALGO) typedef struct Modified: trunk/g10/misc.c =================================================================== --- trunk/g10/misc.c 2010-04-14 11:24:02 UTC (rev 5305) +++ trunk/g10/misc.c 2010-04-14 14:39:16 UTC (rev 5306) @@ -905,15 +905,18 @@ int check_compress_algo(int algo) { + switch (algo) + { + case 0: return 0; +#ifdef HAVE_ZIP + case 1: + case 2: return 0; +#endif #ifdef HAVE_BZIP2 - if(algo>=0 && algo<=3) - return 0; -#else - if(algo>=0 && algo<=2) - return 0; + case 3: return 0; #endif - - return G10ERR_COMPR_ALGO; + default: return G10ERR_COMPR_ALGO; + } } int Modified: trunk/keyserver/ksutil.c =================================================================== --- trunk/keyserver/ksutil.c 2010-04-14 11:24:02 UTC (rev 5305) +++ trunk/keyserver/ksutil.c 2010-04-14 14:39:16 UTC (rev 5306) @@ -29,7 +29,9 @@ */ #include -#include +#ifdef HAVE_SIGNAL_H +# include +#endif #include #include #include Modified: trunk/tools/Makefile.am =================================================================== --- trunk/tools/Makefile.am 2010-04-14 11:24:02 UTC (rev 5305) +++ trunk/tools/Makefile.am 2010-04-14 14:39:16 UTC (rev 5306) @@ -42,16 +42,22 @@ symcryptrun = endif -bin_PROGRAMS = gpgconf gpg-connect-agent gpgkey2ssh ${symcryptrun} +# Fixme: We should remove the gpgkey2ssh tool. +bin_PROGRAMS = gpgconf gpg-connect-agent ${symcryptrun} if !HAVE_W32_SYSTEM bin_PROGRAMS += watchgnupg gpgparsemail endif +if !HAVE_W32CE_SYSTEM +bin_PROGRAMS += gpgkey2ssh +endif if !DISABLE_REGEX libexec_PROGRAMS = gpg-check-pattern endif +if !HAVE_W32CE_SYSTEM noinst_PROGRAMS = clean-sat mk-tdata make-dns-cert gpgsplit +endif common_libs = $(libcommon) ../gl/libgnu.a pwquery_libs = ../common/libsimple-pwquery.a @@ -88,14 +94,15 @@ $(LIBASSUAN_LIBS) $(PTH_LIBS) $(GPG_ERROR_LIBS) \ $(LIBREADLINE) $(LIBINTL) $(NETLIBS) $(LIBICONV) +if !HAVE_W32CE_SYSTEM gpgkey2ssh_SOURCES = gpgkey2ssh.c gpgkey2ssh_CFLAGS = $(LIBGCRYPT_CFLAGS) $(GPG_ERROR_CFLAGS) # common via use of BUG() in an inline function, which # some compilers do not eliminate. gpgkey2ssh_LDADD = $(common_libs) \ $(LIBGCRYPT_LIBS) $(GPG_ERROR_LIBS) $(LIBINTL) $(LIBICONV) +endif - if !DISABLE_REGEX gpg_check_pattern_SOURCES = gpg-check-pattern.c gpg_check_pattern_CFLAGS = $(LIBGCRYPT_CFLAGS) $(GPG_ERROR_CFLAGS) Modified: trunk/tools/gpg-connect-agent.c =================================================================== --- trunk/tools/gpg-connect-agent.c 2010-04-14 11:24:02 UTC (rev 5305) +++ trunk/tools/gpg-connect-agent.c 2010-04-14 14:39:16 UTC (rev 5306) @@ -1203,11 +1203,7 @@ if (log_get_errorcount (0)) exit (2); -#ifdef HAVE_W32CE_SYSTEM - use_tty = 0; -#else - use_tty = (isatty ( fileno (stdin)) && isatty (fileno (stdout))); -#endif + use_tty = (gnupg_isatty (fileno (stdin)) && gnupg_isatty (fileno (stdout))); if (opt.exec) { From cvs at cvs.gnupg.org Wed Apr 14 18:52:02 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 14 Apr 2010 18:52:02 +0200 Subject: [svn] GnuPG - r5307 - trunk/agent Message-ID: Author: wk Date: 2010-04-14 18:52:02 +0200 (Wed, 14 Apr 2010) New Revision: 5307 Modified: trunk/agent/ChangeLog trunk/agent/Makefile.am Log: Remove dependency to simple-pwquery. Modified: trunk/agent/ChangeLog =================================================================== --- trunk/agent/ChangeLog 2010-04-14 14:39:16 UTC (rev 5306) +++ trunk/agent/ChangeLog 2010-04-14 16:52:02 UTC (rev 5307) @@ -2,6 +2,7 @@ * Makefile.am (libexec_PROGRAMS) [W32CE]: Do not build gpg-preset-passphrase for now. + (pwquery_libs) [W32CE]: Set to empty. * trustlist.c (read_one_trustfile): Use estream. Modified: trunk/agent/Makefile.am =================================================================== --- trunk/agent/Makefile.am 2010-04-14 14:39:16 UTC (rev 5306) +++ trunk/agent/Makefile.am 2010-04-14 16:52:02 UTC (rev 5307) @@ -51,7 +51,11 @@ common_libs = $(libcommon) ../gl/libgnu.a commonpth_libs = $(libcommonpth) ../gl/libgnu.a +if HAVE_W32CE_SYSTEM +pwquery_libs = +else pwquery_libs = ../common/libsimple-pwquery.a +endif #if HAVE_W32_SYSTEM #.rc.o: From cvs at cvs.gnupg.org Wed Apr 14 19:56:22 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 14 Apr 2010 19:56:22 +0200 Subject: [svn] GnuPG - r5308 - in trunk: common tools Message-ID: Author: wk Date: 2010-04-14 19:56:22 +0200 (Wed, 14 Apr 2010) New Revision: 5308 Modified: trunk/common/sysutils.c trunk/tools/ChangeLog trunk/tools/Makefile.am Log: Fixed dependencies and a syntax error Modified: trunk/tools/ChangeLog =================================================================== --- trunk/tools/ChangeLog 2010-04-14 16:52:02 UTC (rev 5307) +++ trunk/tools/ChangeLog 2010-04-14 17:56:22 UTC (rev 5308) @@ -2,6 +2,7 @@ * Makefile.am (bin_PROGRAMS) [W32CE]: Exclude gpgkey2ssh. (noinst_PROGRAMS) [W32CE]: Don't build them. + (pwquery_libs) [W32CE]: Set to empty. 2010-03-25 Werner Koch Modified: trunk/common/sysutils.c =================================================================== --- trunk/common/sysutils.c 2010-04-14 16:52:02 UTC (rev 5307) +++ trunk/common/sysutils.c 2010-04-14 17:56:22 UTC (rev 5308) @@ -526,7 +526,7 @@ gpg_err_set_errno (EIO); return !rc; #else - return remove; + return remove (fname); #endif } @@ -590,7 +590,7 @@ if (*modestr && *modestr++ == 'x') mode |= S_IXOTH; } - return mkdir (home, mode) + return mkdir (name, mode); #endif } Modified: trunk/tools/Makefile.am =================================================================== --- trunk/tools/Makefile.am 2010-04-14 16:52:02 UTC (rev 5307) +++ trunk/tools/Makefile.am 2010-04-14 17:56:22 UTC (rev 5308) @@ -60,7 +60,11 @@ endif common_libs = $(libcommon) ../gl/libgnu.a +if HAVE_W32CE_SYSTEM +pwquery_libs = +else pwquery_libs = ../common/libsimple-pwquery.a +endif if HAVE_W32CE_SYSTEM opt_libassuan_libs = $(LIBASSUAN_LIBS) From cvs at cvs.gnupg.org Wed Apr 14 20:55:11 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 14 Apr 2010 20:55:11 +0200 Subject: [svn] pinentry - r225 - trunk/m4 Message-ID: Author: wk Date: 2010-04-14 20:55:11 +0200 (Wed, 14 Apr 2010) New Revision: 225 Added: trunk/m4/pkg.m4 Modified: trunk/m4/ChangeLog Log: Add pkg.m4 Modified: trunk/m4/ChangeLog =================================================================== --- trunk/m4/ChangeLog 2010-04-14 14:34:39 UTC (rev 224) +++ trunk/m4/ChangeLog 2010-04-14 18:55:11 UTC (rev 225) @@ -1,3 +1,7 @@ +2010-04-14 Werner Koch + + * pkg.m4: New. + 2004-12-22 Werner Koch * gtk.m4, glib.m4, qt.m4: Fixed for automake 1.9 @@ -5,5 +9,5 @@ 2004-09-27 Marcus Brinkmann * curses.m4, glib.m4, gtk.m4, iconv.m4, qt.m4: New files. - + Added: trunk/m4/pkg.m4 =================================================================== --- trunk/m4/pkg.m4 (rev 0) +++ trunk/m4/pkg.m4 2010-04-14 18:55:11 UTC (rev 225) @@ -0,0 +1,157 @@ +# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- +# +# Copyright ? 2004 Scott James Remnant . +# +# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# PKG_PROG_PKG_CONFIG([MIN-VERSION]) +# ---------------------------------- +AC_DEFUN([PKG_PROG_PKG_CONFIG], +[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) +m4_pattern_allow([^PKG_CONFIG(_PATH)?$]) +AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then + AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) +fi +if test -n "$PKG_CONFIG"; then + _pkg_min_version=m4_default([$1], [0.9.0]) + AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + PKG_CONFIG="" + fi + +fi[]dnl +])# PKG_PROG_PKG_CONFIG + +# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# +# Check to see whether a particular set of modules exists. Similar +# to PKG_CHECK_MODULES(), but does not set variables or print errors. +# +# +# Similar to PKG_CHECK_MODULES, make sure that the first instance of +# this or PKG_CHECK_MODULES is called, or make sure to call +# PKG_CHECK_EXISTS manually +# -------------------------------------------------------------- +AC_DEFUN([PKG_CHECK_EXISTS], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +if test -n "$PKG_CONFIG" && \ + AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then + m4_ifval([$2], [$2], [:]) +m4_ifvaln([$3], [else + $3])dnl +fi]) + + +# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) +# --------------------------------------------- +m4_define([_PKG_CONFIG], +[if test -n "$PKG_CONFIG"; then + if test -n "$$1"; then + pkg_cv_[]$1="$$1" + else + PKG_CHECK_EXISTS([$3], + [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`], + [pkg_failed=yes]) + fi +else + pkg_failed=untried +fi[]dnl +])# _PKG_CONFIG + +# _PKG_SHORT_ERRORS_SUPPORTED +# ----------------------------- +AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi[]dnl +])# _PKG_SHORT_ERRORS_SUPPORTED + + +# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], +# [ACTION-IF-NOT-FOUND]) +# +# +# Note that if there is a possibility the first call to +# PKG_CHECK_MODULES might not happen, you should be sure to include an +# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac +# +# +# -------------------------------------------------------------- +AC_DEFUN([PKG_CHECK_MODULES], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl +AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl + +pkg_failed=no +AC_MSG_CHECKING([for $1]) + +_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) +_PKG_CONFIG([$1][_LIBS], [libs], [$2]) + +m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS +and $1[]_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details.]) + +if test $pkg_failed = yes; then + _PKG_SHORT_ERRORS_SUPPORTED + if test $_pkg_short_errors_supported = yes; then + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"` + else + $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"` + fi + # Put the nasty error message in config.log where it belongs + echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD + + ifelse([$4], , [AC_MSG_ERROR(dnl +[Package requirements ($2) were not met: + +$$1_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +_PKG_TEXT +])], + [AC_MSG_RESULT([no]) + $4]) +elif test $pkg_failed = untried; then + ifelse([$4], , [AC_MSG_FAILURE(dnl +[The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +_PKG_TEXT + +To get pkg-config, see .])], + [$4]) +else + $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS + $1[]_LIBS=$pkg_cv_[]$1[]_LIBS + AC_MSG_RESULT([yes]) + ifelse([$3], , :, [$3]) +fi[]dnl +])# PKG_CHECK_MODULES From cvs at cvs.gnupg.org Fri Apr 16 02:52:49 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Fri, 16 Apr 2010 02:52:49 +0200 Subject: [svn] assuan - r370 - trunk/src Message-ID: Author: marcus Date: 2010-04-16 02:52:49 +0200 (Fri, 16 Apr 2010) New Revision: 370 Modified: trunk/src/ChangeLog trunk/src/assuan-uds.c Log: 2010-04-16 Marcus Brinkmann * assuan-uds.c (uds_reader, uds_sendfd): Don't break strict aliasing rules. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-04-14 14:33:25 UTC (rev 369) +++ trunk/src/ChangeLog 2010-04-16 00:52:49 UTC (rev 370) @@ -1,3 +1,8 @@ +2010-04-16 Marcus Brinkmann + + * assuan-uds.c (uds_reader, uds_sendfd): Don't break strict + aliasing rules. + 2010-04-14 Werner Koch * Makefile.am (install-exec-hook): Rename libgpgcedev-0.dll. Modified: trunk/src/assuan-uds.c =================================================================== --- trunk/src/assuan-uds.c 2010-04-14 14:33:25 UTC (rev 369) +++ trunk/src/assuan-uds.c 2010-04-16 00:52:49 UTC (rev 370) @@ -116,8 +116,10 @@ "unexpected ancillary data received"); else { - int fd = *((int*)CMSG_DATA (cmptr)); + int fd; + memcpy (&fd, CMSG_DATA (cmptr), sizeof (fd)); + if (ctx->uds.pendingfdscount >= DIM (ctx->uds.pendingfds)) { TRACE1 (ctx, ASSUAN_LOG_SYSIO, "uds_reader", ctx, @@ -208,8 +210,9 @@ cmptr->cmsg_len = CMSG_LEN(sizeof(int)); cmptr->cmsg_level = SOL_SOCKET; cmptr->cmsg_type = SCM_RIGHTS; - *((int*)CMSG_DATA (cmptr)) = fd; + memcpy (CMSG_DATA (cmptr), &fd, sizeof (fd)); + len = _assuan_sendmsg (ctx, ctx->outbound.fd, &msg, 0); if (len < 0) { From cvs at cvs.gnupg.org Fri Apr 16 04:03:49 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Fri, 16 Apr 2010 04:03:49 +0200 Subject: [svn] gcry - r1429 - trunk/src Message-ID: Author: marcus Date: 2010-04-16 04:03:49 +0200 (Fri, 16 Apr 2010) New Revision: 1429 Modified: trunk/src/ChangeLog trunk/src/sexp.c Log: 2010-04-16 Marcus Brinkmann * sexp.c: (sexp_sscan): Make it variable length, and rename the old version to ... (vsexp_sscan): ... this new function. Also swap last two arguments. (gcry_sexp_create): Remove dummy va_list. (gcry_sexp_build): Use vsexp_sscan instead of sexp_sscan. (_gcry_sexp_vbuild): Likewise. (gcry_sexp_build_array): Remove dummy va_list. (gcry_sexp_sscan): Likewise. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-04-14 14:32:53 UTC (rev 1428) +++ trunk/src/ChangeLog 2010-04-16 02:03:49 UTC (rev 1429) @@ -1,3 +1,13 @@ +2010-04-16 Marcus Brinkmann + + * sexp.c: (sexp_sscan): Make it variable length, and rename the old version to ... + (vsexp_sscan): ... this new function. Also swap last two arguments. + (gcry_sexp_create): Remove dummy va_list. + (gcry_sexp_build): Use vsexp_sscan instead of sexp_sscan. + (_gcry_sexp_vbuild): Likewise. + (gcry_sexp_build_array): Remove dummy va_list. + (gcry_sexp_sscan): Likewise. + 2010-04-12 Brad Hards (wk) Spelling fixes. Modified: trunk/src/sexp.c =================================================================== --- trunk/src/sexp.c 2010-04-14 14:32:53 UTC (rev 1428) +++ trunk/src/sexp.c 2010-04-16 02:03:49 UTC (rev 1429) @@ -54,9 +54,14 @@ #define TOKEN_SPECIALS "-./_:*+=" static gcry_error_t +vsexp_sscan (gcry_sexp_t *retsexp, size_t *erroff, + const char *buffer, size_t length, int argflag, + void **arg_list, va_list arg_ptr); + +static gcry_error_t sexp_sscan (gcry_sexp_t *retsexp, size_t *erroff, const char *buffer, size_t length, int argflag, - va_list arg_ptr, void **arg_list); + void **arg_list, ...); /* Return true if P points to a byte containing a whitespace according to the S-expressions definition. */ @@ -210,7 +215,6 @@ { gcry_error_t errcode; gcry_sexp_t se; - volatile va_list dummy_arg_ptr; if (!retsexp) return gcry_error (GPG_ERR_INV_ARG); @@ -230,7 +234,7 @@ length = strlen ((char *)buffer); } - errcode = sexp_sscan (&se, NULL, buffer, length, 0, dummy_arg_ptr, NULL); + errcode = sexp_sscan (&se, NULL, buffer, length, 0, NULL); if (errcode) return errcode; @@ -973,9 +977,9 @@ * regardless whether it is needed or not. */ static gcry_error_t -sexp_sscan (gcry_sexp_t *retsexp, size_t *erroff, - const char *buffer, size_t length, int argflag, - va_list arg_ptr, void **arg_list) +vsexp_sscan (gcry_sexp_t *retsexp, size_t *erroff, + const char *buffer, size_t length, int argflag, + void **arg_list, va_list arg_ptr) { gcry_err_code_t err = 0; static const char tokenchars[] = @@ -1507,6 +1511,24 @@ #undef STORE_LEN } + +static gcry_error_t +sexp_sscan (gcry_sexp_t *retsexp, size_t *erroff, + const char *buffer, size_t length, int argflag, + void **arg_list, ...) +{ + gcry_error_t rc; + va_list arg_ptr; + + va_start (arg_ptr, arg_list); + rc = vsexp_sscan (retsexp, erroff, buffer, length, argflag, + arg_list, arg_ptr); + va_end (arg_ptr); + + return rc; +} + + gcry_error_t gcry_sexp_build (gcry_sexp_t *retsexp, size_t *erroff, const char *format, ...) { @@ -1514,8 +1536,8 @@ va_list arg_ptr; va_start (arg_ptr, format); - rc = sexp_sscan (retsexp, erroff, format, strlen(format), 1, - arg_ptr, NULL); + rc = vsexp_sscan (retsexp, erroff, format, strlen(format), 1, + NULL, arg_ptr); va_end (arg_ptr); return rc; @@ -1526,42 +1548,26 @@ _gcry_sexp_vbuild (gcry_sexp_t *retsexp, size_t *erroff, const char *format, va_list arg_ptr) { - return sexp_sscan (retsexp, erroff, format, strlen(format), 1, - arg_ptr, NULL); + return vsexp_sscan (retsexp, erroff, format, strlen(format), 1, + NULL, arg_ptr); } + /* Like gcry_sexp_build, but uses an array instead of variable function arguments. */ gcry_error_t gcry_sexp_build_array (gcry_sexp_t *retsexp, size_t *erroff, const char *format, void **arg_list) { - /* We don't need the va_list because it is controlled by the - following flag, however we have to pass it but can't initialize - it as there is no portable way to do so. volatile is needed to - suppress the compiler warning */ - volatile va_list dummy_arg_ptr; - - gcry_error_t rc; + return sexp_sscan (retsexp, erroff, format, strlen(format), 1, arg_list); +} - rc = sexp_sscan (retsexp, erroff, format, strlen(format), 1, - dummy_arg_ptr, arg_list); - return rc; -} - gcry_error_t gcry_sexp_sscan (gcry_sexp_t *retsexp, size_t *erroff, const char *buffer, size_t length) { - /* We don't need the va_list because it is controlled by the - following flag, however we have to pass it but can't initialize - it as there is no portable way to do so. volatile is needed to - suppress the compiler warning */ - volatile va_list dummy_arg_ptr; - - return sexp_sscan (retsexp, erroff, buffer, length, 0, - dummy_arg_ptr, NULL); + return sexp_sscan (retsexp, erroff, buffer, length, 0, NULL); } From cvs at cvs.gnupg.org Fri Apr 16 04:11:34 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Fri, 16 Apr 2010 04:11:34 +0200 Subject: [svn] pinentry - r226 - in trunk: . secmem Message-ID: Author: marcus Date: 2010-04-16 04:11:33 +0200 (Fri, 16 Apr 2010) New Revision: 226 Modified: trunk/ChangeLog trunk/secmem/util.c Log: 2010-04-16 Marcus Brinkmann * secmem/util.c: Fix inverted test. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-04-14 18:55:11 UTC (rev 225) +++ trunk/ChangeLog 2010-04-16 02:11:33 UTC (rev 226) @@ -1,3 +1,7 @@ +2010-04-16 Marcus Brinkmann + + * secmem/util.c: Fix inverted test. + 2010-04-12 Werner Koch * w32/main.c (dlg_proc): Act on VK_RETURN. Modified: trunk/secmem/util.c =================================================================== --- trunk/secmem/util.c 2010-04-14 18:55:11 UTC (rev 225) +++ trunk/secmem/util.c 2010-04-16 02:11:33 UTC (rev 226) @@ -19,7 +19,7 @@ #define _GNU_SOURCE 1 #include -#ifdef HAVE_W32CE_SYSTEM +#ifndef HAVE_W32CE_SYSTEM # include #endif #include From cvs at cvs.gnupg.org Fri Apr 16 16:08:41 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 16 Apr 2010 16:08:41 +0200 Subject: [svn] gpgme - r1459 - trunk/src Message-ID: Author: wk Date: 2010-04-16 16:08:41 +0200 (Fri, 16 Apr 2010) New Revision: 1459 Modified: trunk/src/ChangeLog trunk/src/w32-io.c Log: More robust detection of handle and sockets Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-03-15 12:04:53 UTC (rev 1458) +++ trunk/src/ChangeLog 2010-04-16 14:08:41 UTC (rev 1459) @@ -1,3 +1,8 @@ +2010-04-16 Werner Koch + + * w32-io.c (is_socket): New. + (reader, writer): Use it to figure out the API to use. + 2010-03-15 Werner Koch * gpgme.h.in: Add autoconf template to set generated file to Modified: trunk/src/w32-io.c =================================================================== --- trunk/src/w32-io.c 2010-03-15 12:04:53 UTC (rev 1458) +++ trunk/src/w32-io.c 2010-04-16 14:08:41 UTC (rev 1459) @@ -1,6 +1,6 @@ /* w32-io.c - W32 API I/O functions. Copyright (C) 2000 Werner Koch (dd9jn) - Copyright (C) 2001, 2002, 2003, 2004, 2007 g10 Code GmbH + Copyright (C) 2001, 2002, 2003, 2004, 2007, 2010 g10 Code GmbH This file is part of GPGME. @@ -175,16 +175,46 @@ } +/* Return true if HD refers to a socket. */ +static int +is_socket (HANDLE hd) +{ + /* We need to figure out whether we are working on a socket or on a + handle. A trivial way would be to check for the return code of + recv and see if it is WSAENOTSOCK. However the recv may block + after the server process died and thus the destroy_reader will + hang. Another option is to use getsockopt to test whether it is + a socket. The bug here is that once a socket with a certain + values has been opened, closed and later a CreatePipe returned + the same value (i.e. handle), getsockopt still believes it is a + socket. What we do now is to use a combination of GetFileType + and GetNamedPipeInfo. The specs say that the latter may be used + on anonymous pipes as well. Note that there are claims that + since winsocket version 2 ReadFile may be used on a socket but + only if it is supported by the service provider. Tests on a + stock XP using a local TCP socket show that it does not work. */ + DWORD dummyflags, dummyoutsize, dummyinsize, dummyinst; + if (GetFileType (hd) == FILE_TYPE_PIPE + && !GetNamedPipeInfo (hd, &dummyflags, &dummyoutsize, + &dummyinsize, &dummyinst)) + return 1; /* Function failed; thus we assume it is a socket. */ + else + return 0; /* Success; this is not a socket. */ +} + + static DWORD CALLBACK reader (void *arg) { struct reader_context_s *ctx = arg; int nbytes; DWORD nread; - int try_recv = 1; + int sock; TRACE_BEG1 (DEBUG_SYSIO, "gpgme:reader", ctx->file_hd, "thread=%p", ctx->thread_hd); + sock = is_socket (ctx->file_hd); + for (;;) { LOCK (ctx->mutex); @@ -212,17 +242,15 @@ nbytes = READBUF_SIZE - ctx->writepos; UNLOCK (ctx->mutex); - TRACE_LOG1 ("reading %d bytes", nbytes); + TRACE_LOG2 ("%s %d bytes", sock? "receiving":"reading", nbytes); - if (try_recv) + if (sock) { int n; n = recv (handle_to_socket (ctx->file_hd), ctx->buffer + ctx->writepos, nbytes, 0); - if (n < 0 && WSAGetLastError () == WSAENOTSOCK) - try_recv = 0; - else if (n < 0) + if (n < 0) { ctx->error_code = (int) WSAGetLastError (); if (ctx->error_code == ERROR_BROKEN_PIPE) @@ -237,11 +265,9 @@ } break; } - else - nread = n; - + nread = n; } - if (!try_recv) + else { if (!ReadFile (ctx->file_hd, ctx->buffer + ctx->writepos, nbytes, &nread, NULL)) @@ -540,10 +566,12 @@ { struct writer_context_s *ctx = arg; DWORD nwritten; - int try_send = 1; + int sock; TRACE_BEG1 (DEBUG_SYSIO, "gpgme:writer", ctx->file_hd, "thread=%p", ctx->thread_hd); + sock = is_socket (ctx->file_hd); + for (;;) { LOCK (ctx->mutex); @@ -571,11 +599,12 @@ } UNLOCK (ctx->mutex); - TRACE_LOG1 ("writing %d bytes", ctx->nbytes); + TRACE_LOG2 ("%s %d bytes", sock?"sending":"writing", ctx->nbytes); + /* Note that CTX->nbytes is not zero at this point, because _gpgme_io_write always writes at least 1 byte before waking us up, unless CTX->stop_me is true, which we catch above. */ - if (try_send) + if (sock) { /* We need to try send first because a socket handle can't be used with WriteFile. */ @@ -583,19 +612,16 @@ n = send (handle_to_socket (ctx->file_hd), ctx->buffer, ctx->nbytes, 0); - if (n < 0 && WSAGetLastError () == WSAENOTSOCK) - try_send = 0; - else if (n < 0) + if (n < 0) { ctx->error_code = (int) WSAGetLastError (); ctx->error = 1; TRACE_LOG1 ("send error: ec=%d", ctx->error_code); break; } - else - nwritten = n; + nwritten = n; } - if (!try_send) + else { if (!WriteFile (ctx->file_hd, ctx->buffer, ctx->nbytes, &nwritten, NULL)) From cvs at cvs.gnupg.org Fri Apr 16 16:17:57 2010 From: cvs at cvs.gnupg.org (cvs user werner) Date: Fri, 16 Apr 2010 16:17:57 +0200 Subject: misc-scripts (sha1sum.c) Message-ID: Date: Friday, April 16, 2010 @ 16:17:57 Author: werner Path: /cvs/wk/misc-scripts Modified: sha1sum.c Add option -0 + From cvs at cvs.gnupg.org Fri Apr 16 16:19:05 2010 From: cvs at cvs.gnupg.org (cvs user werner) Date: Fri, 16 Apr 2010 16:19:05 +0200 Subject: misc-scripts (sha1sum.c) Message-ID: Date: Friday, April 16, 2010 @ 16:19:05 Author: werner Path: /cvs/wk/misc-scripts Modified: sha1sum.c Update version From cvs at cvs.gnupg.org Mon Apr 19 10:55:19 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 19 Apr 2010 10:55:19 +0200 Subject: [svn] assuan - r371 - trunk/src Message-ID: Author: wk Date: 2010-04-19 10:55:19 +0200 (Mon, 19 Apr 2010) New Revision: 371 Modified: trunk/src/ChangeLog trunk/src/system-w32.c Log: More robust detection of sockets Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-04-16 00:52:49 UTC (rev 370) +++ trunk/src/ChangeLog 2010-04-19 08:55:19 UTC (rev 371) @@ -1,3 +1,8 @@ +2010-04-19 Werner Koch + + * system-w32.c (is_socket): New. + (__assuan_read, __assuan_write): Use is_socket. + 2010-04-16 Marcus Brinkmann * assuan-uds.c (uds_reader, uds_sendfd): Don't break strict Modified: trunk/src/system-w32.c =================================================================== --- trunk/src/system-w32.c 2010-04-16 00:52:49 UTC (rev 370) +++ trunk/src/system-w32.c 2010-04-19 08:55:19 UTC (rev 371) @@ -162,40 +162,63 @@ +/* Return true if HD refers to a socket. */ +static int +is_socket (HANDLE hd) +{ + /* We need to figure out whether we are working on a socket or on a + handle. A trivial way would be to check for the return code of + recv and see if it is WSAENOTSOCK. However the recv may block + after the server process died and thus the destroy_reader will + hang. Another option is to use getsockopt to test whether it is + a socket. The bug here is that once a socket with a certain + values has been opened, closed and later a CreatePipe returned + the same value (i.e. handle), getsockopt still believes it is a + socket. What we do now is to use a combination of GetFileType + and GetNamedPipeInfo. The specs say that the latter may be used + on anonymous pipes as well. Note that there are claims that + since winsocket version 2 ReadFile may be used on a socket but + only if it is supported by the service provider. Tests on a + stock XP using a local TCP socket show that it does not work. */ + DWORD dummyflags, dummyoutsize, dummyinsize, dummyinst; + if (GetFileType (hd) == FILE_TYPE_PIPE + && !GetNamedPipeInfo (hd, &dummyflags, &dummyoutsize, + &dummyinsize, &dummyinst)) + return 1; /* Function failed; thus we assume it is a socket. */ + else + return 0; /* Success; this is not a socket. */ +} + + static ssize_t __assuan_read (assuan_context_t ctx, assuan_fd_t fd, void *buffer, size_t size) { - /* Due to the peculiarities of the W32 API we can't use read for a - network socket and thus we try to use recv first and fallback to - read if recv detects that it is not a network socket. */ int res; - - res = recv (HANDLE2SOCKET (fd), buffer, size, 0); + int ec = 0; + + if (is_socket (fd)) + { + res = recv (HANDLE2SOCKET (fd), buffer, size, 0); + if (res == -1) + ec = WSAGetLastError (); + } + else + { + DWORD nread = 0; + if (!ReadFile (fd, buffer, size, &nread, NULL)) + { + res = -1; + ec = GetLastError (); + } + else + res = nread; + } if (res == -1) { - switch (WSAGetLastError ()) + switch (ec) { case WSAENOTSOCK: - { - DWORD nread = 0; - - res = ReadFile (fd, buffer, size, &nread, NULL); - if (! res) - { - switch (GetLastError ()) - { - case ERROR_BROKEN_PIPE: - gpg_err_set_errno (EPIPE); - break; - - default: - gpg_err_set_errno (EIO); - } - res = -1; - } - else - res = (int) nread; - } + gpg_err_set_errno (EBADF); break; case WSAEWOULDBLOCK: @@ -220,35 +243,50 @@ __assuan_write (assuan_context_t ctx, assuan_fd_t fd, const void *buffer, size_t size) { - /* Due to the peculiarities of the W32 API we can't use write for a - network socket and thus we try to use send first and fallback to - write if send detects that it is not a network socket. */ int res; - - res = send (HANDLE2SOCKET (fd), buffer, size, 0); - if (res == -1 && WSAGetLastError () == WSAENOTSOCK) + int ec = 0; + + if (is_socket (fd)) { + res = send (HANDLE2SOCKET (fd), buffer, size, 0); + if (res == -1) + ec = WSAGetLastError (); + } + else + { DWORD nwrite; - res = WriteFile (fd, buffer, size, &nwrite, NULL); - if (! res) + if (!WriteFile (fd, buffer, size, &nwrite, NULL)) { - switch (GetLastError ()) - { - case ERROR_BROKEN_PIPE: - case ERROR_NO_DATA: - gpg_err_set_errno (EPIPE); - break; - - default: - gpg_err_set_errno (EIO); - break; - } res = -1; + ec = GetLastError (); } - else - res = (int) nwrite; + else + res = (int)nwrite; } + if (res == -1) + { + switch (ec) + { + case WSAENOTSOCK: + gpg_err_set_errno (EBADF); + break; + + case WSAEWOULDBLOCK: + gpg_err_set_errno (EAGAIN); + break; + + case ERROR_BROKEN_PIPE: + case ERROR_NO_DATA: + gpg_err_set_errno (EPIPE); + break; + + default: + gpg_err_set_errno (EIO); + break; + } + + } return res; } From cvs at cvs.gnupg.org Mon Apr 19 11:26:56 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 19 Apr 2010 11:26:56 +0200 Subject: [svn] w32pth - r37 - trunk Message-ID: Author: wk Date: 2010-04-19 11:26:56 +0200 (Mon, 19 Apr 2010) New Revision: 37 Modified: trunk/ChangeLog trunk/w32-io.c trunk/w32-pth.c Log: Change the way we distinguish sockets from handles Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-04-14 14:32:19 UTC (rev 36) +++ trunk/ChangeLog 2010-04-19 09:26:56 UTC (rev 37) @@ -1,3 +1,11 @@ +2010-04-19 Werner Koch + + * w32-pth.c (is_socket_2): New. + (do_pth_read, do_pth_write): Use is_socket_2. + + * w32-io.c (is_socket): New. + (reader, writer): Use is_socket. + 2010-04-08 Werner Koch * w32-io.c (reader, writer) [W32CE]: Take care of Modified: trunk/w32-io.c =================================================================== --- trunk/w32-io.c 2010-04-14 14:32:19 UTC (rev 36) +++ trunk/w32-io.c 2010-04-19 09:26:56 UTC (rev 37) @@ -306,15 +306,51 @@ } +/* Return true if HD refers to a socket. */ +static int +is_socket (HANDLE hd) +{ +#ifdef HAVE_W32CE_SYSTEM + (void)hd; + return 0; +#else + /* We need to figure out whether we are working on a socket or on a + handle. A trivial way would be to check for the return code of + recv and see if it is WSAENOTSOCK. However the recv may block + after the server process died and thus the destroy_reader will + hang. Another option is to use getsockopt to test whether it is + a socket. The bug here is that once a socket with a certain + values has been opened, closed and later a CreatePipe returned + the same value (i.e. handle), getsockopt still believes it is a + socket. What we do now is to use a combination of GetFileType + and GetNamedPipeInfo. The specs say that the latter may be used + on anonymous pipes as well. Note that there are claims that + since winsocket version 2 ReadFile may be used on a socket but + only if it is supported by the service provider. Tests on a + stock XP using a local TCP socket show that it does not work. */ + DWORD dummyflags, dummyoutsize, dummyinsize, dummyinst; + if (GetFileType (hd) == FILE_TYPE_PIPE + && !GetNamedPipeInfo (hd, &dummyflags, &dummyoutsize, + &dummyinsize, &dummyinst)) + return 1; /* Function failed; thus we assume it is a socket. */ + else + return 0; /* Success; this is not a socket. */ +#endif +} + + static DWORD CALLBACK reader (void *arg) { struct reader_context_s *ctx = arg; int nbytes; DWORD nread; + int sock; TRACE_BEG1 (DEBUG_SYSIO, "pth:reader", ctx->file_hd, "thread=%p", ctx->thread_hd); + sock = is_socket (ctx->file_hd); + for (;;) { LOCK (ctx->mutex); @@ -342,35 +378,62 @@ nbytes = READBUF_SIZE - ctx->writepos; UNLOCK (ctx->mutex); - TRACE_LOG1 ("reading %d bytes", nbytes); - if (!ReadFile (ctx->file_hd, - ctx->buffer + ctx->writepos, nbytes, &nread, NULL)) - { - ctx->error_code = (int) GetLastError (); - if (ctx->error_code == ERROR_BROKEN_PIPE) - { - ctx->eof = 1; - TRACE_LOG ("got EOF (broken pipe)"); + TRACE_LOG2 ("%s %d bytes", sock? "receiving":"reading", nbytes); + + if (sock) + { + int n; + + n = recv ((int)ctx->file_hd, + ctx->buffer + ctx->writepos, nbytes, 0); + if (n < 0) + { + ctx->error_code = (int) WSAGetLastError (); + if (ctx->error_code == ERROR_BROKEN_PIPE) + { + ctx->eof = 1; + TRACE_LOG ("got EOF (broken connection)"); + } + else + { + ctx->error = 1; + TRACE_LOG1 ("recv error: ec=%d", ctx->error_code); + } + break; } + nread = n; + } + else + { + if (!ReadFile (ctx->file_hd, + ctx->buffer + ctx->writepos, nbytes, &nread, NULL)) + { + ctx->error_code = (int) GetLastError (); + if (ctx->error_code == ERROR_BROKEN_PIPE) + { + ctx->eof = 1; + TRACE_LOG ("got EOF (broken pipe)"); + } #ifdef HAVE_W32CE_SYSTEM - else if (ctx->error_code == ERROR_PIPE_NOT_CONNECTED - || ctx->error_code == ERROR_BUSY) - { - /* This may happen while one pipe end is still dangling - because the child process has not yet completed the - pipe creation. ERROR_BUSY has been seen as well, it - is propabaly returned by the device manager. */ - ctx->error_code = 0; - Sleep (100); - continue; - } + else if (ctx->error_code == ERROR_PIPE_NOT_CONNECTED + || ctx->error_code == ERROR_BUSY) + { + /* This may happen while one pipe end is still dangling + because the child process has not yet completed the + pipe creation. ERROR_BUSY has been seen as well, it + is propabaly returned by the device manager. */ + ctx->error_code = 0; + Sleep (100); + continue; + } #endif - else - { - ctx->error = 1; - TRACE_LOG1 ("read error: ec=%d", ctx->error_code); + else + { + ctx->error = 1; + TRACE_LOG1 ("read error: ec=%d", ctx->error_code); + } + break; } - break; } if (!nread) { @@ -648,9 +711,12 @@ { struct writer_context_s *ctx = arg; DWORD nwritten; + int sock; TRACE_BEG1 (DEBUG_SYSIO, "pth:writer", ctx->file_hd, "thread=%p", ctx->thread_hd); + sock = is_socket (ctx->file_hd); + for (;;) { LOCK (ctx->mutex); @@ -678,30 +744,52 @@ } UNLOCK (ctx->mutex); - TRACE_LOG1 ("writing %d bytes", ctx->nbytes); + TRACE_LOG2 ("%s %d bytes", sock?"sending":"writing", ctx->nbytes); + /* Note that CTX->nbytes is not zero at this point, because _pth_io_write always writes at least 1 byte before waking us up, unless CTX->stop_me is true, which we catch above. */ - if (!WriteFile (ctx->file_hd, ctx->buffer, - ctx->nbytes, &nwritten, NULL)) - { - ctx->error_code = (int) GetLastError (); + if (sock) + { + /* We need to try send first because a socket handle can't + be used with WriteFile. */ + int n; + + n = send ((int)ctx->file_hd, + ctx->buffer, ctx->nbytes, 0); + if (n < 0) + { + ctx->error_code = (int) WSAGetLastError (); + ctx->error = 1; + TRACE_LOG1 ("send error: ec=%d", ctx->error_code); + break; + } + nwritten = n; + } + else + { + if (!WriteFile (ctx->file_hd, ctx->buffer, + ctx->nbytes, &nwritten, NULL)) + { + ctx->error_code = (int) GetLastError (); #ifdef HAVE_W32CE_SYSTEM - if (ctx->error_code == ERROR_PIPE_NOT_CONNECTED - || ctx->error_code == ERROR_BUSY) - { - /* This may happen while one pipe end is still dangling - because the child process has not yet completed the - pipe creation. ERROR_BUSY has been seen as well, it - is propabaly returned by the device manager. */ - ctx->error_code = 0; - Sleep (100); - continue; + if (ctx->error_code == ERROR_PIPE_NOT_CONNECTED + || ctx->error_code == ERROR_BUSY) + { + /* This may happen while one pipe end is still + dangling because the child process has not yet + completed the pipe creation. ERROR_BUSY has been + seen as well, it is propabaly returned by the + device manager. */ + ctx->error_code = 0; + Sleep (100); + continue; + } +#endif + ctx->error = 1; + TRACE_LOG1 ("write error: ec=%d", ctx->error_code); + break; } -#endif - ctx->error = 1; - TRACE_LOG1 ("write error: ec=%d", ctx->error_code); - break; } TRACE_LOG1 ("wrote %d bytes", (int) nwritten); Modified: trunk/w32-pth.c =================================================================== --- trunk/w32-pth.c 2010-04-14 14:32:19 UTC (rev 36) +++ trunk/w32-pth.c 2010-04-19 09:26:56 UTC (rev 37) @@ -884,7 +884,40 @@ } +/* Return true if HD refers to a socket. */ static int +is_socket_2 (int hd) +{ +#ifdef HAVE_W32CE_SYSTEM + (void)hd; + return 1; /* Assume socket. */ +#else + /* We need to figure out whether we are working on a socket or on a + handle. A trivial way would be to check for the return code of + recv and see if it is WSAENOTSOCK. However the recv may block + after the server process died and thus the destroy_reader will + hang. Another option is to use getsockopt to test whether it is + a socket. The bug here is that once a socket with a certain + values has been opened, closed and later a CreatePipe returned + the same value (i.e. handle), getsockopt still believes it is a + socket. What we do now is to use a combination of GetFileType + and GetNamedPipeInfo. The specs say that the latter may be used + on anonymous pipes as well. Note that there are claims that + since winsocket version 2 ReadFile may be used on a socket but + only if it is supported by the service provider. Tests on a + stock XP using a local TCP socket show that it does not work. */ + DWORD dummyflags, dummyoutsize, dummyinsize, dummyinst; + if (GetFileType ((HANDLE)hd) == FILE_TYPE_PIPE + && !GetNamedPipeInfo ((HANDLE)hd, &dummyflags, &dummyoutsize, + &dummyinsize, &dummyinst)) + return 1; /* Function failed; thus we assume it is a socket. */ + else + return 0; /* Success; this is not a socket. */ +#endif +} + + +static int pipe_is_not_connected (void) { #ifdef HAVE_W32CE_SYSTEM @@ -910,6 +943,7 @@ { int n; HANDLE hd; + int use_readfile = 0; /* We have to check for internal pipes first, as socket operations can block on these. */ @@ -918,8 +952,20 @@ n = _pth_io_read (fd, buffer, size); else { - n = recv (fd, buffer, size, 0); - if (n == -1 && WSAGetLastError () == WSAENOTSOCK) + if (is_socket_2 (fd)) + { + n = recv (fd, buffer, size, 0); +#ifdef HAVE_W32CE_SYSTEM + if (n == -1 && WSAGetLastError () == WSAENOTSOCK) + use_readfile = 1; /* Fallback to ReadFile. */ +#endif + } + else + { + n = -1; + use_readfile = 1; + } + if (n == -1 && use_readfile) { DWORD nread = 0; @@ -941,7 +987,12 @@ n = (int) nread; } else if (n == -1) - set_errno (map_wsa_to_errno (WSAGetLastError ())); + { + if (DBG_ERROR) + fprintf (dbgfp, "%s: pth_read(0x%x) recv failed: ec=%d\n", + log_get_prefix (NULL), fd, (int)WSAGetLastError ()); + set_errno (map_wsa_to_errno (WSAGetLastError ())); + } } return n; @@ -1017,6 +1068,7 @@ { int n; HANDLE hd; + int use_writefile = 0; /* We have to check for internal pipes first, as socket operations can block on these. */ @@ -1025,8 +1077,20 @@ n = _pth_io_write (fd, buffer, size); else { - n = send (fd, buffer, size, 0); - if (n == -1 && WSAGetLastError () == WSAENOTSOCK) + if (is_socket_2 (fd)) + { + n = send (fd, buffer, size, 0); +#ifdef HAVE_W32CE_SYSTEM + if (n == -1 && WSAGetLastError () == WSAENOTSOCK) + use_writefile = 1; /* Fallback to ReadFile. */ +#endif + } + else + { + n = -1; + use_writefile = 1; + } + if (n == -1 && use_writefile) { DWORD nwrite; char strerr[256]; @@ -1046,7 +1110,12 @@ n = (int) nwrite; } else if (n == -1) - set_errno (map_wsa_to_errno (WSAGetLastError ())); + { + if (DBG_ERROR) + fprintf (dbgfp, "%s: pth_write(0x%x) send failed: ec=%d\n", + log_get_prefix (NULL), fd, (int)WSAGetLastError ()); + set_errno (map_wsa_to_errno (WSAGetLastError ())); + } } return n; From cvs at cvs.gnupg.org Mon Apr 19 15:01:16 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 19 Apr 2010 15:01:16 +0200 Subject: [svn] pinentry - r227 - in trunk: . gtk+-2 Message-ID: Author: wk Date: 2010-04-19 15:01:15 +0200 (Mon, 19 Apr 2010) New Revision: 227 Modified: trunk/ChangeLog trunk/gtk+-2/gtksecentry.c trunk/gtk+-2/pinentry-gtk-2.c Log: Fix segv when using -g. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-04-16 02:11:33 UTC (rev 226) +++ trunk/ChangeLog 2010-04-19 13:01:15 UTC (rev 227) @@ -1,3 +1,15 @@ +2010-04-19 Werner Koch + + * gtk+-2/gtksecentry.c (gtk_secure_entry_delete_cb) + (gtk_secure_entry_toggle_overwrite, activate_cb) + (unichar_chosen_func): Comment out these unused functions. + (secentry_malloc): Fix format string error. + +2010-04-19 Stanislav Ochotnicky (wk) + + * gtk+-2/pinentry-gtk-2.c (ungrab_keyboard): Fix segv when using + option -g. + 2010-04-16 Marcus Brinkmann * secmem/util.c: Fix inverted test. Modified: trunk/gtk+-2/gtksecentry.c =================================================================== --- trunk/gtk+-2/gtksecentry.c 2010-04-16 02:11:33 UTC (rev 226) +++ trunk/gtk+-2/gtksecentry.c 2010-04-19 13:01:15 UTC (rev 227) @@ -277,7 +277,7 @@ else p = (gpointer) malloc(size); if (!p) - g_error("could not allocate %ld bytes", size); + g_error("could not allocate %lu bytes", (unsigned long)size); return p; } @@ -1844,21 +1844,21 @@ gtk_secure_entry_pend_cursor_blink(entry); } -static void -gtk_secure_entry_delete_cb(GtkSecureEntry * entry) -{ - GtkEditable *editable = GTK_EDITABLE(entry); - gint start, end; +/* static void */ +/* gtk_secure_entry_delete_cb(GtkSecureEntry * entry) */ +/* { */ +/* GtkEditable *editable = GTK_EDITABLE(entry); */ +/* gint start, end; */ - if (gtk_editable_get_selection_bounds(editable, &start, &end)) - gtk_editable_delete_text(editable, start, end); -} +/* if (gtk_editable_get_selection_bounds(editable, &start, &end)) */ +/* gtk_editable_delete_text(editable, start, end); */ +/* } */ -static void -gtk_secure_entry_toggle_overwrite(GtkSecureEntry * entry) -{ - entry->overwrite_mode = !entry->overwrite_mode; -} +/* static void */ +/* gtk_secure_entry_toggle_overwrite(GtkSecureEntry * entry) */ +/* { */ +/* entry->overwrite_mode = !entry->overwrite_mode; */ +/* } */ static void gtk_secure_entry_real_activate(GtkSecureEntry * entry) @@ -3119,13 +3119,13 @@ /* Quick hack of a popup menu */ -static void -activate_cb(GtkWidget * menuitem, GtkSecureEntry * entry) -{ - const gchar *signal = - g_object_get_data(G_OBJECT(menuitem), "gtk-signal"); - g_signal_emit_by_name(entry, signal); -} +/* static void */ +/* activate_cb(GtkWidget * menuitem, GtkSecureEntry * entry) */ +/* { */ +/* const gchar *asignal = */ +/* g_object_get_data(G_OBJECT(menuitem), "gtk-signal"); */ +/* g_signal_emit_by_name(entry, asignal); */ +/* } */ static gboolean @@ -3137,13 +3137,13 @@ } -static void -unichar_chosen_func(const char *text, gpointer data) -{ - GtkSecureEntry *entry = GTK_SECURE_ENTRY(data); +/* static void */ +/* unichar_chosen_func(const char *text, gpointer data) */ +/* { */ +/* GtkSecureEntry *entry = GTK_SECURE_ENTRY(data); */ - gtk_secure_entry_enter_text(entry, text); -} +/* gtk_secure_entry_enter_text(entry, text); */ +/* } */ /* We display the cursor when * Modified: trunk/gtk+-2/pinentry-gtk-2.c =================================================================== --- trunk/gtk+-2/pinentry-gtk-2.c 2010-04-16 02:11:33 UTC (rev 226) +++ trunk/gtk+-2/pinentry-gtk-2.c 2010-04-19 13:01:15 UTC (rev 227) @@ -145,7 +145,11 @@ { gdk_keyboard_ungrab (gdk_event_get_time (event)); /* Unmake window transient for the root window. */ - gdk_window_set_transient_for (win->window, NULL); + /* gdk_window_set_transient_for cannot be used with parent = NULL to + unset transient hint (unlike gtk_ version which can). Replacement + code is taken from gtk_window_transient_parent_unrealized. */ + gdk_property_delete (win->window, + gdk_atom_intern_static_string ("WM_TRANSIENT_FOR")); } From cvs at cvs.gnupg.org Mon Apr 19 18:59:24 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 19 Apr 2010 18:59:24 +0200 Subject: [svn] gpgme - r1460 - trunk/src Message-ID: Author: marcus Date: 2010-04-19 18:59:23 +0200 (Mon, 19 Apr 2010) New Revision: 1460 Modified: trunk/src/ChangeLog trunk/src/assuan-support.c trunk/src/engine-g13.c trunk/src/key.c trunk/src/ops.h trunk/src/posix-util.c trunk/src/vfs-create.c trunk/src/vfs-mount.c Log: 2010-04-19 Marcus Brinkmann * assuan-support.c (my_spawn): Cast to avoid warning. * engine-g13.c (g13_new): Make ARGV array of pointer to const char. (g13_assuan_simple_command) [!USE_DESCRIPTOR_FUNCTION]: Don't define. * ops.h (_gpgme_key_append_name): Same in prototype. * key.c (_gpgme_key_append_name): Make SRC argument pointer to const char. * posix-util.c (_gpgme_get_uiserver_socket_path): Make HOMEDIR const. * vfs-mount.c (gpgme_op_vfs_transact_start): Never define this potentially useful but currently unused function. * vfs-create.c (gpgme_op_vfs_transact_start): Likewise. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-04-16 14:08:41 UTC (rev 1459) +++ trunk/src/ChangeLog 2010-04-19 16:59:23 UTC (rev 1460) @@ -1,3 +1,18 @@ +2010-04-19 Marcus Brinkmann + + * assuan-support.c (my_spawn): Cast to avoid warning. + * engine-g13.c (g13_new): Make ARGV array of pointer to const + char. + (g13_assuan_simple_command) [!USE_DESCRIPTOR_FUNCTION]: Don't define. + * ops.h (_gpgme_key_append_name): Same in prototype. + * key.c (_gpgme_key_append_name): Make SRC argument pointer to + const char. + * posix-util.c (_gpgme_get_uiserver_socket_path): Make HOMEDIR + const. + * vfs-mount.c (gpgme_op_vfs_transact_start): Never define this + potentially useful but currently unused function. + * vfs-create.c (gpgme_op_vfs_transact_start): Likewise. + 2010-04-16 Werner Koch * w32-io.c (is_socket): New. Modified: trunk/src/assuan-support.c =================================================================== --- trunk/src/assuan-support.c 2010-04-16 14:08:41 UTC (rev 1459) +++ trunk/src/assuan-support.c 2010-04-19 16:59:23 UTC (rev 1460) @@ -158,8 +158,8 @@ fd_items[i].fd = -1; fd_items[i].dup_to = -1; - err = _gpgme_io_spawn (name, argv, IOSPAWN_FLAG_NOCLOSE, fd_items, - atfork, atforkvalue, r_pid); + err = _gpgme_io_spawn (name, (char*const*)argv, IOSPAWN_FLAG_NOCLOSE, + fd_items, atfork, atforkvalue, r_pid); if (! err) { i = 0; Modified: trunk/src/engine-g13.c =================================================================== --- trunk/src/engine-g13.c 2010-04-16 14:08:41 UTC (rev 1459) +++ trunk/src/engine-g13.c 2010-04-19 16:59:23 UTC (rev 1460) @@ -211,7 +211,7 @@ gpgme_error_t err = 0; engine_g13_t g13; int argc; - char *argv[5]; + const char *argv[5]; char *dft_display = NULL; char dft_ttyname[64]; char *dft_ttytype = NULL; @@ -392,6 +392,7 @@ } +#if USE_DESCRIPTOR_PASSING static gpgme_error_t g13_assuan_simple_command (assuan_context_t ctx, char *cmd, engine_status_handler_t status_fnc, @@ -442,6 +443,7 @@ return err; } +#endif static gpgme_error_t Modified: trunk/src/key.c =================================================================== --- trunk/src/key.c 2010-04-16 14:08:41 UTC (rev 1459) +++ trunk/src/key.c 2010-04-19 16:59:23 UTC (rev 1460) @@ -202,7 +202,7 @@ /* Take a name from the --with-colon listing, remove certain escape sequences sequences and put it into the list of UIDs. */ gpgme_error_t -_gpgme_key_append_name (gpgme_key_t key, char *src, int convert) +_gpgme_key_append_name (gpgme_key_t key, const char *src, int convert) { gpgme_user_id_t uid; char *dst; Modified: trunk/src/ops.h =================================================================== --- trunk/src/ops.h 2010-04-16 14:08:41 UTC (rev 1459) +++ trunk/src/ops.h 2010-04-19 16:59:23 UTC (rev 1460) @@ -128,7 +128,7 @@ gpgme_error_t _gpgme_key_new (gpgme_key_t *r_key); gpgme_error_t _gpgme_key_add_subkey (gpgme_key_t key, gpgme_subkey_t *r_subkey); -gpgme_error_t _gpgme_key_append_name (gpgme_key_t key, char *src, int convert); +gpgme_error_t _gpgme_key_append_name (gpgme_key_t key, const char *src, int convert); gpgme_key_sig_t _gpgme_key_add_sig (gpgme_key_t key, char *src); Modified: trunk/src/posix-util.c =================================================================== --- trunk/src/posix-util.c 2010-04-16 14:08:41 UTC (rev 1459) +++ trunk/src/posix-util.c 2010-04-19 16:59:23 UTC (rev 1460) @@ -74,7 +74,7 @@ _gpgme_get_uiserver_socket_path (void) { static char *socket_path; - char *homedir; + const char *homedir; const char name[] = "S.uiserver"; if (socket_path) Modified: trunk/src/vfs-create.c =================================================================== --- trunk/src/vfs-create.c 2010-04-16 14:08:41 UTC (rev 1459) +++ trunk/src/vfs-create.c 2010-04-19 16:59:23 UTC (rev 1460) @@ -58,7 +58,7 @@ } - +#if 0 /* XXXX. This is the asynchronous variant. */ static gpgme_error_t gpgme_op_vfs_transact_start (gpgme_ctx_t ctx, @@ -73,6 +73,7 @@ return vfs_start (ctx, 0, command, data_cb, data_cb_value, inq_cb, inq_cb_value, status_cb, status_cb_value); } +#endif /* XXXX. This is the synchronous variant. */ Modified: trunk/src/vfs-mount.c =================================================================== --- trunk/src/vfs-mount.c 2010-04-16 14:08:41 UTC (rev 1459) +++ trunk/src/vfs-mount.c 2010-04-19 16:59:23 UTC (rev 1460) @@ -116,6 +116,7 @@ +#if 0 /* XXXX. This is the asynchronous variant. */ static gpgme_error_t gpgme_op_vfs_transact_start (gpgme_ctx_t ctx, @@ -130,6 +131,7 @@ return vfs_start (ctx, 0, command, data_cb, data_cb_value, inq_cb, inq_cb_value, status_cb, status_cb_value); } +#endif /* XXXX. This is the synchronous variant. */ From cvs at cvs.gnupg.org Mon Apr 19 19:08:13 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 19 Apr 2010 19:08:13 +0200 Subject: [svn] gcry - r1430 - trunk/src Message-ID: Author: marcus Date: 2010-04-19 19:08:12 +0200 (Mon, 19 Apr 2010) New Revision: 1430 Modified: trunk/src/ChangeLog trunk/src/misc.c Log: 2010-04-19 Marcus Brinkmann * misc.c (write2stderr): Dummy variable to silence gcc warning. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-04-16 02:03:49 UTC (rev 1429) +++ trunk/src/ChangeLog 2010-04-19 17:08:12 UTC (rev 1430) @@ -1,3 +1,7 @@ +2010-04-19 Marcus Brinkmann + + * misc.c (write2stderr): Dummy variable to silence gcc warning. + 2010-04-16 Marcus Brinkmann * sexp.c: (sexp_sscan): Make it variable length, and rename the old version to ... Modified: trunk/src/misc.c =================================================================== --- trunk/src/misc.c 2010-04-16 02:03:49 UTC (rev 1429) +++ trunk/src/misc.c 2010-04-19 17:08:12 UTC (rev 1430) @@ -63,7 +63,9 @@ static void write2stderr( const char *s ) { - write( 2, s, strlen(s) ); + /* Dummy variable to silence gcc warning. */ + int res = write( 2, s, strlen(s) ); + (void) res; } /* From cvs at cvs.gnupg.org Mon Apr 19 19:15:03 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Mon, 19 Apr 2010 19:15:03 +0200 Subject: [svn] gcry - r1431 - trunk Message-ID: Author: marcus Date: 2010-04-19 19:15:03 +0200 (Mon, 19 Apr 2010) New Revision: 1431 Modified: trunk/ChangeLog trunk/configure.ac Log: 2010-04-19 Marcus Brinkmann * configure.ac: Check for -fno-strict-aliasing. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-04-19 17:08:12 UTC (rev 1430) +++ trunk/ChangeLog 2010-04-19 17:15:03 UTC (rev 1431) @@ -1,3 +1,7 @@ +2010-04-19 Marcus Brinkmann + + * configure.ac: Check for -fno-strict-aliasing. + 2010-04-12 Brad Hards (wk) * configure.ac: Print more verbose info at the end. Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2010-04-19 17:08:12 UTC (rev 1430) +++ trunk/configure.ac 2010-04-19 17:15:03 UTC (rev 1431) @@ -928,6 +928,17 @@ if test x"$_gcc_wopt" = xyes ; then CFLAGS="$CFLAGS -Wpointer-arith" fi + + AC_MSG_CHECKING([if gcc supports -fno-strict-aliasing]) + _gcc_cflags_save=$CFLAGS + CFLAGS="-fno-strict-aliasing" + AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),_gcc_wopt=yes,_gcc_wopt=no) + AC_MSG_RESULT($_gcc_wopt) + CFLAGS=$_gcc_cflags_save; + if test x"$_gcc_wopt" = xyes ; then + CFLAGS="$CFLAGS -fno-strict-aliasing" + fi + fi fi From cvs at cvs.gnupg.org Tue Apr 20 03:11:36 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue, 20 Apr 2010 03:11:36 +0200 Subject: [svn] GnuPG - r5309 - in trunk: common kbx tools Message-ID: Author: marcus Date: 2010-04-20 03:11:35 +0200 (Tue, 20 Apr 2010) New Revision: 5309 Modified: trunk/common/ChangeLog trunk/common/logging.c trunk/common/pka.c trunk/common/signal.c trunk/common/sysutils.c trunk/common/t-exechelp.c trunk/kbx/ChangeLog trunk/kbx/keybox-update.c trunk/tools/ChangeLog trunk/tools/gpgconf-comp.c Log: common/ 2010-04-20 Marcus Brinkmann * logging.c (do_log_ignore_arg): New helper function. (log_string): Use it to remove ugly volatile hack that causes gcc warning. (log_flush): Likewise. * sysutils.c (gnupg_unsetenv) [!HAVE_W32CE_SYSTEM]: Return something. (gnupg_setenv) [!HAVE_W32CE_SYSTEM]: Likewise. * pka.c (get_pka_info): Solve strict aliasing rule violation. * t-exechelp.c (test_close_all_fds): Use dummy variables to silence gcc warning. kbx/ 2010-04-20 Marcus Brinkmann * keybox-update.c [!HAVE_DOSISH_SYSTEM]: Include ../common/sysutils.h even then to silence gcc warning about missing declaration of gnupg_remove. tools/ 2010-04-20 Marcus Brinkmann * gpgconf-comp.c (option_check_validity): Use dummy variables to silence gcc warning. Modified: trunk/common/ChangeLog =================================================================== --- trunk/common/ChangeLog 2010-04-14 17:56:22 UTC (rev 5308) +++ trunk/common/ChangeLog 2010-04-20 01:11:35 UTC (rev 5309) @@ -1,3 +1,15 @@ +2010-04-20 Marcus Brinkmann + + * logging.c (do_log_ignore_arg): New helper function. + (log_string): Use it to remove ugly volatile hack that causes gcc + warning. + (log_flush): Likewise. + * sysutils.c (gnupg_unsetenv) [!HAVE_W32CE_SYSTEM]: Return something. + (gnupg_setenv) [!HAVE_W32CE_SYSTEM]: Likewise. + * pka.c (get_pka_info): Solve strict aliasing rule violation. + * t-exechelp.c (test_close_all_fds): Use dummy variables to + silence gcc warning. + 2010-04-14 Werner Koch * Makefile.am (noinst_LIBRARIES) [W32CE]: Exclude libsimple-pwquery. Modified: trunk/kbx/ChangeLog =================================================================== --- trunk/kbx/ChangeLog 2010-04-14 17:56:22 UTC (rev 5308) +++ trunk/kbx/ChangeLog 2010-04-20 01:11:35 UTC (rev 5309) @@ -1,3 +1,9 @@ +2010-04-20 Marcus Brinkmann + + * keybox-update.c [!HAVE_DOSISH_SYSTEM]: Include + ../common/sysutils.h even then to silence gcc warning about + missing declaration of gnupg_remove. + 2010-03-23 Werner Koch * Makefile.am (extra_libs): New. Modified: trunk/tools/ChangeLog =================================================================== --- trunk/tools/ChangeLog 2010-04-14 17:56:22 UTC (rev 5308) +++ trunk/tools/ChangeLog 2010-04-20 01:11:35 UTC (rev 5309) @@ -1,3 +1,8 @@ +2010-04-20 Marcus Brinkmann + + * gpgconf-comp.c (option_check_validity): Use dummy variables to + silence gcc warning. + 2010-04-14 Werner Koch * Makefile.am (bin_PROGRAMS) [W32CE]: Exclude gpgkey2ssh. Modified: trunk/common/logging.c =================================================================== --- trunk/common/logging.c 2010-04-14 17:56:22 UTC (rev 5308) +++ trunk/common/logging.c 2010-04-20 01:11:35 UTC (rev 5309) @@ -515,16 +515,23 @@ } +static void +do_log_ignore_arg (int level, const char *str, ...) +{ + va_list arg_ptr; + va_start (arg_ptr, str); + do_logv (level, 1, str, arg_ptr); + va_end (arg_ptr); +} + + void log_string (int level, const char *string) { - /* We need to provide a dummy arg_ptr. volatile is needed to - suppress compiler warnings. The static is required for gcc 4.4 - because it seems that it detects that a volatile automatic - variable is not any good if not initialized. */ - static volatile va_list dummy_arg_ptr; - - do_logv (level, 1, string, dummy_arg_ptr); + /* We need a dummy arg_ptr, but there is no portable way to create + one. So we call the do_logv function through a variadic wrapper. + MB: Why not just use "%s"? */ + do_log_ignore_arg (level, string); } @@ -604,8 +611,7 @@ void log_flush (void) { - static volatile va_list dummy_arg_ptr; - do_logv (JNLIB_LOG_CONT, 1, NULL, dummy_arg_ptr); + do_log_ignore_arg (JNLIB_LOG_CONT, NULL); } Modified: trunk/common/pka.c =================================================================== --- trunk/common/pka.c 2010-04-14 17:56:22 UTC (rev 5308) +++ trunk/common/pka.c 2010-04-20 01:11:35 UTC (rev 5309) @@ -180,8 +180,8 @@ unsigned char *p, *pend; const char *domain; char *name; + HEADER header; - domain = strrchr (address, '@'); if (!domain || domain == address || !domain[1]) return NULL; /* invalid mail address given. */ @@ -196,19 +196,25 @@ xfree (name); if (anslen < sizeof(HEADER)) return NULL; /* DNS resolver returned a too short answer. */ - if ( (rc=((HEADER*)answer)->rcode) != NOERROR ) + + /* Don't despair: A good compiler should optimize this away, as + header is just 32 byte and constant at compile time. It's + one way to comply with strict aliasing rules. */ + memcpy (&header, answer, sizeof (header)); + + if ( (rc=header.rcode) != NOERROR ) return NULL; /* DNS resolver returned an error. */ /* We assume that PACKETSZ is large enough and don't do dynmically expansion of the buffer. */ if (anslen > PACKETSZ) return NULL; /* DNS resolver returned a too long answer */ + + qdcount = ntohs (header.qdcount); + ancount = ntohs (header.ancount); + nscount = ntohs (header.nscount); + arcount = ntohs (header.arcount); - qdcount = ntohs (((HEADER*)answer)->qdcount); - ancount = ntohs (((HEADER*)answer)->ancount); - nscount = ntohs (((HEADER*)answer)->nscount); - arcount = ntohs (((HEADER*)answer)->arcount); - if (!ancount) return NULL; /* Got no answer. */ Modified: trunk/common/signal.c =================================================================== --- trunk/common/signal.c 2010-04-14 17:56:22 UTC (rev 5308) +++ trunk/common/signal.c 2010-04-20 01:11:35 UTC (rev 5309) @@ -89,6 +89,8 @@ static RETSIGTYPE got_fatal_signal (int sig) { + /* Dummy result variable to suppress gcc warning. */ + int res; const char *s; if (caught_fatal_sig) @@ -98,14 +100,14 @@ if (cleanup_fnc) cleanup_fnc (); /* Better don't translate these messages. */ - write (2, "\n", 1 ); + res = write (2, "\n", 1 ); s = log_get_prefix (NULL); if (s) - write(2, s, strlen (s)); - write (2, ": signal ", 9 ); + res = write(2, s, strlen (s)); + res = write (2, ": signal ", 9 ); s = get_signal_name(sig); if (s) - write (2, s, strlen(s) ); + res = write (2, s, strlen(s) ); else { /* We are in a signal handler so we can't use any kind of printf @@ -115,7 +117,7 @@ things are messed up because we modify its value. Although this is a bug in that system, we will protect against it. */ if (sig < 0 || sig >= 100000) - write (2, "?", 1); + res = write (2, "?", 1); else { int i, value, any=0; @@ -124,7 +126,7 @@ { if (value >= i || ((any || i==1) && !(value/i))) { - write (2, "0123456789"+(value/i), 1); + res = write (2, "0123456789"+(value/i), 1); if ((value/i)) any = 1; value %= i; @@ -132,7 +134,7 @@ } } } - write (2, " caught ... exiting\n", 20); + res = write (2, " caught ... exiting\n", 20); /* Reset action to default action and raise signal again */ init_one_signal (sig, SIG_DFL, 0); Modified: trunk/common/sysutils.c =================================================================== --- trunk/common/sysutils.c 2010-04-14 17:56:22 UTC (rev 5308) +++ trunk/common/sysutils.c 2010-04-20 01:11:35 UTC (rev 5309) @@ -604,7 +604,7 @@ (void)overwrite; return 0; #else - setenv (name, value, overwrite); + return setenv (name, value, overwrite); #endif } @@ -616,9 +616,9 @@ return 0; #else # ifdef HAVE_UNSETENV - unsetenv (name); + return unsetenv (name); # else - putenv (name); + return putenv (name); # endif #endif } Modified: trunk/common/t-exechelp.c =================================================================== --- trunk/common/t-exechelp.c 2010-04-14 17:56:22 UTC (rev 5308) +++ trunk/common/t-exechelp.c 2010-04-20 01:11:35 UTC (rev 5309) @@ -76,6 +76,7 @@ int max_fd = get_max_fds (); int *array; int fd; + int dummy_fd; int initial_count, count, n; #if 0 char buffer[100]; @@ -92,10 +93,10 @@ free (array); /* Some dups to get more file descriptors and close one. */ - dup (1); - dup (1); + dummy_fd = dup (1); + dummy_fd = dup (1); fd = dup (1); - dup (1); + dummy_fd = dup (1); close (fd); array = xget_all_open_fds (); @@ -136,14 +137,14 @@ int except[] = { 20, 23, 24, -1 }; for (n=initial_count; n < 31; n++) - dup (1); + dummy_fd = dup (1); array = xget_all_open_fds (); if (verbose) print_open_fds (array); free (array); for (n=0; n < 5; n++) { - dup (1); + dummy_fd = dup (1); array = xget_all_open_fds (); if (verbose) print_open_fds (array); Modified: trunk/kbx/keybox-update.c =================================================================== --- trunk/kbx/keybox-update.c 2010-04-14 17:56:22 UTC (rev 5308) +++ trunk/kbx/keybox-update.c 2010-04-20 01:11:35 UTC (rev 5309) @@ -26,9 +26,7 @@ #include #include "keybox-defs.h" -#ifdef HAVE_DOSISH_SYSTEM #include "../common/sysutils.h" -#endif #define EXTSEP_S "." Modified: trunk/tools/gpgconf-comp.c =================================================================== --- trunk/tools/gpgconf-comp.c 2010-04-14 17:56:22 UTC (rev 5308) +++ trunk/tools/gpgconf-comp.c 2010-04-20 01:11:35 UTC (rev 5309) @@ -2241,8 +2241,11 @@ } else if (gc_arg_type[option->arg_type].fallback == GC_ARG_TYPE_INT32) { + long res; + gpg_err_set_errno (0); - (void) strtol (arg, &arg, 0); + res = strtol (arg, &arg, 0); + (void) res; if (errno) gc_error (1, errno, "invalid argument for option %s", @@ -2254,8 +2257,11 @@ } else if (gc_arg_type[option->arg_type].fallback == GC_ARG_TYPE_INT32) { + unsigned long res; + gpg_err_set_errno (0); - (void) strtoul (arg, &arg, 0); + res = strtoul (arg, &arg, 0); + (void) res; if (errno) gc_error (1, errno, "invalid argument for option %s", From cvs at cvs.gnupg.org Tue Apr 20 12:52:43 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 20 Apr 2010 12:52:43 +0200 Subject: [svn] assuan - r372 - trunk Message-ID: Author: wk Date: 2010-04-20 12:52:43 +0200 (Tue, 20 Apr 2010) New Revision: 372 Modified: trunk/ChangeLog trunk/configure.ac Log: comment fix Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-04-19 08:55:19 UTC (rev 371) +++ trunk/ChangeLog 2010-04-20 10:52:43 UTC (rev 372) @@ -1,3 +1,7 @@ +2010-04-20 Werner Koch + + * configure.ac: Change wording of the no-funopen warning. + 2010-03-22 Werner Koch * configure.ac (CC_FOR_BUILD): Add test. Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2010-04-19 08:55:19 UTC (rev 371) +++ trunk/configure.ac 2010-04-20 10:52:43 UTC (rev 372) @@ -307,7 +307,8 @@ AC_MSG_WARN([ *** *** No implementation of fopencookie or funopen available. -*** The assuan_get_data_fp feature won't work. +*** The assuan_get_data_fp function won't work; see the +*** manual for details. GnuPG does not require this feature. ***]) fi fi From cvs at cvs.gnupg.org Tue Apr 20 13:52:33 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 20 Apr 2010 13:52:33 +0200 Subject: [svn] GnuPG - r5310 - trunk/common Message-ID: Author: wk Date: 2010-04-20 13:52:33 +0200 (Tue, 20 Apr 2010) New Revision: 5310 Added: trunk/common/gettime.h Modified: trunk/common/ChangeLog trunk/common/gettime.c trunk/common/util.h Log: Add a separate header for time related fucntions. Modified: trunk/common/ChangeLog =================================================================== --- trunk/common/ChangeLog 2010-04-20 01:11:35 UTC (rev 5309) +++ trunk/common/ChangeLog 2010-04-20 11:52:33 UTC (rev 5310) @@ -10,6 +10,16 @@ * t-exechelp.c (test_close_all_fds): Use dummy variables to silence gcc warning. +2010-04-15 Werner Koch + + * util.h: Factor time related fucntions out to ... + * gettime.h: New. + (gnupg_copy_time): Move to ... + * gettime.c (gnupg_copy_time): New. + + * sysutils.c (gnupg_setenv) [!W32CE]: Add missing return. + (gnupg_unsetenv) [!W32CE]: Add missing return. + 2010-04-14 Werner Koch * Makefile.am (noinst_LIBRARIES) [W32CE]: Exclude libsimple-pwquery. Modified: trunk/common/gettime.c =================================================================== --- trunk/common/gettime.c 2010-04-20 01:11:35 UTC (rev 5309) +++ trunk/common/gettime.c 2010-04-20 11:52:33 UTC (rev 5310) @@ -27,6 +27,7 @@ #include "util.h" #include "i18n.h" +#include "gettime.h" static unsigned long timewarp; static enum { NORMAL = 0, FROZEN, FUTURE, PAST } timemode; @@ -507,6 +508,23 @@ } +/* Copy one ISO date to another, this is inline so that we can do a + minimal sanity check. A null date (empty string) is allowed. */ +void +gnupg_copy_time (gnupg_isotime_t d, const gnupg_isotime_t s) +{ + if (*s) + { + if ((strlen (s) != 15 || s[8] != 'T')) + BUG(); + memcpy (d, s, 15); + d[15] = 0; + } + else + *d = 0; +} + + /* Add SECONDS to ATIME. SECONDS may not be negative and is limited to about the equivalent of 62 years which should be more then enough for our purposes. */ Added: trunk/common/gettime.h =================================================================== --- trunk/common/gettime.h (rev 0) +++ trunk/common/gettime.h 2010-04-20 11:52:33 UTC (rev 5310) @@ -0,0 +1,51 @@ +/* gettime.h - Wrapper for time functions + * Copyright (C) 2010 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 3 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, see . + */ + +#ifndef GNUPG_COMMON_GETTIME_H +#define GNUPG_COMMON_GETTIME_H + +#include /* We need time_t. */ +#include /* We need gpg_error_t. */ + + +/* A type to hold the ISO time. Note that this this is the same as + the the KSBA type ksba_isotime_t. */ +typedef char gnupg_isotime_t[16]; + +time_t gnupg_get_time (void); +void gnupg_get_isotime (gnupg_isotime_t timebuf); +void gnupg_set_time (time_t newtime, int freeze); +int gnupg_faked_time_p (void); +u32 make_timestamp (void); +u32 scan_isodatestr (const char *string); +time_t isotime2epoch (const char *string); +void epoch2isotime (gnupg_isotime_t timebuf, time_t atime); +u32 add_days_to_timestamp (u32 stamp, u16 days); +const char *strtimevalue (u32 stamp); +const char *strtimestamp (u32 stamp); /* GMT */ +const char *isotimestamp (u32 stamp); /* GMT */ +const char *asctimestamp (u32 stamp); /* localized */ +gpg_error_t add_seconds_to_isotime (gnupg_isotime_t atime, int nseconds); +gpg_error_t add_days_to_isotime (gnupg_isotime_t atime, int ndays); +gpg_error_t check_isotime (const gnupg_isotime_t atime); +void dump_isotime (const gnupg_isotime_t atime); +void gnupg_copy_time (gnupg_isotime_t d, const gnupg_isotime_t s); + + +#endif /*GNUPG_COMMON_GETTIME_H*/ Modified: trunk/common/util.h =================================================================== --- trunk/common/util.h 2010-04-20 01:11:35 UTC (rev 5309) +++ trunk/common/util.h 2010-04-20 11:52:33 UTC (rev 5310) @@ -21,7 +21,6 @@ #define GNUPG_COMMON_UTIL_H #include /* We need this for the memory function protos. */ -#include /* We need time_t. */ #include /* We need errno. */ #include /* We need gpg_error_t. */ @@ -43,6 +42,7 @@ #include "../common/dynload.h" #include "init.h" +#include "gettime.h" /* Redefine asprintf by our estream version which uses our own memory allocator.. */ @@ -98,47 +98,7 @@ return gpg_error_from_syserror (); } -/* A type to hold the ISO time. Note that this this is the same as - the the KSBA type ksba_isotime_t. */ -typedef char gnupg_isotime_t[16]; - -/*-- gettime.c --*/ -time_t gnupg_get_time (void); -void gnupg_get_isotime (gnupg_isotime_t timebuf); -void gnupg_set_time (time_t newtime, int freeze); -int gnupg_faked_time_p (void); -u32 make_timestamp (void); -u32 scan_isodatestr (const char *string); -time_t isotime2epoch (const char *string); -void epoch2isotime (gnupg_isotime_t timebuf, time_t atime); -u32 add_days_to_timestamp (u32 stamp, u16 days); -const char *strtimevalue (u32 stamp); -const char *strtimestamp (u32 stamp); /* GMT */ -const char *isotimestamp (u32 stamp); /* GMT */ -const char *asctimestamp (u32 stamp); /* localized */ -gpg_error_t add_seconds_to_isotime (gnupg_isotime_t atime, int nseconds); -gpg_error_t add_days_to_isotime (gnupg_isotime_t atime, int ndays); -gpg_error_t check_isotime (const gnupg_isotime_t atime); -void dump_isotime (const gnupg_isotime_t atime); - -/* Copy one ISO date to another, this is inline so that we can do a - minimal sanity check. A null date (empty string) is allowed. */ -static inline void -gnupg_copy_time (gnupg_isotime_t d, const gnupg_isotime_t s) -{ - if (*s) - { - if ((strlen (s) != 15 || s[8] != 'T')) - BUG(); - memcpy (d, s, 15); - d[15] = 0; - } - else - *d = 0; -} - - /*-- signal.c --*/ void gnupg_init_signals (int mode, void (*fast_cleanup)(void)); void gnupg_block_all_signals (void); From cvs at cvs.gnupg.org Tue Apr 20 15:42:07 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue, 20 Apr 2010 15:42:07 +0200 Subject: [svn] GpgEX - r79 - in trunk: . po Message-ID: Author: marcus Date: 2010-04-20 15:42:07 +0200 (Tue, 20 Apr 2010) New Revision: 79 Modified: trunk/ChangeLog trunk/po/de.po Log: 2010-04-20 Emanuel Sch?\195?\188tze * po/de.po: Use "pruefen" instead "ueberpruefen" for signatures. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-02-10 12:00:33 UTC (rev 78) +++ trunk/ChangeLog 2010-04-20 13:42:07 UTC (rev 79) @@ -1,3 +1,7 @@ +2010-04-20 Emanuel Sch?tze + + * po/de.po: Use "pruefen" instead "ueberpruefen" for signatures. + 2010-01-08 Marcus Brinkmann * Release 0.9.5. Modified: trunk/po/de.po [not shown] From cvs at cvs.gnupg.org Tue Apr 20 15:47:12 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 20 Apr 2010 15:47:12 +0200 Subject: [svn] GnuPG - r5311 - trunk/common Message-ID: Author: wk Date: 2010-04-20 15:47:12 +0200 (Tue, 20 Apr 2010) New Revision: 5311 Modified: trunk/common/ChangeLog trunk/common/Makefile.am trunk/common/sexputil.c Log: Add missing file. Typo fix. Modified: trunk/common/ChangeLog =================================================================== --- trunk/common/ChangeLog 2010-04-20 11:52:33 UTC (rev 5310) +++ trunk/common/ChangeLog 2010-04-20 13:47:12 UTC (rev 5311) @@ -1,3 +1,7 @@ +2010-04-20 Werner Koch + + * Makefile.am (common_sources): Add gettime.h. + 2010-04-20 Marcus Brinkmann * logging.c (do_log_ignore_arg): New helper function. Modified: trunk/common/Makefile.am =================================================================== --- trunk/common/Makefile.am 2010-04-20 11:52:33 UTC (rev 5310) +++ trunk/common/Makefile.am 2010-04-20 13:47:12 UTC (rev 5311) @@ -68,7 +68,7 @@ sexputil.c \ sysutils.c sysutils.h \ homedir.c \ - gettime.c \ + gettime.c gettime.h \ yesno.c \ b64enc.c b64dec.c \ convert.c \ Modified: trunk/common/sexputil.c =================================================================== --- trunk/common/sexputil.c 2010-04-20 11:52:33 UTC (rev 5310) +++ trunk/common/sexputil.c 2010-04-20 13:47:12 UTC (rev 5311) @@ -292,7 +292,7 @@ } -/* Return the so parameters of a public RSA key expressed as an +/* Return the parameters of a public RSA key expressed as an canonical encoded S-expression. */ gpg_error_t get_rsa_pk_from_canon_sexp (const unsigned char *keydata, size_t keydatalen, From cvs at cvs.gnupg.org Tue Apr 20 16:37:05 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue, 20 Apr 2010 16:37:05 +0200 Subject: [svn] pinentry - r228 - in trunk: . secmem Message-ID: Author: marcus Date: 2010-04-20 16:37:05 +0200 (Tue, 20 Apr 2010) New Revision: 228 Modified: trunk/ChangeLog trunk/secmem/util.c Log: 2010-04-20 Marcus Brinkmann * pinentry/pinentry.c: Move include config.h to top! Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-04-19 13:01:15 UTC (rev 227) +++ trunk/ChangeLog 2010-04-20 14:37:05 UTC (rev 228) @@ -1,3 +1,7 @@ +2010-04-20 Marcus Brinkmann + + * pinentry/pinentry.c: Move include config.h to top! + 2010-04-19 Werner Koch * gtk+-2/gtksecentry.c (gtk_secure_entry_delete_cb) Modified: trunk/secmem/util.c =================================================================== --- trunk/secmem/util.c 2010-04-19 13:01:15 UTC (rev 227) +++ trunk/secmem/util.c 2010-04-20 14:37:05 UTC (rev 228) @@ -16,6 +16,10 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#ifdef HAVE_CONFIG_H +#include +#endif + #define _GNU_SOURCE 1 #include @@ -28,10 +32,6 @@ #include #include -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - #include "util.h" #ifndef HAVE_DOSISH_SYSTEM From cvs at cvs.gnupg.org Tue Apr 20 18:23:46 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue, 20 Apr 2010 18:23:46 +0200 Subject: [svn] GpgEX - r80 - in trunk: . src Message-ID: Author: marcus Date: 2010-04-20 18:23:46 +0200 (Tue, 20 Apr 2010) New Revision: 80 Modified: trunk/ChangeLog trunk/configure.ac trunk/src/ChangeLog trunk/src/client.cc trunk/src/main.cc Log: 2010-04-20 Marcus Brinkmann * configure.ac: Bump version to 0.9.6. (NEED_LIBASSUAN_API): Bump to 2. (NEED_LIBASSAUN_VERSION): Bump to 2.0.0. src/ 2010-04-20 Marcus Brinkmann * client.cc (getinfo_pid_cb): Return gpg_error_t. (uiserver_connect): Port to new assuan interface. * main.cc (DllMain): Likewise. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-04-20 13:42:07 UTC (rev 79) +++ trunk/ChangeLog 2010-04-20 16:23:46 UTC (rev 80) @@ -1,3 +1,9 @@ +2010-04-20 Marcus Brinkmann + + * configure.ac: Bump version to 0.9.6. + (NEED_LIBASSUAN_API): Bump to 2. + (NEED_LIBASSAUN_VERSION): Bump to 2.0.0. + 2010-04-20 Emanuel Sch?tze * po/de.po: Use "pruefen" instead "ueberpruefen" for signatures. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-04-20 13:42:07 UTC (rev 79) +++ trunk/src/ChangeLog 2010-04-20 16:23:46 UTC (rev 80) @@ -1,3 +1,9 @@ +2010-04-20 Marcus Brinkmann + + * client.cc (getinfo_pid_cb): Return gpg_error_t. + (uiserver_connect): Port to new assuan interface. + * main.cc (DllMain): Likewise. + 2010-02-10 Marcus Brinkmann * gpgex.cc (gpgex_t::Initialize): Default to sign/encrypt if a Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2010-04-20 13:42:07 UTC (rev 79) +++ trunk/configure.ac 2010-04-20 16:23:46 UTC (rev 80) @@ -16,7 +16,7 @@ # 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], [0.9.5]) +m4_define([my_version], [0.9.6]) m4_define([my_issvn], [no]) m4_define([svn_revision], m4_esyscmd([echo -n $( (svn info 2>/dev/null \ @@ -31,8 +31,8 @@ NEED_GPG_ERROR_VERSION=1.4 -NEED_LIBASSUAN_API=1 -NEED_LIBASSUAN_VERSION=0.9.3 +NEED_LIBASSUAN_API=2 +NEED_LIBASSUAN_VERSION=2.0.0 AC_CONFIG_SRCDIR(src/gpgex.def) AM_CONFIG_HEADER(config.h) Modified: trunk/src/client.cc =================================================================== --- trunk/src/client.cc 2010-04-20 13:42:07 UTC (rev 79) +++ trunk/src/client.cc 2010-04-20 16:23:46 UTC (rev 80) @@ -191,7 +191,7 @@ } -static int +static gpg_error_t getinfo_pid_cb (void *opaque, const void *buffer, size_t length) { pid_t *pid = (pid_t *) opaque; @@ -238,10 +238,10 @@ } -static int +static gpg_error_t uiserver_connect (assuan_context_t *ctx, HWND hwnd) { - int rc; + gpg_error_t rc; const char *socket_name = NULL; pid_t pid; @@ -255,9 +255,16 @@ } (void) TRACE_LOG1 ("socket name: %s", socket_name); - rc = assuan_socket_connect (ctx, socket_name, -1); + rc = assuan_new (ctx); if (rc) { + (void) TRACE_LOG ("could not allocate context"); + return TRACE_GPGERR (rc); + } + + rc = assuan_socket_connect (*ctx, socket_name, -1, 0); + if (rc) + { int count; (void) TRACE_LOG ("UI server not running, starting it"); @@ -271,7 +278,7 @@ for (count = 0; count < 10; count++) { Sleep (1000); - rc = assuan_socket_connect (ctx, socket_name, -1); + rc = assuan_socket_connect (*ctx, socket_name, -1, 0); if (!rc) break; } @@ -285,7 +292,7 @@ rc = send_options (*ctx, hwnd, &pid); if (rc) { - assuan_disconnect (*ctx); + assuan_release (*ctx); *ctx = NULL; } } @@ -343,7 +350,7 @@ leave: TRACE_GPGERR (rc); if (ctx) - assuan_disconnect (ctx); + assuan_release (ctx); if (rc) { char buf[256]; Modified: trunk/src/main.cc =================================================================== --- trunk/src/main.cc 2010-04-20 13:42:07 UTC (rev 79) +++ trunk/src/main.cc 2010-04-20 16:23:46 UTC (rev 80) @@ -219,7 +219,7 @@ assuan_set_assuan_log_stream (debug_file); assuan_set_assuan_log_prefix ("gpgex:assuan"); } - assuan_set_assuan_err_source (GPG_ERR_SOURCE_DEFAULT); + assuan_set_gpg_err_source (GPG_ERR_SOURCE_DEFAULT); (void) TRACE0 (DEBUG_INIT, "DllMain", hinst, "reason=DLL_PROCESS_ATTACH"); From cvs at cvs.gnupg.org Tue Apr 20 19:57:51 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 20 Apr 2010 19:57:51 +0200 Subject: [svn] GnuPG - r5312 - trunk/g10 Message-ID: Author: wk Date: 2010-04-20 19:57:50 +0200 (Tue, 20 Apr 2010) New Revision: 5312 Modified: trunk/g10/ChangeLog trunk/g10/call-agent.c trunk/g10/call-agent.h trunk/g10/card-util.c trunk/g10/export.c trunk/g10/getkey.c trunk/g10/gpg.h trunk/g10/gpgv.c trunk/g10/keydb.h trunk/g10/keyedit.c trunk/g10/keygen.c trunk/g10/keyid.c trunk/g10/keylist.c trunk/g10/main.h trunk/g10/packet.h trunk/g10/pkglue.c trunk/g10/pkglue.h trunk/g10/pubkey-enc.c trunk/g10/revoke.c trunk/g10/seckey-cert.c trunk/g10/seskey.c trunk/g10/sig-check.c trunk/g10/sign.c Log: Generating an OpenPGP key cia gpg-agent basically works. [The diff below has been truncated] Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2010-04-20 13:47:12 UTC (rev 5311) +++ trunk/g10/ChangeLog 2010-04-20 17:57:50 UTC (rev 5312) @@ -1,3 +1,38 @@ +2010-04-20 Werner Koch + + * keylist.c (list_keyblock_colon): Print the keygrip. + + * sign.c (do_sign): Call the agent to create the signature. + (mpi_from_sexp): New. + * keyid.c (keygrip_from_pk, hexkeygrip_from_pk): New. + * call-agent.c (agent_pksign): New. + * pkglue.c (pk_sign): Remove. + + * keygen.c (generate_keypair): Do not ask for a passphrase. + +2010-04-15 Werner Koch + + * keygen.c (gen_dsa, gen_elg, gen_rsa): Remove args SEC_ROOT, DEK, + S2K and RET_SK. Change to use the gpg-agent based key generation. + Factor common code out to ... + (common_gen): New. + (do_create): Remove args SEC_ROOT, DEK, S2K and RET_SK. + (do_generate_keypair, write_selfsigs, write_direct_sig) + (write_keybinding, make_backsig): Adjust for above changes. + (generate_subkeypair): Remove arg SEC_KEYBLOCK. + (genhelp_protect, genhelp_factors): Remove. + (get_parameter_dek, get_parameter_s2k): Remove. + + * call-agent.c (start_agent): Add dummy arg CTRL. + (agent_havekey, keyinfo_status_cb, agent_get_keyinfo) + (agent_genkey): New. + + * seckey-cert.c (check_secret_key): Remove + (is_secret_key_protected): Take a public key as arg. + (protect_secret_key): Remove. + + * seskey.c (encode_md_value): Remove SK arg. + 2010-04-14 Werner Koch * cpr.c (myread) [W32CE]: Do not use raise. Modified: trunk/g10/call-agent.c =================================================================== --- trunk/g10/call-agent.c 2010-04-20 13:47:12 UTC (rev 5311) +++ trunk/g10/call-agent.c 2010-04-20 17:57:50 UTC (rev 5312) @@ -1,6 +1,6 @@ /* call-agent.c - Divert GPG operations to the agent. - * Copyright (C) 2001, 2002, 2003, 2006, 2007, - * 2008, 2009 Free Software Foundation, Inc. + * Copyright (C) 2001, 2002, 2003, 2006, 2007, 2008, 2009, + * 2010 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -69,14 +69,15 @@ size_t keydatalen; }; -struct genkey_parm_s +struct genkey_parm_s { + ctrl_t ctrl; assuan_context_t ctx; - const char *sexp; - size_t sexplen; + const char *keyparms; }; + static gpg_error_t learn_status_cb (void *opaque, const char *line); @@ -107,10 +108,12 @@ /* Try to connect to the agent via socket or fork it off and work by pipes. Handle the server's initial greeting */ static int -start_agent (int for_card) +start_agent (ctrl_t ctrl, int for_card) { int rc; + (void)ctrl; /* Not yet used. */ + /* Fixme: We need a context for each thread or serialize the access to the agent. */ if (agent_ctx) @@ -486,7 +489,7 @@ { int rc; - rc = start_agent (1); + rc = start_agent (NULL, 1); if (rc) return rc; @@ -531,7 +534,7 @@ return gpg_error (GPG_ERR_TOO_LARGE); stpcpy (stpcpy (line, "SCD GETATTR "), name); - rc = start_agent (1); + rc = start_agent (NULL, 1); if (rc) return rc; @@ -581,7 +584,7 @@ } *p = 0; - rc = start_agent (1); + rc = start_agent (NULL, 1); if (!rc) { rc = assuan_transact (agent_ctx, line, NULL, NULL, @@ -623,7 +626,7 @@ char line[ASSUAN_LINELENGTH]; struct writecert_parm_s parms; - rc = start_agent (1); + rc = start_agent (NULL, 1); if (rc) return rc; @@ -673,7 +676,7 @@ (void)serialno; - rc = start_agent (1); + rc = start_agent (NULL, 1); if (rc) return rc; @@ -762,7 +765,7 @@ (void)serialno; - rc = start_agent (1); + rc = start_agent (NULL, 1); if (rc) return rc; @@ -909,7 +912,7 @@ *r_buf = NULL; *r_buflen = 0; - rc = start_agent (1); + rc = start_agent (NULL, 1); if (gpg_err_code (rc) == GPG_ERR_CARD_NOT_PRESENT || gpg_err_code (rc) == GPG_ERR_NOT_SUPPORTED) rc = 0; /* We check later. */ @@ -972,7 +975,7 @@ size_t len; *r_buf = NULL; - rc = start_agent (1); + rc = start_agent (NULL, 1); if (gpg_err_code (rc) == GPG_ERR_CARD_NOT_PRESENT || gpg_err_code (rc) == GPG_ERR_NOT_SUPPORTED) rc = 0; /* We check later. */ @@ -1029,7 +1032,7 @@ size_t len; *r_buf = NULL; - rc = start_agent (1); + rc = start_agent (NULL, 1); if (rc) return rc; @@ -1077,7 +1080,7 @@ reset = "--reset"; chvno %= 100; - rc = start_agent (1); + rc = start_agent (NULL, 1); if (rc) return rc; @@ -1099,7 +1102,7 @@ int rc; char line[ASSUAN_LINELENGTH]; - rc = start_agent (1); + rc = start_agent (NULL, 1); if (rc) return rc; @@ -1146,7 +1149,7 @@ *r_passphrase = NULL; - rc = start_agent (0); + rc = start_agent (NULL, 0); if (rc) return rc; @@ -1217,7 +1220,7 @@ if (!cache_id || !*cache_id) return 0; - rc = start_agent (0); + rc = start_agent (NULL, 0); if (rc) return rc; @@ -1237,7 +1240,7 @@ char *tmp; char line[ASSUAN_LINELENGTH]; - rc = start_agent (0); + rc = start_agent (NULL, 0); if (rc) return rc; @@ -1264,7 +1267,7 @@ *r_count = 0; - err = start_agent (0); + err = start_agent (NULL, 0); if (err) return err; @@ -1289,3 +1292,291 @@ return err; } + + +/* Ask the agent whether a secret key with the given keygrip is + known. */ +gpg_error_t +agent_havekey (ctrl_t ctrl, const char *hexkeygrip) +{ + gpg_error_t err; + char line[ASSUAN_LINELENGTH]; + + err = start_agent (ctrl, 0); + if (err) + return err; + + if (!hexkeygrip || strlen (hexkeygrip) != 40) + return gpg_error (GPG_ERR_INV_VALUE); + + snprintf (line, DIM(line)-1, "HAVEKEY %s", hexkeygrip); + line[DIM(line)-1] = 0; + + err = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL); + return err; +} + + + +static gpg_error_t +keyinfo_status_cb (void *opaque, const char *line) +{ + char **serialno = opaque; + const char *s, *s2; + + if (!strncmp (line, "KEYINFO ", 8) && !*serialno) + { + s = strchr (line+8, ' '); + if (s && s[1] == 'T' && s[2] == ' ' && s[3]) + { + s += 3; + s2 = strchr (s, ' '); + if ( s2 > s ) + { + *serialno = xtrymalloc ((s2 - s)+1); + if (*serialno) + { + memcpy (*serialno, s, s2 - s); + (*serialno)[s2 - s] = 0; + } + } + } + } + return 0; +} + + +/* Return the serial number for a secret key. If the returned serial + number is NULL, the key is not stored on a smartcard. Caller needs + to free R_SERIALNO. */ +gpg_error_t +agent_get_keyinfo (ctrl_t ctrl, const char *hexkeygrip, char **r_serialno) +{ + gpg_error_t err; + char line[ASSUAN_LINELENGTH]; + char *serialno = NULL; + + *r_serialno = NULL; + + err = start_agent (ctrl, 0); + if (err) + return err; + + if (!hexkeygrip || strlen (hexkeygrip) != 40) + return gpg_error (GPG_ERR_INV_VALUE); + + snprintf (line, DIM(line)-1, "KEYINFO %s", hexkeygrip); + line[DIM(line)-1] = 0; + + err = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, + keyinfo_status_cb, &serialno); + if (!err && serialno) + { + /* Sanity check for bad characters. */ + if (strpbrk (serialno, ":\n\r")) + err = GPG_ERR_INV_VALUE; + } + if (err) + xfree (serialno); + else + *r_serialno = serialno; + return err; +} + + + +/* Handle a KEYPARMS inquiry. Note, we only send the data, + assuan_transact takes care of flushing and writing the end */ +static gpg_error_t +inq_genkey_parms (void *opaque, const char *line) +{ + struct genkey_parm_s *parm = opaque; + gpg_error_t err; + + if (!strncmp (line, "KEYPARAM", 8) && (line[8]==' '||!line[8])) + { + err = assuan_send_data (parm->ctx, + parm->keyparms, strlen (parm->keyparms)); + } + else + err = default_inq_cb (parm->ctrl, line); + + return err; +} + + +/* Call the agent to generate a new key. KEYPARMS is the usual + S-expression giving the parameters of the key. gpg-agent passes it + gcry_pk_genkey. */ +gpg_error_t +agent_genkey (ctrl_t ctrl, const char *keyparms, gcry_sexp_t *r_pubkey) +{ + gpg_error_t err; + struct genkey_parm_s gk_parm; + membuf_t data; + size_t len; + unsigned char *buf; + + *r_pubkey = NULL; + err = start_agent (ctrl, 0); + if (err) + return err; + + err = assuan_transact (agent_ctx, "RESET", + NULL, NULL, NULL, NULL, NULL, NULL); + if (err) + return err; + + init_membuf (&data, 1024); + gk_parm.ctrl = ctrl; + gk_parm.ctx = agent_ctx; + gk_parm.keyparms = keyparms; + err = assuan_transact (agent_ctx, "GENKEY", + membuf_data_cb, &data, + inq_genkey_parms, &gk_parm, NULL, NULL); + if (err) + { + xfree (get_membuf (&data, &len)); + return err; + } + + buf = get_membuf (&data, &len); + if (!buf) + err = gpg_error_from_syserror (); + else + { + err = gcry_sexp_sscan (r_pubkey, NULL, buf, len); + xfree (buf); + } + return err; +} + + + + +/* FIXME: Call the agent to read the public key part for a given keygrip. If + FROMCARD is true, the key is directly read from the current + smartcard. In this case HEXKEYGRIP should be the keyID + (e.g. OPENPGP.3). */ +/* int */ +/* agent_readkey (ctrl_t ctrl, int fromcard, const char *hexkeygrip, */ +/* ksba_sexp_t *r_pubkey) */ +/* { */ +/* int rc; */ +/* membuf_t data; */ +/* size_t len; */ +/* unsigned char *buf; */ +/* char line[ASSUAN_LINELENGTH]; */ + +/* *r_pubkey = NULL; */ +/* rc = start_agent (ctrl); */ +/* if (rc) */ +/* return rc; */ + +/* rc = assuan_transact (agent_ctx, "RESET",NULL, NULL, NULL, NULL, NULL, NULL); */ +/* if (rc) */ +/* return rc; */ + +/* snprintf (line, DIM(line)-1, "%sREADKEY %s", */ +/* fromcard? "SCD ":"", hexkeygrip); */ +/* line[DIM(line)-1] = 0; */ + +/* init_membuf (&data, 1024); */ +/* rc = assuan_transact (agent_ctx, line, */ +/* membuf_data_cb, &data, */ +/* default_inq_cb, ctrl, NULL, NULL); */ +/* if (rc) */ +/* { */ +/* xfree (get_membuf (&data, &len)); */ +/* return rc; */ +/* } */ +/* buf = get_membuf (&data, &len); */ +/* if (!buf) */ +/* return gpg_error (GPG_ERR_ENOMEM); */ +/* if (!gcry_sexp_canon_len (buf, len, NULL, NULL)) */ +/* { */ +/* xfree (buf); */ +/* return gpg_error (GPG_ERR_INV_SEXP); */ +/* } */ +/* *r_pubkey = buf; */ +/* return 0; */ +/* } */ + + + +/* Call the agent to do a sign operation using the key identified by + the hex string KEYGRIP. DESC is a description of the key to be + displayed if the agent needs to ask for the PIN. DIGEST and + DIGESTLEN is the hash value to sign and DIGESTALGO the algorithm id + used to compute the digest. */ +gpg_error_t +agent_pksign (ctrl_t ctrl, const char *keygrip, const char *desc, + unsigned char *digest, size_t digestlen, int digestalgo, + gcry_sexp_t *r_sigval) +{ + gpg_error_t err; + int i; + char *p, line[ASSUAN_LINELENGTH]; + membuf_t data; + + *r_sigval = NULL; + err = start_agent (ctrl, 0); + if (err) + return err; + + if (digestlen*2 + 50 > DIM(line)) + return gpg_error (GPG_ERR_GENERAL); + + err = assuan_transact (agent_ctx, "RESET", + NULL, NULL, NULL, NULL, NULL, NULL); + if (err) + return err; + + snprintf (line, DIM(line)-1, "SIGKEY %s", keygrip); + line[DIM(line)-1] = 0; + err = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL); + if (err) + return err; + + if (desc) + { + snprintf (line, DIM(line)-1, "SETKEYDESC %s", desc); + line[DIM(line)-1] = 0; + err = assuan_transact (agent_ctx, line, + NULL, NULL, NULL, NULL, NULL, NULL); + if (err) + return err; + } + + snprintf (line, sizeof line, "SETHASH %d ", digestalgo); + p = line + strlen (line); + for (i=0; i < digestlen ; i++, p += 2 ) + sprintf (p, "%02X", digest[i]); + err = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL); + if (err) + return err; + + init_membuf (&data, 1024); + err = assuan_transact (agent_ctx, "PKSIGN", + membuf_data_cb, &data, default_inq_cb, ctrl, + NULL, NULL); + if (err) + xfree (get_membuf (&data, NULL)); + else + { + unsigned char *buf; + size_t len; + + buf = get_membuf (&data, &len); + if (!buf) + err = gpg_error_from_syserror (); + else + { + err = gcry_sexp_sscan (r_sigval, NULL, buf, len); + xfree (buf); + } + } + return err; +} + + Modified: trunk/g10/call-agent.h =================================================================== --- trunk/g10/call-agent.h 2010-04-20 13:47:12 UTC (rev 5311) +++ trunk/g10/call-agent.h 2010-04-20 17:57:50 UTC (rev 5312) @@ -140,6 +140,24 @@ /* Return the S2K iteration count as computed by gpg-agent. */ gpg_error_t agent_get_s2k_count (unsigned long *r_count); +/* Check whether a secret key with HEXKEYGRIP is available. */ +gpg_error_t agent_havekey (ctrl_t ctrl, const char *hexkeygrip); +/* Return infos about the secret key with HEXKEYGRIP. */ +gpg_error_t agent_get_keyinfo (ctrl_t ctrl, const char *hexkeygrip, + char **r_serialno); + +/* Generate a new key. */ +gpg_error_t agent_genkey (ctrl_t ctrl, const char *keyparms, + gcry_sexp_t *r_pubkey); + +/* Create a sigtnature. */ +gpg_error_t agent_pksign (ctrl_t ctrl, const char *keygrip, const char *desc, + unsigned char *digest, size_t digestlen, + int digestalgo, + gcry_sexp_t *r_sigval); + + + #endif /*GNUPG_G10_CALL_AGENT_H*/ Modified: trunk/g10/card-util.c =================================================================== --- trunk/g10/card-util.c 2010-04-20 13:47:12 UTC (rev 5311) +++ trunk/g10/card-util.c 2010-04-20 17:57:50 UTC (rev 5312) @@ -1495,8 +1495,8 @@ the serialnumber and thus it won't harm. */ } - okay = generate_card_subkeypair (pub_keyblock, sec_keyblock, - keyno, info.serialno); + /* xxx = generate_card_subkeypair (pub_keyblock, sec_keyblock, */ + /* keyno, info.serialno); */ leave: agent_release_card_info (&info); @@ -1612,17 +1612,18 @@ } /* We better copy the key before we unprotect it. */ copied_sk = sk = copy_secret_key (NULL, sk); - rc = check_secret_key (sk, 0); + rc = 0/*check_secret_key (sk, 0)*/; if (rc) goto leave; } - rc = save_unprotected_key_to_card (sk, keyno); - if (rc) - { - log_error (_("error writing key to card: %s\n"), gpg_strerror (rc)); - goto leave; - } +#warning code save_unprotected_key_to_card + /* rc = save_unprotected_key_to_card (sk, keyno); */ + /* if (rc) */ + /* { */ + /* log_error (_("error writing key to card: %s\n"), gpg_strerror (rc)); */ + /* goto leave; */ + /* } */ /* Get back to the maybe protected original secret key. */ if (copied_sk) Modified: trunk/g10/export.c =================================================================== --- trunk/g10/export.c 2010-04-20 13:47:12 UTC (rev 5311) +++ trunk/g10/export.c 2010-04-20 17:57:50 UTC (rev 5312) @@ -550,7 +550,7 @@ ; /* Card key stub. */ else { - rc = check_secret_key( sk, 0 ); + /* rc = check_secret_key( sk, 0 ); */ } break; } Modified: trunk/g10/getkey.c =================================================================== --- trunk/g10/getkey.c 2010-04-20 13:47:12 UTC (rev 5311) +++ trunk/g10/getkey.c 2010-04-20 17:57:50 UTC (rev 5312) @@ -526,7 +526,7 @@ { /* Check the secret key (this may prompt for a passprase to * unlock the secret key. */ - rc = check_secret_key (sk, 0); + /* rc = check_secret_key (sk, 0); */ } return rc; @@ -1111,8 +1111,8 @@ free_strlist (namelist); - if (!rc && unprotect) - rc = check_secret_key (sk, 0); + /* if (!rc && unprotect) */ + /* rc = check_secret_key (sk, 0); */ return rc; } Modified: trunk/g10/gpg.h =================================================================== --- trunk/g10/gpg.h 2010-04-20 13:47:12 UTC (rev 5311) +++ trunk/g10/gpg.h 2010-04-20 17:57:50 UTC (rev 5312) @@ -108,7 +108,7 @@ #define G10ERR_RENAME_FILE GPG_ERR_RENAME_FILE #define G10ERR_RESOURCE_LIMIT GPG_ERR_RESOURCE_LIMIT #define G10ERR_SIG_CLASS GPG_ERR_SIG_CLASS -#define G10ERR_TIME_CONFLICT GPG_ERR_TIME_CONFLICT +#define G10ERR_TIME_CONFLICT GPG_ERR_TIME_CONFLICT #define G10ERR_TRUSTDB GPG_ERR_TRUSTDB #define G10ERR_UNEXPECTED GPG_ERR_UNEXPECTED #define G10ERR_UNKNOWN_PACKET GPG_ERR_UNKNOWN_PACKET Modified: trunk/g10/gpgv.c =================================================================== --- trunk/g10/gpgv.c 2010-04-20 13:47:12 UTC (rev 5311) +++ trunk/g10/gpgv.c 2010-04-20 17:57:50 UTC (rev 5312) @@ -399,9 +399,9 @@ * We don't use secret keys, but getkey.c links to this */ int -check_secret_key (PKT_secret_key *sk, int n) +check_secret_key (PKT_public_key *pk, int n) { - (void)sk; + (void)pk; (void)n; return G10ERR_GENERAL; } Modified: trunk/g10/keydb.h =================================================================== --- trunk/g10/keydb.h 2010-04-20 13:47:12 UTC (rev 5311) +++ trunk/g10/keydb.h 2010-04-20 17:57:50 UTC (rev 5312) @@ -286,7 +286,10 @@ byte *fingerprint_from_pk( PKT_public_key *pk, byte *buf, size_t *ret_len ); char *serialno_and_fpr_from_sk (const unsigned char *sn, size_t snlen, PKT_secret_key *sk); +gpg_error_t keygrip_from_pk (PKT_public_key *pk, unsigned char *array); +gpg_error_t hexkeygrip_from_pk (PKT_public_key *pk, char **r_grip); + /*-- kbnode.c --*/ KBNODE new_kbnode( PACKET *pkt ); KBNODE clone_kbnode( KBNODE node ); Modified: trunk/g10/keyedit.c =================================================================== --- trunk/g10/keyedit.c 2010-04-20 13:47:12 UTC (rev 5311) +++ trunk/g10/keyedit.c 2010-04-20 17:57:50 UTC (rev 5312) @@ -1164,9 +1164,9 @@ keyid_from_sk (sk, keyid); passphrase_clear_cache (keyid, NULL, 0); - rc = check_secret_key( sk, 0 ); - if( !rc ) - passphrase = get_last_passphrase(); + /* rc = check_secret_key( sk, 0 ); */ + /* if( !rc ) */ + /* passphrase = get_last_passphrase(); */ } break; } @@ -1179,9 +1179,9 @@ && (subsk->protect.s2k.mode == 1001 || subsk->protect.s2k.mode == 1002))) { set_next_passphrase( passphrase ); - rc = check_secret_key( subsk, 0 ); - if( !rc && !passphrase ) - passphrase = get_last_passphrase(); + /* rc = check_secret_key( subsk, 0 ); */ + /* if( !rc && !passphrase ) */ + /* passphrase = get_last_passphrase(); */ } } } @@ -1227,7 +1227,9 @@ if( !no_primary_secrets ) { sk->protect.algo = dek->algo; sk->protect.s2k = *s2k; - rc = protect_secret_key( sk, dek ); +#warning fixme + rc = 0; + /* rc = protect_secret_key( sk, dek ); */ } for(node=keyblock; !rc && node; node = node->next ) { if( node->pkt->pkttype == PKT_SECRET_SUBKEY ) { @@ -1237,7 +1239,9 @@ || subsk->protect.s2k.mode == 1002))) { subsk->protect.algo = dek->algo; subsk->protect.s2k = *s2k; - rc = protect_secret_key( subsk, dek ); +#warning fixme + rc = 0; + /* rc = protect_secret_key( subsk, dek ); */ } } } @@ -1892,12 +1896,13 @@ break; case cmdADDKEY: - if( generate_subkeypair( keyblock, sec_keyblock ) ) { + if (!generate_subkeypair (keyblock)) + { redisplay = 1; sec_modified = modified = 1; merge_keys_and_selfsig( sec_keyblock ); merge_keys_and_selfsig( keyblock ); - } + } break; #ifdef ENABLE_CARD_SUPPORT @@ -2018,8 +2023,8 @@ if (sk->protect.s2k.mode == 1002) tty_printf (_("Secret parts of key" " are stored on-card.\n")); - else - check_secret_key (sk, 0); + /* else */ + /* check_secret_key (sk, 0); */ } } else /* Store it. */ Modified: trunk/g10/keygen.c =================================================================== --- trunk/g10/keygen.c 2010-04-20 13:47:12 UTC (rev 5311) +++ trunk/g10/keygen.c 2010-04-20 17:57:50 UTC (rev 5312) @@ -132,15 +132,12 @@ static void do_generate_keypair( struct para_data_s *para, struct output_control_s *outctrl, int card ); -static int write_keyblock( IOBUF out, KBNODE node ); -static int gen_card_key (int algo, int keyno, int is_primary, - KBNODE pub_root, KBNODE sec_root, - PKT_secret_key **ret_sk, - u32 *timestamp, - u32 expireval, struct para_data_s *para); +static int write_keyblock (iobuf_t out, kbnode_t node); +static int gen_card_key (int algo, int keyno, int is_primary, kbnode_t pub_root, + u32 *timestamp, u32 expireval, + struct para_data_s *para); static int gen_card_key_with_backup (int algo, int keyno, int is_primary, - KBNODE pub_root, KBNODE sec_root, - u32 timestamp, + kbnode_t pub_root, u32 timestamp, u32 expireval, struct para_data_s *para, const char *backup_dir); @@ -227,43 +224,46 @@ int -keygen_add_key_expire( PKT_signature *sig, void *opaque ) +keygen_add_key_expire (PKT_signature *sig, void *opaque) { - PKT_public_key *pk = opaque; - byte buf[8]; - u32 u; - - if( pk->expiredate ) { - if(pk->expiredate > pk->timestamp) - u= pk->expiredate - pk->timestamp; - else - u= 1; - - buf[0] = (u >> 24) & 0xff; - buf[1] = (u >> 16) & 0xff; - buf[2] = (u >> 8) & 0xff; - buf[3] = u & 0xff; - build_sig_subpkt( sig, SIGSUBPKT_KEY_EXPIRE, buf, 4 ); + PKT_public_key *pk = opaque; + byte buf[8]; + u32 u; + + if (pk->expiredate) + { + if (pk->expiredate > pk->timestamp) + u = pk->expiredate - pk->timestamp; + else + u = 1; + + buf[0] = (u >> 24) & 0xff; + buf[1] = (u >> 16) & 0xff; + buf[2] = (u >> 8) & 0xff; + buf[3] = u & 0xff; + build_sig_subpkt (sig, SIGSUBPKT_KEY_EXPIRE, buf, 4); } - else - { - /* Make sure we don't leave a key expiration subpacket lying - around */ - delete_sig_subpkt (sig->hashed, SIGSUBPKT_KEY_EXPIRE); - } + else + { + /* Make sure we don't leave a key expiration subpacket lying + around */ + delete_sig_subpkt (sig->hashed, SIGSUBPKT_KEY_EXPIRE); + } - return 0; + return 0; } + static int keygen_add_key_flags_and_expire (PKT_signature *sig, void *opaque) { - struct opaque_data_usage_and_pk *oduap = opaque; - - do_add_key_flags (sig, oduap->usage); - return keygen_add_key_expire (sig, oduap->pk); + struct opaque_data_usage_and_pk *oduap = opaque; + + do_add_key_flags (sig, oduap->usage); + return keygen_add_key_expire (sig, oduap->pk); } + static int set_one_pref (int val, int type, const char *item, byte *buf, int *nbuf) { @@ -697,19 +697,18 @@ /**************** * Add preference to the self signature packet. * This is only called for packets with version > 3. - */ int -keygen_add_std_prefs( PKT_signature *sig, void *opaque ) +keygen_add_std_prefs (PKT_signature *sig, void *opaque) { - PKT_public_key *pk = opaque; - - do_add_key_flags (sig, pk->pubkey_usage); - keygen_add_key_expire( sig, opaque ); - keygen_upd_std_prefs (sig, opaque); - keygen_add_keyserver_url(sig,NULL); - - return 0; + PKT_public_key *pk = opaque; + + do_add_key_flags (sig, pk->pubkey_usage); + keygen_add_key_expire (sig, opaque ); + keygen_upd_std_prefs (sig, opaque); + keygen_add_keyserver_url (sig,NULL); + + return 0; } int @@ -778,23 +777,23 @@ } int -keygen_add_revkey(PKT_signature *sig, void *opaque) +keygen_add_revkey (PKT_signature *sig, void *opaque) { - struct revocation_key *revkey=opaque; + struct revocation_key *revkey = opaque; byte buf[2+MAX_FINGERPRINT_LEN]; - buf[0]=revkey->class; - buf[1]=revkey->algid; - memcpy(&buf[2],revkey->fpr,MAX_FINGERPRINT_LEN); + buf[0] = revkey->class; + buf[1] = revkey->algid; + memcpy (&buf[2], revkey->fpr, MAX_FINGERPRINT_LEN); - build_sig_subpkt(sig,SIGSUBPKT_REV_KEY,buf,2+MAX_FINGERPRINT_LEN); + build_sig_subpkt (sig, SIGSUBPKT_REV_KEY, buf, 2+MAX_FINGERPRINT_LEN); - /* All sigs with revocation keys set are nonrevocable */ - sig->flags.revocable=0; + /* All sigs with revocation keys set are nonrevocable. */ + sig->flags.revocable = 0; buf[0] = 0; - build_sig_subpkt( sig, SIGSUBPKT_REVOCABLE, buf, 1 ); + build_sig_subpkt (sig, SIGSUBPKT_REVOCABLE, buf, 1); - parse_revkeys(sig); + parse_revkeys (sig); return 0; } @@ -803,115 +802,118 @@ /* Create a back-signature. If TIMESTAMP is not NULL, use it for the signature creation time. */ -int -make_backsig (PKT_signature *sig,PKT_public_key *pk, - PKT_public_key *sub_pk,PKT_secret_key *sub_sk, +gpg_error_t +make_backsig (PKT_signature *sig, PKT_public_key *pk, + PKT_public_key *sub_pk, PKT_public_key *sub_psk, u32 timestamp) { + gpg_error_t err; PKT_signature *backsig; - int rc; - cache_public_key(sub_pk); + cache_public_key (sub_pk); - rc = make_keysig_packet (&backsig, pk, NULL, sub_pk, sub_sk, 0x19, - 0, 0, timestamp, 0, NULL, NULL); - if(rc) - log_error("make_keysig_packet failed for backsig: %s\n",g10_errstr(rc)); + err = make_keysig_packet (&backsig, pk, NULL, sub_pk, sub_psk, 0x19, + 0, 0, timestamp, 0, NULL, NULL); + if (err) + log_error ("make_keysig_packet failed for backsig: %s\n", g10_errstr(err)); else { /* Get it into a binary packed form. */ - IOBUF backsig_out=iobuf_temp(); + IOBUF backsig_out = iobuf_temp(); PACKET backsig_pkt; - init_packet(&backsig_pkt); - backsig_pkt.pkttype=PKT_SIGNATURE; - backsig_pkt.pkt.signature=backsig; - rc=build_packet(backsig_out,&backsig_pkt); - free_packet(&backsig_pkt); - if(rc) - log_error("build_packet failed for backsig: %s\n",g10_errstr(rc)); + init_packet (&backsig_pkt); + backsig_pkt.pkttype = PKT_SIGNATURE; + backsig_pkt.pkt.signature = backsig; + err = build_packet (backsig_out, &backsig_pkt); + free_packet (&backsig_pkt); + if (err) + log_error ("build_packet failed for backsig: %s\n", g10_errstr(err)); else { - size_t pktlen=0; - byte *buf=iobuf_get_temp_buffer(backsig_out); + size_t pktlen = 0; + byte *buf = iobuf_get_temp_buffer (backsig_out); - /* Remove the packet header */ + /* Remove the packet header. */ if(buf[0]&0x40) { - if(buf[1]<192) + if (buf[1] < 192) { - pktlen=buf[1]; - buf+=2; - } - else if(buf[1]<224) + pktlen = buf[1]; + buf += 2; + } + else if(buf[1] < 224) { - pktlen=(buf[1]-192)*256; - pktlen+=buf[2]+192; - buf+=3; + pktlen = (buf[1]-192)*256; + pktlen += buf[2]+192; + buf += 3; } - else if(buf[1]==255) + else if (buf[1] == 255) { - pktlen =buf[2] << 24; - pktlen|=buf[3] << 16; - pktlen|=buf[4] << 8; - pktlen|=buf[5]; - buf+=6; + pktlen = buf[2] << 24; + pktlen |= buf[3] << 16; + pktlen |= buf[4] << 8; + pktlen |= buf[5]; + buf += 6; } else - BUG(); + BUG (); } else { - int mark=1; + int mark = 1; - switch(buf[0]&3) + switch (buf[0]&3) { case 3: - BUG(); + BUG (); break; case 2: - pktlen =buf[mark++] << 24; - pktlen|=buf[mark++] << 16; + pktlen = buf[mark++] << 24; + pktlen |= buf[mark++] << 16; case 1: - pktlen|=buf[mark++] << 8; + pktlen |= buf[mark++] << 8; case 0: - pktlen|=buf[mark++]; + pktlen |= buf[mark++]; } - buf+=mark; + buf += mark; } /* Now make the binary blob into a subpacket. */ - build_sig_subpkt(sig,SIGSUBPKT_SIGNATURE,buf,pktlen); + build_sig_subpkt (sig, SIGSUBPKT_SIGNATURE, buf, pktlen); - iobuf_close(backsig_out); + iobuf_close (backsig_out); } } - - return rc; + + return err; } -static int -write_direct_sig (KBNODE root, KBNODE pub_root, PKT_secret_key *sk, - struct revocation_key *revkey, u32 timestamp) +/* Write a direct key signature to the first key in ROOT using the key + PSK. REVKEY is describes the direct key signature and TIMESTAMP is + the timestamp to set on the signature. */ +static gpg_error_t +write_direct_sig (KBNODE root, PKT_public_key *psk, + struct revocation_key *revkey, u32 timestamp) { + gpg_error_t err; PACKET *pkt; PKT_signature *sig; - int rc=0; KBNODE node; PKT_public_key *pk; - if( opt.verbose ) - log_info(_("writing direct signature\n")); + if (opt.verbose) + log_info (_("writing direct signature\n")); /* Get the pk packet from the pub_tree. */ - node = find_kbnode( pub_root, PKT_PUBLIC_KEY ); - if( !node ) - BUG(); + node = find_kbnode (root, PKT_PUBLIC_KEY); + if (!node) + BUG (); pk = node->pkt->pkt.public_key; /* We have to cache the key, so that the verification of the @@ -919,48 +921,54 @@ cache_public_key (pk); /* Make the signature. */ - rc = make_keysig_packet (&sig,pk,NULL,NULL,sk,0x1F, - 0, 0, timestamp, 0, - keygen_add_revkey, revkey); - if( rc ) + err = make_keysig_packet (&sig, pk, NULL,NULL, psk, 0x1F, + 0, 0, timestamp, 0, + keygen_add_revkey, revkey); + if (err) { - log_error("make_keysig_packet failed: %s\n", g10_errstr(rc) ); - return rc; + log_error ("make_keysig_packet failed: %s\n", g10_errstr (err) ); + return err; } - pkt = xmalloc_clear( sizeof *pkt ); + pkt = xmalloc_clear (sizeof *pkt); pkt->pkttype = PKT_SIGNATURE; pkt->pkt.signature = sig; - add_kbnode( root, new_kbnode( pkt ) ); - return rc; + add_kbnode (root, new_kbnode (pkt)); + return err; } -static int -write_selfsigs( KBNODE sec_root, KBNODE pub_root, PKT_secret_key *sk, - unsigned int use, u32 timestamp ) + +/* Write a self-signature to the first user id in ROOT using the key + PSK. USE and TIMESTAMP give the extra data we need for the + signature. */ +static gpg_error_t +write_selfsigs (KBNODE root, PKT_public_key *psk, + unsigned int use, u32 timestamp) { + gpg_error_t err; PACKET *pkt; PKT_signature *sig; PKT_user_id *uid; - int rc=0; KBNODE node; PKT_public_key *pk; - if( opt.verbose ) - log_info(_("writing self signature\n")); + if (opt.verbose) + log_info (_("writing self signature\n")); /* Get the uid packet from the list. */ - node = find_kbnode( pub_root, PKT_USER_ID ); - if( !node ) + node = find_kbnode (root, PKT_USER_ID); + if (!node) BUG(); /* No user id packet in tree. */ uid = node->pkt->pkt.user_id; /* Get the pk packet from the pub_tree. */ - node = find_kbnode( pub_root, PKT_PUBLIC_KEY ); - if( !node ) + node = find_kbnode (root, PKT_PUBLIC_KEY); + if (!node) BUG(); pk = node->pkt->pkt.public_key; + + /* The usage has not yet been set - do it now. */ pk->pubkey_usage = use; /* We have to cache the key, so that the verification of the @@ -968,48 +976,45 @@ cache_public_key (pk); /* Make the signature. */ - rc = make_keysig_packet (&sig, pk, uid, NULL, sk, 0x13, - 0, 0, timestamp, 0, - keygen_add_std_prefs, pk); - if( rc ) + err = make_keysig_packet (&sig, pk, uid, NULL, psk, 0x13, + 0, 0, timestamp, 0, + keygen_add_std_prefs, pk); + if (err) { - log_error("make_keysig_packet failed: %s\n", g10_errstr(rc) ); - return rc; + log_error ("make_keysig_packet failed: %s\n", g10_errstr (err)); + return err; } - pkt = xmalloc_clear( sizeof *pkt ); + pkt = xmalloc_clear (sizeof *pkt); pkt->pkttype = PKT_SIGNATURE; pkt->pkt.signature = sig; - add_kbnode( sec_root, new_kbnode( pkt ) ); + add_kbnode (root, new_kbnode (pkt)); - pkt = xmalloc_clear( sizeof *pkt ); - pkt->pkttype = PKT_SIGNATURE; - pkt->pkt.signature = copy_signature(NULL,sig); - add_kbnode( pub_root, new_kbnode( pkt ) ); - return rc; + return err; } /* Write the key binding signature. If TIMESTAMP is not NULL use the - signature creation times. */ + signature creation time. PRI_PSK is the key use for signing. + SUB_PSK is a key used to create a back-signature; that one is only + used if USE has the PUBKEY_USAGE_SIG capability. */ static int -write_keybinding (KBNODE root, KBNODE pub_root, - PKT_secret_key *pri_sk, PKT_secret_key *sub_sk, +write_keybinding (KBNODE root, PKT_public_key *pri_psk, PKT_public_key *sub_psk, unsigned int use, u32 timestamp) { + gpg_error_t err; PACKET *pkt; PKT_signature *sig; - int rc=0; KBNODE node; PKT_public_key *pri_pk, *sub_pk; struct opaque_data_usage_and_pk oduap; - if ( opt.verbose ) + if (opt.verbose) log_info(_("writing key binding signature\n")); - /* Get the pk packet from the pub_tree. */ - node = find_kbnode ( pub_root, PKT_PUBLIC_KEY ); - if ( !node ) + /* Get the primary pk packet from the tree. */ + node = find_kbnode (root, PKT_PUBLIC_KEY); + if (!node) BUG(); pri_pk = node->pkt->pkt.public_key; @@ -1019,9 +1024,9 @@ /* Find the last subkey. */ sub_pk = NULL; - for (node=pub_root; node; node = node->next ) + for (node = root; node; node = node->next ) { - if ( node->pkt->pkttype == PKT_PUBLIC_SUBKEY ) + if (node->pkt->pkttype == PKT_PUBLIC_SUBKEY) sub_pk = node->pkt->pkt.public_key; } if (!sub_pk) @@ -1030,28 +1035,28 @@ /* Make the signature. */ oduap.usage = use; oduap.pk = sub_pk; - rc = make_keysig_packet (&sig, pri_pk, NULL, sub_pk, pri_sk, 0x18, - 0, 0, timestamp, 0, - keygen_add_key_flags_and_expire, &oduap ); - if (rc) + err = make_keysig_packet (&sig, pri_pk, NULL, sub_pk, pri_psk, 0x18, + 0, 0, timestamp, 0, + keygen_add_key_flags_and_expire, &oduap); + if (err) { - log_error ("make_keysig_packet failed: %s\n", g10_errstr(rc) ); - return rc; + log_error ("make_keysig_packet failed: %s\n", g10_errstr (err)); + return err; } /* Make a backsig. */ - if (use&PUBKEY_USAGE_SIG) + if (use & PUBKEY_USAGE_SIG) { - rc = make_backsig (sig, pri_pk, sub_pk, sub_sk, timestamp); - if (rc) - return rc; + err = make_backsig (sig, pri_pk, sub_pk, sub_psk, timestamp); + if (err) + return err; } pkt = xmalloc_clear ( sizeof *pkt ); pkt->pkttype = PKT_SIGNATURE; pkt->pkt.signature = sig; add_kbnode (root, new_kbnode (pkt) ); - return rc; + return err; } @@ -1106,71 +1111,76 @@ } + +/* Common code for the key generation fucntion gen_xxx. */ static int -genhelp_protect (DEK *dek, STRING2KEY *s2k, PKT_secret_key *sk) +common_gen (const char *keyparms, int algo, const char *algoelem, + kbnode_t pub_root, u32 timestamp, u32 expireval, int is_subkey) { - int rc = 0; - - if (dek) + int err; + PACKET *pkt; + PKT_public_key *pk; + gcry_sexp_t s_key; + + err = agent_genkey (NULL, keyparms, &s_key); + if (err) { - sk->protect.algo = dek->algo; - sk->protect.s2k = *s2k; - rc = protect_secret_key (sk, dek); - if (rc) - log_error ("protect_secret_key failed: %s\n", gpg_strerror (rc) ); + log_error ("agent_genkey failed: %s\n", gpg_strerror (err) ); + return err; } + + pk = xtrycalloc (1, sizeof *pk); + if (!pk) + { + err = gpg_error_from_syserror (); + gcry_sexp_release (s_key); + return err; + } - return rc; -} + pk->timestamp = timestamp; + pk->version = 4; + if (expireval) + pk->expiredate = pk->timestamp + expireval; + pk->pubkey_algo = algo; -static void -genhelp_factors (gcry_sexp_t misc_key_info, KBNODE sec_root) -{ - (void)misc_key_info; - (void)sec_root; -#if 0 /* Not used anymore */ - size_t n; - char *buf; + err = key_from_sexp (pk->pkey, s_key, "public-key", algoelem); + if (err) + { + log_error ("key_from_sexp failed: %s\n", gpg_strerror (err) ); + gcry_sexp_release (s_key); + free_public_key (pk); + return err; + } + gcry_sexp_release (s_key); - if (misc_key_info) + pkt = xtrycalloc (1, sizeof *pkt); + if (!pkt) { - /* DSA: don't know whether it makes sense to have the factors, so for now - we store them in the secret keyring (but they are not secret) - p = 2 * q * f1 * f2 * ... * fn - We store only f1 to f_n-1; fn can be calculated because p and q - are known. */ - n = gcry_sexp_sprint (misc_key_info, 0, NULL, 0); - buf = xmalloc (n+4); - strcpy (buf, "#::"); - n = gcry_sexp_sprint (misc_key_info, 0, buf+3, n); - if (n) - { - n += 3; - add_kbnode (sec_root, make_comment_node_from_buffer (buf, n)); - } - xfree (buf); - gcry_sexp_release (misc_key_info); + err = gpg_error_from_syserror (); + free_public_key (pk); + return err; } -#endif + + pkt->pkttype = is_subkey ? PKT_PUBLIC_SUBKEY : PKT_PUBLIC_KEY; + pkt->pkt.public_key = pk; + add_kbnode (pub_root, new_kbnode (pkt)); + + return 0; } -/* Generate an Elgamal encryption key pair. TIMESTAMP is the creatuion - time to be put into the key structure. */ +/* + * Generate an Elgamal key. + */ static int -gen_elg (int algo, unsigned int nbits, - KBNODE pub_root, KBNODE sec_root, DEK *dek, - STRING2KEY *s2k, PKT_secret_key **ret_sk, +gen_elg (int algo, unsigned int nbits, KBNODE pub_root, u32 timestamp, u32 expireval, int is_subkey) { - int rc; - PACKET *pkt; - PKT_secret_key *sk; - PKT_public_key *pk; - gcry_sexp_t s_parms, s_key; - gcry_sexp_t misc_key_info; + int err; + char *keyparms; + char nbitsstr[35]; - assert( is_ELGAMAL(algo) ); + assert (is_ELGAMAL (algo)); if (nbits < 512) { @@ -1184,104 +1194,36 @@ log_info (_("keysize rounded up to %u bits\n"), nbits ); } - - rc = gcry_sexp_build ( &s_parms, NULL, - "(genkey(%s(nbits %d)))", - algo == GCRY_PK_ELG_E ? "openpgp-elg" : - algo == GCRY_PK_ELG ? "elg" : "x-oops" , - (int)nbits); - if (rc) - log_bug ("gcry_sexp_build failed: %s\n", gpg_strerror (rc)); - - rc = gcry_pk_genkey (&s_key, s_parms); - gcry_sexp_release (s_parms); - if (rc) + snprintf (nbitsstr, sizeof nbitsstr, "%u", nbits); + keyparms = xtryasprintf ("(genkey(%s(nbits %zu:%s)))", + algo == GCRY_PK_ELG_E ? "openpgp-elg" : + algo == GCRY_PK_ELG ? "elg" : "x-oops" , + strlen (nbitsstr), nbitsstr); + if (!keyparms) + err = gpg_error_from_syserror (); + else { - log_error ("gcry_pk_genkey failed: %s\n", gpg_strerror (rc) ); - return rc; + err = common_gen (keyparms, algo, "pgy", + pub_root, timestamp, expireval, is_subkey); + xfree (keyparms); } - - sk = xmalloc_clear( sizeof *sk ); - pk = xmalloc_clear( sizeof *pk ); - sk->timestamp = pk->timestamp = timestamp; - sk->version = pk->version = 4; - if (expireval) - { - sk->expiredate = pk->expiredate = sk->timestamp + expireval; - } - sk->pubkey_algo = pk->pubkey_algo = algo; - rc = key_from_sexp (pk->pkey, s_key, "public-key", "pgy"); - if (rc) - { - log_error ("key_from_sexp failed: %s\n", gpg_strerror (rc) ); - gcry_sexp_release (s_key); - free_secret_key (sk); - free_public_key (pk); - return rc; - } - rc = key_from_sexp (sk->skey, s_key, "private-key", "pgyx"); - if (rc) - { - log_error("key_from_sexp failed: %s\n", gpg_strerror (rc) ); - gcry_sexp_release (s_key); - free_secret_key (sk); - free_public_key (pk); - return rc; - } - misc_key_info = gcry_sexp_find_token (s_key, "misc-key-info", 0); - gcry_sexp_release (s_key); - - sk->is_protected = 0; - sk->protect.algo = 0; - - sk->csum = checksum_mpi (sk->skey[3]); - if (ret_sk) /* Return an unprotected version of the sk. */ - *ret_sk = copy_secret_key ( NULL, sk ); - - rc = genhelp_protect (dek, s2k, sk); - if (rc) - { - free_public_key (pk); - free_secret_key (sk); - gcry_sexp_release (misc_key_info); - return rc; - } - - pkt = xmalloc_clear (sizeof *pkt); - pkt->pkttype = is_subkey ? PKT_PUBLIC_SUBKEY : PKT_PUBLIC_KEY; - pkt->pkt.public_key = pk; - add_kbnode (pub_root, new_kbnode( pkt )); - - /* Don't know whether it makes sense to have access to the factors, - so for now we store them in the secret keyring (but they are not - secret). */ - pkt = xmalloc_clear (sizeof *pkt); - pkt->pkttype = is_subkey ? PKT_SECRET_SUBKEY : PKT_SECRET_KEY; - pkt->pkt.secret_key = sk; - add_kbnode (sec_root, new_kbnode( pkt )); - - genhelp_factors (misc_key_info, sec_root); - - return 0; + return err; } -/**************** - * Generate a DSA key +/* + * Generate an DSA key */ -static int -gen_dsa (unsigned int nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek, - STRING2KEY *s2k, PKT_secret_key **ret_sk, +static gpg_error_t +gen_dsa (unsigned int nbits, KBNODE pub_root, u32 timestamp, u32 expireval, int is_subkey) { - int rc; - PACKET *pkt; - PKT_secret_key *sk; - PKT_public_key *pk; - gcry_sexp_t s_parms, s_key; - gcry_sexp_t misc_key_info; + int err; unsigned int qbits; + char *keyparms; + char nbitsstr[35]; + char qbitsstr[35]; if ( nbits < 512) { @@ -1334,84 +1276,21 @@ log_info (_("WARNING: some OpenPGP programs can't" " handle a DSA key with this digest size\n")); - rc = gcry_sexp_build (&s_parms, NULL, - "(genkey(dsa(nbits %d)(qbits %d)))", - (int)nbits, (int)qbits); From cvs at cvs.gnupg.org Tue Apr 20 20:19:20 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 20 Apr 2010 20:19:20 +0200 Subject: [svn] GnuPG - r5313 - trunk/g10 Message-ID: Author: wk Date: 2010-04-20 20:19:19 +0200 (Tue, 20 Apr 2010) New Revision: 5313 Modified: trunk/g10/keyedit.c Log: Reindented [The diff below has been truncated] Modified: trunk/g10/keyedit.c =================================================================== --- trunk/g10/keyedit.c 2010-04-20 17:57:50 UTC (rev 5312) +++ trunk/g10/keyedit.c 2010-04-20 18:19:19 UTC (rev 5313) @@ -26,8 +26,8 @@ #include #include #ifdef HAVE_LIBREADLINE -#define GNUPG_LIBREADLINE_H_INCLUDED -#include +# define GNUPG_LIBREADLINE_H_INCLUDED +# include #endif #include "gpg.h" @@ -46,64 +46,67 @@ #include "i18n.h" #include "keyserver-internal.h" -static void show_prefs( PKT_user_id *uid, PKT_signature *selfsig, int verbose); -static void show_names(KBNODE keyblock,PKT_public_key *pk, - unsigned int flag,int with_prefs); -static void show_key_with_all_names( KBNODE keyblock, int only_marked, - int with_revoker, int with_fpr, int with_subkeys, int with_prefs ); -static void show_key_and_fingerprint( KBNODE keyblock ); -static int menu_adduid( KBNODE keyblock, KBNODE sec_keyblock, - int photo, const char *photo_name ); -static void menu_deluid( KBNODE pub_keyblock, KBNODE sec_keyblock ); -static int menu_delsig( KBNODE pub_keyblock ); -static int menu_clean(KBNODE keyblock,int self_only); -static void menu_delkey( KBNODE pub_keyblock, KBNODE sec_keyblock ); -static int menu_addrevoker( KBNODE pub_keyblock, - KBNODE sec_keyblock, int sensitive ); -static int menu_expire( KBNODE pub_keyblock, KBNODE sec_keyblock ); -static int menu_backsign(KBNODE pub_keyblock,KBNODE sec_keyblock); -static int menu_set_primary_uid( KBNODE pub_keyblock, KBNODE sec_keyblock ); -static int menu_set_preferences( KBNODE pub_keyblock, KBNODE sec_keyblock ); +static void show_prefs (PKT_user_id * uid, PKT_signature * selfsig, + int verbose); +static void show_names (KBNODE keyblock, PKT_public_key * pk, + unsigned int flag, int with_prefs); +static void show_key_with_all_names (KBNODE keyblock, int only_marked, + int with_revoker, int with_fpr, + int with_subkeys, int with_prefs); +static void show_key_and_fingerprint (KBNODE keyblock); +static int menu_adduid (KBNODE keyblock, KBNODE sec_keyblock, + int photo, const char *photo_name); +static void menu_deluid (KBNODE pub_keyblock, KBNODE sec_keyblock); +static int menu_delsig (KBNODE pub_keyblock); +static int menu_clean (KBNODE keyblock, int self_only); +static void menu_delkey (KBNODE pub_keyblock, KBNODE sec_keyblock); +static int menu_addrevoker (KBNODE pub_keyblock, + KBNODE sec_keyblock, int sensitive); +static int menu_expire (KBNODE pub_keyblock, KBNODE sec_keyblock); +static int menu_backsign (KBNODE pub_keyblock, KBNODE sec_keyblock); +static int menu_set_primary_uid (KBNODE pub_keyblock, KBNODE sec_keyblock); +static int menu_set_preferences (KBNODE pub_keyblock, KBNODE sec_keyblock); static int menu_set_keyserver_url (const char *url, - KBNODE pub_keyblock, KBNODE sec_keyblock ); -static int menu_set_notation(const char *string, - KBNODE pub_keyblock,KBNODE sec_keyblock); -static int menu_select_uid( KBNODE keyblock, int idx ); -static int menu_select_uid_namehash( KBNODE keyblock, const char *namehash ); -static int menu_select_key( KBNODE keyblock, int idx ); -static int count_uids( KBNODE keyblock ); -static int count_uids_with_flag( KBNODE keyblock, unsigned flag ); -static int count_keys_with_flag( KBNODE keyblock, unsigned flag ); -static int count_selected_uids( KBNODE keyblock ); -static int real_uids_left( KBNODE keyblock ); -static int count_selected_keys( KBNODE keyblock ); -static int menu_revsig( KBNODE keyblock ); -static int menu_revuid( KBNODE keyblock, KBNODE sec_keyblock ); -static int menu_revkey( KBNODE pub_keyblock, KBNODE sec_keyblock ); -static int menu_revsubkey( KBNODE pub_keyblock, KBNODE sec_keyblock ); -static int enable_disable_key( KBNODE keyblock, int disable ); -static void menu_showphoto( KBNODE keyblock ); + KBNODE pub_keyblock, KBNODE sec_keyblock); +static int menu_set_notation (const char *string, + KBNODE pub_keyblock, KBNODE sec_keyblock); +static int menu_select_uid (KBNODE keyblock, int idx); +static int menu_select_uid_namehash (KBNODE keyblock, const char *namehash); +static int menu_select_key (KBNODE keyblock, int idx); +static int count_uids (KBNODE keyblock); +static int count_uids_with_flag (KBNODE keyblock, unsigned flag); +static int count_keys_with_flag (KBNODE keyblock, unsigned flag); +static int count_selected_uids (KBNODE keyblock); +static int real_uids_left (KBNODE keyblock); +static int count_selected_keys (KBNODE keyblock); +static int menu_revsig (KBNODE keyblock); +static int menu_revuid (KBNODE keyblock, KBNODE sec_keyblock); +static int menu_revkey (KBNODE pub_keyblock, KBNODE sec_keyblock); +static int menu_revsubkey (KBNODE pub_keyblock, KBNODE sec_keyblock); +static int enable_disable_key (KBNODE keyblock, int disable); +static void menu_showphoto (KBNODE keyblock); -static int update_trust=0; +static int update_trust = 0; #define CONTROL_D ('D' - 'A' + 1) -#define NODFLG_BADSIG (1<<0) /* bad signature */ -#define NODFLG_NOKEY (1<<1) /* no public key */ -#define NODFLG_SIGERR (1<<2) /* other sig error */ +#define NODFLG_BADSIG (1<<0) /* Bad signature. */ +#define NODFLG_NOKEY (1<<1) /* No public key. */ +#define NODFLG_SIGERR (1<<2) /* Other sig error. */ -#define NODFLG_MARK_A (1<<4) /* temporary mark */ -#define NODFLG_DELSIG (1<<5) /* to be deleted */ +#define NODFLG_MARK_A (1<<4) /* Temporary mark. */ +#define NODFLG_DELSIG (1<<5) /* To be deleted. */ -#define NODFLG_SELUID (1<<8) /* indicate the selected userid */ -#define NODFLG_SELKEY (1<<9) /* indicate the selected key */ -#define NODFLG_SELSIG (1<<10) /* indicate a selected signature */ +#define NODFLG_SELUID (1<<8) /* Indicate the selected userid. */ +#define NODFLG_SELKEY (1<<9) /* Indicate the selected key. */ +#define NODFLG_SELSIG (1<<10) /* Indicate a selected signature. */ -struct sign_attrib { - int non_exportable,non_revocable; - struct revocation_reason_info *reason; - byte trust_depth,trust_value; - char *trust_regexp; +struct sign_attrib +{ + int non_exportable, non_revocable; + struct revocation_reason_info *reason; + byte trust_depth, trust_value; + char *trust_regexp; }; @@ -116,7 +119,7 @@ KBNODE node = pub_keyblock; PKT_secret_key *sk; PKT_public_key *pk; - + if (sec_node->pkt->pkttype == PKT_SECRET_KEY && node->pkt->pkttype == PKT_PUBLIC_KEY) return node->pkt->pkt.public_key; @@ -126,11 +129,11 @@ for (; node; node = node->next) if (node->pkt->pkttype == PKT_PUBLIC_SUBKEY) { - pk = node->pkt->pkt.public_key; - if (pk->keyid[0] == sk->keyid[0] && pk->keyid[1] == sk->keyid[1]) - return pk; + pk = node->pkt->pkt.public_key; + if (pk->keyid[0] == sk->keyid[0] && pk->keyid[1] == sk->keyid[1]) + return pk; } - + return NULL; } #endif /* ENABLE_CARD_SUPPORT */ @@ -139,9 +142,9 @@ /* TODO: Fix duplicated code between here and the check-sigs/list-sigs code in keylist.c. */ static int -print_and_check_one_sig_colon( KBNODE keyblock, KBNODE node, +print_and_check_one_sig_colon (KBNODE keyblock, KBNODE node, int *inv_sigs, int *no_key, int *oth_err, - int *is_selfsig, int print_without_key ) + int *is_selfsig, int print_without_key) { PKT_signature *sig = node->pkt->pkt.signature; int rc, sigrc; @@ -149,1134 +152,1188 @@ /* TODO: Make sure a cached sig record here still has the pk that issued it. See also keylist.c:list_keyblock_print */ - switch((rc=check_key_signature(keyblock,node,is_selfsig))) + switch ((rc = check_key_signature (keyblock, node, is_selfsig))) { case 0: - node->flag &= ~(NODFLG_BADSIG|NODFLG_NOKEY|NODFLG_SIGERR); + node->flag &= ~(NODFLG_BADSIG | NODFLG_NOKEY | NODFLG_SIGERR); sigrc = '!'; break; case G10ERR_BAD_SIGN: node->flag = NODFLG_BADSIG; sigrc = '-'; - if( inv_sigs ) - ++*inv_sigs; + if (inv_sigs) + ++ * inv_sigs; break; case G10ERR_NO_PUBKEY: case G10ERR_UNU_PUBKEY: node->flag = NODFLG_NOKEY; sigrc = '?'; - if( no_key ) - ++*no_key; + if (no_key) + ++ * no_key; break; default: node->flag = NODFLG_SIGERR; sigrc = '%'; - if( oth_err ) - ++*oth_err; + if (oth_err) + ++ * oth_err; break; } - if( sigrc != '?' || print_without_key ) + if (sigrc != '?' || print_without_key) { - printf("sig:%c::%d:%08lX%08lX:%lu:%lu:", - sigrc,sig->pubkey_algo,(ulong)sig->keyid[0],(ulong)sig->keyid[1], - (ulong)sig->timestamp,(ulong)sig->expiredate); + printf ("sig:%c::%d:%08lX%08lX:%lu:%lu:", + sigrc, sig->pubkey_algo, (ulong) sig->keyid[0], + (ulong) sig->keyid[1], (ulong) sig->timestamp, + (ulong) sig->expiredate); - if(sig->trust_depth || sig->trust_value) - printf("%d %d",sig->trust_depth,sig->trust_value); + if (sig->trust_depth || sig->trust_value) + printf ("%d %d", sig->trust_depth, sig->trust_value); - printf(":"); + printf (":"); - if(sig->trust_regexp) - es_write_sanitized (es_stdout, - sig->trust_regexp, strlen (sig->trust_regexp), - ":", NULL); + if (sig->trust_regexp) + es_write_sanitized (es_stdout, + sig->trust_regexp, strlen (sig->trust_regexp), + ":", NULL); - printf("::%02x%c\n",sig->sig_class,sig->flags.exportable?'x':'l'); + printf ("::%02x%c\n", sig->sig_class, + sig->flags.exportable ? 'x' : 'l'); - if(opt.show_subpackets) - print_subpackets_colon(sig); + if (opt.show_subpackets) + print_subpackets_colon (sig); } return (sigrc == '!'); } -/**************** +/* * Print information about a signature, check it and return true * if the signature is okay. NODE must be a signature packet. */ static int -print_and_check_one_sig( KBNODE keyblock, KBNODE node, +print_and_check_one_sig (KBNODE keyblock, KBNODE node, int *inv_sigs, int *no_key, int *oth_err, - int *is_selfsig, int print_without_key ) + int *is_selfsig, int print_without_key) { - PKT_signature *sig = node->pkt->pkt.signature; - int rc, sigrc; - int is_rev = sig->sig_class == 0x30; + PKT_signature *sig = node->pkt->pkt.signature; + int rc, sigrc; + int is_rev = sig->sig_class == 0x30; - /* TODO: Make sure a cached sig record here still has the pk that - issued it. See also keylist.c:list_keyblock_print */ + /* TODO: Make sure a cached sig record here still has the pk that + issued it. See also keylist.c:list_keyblock_print */ - switch( (rc = check_key_signature( keyblock, node, is_selfsig)) ) { - case 0: - node->flag &= ~(NODFLG_BADSIG|NODFLG_NOKEY|NODFLG_SIGERR); - sigrc = '!'; - break; - case G10ERR_BAD_SIGN: - node->flag = NODFLG_BADSIG; - sigrc = '-'; - if( inv_sigs ) - ++*inv_sigs; - break; - case G10ERR_NO_PUBKEY: - case G10ERR_UNU_PUBKEY: - node->flag = NODFLG_NOKEY; - sigrc = '?'; - if( no_key ) - ++*no_key; - break; - default: - node->flag = NODFLG_SIGERR; - sigrc = '%'; - if( oth_err ) - ++*oth_err; - break; + switch ((rc = check_key_signature (keyblock, node, is_selfsig))) + { + case 0: + node->flag &= ~(NODFLG_BADSIG | NODFLG_NOKEY | NODFLG_SIGERR); + sigrc = '!'; + break; + case G10ERR_BAD_SIGN: + node->flag = NODFLG_BADSIG; + sigrc = '-'; + if (inv_sigs) + ++ * inv_sigs; + break; + case G10ERR_NO_PUBKEY: + case G10ERR_UNU_PUBKEY: + node->flag = NODFLG_NOKEY; + sigrc = '?'; + if (no_key) + ++ * no_key; + break; + default: + node->flag = NODFLG_SIGERR; + sigrc = '%'; + if (oth_err) + ++ * oth_err; + break; } - if( sigrc != '?' || print_without_key ) { - tty_printf("%s%c%c %c%c%c%c%c%c %s %s", - is_rev? "rev":"sig",sigrc, - (sig->sig_class-0x10>0 && - sig->sig_class-0x10<4)?'0'+sig->sig_class-0x10:' ', - sig->flags.exportable?' ':'L', - sig->flags.revocable?' ':'R', - sig->flags.policy_url?'P':' ', - sig->flags.notation?'N':' ', - sig->flags.expired?'X':' ', - (sig->trust_depth>9)?'T': - (sig->trust_depth>0)?'0'+sig->trust_depth:' ', - keystr(sig->keyid),datestr_from_sig(sig)); - if(opt.list_options&LIST_SHOW_SIG_EXPIRE) - tty_printf(" %s",expirestr_from_sig(sig)); - tty_printf(" "); - if( sigrc == '%' ) - tty_printf("[%s] ", g10_errstr(rc) ); - else if( sigrc == '?' ) - ; - else if( *is_selfsig ) { - tty_printf( is_rev? _("[revocation]") - : _("[self-signature]") ); + if (sigrc != '?' || print_without_key) + { + tty_printf ("%s%c%c %c%c%c%c%c%c %s %s", + is_rev ? "rev" : "sig", sigrc, + (sig->sig_class - 0x10 > 0 && + sig->sig_class - 0x10 < + 4) ? '0' + sig->sig_class - 0x10 : ' ', + sig->flags.exportable ? ' ' : 'L', + sig->flags.revocable ? ' ' : 'R', + sig->flags.policy_url ? 'P' : ' ', + sig->flags.notation ? 'N' : ' ', + sig->flags.expired ? 'X' : ' ', + (sig->trust_depth > 9) ? 'T' : (sig->trust_depth > + 0) ? '0' + + sig->trust_depth : ' ', keystr (sig->keyid), + datestr_from_sig (sig)); + if (opt.list_options & LIST_SHOW_SIG_EXPIRE) + tty_printf (" %s", expirestr_from_sig (sig)); + tty_printf (" "); + if (sigrc == '%') + tty_printf ("[%s] ", g10_errstr (rc)); + else if (sigrc == '?') + ; + else if (*is_selfsig) + { + tty_printf (is_rev ? _("[revocation]") : _("[self-signature]")); } - else - { - size_t n; - char *p = get_user_id( sig->keyid, &n ); - tty_print_utf8_string2(p, n, opt.screen_columns-keystrlen()-26- - ((opt.list_options&LIST_SHOW_SIG_EXPIRE)?11:0)); - xfree(p); - } - tty_printf("\n"); + else + { + size_t n; + char *p = get_user_id (sig->keyid, &n); + tty_print_utf8_string2 (p, n, + opt.screen_columns - keystrlen () - 26 - + ((opt. + list_options & LIST_SHOW_SIG_EXPIRE) ? 11 + : 0)); + xfree (p); + } + tty_printf ("\n"); - if(sig->flags.policy_url && (opt.list_options&LIST_SHOW_POLICY_URLS)) - show_policy_url(sig,3,0); + if (sig->flags.policy_url && (opt.list_options & LIST_SHOW_POLICY_URLS)) + show_policy_url (sig, 3, 0); - if(sig->flags.notation && (opt.list_options&LIST_SHOW_NOTATIONS)) - show_notation(sig,3,0, - ((opt.list_options&LIST_SHOW_STD_NOTATIONS)?1:0)+ - ((opt.list_options&LIST_SHOW_USER_NOTATIONS)?2:0)); + if (sig->flags.notation && (opt.list_options & LIST_SHOW_NOTATIONS)) + show_notation (sig, 3, 0, + ((opt. + list_options & LIST_SHOW_STD_NOTATIONS) ? 1 : 0) + + ((opt. + list_options & LIST_SHOW_USER_NOTATIONS) ? 2 : 0)); - if(sig->flags.pref_ks && (opt.list_options&LIST_SHOW_KEYSERVER_URLS)) - show_keyserver_url(sig,3,0); + if (sig->flags.pref_ks && (opt.list_options & LIST_SHOW_KEYSERVER_URLS)) + show_keyserver_url (sig, 3, 0); } - return (sigrc == '!'); + return (sigrc == '!'); } -/**************** +/* * Check the keysigs and set the flags to indicate errors. * Returns true if error found. */ static int -check_all_keysigs( KBNODE keyblock, int only_selected ) +check_all_keysigs (KBNODE keyblock, int only_selected) { - KBNODE kbctx; - KBNODE node; - int inv_sigs = 0; - int no_key = 0; - int oth_err = 0; - int has_selfsig = 0; - int mis_selfsig = 0; - int selected = !only_selected; - int anyuid = 0; + KBNODE kbctx; + KBNODE node; + int inv_sigs = 0; + int no_key = 0; + int oth_err = 0; + int has_selfsig = 0; + int mis_selfsig = 0; + int selected = !only_selected; + int anyuid = 0; - for( kbctx=NULL; (node=walk_kbnode( keyblock, &kbctx, 0)) ; ) { - if( node->pkt->pkttype == PKT_USER_ID ) { - PKT_user_id *uid = node->pkt->pkt.user_id; + for (kbctx = NULL; (node = walk_kbnode (keyblock, &kbctx, 0));) + { + if (node->pkt->pkttype == PKT_USER_ID) + { + PKT_user_id *uid = node->pkt->pkt.user_id; - if( only_selected ) - selected = (node->flag & NODFLG_SELUID); - if( selected ) { - tty_printf("uid "); - tty_print_utf8_string( uid->name, uid->len ); - tty_printf("\n"); - if( anyuid && !has_selfsig ) - mis_selfsig++; - has_selfsig = 0; - anyuid = 1; + if (only_selected) + selected = (node->flag & NODFLG_SELUID); + if (selected) + { + tty_printf ("uid "); + tty_print_utf8_string (uid->name, uid->len); + tty_printf ("\n"); + if (anyuid && !has_selfsig) + mis_selfsig++; + has_selfsig = 0; + anyuid = 1; } } - else if( selected && node->pkt->pkttype == PKT_SIGNATURE - && ( (node->pkt->pkt.signature->sig_class&~3) == 0x10 - || node->pkt->pkt.signature->sig_class == 0x30 ) ) { - int selfsig; + else if (selected && node->pkt->pkttype == PKT_SIGNATURE + && ((node->pkt->pkt.signature->sig_class & ~3) == 0x10 + || node->pkt->pkt.signature->sig_class == 0x30)) + { + int selfsig; - if( print_and_check_one_sig( keyblock, node, &inv_sigs, - &no_key, &oth_err, &selfsig, 0 ) ) { - if( selfsig ) - has_selfsig = 1; + if (print_and_check_one_sig (keyblock, node, &inv_sigs, + &no_key, &oth_err, &selfsig, 0)) + { + if (selfsig) + has_selfsig = 1; } - /* Hmmm: should we update the trustdb here? */ + /* Hmmm: should we update the trustdb here? */ } } - if( !has_selfsig ) - mis_selfsig++; - if( inv_sigs == 1 ) - tty_printf(_("1 bad signature\n") ); - else if( inv_sigs ) - tty_printf(_("%d bad signatures\n"), inv_sigs ); - if( no_key == 1 ) - tty_printf(_("1 signature not checked due to a missing key\n") ); - else if( no_key ) - tty_printf(_("%d signatures not checked due to missing keys\n"), no_key ); - if( oth_err == 1 ) - tty_printf(_("1 signature not checked due to an error\n") ); - else if( oth_err ) - tty_printf(_("%d signatures not checked due to errors\n"), oth_err ); - if( mis_selfsig == 1 ) - tty_printf(_("1 user ID without valid self-signature detected\n")); - else if( mis_selfsig ) - tty_printf(_("%d user IDs without valid self-signatures detected\n"), - mis_selfsig); + if (!has_selfsig) + mis_selfsig++; + if (inv_sigs == 1) + tty_printf (_("1 bad signature\n")); + else if (inv_sigs) + tty_printf (_("%d bad signatures\n"), inv_sigs); + if (no_key == 1) + tty_printf (_("1 signature not checked due to a missing key\n")); + else if (no_key) + tty_printf (_("%d signatures not checked due to missing keys\n"), no_key); + if (oth_err == 1) + tty_printf (_("1 signature not checked due to an error\n")); + else if (oth_err) + tty_printf (_("%d signatures not checked due to errors\n"), oth_err); + if (mis_selfsig == 1) + tty_printf (_("1 user ID without valid self-signature detected\n")); + else if (mis_selfsig) + tty_printf (_("%d user IDs without valid self-signatures detected\n"), + mis_selfsig); - return inv_sigs || no_key || oth_err || mis_selfsig; + return inv_sigs || no_key || oth_err || mis_selfsig; } static int -sign_mk_attrib( PKT_signature *sig, void *opaque ) +sign_mk_attrib (PKT_signature * sig, void *opaque) { - struct sign_attrib *attrib = opaque; - byte buf[8]; + struct sign_attrib *attrib = opaque; + byte buf[8]; - if( attrib->non_exportable ) { - buf[0] = 0; /* not exportable */ - build_sig_subpkt( sig, SIGSUBPKT_EXPORTABLE, buf, 1 ); + if (attrib->non_exportable) + { + buf[0] = 0; /* not exportable */ + build_sig_subpkt (sig, SIGSUBPKT_EXPORTABLE, buf, 1); } - if( attrib->non_revocable ) { - buf[0] = 0; /* not revocable */ - build_sig_subpkt( sig, SIGSUBPKT_REVOCABLE, buf, 1 ); + if (attrib->non_revocable) + { + buf[0] = 0; /* not revocable */ + build_sig_subpkt (sig, SIGSUBPKT_REVOCABLE, buf, 1); } - if( attrib->reason ) - revocation_reason_build_cb( sig, attrib->reason ); + if (attrib->reason) + revocation_reason_build_cb (sig, attrib->reason); - if(attrib->trust_depth) - { - /* Not critical. If someone doesn't understand trust sigs, - this can still be a valid regular signature. */ - buf[0] = attrib->trust_depth; - buf[1] = attrib->trust_value; - build_sig_subpkt(sig,SIGSUBPKT_TRUST,buf,2); + if (attrib->trust_depth) + { + /* Not critical. If someone doesn't understand trust sigs, + this can still be a valid regular signature. */ + buf[0] = attrib->trust_depth; + buf[1] = attrib->trust_value; + build_sig_subpkt (sig, SIGSUBPKT_TRUST, buf, 2); - /* Critical. If someone doesn't understands regexps, this - whole sig should be invalid. Note the +1 for the length - - regexps are null terminated. */ - if(attrib->trust_regexp) - build_sig_subpkt(sig,SIGSUBPKT_FLAG_CRITICAL|SIGSUBPKT_REGEXP, - attrib->trust_regexp, - strlen(attrib->trust_regexp)+1); - } + /* Critical. If someone doesn't understands regexps, this + whole sig should be invalid. Note the +1 for the length - + regexps are null terminated. */ + if (attrib->trust_regexp) + build_sig_subpkt (sig, SIGSUBPKT_FLAG_CRITICAL | SIGSUBPKT_REGEXP, + attrib->trust_regexp, + strlen (attrib->trust_regexp) + 1); + } - return 0; + return 0; } + static void -trustsig_prompt(byte *trust_value,byte *trust_depth,char **regexp) +trustsig_prompt (byte * trust_value, byte * trust_depth, char **regexp) { char *p; - *trust_value=0; - *trust_depth=0; - *regexp=NULL; + *trust_value = 0; + *trust_depth = 0; + *regexp = NULL; /* Same string as pkclist.c:do_edit_ownertrust */ - tty_printf(_("Please decide how far you trust this user to correctly verify" + tty_printf (_ + ("Please decide how far you trust this user to correctly verify" " other users' keys\n(by looking at passports, checking" " fingerprints from different sources, etc.)\n")); - tty_printf("\n"); + tty_printf ("\n"); tty_printf (_(" %d = I trust marginally\n"), 1); tty_printf (_(" %d = I trust fully\n"), 2); - tty_printf("\n"); + tty_printf ("\n"); - while(*trust_value==0) + while (*trust_value == 0) { - p = cpr_get("trustsig_prompt.trust_value",_("Your selection? ")); - trim_spaces(p); - cpr_kill_prompt(); + p = cpr_get ("trustsig_prompt.trust_value", _("Your selection? ")); + trim_spaces (p); + cpr_kill_prompt (); /* 60 and 120 are as per RFC2440 */ - if(p[0]=='1' && !p[1]) - *trust_value=60; - else if(p[0]=='2' && !p[1]) - *trust_value=120; - xfree(p); + if (p[0] == '1' && !p[1]) + *trust_value = 60; + else if (p[0] == '2' && !p[1]) + *trust_value = 120; + xfree (p); } - tty_printf("\n"); + tty_printf ("\n"); - tty_printf(_( - "Please enter the depth of this trust signature.\n" - "A depth greater than 1 allows the key you are signing to make\n" - "trust signatures on your behalf.\n")); - tty_printf("\n"); + tty_printf (_("Please enter the depth of this trust signature.\n" + "A depth greater than 1 allows the key you are signing to make\n" + "trust signatures on your behalf.\n")); + tty_printf ("\n"); - while(*trust_depth==0) + while (*trust_depth == 0) { - p = cpr_get("trustsig_prompt.trust_depth",_("Your selection? ")); - trim_spaces(p); - cpr_kill_prompt(); - *trust_depth=atoi(p); - xfree(p); + p = cpr_get ("trustsig_prompt.trust_depth", _("Your selection? ")); + trim_spaces (p); + cpr_kill_prompt (); + *trust_depth = atoi (p); + xfree (p); } - tty_printf("\n"); + tty_printf ("\n"); - tty_printf(_("Please enter a domain to restrict this signature, " - "or enter for none.\n")); + tty_printf (_("Please enter a domain to restrict this signature, " + "or enter for none.\n")); - tty_printf("\n"); + tty_printf ("\n"); - p=cpr_get("trustsig_prompt.trust_regexp",_("Your selection? ")); - trim_spaces(p); - cpr_kill_prompt(); + p = cpr_get ("trustsig_prompt.trust_regexp", _("Your selection? ")); + trim_spaces (p); + cpr_kill_prompt (); - if(strlen(p)>0) + if (strlen (p) > 0) { - char *q=p; - int regexplen=100,ind; + char *q = p; + int regexplen = 100, ind; - *regexp=xmalloc(regexplen); + *regexp = xmalloc (regexplen); /* Now mangle the domain the user entered into a regexp. To do - this, \-escape everything that isn't alphanumeric, and attach - "<[^>]+[@.]" to the front, and ">$" to the end. */ + this, \-escape everything that isn't alphanumeric, and attach + "<[^>]+[@.]" to the front, and ">$" to the end. */ - strcpy(*regexp,"<[^>]+[@.]"); - ind=strlen(*regexp); + strcpy (*regexp, "<[^>]+[@.]"); + ind = strlen (*regexp); - while(*q) + while (*q) { - if(!((*q>='A' && *q<='Z') - || (*q>='a' && *q<='z') || (*q>='0' && *q<='9'))) - (*regexp)[ind++]='\\'; + if (!((*q >= 'A' && *q <= 'Z') + || (*q >= 'a' && *q <= 'z') || (*q >= '0' && *q <= '9'))) + (*regexp)[ind++] = '\\'; - (*regexp)[ind++]=*q; + (*regexp)[ind++] = *q; - if((regexplen-ind)<3) + if ((regexplen - ind) < 3) { - regexplen+=100; - *regexp=xrealloc(*regexp,regexplen); + regexplen += 100; + *regexp = xrealloc (*regexp, regexplen); } q++; } - (*regexp)[ind]='\0'; - strcat(*regexp,">$"); + (*regexp)[ind] = '\0'; + strcat (*regexp, ">$"); } - xfree(p); - tty_printf("\n"); + xfree (p); + tty_printf ("\n"); } -/**************** + +/* * Loop over all locusr and and sign the uids after asking. * If no user id is marked, all user ids will be signed; * if some user_ids are marked those will be signed. */ static int -sign_uids( KBNODE keyblock, strlist_t locusr, int *ret_modified, - int local, int nonrevocable, int trust, int interactive ) +sign_uids (KBNODE keyblock, strlist_t locusr, int *ret_modified, + int local, int nonrevocable, int trust, int interactive) { - int rc = 0; - SK_LIST sk_list = NULL; - SK_LIST sk_rover = NULL; - PKT_public_key *pk = NULL; - KBNODE node, uidnode; - PKT_public_key *primary_pk=NULL; - int select_all = !count_selected_uids(keyblock) || interactive; - int all_v3=1; + int rc = 0; + SK_LIST sk_list = NULL; + SK_LIST sk_rover = NULL; + PKT_public_key *pk = NULL; + KBNODE node, uidnode; + PKT_public_key *primary_pk = NULL; + int select_all = !count_selected_uids (keyblock) || interactive; + int all_v3 = 1; - /* Are there any non-v3 sigs on this key already? */ - if(PGP2) - for(node=keyblock;node;node=node->next) - if(node->pkt->pkttype==PKT_SIGNATURE && - node->pkt->pkt.signature->version>3) - { - all_v3=0; - break; - } + /* Are there any non-v3 sigs on this key already? */ + if (PGP2) + for (node = keyblock; node; node = node->next) + if (node->pkt->pkttype == PKT_SIGNATURE && + node->pkt->pkt.signature->version > 3) + { + all_v3 = 0; + break; + } - /* build a list of all signators. - * - * We use the CERT flag to request the primary which must always - * be one which is capable of signing keys. I can't see a reason - * why to sign keys using a subkey. Implementation of USAGE_CERT - * is just a hack in getkey.c and does not mean that a subkey - * marked as certification capable will be used. */ - rc=build_sk_list( locusr, &sk_list, 0, PUBKEY_USAGE_CERT); - if( rc ) - goto leave; + /* Build a list of all signators. + * + * We use the CERT flag to request the primary which must always + * be one which is capable of signing keys. I can't see a reason + * why to sign keys using a subkey. Implementation of USAGE_CERT + * is just a hack in getkey.c and does not mean that a subkey + * marked as certification capable will be used. */ + rc = build_sk_list (locusr, &sk_list, 0, PUBKEY_USAGE_CERT); + if (rc) + goto leave; - /* loop over all signators */ - for( sk_rover = sk_list; sk_rover; sk_rover = sk_rover->next ) { - u32 sk_keyid[2],pk_keyid[2]; - char *p,*trust_regexp=NULL; - int force_v4=0,class=0,selfsig=0; - u32 duration=0,timestamp=0; - byte trust_depth=0,trust_value=0; + /* Loop over all signators. */ + for (sk_rover = sk_list; sk_rover; sk_rover = sk_rover->next) + { + u32 sk_keyid[2], pk_keyid[2]; + char *p, *trust_regexp = NULL; + int force_v4 = 0, class = 0, selfsig = 0; + u32 duration = 0, timestamp = 0; + byte trust_depth = 0, trust_value = 0; - if(local || nonrevocable || trust || - opt.cert_policy_url || opt.cert_notations) - force_v4=1; + if (local || nonrevocable || trust || + opt.cert_policy_url || opt.cert_notations) + force_v4 = 1; - /* We have to use a copy of the pk, because make_keysig_packet - * may remove the protection from sk and if we did other - * changes to the secret key, we would save the unprotected - * version. FIXME: This can be removed because all protection - * is now done by gpg-agent. */ - if (pk) - free_public_key (pk); - pk = copy_public_key (NULL, sk_rover->pk); - keyid_from_pk (pk, sk_keyid); + /* We have to use a copy of the pk, because make_keysig_packet + * may remove the protection from sk and if we did other + * changes to the secret key, we would save the unprotected + * version. FIXME: This can be removed because all protection + * is now done by gpg-agent. */ + if (pk) + free_public_key (pk); + pk = copy_public_key (NULL, sk_rover->pk); + keyid_from_pk (pk, sk_keyid); - /* set mark A for all selected user ids */ - for( node=keyblock; node; node = node->next ) { - if( select_all || (node->flag & NODFLG_SELUID) ) - node->flag |= NODFLG_MARK_A; - else - node->flag &= ~NODFLG_MARK_A; + /* Set mark A for all selected user ids. */ + for (node = keyblock; node; node = node->next) + { + if (select_all || (node->flag & NODFLG_SELUID)) + node->flag |= NODFLG_MARK_A; + else + node->flag &= ~NODFLG_MARK_A; } - /* reset mark for uids which are already signed */ - uidnode = NULL; - for( node=keyblock; node; node = node->next ) { - if( node->pkt->pkttype == PKT_PUBLIC_KEY ) { - primary_pk=node->pkt->pkt.public_key; - keyid_from_pk( primary_pk, pk_keyid ); + /* Reset mark for uids which are already signed. */ + uidnode = NULL; + for (node = keyblock; node; node = node->next) + { + if (node->pkt->pkttype == PKT_PUBLIC_KEY) + { + primary_pk = node->pkt->pkt.public_key; + keyid_from_pk (primary_pk, pk_keyid); - /* Is this a self-sig? */ - if(pk_keyid[0]==sk_keyid[0] && pk_keyid[1]==sk_keyid[1]) - { - selfsig=1; - /* Do not force a v4 sig here, otherwise it would - be difficult to remake a v3 selfsig. If this - is a v3->v4 promotion case, then we set - force_v4 later anyway. */ - force_v4=0; - } + /* Is this a self-sig? */ + if (pk_keyid[0] == sk_keyid[0] && pk_keyid[1] == sk_keyid[1]) + { + selfsig = 1; + /* Do not force a v4 sig here, otherwise it would + be difficult to remake a v3 selfsig. If this + is a v3->v4 promotion case, then we set + force_v4 later anyway. */ + force_v4 = 0; + } } - else if( node->pkt->pkttype == PKT_USER_ID ) - { - uidnode = (node->flag & NODFLG_MARK_A)? node : NULL; - if(uidnode) - { - int yesreally=0; - char *user=utf8_to_native(uidnode->pkt->pkt.user_id->name, - uidnode->pkt->pkt.user_id->len, - 0); + else if (node->pkt->pkttype == PKT_USER_ID) + { + uidnode = (node->flag & NODFLG_MARK_A) ? node : NULL; + if (uidnode) + { + int yesreally = 0; + char *user = + utf8_to_native (uidnode->pkt->pkt.user_id->name, + uidnode->pkt->pkt.user_id->len, + 0); - if(uidnode->pkt->pkt.user_id->is_revoked) - { - tty_printf(_("User ID \"%s\" is revoked."),user); + if (uidnode->pkt->pkt.user_id->is_revoked) + { + tty_printf (_("User ID \"%s\" is revoked."), user); - if(selfsig) - tty_printf("\n"); - else if(opt.expert) - { - tty_printf("\n"); - /* No, so remove the mark and continue */ - if(!cpr_get_answer_is_yes("sign_uid.revoke_okay", + if (selfsig) + tty_printf ("\n"); + else if (opt.expert) + { + tty_printf ("\n"); + /* No, so remove the mark and continue */ + if (!cpr_get_answer_is_yes ("sign_uid.revoke_okay", _("Are you sure you " "still want to sign " "it? (y/N) "))) - { - uidnode->flag &= ~NODFLG_MARK_A; - uidnode=NULL; - } - else if(interactive) - yesreally=1; - } - else - { - uidnode->flag &= ~NODFLG_MARK_A; - uidnode=NULL; - tty_printf(_(" Unable to sign.\n")); - } - } - else if(uidnode->pkt->pkt.user_id->is_expired) - { - tty_printf(_("User ID \"%s\" is expired."),user); + { + uidnode->flag &= ~NODFLG_MARK_A; + uidnode = NULL; + } + else if (interactive) + yesreally = 1; + } + else + { + uidnode->flag &= ~NODFLG_MARK_A; + uidnode = NULL; + tty_printf (_(" Unable to sign.\n")); + } + } + else if (uidnode->pkt->pkt.user_id->is_expired) + { + tty_printf (_("User ID \"%s\" is expired."), user); - if(selfsig) - tty_printf("\n"); - else if(opt.expert) - { - tty_printf("\n"); - /* No, so remove the mark and continue */ - if(!cpr_get_answer_is_yes("sign_uid.expire_okay", + if (selfsig) + tty_printf ("\n"); + else if (opt.expert) + { + tty_printf ("\n"); + /* No, so remove the mark and continue */ + if (!cpr_get_answer_is_yes ("sign_uid.expire_okay", _("Are you sure you " "still want to sign " "it? (y/N) "))) - { - uidnode->flag &= ~NODFLG_MARK_A; - uidnode=NULL; - } - else if(interactive) - yesreally=1; - } - else - { - uidnode->flag &= ~NODFLG_MARK_A; - uidnode=NULL; - tty_printf(_(" Unable to sign.\n")); - } - } - else if(!uidnode->pkt->pkt.user_id->created && !selfsig) - { - tty_printf(_("User ID \"%s\" is not self-signed."), - user); + { + uidnode->flag &= ~NODFLG_MARK_A; + uidnode = NULL; + } + else if (interactive) + yesreally = 1; + } + else + { + uidnode->flag &= ~NODFLG_MARK_A; + uidnode = NULL; + tty_printf (_(" Unable to sign.\n")); + } + } + else if (!uidnode->pkt->pkt.user_id->created && !selfsig) + { + tty_printf (_("User ID \"%s\" is not self-signed."), + user); - if(opt.expert) - { - tty_printf("\n"); - /* No, so remove the mark and continue */ - if(!cpr_get_answer_is_yes("sign_uid.nosig_okay", + if (opt.expert) + { + tty_printf ("\n"); + /* No, so remove the mark and continue */ + if (!cpr_get_answer_is_yes ("sign_uid.nosig_okay", _("Are you sure you " "still want to sign " "it? (y/N) "))) - { - uidnode->flag &= ~NODFLG_MARK_A; - uidnode=NULL; - } - else if(interactive) - yesreally=1; - } - else - { - uidnode->flag &= ~NODFLG_MARK_A; - uidnode=NULL; - tty_printf(_(" Unable to sign.\n")); - } - } + { + uidnode->flag &= ~NODFLG_MARK_A; + uidnode = NULL; + } + else if (interactive) + yesreally = 1; + } + else + { + uidnode->flag &= ~NODFLG_MARK_A; + uidnode = NULL; + tty_printf (_(" Unable to sign.\n")); + } + } - if(uidnode && interactive && !yesreally) - { - tty_printf(_("User ID \"%s\" is signable. "),user); - if(!cpr_get_answer_is_yes("sign_uid.sign_okay", + if (uidnode && interactive && !yesreally) + { + tty_printf (_("User ID \"%s\" is signable. "), user); + if (!cpr_get_answer_is_yes ("sign_uid.sign_okay", _("Sign it? (y/N) "))) - { - uidnode->flag &= ~NODFLG_MARK_A; - uidnode=NULL; - } - } + { + uidnode->flag &= ~NODFLG_MARK_A; + uidnode = NULL; + } + } - xfree(user); - } - } - else if( uidnode && node->pkt->pkttype == PKT_SIGNATURE - && (node->pkt->pkt.signature->sig_class&~3) == 0x10 ) { - if( sk_keyid[0] == node->pkt->pkt.signature->keyid[0] - && sk_keyid[1] == node->pkt->pkt.signature->keyid[1] ) { - char buf[50]; - char *user=utf8_to_native(uidnode->pkt->pkt.user_id->name, - uidnode->pkt->pkt.user_id->len, - 0); + xfree (user); + } + } + else if (uidnode && node->pkt->pkttype == PKT_SIGNATURE + && (node->pkt->pkt.signature->sig_class & ~3) == 0x10) + { + if (sk_keyid[0] == node->pkt->pkt.signature->keyid[0] + && sk_keyid[1] == node->pkt->pkt.signature->keyid[1]) + { + char buf[50]; + char *user = + utf8_to_native (uidnode->pkt->pkt.user_id->name, + uidnode->pkt->pkt.user_id->len, + 0); - /* It's a v3 self-sig. Make it into a v4 self-sig? */ - if(node->pkt->pkt.signature->version<4 && selfsig) - { - tty_printf(_("The self-signature on \"%s\"\n" - "is a PGP 2.x-style signature.\n"),user); - - /* Note that the regular PGP2 warning below - still applies if there are no v4 sigs on - this key at all. */ + /* It's a v3 self-sig. Make it into a v4 self-sig? */ + if (node->pkt->pkt.signature->version < 4 && selfsig) + { + tty_printf (_("The self-signature on \"%s\"\n" + "is a PGP 2.x-style signature.\n"), user); - if(opt.expert) - if(cpr_get_answer_is_yes("sign_uid.v4_promote_okay", + /* Note that the regular PGP2 warning below + still applies if there are no v4 sigs on + this key at all. */ + + if (opt.expert) + if (cpr_get_answer_is_yes ("sign_uid.v4_promote_okay", _("Do you want to promote " "it to an OpenPGP self-" "signature? (y/N) "))) - { - force_v4=1; - node->flag|=NODFLG_DELSIG; - xfree(user); - continue; - } - } - - /* Is the current signature expired? */ - if(node->pkt->pkt.signature->flags.expired) - { - tty_printf(_("Your current signature on \"%s\"\n" - "has expired.\n"),user); - - if(cpr_get_answer_is_yes("sign_uid.replace_expired_okay", - _("Do you want to issue a " - "new signature to replace " - "the expired one? (y/N) "))) { - /* Mark these for later deletion. We - don't want to delete them here, just in - case the replacement signature doesn't - happen for some reason. We only delete - these after the replacement is already - in place. */ - - node->flag|=NODFLG_DELSIG; - xfree(user); + force_v4 = 1; + node->flag |= NODFLG_DELSIG; + xfree (user); continue; } - } + } - if(!node->pkt->pkt.signature->flags.exportable && !local) - { - /* It's a local sig, and we want to make a - exportable sig. */ - tty_printf(_("Your current signature on \"%s\"\n" - "is a local signature.\n"),user); + /* Is the current signature expired? */ + if (node->pkt->pkt.signature->flags.expired) + { + tty_printf (_("Your current signature on \"%s\"\n" + "has expired.\n"), user); - if(cpr_get_answer_is_yes("sign_uid.local_promote_okay", - _("Do you want to promote " - "it to a full exportable " - "signature? (y/N) "))) - { - /* Mark these for later deletion. We - don't want to delete them here, just in - case the replacement signature doesn't - happen for some reason. We only delete - these after the replacement is already - in place. */ + if (cpr_get_answer_is_yes + ("sign_uid.replace_expired_okay", + _("Do you want to issue a " + "new signature to replace " + "the expired one? (y/N) "))) + { + /* Mark these for later deletion. We + don't want to delete them here, just in + case the replacement signature doesn't + happen for some reason. We only delete + these after the replacement is already + in place. */ - node->flag|=NODFLG_DELSIG; - xfree(user); - continue; - } - } + node->flag |= NODFLG_DELSIG; + xfree (user); + continue; + } + } - /* Fixme: see whether there is a revocation in which - * case we should allow to sign it again. */ - if (!node->pkt->pkt.signature->flags.exportable && local) - tty_printf(_( - "\"%s\" was already locally signed by key %s\n"), - user,keystr_from_pk (pk)); - else - tty_printf(_("\"%s\" was already signed by key %s\n"), - user,keystr_from_pk (pk)); + if (!node->pkt->pkt.signature->flags.exportable && !local) + { + /* It's a local sig, and we want to make a + exportable sig. */ + tty_printf (_("Your current signature on \"%s\"\n" + "is a local signature.\n"), user); - if(opt.expert - && cpr_get_answer_is_yes("sign_uid.dupe_okay", + if (cpr_get_answer_is_yes + ("sign_uid.local_promote_okay", + _("Do you want to promote " + "it to a full exportable " "signature? (y/N) "))) + { + /* Mark these for later deletion. We + don't want to delete them here, just in + case the replacement signature doesn't + happen for some reason. We only delete + these after the replacement is already + in place. */ + + node->flag |= NODFLG_DELSIG; + xfree (user); + continue; + } + } + + /* Fixme: see whether there is a revocation in which + * case we should allow to sign it again. */ + if (!node->pkt->pkt.signature->flags.exportable && local) + tty_printf (_ + ("\"%s\" was already locally signed by key %s\n"), + user, keystr_from_pk (pk)); + else + tty_printf (_("\"%s\" was already signed by key %s\n"), + user, keystr_from_pk (pk)); + + if (opt.expert + && cpr_get_answer_is_yes ("sign_uid.dupe_okay", _("Do you want to sign it " "again anyway? (y/N) "))) - { - /* Don't delete the old sig here since this is - an --expert thing. */ - xfree(user); - continue; - } + { + /* Don't delete the old sig here since this is + an --expert thing. */ + xfree (user); + continue; + } - snprintf (buf, sizeof buf, "%08lX%08lX", - (ulong)pk->keyid[0], (ulong)pk->keyid[1]); - write_status_text (STATUS_ALREADY_SIGNED, buf); - uidnode->flag &= ~NODFLG_MARK_A; /* remove mark */ + snprintf (buf, sizeof buf, "%08lX%08lX", + (ulong) pk->keyid[0], (ulong) pk->keyid[1]); + write_status_text (STATUS_ALREADY_SIGNED, buf); + uidnode->flag &= ~NODFLG_MARK_A; /* remove mark */ - xfree(user); + xfree (user); } } } - /* check whether any uids are left for signing */ - if( !count_uids_with_flag(keyblock, NODFLG_MARK_A) ) - { - tty_printf (_("Nothing to sign with key %s\n"), keystr_from_pk (pk)); - continue; - } + /* Check whether any uids are left for signing. */ + if (!count_uids_with_flag (keyblock, NODFLG_MARK_A)) + { + tty_printf (_("Nothing to sign with key %s\n"), + keystr_from_pk (pk)); + continue; + } - /* Ask whether we really should sign these user id(s) */ - tty_printf("\n"); - show_key_with_all_names( keyblock, 1, 0, 1, 0, 0 ); - tty_printf("\n"); + /* Ask whether we really should sign these user id(s). */ + tty_printf ("\n"); + show_key_with_all_names (keyblock, 1, 0, 1, 0, 0); + tty_printf ("\n"); - if(primary_pk->expiredate && !selfsig) - { - u32 now=make_timestamp(); + if (primary_pk->expiredate && !selfsig) + { + u32 now = make_timestamp (); - if(primary_pk->expiredate<=now) - { - tty_printf(_("This key has expired!")); + if (primary_pk->expiredate <= now) + { + tty_printf (_("This key has expired!")); - if(opt.expert) - { - tty_printf(" "); - if(!cpr_get_answer_is_yes("sign_uid.expired_okay", + if (opt.expert) + { + tty_printf (" "); + if (!cpr_get_answer_is_yes ("sign_uid.expired_okay", _("Are you sure you still " "want to sign it? (y/N) "))) - continue; - } - else - { - tty_printf(_(" Unable to sign.\n")); continue; - } - } - else - { - tty_printf(_("This key is due to expire on %s.\n"), - expirestr_from_pk(primary_pk)); + } + else + { + tty_printf (_(" Unable to sign.\n")); + continue; + } + } + else + { + tty_printf (_("This key is due to expire on %s.\n"), + expirestr_from_pk (primary_pk)); - if(opt.ask_cert_expire) - { - char *answer=cpr_get("sign_uid.expire", - _("Do you want your signature to " - "expire at the same time? (Y/n) ")); - if(answer_is_yes_no_default(answer,1)) - { - /* This fixes the signature timestamp we're - going to make as now. This is so the - expiration date is exactly correct, and not - a few seconds off (due to the time it takes - to answer the questions, enter the - passphrase, etc). */ - timestamp=now; - duration=primary_pk->expiredate-now; - force_v4=1; - } + if (opt.ask_cert_expire) + { + char *answer = cpr_get ("sign_uid.expire", + _("Do you want your signature to " + "expire at the same time? (Y/n) ")); + if (answer_is_yes_no_default (answer, 1)) + { + /* This fixes the signature timestamp we're + going to make as now. This is so the + expiration date is exactly correct, and not + a few seconds off (due to the time it takes + to answer the questions, enter the + passphrase, etc). */ + timestamp = now; + duration = primary_pk->expiredate - now; + force_v4 = 1; + } - cpr_kill_prompt(); - xfree(answer); - } - } - } + cpr_kill_prompt (); + xfree (answer); + } + } + } - /* Only ask for duration if we haven't already set it to match - the expiration of the pk */ - if(!duration && !selfsig) - { - if(opt.ask_cert_expire) - duration=ask_expire_interval(1,opt.def_cert_expire); - else - duration=parse_expire_string(opt.def_cert_expire); - } + /* Only ask for duration if we haven't already set it to match + the expiration of the pk */ + if (!duration && !selfsig) + { + if (opt.ask_cert_expire) + duration = ask_expire_interval (1, opt.def_cert_expire); + else + duration = parse_expire_string (opt.def_cert_expire); + } - if(duration) - force_v4=1; + if (duration) + force_v4 = 1; - /* Is --pgp2 on, it's a v3 key, all the sigs on the key are - currently v3 and we're about to sign it with a v4 sig? If - so, danger! */ - if(PGP2 && all_v3 && - (pk->version > 3 || force_v4) && primary_pk->version <= 3) - { - tty_printf(_("You may not make an OpenPGP signature on a " - "PGP 2.x key while in --pgp2 mode.\n")); - tty_printf(_("This would make the key unusable in PGP 2.x.\n")); + /* Is --pgp2 on, it's a v3 key, all the sigs on the key are + currently v3 and we're about to sign it with a v4 sig? If + so, danger! */ + if (PGP2 && all_v3 && + (pk->version > 3 || force_v4) && primary_pk->version <= 3) From cvs at cvs.gnupg.org Wed Apr 21 04:57:17 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Wed, 21 Apr 2010 04:57:17 +0200 Subject: [svn] GpgEX - r81 - trunk Message-ID: Author: marcus Date: 2010-04-21 04:57:17 +0200 (Wed, 21 Apr 2010) New Revision: 81 Modified: trunk/ChangeLog trunk/NEWS Log: 2010-04-21 Marcus Brinkmann Release 0.9.6. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-04-20 16:23:46 UTC (rev 80) +++ trunk/ChangeLog 2010-04-21 02:57:17 UTC (rev 81) @@ -1,3 +1,7 @@ +2010-04-21 Marcus Brinkmann + + Release 0.9.6. + 2010-04-20 Marcus Brinkmann * configure.ac: Bump version to 0.9.6. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2010-04-20 16:23:46 UTC (rev 80) +++ trunk/NEWS 2010-04-21 02:57:17 UTC (rev 81) @@ -1,3 +1,13 @@ +Noteworthy changes for version 0.9.6 (2010-04-21) +------------------------------------------------- + +* Update to libassuan 2.0.0. + +* Improve German translation. + +* Fix default menu item. + + Noteworthy changes for version 0.9.5 (2010-01-08) ------------------------------------------------- From cvs at cvs.gnupg.org Wed Apr 21 05:04:20 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Wed, 21 Apr 2010 05:04:20 +0200 Subject: [svn] GpgEX - r82 - tags Message-ID: Author: marcus Date: 2010-04-21 05:04:20 +0200 (Wed, 21 Apr 2010) New Revision: 82 Added: tags/gpgex-0.9.6/ Log: Tag release. From cvs at cvs.gnupg.org Wed Apr 21 05:04:44 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Wed, 21 Apr 2010 05:04:44 +0200 Subject: [svn] GpgEX - r83 - trunk Message-ID: Author: marcus Date: 2010-04-21 05:04:44 +0200 (Wed, 21 Apr 2010) New Revision: 83 Modified: trunk/configure.ac Log: Post release. Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2010-04-21 03:04:20 UTC (rev 82) +++ trunk/configure.ac 2010-04-21 03:04:44 UTC (rev 83) @@ -16,8 +16,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], [0.9.6]) -m4_define([my_issvn], [no]) +m4_define([my_version], [0.9.7]) +m4_define([my_issvn], [yes]) m4_define([svn_revision], m4_esyscmd([echo -n $( (svn info 2>/dev/null \ || echo 'Revision: 0')|sed -n '/^Revision:/ {s/[^0-9]//gp;q;}')])) From cvs at cvs.gnupg.org Wed Apr 21 05:23:37 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Wed, 21 Apr 2010 05:23:37 +0200 Subject: [svn] GpgOL - r334 - in trunk: . src Message-ID: Author: marcus Date: 2010-04-21 05:23:36 +0200 (Wed, 21 Apr 2010) New Revision: 334 Modified: trunk/ChangeLog trunk/configure.ac trunk/src/ChangeLog trunk/src/engine-assuan.c Log: 2010-04-21 Marcus Brinkmann * configure.ac (NEED_LIBASSUAN_API, NEED_LIBASSUAN_VERSION): Bump to 2/2.0.0. (_ASSUAN_ONLY_GPG_ERRORS): Remove. src/ 2010-04-21 Marcus Brinkmann * engine-assuan.c (connect_uiserver): Update to new libassuan interface. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-01-13 11:33:39 UTC (rev 333) +++ trunk/ChangeLog 2010-04-21 03:23:36 UTC (rev 334) @@ -1,3 +1,9 @@ +2010-04-21 Marcus Brinkmann + + * configure.ac (NEED_LIBASSUAN_API, NEED_LIBASSUAN_VERSION): Bump + to 2/2.0.0. + (_ASSUAN_ONLY_GPG_ERRORS): Remove. + 2010-01-13 Werner Koch Release 1.1.1. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-01-13 11:33:39 UTC (rev 333) +++ trunk/src/ChangeLog 2010-04-21 03:23:36 UTC (rev 334) @@ -1,3 +1,8 @@ +2010-04-21 Marcus Brinkmann + + * engine-assuan.c (connect_uiserver): Update to new libassuan + interface. + 2010-01-13 Werner Koch * README.icons: Change instructions to better cope with alpha Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2010-01-13 11:33:39 UTC (rev 333) +++ trunk/configure.ac 2010-04-21 03:23:36 UTC (rev 334) @@ -16,8 +16,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.1.1]) -m4_define([my_issvn], [no]) +m4_define([my_version], [1.1.2]) +m4_define([my_issvn], [yes]) m4_define([svn_revision], m4_esyscmd([echo -n $( (svn info 2>/dev/null \ || echo 'Revision: 0')|sed -n '/^Revision:/ {s/[^0-9]//gp;q;}')])) @@ -28,8 +28,8 @@ NEED_GPG_ERROR_VERSION=1.4 NEED_GPGME_API=1 NEED_GPGME_VERSION=1.1.0 -NEED_LIBASSUAN_API=1 -NEED_LIBASSUAN_VERSION=1.0.4 +NEED_LIBASSUAN_API=2 +NEED_LIBASSUAN_VERSION=2.0.0 SVN_REVISION=svn_revision @@ -156,13 +156,7 @@ AM_PATH_LIBASSUAN("$NEED_LIBASSUAN_API:$NEED_LIBASSUAN_VERSION", have_libassuan=yes,have_libassuan=no) -AH_BOTTOM([ -/* We don't want the old assuan codes anymore. */ -#define _ASSUAN_ONLY_GPG_ERRORS 1 -]) - - # Note, that autogen.sh greps for the next line. AM_GNU_GETTEXT_VERSION(0.12.1) AM_GNU_GETTEXT([external]) Modified: trunk/src/engine-assuan.c =================================================================== --- trunk/src/engine-assuan.c 2010-01-13 11:33:39 UTC (rev 333) +++ trunk/src/engine-assuan.c 2010-04-21 03:23:36 UTC (rev 334) @@ -1,5 +1,5 @@ /* engine-assuan.c - Crypto engine using an Assuan server - * Copyright (C) 2007, 2008, 2009 g10 Code GmbH + * Copyright (C) 2007, 2008, 2009, 2010 g10 Code GmbH * * This file is part of GpgOL. * @@ -463,8 +463,15 @@ *r_ctx = NULL; *r_pid = (pid_t)(-1); *r_cmdid = 0; + err = assuan_new (&ctx); + if (err) + { + InterlockedExchange (&retry_counter, 0); + return 0; + } + retry: - err = assuan_socket_connect (&ctx, get_socket_name (), -1); + err = assuan_socket_connect (ctx, get_socket_name (), -1, 0); if (err) { /* Let only one thread start an UI server but all allow threads @@ -519,7 +526,7 @@ } else if ((err = send_options (ctx, hwnd, r_pid))) { - assuan_disconnect (ctx); + assuan_release (ctx); } else { @@ -583,7 +590,7 @@ if (!err) { err = assuan_transact (ctx, "NOP", NULL, NULL, NULL, NULL, NULL, NULL); - assuan_disconnect (ctx); + assuan_release (ctx); } if (err) return err; @@ -1729,7 +1736,7 @@ close_pipe (inpipe); close_pipe (outpipe); xfree (cld); - assuan_disconnect (ctx); + assuan_release (ctx); } else engine_private_set_cancel (filter, ctx); @@ -1767,7 +1774,7 @@ close_pipe (encstate->outpipe); if (cancel) destroy_command (encstate->cmdid, 1); - assuan_disconnect (encstate->ctx); + assuan_release (encstate->ctx); encstate->ctx = NULL; } else @@ -1897,7 +1904,7 @@ close_pipe (inpipe); close_pipe (outpipe); xfree (cld); - assuan_disconnect (ctx); + assuan_release (ctx); } else engine_private_set_cancel (filter, ctx); @@ -1995,7 +2002,7 @@ close_pipe (inpipe); close_pipe (outpipe); xfree (cld); - assuan_disconnect (ctx); + assuan_release (ctx); } else engine_private_set_cancel (filter, ctx); @@ -2152,7 +2159,7 @@ close_pipe (outpipe); gpgme_data_release (sigdata); xfree (cld); - assuan_disconnect (ctx); + assuan_release (ctx); } else engine_private_set_cancel (filter, ctx); @@ -2175,7 +2182,7 @@ { err = assuan_transact (ctx, "START_KEYMANAGER", NULL, NULL, NULL, NULL, NULL, NULL); - assuan_disconnect (ctx); + assuan_release (ctx); } return err; } @@ -2196,7 +2203,7 @@ { err = assuan_transact (ctx, "START_CONFDIALOG", NULL, NULL, NULL, NULL, NULL, NULL); - assuan_disconnect (ctx); + assuan_release (ctx); } return err; } From cvs at cvs.gnupg.org Wed Apr 21 11:56:44 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 21 Apr 2010 11:56:44 +0200 Subject: [svn] GnuPG - r5314 - trunk Message-ID: Author: wk Date: 2010-04-21 11:56:43 +0200 (Wed, 21 Apr 2010) New Revision: 5314 Modified: trunk/configure.ac Log: Disable card support for now Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2010-04-20 18:19:19 UTC (rev 5313) +++ trunk/configure.ac 2010-04-21 09:56:43 UTC (rev 5314) @@ -454,7 +454,7 @@ #define HTTP_NO_WSASTARTUP /* We always include support for the OpenPGP card. */ -#define ENABLE_CARD_SUPPORT 1 +/* Disabled for now ENABLE_CARD_SUPPORT 1 */ /* We explicitly need to disable PTH's soft mapping as Debian currently enables it by default for no reason. */ From cvs at cvs.gnupg.org Wed Apr 21 18:26:19 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 21 Apr 2010 18:26:19 +0200 Subject: [svn] GnuPG - r5315 - in trunk: agent common doc g10 kbx po tools Message-ID: Author: wk Date: 2010-04-21 18:26:17 +0200 (Wed, 21 Apr 2010) New Revision: 5315 Modified: trunk/agent/ChangeLog trunk/agent/agent.h trunk/agent/command.c trunk/agent/findkey.c trunk/agent/pksign.c trunk/common/ChangeLog trunk/common/estream.c trunk/doc/DETAILS trunk/g10/ChangeLog trunk/g10/call-agent.c trunk/g10/call-agent.h trunk/g10/delkey.c trunk/g10/export.c trunk/g10/getkey.c trunk/g10/gpgv.c trunk/g10/import.c trunk/g10/keydb.c trunk/g10/keydb.h trunk/g10/keyedit.c trunk/g10/keygen.c trunk/g10/keylist.c trunk/g10/keyserver.c trunk/g10/mainproc.c trunk/g10/pkclist.c trunk/g10/revoke.c trunk/g10/sign.c trunk/g10/trustdb.c trunk/kbx/ChangeLog trunk/kbx/keybox-blob.c trunk/po/POTFILES.in trunk/tools/Makefile.am Log: More changes on the way to remove secring.gpg. [The diff below has been truncated] Modified: trunk/agent/ChangeLog =================================================================== --- trunk/agent/ChangeLog 2010-04-21 09:56:43 UTC (rev 5314) +++ trunk/agent/ChangeLog 2010-04-21 16:26:17 UTC (rev 5315) @@ -1,3 +1,13 @@ +2010-04-19 Werner Koch + + * pksign.c (get_dsa_qbits, do_encode_dsa): New. + (agent_pksign_do): Detect DSA keys and use do_encode_dsa. + * findkey.c (agent_public_key_from_file): Factor some code out to .. + (key_parms_from_sexp): New. + (agent_is_dsa_key): New. + + * command.c (cmd_sethash): Clear digeest.RAW_VALUE. + 2010-04-14 Werner Koch * Makefile.am (libexec_PROGRAMS) [W32CE]: Do not build Modified: trunk/common/ChangeLog =================================================================== --- trunk/common/ChangeLog 2010-04-21 09:56:43 UTC (rev 5314) +++ trunk/common/ChangeLog 2010-04-21 16:26:17 UTC (rev 5315) @@ -1,5 +1,8 @@ 2010-04-20 Werner Koch + * estream.c (es_deinit): New. + (es_init_do): Intll atexit handler to flush all streams. + * Makefile.am (common_sources): Add gettime.h. 2010-04-20 Marcus Brinkmann @@ -16,7 +19,7 @@ 2010-04-15 Werner Koch - * util.h: Factor time related fucntions out to ... + * util.h: Factor time related functions out to ... * gettime.h: New. (gnupg_copy_time): Move to ... * gettime.c (gnupg_copy_time): New. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2010-04-21 09:56:43 UTC (rev 5314) +++ trunk/g10/ChangeLog 2010-04-21 16:26:17 UTC (rev 5315) @@ -1,3 +1,37 @@ +2010-04-21 Werner Koch + + * pkclist.c (default_recipient): Change to use public keys. + + * keydb.c (keydb_new): Remove arg SECRET. Change all callers. + + * getkey.c (get_seckey): Change to take a public key. + (have_secret_key): Rename to have_any_secret_key and make use of + the agent. + (key_byname): Rmemove unused arg SK. + (get_seckey_byname2): Remove and move code to + (get_seckey_byname): .. here. Remove INLOCK arg. + (get_seckey_bynames): Remove. + (get_seckey_next): Remove. + (get_seckey_end): Remove. Use get_pubkey_end instead. + (get_seckey_byfprint, get_seckeyblock_byfprint): Change to use + public keys. + (seckey_available): Rename to .. + (have_secret_key_with_kid): .. this and change to employ the + agent. Change all callers. + (sk_from_block): Remove. + + * call-agent.c (agent_probe_secret_key): New. + (agent_havekey): Remove. + * gpgv.c (agent_probe_secret_key): New. + + * keyedit.c (keyedit_menu) + (sign_uids, menu_adduid, menu_deluid, menu_delkey) + (menu_addrevoker, menu_expire, menu_backsign) + (menu_set_primary_uid, menu_set_preferences) + (menu_set_keyserver_url, menu_set_notation, menu_revsig) + (menu_revuid, menu_revkey, menu_revsubkey): Remove all code to + manage the secret keyring. + 2010-04-20 Werner Koch * keylist.c (list_keyblock_colon): Print the keygrip. @@ -6,6 +40,7 @@ (mpi_from_sexp): New. * keyid.c (keygrip_from_pk, hexkeygrip_from_pk): New. * call-agent.c (agent_pksign): New. + * pkglue.c (pk_sign): Remove. * keygen.c (generate_keypair): Do not ask for a passphrase. Modified: trunk/kbx/ChangeLog =================================================================== --- trunk/kbx/ChangeLog 2010-04-21 09:56:43 UTC (rev 5314) +++ trunk/kbx/ChangeLog 2010-04-21 16:26:17 UTC (rev 5315) @@ -4,6 +4,11 @@ ../common/sysutils.h even then to silence gcc warning about missing declaration of gnupg_remove. +2010-04-15 Werner Koch + + * keybox-blob.c: Include gettime.h + (make_timestamp): Remove. + 2010-03-23 Werner Koch * Makefile.am (extra_libs): New. Modified: trunk/agent/agent.h =================================================================== --- trunk/agent/agent.h 2010-04-21 09:56:43 UTC (rev 5314) +++ trunk/agent/agent.h 2010-04-21 16:26:17 UTC (rev 5315) @@ -232,6 +232,7 @@ gpg_error_t agent_public_key_from_file (ctrl_t ctrl, const unsigned char *grip, gcry_sexp_t *result); +int agent_is_dsa_key (gcry_sexp_t s_key); int agent_key_available (const unsigned char *grip); gpg_error_t agent_key_info_from_file (ctrl_t ctrl, const unsigned char *grip, int *r_keytype, Modified: trunk/agent/command.c =================================================================== --- trunk/agent/command.c 2010-04-21 09:56:43 UTC (rev 5314) +++ trunk/agent/command.c 2010-04-21 16:26:17 UTC (rev 5315) @@ -589,7 +589,7 @@ static const char hlp_sethash[] = - "SETHASH --hash=| \n" + "SETHASH (--hash=)|() \n" "\n" "The client can use this command to tell the server about the data\n" "(which usually is a hash) to be signed."; @@ -642,6 +642,7 @@ return set_error (GPG_ERR_UNSUPPORTED_ALGORITHM, NULL); } ctrl->digest.algo = algo; + ctrl->digest.raw_value = 0; /* Parse the hash value. */ n = 0; @@ -848,7 +849,7 @@ "\n" "TYPE is describes the type of the key:\n" " 'D' - Regular key stored on disk,\n" - " 'T' - Key is stored on a smartcard (token).\n" + " 'T' - Key is stored on a smartcard (token),\n" " '-' - Unknown type.\n" "\n" "SERIALNO is an ASCII string with the serial number of the\n" Modified: trunk/agent/findkey.c =================================================================== --- trunk/agent/findkey.c 2010-04-21 09:56:43 UTC (rev 5314) +++ trunk/agent/findkey.c 2010-04-21 16:26:17 UTC (rev 5315) @@ -1,6 +1,6 @@ /* findkey.c - Locate the secret key - * Copyright (C) 2001, 2002, 2003, 2004, 2005, - * 2007 Free Software Foundation, Inc. + * Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, + * 2010 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -626,50 +626,32 @@ } - -/* Return the public key for the keygrip GRIP. The result is stored - at RESULT. This function extracts the public key from the private - key database. On failure an error code is returned and NULL stored - at RESULT. */ -gpg_error_t -agent_public_key_from_file (ctrl_t ctrl, - const unsigned char *grip, - gcry_sexp_t *result) +/* Return the string name from the S-expression S_KEY as well as a + string describing the names of the parameters. ALGONAMESIZE and + ELEMSSIZE give the allocated size of the provided buffers. The + buffers may be NULL if not required. If R_LIST is not NULL the top + level list will be stored tehre; the caller needs to release it in + this case. */ +static gpg_error_t +key_parms_from_sexp (gcry_sexp_t s_key, gcry_sexp_t *r_list, + char *r_algoname, size_t algonamesize, + char *r_elems, size_t elemssize) { - int i, idx, rc; - gcry_sexp_t s_skey; - const char *algoname; - gcry_sexp_t uri_sexp, comment_sexp; - const char *uri, *comment; - size_t uri_length, comment_length; - char *format, *p; - void *args[4+2+2+1]; /* Size is max. # of elements + 2 for uri + 2 - for comment + end-of-list. */ - int argidx; gcry_sexp_t list, l2; - const char *name; - const char *s; + const char *name, *algoname, *elems; size_t n; - const char *elems; - gcry_mpi_t *array; - (void)ctrl; + if (r_list) + *r_list = NULL; - *result = NULL; - - rc = read_key_file (grip, &s_skey); - if (rc) - return rc; - - list = gcry_sexp_find_token (s_skey, "shadowed-private-key", 0 ); + list = gcry_sexp_find_token (s_key, "shadowed-private-key", 0 ); if (!list) - list = gcry_sexp_find_token (s_skey, "protected-private-key", 0 ); + list = gcry_sexp_find_token (s_key, "protected-private-key", 0 ); if (!list) - list = gcry_sexp_find_token (s_skey, "private-key", 0 ); + list = gcry_sexp_find_token (s_key, "private-key", 0 ); if (!list) { log_error ("invalid private key format\n"); - gcry_sexp_release (s_skey); return gpg_error (GPG_ERR_BAD_SECKEY); } @@ -696,19 +678,99 @@ { log_error ("unknown private key algorithm\n"); gcry_sexp_release (list); - gcry_sexp_release (s_skey); return gpg_error (GPG_ERR_BAD_SECKEY); } + if (r_algoname) + { + if (strlen (algoname) >= algonamesize) + return gpg_error (GPG_ERR_BUFFER_TOO_SHORT); + strcpy (r_algoname, algoname); + } + if (r_elems) + { + if (strlen (elems) >= elemssize) + return gpg_error (GPG_ERR_BUFFER_TOO_SHORT); + strcpy (r_elems, elems); + } + + if (r_list) + *r_list = list; + else + gcry_sexp_release (list); + + return 0; +} + + +/* Return true if S_KEY is a DSA style key. */ +int +agent_is_dsa_key (gcry_sexp_t s_key) +{ + char algoname[6]; + + if (!s_key) + return 0; + + if (key_parms_from_sexp (s_key, NULL, algoname, sizeof algoname, NULL, 0)) + return 0; /* Error - assume it is not an DSA key. */ + + return (!strcmp (algoname, "dsa") || !strcmp (algoname, "ecdsa")); +} + + + +/* Return the public key for the keygrip GRIP. The result is stored + at RESULT. This function extracts the public key from the private + key database. On failure an error code is returned and NULL stored + at RESULT. */ +gpg_error_t +agent_public_key_from_file (ctrl_t ctrl, + const unsigned char *grip, + gcry_sexp_t *result) +{ + gpg_error_t err; + int i, idx; + gcry_sexp_t s_skey; + char algoname[6]; + char elems[6]; + gcry_sexp_t uri_sexp, comment_sexp; + const char *uri, *comment; + size_t uri_length, comment_length; + char *format, *p; + void *args[4+2+2+1]; /* Size is max. # of elements + 2 for uri + 2 + for comment + end-of-list. */ + int argidx; + gcry_sexp_t list, l2; + const char *s; + gcry_mpi_t *array; + + (void)ctrl; + + *result = NULL; + + err = read_key_file (grip, &s_skey); + if (err) + return err; + + err = key_parms_from_sexp (s_skey, &list, + algoname, sizeof algoname, + elems, sizeof elems); + if (err) + { + gcry_sexp_release (s_skey); + return err; + } + /* Allocate an array for the parameters and copy them out of the secret key. FIXME: We should have a generic copy function. */ array = xtrycalloc (strlen(elems) + 1, sizeof *array); if (!array) { - rc = gpg_error_from_syserror (); + err = gpg_error_from_syserror (); gcry_sexp_release (list); gcry_sexp_release (s_skey); - return rc; + return err; } for (idx=0, s=elems; *s; s++, idx++ ) @@ -757,8 +819,8 @@ /* FIXME: The following thing is pretty ugly code; we should - investigate how to make it cleaner. Probably code to handle - canonical S-expressions in a memory buffer is better suioted for + investigate how to make it cleaner. Probably code to handle + canonical S-expressions in a memory buffer is better suited for such a task. After all that is what we do in protect.c. Neeed to find common patterns and write a straightformward API to use them. */ @@ -767,13 +829,13 @@ format = xtrymalloc (15+7*strlen (elems)+10+15+1+1); if (!format) { - rc = gpg_error_from_syserror (); + err = gpg_error_from_syserror (); for (i=0; array[i]; i++) gcry_mpi_release (array[i]); xfree (array); gcry_sexp_release (uri_sexp); gcry_sexp_release (comment_sexp); - return rc; + return err; } argidx = 0; @@ -806,7 +868,7 @@ assert (argidx < DIM (args)); args[argidx] = NULL; - rc = gcry_sexp_build_array (&list, NULL, format, args); + err = gcry_sexp_build_array (&list, NULL, format, args); xfree (format); for (i=0; array[i]; i++) gcry_mpi_release (array[i]); @@ -814,9 +876,9 @@ gcry_sexp_release (uri_sexp); gcry_sexp_release (comment_sexp); - if (!rc) + if (!err) *result = list; - return rc; + return err; } Modified: trunk/agent/pksign.c =================================================================== --- trunk/agent/pksign.c 2010-04-21 09:56:43 UTC (rev 5314) +++ trunk/agent/pksign.c 2010-04-21 16:26:17 UTC (rev 5315) @@ -1,5 +1,5 @@ /* pksign.c - public key signing (well, actually using a secret key) - * Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + * Copyright (C) 2001, 2002, 2003, 2004, 2010 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -28,6 +28,7 @@ #include #include "agent.h" +#include "i18n.h" static int @@ -75,6 +76,104 @@ } +/* Return the number of bits of the Q parameter from the DSA key + KEY. */ +static unsigned int +get_dsa_qbits (gcry_sexp_t key) +{ + gcry_sexp_t l1, l2; + gcry_mpi_t q; + unsigned int nbits; + + l1 = gcry_sexp_find_token (key, "private-key", 0); + if (!l1) + l1 = gcry_sexp_find_token (key, "protected-private-key", 0); + if (!l1) + l1 = gcry_sexp_find_token (key, "shadowed-private-key", 0); + if (!l1) + l1 = gcry_sexp_find_token (key, "public-key", 0); + if (!l1) + return 0; /* Does not contain a key object. */ + l2 = gcry_sexp_cadr (l1); + gcry_sexp_release (l1); + l1 = gcry_sexp_find_token (l2, "q", 1); + gcry_sexp_release (l2); + if (!l1) + return 0; /* Invalid object. */ + q = gcry_sexp_nth_mpi (l1, 1, GCRYMPI_FMT_USG); + gcry_sexp_release (l1); + if (!q) + return 0; /* Missing value. */ + nbits = gcry_mpi_get_nbits (q); + gcry_mpi_release (q); + + return nbits; +} + + +/* Encode a message digest for use with an DSA algorithm. */ +static gpg_error_t +do_encode_dsa (const byte * md, size_t mdlen, int dsaalgo, gcry_sexp_t pkey, + gcry_sexp_t *r_hash) +{ + gpg_error_t err; + gcry_sexp_t hash; + unsigned int qbits; + + *r_hash = NULL; + + if (dsaalgo == GCRY_PK_ECDSA) + qbits = gcry_pk_get_nbits (pkey); + else if (dsaalgo == GCRY_PK_DSA) + qbits = get_dsa_qbits (pkey); + else + return gpg_error (GPG_ERR_WRONG_PUBKEY_ALGO); + + if ((qbits%8)) + { + log_error (_("DSA requires the hash length to be a" + " multiple of 8 bits\n")); + return gpg_error (GPG_ERR_INV_LENGTH); + } + + /* Don't allow any Q smaller than 160 bits. We don't want someone + to issue signatures from a key with a 16-bit Q or something like + that, which would look correct but allow trivial forgeries. Yes, + I know this rules out using MD5 with DSA. ;) */ + if (qbits < 160) + { + log_error (_("%s key uses an unsafe (%u bit) hash\n"), + gcry_pk_algo_name (dsaalgo), qbits); + return gpg_error (GPG_ERR_INV_LENGTH); + } + + /* Check if we're too short. Too long is safe as we'll + automatically left-truncate. */ + if (mdlen < qbits/8) + { + log_error (_("a %zu bit hash is not valid for a %u bit %s key\n"), + mdlen*8, + gcry_pk_get_nbits (pkey), + gcry_pk_algo_name (dsaalgo)); + /* FIXME: we need to check the requirements for ECDSA. */ + if (mdlen < 20 || dsaalgo == GCRY_PK_DSA) + return gpg_error (GPG_ERR_INV_LENGTH); + } + + /* Truncate. */ + if (mdlen > qbits/8) + mdlen = qbits/8; + + /* Create the S-expression. */ + err = gcry_sexp_build (&hash, NULL, + "(data (flags raw) (value %b))", + (int)mdlen, md); + if (!err) + *r_hash = hash; + return err; +} + + /* Special version of do_encode_md to take care of pkcs#1 padding. For TLS-MD5SHA1 we need to do the padding ourself as Libgrypt does not know about this special scheme. Fixme: We should have a @@ -180,8 +279,8 @@ else { /* No smartcard, but a private key */ - gcry_sexp_t s_hash = NULL; + int dsaalgo; /* Put the hash into a sexp */ if (ctrl->digest.algo == MD_USER_TLS_MD5SHA1) @@ -189,6 +288,11 @@ ctrl->digest.valuelen, gcry_pk_get_nbits (s_skey), &s_hash); + else if ( (dsaalgo = agent_is_dsa_key (s_skey)) ) + rc = do_encode_dsa (ctrl->digest.value, + ctrl->digest.valuelen, + dsaalgo, s_skey, + &s_hash); else rc = do_encode_md (ctrl->digest.value, ctrl->digest.valuelen, Modified: trunk/common/estream.c =================================================================== --- trunk/common/estream.c 2010-04-21 09:56:43 UTC (rev 5314) +++ trunk/common/estream.c 2010-04-21 16:26:17 UTC (rev 5315) @@ -423,6 +423,14 @@ +static void +es_deinit (void) +{ + /* Flush all streams. */ + es_fflush (NULL); +} + + /* * Initialization. */ @@ -430,17 +438,20 @@ static int es_init_do (void) { -#ifdef HAVE_PTH static int initialized; if (!initialized) { +#ifdef HAVE_PTH if (!pth_init () && errno != EPERM ) return -1; if (pth_mutex_init (&estream_list_lock)) initialized = 1; +#else + initialized = 1; +#endif + atexit (es_deinit); } -#endif return 0; } Modified: trunk/doc/DETAILS =================================================================== --- trunk/doc/DETAILS 2010-04-21 09:56:43 UTC (rev 5314) +++ trunk/doc/DETAILS 2010-04-21 16:26:17 UTC (rev 5315) @@ -34,7 +34,7 @@ rev = revocation signature fpr = fingerprint: (fingerprint is in field 10) pkd = public key data (special field format, see below) - grp = reserved for gpgsm + grp = keygrip rvk = revocation key tru = trust database information spk = signature subpacket Modified: trunk/g10/call-agent.c =================================================================== --- trunk/g10/call-agent.c 2010-04-21 09:56:43 UTC (rev 5314) +++ trunk/g10/call-agent.c 2010-04-21 16:26:17 UTC (rev 5315) @@ -1294,23 +1294,25 @@ -/* Ask the agent whether a secret key with the given keygrip is - known. */ +/* Ask the agent whether a secret key for the given public key is + available. Returns 0 if available. */ gpg_error_t -agent_havekey (ctrl_t ctrl, const char *hexkeygrip) +agent_probe_secret_key (ctrl_t ctrl, PKT_public_key *pk) { gpg_error_t err; char line[ASSUAN_LINELENGTH]; + char *hexgrip; err = start_agent (ctrl, 0); if (err) return err; - if (!hexkeygrip || strlen (hexkeygrip) != 40) - return gpg_error (GPG_ERR_INV_VALUE); + err = hexkeygrip_from_pk (pk, &hexgrip); + if (err) + return err; - snprintf (line, DIM(line)-1, "HAVEKEY %s", hexkeygrip); - line[DIM(line)-1] = 0; + snprintf (line, sizeof line, "HAVEKEY %s", hexgrip); + xfree (hexgrip); err = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL); return err; Modified: trunk/g10/call-agent.h =================================================================== --- trunk/g10/call-agent.h 2010-04-21 09:56:43 UTC (rev 5314) +++ trunk/g10/call-agent.h 2010-04-21 16:26:17 UTC (rev 5315) @@ -140,8 +140,9 @@ /* Return the S2K iteration count as computed by gpg-agent. */ gpg_error_t agent_get_s2k_count (unsigned long *r_count); -/* Check whether a secret key with HEXKEYGRIP is available. */ -gpg_error_t agent_havekey (ctrl_t ctrl, const char *hexkeygrip); +/* Check whether a secret key for public key PK is available. Returns + 0 if the secret key is available. */ +gpg_error_t agent_probe_secret_key (ctrl_t ctrl, PKT_public_key *pk); /* Return infos about the secret key with HEXKEYGRIP. */ gpg_error_t agent_get_keyinfo (ctrl_t ctrl, const char *hexkeygrip, @@ -151,8 +152,8 @@ gpg_error_t agent_genkey (ctrl_t ctrl, const char *keyparms, gcry_sexp_t *r_pubkey); -/* Create a sigtnature. */ -gpg_error_t agent_pksign (ctrl_t ctrl, const char *keygrip, const char *desc, +/* Create a signature. */ +gpg_error_t agent_pksign (ctrl_t ctrl, const char *hexkeygrip, const char *desc, unsigned char *digest, size_t digestlen, int digestalgo, gcry_sexp_t *r_sigval); Modified: trunk/g10/delkey.c =================================================================== --- trunk/g10/delkey.c 2010-04-21 09:56:43 UTC (rev 5314) +++ trunk/g10/delkey.c 2010-04-21 16:26:17 UTC (rev 5315) @@ -52,7 +52,7 @@ int rc = 0; KBNODE keyblock = NULL; KBNODE node; - KEYDB_HANDLE hd = keydb_new (secret); + KEYDB_HANDLE hd = keydb_new (); PKT_public_key *pk = NULL; PKT_secret_key *sk = NULL; u32 keyid[2]; @@ -104,15 +104,12 @@ if(!force) { - rc = seckey_available( keyid ); - if( !rc ) + if (have_secret_key_with_kid (keyid)) { *r_sec_avail = 1; rc = -1; goto leave; } - else if( rc != G10ERR_NO_SECKEY ) - log_error("%s: get secret key: %s\n", username, g10_errstr(rc) ); else rc = 0; } Modified: trunk/g10/export.c =================================================================== --- trunk/g10/export.c 2010-04-21 09:56:43 UTC (rev 5314) +++ trunk/g10/export.c 2010-04-21 16:26:17 UTC (rev 5315) @@ -306,7 +306,7 @@ *any = 0; init_packet( &pkt ); - kdbhd = keydb_new (secret); + kdbhd = keydb_new (); if (!users) { ndesc = 1; Modified: trunk/g10/getkey.c =================================================================== --- trunk/g10/getkey.c 2010-04-21 09:56:43 UTC (rev 5314) +++ trunk/g10/getkey.c 2010-04-21 16:26:17 UTC (rev 5315) @@ -35,6 +35,7 @@ #include "trustdb.h" #include "i18n.h" #include "keyserver-internal.h" +#include "call-agent.h" #define MAX_PK_CACHE_ENTRIES PK_UID_CACHE_SIZE #define MAX_UID_CACHE_ENTRIES PK_UID_CACHE_SIZE @@ -325,18 +326,6 @@ copy_public_key (pk, a->pkt->pkt.public_key); } -static void -sk_from_block (GETKEY_CTX ctx, PKT_secret_key * sk, KBNODE keyblock) -{ - KBNODE a = ctx->found_key ? ctx->found_key : keyblock; - - assert (a->pkt->pkttype == PKT_SECRET_KEY - || a->pkt->pkttype == PKT_SECRET_SUBKEY); - - copy_secret_key (sk, a->pkt->pkt.secret_key); -} - - /* Get a public key and store it into the allocated pk can be called * with PK set to NULL to just read it into some internal * structures. */ @@ -378,7 +367,7 @@ memset (&ctx, 0, sizeof ctx); ctx.exact = 1; /* Use the key ID exactly as given. */ ctx.not_allocated = 1; - ctx.kr_handle = keydb_new (0); + ctx.kr_handle = keydb_new (); ctx.nitems = 1; ctx.items[0].mode = KEYDB_SEARCH_MODE_LONG_KID; ctx.items[0].u.kid[0] = keyid[0]; @@ -437,7 +426,7 @@ } #endif - hd = keydb_new (0); + hd = keydb_new (); rc = keydb_search_kid (hd, keyid); if (rc == -1) { @@ -480,7 +469,7 @@ memset (&ctx, 0, sizeof ctx); /* No need to set exact here because we want the entire block. */ ctx.not_allocated = 1; - ctx.kr_handle = keydb_new (0); + ctx.kr_handle = keydb_new (); ctx.nitems = 1; ctx.items[0].mode = KEYDB_SEARCH_MODE_LONG_KID; ctx.items[0].u.kid[0] = keyid[0]; @@ -494,67 +483,43 @@ -/**************** - * Get a secret key and store it into sk +/* + * Get a public key and store it into PK. This functions check that a + * corresponding secret key is available. With no secret key it does + * not succeeed. */ -int -get_seckey (PKT_secret_key * sk, u32 * keyid) +gpg_error_t +get_seckey (PKT_public_key *pk, u32 *keyid) { - int rc; + gpg_error_t err; struct getkey_ctx_s ctx; - KBNODE kb = NULL; + kbnode_t keyblock = NULL; memset (&ctx, 0, sizeof ctx); ctx.exact = 1; /* Use the key ID exactly as given. */ ctx.not_allocated = 1; - ctx.kr_handle = keydb_new (1); + ctx.kr_handle = keydb_new (); ctx.nitems = 1; ctx.items[0].mode = KEYDB_SEARCH_MODE_LONG_KID; ctx.items[0].u.kid[0] = keyid[0]; ctx.items[0].u.kid[1] = keyid[1]; - ctx.req_algo = sk->req_algo; - ctx.req_usage = sk->req_usage; - rc = lookup (&ctx, &kb, 1); - if (!rc) + ctx.req_algo = pk->req_algo; + ctx.req_usage = pk->req_usage; + err = lookup (&ctx, &keyblock, 1); + if (!err) { - sk_from_block (&ctx, sk, kb); + pk_from_block (&ctx, pk, keyblock); } - get_seckey_end (&ctx); - release_kbnode (kb); + get_pubkey_end (&ctx); + release_kbnode (keyblock); - if (!rc) - { - /* Check the secret key (this may prompt for a passprase to - * unlock the secret key. */ - /* rc = check_secret_key (sk, 0); */ - } + if (!err) + err = agent_probe_secret_key (/*ctrl*/NULL, pk); - return rc; + return err; } -/* Check whether the secret key is available. This is just a fast - * check and does not tell us whether the secret key is valid. It - * merely tells other whether there is some secret key. - * Returns: - * 0 := key is available - * G10ERR_NO_SECKEY := key not availabe - */ -int -seckey_available (u32 * keyid) -{ - int rc; - KEYDB_HANDLE hd = keydb_new (1); - - rc = keydb_search_kid (hd, keyid); - if (rc == -1) - rc = G10ERR_NO_SECKEY; - keydb_release (hd); - return rc; -} - - - static int skip_unusable (void *dummy, u32 * keyid, PKT_user_id * uid) { @@ -599,16 +564,15 @@ } -/* Try to get the pubkey by the userid. This function looks for the +/* Try to get the pubkey by the userid. This function looks for the * first pubkey certificate which has the given name in a user_id. If - * pk/sk has the pubkey algo set, the function will only return a - * pubkey with that algo. If namelist is NULL, the first key is - * returned. The caller should provide storage for either the pk or - * the sk. If ret_kb is not NULL the function will return the - * keyblock there. */ + * PK has the pubkey algo set, the function will only return a pubkey + * with that algo. If NAMELIST is NULL, the first key is returned. + * The caller should provide storage for the PK. If RET_KB is not + * NULL the function will return the keyblock there. */ static int -key_byname (GETKEY_CTX * retctx, strlist_t namelist, - PKT_public_key * pk, PKT_secret_key * sk, +key_byname (GETKEY_CTX *retctx, strlist_t namelist, + PKT_public_key *pk, int want_secret, int include_unusable, KBNODE * ret_kb, KEYDB_HANDLE * ret_kdbhd) { @@ -618,8 +582,6 @@ GETKEY_CTX ctx; KBNODE help_kb = NULL; - /* FIXME: Eventually remove the SK argument. */ - if (retctx) { /* Reset the returned context in case of error. */ @@ -671,7 +633,7 @@ } ctx->want_secret = want_secret; - ctx->kr_handle = keydb_new (0); + ctx->kr_handle = keydb_new (); if (!ret_kb) ret_kb = &help_kb; @@ -680,11 +642,7 @@ ctx->req_algo = pk->req_algo; ctx->req_usage = pk->req_usage; } - else if (sk) /* FIXME: We should remove this. */ - { - ctx->req_algo = sk->req_algo; - ctx->req_usage = sk->req_usage; - } + rc = lookup (ctx, ret_kb, want_secret); if (!rc && pk) { @@ -771,7 +729,7 @@ else { add_to_strlist (&namelist, name); - rc = key_byname (retctx, namelist, pk, NULL, 0, + rc = key_byname (retctx, namelist, pk, 0, include_unusable, ret_keyblock, ret_kdbhd); } @@ -805,7 +763,7 @@ } add_to_strlist (&namelist, name); rc = key_byname (anylocalfirst ? retctx : NULL, - namelist, pk, NULL, 0, + namelist, pk, 0, include_unusable, ret_keyblock, ret_kdbhd); break; @@ -904,7 +862,7 @@ *retctx = NULL; } rc = key_byname (anylocalfirst ? retctx : NULL, - namelist, pk, NULL, 0, + namelist, pk, 0, include_unusable, ret_keyblock, ret_kdbhd); } if (!rc) @@ -943,7 +901,7 @@ get_pubkey_bynames (GETKEY_CTX * retctx, PKT_public_key * pk, strlist_t names, KBNODE * ret_keyblock) { - return key_byname (retctx, names, pk, NULL, 0, 1, ret_keyblock, NULL); + return key_byname (retctx, names, pk, 0, 1, ret_keyblock, NULL); } int @@ -991,7 +949,7 @@ memset (&ctx, 0, sizeof ctx); ctx.exact = 1; ctx.not_allocated = 1; - ctx.kr_handle = keydb_new (0); + ctx.kr_handle = keydb_new (); ctx.nitems = 1; ctx.items[0].mode = fprint_len == 16 ? KEYDB_SEARCH_MODE_FPR16 : KEYDB_SEARCH_MODE_FPR20; @@ -1028,7 +986,7 @@ while (i < MAX_FINGERPRINT_LEN) fprbuf[i++] = 0; - hd = keydb_new (0); + hd = keydb_new (); rc = keydb_search_fpr (hd, fprbuf); if (rc == -1) { @@ -1070,7 +1028,7 @@ memset (&ctx, 0, sizeof ctx); ctx.not_allocated = 1; - ctx.kr_handle = keydb_new (0); + ctx.kr_handle = keydb_new (); ctx.nitems = 1; ctx.items[0].mode = (fprint_len == 16 ? KEYDB_SEARCH_MODE_FPR16 @@ -1086,15 +1044,15 @@ } -/* Get a secret key by name and store it into sk. - * If NAME is NULL use the default key. */ -static int -get_seckey_byname2 (GETKEY_CTX * retctx, - PKT_secret_key * sk, const char *name, int unprotect, - KBNODE * retblock) +/* Get a secret key by NAME and store it into PK. If NAME is NULL use + * the default key. This functions checks that a corresponding secret + * key is available. With no secret key it does not succeeed. */ +gpg_error_t +get_seckey_byname (PKT_public_key *pk, const char *name) { + gpg_error_t err; strlist_t namelist = NULL; - int rc, include_unusable = 1; + int include_unusable = 1; /* If we have no name, try to use the default secret key. If we have no default, we'll use the first usable one. */ @@ -1106,110 +1064,73 @@ else include_unusable = 0; - rc = key_byname (retctx, namelist, NULL, sk, 1, include_unusable, - retblock, NULL); + err = key_byname (NULL, namelist, pk, 1, include_unusable, NULL, NULL); free_strlist (namelist); - /* if (!rc && unprotect) */ - /* rc = check_secret_key (sk, 0); */ - - return rc; + return err; } -int -get_seckey_byname (PKT_secret_key * sk, const char *name, int unlock) -{ - return get_seckey_byname2 (NULL, sk, name, unlock, NULL); -} -int -get_seckey_bynames (GETKEY_CTX * retctx, PKT_secret_key * sk, - strlist_t names, KBNODE * ret_keyblock) -{ - return key_byname (retctx, names, NULL, sk, 1, 1, ret_keyblock, NULL); -} - - -int -get_seckey_next (GETKEY_CTX ctx, PKT_secret_key * sk, KBNODE * ret_keyblock) -{ - int rc; - - rc = lookup (ctx, ret_keyblock, 1); - if (!rc && sk && ret_keyblock) - sk_from_block (ctx, sk, *ret_keyblock); - - return rc; -} - - -void -get_seckey_end (GETKEY_CTX ctx) -{ - get_pubkey_end (ctx); -} - - /* Search for a key with the given fingerprint. * FIXME: - * We should replace this with the _byname function. Thiscsan be done + * We should replace this with the _byname function. This can be done * by creating a userID conforming to the unified fingerprint style. */ -int -get_seckey_byfprint (PKT_secret_key * sk, - const byte * fprint, size_t fprint_len) +gpg_error_t +get_seckey_byfprint (PKT_public_key *pk, const byte * fprint, size_t fprint_len) { - int rc; + gpg_error_t err; if (fprint_len == 20 || fprint_len == 16) { struct getkey_ctx_s ctx; - KBNODE kb = NULL; + kbnode_t kb = NULL; memset (&ctx, 0, sizeof ctx); ctx.exact = 1; ctx.not_allocated = 1; - ctx.kr_handle = keydb_new (1); + ctx.kr_handle = keydb_new (); ctx.nitems = 1; ctx.items[0].mode = fprint_len == 16 ? KEYDB_SEARCH_MODE_FPR16 : KEYDB_SEARCH_MODE_FPR20; memcpy (ctx.items[0].u.fpr, fprint, fprint_len); - rc = lookup (&ctx, &kb, 1); - if (!rc && sk) - sk_from_block (&ctx, sk, kb); + err = lookup (&ctx, &kb, 1); + if (!err && pk) + pk_from_block (&ctx, pk, kb); release_kbnode (kb); - get_seckey_end (&ctx); + get_pubkey_end (&ctx); } else - rc = G10ERR_GENERAL; /* Oops */ - return rc; + err = gpg_error (GPG_ERR_BUG); + return err; } /* Search for a secret key with the given fingerprint and return the - complete keyblock which may have more than only this key. */ -int -get_seckeyblock_byfprint (KBNODE * ret_keyblock, const byte * fprint, - size_t fprint_len) + complete keyblock which may have more than only this key. Return + an error if no corresponding secret key is available. */ +gpg_error_t +get_seckeyblock_byfprint (kbnode_t *ret_keyblock, + const byte *fprint, size_t fprint_len) { - int rc; + gpg_error_t err; struct getkey_ctx_s ctx; if (fprint_len != 20 && fprint_len == 16) - return G10ERR_GENERAL; /* Oops */ + return gpg_error (GPG_ERR_BUG); memset (&ctx, 0, sizeof ctx); ctx.not_allocated = 1; - ctx.kr_handle = keydb_new (1); + ctx.kr_handle = keydb_new (); ctx.nitems = 1; ctx.items[0].mode = (fprint_len == 16 ? KEYDB_SEARCH_MODE_FPR16 : KEYDB_SEARCH_MODE_FPR20); memcpy (ctx.items[0].u.fpr, fprint, fprint_len); - rc = lookup (&ctx, ret_keyblock, 1); - get_seckey_end (&ctx); + err = lookup (&ctx, ret_keyblock, 1); + get_pubkey_end (&ctx); - return rc; + return err; } @@ -1220,7 +1141,7 @@ getkey_bynames (getkey_ctx_t *retctx, PKT_public_key *pk, strlist_t names, int want_secret, kbnode_t *ret_keyblock) { - return key_byname (retctx, names, pk, NULL, want_secret, 1, + return key_byname (retctx, names, pk, want_secret, 1, ret_keyblock, NULL); } @@ -1238,7 +1159,7 @@ * * FIXME: Explain what is up with unusable keys. * - * FIXME: We also have the get_pubkey_byname fucntion which has a + * FIXME: We also have the get_pubkey_byname function which has a * different semantic. Should be merged with this one. */ gpg_error_t @@ -1256,7 +1177,7 @@ else with_unusable = 0; - err = key_byname (retctx, namelist, pk, NULL, want_secret, with_unusable, + err = key_byname (retctx, namelist, pk, want_secret, with_unusable, ret_keyblock, NULL); /* FIXME: Check that we really return GPG_ERR_NO_SECKEY if @@ -2538,7 +2459,7 @@ goto skip; } - if (want_secret && have_secret_key (ctx->keyblock)) + if (want_secret && !have_any_secret_key (NULL, ctx->keyblock)) goto skip; /* No secret key available. */ /* Warning: node flag bits 0 and 1 should be preserved by @@ -2586,9 +2507,7 @@ /**************** * FIXME: Replace by the generic function * It does not work as it is right now - it is used at - * 2 places: a) to get the key for an anonyous recipient - * b) to get the ultimately trusted keys. - * The a) usage might have some problems. + * one place: to get the key for an anonymous recipient. * * set with_subkeys true to include subkeys * set with_spm true to include secret-parts-missing keys @@ -2606,6 +2525,10 @@ enum_secret_keys (void **context, PKT_secret_key * sk, int with_subkeys, int with_spm) { + log_debug ("FIXME: Anonymous recipient does not yet work\n"); + return -1; +#if 0 + int rc = 0; struct { @@ -2622,7 +2545,7 @@ /* Make a new context. */ c = xmalloc_clear (sizeof *c); *context = c; - c->hd = keydb_new (1); + c->hd = keydb_new (1); /*FIXME*/ c->first = 1; c->keyblock = NULL; c->node = NULL; @@ -2676,6 +2599,7 @@ while (!rc); return rc; /* Error. */ +#endif } @@ -2893,37 +2817,71 @@ } -/* Return 0 if a secret key is available for the key described by - KEYBLOCK. FIXME: How do we handel subkeys? */ -gpg_error_t -have_secret_key (kbnode_t keyblock) +/* Return true if a secret key or secret subkey is available for one + of the public keys in KEYBLOCK. */ +int +have_any_secret_key (ctrl_t ctrl, kbnode_t keyblock) { - gpg_error_t err; - unsigned char fpr[MAX_FINGERPRINT_LEN]; - size_t fprlen; - KEYDB_HANDLE kdh; + kbnode_t node; - if (!keyblock || keyblock->pkt->pkttype != PKT_PUBLIC_KEY) - return gpg_error (GPG_ERR_NO_PUBKEY); /* Should not happen. */ + for (node = keyblock; node; node = node->next) + if ((node->pkt->pkttype == PKT_PUBLIC_KEY + || node->pkt->pkttype == PKT_PUBLIC_SUBKEY) + && !agent_probe_secret_key (ctrl, node->pkt->pkt.public_key)) + return 1; + return 0; +} - fingerprint_from_pk (keyblock->pkt->pkt.public_key, fpr, &fprlen); - while (fprlen < MAX_FINGERPRINT_LEN) - fpr[fprlen++] = 0; - /* FIXME: Always allocating a new handle is too slow. However this - entire implementation is anyway a temporary solution until we can - ask gpg-agent for the secret key. */ - kdh = keydb_new (1); - if (!kdh) - return gpg_error (GPG_ERR_GENERAL); +/* Return true if a secret key is available for the public key with + * the given KEYID. This is just a fast check and does not tell us + * whether the secret key is valid. It merely tells os whether there + * is some secret key. */ +int +have_secret_key_with_kid (u32 *keyid) +{ + gpg_error_t err; + KEYDB_HANDLE kdbhd; + KEYDB_SEARCH_DESC desc; + kbnode_t keyblock; + kbnode_t node; + int result = 0; - err = keydb_search_fpr (kdh, fpr); - if (err == -1 || gpg_err_code (err) == GPG_ERR_EOF) - err = gpg_error (GPG_ERR_NO_SECKEY); + kdbhd = keydb_new (); + memset (&desc, 0, sizeof desc); + desc.mode = KEYDB_SEARCH_MODE_LONG_KID; + desc.u.kid[0] = keyid[0]; + desc.u.kid[1] = keyid[1]; + while (!result && !(err = keydb_search (kdbhd, &desc, 1))) + { + desc.mode = KEYDB_SEARCH_MODE_NEXT; + err = keydb_get_keyblock (kdbhd, &keyblock); + if (err) + { + log_error (_("error reading keyblock: %s\n"), g10_errstr (err)); + break; + } - keydb_release (kdh); + for (node = keyblock; node; node = node->next) + { + /* Bit 0 of the flags is set if the search found the key + using that key or subkey. */ + if ((node->flag & 1)) + { + assert (node->pkt->pkttype == PKT_PUBLIC_KEY + || node->pkt->pkttype == PKT_PUBLIC_SUBKEY); - return err; + if (!agent_probe_secret_key (NULL, node->pkt->pkt.public_key)) + { + result = 1; + break; + } + } + } + release_kbnode (keyblock); + } + keydb_release (kdbhd); + return result; } Modified: trunk/g10/gpgv.c =================================================================== --- trunk/g10/gpgv.c 2010-04-21 09:56:43 UTC (rev 5314) +++ trunk/g10/gpgv.c 2010-04-21 16:26:17 UTC (rev 5315) @@ -533,3 +533,10 @@ { } +gpg_error_t +agent_probe_secret_key (ctrl_t ctrl, PKT_public_key *pk) +{ + (void)ctrl; + (void)pk; + return gpg_error (GPG_ERR_NO_SECKEY); +} Modified: trunk/g10/import.c =================================================================== --- trunk/g10/import.c 2010-04-21 09:56:43 UTC (rev 5314) +++ trunk/g10/import.c 2010-04-21 16:26:17 UTC (rev 5315) @@ -800,7 +800,7 @@ stats->skipped_new_keys++; } else if( rc ) { /* insert this key */ - KEYDB_HANDLE hd = keydb_new (0); + KEYDB_HANDLE hd = keydb_new (); rc = keydb_locate_writable (hd, NULL); if (rc) { @@ -861,7 +861,7 @@ } /* now read the original keyblock */ - hd = keydb_new (0); + hd = keydb_new (); { byte afp[MAX_FINGERPRINT_LEN]; size_t an; @@ -1012,17 +1012,17 @@ need to check if a designated revocation is present or if the prefs are not rational so we can warn the user. */ - if(mod_key) + if (mod_key) { - revocation_present(keyblock_orig); - if(!from_sk && seckey_available(keyid)==0) - check_prefs(keyblock_orig); + revocation_present (keyblock_orig); + if (!from_sk && have_secret_key_with_kid (keyid)) + check_prefs (keyblock_orig); } - else if(new_key) + else if (new_key) { - revocation_present(keyblock); - if(!from_sk && seckey_available(keyid)==0) - check_prefs(keyblock); + revocation_present (keyblock); + if (!from_sk && have_secret_key_with_kid (keyid)) + check_prefs (keyblock); } release_kbnode( keyblock_orig ); @@ -1160,11 +1160,16 @@ clear_kbnode_flags( keyblock ); /* do we have this key already in one of our secrings ? */ - rc = seckey_available( keyid ); + rc = -1 /* fixme seckey_available( keyid ) is not anymore + available and has been replaced by + have_secret_key_with_kid. We need to rework the entire + secret key import code. The solution I am currently + thinking about is to move that code into a helper + program. */; if( rc == G10ERR_NO_SECKEY && !(opt.import_options&IMPORT_MERGE_ONLY) ) { /* simply insert this key */ - KEYDB_HANDLE hd = keydb_new (1); + KEYDB_HANDLE hd = keydb_new (); /* FIXME*/ /* get default resource */ rc = keydb_locate_writable (hd, NULL); @@ -1265,7 +1270,7 @@ } /* read the original keyblock */ - hd = keydb_new (0); + hd = keydb_new (); { byte afp[MAX_FINGERPRINT_LEN]; size_t an; @@ -1594,7 +1599,7 @@ else if( node->pkt->pkttype == PKT_SIGNATURE && !node->pkt->pkt.signature->flags.exportable && !(options&IMPORT_LOCAL_SIGS) && - seckey_available( node->pkt->pkt.signature->keyid ) ) + !have_secret_key_with_kid (node->pkt->pkt.signature->keyid)) { /* here we violate the rfc a bit by still allowing * to import non-exportable signature when we have the @@ -2395,9 +2400,10 @@ ; else return G10ERR_GENERAL; - - hd = keydb_new (1); + log_debug ("FIXME: Do we need the stub at all?\n"); + hd = keydb_new (); /* FIXME. */ + /* Now check whether there is a secret keyring. */ { PKT_public_key *pk = pub_keyblock->pkt->pkt.public_key; Modified: trunk/g10/keydb.c =================================================================== --- trunk/g10/keydb.c 2010-04-21 09:56:43 UTC (rev 5314) +++ trunk/g10/keydb.c 2010-04-21 16:26:17 UTC (rev 5315) @@ -348,10 +348,11 @@ KEYDB_HANDLE -keydb_new (int secret) +keydb_new (void) { KEYDB_HANDLE hd; int i, j; + int secret = 0; /* FIXME: Remove the secret stuff all together. */ hd = xmalloc_clear (sizeof *hd); hd->found = -1; Modified: trunk/g10/keydb.h =================================================================== --- trunk/g10/keydb.h 2010-04-21 09:56:43 UTC (rev 5314) +++ trunk/g10/keydb.h 2010-04-21 16:26:17 UTC (rev 5315) @@ -24,6 +24,7 @@ #include #include "types.h" +#include "util.h" #include "packet.h" #include "cipher.h" @@ -132,7 +133,7 @@ Flag 2 == default */ int keydb_add_resource (const char *url, int flags, int secret); -KEYDB_HANDLE keydb_new (int secret); +KEYDB_HANDLE keydb_new (void); void keydb_release (KEYDB_HANDLE hd); const char *keydb_get_resource_name (KEYDB_HANDLE hd); int keydb_get_keyblock (KEYDB_HANDLE hd, KBNODE *ret_kb); @@ -207,27 +208,23 @@ strlist_t names, KBNODE *ret_keyblock ); int get_pubkey_next( GETKEY_CTX ctx, PKT_public_key *pk, KBNODE *ret_keyblock ); void get_pubkey_end( GETKEY_CTX ctx ); -int get_seckey( PKT_secret_key *sk, u32 *keyid ); -int get_primary_seckey( PKT_secret_key *sk, u32 *keyid ); +gpg_error_t get_seckey (PKT_public_key *pk, u32 *keyid); int get_pubkey_byfprint( PKT_public_key *pk, const byte *fprint, size_t fprint_len ); int get_pubkey_byfprint_fast (PKT_public_key *pk, const byte *fprint, size_t fprint_len); int get_keyblock_byfprint( KBNODE *ret_keyblock, const byte *fprint, size_t fprint_len ); -int get_keyblock_bylid( KBNODE *ret_keyblock, ulong lid ); -int seckey_available( u32 *keyid ); -int get_seckey_byname( PKT_secret_key *sk, const char *name, int unlock ); -int get_seckey_bynames( GETKEY_CTX *rx, PKT_secret_key *sk, - strlist_t names, KBNODE *ret_keyblock ); -int get_seckey_next (GETKEY_CTX ctx, PKT_secret_key *sk, KBNODE *ret_keyblock); -void get_seckey_end( GETKEY_CTX ctx ); -int get_seckey_byfprint( PKT_secret_key *sk, - const byte *fprint, size_t fprint_len); -int get_seckeyblock_byfprint (KBNODE *ret_keyblock, const byte *fprint, - size_t fprint_len ); +int have_secret_key_with_kid (u32 *keyid); +gpg_error_t get_seckey_byname (PKT_public_key *pk, const char *name); + +gpg_error_t get_seckey_byfprint (PKT_public_key *pk, + const byte *fprint, size_t fprint_len); +gpg_error_t get_seckeyblock_byfprint (kbnode_t *ret_keyblock, + const byte *fprint, size_t fprint_len); + gpg_error_t getkey_bynames (getkey_ctx_t *retctx, PKT_public_key *pk, strlist_t names, int want_secret, kbnode_t *ret_keyblock); @@ -238,7 +235,7 @@ kbnode_t *ret_keyblock); void getkey_end (getkey_ctx_t ctx); -gpg_error_t have_secret_key (kbnode_t keyblock); +int have_any_secret_key (ctrl_t ctrl, kbnode_t keyblock); int enum_secret_keys( void **context, PKT_secret_key *sk, Modified: trunk/g10/keyedit.c =================================================================== --- trunk/g10/keyedit.c 2010-04-21 09:56:43 UTC (rev 5314) +++ trunk/g10/keyedit.c 2010-04-21 16:26:17 UTC (rev 5315) @@ -45,6 +45,7 @@ #include "status.h" #include "i18n.h" #include "keyserver-internal.h" +#include "call-agent.h" static void show_prefs (PKT_user_id * uid, PKT_signature * selfsig, int verbose); @@ -54,22 +55,18 @@ int with_revoker, int with_fpr, int with_subkeys, int with_prefs); static void show_key_and_fingerprint (KBNODE keyblock); -static int menu_adduid (KBNODE keyblock, KBNODE sec_keyblock, - int photo, const char *photo_name); -static void menu_deluid (KBNODE pub_keyblock, KBNODE sec_keyblock); +static int menu_adduid (KBNODE keyblock, int photo, const char *photo_name); +static void menu_deluid (KBNODE pub_keyblock); static int menu_delsig (KBNODE pub_keyblock); static int menu_clean (KBNODE keyblock, int self_only); -static void menu_delkey (KBNODE pub_keyblock, KBNODE sec_keyblock); -static int menu_addrevoker (KBNODE pub_keyblock, - KBNODE sec_keyblock, int sensitive); -static int menu_expire (KBNODE pub_keyblock, KBNODE sec_keyblock); -static int menu_backsign (KBNODE pub_keyblock, KBNODE sec_keyblock); -static int menu_set_primary_uid (KBNODE pub_keyblock, KBNODE sec_keyblock); -static int menu_set_preferences (KBNODE pub_keyblock, KBNODE sec_keyblock); -static int menu_set_keyserver_url (const char *url, - KBNODE pub_keyblock, KBNODE sec_keyblock); -static int menu_set_notation (const char *string, - KBNODE pub_keyblock, KBNODE sec_keyblock); +static void menu_delkey (KBNODE pub_keyblock); +static int menu_addrevoker (KBNODE pub_keyblock, int sensitive); +static int menu_expire (KBNODE pub_keyblock); +static int menu_backsign (KBNODE pub_keyblock); +static int menu_set_primary_uid (KBNODE pub_keyblock); +static int menu_set_preferences (KBNODE pub_keyblock); +static int menu_set_keyserver_url (const char *url, KBNODE pub_keyblock); +static int menu_set_notation (const char *string, KBNODE pub_keyblock); static int menu_select_uid (KBNODE keyblock, int idx); static int menu_select_uid_namehash (KBNODE keyblock, const char *namehash); static int menu_select_key (KBNODE keyblock, int idx); @@ -80,9 +77,9 @@ static int real_uids_left (KBNODE keyblock); static int count_selected_keys (KBNODE keyblock); static int menu_revsig (KBNODE keyblock); -static int menu_revuid (KBNODE keyblock, KBNODE sec_keyblock); -static int menu_revkey (KBNODE pub_keyblock, KBNODE sec_keyblock); -static int menu_revsubkey (KBNODE pub_keyblock, KBNODE sec_keyblock); +static int menu_revuid (KBNODE keyblock); +static int menu_revkey (KBNODE pub_keyblock); +static int menu_revsubkey (KBNODE pub_keyblock); static int enable_disable_key (KBNODE keyblock, int disable); static void menu_showphoto (KBNODE keyblock); @@ -120,6 +117,7 @@ PKT_secret_key *sk; PKT_public_key *pk; +#warning: This is not anymore needed. if (sec_node->pkt->pkttype == PKT_SECRET_KEY && node->pkt->pkttype == PKT_PUBLIC_KEY) return node->pkt->pkt.public_key; @@ -525,7 +523,7 @@ /* - * Loop over all locusr and and sign the uids after asking. + * Loop over all LOCUSR and and sign the uids after asking. * If no user id is marked, all user ids will be signed; * if some user_ids are marked those will be signed. */ @@ -572,18 +570,11 @@ u32 duration = 0, timestamp = 0; byte trust_depth = 0, trust_value = 0; - if (local || nonrevocable || trust || - opt.cert_policy_url || opt.cert_notations) + if (local || nonrevocable || trust + || opt.cert_policy_url || opt.cert_notations) force_v4 = 1; - /* We have to use a copy of the pk, because make_keysig_packet - * may remove the protection from sk and if we did other - * changes to the secret key, we would save the unprotected - * version. FIXME: This can be removed because all protection - * is now done by gpg-agent. */ - if (pk) - free_public_key (pk); - pk = copy_public_key (NULL, sk_rover->pk); + pk = sk_rover->pk; keyid_from_pk (pk, sk_keyid); /* Set mark A for all selected user ids. */ @@ -594,6 +585,7 @@ else node->flag &= ~NODFLG_MARK_A; } + /* Reset mark for uids which are already signed. */ uidnode = NULL; for (node = keyblock; node; node = node->next) @@ -620,11 +612,11 @@ if (uidnode) { int yesreally = 0; - char *user = - utf8_to_native (uidnode->pkt->pkt.user_id->name, - uidnode->pkt->pkt.user_id->len, - 0); + char *user; From cvs at cvs.gnupg.org Wed Apr 21 19:30:07 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 21 Apr 2010 19:30:07 +0200 Subject: [svn] GnuPG - r5316 - trunk/g10 Message-ID: Author: wk Date: 2010-04-21 19:30:07 +0200 (Wed, 21 Apr 2010) New Revision: 5316 Modified: trunk/g10/gpgv.c trunk/g10/packet.h trunk/g10/pubkey-enc.c Log: Re-indent and changed return type. Modified: trunk/g10/gpgv.c =================================================================== --- trunk/g10/gpgv.c 2010-04-21 16:26:17 UTC (rev 5315) +++ trunk/g10/gpgv.c 2010-04-21 17:30:07 UTC (rev 5316) @@ -358,7 +358,7 @@ /* Stub: * No encryption here but mainproc links to these functions. */ -int +gpg_error_t get_session_key (PKT_pubkey_enc *k, DEK *dek) { (void)k; @@ -367,7 +367,7 @@ } /* Stub: */ -int +gpg_error_t get_override_session_key (DEK *dek, const char *string) { (void)dek; Modified: trunk/g10/packet.h =================================================================== --- trunk/g10/packet.h 2010-04-21 16:26:17 UTC (rev 5315) +++ trunk/g10/packet.h 2010-04-21 17:30:07 UTC (rev 5316) @@ -480,8 +480,8 @@ int is_secret_key_protected (PKT_public_key *pk); /*-- pubkey-enc.c --*/ -int get_session_key( PKT_pubkey_enc *k, DEK *dek ); -int get_override_session_key( DEK *dek, const char *string ); +gpg_error_t get_session_key (PKT_pubkey_enc *k, DEK *dek); +gpg_error_t get_override_session_key (DEK *dek, const char *string); /*-- compress.c --*/ int handle_compressed( void *ctx, PKT_compressed *cd, Modified: trunk/g10/pubkey-enc.c =================================================================== --- trunk/g10/pubkey-enc.c 2010-04-21 16:26:17 UTC (rev 5315) +++ trunk/g10/pubkey-enc.c 2010-04-21 17:30:07 UTC (rev 5316) @@ -1,6 +1,6 @@ -/* pubkey-enc.c - public key encoded packet handling - * Copyright (C) 1998, 1999, 2000, 2001, 2002, - * 2006, 2009 Free Software Foundation, Inc. +/* pubkey-enc.c - Process a public key encoded packet. + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2006, 2009, + * 2010 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -38,131 +38,136 @@ #include "call-agent.h" -static int get_it( PKT_pubkey_enc *k, - DEK *dek, PKT_secret_key *sk, u32 *keyid ); +static gpg_error_t get_it (PKT_pubkey_enc *k, + DEK *dek, PKT_secret_key *sk, u32 *keyid); -/* check that the given algo is mentioned in one of the valid user IDs */ +/* Check that the given algo is mentioned in one of the valid user-ids. */ static int -is_algo_in_prefs ( KBNODE keyblock, preftype_t type, int algo ) +is_algo_in_prefs (kbnode_t keyblock, preftype_t type, int algo) { - KBNODE k; + kbnode_t k; - for (k=keyblock; k; k=k->next) { - if (k->pkt->pkttype == PKT_USER_ID) { - PKT_user_id *uid = k->pkt->pkt.user_id; - prefitem_t *prefs = uid->prefs; - - if (uid->created && prefs && - !uid->is_revoked && !uid->is_expired ) { - for (; prefs->type; prefs++ ) - if (prefs->type == type && prefs->value == algo) - return 1; + for (k = keyblock; k; k = k->next) + { + if (k->pkt->pkttype == PKT_USER_ID) + { + PKT_user_id *uid = k->pkt->pkt.user_id; + prefitem_t *prefs = uid->prefs; + + if (uid->created && prefs && !uid->is_revoked && !uid->is_expired) + { + for (; prefs->type; prefs++) + if (prefs->type == type && prefs->value == algo) + return 1; } } } - return 0; + return 0; } -/**************** - * Get the session key from a pubkey enc packet and return - * it in DEK, which should have been allocated in secure memory. +/* + * Get the session key from a pubkey enc packet and return it in DEK, + * which should have been allocated in secure memory by the caller. */ -int -get_session_key( PKT_pubkey_enc *k, DEK *dek ) +gpg_error_t +get_session_key (PKT_pubkey_enc * k, DEK * dek) { - PKT_secret_key *sk = NULL; - int rc; + PKT_secret_key *sk = NULL; + int rc; - rc = openpgp_pk_test_algo2 (k->pubkey_algo, PUBKEY_USAGE_ENC); - if( rc ) - goto leave; + rc = openpgp_pk_test_algo2 (k->pubkey_algo, PUBKEY_USAGE_ENC); + if (rc) + goto leave; - if( (k->keyid[0] || k->keyid[1]) && !opt.try_all_secrets ) { - sk = xmalloc_clear( sizeof *sk ); - sk->pubkey_algo = k->pubkey_algo; /* we want a pubkey with this algo*/ - if( !(rc = get_seckey( sk, k->keyid )) ) - rc = get_it( k, dek, sk, k->keyid ); + if ((k->keyid[0] || k->keyid[1]) && !opt.try_all_secrets) + { + sk = xmalloc_clear (sizeof *sk); + sk->pubkey_algo = k->pubkey_algo; /* We want a pubkey with this algo */ + if (!(rc = get_seckey (sk, k->keyid))) + rc = get_it (k, dek, sk, k->keyid); } - else if (opt.skip_hidden_recipients) - rc = gpg_error (GPG_ERR_NO_SECKEY); - else { /* anonymous receiver: Try all available secret keys */ - void *enum_context = NULL; - u32 keyid[2]; - char *p; + else if (opt.skip_hidden_recipients) + rc = gpg_error (GPG_ERR_NO_SECKEY); + else /* Anonymous receiver: Try all available secret keys. */ + { + void *enum_context = NULL; + u32 keyid[2]; + char *p; - for(;;) { - if( sk ) - free_secret_key( sk ); - sk = xmalloc_clear( sizeof *sk ); - rc=enum_secret_keys( &enum_context, sk, 1, 0); - if( rc ) { - rc = G10ERR_NO_SECKEY; - break; - } - if( sk->pubkey_algo != k->pubkey_algo ) - continue; - keyid_from_sk( sk, keyid ); - log_info(_("anonymous recipient; trying secret key %s ...\n"), - keystr(keyid)); + for (;;) + { + if (sk) + free_secret_key (sk); + sk = xmalloc_clear (sizeof *sk); + rc = enum_secret_keys (&enum_context, sk, 1, 0); + if (rc) + { + rc = G10ERR_NO_SECKEY; + break; + } + if (sk->pubkey_algo != k->pubkey_algo) + continue; + keyid_from_sk (sk, keyid); + log_info (_("anonymous recipient; trying secret key %s ...\n"), + keystr (keyid)); - if(!opt.try_all_secrets && !is_status_enabled()) - { - p=get_last_passphrase(); - set_next_passphrase(p); - xfree(p); - } + if (!opt.try_all_secrets && !is_status_enabled ()) + { + p = get_last_passphrase (); + set_next_passphrase (p); + xfree (p); + } - /* rc = check_secret_key( sk, opt.try_all_secrets?1:-1 ); /\* ask */ - /* only */ - /* once *\/ */ - /* if( !rc ) */ - { - rc = get_it( k, dek, sk, keyid ); - /* Successfully checked the secret key (either it was - a card, had no passphrase, or had the right - passphrase) but couldn't decrypt the session key, - so thus that key is not the anonymous recipient. - Move the next passphrase into last for the next - round. We only do this if the secret key was - successfully checked as in the normal case, - check_secret_key handles this for us via - passphrase_to_dek */ - if(rc) - next_to_last_passphrase(); - } + /* rc = check_secret_key( sk, opt.try_all_secrets?1:-1 ); /\* ask */ + /* only */ + /* once *\/ */ + /* if( !rc ) */ + { + rc = get_it (k, dek, sk, keyid); + /* Successfully checked the secret key (either it was a + card, had no passphrase, or had the right passphrase) + but couldn't decrypt the session key, so thus that key + is not the anonymous recipient. Move the next + passphrase into last for the next round. We only do + this if the secret key was successfully checked as in + the normal case, check_secret_key handles this for us + via passphrase_to_dek. */ + if (rc) + next_to_last_passphrase (); + } - if( !rc ) - { - log_info(_("okay, we are the anonymous recipient.\n") ); - break; - } - } - enum_secret_keys( &enum_context, NULL, 0, 0 ); /* free context */ + if (!rc) + { + log_info (_("okay, we are the anonymous recipient.\n")); + break; + } + } + enum_secret_keys (&enum_context, NULL, 0, 0); /* free context */ } - leave: - if( sk ) - free_secret_key( sk ); - return rc; +leave: + if (sk) + free_secret_key (sk); + return rc; } -static int -get_it( PKT_pubkey_enc *enc, DEK *dek, PKT_secret_key *sk, u32 *keyid ) +static gpg_error_t +get_it (PKT_pubkey_enc *enc, DEK *dek, PKT_secret_key *sk, u32 *keyid) { int rc; - gcry_mpi_t plain_dek = NULL; + gcry_mpi_t plain_dek = NULL; byte *frame = NULL; unsigned int n; size_t nframe; u16 csum, csum2; - + int card = 0; if (sk->is_protected && sk->protect.s2k.mode == 1002) - { /* Note, that we only support RSA for now. */ + { /* Note, that we only support RSA for now. */ #ifdef ENABLE_CARD_SUPPORT unsigned char *rbuf; size_t rbuflen; @@ -170,9 +175,11 @@ unsigned char *indata = NULL; size_t indatalen; - snbuf = serialno_and_fpr_from_sk (sk->protect.iv, sk->protect.ivlen, sk); + snbuf = + serialno_and_fpr_from_sk (sk->protect.iv, sk->protect.ivlen, sk); - if (gcry_mpi_aprint (GCRYMPI_FMT_USG, &indata, &indatalen, enc->data[0])) + if (gcry_mpi_aprint + (GCRYMPI_FMT_USG, &indata, &indatalen, enc->data[0])) BUG (); rc = agent_scd_pkdecrypt (snbuf, indata, indatalen, &rbuf, &rbuflen); @@ -187,173 +194,197 @@ #else rc = gpg_error (GPG_ERR_NOT_SUPPORTED); goto leave; -#endif /*!ENABLE_CARD_SUPPORT*/ +#endif /*!ENABLE_CARD_SUPPORT */ } else { - rc = pk_decrypt (sk->pubkey_algo, &plain_dek, enc->data, sk->skey ); - if( rc ) - goto leave; + rc = pk_decrypt (sk->pubkey_algo, &plain_dek, enc->data, sk->skey); + if (rc) + goto leave; if (gcry_mpi_aprint (GCRYMPI_FMT_USG, &frame, &nframe, plain_dek)) - BUG(); - gcry_mpi_release (plain_dek); plain_dek = NULL; + BUG (); + gcry_mpi_release (plain_dek); + plain_dek = NULL; } - /* Now get the DEK (data encryption key) from the frame - * - * Old versions encode the DEK in in this format (msb is left): - * - * 0 1 DEK(16 bytes) CSUM(2 bytes) 0 RND(n bytes) 2 - * - * Later versions encode the DEK like this: - * - * 0 2 RND(n bytes) 0 A DEK(k bytes) CSUM(2 bytes) - * - * (mpi_get_buffer already removed the leading zero). - * - * RND are non-zero randow bytes. - * A is the cipher algorithm - * DEK is the encryption key (session key) with length k - * CSUM - */ - if (DBG_CIPHER) - log_printhex ("DEK frame:", frame, nframe ); - n=0; - if (!card) - { - if( n + 7 > nframe ) - { rc = G10ERR_WRONG_SECKEY; goto leave; } - if( frame[n] == 1 && frame[nframe-1] == 2 ) { - log_info(_("old encoding of the DEK is not supported\n")); + /* Now get the DEK (data encryption key) from the frame + * + * Old versions encode the DEK in in this format (msb is left): + * + * 0 1 DEK(16 bytes) CSUM(2 bytes) 0 RND(n bytes) 2 + * + * Later versions encode the DEK like this: + * + * 0 2 RND(n bytes) 0 A DEK(k bytes) CSUM(2 bytes) + * + * (mpi_get_buffer already removed the leading zero). + * + * RND are non-zero randow bytes. + * A is the cipher algorithm + * DEK is the encryption key (session key) with length k + * CSUM + */ + if (DBG_CIPHER) + log_printhex ("DEK frame:", frame, nframe); + n = 0; + if (!card) + { + if (n + 7 > nframe) + { + rc = G10ERR_WRONG_SECKEY; + goto leave; + } + if (frame[n] == 1 && frame[nframe - 1] == 2) + { + log_info (_("old encoding of the DEK is not supported\n")); rc = G10ERR_CIPHER_ALGO; goto leave; } - if( frame[n] != 2 ) /* somethink is wrong */ - { rc = G10ERR_WRONG_SECKEY; goto leave; } - for(n++; n < nframe && frame[n]; n++ ) /* skip the random bytes */ - ; - n++; /* and the zero byte */ - } + if (frame[n] != 2) /* Somethink is wrong. */ + { + rc = G10ERR_WRONG_SECKEY; + goto leave; + } + for (n++; n < nframe && frame[n]; n++) /* Skip the random bytes. */ + ; + n++; /* Skip the zero byte. */ + } - if( n + 4 > nframe ) - { rc = G10ERR_WRONG_SECKEY; goto leave; } + if (n + 4 > nframe) + { + rc = G10ERR_WRONG_SECKEY; + goto leave; + } - dek->keylen = nframe - (n+1) - 2; - dek->algo = frame[n++]; - if( dek->algo == CIPHER_ALGO_IDEA ) - write_status(STATUS_RSA_OR_IDEA); - rc = openpgp_cipher_test_algo (dek->algo); - if( rc ) { - if( !opt.quiet && gpg_err_code (rc) == GPG_ERR_CIPHER_ALGO ) { - log_info(_("cipher algorithm %d%s is unknown or disabled\n"), - dek->algo, dek->algo == CIPHER_ALGO_IDEA? " (IDEA)":""); - if(dek->algo==CIPHER_ALGO_IDEA) - idea_cipher_warn (0); - } - dek->algo = 0; - goto leave; + dek->keylen = nframe - (n + 1) - 2; + dek->algo = frame[n++]; + if (dek->algo == CIPHER_ALGO_IDEA) + write_status (STATUS_RSA_OR_IDEA); + rc = openpgp_cipher_test_algo (dek->algo); + if (rc) + { + if (!opt.quiet && gpg_err_code (rc) == GPG_ERR_CIPHER_ALGO) + { + log_info (_("cipher algorithm %d%s is unknown or disabled\n"), + dek->algo, + dek->algo == CIPHER_ALGO_IDEA ? " (IDEA)" : ""); + if (dek->algo == CIPHER_ALGO_IDEA) + idea_cipher_warn (0); + } + dek->algo = 0; + goto leave; } - if ( dek->keylen != openpgp_cipher_get_algo_keylen (dek->algo) ) { - rc = GPG_ERR_WRONG_SECKEY; - goto leave; + if (dek->keylen != openpgp_cipher_get_algo_keylen (dek->algo)) + { + rc = GPG_ERR_WRONG_SECKEY; + goto leave; } - /* copy the key to DEK and compare the checksum */ - csum = frame[nframe-2] << 8; - csum |= frame[nframe-1]; - memcpy( dek->key, frame+n, dek->keylen ); - for( csum2=0, n=0; n < dek->keylen; n++ ) - csum2 += dek->key[n]; - if( csum != csum2 ) { - rc = G10ERR_WRONG_SECKEY; - goto leave; + /* Copy the key to DEK and compare the checksum. */ + csum = frame[nframe - 2] << 8; + csum |= frame[nframe - 1]; + memcpy (dek->key, frame + n, dek->keylen); + for (csum2 = 0, n = 0; n < dek->keylen; n++) + csum2 += dek->key[n]; + if (csum != csum2) + { + rc = G10ERR_WRONG_SECKEY; + goto leave; } - if( DBG_CIPHER ) - log_printhex ("DEK is:", dek->key, dek->keylen ); - /* check that the algo is in the preferences and whether it has expired */ - { - PKT_public_key *pk = NULL; - KBNODE pkb = get_pubkeyblock (keyid); + if (DBG_CIPHER) + log_printhex ("DEK is:", dek->key, dek->keylen); - if( !pkb ) { - rc = -1; - log_error("oops: public key not found for preference check\n"); - } - else if(pkb->pkt->pkt.public_key->selfsigversion > 3 - && dek->algo != CIPHER_ALGO_3DES - && !opt.quiet - && !is_algo_in_prefs( pkb, PREFTYPE_SYM, dek->algo )) - log_info (_("WARNING: cipher algorithm %s not found in recipient" - " preferences\n"), openpgp_cipher_algo_name (dek->algo)); - if (!rc) { - KBNODE k; - - for (k=pkb; k; k = k->next) { - if (k->pkt->pkttype == PKT_PUBLIC_KEY - || k->pkt->pkttype == PKT_PUBLIC_SUBKEY){ - u32 aki[2]; - keyid_from_pk(k->pkt->pkt.public_key, aki); + /* Check that the algo is in the preferences and whether it has expired. */ + { + PKT_public_key *pk = NULL; + KBNODE pkb = get_pubkeyblock (keyid); - if (aki[0]==keyid[0] && aki[1]==keyid[1]) { - pk = k->pkt->pkt.public_key; - break; - } - } - } - if (!pk) - BUG (); - if ( pk->expiredate && pk->expiredate <= make_timestamp() ) { - log_info(_("NOTE: secret key %s expired at %s\n"), - keystr(keyid), asctimestamp( pk->expiredate) ); - } - } + if (!pkb) + { + rc = -1; + log_error ("oops: public key not found for preference check\n"); + } + else if (pkb->pkt->pkt.public_key->selfsigversion > 3 + && dek->algo != CIPHER_ALGO_3DES + && !opt.quiet + && !is_algo_in_prefs (pkb, PREFTYPE_SYM, dek->algo)) + log_info (_("WARNING: cipher algorithm %s not found in recipient" + " preferences\n"), openpgp_cipher_algo_name (dek->algo)); + if (!rc) + { + KBNODE k; - if ( pk && pk->is_revoked ) { - log_info( _("NOTE: key has been revoked") ); - log_printf ("\n"); - show_revocation_reason( pk, 1 ); - } + for (k = pkb; k; k = k->next) + { + if (k->pkt->pkttype == PKT_PUBLIC_KEY + || k->pkt->pkttype == PKT_PUBLIC_SUBKEY) + { + u32 aki[2]; + keyid_from_pk (k->pkt->pkt.public_key, aki); - release_kbnode (pkb); - rc = 0; - } + if (aki[0] == keyid[0] && aki[1] == keyid[1]) + { + pk = k->pkt->pkt.public_key; + break; + } + } + } + if (!pk) + BUG (); + if (pk->expiredate && pk->expiredate <= make_timestamp ()) + { + log_info (_("NOTE: secret key %s expired at %s\n"), + keystr (keyid), asctimestamp (pk->expiredate)); + } + } + if (pk && pk->is_revoked) + { + log_info (_("NOTE: key has been revoked")); + log_printf ("\n"); + show_revocation_reason (pk, 1); + } - leave: - gcry_mpi_release (plain_dek); - xfree (frame); - return rc; + release_kbnode (pkb); + rc = 0; + } + + +leave: + gcry_mpi_release (plain_dek); + xfree (frame); + return rc; } -/**************** +/* * Get the session key from the given string. * String is supposed to be formatted as this: * : */ -int -get_override_session_key( DEK *dek, const char *string ) +gpg_error_t +get_override_session_key (DEK *dek, const char *string) { - const char *s; - int i; + const char *s; + int i; - if ( !string ) - return G10ERR_BAD_KEY; - dek->algo = atoi(string); - if ( dek->algo < 1 ) - return G10ERR_BAD_KEY; - if ( !(s = strchr ( string, ':' )) ) - return G10ERR_BAD_KEY; - s++; - for(i=0; i < DIM(dek->key) && *s; i++, s +=2 ) { - int c = hextobyte ( s ); - if (c == -1) - return G10ERR_BAD_KEY; - dek->key[i] = c; + if (!string) + return G10ERR_BAD_KEY; + dek->algo = atoi (string); + if (dek->algo < 1) + return G10ERR_BAD_KEY; + if (!(s = strchr (string, ':'))) + return G10ERR_BAD_KEY; + s++; + for (i = 0; i < DIM (dek->key) && *s; i++, s += 2) + { + int c = hextobyte (s); + if (c == -1) + return G10ERR_BAD_KEY; + dek->key[i] = c; } - if ( *s ) - return G10ERR_BAD_KEY; - dek->keylen = i; - return 0; + if (*s) + return G10ERR_BAD_KEY; + dek->keylen = i; + return 0; } - From cvs at cvs.gnupg.org Thu Apr 22 11:52:13 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 22 Apr 2010 11:52:13 +0200 Subject: [svn] GnuPG - r5317 - trunk/tools Message-ID: Author: wk Date: 2010-04-22 11:52:13 +0200 (Thu, 22 Apr 2010) New Revision: 5317 Modified: trunk/tools/Makefile.am Log: remove gpgtar Modified: trunk/tools/Makefile.am =================================================================== --- trunk/tools/Makefile.am 2010-04-21 17:30:07 UTC (rev 5316) +++ trunk/tools/Makefile.am 2010-04-22 09:52:13 UTC (rev 5317) @@ -48,7 +48,7 @@ bin_PROGRAMS += watchgnupg gpgparsemail endif if !HAVE_W32CE_SYSTEM -bin_PROGRAMS += gpgkey2ssh gpgtar +bin_PROGRAMS += gpgkey2ssh endif if !DISABLE_REGEX @@ -114,15 +114,15 @@ $(LIBINTL) $(LIBICONV) $(W32SOCKLIBS) endif -gpgtar_SOURCES = \ - gpgtar.c gpgtar.h \ - gpgtar-create.c \ - gpgtar-extract.c \ - gpgtar-list.c \ - no-libgcrypt.c -gpgtar_LDADD = $(common_libs) +#gpgtar_SOURCES = \ +# gpgtar.c gpgtar.h \ +# gpgtar-create.c \ +# gpgtar-extract.c \ +# gpgtar-list.c \ +# no-libgcrypt.c +#gpgtar_LDADD = $(common_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) ../common/libgpgrl.a From cvs at cvs.gnupg.org Thu Apr 22 16:59:26 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 22 Apr 2010 16:59:26 +0200 Subject: [svn] GnuPG - r5318 - branches/STABLE-BRANCH-2-0/po Message-ID: Author: wk Date: 2010-04-22 16:59:25 +0200 (Thu, 22 Apr 2010) New Revision: 5318 Modified: branches/STABLE-BRANCH-2-0/po/de.po Log: Change pinentry button label. Modified: branches/STABLE-BRANCH-2-0/po/de.po [not shown] From cvs at cvs.gnupg.org Thu Apr 22 17:51:02 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 22 Apr 2010 17:51:02 +0200 Subject: [svn] assuan - r373 - trunk/src Message-ID: Author: wk Date: 2010-04-22 17:51:01 +0200 (Thu, 22 Apr 2010) New Revision: 373 Modified: trunk/src/ChangeLog trunk/src/assuan-listen.c Log: Sho the pid in the the hello line. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2010-04-20 10:52:43 UTC (rev 372) +++ trunk/src/ChangeLog 2010-04-22 15:51:01 UTC (rev 373) @@ -1,3 +1,8 @@ +2010-04-22 Werner Koch + + * assuan-listen.c (assuan_accept): Show the PID with the default + hello message. + 2010-04-19 Werner Koch * system-w32.c (is_socket): New. Modified: trunk/src/assuan-listen.c =================================================================== --- trunk/src/assuan-listen.c 2010-04-20 10:52:43 UTC (rev 372) +++ trunk/src/assuan-listen.c 2010-04-22 15:51:01 UTC (rev 373) @@ -112,7 +112,18 @@ else if (p) rc = assuan_write_line (ctx, p); else - rc = assuan_write_line (ctx, "OK Pleased to meet you"); + { + static char const okstr[] = "OK Pleased to meet you"; + pid_t apid = assuan_get_pid (ctx); + if (apid != ASSUAN_INVALID_PID) + { + char tmpbuf[50]; + snprintf (tmpbuf, sizeof tmpbuf, "%s, process %i", okstr, (int)apid); + rc = assuan_write_line (ctx, tmpbuf); + } + else + rc = assuan_write_line (ctx, okstr); + } if (rc) return rc; From cvs at cvs.gnupg.org Fri Apr 23 03:59:08 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Fri, 23 Apr 2010 03:59:08 +0200 Subject: [svn] GnuPG - r5319 - trunk/sm Message-ID: Author: marcus Date: 2010-04-23 03:59:08 +0200 (Fri, 23 Apr 2010) New Revision: 5319 Modified: trunk/sm/ChangeLog trunk/sm/certreqgen.c Log: 2010-04-23 Marcus Brinkmann * certreqgen.c (read_parameters): Use ascii_isspace instead of spacep to stop at newline, too. Modified: trunk/sm/ChangeLog =================================================================== --- trunk/sm/ChangeLog 2010-04-22 14:59:25 UTC (rev 5318) +++ trunk/sm/ChangeLog 2010-04-23 01:59:08 UTC (rev 5319) @@ -1,3 +1,8 @@ +2010-04-23 Marcus Brinkmann + + * certreqgen.c (read_parameters): Use ascii_isspace instead of + spacep to stop at newline, too. + 2010-04-14 Werner Koch * gpgsm.c (main) [W32CE]: Disable dirmngr for now. Modified: trunk/sm/certreqgen.c =================================================================== --- trunk/sm/certreqgen.c 2010-04-22 14:59:25 UTC (rev 5318) +++ trunk/sm/certreqgen.c 2010-04-23 01:59:08 UTC (rev 5319) @@ -294,11 +294,11 @@ keyword = p; if (*keyword == '%') { - for (; *p && !spacep (p); p++) + for (; *p && !ascii_isspace (*p); p++) ; if (*p) *p++ = 0; - for (; spacep (p); p++) + for (; ascii_isspace (*p); p++) ; value = p; trim_trailing_spaces (value); From cvs at cvs.gnupg.org Fri Apr 23 13:37:00 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 23 Apr 2010 13:37:00 +0200 Subject: [svn] GnuPG - r5320 - in trunk: common g10 sm Message-ID: Author: wk Date: 2010-04-23 13:36:59 +0200 (Fri, 23 Apr 2010) New Revision: 5320 Modified: trunk/common/sexputil.c trunk/g10/ChangeLog trunk/g10/call-agent.c trunk/g10/call-agent.h trunk/g10/gpg.c trunk/g10/gpgv.c trunk/g10/keydb.c trunk/g10/keydb.h trunk/g10/keyedit.c trunk/g10/keylist.c trunk/g10/keyring.c trunk/g10/keyring.h trunk/g10/main.h trunk/g10/mainproc.c trunk/g10/photoid.c trunk/g10/photoid.h trunk/g10/pkclist.c trunk/g10/pubkey-enc.c trunk/g10/revoke.c trunk/g10/sign.c trunk/g10/skclist.c trunk/sm/call-agent.c Log: Decryption and signi via agent is now implemented. [The diff below has been truncated] Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2010-04-23 01:59:08 UTC (rev 5319) +++ trunk/g10/ChangeLog 2010-04-23 11:36:59 UTC (rev 5320) @@ -1,3 +1,33 @@ +2010-04-23 Werner Koch + + * pubkey-enc.c (get_it): Use the agent for decryption. + * call-agent.c (agent_pkdecrypt, inq_ciphertext_cb): New. + +2010-04-22 Werner Koch + + * photoid.c (show_photos): Remove arg SK. + + * pubkey-enc.c (get_session_key, get_it): Change to use the public + key object. + (get_it): Remove card related stuff. Now automagically handled + by the agent. + + * skclist.c (build_sk_list): Remove UNLOCK arg. + + * keylist.c (print_fingerprint): Remove arg SK. + * mainproc.c (list_node): Disable listing of secret key packets. + + * keyring.c (struct keyring_name, struct keyring_handle): Remove + field SECRET. + (keyring_register_filename, keyring_new, orename_tmp_file) + (do_copy): Remove arg SECRET. + * keydb.c (struct resource_item): Remove field SECRET. + (keydb_add_resource): Remove arg SECRET. + (keydb_new): Remove code fro secret keyrings. + + * gpg.c (main): Ignore --secret-keyring. Remove all secret + keyring related code. + 2010-04-21 Werner Koch * pkclist.c (default_recipient): Change to use public keys. Modified: trunk/common/sexputil.c =================================================================== --- trunk/common/sexputil.c 2010-04-23 01:59:08 UTC (rev 5319) +++ trunk/common/sexputil.c 2010-04-23 11:36:59 UTC (rev 5320) @@ -136,7 +136,7 @@ } -/* Create a simple S-expression from the hex string at LIBNE. Returns +/* Create a simple S-expression from the hex string at LINE. Returns a newly allocated buffer with that canonical encoded S-expression or NULL in case of an error. On return the number of characters scanned in LINE will be stored at NSCANNED. This fucntions stops Modified: trunk/g10/call-agent.c =================================================================== --- trunk/g10/call-agent.c 2010-04-23 01:59:08 UTC (rev 5319) +++ trunk/g10/call-agent.c 2010-04-23 11:36:59 UTC (rev 5320) @@ -50,8 +50,9 @@ struct cipher_parm_s { + ctrl_t ctrl; assuan_context_t ctx; - const char *ciphertext; + unsigned char *ciphertext; size_t ciphertextlen; }; @@ -104,7 +105,6 @@ - /* Try to connect to the agent via socket or fork it off and work by pipes. Handle the server's initial greeting */ static int @@ -1582,3 +1582,127 @@ } + +/* Handle a CIPHERTEXT inquiry. Note, we only send the data, + assuan_transact takes care of flushing and writing the END. */ +static gpg_error_t +inq_ciphertext_cb (void *opaque, const char *line) +{ + struct cipher_parm_s *parm = opaque; + int rc; + + if (!strncmp (line, "CIPHERTEXT", 10) && (line[10]==' '||!line[10])) + { + assuan_begin_confidential (parm->ctx); + rc = assuan_send_data (parm->ctx, parm->ciphertext, parm->ciphertextlen); + assuan_end_confidential (parm->ctx); + } + else + rc = default_inq_cb (parm->ctrl, line); + + return rc; +} + + +/* Call the agent to do a decrypt operation using the key identified + by the hex string KEYGRIP and the input data S_CIPHERTEXT. On the + success the decoded value is stored verbatim at R_BUF and its + length at R_BUF; the callers needs to release it. */ +gpg_error_t +agent_pkdecrypt (ctrl_t ctrl, const char *keygrip, const char *desc, + gcry_sexp_t s_ciphertext, + unsigned char **r_buf, size_t *r_buflen) +{ + gpg_error_t err; + char line[ASSUAN_LINELENGTH]; + membuf_t data; + size_t n, len; + char *p, *buf, *endp; + + if (!keygrip || strlen(keygrip) != 40 || !s_ciphertext || !r_buf || !r_buflen) + return gpg_error (GPG_ERR_INV_VALUE); + *r_buf = NULL; + + err = start_agent (ctrl, 0); + if (err) + return err; + + err = assuan_transact (agent_ctx, "RESET", + NULL, NULL, NULL, NULL, NULL, NULL); + if (err) + return err; + + snprintf (line, sizeof line, "SETKEY %s", keygrip); + err = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL); + if (err) + return err; + + if (desc) + { + snprintf (line, DIM(line)-1, "SETKEYDESC %s", desc); + line[DIM(line)-1] = 0; + err = assuan_transact (agent_ctx, line, + NULL, NULL, NULL, NULL, NULL, NULL); + if (err) + return err; + } + + init_membuf_secure (&data, 1024); + { + struct cipher_parm_s parm; + + parm.ctrl = ctrl; + parm.ctx = agent_ctx; + err = make_canon_sexp (s_ciphertext, &parm.ciphertext, &parm.ciphertextlen); + if (err) + return err; + err = assuan_transact (agent_ctx, "PKDECRYPT", + membuf_data_cb, &data, + inq_ciphertext_cb, &parm, NULL, NULL); + xfree (parm.ciphertext); + } + if (err) + { + xfree (get_membuf (&data, &len)); + return err; + } + + put_membuf (&data, "", 1); /* Make sure it is 0 terminated. */ + buf = get_membuf (&data, &len); + if (!buf) + return gpg_error_from_syserror (); + assert (len); /* (we forced Nul termination.) */ + + if (*buf != '(') + { + xfree (buf); + return gpg_error (GPG_ERR_INV_SEXP); + } + + if (len < 13 || memcmp (buf, "(5:value", 8) ) /* "(5:valueN:D)\0" */ + { + xfree (buf); + return gpg_error (GPG_ERR_INV_SEXP); + } + len -= 11; /* Count only the data of the second part. */ + p = buf + 8; /* Skip leading parenthesis and the value tag. */ + + n = strtoul (p, &endp, 10); + if (!n || *endp != ':') + { + xfree (buf); + return gpg_error (GPG_ERR_INV_SEXP); + } + endp++; + if (endp-p+n > len) + { + xfree (buf); + return gpg_error (GPG_ERR_INV_SEXP); /* Oops: Inconsistent S-Exp. */ + } + + memmove (buf, endp, n); + + *r_buflen = n; + *r_buf = buf; + return 0; +} Modified: trunk/g10/call-agent.h =================================================================== --- trunk/g10/call-agent.h 2010-04-23 01:59:08 UTC (rev 5319) +++ trunk/g10/call-agent.h 2010-04-23 11:36:59 UTC (rev 5320) @@ -158,6 +158,10 @@ int digestalgo, gcry_sexp_t *r_sigval); +/* Decrypt a ciphertext. */ +gpg_error_t agent_pkdecrypt (ctrl_t ctrl, const char *keygrip, const char *desc, + gcry_sexp_t s_ciphertext, + unsigned char **r_buf, size_t *r_buflen); #endif /*GNUPG_G10_CALL_AGENT_H*/ Modified: trunk/g10/gpg.c =================================================================== --- trunk/g10/gpg.c 2010-04-23 01:59:08 UTC (rev 5319) +++ trunk/g10/gpg.c 2010-04-23 11:36:59 UTC (rev 5320) @@ -1890,7 +1890,7 @@ char *username; int may_coredump; strlist_t sl, remusr= NULL, locusr=NULL; - strlist_t nrings=NULL, sec_nrings=NULL; + strlist_t nrings = NULL; armor_filter_context_t *afx = NULL; int detached_sig = 0; FILE *configfp = NULL; @@ -2283,8 +2283,9 @@ break; case oSecretKeyring: - append_to_strlist( &sec_nrings, pargs.r.ret_str); + /* Ignore this old option. */ break; + case oOptions: /* config files may not be nested (silently ignore them) */ if( !configfp ) { @@ -3385,22 +3386,12 @@ if( ALWAYS_ADD_KEYRINGS || (cmd != aDeArmor && cmd != aEnArmor && cmd != aGPGConfTest) ) { - if (ALWAYS_ADD_KEYRINGS - || (cmd != aCheckKeys && cmd != aListSigs && cmd != aListKeys - && cmd != aVerify && cmd != aSym && cmd != aLocateKeys)) - { - if (!sec_nrings || default_keyring) /* add default secret rings */ - keydb_add_resource ("secring" EXTSEP_S "gpg", 4, 1); - for (sl = sec_nrings; sl; sl = sl->next) - keydb_add_resource ( sl->d, 0, 1 ); - } - if( !nrings || default_keyring ) /* add default ring */ - keydb_add_resource ("pubring" EXTSEP_S "gpg", 4, 0); - for(sl = nrings; sl; sl = sl->next ) - keydb_add_resource ( sl->d, sl->flags, 0 ); + if (!nrings || default_keyring) /* Add default ring. */ + keydb_add_resource ("pubring" EXTSEP_S "gpg", 4); + for (sl = nrings; sl; sl = sl->next ) + keydb_add_resource (sl->d, sl->flags); } FREE_STRLIST(nrings); - FREE_STRLIST(sec_nrings); if (cmd == aGPGConfTest) g10_exit(0); Modified: trunk/g10/gpgv.c =================================================================== --- trunk/g10/gpgv.c 2010-04-23 01:59:08 UTC (rev 5319) +++ trunk/g10/gpgv.c 2010-04-23 11:36:59 UTC (rev 5320) @@ -196,9 +196,9 @@ /* Note: We open all keyrings in read-only mode (flag value: 8). */ if (!nrings) /* No keyring given: use default one. */ - keydb_add_resource ("trustedkeys" EXTSEP_S "gpg", 8, 0); + keydb_add_resource ("trustedkeys" EXTSEP_S "gpg", 8); for (sl = nrings; sl; sl = sl->next) - keydb_add_resource (sl->d, 8, 0 ); + keydb_add_resource (sl->d, 8); FREE_STRLIST (nrings); Modified: trunk/g10/keydb.c =================================================================== --- trunk/g10/keydb.c 2010-04-23 01:59:08 UTC (rev 5319) +++ trunk/g10/keydb.c 2010-04-23 11:36:59 UTC (rev 5320) @@ -45,13 +45,13 @@ } KeydbResourceType; #define MAX_KEYDB_RESOURCES 40 -struct resource_item { +struct resource_item +{ KeydbResourceType type; union { KEYRING_HANDLE kr; } u; void *token; - int secret; }; static struct resource_item all_resources[MAX_KEYDB_RESOURCES]; @@ -213,9 +213,9 @@ * Flag 8 - Open as read-only. */ int -keydb_add_resource (const char *url, int flags, int secret) +keydb_add_resource (const char *url, int flags) { - static int any_secret, any_public; + static int any_public; const char *resname = url; char *filename = NULL; int force = (flags&1); @@ -255,7 +255,7 @@ filename = xstrdup (resname); if (!force && !read_only) - force = secret? !any_secret : !any_public; + force = !any_public; /* See whether we can determine the filetype. */ if (rt == KEYDB_RESOURCE_TYPE_NONE) { @@ -289,7 +289,7 @@ if (rc) goto leave; - if(keyring_register_filename (filename, secret, read_only, &token)) + if(keyring_register_filename (filename, read_only, &token)) { if (used_resources >= MAX_KEYDB_RESOURCES) rc = G10ERR_RESOURCE_LIMIT; @@ -300,7 +300,6 @@ all_resources[used_resources].type = rt; all_resources[used_resources].u.kr = NULL; /* Not used here */ all_resources[used_resources].token = token; - all_resources[used_resources].secret = secret; used_resources++; } } @@ -324,22 +323,9 @@ leave: if (rc) - { - /* Secret keyrings are not required in all cases. To avoid - having gpg return failure we use log_info here if the - rewsource is a secret one and marked as default - resource. */ - if ((flags&4) && secret) - log_info (_("keyblock resource `%s': %s\n"), - filename, g10_errstr(rc)); - else - log_error (_("keyblock resource `%s': %s\n"), - filename, g10_errstr(rc)); - } - else if (secret) - any_secret = 1; + log_error (_("keyblock resource `%s': %s\n"), filename, g10_errstr(rc)); else - any_public = 1; + any_public = 1; xfree (filename); return rc; } @@ -352,7 +338,6 @@ { KEYDB_HANDLE hd; int i, j; - int secret = 0; /* FIXME: Remove the secret stuff all together. */ hd = xmalloc_clear (sizeof *hd); hd->found = -1; @@ -360,8 +345,6 @@ assert (used_resources <= MAX_KEYDB_RESOURCES); for (i=j=0; i < used_resources; i++) { - if (!all_resources[i].secret != !secret) - continue; switch (all_resources[i].type) { case KEYDB_RESOURCE_TYPE_NONE: /* ignore */ @@ -369,8 +352,7 @@ case KEYDB_RESOURCE_TYPE_KEYRING: hd->active[j].type = all_resources[i].type; hd->active[j].token = all_resources[i].token; - hd->active[j].secret = all_resources[i].secret; - hd->active[j].u.kr = keyring_new (all_resources[i].token, secret); + hd->active[j].u.kr = keyring_new (all_resources[i].token); if (!hd->active[j].u.kr) { xfree (hd); return NULL; /* fixme: release all previously allocated handles*/ @@ -706,8 +688,6 @@ for (i=0; i < used_resources; i++) { - if (all_resources[i].secret) - continue; if (!keyring_is_writable (all_resources[i].token)) continue; switch (all_resources[i].type) Modified: trunk/g10/keydb.h =================================================================== --- trunk/g10/keydb.h 2010-04-23 01:59:08 UTC (rev 5319) +++ trunk/g10/keydb.h 2010-04-23 11:36:59 UTC (rev 5320) @@ -132,7 +132,7 @@ Flag 1 == force Flag 2 == default */ -int keydb_add_resource (const char *url, int flags, int secret); +int keydb_add_resource (const char *url, int flags); KEYDB_HANDLE keydb_new (void); void keydb_release (KEYDB_HANDLE hd); const char *keydb_get_resource_name (KEYDB_HANDLE hd); @@ -173,7 +173,7 @@ int random_is_faked (void); void release_sk_list( SK_LIST sk_list ); gpg_error_t build_sk_list (strlist_t locusr, SK_LIST *ret_sk_list, - int unlock, unsigned use); + unsigned use); /*-- passphrase.h --*/ unsigned char encode_s2k_iterations (int iterations); Modified: trunk/g10/keyedit.c =================================================================== --- trunk/g10/keyedit.c 2010-04-23 01:59:08 UTC (rev 5319) +++ trunk/g10/keyedit.c 2010-04-23 11:36:59 UTC (rev 5320) @@ -557,7 +557,7 @@ * why to sign keys using a subkey. Implementation of USAGE_CERT * is just a hack in getkey.c and does not mean that a subkey * marked as certification capable will be used. */ - rc = build_sk_list (locusr, &sk_list, 0, PUBKEY_USAGE_CERT); + rc = build_sk_list (locusr, &sk_list, PUBKEY_USAGE_CERT); if (rc) goto leave; @@ -2686,7 +2686,7 @@ putchar ('a'); putchar ('\n'); - print_fingerprint (pk, NULL, 0); + print_fingerprint (pk, 0); print_revokers (pk); } } @@ -2970,7 +2970,7 @@ if (node->pkt->pkttype == PKT_PUBLIC_KEY && with_fpr) { - print_fingerprint (pk, NULL, 2); + print_fingerprint (pk, 2); tty_printf ("\n"); } } @@ -3047,7 +3047,7 @@ tty_printf (" "); tty_printf (_("expires: %s"), expirestr_from_pk (pk)); tty_printf ("\n"); - print_fingerprint (pk, NULL, 3); + print_fingerprint (pk, 3); tty_printf ("\n"); } else if (node->pkt->pkttype == PKT_SECRET_KEY) @@ -3061,7 +3061,8 @@ tty_printf (" "); tty_printf (_("expires: %s"), expirestr_from_sk (sk)); tty_printf ("\n"); - print_fingerprint (NULL, sk, 3); + log_debug ("FIXME\n"); + /* print_fingerprint (NULL, sk, 3); */ tty_printf ("\n"); } } @@ -3110,7 +3111,7 @@ } tty_printf ("\n"); if (pk) - print_fingerprint (pk, NULL, 2); + print_fingerprint (pk, 2); } @@ -3588,7 +3589,7 @@ } print_pubkey_info (NULL, revoker_pk); - print_fingerprint (revoker_pk, NULL, 2); + print_fingerprint (revoker_pk, 2); tty_printf ("\n"); tty_printf (_("WARNING: appointing a key as a designated revoker " @@ -5201,7 +5202,7 @@ "key %s (uid %d)\n"), image_type_to_string (type, 1), (ulong) size, keystr_from_pk (pk), count); - show_photos (&uid->attribs[i], 1, pk, NULL, uid); + show_photos (&uid->attribs[i], 1, pk, uid); } } } Modified: trunk/g10/keylist.c =================================================================== --- trunk/g10/keylist.c 2010-04-23 01:59:08 UTC (rev 5319) +++ trunk/g10/keylist.c 2010-04-23 11:36:59 UTC (rev 5320) @@ -817,7 +817,7 @@ es_fprintf (es_stdout, "\n"); if (fpr) - print_fingerprint (pk, NULL, 0); + print_fingerprint (pk, 0); /* FIXME: Change this function to take a PK and ask the agent: */ /* if (secret) print_card_serialno (sk); */ @@ -866,7 +866,7 @@ es_putc ('\n', es_stdout); if ((opt.list_options & LIST_SHOW_PHOTOS) && uid->attribs != NULL) - show_photos (uid->attribs, uid->numattribs, pk, NULL, uid); + show_photos (uid->attribs, uid->numattribs, pk, uid); } else if (node->pkt->pkttype == PKT_PUBLIC_SUBKEY) { @@ -911,7 +911,7 @@ es_putc ('\n', es_stdout); if (fpr > 1) { - print_fingerprint (pk2, NULL, 0); + print_fingerprint (pk2, 0); /* FIXME: (see above) */ /* if (secret) */ /* print_card_serialno (sk2); */ @@ -1127,7 +1127,7 @@ print_revokers (pk); if (fpr) - print_fingerprint (pk, NULL, 0); + print_fingerprint (pk, 0); if (opt.with_key_data) { if (!hexkeygrip_from_pk (pk, &p)) @@ -1232,7 +1232,7 @@ } es_putc ('\n', es_stdout); if (fpr > 1) - print_fingerprint (pk2, NULL, 0); + print_fingerprint (pk2, 0); if (opt.with_key_data) { if (!hexkeygrip_from_pk (pk2, &p)) @@ -1428,15 +1428,17 @@ } /* - * standard function to print the finperprint. + * Function to print the finperprint. * mode 0: as used in key listings, opt.with_colons is honored * 1: print using log_info () * 2: direct use of tty * 3: direct use of tty but only primary key. - * modes 1 and 2 will try and print both subkey and primary key fingerprints + * + * Modes 1 and 2 will try and print both subkey and primary key + * fingerprints. A MODE with bit 7 set is used internally. */ void -print_fingerprint (PKT_public_key * pk, PKT_secret_key * sk, int mode) +print_fingerprint (PKT_public_key *pk, int mode) { byte array[MAX_FINGERPRINT_LEN], *p; size_t i, n; @@ -1444,21 +1446,12 @@ const char *text; int primary = 0; - if (sk) - { - if (sk->main_keyid[0] == sk->keyid[0] - && sk->main_keyid[1] == sk->keyid[1]) - primary = 1; - } - else - { - if (pk->main_keyid[0] == pk->keyid[0] - && pk->main_keyid[1] == pk->keyid[1]) - primary = 1; - } + if (pk->main_keyid[0] == pk->keyid[0] + && pk->main_keyid[1] == pk->keyid[1]) + primary = 1; /* Just to be safe */ - if (mode & 0x80 && !primary) + if ((mode & 0x80) && !primary) { log_error ("primary key is not really primary!\n"); return; @@ -1468,20 +1461,10 @@ if (!primary && (mode == 1 || mode == 2)) { - if (sk) - { - PKT_secret_key *primary_sk = xmalloc_clear (sizeof (*primary_sk)); - get_seckey (primary_sk, sk->main_keyid); - print_fingerprint (NULL, primary_sk, mode | 0x80); - free_secret_key (primary_sk); - } - else - { - PKT_public_key *primary_pk = xmalloc_clear (sizeof (*primary_pk)); - get_pubkey (primary_pk, pk->main_keyid); - print_fingerprint (primary_pk, NULL, mode | 0x80); - free_public_key (primary_pk); - } + PKT_public_key *primary_pk = xmalloc_clear (sizeof (*primary_pk)); + get_pubkey (primary_pk, pk->main_keyid); + print_fingerprint (primary_pk, mode | 0x80); + free_public_key (primary_pk); } if (mode == 1) @@ -1513,10 +1496,7 @@ text = _(" Key fingerprint ="); } - if (sk) - fingerprint_from_sk (sk, array, &n); - else - fingerprint_from_pk (pk, array, &n); + fingerprint_from_pk (pk, array, &n); p = array; if (opt.with_colons && !mode) { Modified: trunk/g10/keyring.c =================================================================== --- trunk/g10/keyring.c 2010-04-23 01:59:08 UTC (rev 5319) +++ trunk/g10/keyring.c 2010-04-23 11:36:59 UTC (rev 5320) @@ -1,5 +1,5 @@ /* keyring.c - keyring file handling - * Copyright (C) 2001, 2004, 2009 Free Software Foundation, Inc. + * Copyright (C) 2001, 2004, 2009, 2010 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -53,7 +53,6 @@ struct keyring_name { struct keyring_name *next; - int secret; int read_only; dotlock_t lockhd; int is_locked; @@ -69,9 +68,9 @@ static int kr_offtbl_ready; -struct keyring_handle { +struct keyring_handle +{ CONST_KR_NAME resource; - int secret; /* this is for a secret keyring */ struct { CONST_KR_NAME kr; IOBUF iobuf; @@ -93,7 +92,7 @@ -static int do_copy (int mode, const char *fname, KBNODE root, int secret, +static int do_copy (int mode, const char *fname, KBNODE root, off_t start_offset, unsigned int n_packets ); @@ -201,8 +200,7 @@ * if a new keyring was registered. */ int -keyring_register_filename (const char *fname, int secret, int read_only, - void **ptr) +keyring_register_filename (const char *fname, int read_only, void **ptr) { KR_NAME kr; @@ -221,12 +219,8 @@ } } - if (secret) - register_secured_file (fname); - kr = xmalloc (sizeof *kr + strlen (fname)); strcpy (kr->fname, fname); - kr->secret = !!secret; kr->read_only = read_only; kr->lockhd = NULL; kr->is_locked = 0; @@ -254,21 +248,19 @@ -/* Create a new handle for the resource associated with TOKEN. SECRET - is just just as a cross-check. +/* Create a new handle for the resource associated with TOKEN. The returned handle must be released using keyring_release (). */ KEYRING_HANDLE -keyring_new (void *token, int secret) +keyring_new (void *token) { KEYRING_HANDLE hd; KR_NAME resource = token; - assert (resource && !resource->secret == !secret); + assert (resource); hd = xmalloc_clear (sizeof *hd); hd->resource = resource; - hd->secret = !!secret; active_handles++; return hd; } @@ -537,10 +529,10 @@ hd->current.iobuf = NULL; /* do the update */ - rc = do_copy (3, hd->found.kr->fname, kb, hd->secret, + rc = do_copy (3, hd->found.kr->fname, kb, hd->found.offset, hd->found.n_packets ); if (!rc) { - if (!hd->secret && kr_offtbl) + if (kr_offtbl) { update_offset_hash_table_from_kb (kr_offtbl, kb, 0); } @@ -585,8 +577,8 @@ hd->current.iobuf = NULL; /* do the insert */ - rc = do_copy (1, fname, kb, hd->secret, 0, 0 ); - if (!rc && !hd->secret && kr_offtbl) + rc = do_copy (1, fname, kb, 0, 0 ); + if (!rc && kr_offtbl) { update_offset_hash_table_from_kb (kr_offtbl, kb, 0); } @@ -625,7 +617,7 @@ hd->current.iobuf = NULL; /* do the delete */ - rc = do_copy (2, hd->found.kr->fname, NULL, hd->secret, + rc = do_copy (2, hd->found.kr->fname, NULL, hd->found.offset, hd->found.n_packets ); if (!rc) { /* better reset the found info */ @@ -953,7 +945,7 @@ if (rc) return rc; - use_offtbl = !hd->secret && kr_offtbl; + use_offtbl = !!kr_offtbl; if (!use_offtbl) ; else if (!kr_offtbl_ready) @@ -1148,11 +1140,10 @@ { KR_NAME kr; - /* First set the did_full_scan flag for this keyring (ignore - secret keyrings) */ + /* First set the did_full_scan flag for this keyring. */ for (kr=kr_names; kr; kr = kr->next) { - if (!kr->secret && hd->resource == kr) + if (hd->resource == kr) { kr->did_full_scan = 1; break; @@ -1162,7 +1153,7 @@ offtbl ready */ for (kr=kr_names; kr; kr = kr->next) { - if (!kr->secret && !kr->did_full_scan) + if (!kr->did_full_scan) break; } if (!kr) @@ -1247,20 +1238,10 @@ static int -rename_tmp_file (const char *bakfname, const char *tmpfname, - const char *fname, int secret ) +rename_tmp_file (const char *bakfname, const char *tmpfname, const char *fname) { int rc = 0; - /* It's a secret keyring, so let's force a fsync just to be safe on - filesystems that may not sync data and metadata together - (e.g. ext4). */ - if (secret && iobuf_ioctl (NULL, IOBUF_IOCTL_FSYNC, 0, (char*)tmpfname)) - { - rc = gpg_error_from_syserror (); - goto fail; - } - /* Invalidate close caches. */ if (iobuf_ioctl (NULL, IOBUF_IOCTL_INVALIDATE_CACHE, 0, (char*)tmpfname )) { @@ -1270,27 +1251,22 @@ iobuf_ioctl (NULL, IOBUF_IOCTL_INVALIDATE_CACHE, 0, (char*)bakfname ); iobuf_ioctl (NULL, IOBUF_IOCTL_INVALIDATE_CACHE, 0, (char*)fname ); - /* first make a backup file except for secret keyrings */ - if (!secret) - { + /* First make a backup file. */ #if defined(HAVE_DOSISH_SYSTEM) || defined(__riscos__) - gnupg_remove (bakfname); + gnupg_remove (bakfname); #endif - if (rename (fname, bakfname) ) - { - rc = gpg_error_from_syserror (); - log_error ("renaming `%s' to `%s' failed: %s\n", - fname, bakfname, strerror(errno) ); - return rc; - } + if (rename (fname, bakfname) ) + { + rc = gpg_error_from_syserror (); + log_error ("renaming `%s' to `%s' failed: %s\n", + fname, bakfname, strerror(errno) ); + return rc; } /* then rename the file */ #if defined(HAVE_DOSISH_SYSTEM) || defined(__riscos__) gnupg_remove( fname ); #endif - if (secret) - unregister_secured_file (fname); if (rename (tmpfname, fname) ) { rc = gpg_error_from_syserror (); @@ -1308,9 +1284,7 @@ statbuf.st_mode=S_IRUSR | S_IWUSR; - if (((secret && !opt.preserve_permissions) - || !stat (bakfname,&statbuf)) - && !chmod (fname,statbuf.st_mode)) + if (!stat (bakfname, &statbuf) && !chmod (fname, statbuf.st_mode)) ; else log_error ("WARNING: unable to restore permissions to `%s': %s", @@ -1321,13 +1295,6 @@ return 0; fail: - if (secret) - { - log_info(_("WARNING: 2 files with confidential information exists.\n")); - log_info(_("%s is the unchanged one\n"), fname ); - log_info(_("%s is the new one\n"), tmpfname ); - log_info(_("Please fix this possible security flaw\n")); - } return rc; } @@ -1392,7 +1359,7 @@ int rc; ulong count = 0, sigcount = 0; - hd = keyring_new (token, 0); + hd = keyring_new (token); memset (&desc, 0, sizeof desc); desc.mode = KEYDB_SEARCH_MODE_FIRST; @@ -1420,7 +1387,7 @@ tmpfp = NULL; } rc = lastresname? rename_tmp_file (bakfilename, tmpfilename, - lastresname, 0) : 0; + lastresname) : 0; xfree (tmpfilename); tmpfilename = NULL; xfree (bakfilename); bakfilename = NULL; if (rc) @@ -1513,7 +1480,7 @@ tmpfp = NULL; } rc = lastresname? rename_tmp_file (bakfilename, tmpfilename, - lastresname, 0) : 0; + lastresname) : 0; xfree (tmpfilename); tmpfilename = NULL; xfree (bakfilename); bakfilename = NULL; @@ -1536,7 +1503,7 @@ * 3 = update */ static int -do_copy (int mode, const char *fname, KBNODE root, int secret, +do_copy (int mode, const char *fname, KBNODE root, off_t start_offset, unsigned int n_packets ) { IOBUF fp, newfp; @@ -1556,7 +1523,7 @@ mode_t oldmask; oldmask=umask(077); - if (!secret && is_secured_filename (fname)) { + if (is_secured_filename (fname)) { newfp = NULL; gpg_err_set_errno (EPERM); } @@ -1602,8 +1569,6 @@ iobuf_close(fp); goto leave; } - if (secret) - register_secured_file (tmpfname); if( mode == 1 ) { /* insert */ /* copy everything to the new file */ @@ -1612,8 +1577,6 @@ log_error("%s: copy to `%s' failed: %s\n", fname, tmpfname, g10_errstr(rc) ); iobuf_close(fp); - if (secret) - unregister_secured_file (tmpfname); iobuf_cancel(newfp); goto leave; } @@ -1627,8 +1590,6 @@ log_error ("%s: copy to `%s' failed: %s\n", fname, tmpfname, g10_errstr(rc) ); iobuf_close(fp); - if (secret) - unregister_secured_file (tmpfname); iobuf_cancel(newfp); goto leave; } @@ -1639,8 +1600,6 @@ log_error("%s: skipping %u packets failed: %s\n", fname, n_packets, g10_errstr(rc)); iobuf_close(fp); - if (secret) - unregister_secured_file (tmpfname); iobuf_cancel(newfp); goto leave; } @@ -1650,8 +1609,6 @@ rc = write_keyblock (newfp, root); if (rc) { iobuf_close(fp); - if (secret) - unregister_secured_file (tmpfname); iobuf_cancel(newfp); goto leave; } @@ -1664,8 +1621,6 @@ log_error("%s: copy to `%s' failed: %s\n", fname, tmpfname, g10_errstr(rc) ); iobuf_close(fp); - if (secret) - unregister_secured_file (tmpfname); iobuf_cancel(newfp); goto leave; } @@ -1684,7 +1639,7 @@ goto leave; } - rc = rename_tmp_file (bakfname, tmpfname, fname, secret); + rc = rename_tmp_file (bakfname, tmpfname, fname); leave: xfree(bakfname); Modified: trunk/g10/keyring.h =================================================================== --- trunk/g10/keyring.h 2010-04-23 01:59:08 UTC (rev 5319) +++ trunk/g10/keyring.h 2010-04-23 11:36:59 UTC (rev 5320) @@ -24,11 +24,10 @@ typedef struct keyring_handle *KEYRING_HANDLE; -int keyring_register_filename (const char *fname, int secret, int read_only, - void **ptr); +int keyring_register_filename (const char *fname, int read_only, void **ptr); int keyring_is_writable (void *token); -KEYRING_HANDLE keyring_new (void *token, int secret); +KEYRING_HANDLE keyring_new (void *token); void keyring_release (KEYRING_HANDLE hd); const char *keyring_get_resource_name (KEYRING_HANDLE hd); int keyring_lock (KEYRING_HANDLE hd, int yes); Modified: trunk/g10/main.h =================================================================== --- trunk/g10/main.h 2010-04-23 01:59:08 UTC (rev 5319) +++ trunk/g10/main.h 2010-04-23 11:36:59 UTC (rev 5320) @@ -305,7 +305,7 @@ void print_subpackets_colon(PKT_signature *sig); void reorder_keyblock (KBNODE keyblock); void list_keyblock( KBNODE keyblock, int secret, int fpr, void *opaque ); -void print_fingerprint (PKT_public_key *pk, PKT_secret_key *sk, int mode); +void print_fingerprint (PKT_public_key *pk, int mode); void print_revokers(PKT_public_key *pk); void show_policy_url(PKT_signature *sig,int indent,int mode); void show_keyserver_url(PKT_signature *sig,int indent,int mode); Modified: trunk/g10/mainproc.c =================================================================== --- trunk/g10/mainproc.c 2010-04-23 01:59:08 UTC (rev 5319) +++ trunk/g10/mainproc.c 2010-04-23 11:36:59 UTC (rev 5320) @@ -939,7 +939,7 @@ if( node->next && node->next->pkt->pkttype == PKT_RING_TRUST) { putchar('\n'); any=1; if( opt.fingerprint ) - print_fingerprint( pk, NULL, 0 ); + print_fingerprint (pk, 0); printf("rtv:1:%u:\n", node->next->pkt->pkt.ring_trust->trustval ); } @@ -976,7 +976,7 @@ putchar(':'); putchar('\n'); if( opt.fingerprint && !any ) - print_fingerprint( pk, NULL, 0 ); + print_fingerprint ( pk, 0 ); if( opt.with_colons && node->next && node->next->pkt->pkttype == PKT_RING_TRUST ) { @@ -1015,71 +1015,75 @@ if( !any ) putchar('\n'); if( !mainkey && opt.fingerprint > 1 ) - print_fingerprint( pk, NULL, 0 ); + print_fingerprint( pk, 0 ); } else if( (mainkey = (node->pkt->pkttype == PKT_SECRET_KEY) ) || node->pkt->pkttype == PKT_SECRET_SUBKEY ) { - PKT_secret_key *sk = node->pkt->pkt.secret_key; - if( opt.with_colons ) - { - u32 keyid[2]; - keyid_from_sk( sk, keyid ); - printf("%s::%u:%d:%08lX%08lX:%s:%s:::", - mainkey? "sec":"ssb", - nbits_from_sk( sk ), - sk->pubkey_algo, - (ulong)keyid[0],(ulong)keyid[1], - colon_datestr_from_sk( sk ), - colon_strtime (sk->expiredate) - /* fixme: add LID */ ); - } - else - printf("%s %4u%c/%s %s ", mainkey? "sec":"ssb", - nbits_from_sk( sk ), pubkey_letter( sk->pubkey_algo ), - keystr_from_sk( sk ), datestr_from_sk( sk )); - if( mainkey ) { - /* and now list all userids with their signatures */ - for( node = node->next; node; node = node->next ) { - if( node->pkt->pkttype == PKT_SIGNATURE ) { - if( !any ) { - if( node->pkt->pkt.signature->sig_class == 0x20 ) - puts("[revoked]"); - else - putchar('\n'); - any = 1; - } - list_node(c, node ); - } - else if( node->pkt->pkttype == PKT_USER_ID ) { - if( any ) { - if( opt.with_colons ) - printf("%s:::::::::", - node->pkt->pkt.user_id->attrib_data?"uat":"uid"); - else - printf( "uid%*s", 28, "" ); - } - print_userid( node->pkt ); - if( opt.with_colons ) - putchar(':'); - putchar('\n'); - if( opt.fingerprint && !any ) - print_fingerprint( NULL, sk, 0 ); - any=1; - } - else if( node->pkt->pkttype == PKT_SECRET_SUBKEY ) { - if( !any ) { - putchar('\n'); - any = 1; - } - list_node(c, node ); - } - } - } - if( !any ) - putchar('\n'); - if( !mainkey && opt.fingerprint > 1 ) - print_fingerprint( NULL, sk, 0 ); + log_debug ("FIXME: No way to print secret key packets here\n"); + /* fixme: We may use a fucntion to trun a secret key packet into + a public key one and use that here. */ + /* PKT_secret_key *sk = node->pkt->pkt.secret_key; */ + + /* if( opt.with_colons ) */ + /* { */ + /* u32 keyid[2]; */ + /* keyid_from_sk( sk, keyid ); */ + /* printf("%s::%u:%d:%08lX%08lX:%s:%s:::", */ + /* mainkey? "sec":"ssb", */ + /* nbits_from_sk( sk ), */ + /* sk->pubkey_algo, */ + /* (ulong)keyid[0],(ulong)keyid[1], */ + /* colon_datestr_from_sk( sk ), */ + /* colon_strtime (sk->expiredate) */ + /* /\* fixme: add LID *\/ ); */ + /* } */ + /* else */ + /* printf("%s %4u%c/%s %s ", mainkey? "sec":"ssb", */ + /* nbits_from_sk( sk ), pubkey_letter( sk->pubkey_algo ), */ + /* keystr_from_sk( sk ), datestr_from_sk( sk )); */ + /* if( mainkey ) { */ + /* /\* and now list all userids with their signatures *\/ */ + /* for( node = node->next; node; node = node->next ) { */ + /* if( node->pkt->pkttype == PKT_SIGNATURE ) { */ + /* if( !any ) { */ + /* if( node->pkt->pkt.signature->sig_class == 0x20 ) */ + /* puts("[revoked]"); */ + /* else */ + /* putchar('\n'); */ + /* any = 1; */ + /* } */ + /* list_node(c, node ); */ + /* } */ + /* else if( node->pkt->pkttype == PKT_USER_ID ) { */ + /* if( any ) { */ + /* if( opt.with_colons ) */ + /* printf("%s:::::::::", */ + /* node->pkt->pkt.user_id->attrib_data?"uat":"uid"); */ + /* else */ + /* printf( "uid%*s", 28, "" ); */ + /* } */ + /* print_userid( node->pkt ); */ + /* if( opt.with_colons ) */ + /* putchar(':'); */ + /* putchar('\n'); */ + /* if( opt.fingerprint && !any ) */ + /* print_fingerprint( NULL, sk, 0 ); */ + /* any=1; */ + /* } */ + /* else if( node->pkt->pkttype == PKT_SECRET_SUBKEY ) { */ + /* if( !any ) { */ + /* putchar('\n'); */ + /* any = 1; */ + /* } */ + /* list_node(c, node ); */ + /* } */ + /* } */ + /* } */ + /* if( !any ) */ + /* putchar('\n'); */ + /* if( !mainkey && opt.fingerprint > 1 ) */ + /* print_fingerprint( NULL, sk, 0 ); */ } else if( node->pkt->pkttype == PKT_SIGNATURE ) { PKT_signature *sig = node->pkt->pkt.signature; @@ -1848,7 +1852,7 @@ if(opt.verify_options&VERIFY_SHOW_PHOTOS) show_photos(un->pkt->pkt.user_id->attribs, un->pkt->pkt.user_id->numattribs, - pk,NULL,un->pkt->pkt.user_id); + pk ,un->pkt->pkt.user_id); } p=utf8_to_native(un->pkt->pkt.user_id->name, Modified: trunk/g10/photoid.c =================================================================== --- trunk/g10/photoid.c 2010-04-23 01:59:08 UTC (rev 5319) +++ trunk/g10/photoid.c 2010-04-23 11:36:59 UTC (rev 5320) @@ -161,7 +161,7 @@ "user" may not be able to dismiss a viewer window! */ if(opt.command_fd==-1) { - show_photos(uid->attribs,uid->numattribs,pk,NULL,uid); + show_photos (uid->attribs, uid->numattribs, pk, uid); switch(cpr_get_answer_yes_no_quit("photoid.jpeg.okay", _("Is this photo correct (y/N/q)? "))) { @@ -285,9 +285,8 @@ #endif void -show_photos(const struct user_attribute *attrs, - int count,PKT_public_key *pk,PKT_secret_key *sk, - PKT_user_id *uid) +show_photos(const struct user_attribute *attrs, int count, + PKT_public_key *pk, PKT_user_id *uid) { #ifndef DISABLE_PHOTO_VIEWER int i; @@ -295,16 +294,13 @@ u32 len; u32 kid[2]={0,0}; - memset(&args,0,sizeof(args)); - args.pk=pk; - args.pksk=sk; - args.validity_info=get_validity_info(pk,uid); - args.validity_string=get_validity_string(pk,uid); + memset (&args, 0, sizeof(args)); + args.pk = pk; + args.validity_info = get_validity_info (pk, uid); + args.validity_string = get_validity_string (pk, uid); - if(pk) - keyid_from_pk(pk,kid); - else if(sk) - keyid_from_sk(sk,kid); + if (pk) + keyid_from_pk (pk, kid); for(i=0;ipkt->pkt.user_id->attrib_data) - show_photos(un->pkt->pkt.user_id->attribs, - un->pkt->pkt.user_id->numattribs,pk,NULL, - un->pkt->pkt.user_id); + show_photos (un->pkt->pkt.user_id->attribs, + un->pkt->pkt.user_id->numattribs, pk, + un->pkt->pkt.user_id); p=utf8_to_native(un->pkt->pkt.user_id->name, un->pkt->pkt.user_id->len,0); @@ -256,7 +256,7 @@ tty_printf(_(" aka \"%s\"\n"),p); } - print_fingerprint (pk, NULL, 2); + print_fingerprint (pk, 2); tty_printf("\n"); release_kbnode (keyblock); } @@ -464,7 +464,7 @@ if( !opt.batch && !rc ) { print_pubkey_info(NULL,pk); - print_fingerprint (pk, NULL, 2); + print_fingerprint (pk, 2); tty_printf("\n"); tty_printf( @@ -523,7 +523,7 @@ if( !opt.quiet ) log_info(_("WARNING: Using untrusted key!\n")); if (opt.with_fingerprint) - print_fingerprint (pk, NULL, 1); + print_fingerprint (pk, 1); goto leave; } @@ -611,7 +611,7 @@ { case TRUST_EXPIRED: log_info(_("Note: This key has expired!\n")); - print_fingerprint (pk, NULL, 1); + print_fingerprint (pk, 1); break; default: @@ -625,7 +625,7 @@ " a trusted signature!\n")); log_info(_(" There is no indication that the " "signature belongs to the owner.\n" )); - print_fingerprint (pk, NULL, 1); + print_fingerprint (pk, 1); break; case TRUST_NEVER: @@ -634,7 +634,7 @@ log_info(_("WARNING: We do NOT trust this key!\n")); log_info(_(" The signature is probably a FORGERY.\n")); if (opt.with_fingerprint) - print_fingerprint (pk, NULL, 1); + print_fingerprint (pk, 1); rc = gpg_error (GPG_ERR_BAD_SIGNATURE); break; @@ -644,19 +644,19 @@ " sufficiently trusted signatures!\n")); log_info(_(" It is not certain that the" " signature belongs to the owner.\n" )); - print_fingerprint (pk, NULL, 1); + print_fingerprint (pk, 1); break; case TRUST_FULLY: write_status( STATUS_TRUST_FULLY ); if (opt.with_fingerprint) - print_fingerprint (pk, NULL, 1); + print_fingerprint (pk, 1); break; case TRUST_ULTIMATE: write_status( STATUS_TRUST_ULTIMATE ); if (opt.with_fingerprint) - print_fingerprint (pk, NULL, 1); + print_fingerprint (pk, 1); break; } Modified: trunk/g10/pubkey-enc.c =================================================================== --- trunk/g10/pubkey-enc.c 2010-04-23 01:59:08 UTC (rev 5319) +++ trunk/g10/pubkey-enc.c 2010-04-23 11:36:59 UTC (rev 5320) @@ -39,7 +39,7 @@ static gpg_error_t get_it (PKT_pubkey_enc *k, - DEK *dek, PKT_secret_key *sk, u32 *keyid); + DEK *dek, PKT_public_key *sk, u32 *keyid); /* Check that the given algo is mentioned in one of the valid user-ids. */ @@ -74,7 +74,7 @@ gpg_error_t get_session_key (PKT_pubkey_enc * k, DEK * dek) { - PKT_secret_key *sk = NULL; + PKT_public_key *sk = NULL; int rc; rc = openpgp_pk_test_algo2 (k->pubkey_algo, PUBKEY_USAGE_ENC); @@ -84,7 +84,7 @@ if ((k->keyid[0] || k->keyid[1]) && !opt.try_all_secrets) { sk = xmalloc_clear (sizeof *sk); - sk->pubkey_algo = k->pubkey_algo; /* We want a pubkey with this algo */ + sk->pubkey_algo = k->pubkey_algo; /* We want a pubkey with this algo. */ if (!(rc = get_seckey (sk, k->keyid))) rc = get_it (k, dek, sk, k->keyid); } @@ -99,9 +99,9 @@ for (;;) { if (sk) - free_secret_key (sk); + free_public_key (sk); sk = xmalloc_clear (sizeof *sk); - rc = enum_secret_keys (&enum_context, sk, 1, 0); + rc = -1; /* FIXME:enum_secret_keys (&enum_context, sk, 1, 0);*/ if (rc) { rc = G10ERR_NO_SECKEY; @@ -109,7 +109,7 @@ } if (sk->pubkey_algo != k->pubkey_algo) continue; - keyid_from_sk (sk, keyid); + keyid_from_pk (sk, keyid); log_info (_("anonymous recipient; trying secret key %s ...\n"), keystr (keyid)); @@ -149,64 +149,60 @@ leave: if (sk) - free_secret_key (sk); + free_public_key (sk); return rc; } static gpg_error_t -get_it (PKT_pubkey_enc *enc, DEK *dek, PKT_secret_key *sk, u32 *keyid) +get_it (PKT_pubkey_enc *enc, DEK *dek, PKT_public_key *sk, u32 *keyid) { - int rc; - gcry_mpi_t plain_dek = NULL; + gpg_error_t err; byte *frame = NULL; unsigned int n; size_t nframe; u16 csum, csum2; - int card = 0; + gcry_sexp_t s_data; + char *desc; + char *keygrip; - if (sk->is_protected && sk->protect.s2k.mode == 1002) - { /* Note, that we only support RSA for now. */ -#ifdef ENABLE_CARD_SUPPORT - unsigned char *rbuf; - size_t rbuflen; - char *snbuf; - unsigned char *indata = NULL; - size_t indatalen; + /* Get the keygrip. */ + err = hexkeygrip_from_pk (sk, &keygrip); + if (err) + goto leave; - snbuf = - serialno_and_fpr_from_sk (sk->protect.iv, sk->protect.ivlen, sk); - - if (gcry_mpi_aprint - (GCRYMPI_FMT_USG, &indata, &indatalen, enc->data[0])) - BUG (); - - rc = agent_scd_pkdecrypt (snbuf, indata, indatalen, &rbuf, &rbuflen); - xfree (snbuf); - xfree (indata); - if (rc) - goto leave; - - frame = rbuf; - nframe = rbuflen; - card = 1; -#else - rc = gpg_error (GPG_ERR_NOT_SUPPORTED); - goto leave; -#endif /*!ENABLE_CARD_SUPPORT */ + /* Convert the data to an S-expression. */ + if (sk->pubkey_algo == GCRY_PK_ELG || sk->pubkey_algo == GCRY_PK_ELG_E) + { + if (!enc->data[0] || !enc->data[1]) + err = gpg_error (GPG_ERR_BAD_MPI); + else + err = gcry_sexp_build (&s_data, NULL, "(enc-val(elg(a%m)(b%m)))", + enc->data[0], enc->data[1]); } - else + else if (sk->pubkey_algo == GCRY_PK_RSA || sk->pubkey_algo == GCRY_PK_RSA_E) { - rc = pk_decrypt (sk->pubkey_algo, &plain_dek, enc->data, sk->skey); - if (rc) - goto leave; - if (gcry_mpi_aprint (GCRYMPI_FMT_USG, &frame, &nframe, plain_dek)) - BUG (); - gcry_mpi_release (plain_dek); - plain_dek = NULL; + if (!enc->data[0]) + err = gpg_error (GPG_ERR_BAD_MPI); + else + err = gcry_sexp_build (&s_data, NULL, "(enc-val(rsa(a%m)))", + enc->data[0]); } + else + err = gpg_error (GPG_ERR_BUG); + if (err) + goto leave; + + /* Decrypt. */ + desc = xtrystrdup ("FIXME: Format a description"); + err = agent_pkdecrypt (NULL, keygrip, desc, s_data, &frame, &nframe); + xfree (desc); + gcry_sexp_release (s_data); + if (err) + goto leave; + /* Now get the DEK (data encryption key) from the frame * * Old versions encode the DEK in in this format (msb is left): @@ -231,18 +227,18 @@ { if (n + 7 > nframe) { - rc = G10ERR_WRONG_SECKEY; + err = gpg_error (G10ERR_WRONG_SECKEY); goto leave; } if (frame[n] == 1 && frame[nframe - 1] == 2) { log_info (_("old encoding of the DEK is not supported\n")); - rc = G10ERR_CIPHER_ALGO; + err = gpg_error (G10ERR_CIPHER_ALGO); goto leave; } - if (frame[n] != 2) /* Somethink is wrong. */ + if (frame[n] != 2) /* Something went wrong. */ { - rc = G10ERR_WRONG_SECKEY; + err = gpg_error (G10ERR_WRONG_SECKEY); goto leave; } for (n++; n < nframe && frame[n]; n++) /* Skip the random bytes. */ @@ -252,7 +248,7 @@ if (n + 4 > nframe) { - rc = G10ERR_WRONG_SECKEY; + err = gpg_error (G10ERR_WRONG_SECKEY); goto leave; } @@ -260,10 +256,10 @@ dek->algo = frame[n++]; From cvs at cvs.gnupg.org Mon Apr 26 13:53:15 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 26 Apr 2010 13:53:15 +0200 Subject: [svn] GnuPG - r5321 - in trunk: common g10 Message-ID: Author: wk Date: 2010-04-26 13:53:14 +0200 (Mon, 26 Apr 2010) New Revision: 5321 Modified: trunk/common/ChangeLog trunk/common/init.c trunk/common/utf8conv.c trunk/g10/ChangeLog trunk/g10/decrypt.c trunk/g10/keygen.c trunk/g10/seckey-cert.c Log: Fix preference setting in new keys Modified: trunk/common/ChangeLog =================================================================== --- trunk/common/ChangeLog 2010-04-23 11:36:59 UTC (rev 5320) +++ trunk/common/ChangeLog 2010-04-26 11:53:14 UTC (rev 5321) @@ -1,3 +1,10 @@ +2010-04-26 Werner Koch + + * utf8conv.c (load_libiconv) [W32CE]: No libiconv warning + + * init.c (init_common_subsystems) [W32CE]: Register the sleep + function before es_init. + 2010-04-20 Werner Koch * estream.c (es_deinit): New. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2010-04-23 11:36:59 UTC (rev 5320) +++ trunk/g10/ChangeLog 2010-04-26 11:53:14 UTC (rev 5321) @@ -1,3 +1,9 @@ +2010-04-26 Werner Koch + + * keygen.c (keygen_set_std_prefs): Explicitly include Z0 in the + default preferences if no compression algorithms are available. + Remove a possible trailing space in the dummy_string. + 2010-04-23 Werner Koch * pubkey-enc.c (get_it): Use the agent for decryption. Modified: trunk/common/init.c =================================================================== --- trunk/common/init.c 2010-04-23 11:36:59 UTC (rev 5320) +++ trunk/common/init.c 2010-04-26 11:53:14 UTC (rev 5321) @@ -73,13 +73,21 @@ # ifdef HAVE_PTH pth_init (); # else - { - WSADATA wsadat; - - WSAStartup (0x202, &wsadat); - } + { + WSADATA wsadat; + + WSAStartup (0x202, &wsadat); + } # endif /*!HAVE_PTH*/ #endif + +#ifdef HAVE_W32CE_SYSTEM + /* Register the sleep exit function before the estream init so that + the sleep will be called after the estream registered atexit + function which flushes the left open estream streams and in + particular es_stdout. */ + atexit (sleep_on_exit); +#endif /* Initialize the Estream library. */ es_init (); @@ -87,7 +95,6 @@ /* Special hack for Windows CE: We extract some options from arg to setup the standard handles. */ #ifdef HAVE_W32CE_SYSTEM - atexit (sleep_on_exit); parse_std_file_handles (argcp, argvp); #else (void)argcp; Modified: trunk/common/utf8conv.c =================================================================== --- trunk/common/utf8conv.c 2010-04-23 11:36:59 UTC (rev 5320) +++ trunk/common/utf8conv.c 2010-04-26 11:53:14 UTC (rev 5321) @@ -62,6 +62,10 @@ static int load_libiconv (void) { +#ifdef HAVE_W32CE_SYSTEM + return -1; /* FIXME No libiconv yet - Need to investigate whether it + is at all required. */ +#else static int done; if (!done) @@ -94,6 +98,7 @@ } } return iconv_open? 0: -1; +#endif } #endif /*HAVE_W32_SYSTEM*/ Modified: trunk/g10/decrypt.c =================================================================== --- trunk/g10/decrypt.c 2010-04-23 11:36:59 UTC (rev 5320) +++ trunk/g10/decrypt.c 2010-04-26 11:53:14 UTC (rev 5321) @@ -132,7 +132,7 @@ } #ifdef HAVE_W32CE_SYSTEM -#warning Ned to fix this +#warning Need to fix this opt.outfp = NULL; #else opt.outfp = fdopen (dup (output_fd), "wb"); Modified: trunk/g10/keygen.c =================================================================== --- trunk/g10/keygen.c 2010-04-23 11:36:59 UTC (rev 5320) +++ trunk/g10/keygen.c 2010-04-26 11:53:14 UTC (rev 5321) @@ -315,6 +315,7 @@ string=opt.def_preference_list; else { + int any_compress = 0; dummy_string[0]='\0'; /* The rationale why we use the order AES256,192,128 is @@ -375,14 +376,32 @@ strcat (dummy_string, "H11 "); if(!check_compress_algo(COMPRESS_ALGO_ZLIB)) - strcat(dummy_string,"Z2 "); + { + strcat(dummy_string,"Z2 "); + any_compress = 1; + } if(!check_compress_algo(COMPRESS_ALGO_BZIP2)) - strcat(dummy_string,"Z3 "); + { + strcat(dummy_string,"Z3 "); + any_compress = 1; + } if(!check_compress_algo(COMPRESS_ALGO_ZIP)) - strcat(dummy_string,"Z1"); + { + strcat(dummy_string,"Z1 "); + any_compress = 1; + } + + /* In case we have no compress algo at all, declare that + we prefer no compresssion. */ + if (!any_compress) + strcat(dummy_string,"Z0 "); + /* Remove the trailing space. */ + if (*dummy_string && dummy_string[strlen (dummy_string)-1] == ' ') + dummy_string[strlen (dummy_string)-1] = 0; + string=dummy_string; } } Modified: trunk/g10/seckey-cert.c =================================================================== --- trunk/g10/seckey-cert.c 2010-04-23 11:36:59 UTC (rev 5320) +++ trunk/g10/seckey-cert.c 2010-04-26 11:53:14 UTC (rev 5321) @@ -35,6 +35,7 @@ #include "status.h" #include "pkglue.h" +#if 0 /* Not anymore used - kept for reference. */ static int do_check( PKT_secret_key *sk, const char *tryagain_text, int mode, int *canceled ) @@ -256,9 +257,9 @@ return 0; } +#endif /*0*/ - /**************** * check whether the secret key is protected. * Returns: 0 not protected, -1 on error or the protection algorithm From cvs at cvs.gnupg.org Mon Apr 26 16:51:39 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 26 Apr 2010 16:51:39 +0200 Subject: [svn] GnuPG - r5322 - trunk/agent Message-ID: Author: wk Date: 2010-04-26 16:51:38 +0200 (Mon, 26 Apr 2010) New Revision: 5322 Modified: trunk/agent/ChangeLog trunk/agent/gpg-agent.c Log: Ignore a stale agent socket. Modified: trunk/agent/ChangeLog =================================================================== --- trunk/agent/ChangeLog 2010-04-26 11:53:14 UTC (rev 5321) +++ trunk/agent/ChangeLog 2010-04-26 14:51:38 UTC (rev 5322) @@ -1,3 +1,7 @@ +2010-04-26 Werner Koch + + * gpg-agent.c (create_server_socket) [W32]: Also check for EEXIST. + 2010-04-19 Werner Koch * pksign.c (get_dsa_qbits, do_encode_dsa): New. Modified: trunk/agent/gpg-agent.c =================================================================== --- trunk/agent/gpg-agent.c 2010-04-26 11:53:14 UTC (rev 5321) +++ trunk/agent/gpg-agent.c 2010-04-26 14:51:38 UTC (rev 5322) @@ -1493,7 +1493,15 @@ strcpy (serv_addr->sun_path, name); len = SUN_LEN (serv_addr); rc = assuan_sock_bind (fd, (struct sockaddr*) serv_addr, len); - if (use_standard_socket && rc == -1 && errno == EADDRINUSE) + + /* Our error code mapping on W32CE returns EEXIST thus we also test + for this. */ + if (use_standard_socket && rc == -1 + && (errno == EADDRINUSE +#ifdef HAVE_W32_SYSTEM + || errno == EEXIST +#endif + )) { /* Check whether a gpg-agent is already running on the standard socket. We do this test only if this is not the ssh socket. From cvs at cvs.gnupg.org Mon Apr 26 19:37:28 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 26 Apr 2010 19:37:28 +0200 Subject: [svn] pinentry - r229 - in trunk: . gtk+-2 Message-ID: Author: wk Date: 2010-04-26 19:37:27 +0200 (Mon, 26 Apr 2010) New Revision: 229 Modified: trunk/ChangeLog trunk/gtk+-2/pinentry-gtk-2.c Log: Do not use g_error but return cancel. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-04-20 14:37:05 UTC (rev 228) +++ trunk/ChangeLog 2010-04-26 17:37:27 UTC (rev 229) @@ -1,3 +1,9 @@ +2010-04-26 Werner Koch + + * gtk+-2/pinentry-gtk-2.c (grab_failed): New. + (grab_keyboard): s/g_error/g_critical/. Set GRAB_FAILED. + (gtk_cmd_handler): Return Cancel if a grab failed. + 2010-04-20 Marcus Brinkmann * pinentry/pinentry.c: Move include config.h to top! Modified: trunk/gtk+-2/pinentry-gtk-2.c =================================================================== --- trunk/gtk+-2/pinentry-gtk-2.c 2010-04-20 14:37:05 UTC (rev 228) +++ trunk/gtk+-2/pinentry-gtk-2.c 2010-04-26 17:37:27 UTC (rev 229) @@ -52,6 +52,7 @@ #endif static pinentry_t pinentry; +static int grab_failed; static int passphrase_ok; typedef enum { CONFIRM_CANCEL, CONFIRM_OK, CONFIRM_NOTOK } confirm_value_t; static confirm_value_t confirm_value; @@ -135,7 +136,11 @@ return; if (gdk_keyboard_grab (win->window, FALSE, gdk_event_get_time (event))) - g_error ("could not grab keyboard"); + { + g_critical ("could not grab keyboard"); + grab_failed = 1; + gtk_main_quit (); + } } @@ -520,7 +525,7 @@ while (gtk_events_pending ()) gtk_main_iteration (); - if (confirm_value == CONFIRM_CANCEL) + if (confirm_value == CONFIRM_CANCEL || grab_failed) pe->canceled = 1; pinentry = NULL; From cvs at cvs.gnupg.org Tue Apr 27 05:04:56 2010 From: cvs at cvs.gnupg.org (svn author marcus) Date: Tue, 27 Apr 2010 05:04:56 +0200 Subject: [svn] gcry - r1432 - trunk/random Message-ID: Author: marcus Date: 2010-04-27 05:04:56 +0200 (Tue, 27 Apr 2010) New Revision: 1432 Modified: trunk/random/ChangeLog trunk/random/rndw32ce.c Log: 2010-04-27 Marcus Brinkmann * rndw32ce.c (fillup_buffer): Rewrite without using nested functions, which are broken on arm/cegcc. Modified: trunk/random/ChangeLog =================================================================== --- trunk/random/ChangeLog 2010-04-19 17:15:03 UTC (rev 1431) +++ trunk/random/ChangeLog 2010-04-27 03:04:56 UTC (rev 1432) @@ -1,3 +1,8 @@ +2010-04-27 Marcus Brinkmann + + * rndw32ce.c (fillup_buffer): Rewrite without using nested + functions, which are broken on arm/cegcc. + 2010-04-12 Brad Hards (wk) Spelling fixes. Modified: trunk/random/rndw32ce.c =================================================================== --- trunk/random/rndw32ce.c 2010-04-19 17:15:03 UTC (rev 1431) +++ trunk/random/rndw32ce.c 2010-04-27 03:04:56 UTC (rev 1432) @@ -34,27 +34,33 @@ some extra random. We do this, despite that it is a questionable suggestion as the OS as better means of collecting entropy than an application. */ +static size_t filler_used; +static size_t filler_length; +static unsigned char *filler_buffer; + static void +filler (const void *data, size_t datalen, enum random_origins dummy) +{ + (void)dummy; + if (filler_used + datalen > filler_length) + datalen = filler_length - filler_used; + memcpy (filler_buffer + filler_used, data, datalen); + filler_used += datalen; +} + + +static void fillup_buffer (unsigned char *buffer, size_t length) { - size_t used = 0; + filler_used = 0; + filler_length = length; + filler_buffer = buffer; - /* This code uses gcc anyway, thus we can use a nested function. */ - void filler (const void *data, size_t datalen, enum random_origins dummy) - { - (void)dummy; - if (used + datalen > length) - datalen = length - used; - memcpy (buffer+used, data, datalen); - used += datalen; - } - - while (used < length) + while (filler_used < length) _gcry_rndw32ce_gather_random_fast (filler, 0); } - int _gcry_rndw32ce_gather_random (void (*add)(const void*, size_t, enum random_origins), From cvs at cvs.gnupg.org Tue Apr 27 16:11:42 2010 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 27 Apr 2010 16:11:42 +0200 Subject: [svn] GnuPG - r5323 - trunk/g10 Message-ID: Author: wk Date: 2010-04-27 16:11:41 +0200 (Tue, 27 Apr 2010) New Revision: 5323 Modified: trunk/g10/ChangeLog trunk/g10/keydb.h trunk/g10/passphrase.c trunk/g10/pubkey-enc.c trunk/g10/sign.c Log: Provide a useful pinentry prompt. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2010-04-26 14:51:38 UTC (rev 5322) +++ trunk/g10/ChangeLog 2010-04-27 14:11:41 UTC (rev 5323) @@ -1,3 +1,9 @@ +2010-04-27 Werner Koch + + * passphrase.c (gpg_format_keydesc): New. + * pubkey-enc.c (get_it): Use it. + * sign.c (do_sign): Use it. + 2010-04-26 Werner Koch * keygen.c (keygen_set_std_prefs): Explicitly include Z0 in the Modified: trunk/g10/keydb.h =================================================================== --- trunk/g10/keydb.h 2010-04-26 14:51:38 UTC (rev 5322) +++ trunk/g10/keydb.h 2010-04-27 14:11:41 UTC (rev 5323) @@ -195,6 +195,9 @@ char *get_last_passphrase(void); void next_to_last_passphrase(void); +char *gpg_format_keydesc (PKT_public_key *pk, int escaped); + + /*-- getkey.c --*/ void cache_public_key( PKT_public_key *pk ); void getkey_disable_caches(void); Modified: trunk/g10/passphrase.c =================================================================== --- trunk/g10/passphrase.c 2010-04-26 14:51:38 UTC (rev 5322) +++ trunk/g10/passphrase.c 2010-04-27 14:11:41 UTC (rev 5323) @@ -683,3 +683,57 @@ s2k, mode, tryagain_text, NULL, NULL, canceled); } + + +/* Return an allocated utf-8 string describing the key PK. IF ESCAPED + is true spaces and control characters are percent or plus + escaped. */ +char * +gpg_format_keydesc (PKT_public_key *pk, int escaped) +{ + char *uid; + size_t uidlen; + const char *algo_name; + const char *timestr; + char *orig_codeset; + char *maink; + char *desc; + + algo_name = gcry_pk_algo_name (pk->pubkey_algo); + if (!algo_name) + algo_name = "?"; + timestr = strtimestamp (pk->timestamp); + uid = get_user_id (pk->keyid, &uidlen); + + orig_codeset = i18n_switchto_utf8 (); + + if (pk->main_keyid[2] && pk->main_keyid[3] + && pk->keyid[0] != pk->main_keyid[2] + && pk->keyid[1] != pk->main_keyid[3]) + maink = xtryasprintf (_(" (main key ID %s)"), keystr (pk->main_keyid)); + else + maink = NULL; + + desc = xtryasprintf (_("Please enter the passphrase to unlock the" + " secret key for the OpenPGP certificate:\n" + "\"%.*s\"\n" + "%u-bit %s key, ID %s,\n" + "created %s%s.\n"), + (int)uidlen, uid, + nbits_from_pk (pk), algo_name, + keystr (pk->keyid), timestr, + maink?maink:"" ); + xfree (maink); + xfree (uid); + + i18n_switchback (orig_codeset); + + if (escaped) + { + char *tmp = percent_plus_escape (desc); + xfree (desc); + desc = tmp; + } + + return desc; +} Modified: trunk/g10/pubkey-enc.c =================================================================== --- trunk/g10/pubkey-enc.c 2010-04-26 14:51:38 UTC (rev 5322) +++ trunk/g10/pubkey-enc.c 2010-04-27 14:11:41 UTC (rev 5323) @@ -196,7 +196,7 @@ goto leave; /* Decrypt. */ - desc = xtrystrdup ("FIXME: Format a description"); + desc = gpg_format_keydesc (sk, 1); err = agent_pkdecrypt (NULL, keygrip, desc, s_data, &frame, &nframe); xfree (desc); gcry_sexp_release (s_data); Modified: trunk/g10/sign.c =================================================================== --- trunk/g10/sign.c 2010-04-26 14:51:38 UTC (rev 5322) +++ trunk/g10/sign.c 2010-04-27 14:11:41 UTC (rev 5323) @@ -313,13 +313,10 @@ char *desc; gcry_sexp_t s_sigval; - /* FIXME: desc = gpgsm_format_keydesc (cert); */ - desc = xtrystrdup ("FIXME: Format a description"); - + desc = gpg_format_keydesc (pksk, 1); err = agent_pksign (NULL/*ctrl*/, hexgrip, desc, dp, gcry_md_get_algo_dlen (mdalgo), mdalgo, &s_sigval); - xfree (desc); if (err)