Photo UIDs on --attribute-fd on Windows and strange LF->CRLF
conversions
David Shaw
dshaw at jabberwocky.com
Wed Aug 3 22:19:25 CEST 2005
On Wed, Aug 03, 2005 at 06:39:39PM +0200, Michael Schierl wrote:
> (sorry for the private mail, David. I guess I have to read more mailing
> lists to remember clicking the "reply to all" button...)
>
> David Shaw schrieb:
>
> > The problem here is twofold - first, you can't dump jpegs that way.
> > You'll end up with garbage because it'll be mixed up with the key
> > listings themselves. The second problem is related to the first -
> > you're dumping to stdout, and stdout on windows does textmode
> > conversion by default.
>
> Hmm. For that "I can't do it that way" it works surprisingly well :)
It's a miracle... ;)
Seriously, you're doing a lot of extra work to parse around the
non-attribute data there.
> > To make this work, you need to use a fd that isn't stdout, or
> > something like "--attribute-file new.dat"
>
> Other fds (except stderr, which has the same problem I guess, and stdin,
> which is only writable) are not available from Java AFAIK (at least not
> platform-independently); and when using »--attribute-file new2.dat« I
> got the same CRLF mangling :(
That should not happen. Try the attached patch.
David
-------------- next part --------------
Index: g10.c
===================================================================
--- g10.c (revision 3847)
+++ g10.c (working copy)
@@ -937,7 +937,7 @@
might like it too. Prints an error message and returns -1 on
error. On success the file descriptor is returned. */
static int
-open_info_file (const char *fname, int for_write)
+open_info_file (const char *fname, int for_write, int binary)
{
#ifdef __riscos__
return riscos_fdopenfile (fname, for_write);
@@ -962,7 +962,8 @@
{
if (for_write)
fd = open (fname, O_CREAT | O_TRUNC | O_WRONLY,
- S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP
+ | (binary?MY_O_BINARY:0));
else
fd = open (fname, O_RDONLY | MY_O_BINARY);
}
@@ -1996,20 +1997,20 @@
set_status_fd( iobuf_translate_file_handle (pargs.r.ret_int, 1) );
break;
case oStatusFile:
- set_status_fd ( open_info_file (pargs.r.ret_str, 1) );
+ set_status_fd ( open_info_file (pargs.r.ret_str, 1, 0) );
break;
case oAttributeFD:
set_attrib_fd(iobuf_translate_file_handle (pargs.r.ret_int, 1));
break;
case oAttributeFile:
- set_attrib_fd ( open_info_file (pargs.r.ret_str, 1) );
+ set_attrib_fd ( open_info_file (pargs.r.ret_str, 1, 1) );
break;
case oLoggerFD:
log_set_logfile( NULL,
iobuf_translate_file_handle (pargs.r.ret_int, 1));
break;
case oLoggerFile:
- log_set_logfile( NULL, open_info_file (pargs.r.ret_str, 1) );
+ log_set_logfile( NULL, open_info_file (pargs.r.ret_str, 1, 0) );
break;
case oWithFingerprint:
@@ -2275,13 +2276,13 @@
opt.use_agent = 0;
break;
case oPasswdFile:
- pwfd = open_info_file (pargs.r.ret_str, 0);
+ pwfd = open_info_file (pargs.r.ret_str, 0, 0);
break;
case oCommandFD:
opt.command_fd = iobuf_translate_file_handle (pargs.r.ret_int, 0);
break;
case oCommandFile:
- opt.command_fd = open_info_file (pargs.r.ret_str, 0);
+ opt.command_fd = open_info_file (pargs.r.ret_str, 0, 0);
break;
case oCipherAlgo:
def_cipher_string = xstrdup(pargs.r.ret_str);
More information about the Gnupg-devel
mailing list