aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Shaw <[email protected]>2002-05-13 20:44:30 +0000
committerDavid Shaw <[email protected]>2002-05-13 20:44:30 +0000
commit435ecaa5b0c9a2185abb0df737f90cc7f2df7343 (patch)
tree3c24b386563adb7d4d82f2d7ef75de733420a9f7
parent* mainproc.c (proc_symkey_enc): Avoid segv in case the parser (diff)
downloadgnupg-435ecaa5b0c9a2185abb0df737f90cc7f2df7343.tar.gz
gnupg-435ecaa5b0c9a2185abb0df737f90cc7f2df7343.zip
* photoid.c (show_photos): Use the long keyid as the filename for the
photo. Use the short keyid as the filename on 8.3 systems. * exec.h, exec.c (make_tempdir, exec_write, exec_finish): Allow caller to specify filename. This should make things easier on windows and macs where the file extension is required, but a whole filename is even better. * keyedit.c (show_key_with_all_names, show_prefs): Show proper prefs for a v4 key uid with no selfsig at all. * misc.c (check_permissions): Don't check permissions on non-normal files (pipes, character devices, etc.)
-rw-r--r--g10/ChangeLog16
-rw-r--r--g10/exec.c28
-rw-r--r--g10/exec.h4
-rw-r--r--g10/keyedit.c9
-rw-r--r--g10/misc.c8
-rw-r--r--g10/photoid.c38
6 files changed, 73 insertions, 30 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index 804945eb3..b5ac0b6e4 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,19 @@
+2002-05-13 David Shaw <[email protected]>
+
+ * photoid.c (show_photos): Use the long keyid as the filename for
+ the photo. Use the short keyid as the filename on 8.3 systems.
+
+ * exec.h, exec.c (make_tempdir, exec_write, exec_finish): Allow
+ caller to specify filename. This should make things easier on
+ windows and macs where the file extension is required, but a whole
+ filename is even better.
+
+ * keyedit.c (show_key_with_all_names, show_prefs): Show proper
+ prefs for a v4 key uid with no selfsig at all.
+
+ * misc.c (check_permissions): Don't check permissions on
+ non-normal files (pipes, character devices, etc.)
+
2002-05-11 Werner Koch <[email protected]>
* mainproc.c (proc_symkey_enc): Avoid segv in case the parser
diff --git a/g10/exec.c b/g10/exec.c
index a51ccde1d..520aef908 100644
--- a/g10/exec.c
+++ b/g10/exec.c
@@ -61,10 +61,10 @@ char *mkdtemp(char *template);
/* Makes a temp directory and filenames */
static int make_tempdir(struct exec_info *info)
{
- char *tmp=opt.temp_dir,*ext=info->ext;
+ char *tmp=opt.temp_dir,*name=info->name;
- if(!ext)
- ext=info->binary?"bin":"txt";
+ if(!name)
+ name=info->binary?"tempfile.bin":"tempfile.txt";
/* Make up the temp dir and files in case we need them */
@@ -118,17 +118,15 @@ static int make_tempdir(struct exec_info *info)
{
info->madedir=1;
- info->tempfile_in=m_alloc(strlen(info->tempdir)+strlen(DIRSEP_S)+6+
- strlen(EXTSEP_S)+strlen(ext)+1);
- sprintf(info->tempfile_in,"%s" DIRSEP_S "datain" EXTSEP_S "%s",
- info->tempdir,ext);
+ info->tempfile_in=m_alloc(strlen(info->tempdir)+
+ strlen(DIRSEP_S)+strlen(name)+1);
+ sprintf(info->tempfile_in,"%s" DIRSEP_S "%s",info->tempdir,name);
if(!info->writeonly)
{
- info->tempfile_out=m_alloc(strlen(info->tempdir)+strlen(DIRSEP_S)+7+
- strlen(EXTSEP_S)+strlen(ext)+1);
- sprintf(info->tempfile_out,"%s" DIRSEP_S "dataout" EXTSEP_S "%s",
- info->tempdir,ext);
+ info->tempfile_out=m_alloc(strlen(info->tempdir)+
+ strlen(DIRSEP_S)+strlen(name)+1);
+ sprintf(info->tempfile_out,"%s" DIRSEP_S "%s",info->tempdir,name);
}
}
@@ -239,7 +237,7 @@ static int expand_args(struct exec_info *info,const char *args_in)
shell -c. If there are tempfiles, then it's a system. */
int exec_write(struct exec_info **info,const char *program,
- const char *args_in,const char *ext,int writeonly,int binary)
+ const char *args_in,const char *name,int writeonly,int binary)
{
int ret=G10ERR_GENERAL;
@@ -263,8 +261,8 @@ int exec_write(struct exec_info **info,const char *program,
*info=m_alloc_clear(sizeof(struct exec_info));
- if(ext)
- (*info)->ext=m_strdup(ext);
+ if(name)
+ (*info)->name=m_strdup(name);
(*info)->binary=binary;
(*info)->writeonly=writeonly;
@@ -508,7 +506,7 @@ int exec_finish(struct exec_info *info)
}
m_free(info->command);
- m_free(info->ext);
+ m_free(info->name);
m_free(info->tempdir);
m_free(info->tempfile_in);
m_free(info->tempfile_out);
diff --git a/g10/exec.h b/g10/exec.h
index 876081778..2e0be460b 100644
--- a/g10/exec.h
+++ b/g10/exec.h
@@ -11,11 +11,11 @@ struct exec_info
pid_t child;
FILE *tochild;
IOBUF fromchild;
- char *command,*ext,*tempdir,*tempfile_in,*tempfile_out;
+ char *command,*name,*tempdir,*tempfile_in,*tempfile_out;
};
int exec_write(struct exec_info **info,const char *program,
- const char *args_in,const char *ext,int writeonly,int binary);
+ const char *args_in,const char *name,int writeonly,int binary);
int exec_read(struct exec_info *info);
int exec_finish(struct exec_info *info);
diff --git a/g10/keyedit.c b/g10/keyedit.c
index f86ec3663..79c8ba6c7 100644
--- a/g10/keyedit.c
+++ b/g10/keyedit.c
@@ -1424,7 +1424,7 @@ show_prefs (PKT_user_id *uid, int verbose)
if( uid->prefs )
prefs=uid->prefs;
- else if(uid->selfsigversion>=4 && verbose)
+ else if(verbose)
prefs=&fake;
else
return;
@@ -1544,6 +1544,7 @@ show_key_with_all_names( KBNODE keyblock, int only_marked, int with_revoker,
KBNODE node;
int i, rc;
int do_warn = 0;
+ byte pk_version=0;
/* the keys */
for( node = keyblock; node; node = node->next ) {
@@ -1566,6 +1567,8 @@ show_key_with_all_names( KBNODE keyblock, int only_marked, int with_revoker,
did_warn = 1;
do_warn = 1;
}
+
+ pk_version=pk->version;
}
if(with_revoker) {
@@ -1660,7 +1663,7 @@ show_key_with_all_names( KBNODE keyblock, int only_marked, int with_revoker,
tty_printf ("[revoked] ");
tty_print_utf8_string( uid->name, uid->len );
tty_printf("\n");
- if( with_prefs )
+ if( with_prefs && (pk_version>3 || uid->selfsigversion>3))
show_prefs (uid, with_prefs == 2);
}
}
@@ -1668,7 +1671,7 @@ show_key_with_all_names( KBNODE keyblock, int only_marked, int with_revoker,
if (do_warn)
tty_printf (_("Please note that the shown key validity "
- "is not necessary correct\n"
+ "is not necessarily correct\n"
"unless you restart the program.\n"));
}
diff --git a/g10/misc.c b/g10/misc.c
index c9322d9ef..6f535c4ff 100644
--- a/g10/misc.c
+++ b/g10/misc.c
@@ -368,6 +368,14 @@ check_permissions(const char *path,int extension,int checkonly)
goto end;
}
+ /* We may have to revisit this if we start piping keyrings to gpg
+ over a named pipe or keyserver character device :) */
+ if(!S_ISREG(statbuf.st_mode))
+ {
+ ret=0;
+ goto end;
+ }
+
isdir=S_ISDIR(statbuf.st_mode);
/* Per-user files must be owned by the user. Extensions must be
diff --git a/g10/photoid.c b/g10/photoid.c
index 7a769b711..d696c761c 100644
--- a/g10/photoid.c
+++ b/g10/photoid.c
@@ -220,33 +220,51 @@ void show_photos(const struct user_attribute *attrs,
int i;
struct expando_args args;
u32 len;
+ u32 kid[2];
memset(&args,0,sizeof(args));
args.pk=pk;
+ keyid_from_pk(pk,kid);
+
for(i=0;i<count;i++)
if(attrs[i].type==ATTRIB_IMAGE &&
parse_image_header(&attrs[i],&args.imagetype,&len))
{
- char *command;
+ char *command,*name;
struct exec_info *spawn;
int offset=attrs[i].len-len;
- /* Notice we are not using the byte for image encoding type
- for more than cosmetics. Most external image viewers can
- handle a multitude of types, and even if one cannot
- understand a partcular type, we have no way to know which.
- The spec specifically permits this, by the way. -dms */
-
/* make command grow */
command=pct_expando(opt.photo_viewer?
opt.photo_viewer:DEFAULT_PHOTO_COMMAND,&args);
if(!command)
goto fail;
- if(exec_write(&spawn,NULL,command,
- image_type_to_string(args.imagetype,0),1,1)!=0)
- goto fail;
+ name=m_alloc(16+strlen(EXTSEP_S)+
+ strlen(image_type_to_string(args.imagetype,0))+1);
+
+ /* Make the filename. Notice we are not using the image
+ encoding type for more than cosmetics. Most external image
+ viewers can handle a multitude of types, and even if one
+ cannot understand a partcular type, we have no way to know
+ which. The spec permits this, by the way. -dms */
+
+#ifdef USE_ONLY_8DOT3
+ sprintf(name,"%08lX" EXTSEP_S "%s",(ulong)kid[1],
+ image_type_to_string(args.imagetype,0));
+#else
+ sprintf(name,"%08lX%08lX" EXTSEP_S "%s",(ulong)kid[0],(ulong)kid[1],
+ image_type_to_string(args.imagetype,0));
+#endif
+
+ if(exec_write(&spawn,NULL,command,name,1,1)!=0)
+ {
+ m_free(name);
+ goto fail;
+ }
+
+ m_free(name);
fwrite(&attrs[i].data[offset],attrs[i].len-offset,1,spawn->tochild);