mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-23 10:29:58 +01:00
* g10.c: New options --[no-]mangle-dos-filenames.
* options.h (opt): Added mangle-dos-filenames. * openfile.c (open_outfile) [USE_ONLY_8DOT3]: Truncate the filename only when this option is set; this is the default. NOT YET TESTED!
This commit is contained in:
parent
1ae9261ef6
commit
9a34b607ab
@ -1,3 +1,10 @@
|
|||||||
|
2002-12-05 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* g10.c: New options --[no-]mangle-dos-filenames.
|
||||||
|
* options.h (opt): Added mangle-dos-filenames.
|
||||||
|
* openfile.c (open_outfile) [USE_ONLY_8DOT3]: Truncate the
|
||||||
|
filename only when this option is set; this is the default.
|
||||||
|
|
||||||
2002-12-04 David Shaw <dshaw@jabberwocky.com>
|
2002-12-04 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
* main.h, keyedit.c, keygen.c: Back out previous (2002-12-01)
|
* main.h, keyedit.c, keygen.c: Back out previous (2002-12-01)
|
||||||
|
29
g10/g10.c
29
g10/g10.c
@ -149,13 +149,9 @@ enum cmd_and_opt_values { aNull = 0,
|
|||||||
oDebug,
|
oDebug,
|
||||||
oDebugAll,
|
oDebugAll,
|
||||||
oStatusFD,
|
oStatusFD,
|
||||||
#ifdef __riscos__
|
oStatusFile, /* only used with risc os */
|
||||||
oStatusFile,
|
|
||||||
#endif /* __riscos__ */
|
|
||||||
oAttributeFD,
|
oAttributeFD,
|
||||||
#ifdef __riscos__
|
oAttributeFile, /* only used with risc os */
|
||||||
oAttributeFile,
|
|
||||||
#endif /* __riscos__ */
|
|
||||||
oSKComments,
|
oSKComments,
|
||||||
oNoSKComments,
|
oNoSKComments,
|
||||||
oNoVersion,
|
oNoVersion,
|
||||||
@ -179,13 +175,9 @@ enum cmd_and_opt_values { aNull = 0,
|
|||||||
oCertDigestAlgo,
|
oCertDigestAlgo,
|
||||||
oCompressAlgo,
|
oCompressAlgo,
|
||||||
oPasswdFD,
|
oPasswdFD,
|
||||||
#ifdef __riscos__
|
oPasswdFile, /* only used with risc os */
|
||||||
oPasswdFile,
|
|
||||||
#endif /* __riscos__ */
|
|
||||||
oCommandFD,
|
oCommandFD,
|
||||||
#ifdef __riscos__
|
oCommandFile, /* only used with risc os */
|
||||||
oCommandFile,
|
|
||||||
#endif /* __riscos__ */
|
|
||||||
oQuickRandom,
|
oQuickRandom,
|
||||||
oNoVerbose,
|
oNoVerbose,
|
||||||
oTrustDBName,
|
oTrustDBName,
|
||||||
@ -251,9 +243,7 @@ enum cmd_and_opt_values { aNull = 0,
|
|||||||
oEncryptTo,
|
oEncryptTo,
|
||||||
oNoEncryptTo,
|
oNoEncryptTo,
|
||||||
oLoggerFD,
|
oLoggerFD,
|
||||||
#ifdef __riscos__
|
oLoggerFile, /* only used with risc os */
|
||||||
oLoggerFile,
|
|
||||||
#endif /* __riscos__ */
|
|
||||||
oUtf8Strings,
|
oUtf8Strings,
|
||||||
oNoUtf8Strings,
|
oNoUtf8Strings,
|
||||||
oDisableCipherAlgo,
|
oDisableCipherAlgo,
|
||||||
@ -304,6 +294,8 @@ enum cmd_and_opt_values { aNull = 0,
|
|||||||
oGroup,
|
oGroup,
|
||||||
oStrict,
|
oStrict,
|
||||||
oNoStrict,
|
oNoStrict,
|
||||||
|
oMangleDosFilenames,
|
||||||
|
oNoMangleDosFilenames,
|
||||||
aTest };
|
aTest };
|
||||||
|
|
||||||
|
|
||||||
@ -597,6 +589,8 @@ static ARGPARSE_OPTS opts[] = {
|
|||||||
{ oGroup, "group", 2, "@" },
|
{ oGroup, "group", 2, "@" },
|
||||||
{ oStrict, "strict", 0, "@" },
|
{ oStrict, "strict", 0, "@" },
|
||||||
{ oNoStrict, "no-strict", 0, "@" },
|
{ oNoStrict, "no-strict", 0, "@" },
|
||||||
|
{ oMangleDosFilenames, "mangle-dos-filenames", 0, "@" },
|
||||||
|
{ oNoMangleDosFilenames, "no-mangle-dos-filenames", 0, "@" },
|
||||||
{0} };
|
{0} };
|
||||||
|
|
||||||
|
|
||||||
@ -1112,6 +1106,7 @@ main( int argc, char **argv )
|
|||||||
EXPORT_INCLUDE_NON_RFC|EXPORT_INCLUDE_ATTRIBUTES;
|
EXPORT_INCLUDE_NON_RFC|EXPORT_INCLUDE_ATTRIBUTES;
|
||||||
opt.keyserver_options.include_subkeys=1;
|
opt.keyserver_options.include_subkeys=1;
|
||||||
opt.keyserver_options.include_revoked=1;
|
opt.keyserver_options.include_revoked=1;
|
||||||
|
opt.mangle_dos_filenames = 1;
|
||||||
#if defined (__MINGW32__)
|
#if defined (__MINGW32__)
|
||||||
set_homedir ( read_w32_registry_string( NULL,
|
set_homedir ( read_w32_registry_string( NULL,
|
||||||
"Software\\GNU\\GnuPG", "HomeDir" ));
|
"Software\\GNU\\GnuPG", "HomeDir" ));
|
||||||
@ -1685,6 +1680,10 @@ main( int argc, char **argv )
|
|||||||
case oGroup: add_group(pargs.r.ret_str); break;
|
case oGroup: add_group(pargs.r.ret_str); break;
|
||||||
case oStrict: /* noop */ break;
|
case oStrict: /* noop */ break;
|
||||||
case oNoStrict: /* noop */ break;
|
case oNoStrict: /* noop */ break;
|
||||||
|
|
||||||
|
case oMangleDosFilenames: opt.mangle_dos_filenames = 1; break;
|
||||||
|
case oNoMangleDosFilenames: opt.mangle_dos_filenames = 0; break;
|
||||||
|
|
||||||
default : pargs.err = configfp? 1:2; break;
|
default : pargs.err = configfp? 1:2; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
145
g10/openfile.c
145
g10/openfile.c
@ -172,80 +172,91 @@ ask_outfile_name( const char *name, size_t namelen )
|
|||||||
int
|
int
|
||||||
open_outfile( const char *iname, int mode, IOBUF *a )
|
open_outfile( const char *iname, int mode, IOBUF *a )
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
*a = NULL;
|
*a = NULL;
|
||||||
if( (!iname || (*iname=='-' && !iname[1])) && !opt.outfile ) {
|
if( (!iname || (*iname=='-' && !iname[1])) && !opt.outfile ) {
|
||||||
if( !(*a = iobuf_create(NULL)) ) {
|
if( !(*a = iobuf_create(NULL)) ) {
|
||||||
log_error(_("%s: can't open: %s\n"), "[stdout]", strerror(errno) );
|
log_error(_("%s: can't open: %s\n"), "[stdout]", strerror(errno) );
|
||||||
rc = G10ERR_CREATE_FILE;
|
rc = G10ERR_CREATE_FILE;
|
||||||
}
|
|
||||||
else if( opt.verbose )
|
|
||||||
log_info(_("writing to stdout\n"));
|
|
||||||
}
|
}
|
||||||
|
else if( opt.verbose )
|
||||||
|
log_info(_("writing to stdout\n"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
char *buf = NULL;
|
||||||
|
const char *name;
|
||||||
|
|
||||||
|
if( opt.dry_run )
|
||||||
|
name = "/dev/null";
|
||||||
|
else if( opt.outfile )
|
||||||
|
name = opt.outfile;
|
||||||
else {
|
else {
|
||||||
char *buf=NULL;
|
#ifdef USE_ONLY_8DOT3
|
||||||
const char *name;
|
if (opt.mangle_dos_filenames)
|
||||||
|
{
|
||||||
|
/* It is quite common DOS system to have only one dot in a
|
||||||
|
* a filename So if we have something like this, we simple
|
||||||
|
* replace the suffix execpt in cases where the suffix is
|
||||||
|
* larger than 3 characters and not the same as.
|
||||||
|
* We should really map the filenames to 8.3 but this tends to
|
||||||
|
* be more complicated and is probaly a duty of the filesystem
|
||||||
|
*/
|
||||||
|
char *dot;
|
||||||
|
const char *newsfx = mode==1 ? ".asc" :
|
||||||
|
mode==2 ? ".sig" : ".gpg";
|
||||||
|
|
||||||
if( opt.dry_run )
|
buf = m_alloc(strlen(iname)+4+1);
|
||||||
name = "/dev/null";
|
strcpy(buf,iname);
|
||||||
else if( opt.outfile )
|
dot = strchr(buf, '.' );
|
||||||
name = opt.outfile;
|
if ( dot && dot > buf && dot[1] && strlen(dot) <= 4
|
||||||
else {
|
&& CMP_FILENAME(newsfx, dot) )
|
||||||
#ifdef USE_ONLY_8DOT3
|
{
|
||||||
/* It is quite common DOS system to have only one dot in a
|
strcpy(dot, newsfx );
|
||||||
* a filename So if we have something like this, we simple
|
|
||||||
* replace the suffix execpt in cases where the suffix is
|
|
||||||
* larger than 3 characters and not the same as.
|
|
||||||
* We should really map the filenames to 8.3 but this tends to
|
|
||||||
* be more complicated and is probaly a duty of the filesystem
|
|
||||||
*/
|
|
||||||
char *dot;
|
|
||||||
const char *newsfx = mode==1 ? ".asc" :
|
|
||||||
mode==2 ? ".sig" : ".gpg";
|
|
||||||
|
|
||||||
buf = m_alloc(strlen(iname)+4+1);
|
|
||||||
strcpy(buf,iname);
|
|
||||||
dot = strchr(buf, '.' );
|
|
||||||
if( dot && dot > buf && dot[1] && strlen(dot) <= 4
|
|
||||||
&& CMP_FILENAME(newsfx, dot) ) {
|
|
||||||
strcpy(dot, newsfx );
|
|
||||||
}
|
|
||||||
else if( dot && !dot[1] ) /* don't duplicate a dot */
|
|
||||||
strcpy( dot, newsfx+1 );
|
|
||||||
else
|
|
||||||
strcat( buf, newsfx );
|
|
||||||
#else
|
|
||||||
buf = m_alloc(strlen(iname)+4+1);
|
|
||||||
strcpy(stpcpy(buf,iname), mode==1 ? EXTSEP_S "asc" :
|
|
||||||
mode==2 ? EXTSEP_S "sig" : EXTSEP_S "gpg");
|
|
||||||
#endif
|
|
||||||
name = buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = 0;
|
|
||||||
while( !overwrite_filep (name) ) {
|
|
||||||
char *tmp = ask_outfile_name (NULL, 0);
|
|
||||||
if ( !tmp || !*tmp ) {
|
|
||||||
m_free (tmp);
|
|
||||||
rc = G10ERR_FILE_EXISTS;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
m_free (buf);
|
else if ( dot && !dot[1] ) /* don't duplicate a dot */
|
||||||
name = buf = tmp;
|
strcpy( dot, newsfx+1 );
|
||||||
|
else
|
||||||
|
strcat ( buf, newsfx );
|
||||||
}
|
}
|
||||||
|
if (!buf)
|
||||||
if( !rc ) {
|
#endif /* USE_ONLY_8DOT3 */
|
||||||
if( !(*a = iobuf_create( name )) ) {
|
{
|
||||||
log_error(_("%s: can't create: %s\n"), name, strerror(errno) );
|
buf = m_alloc(strlen(iname)+4+1);
|
||||||
rc = G10ERR_CREATE_FILE;
|
strcpy(stpcpy(buf,iname), mode==1 ? EXTSEP_S "asc" :
|
||||||
}
|
mode==2 ? EXTSEP_S "sig" : EXTSEP_S "gpg");
|
||||||
else if( opt.verbose )
|
}
|
||||||
log_info(_("writing to `%s'\n"), name );
|
name = buf;
|
||||||
}
|
|
||||||
m_free(buf);
|
|
||||||
}
|
}
|
||||||
return rc;
|
|
||||||
|
rc = 0;
|
||||||
|
while( !overwrite_filep (name) )
|
||||||
|
{
|
||||||
|
char *tmp = ask_outfile_name (NULL, 0);
|
||||||
|
if ( !tmp || !*tmp )
|
||||||
|
{
|
||||||
|
m_free (tmp);
|
||||||
|
rc = G10ERR_FILE_EXISTS;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
m_free (buf);
|
||||||
|
name = buf = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !rc )
|
||||||
|
{
|
||||||
|
if( !(*a = iobuf_create( name )) )
|
||||||
|
{
|
||||||
|
log_error(_("%s: can't create: %s\n"), name, strerror(errno) );
|
||||||
|
rc = G10ERR_CREATE_FILE;
|
||||||
|
}
|
||||||
|
else if( opt.verbose )
|
||||||
|
log_info(_("writing to `%s'\n"), name );
|
||||||
|
}
|
||||||
|
m_free(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -178,6 +178,7 @@ struct {
|
|||||||
int no_homedir_creation;
|
int no_homedir_creation;
|
||||||
int show_keyring;
|
int show_keyring;
|
||||||
struct groupitem *grouplist;
|
struct groupitem *grouplist;
|
||||||
|
int mangle_dos_filenames;
|
||||||
} opt;
|
} opt;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user