mirror of
git://git.gnupg.org/gnupg.git
synced 2025-06-14 18:31:03 +02:00
* 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.)
This commit is contained in:
parent
0a66b9aaae
commit
435ecaa5b0
@ -1,3 +1,19 @@
|
|||||||
|
2002-05-13 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
|
* 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 <wk@gnupg.org>
|
2002-05-11 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
* mainproc.c (proc_symkey_enc): Avoid segv in case the parser
|
* mainproc.c (proc_symkey_enc): Avoid segv in case the parser
|
||||||
|
28
g10/exec.c
28
g10/exec.c
@ -61,10 +61,10 @@ char *mkdtemp(char *template);
|
|||||||
/* Makes a temp directory and filenames */
|
/* Makes a temp directory and filenames */
|
||||||
static int make_tempdir(struct exec_info *info)
|
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)
|
if(!name)
|
||||||
ext=info->binary?"bin":"txt";
|
name=info->binary?"tempfile.bin":"tempfile.txt";
|
||||||
|
|
||||||
/* Make up the temp dir and files in case we need them */
|
/* 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->madedir=1;
|
||||||
|
|
||||||
info->tempfile_in=m_alloc(strlen(info->tempdir)+strlen(DIRSEP_S)+6+
|
info->tempfile_in=m_alloc(strlen(info->tempdir)+
|
||||||
strlen(EXTSEP_S)+strlen(ext)+1);
|
strlen(DIRSEP_S)+strlen(name)+1);
|
||||||
sprintf(info->tempfile_in,"%s" DIRSEP_S "datain" EXTSEP_S "%s",
|
sprintf(info->tempfile_in,"%s" DIRSEP_S "%s",info->tempdir,name);
|
||||||
info->tempdir,ext);
|
|
||||||
|
|
||||||
if(!info->writeonly)
|
if(!info->writeonly)
|
||||||
{
|
{
|
||||||
info->tempfile_out=m_alloc(strlen(info->tempdir)+strlen(DIRSEP_S)+7+
|
info->tempfile_out=m_alloc(strlen(info->tempdir)+
|
||||||
strlen(EXTSEP_S)+strlen(ext)+1);
|
strlen(DIRSEP_S)+strlen(name)+1);
|
||||||
sprintf(info->tempfile_out,"%s" DIRSEP_S "dataout" EXTSEP_S "%s",
|
sprintf(info->tempfile_out,"%s" DIRSEP_S "%s",info->tempdir,name);
|
||||||
info->tempdir,ext);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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. */
|
shell -c. If there are tempfiles, then it's a system. */
|
||||||
|
|
||||||
int exec_write(struct exec_info **info,const char *program,
|
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;
|
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));
|
*info=m_alloc_clear(sizeof(struct exec_info));
|
||||||
|
|
||||||
if(ext)
|
if(name)
|
||||||
(*info)->ext=m_strdup(ext);
|
(*info)->name=m_strdup(name);
|
||||||
(*info)->binary=binary;
|
(*info)->binary=binary;
|
||||||
(*info)->writeonly=writeonly;
|
(*info)->writeonly=writeonly;
|
||||||
|
|
||||||
@ -508,7 +506,7 @@ int exec_finish(struct exec_info *info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_free(info->command);
|
m_free(info->command);
|
||||||
m_free(info->ext);
|
m_free(info->name);
|
||||||
m_free(info->tempdir);
|
m_free(info->tempdir);
|
||||||
m_free(info->tempfile_in);
|
m_free(info->tempfile_in);
|
||||||
m_free(info->tempfile_out);
|
m_free(info->tempfile_out);
|
||||||
|
@ -11,11 +11,11 @@ struct exec_info
|
|||||||
pid_t child;
|
pid_t child;
|
||||||
FILE *tochild;
|
FILE *tochild;
|
||||||
IOBUF fromchild;
|
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,
|
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_read(struct exec_info *info);
|
||||||
int exec_finish(struct exec_info *info);
|
int exec_finish(struct exec_info *info);
|
||||||
|
|
||||||
|
@ -1424,7 +1424,7 @@ show_prefs (PKT_user_id *uid, int verbose)
|
|||||||
|
|
||||||
if( uid->prefs )
|
if( uid->prefs )
|
||||||
prefs=uid->prefs;
|
prefs=uid->prefs;
|
||||||
else if(uid->selfsigversion>=4 && verbose)
|
else if(verbose)
|
||||||
prefs=&fake;
|
prefs=&fake;
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
@ -1544,6 +1544,7 @@ show_key_with_all_names( KBNODE keyblock, int only_marked, int with_revoker,
|
|||||||
KBNODE node;
|
KBNODE node;
|
||||||
int i, rc;
|
int i, rc;
|
||||||
int do_warn = 0;
|
int do_warn = 0;
|
||||||
|
byte pk_version=0;
|
||||||
|
|
||||||
/* the keys */
|
/* the keys */
|
||||||
for( node = keyblock; node; node = node->next ) {
|
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;
|
did_warn = 1;
|
||||||
do_warn = 1;
|
do_warn = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pk_version=pk->version;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(with_revoker) {
|
if(with_revoker) {
|
||||||
@ -1660,7 +1663,7 @@ show_key_with_all_names( KBNODE keyblock, int only_marked, int with_revoker,
|
|||||||
tty_printf ("[revoked] ");
|
tty_printf ("[revoked] ");
|
||||||
tty_print_utf8_string( uid->name, uid->len );
|
tty_print_utf8_string( uid->name, uid->len );
|
||||||
tty_printf("\n");
|
tty_printf("\n");
|
||||||
if( with_prefs )
|
if( with_prefs && (pk_version>3 || uid->selfsigversion>3))
|
||||||
show_prefs (uid, with_prefs == 2);
|
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)
|
if (do_warn)
|
||||||
tty_printf (_("Please note that the shown key validity "
|
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"));
|
"unless you restart the program.\n"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -368,6 +368,14 @@ check_permissions(const char *path,int extension,int checkonly)
|
|||||||
goto end;
|
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);
|
isdir=S_ISDIR(statbuf.st_mode);
|
||||||
|
|
||||||
/* Per-user files must be owned by the user. Extensions must be
|
/* Per-user files must be owned by the user. Extensions must be
|
||||||
|
@ -220,33 +220,51 @@ void show_photos(const struct user_attribute *attrs,
|
|||||||
int i;
|
int i;
|
||||||
struct expando_args args;
|
struct expando_args args;
|
||||||
u32 len;
|
u32 len;
|
||||||
|
u32 kid[2];
|
||||||
|
|
||||||
memset(&args,0,sizeof(args));
|
memset(&args,0,sizeof(args));
|
||||||
args.pk=pk;
|
args.pk=pk;
|
||||||
|
|
||||||
|
keyid_from_pk(pk,kid);
|
||||||
|
|
||||||
for(i=0;i<count;i++)
|
for(i=0;i<count;i++)
|
||||||
if(attrs[i].type==ATTRIB_IMAGE &&
|
if(attrs[i].type==ATTRIB_IMAGE &&
|
||||||
parse_image_header(&attrs[i],&args.imagetype,&len))
|
parse_image_header(&attrs[i],&args.imagetype,&len))
|
||||||
{
|
{
|
||||||
char *command;
|
char *command,*name;
|
||||||
struct exec_info *spawn;
|
struct exec_info *spawn;
|
||||||
int offset=attrs[i].len-len;
|
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 */
|
/* make command grow */
|
||||||
command=pct_expando(opt.photo_viewer?
|
command=pct_expando(opt.photo_viewer?
|
||||||
opt.photo_viewer:DEFAULT_PHOTO_COMMAND,&args);
|
opt.photo_viewer:DEFAULT_PHOTO_COMMAND,&args);
|
||||||
if(!command)
|
if(!command)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if(exec_write(&spawn,NULL,command,
|
name=m_alloc(16+strlen(EXTSEP_S)+
|
||||||
image_type_to_string(args.imagetype,0),1,1)!=0)
|
strlen(image_type_to_string(args.imagetype,0))+1);
|
||||||
goto fail;
|
|
||||||
|
/* 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);
|
fwrite(&attrs[i].data[offset],attrs[i].len-offset,1,spawn->tochild);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user