mirror of
git://git.gnupg.org/gnupg.git
synced 2025-03-11 22:52:47 +01:00
Print warning for arguments not considered an option.
GnuPG requires that options are given before other arguments. This can sometimes be confusing. We now print a warning if we found an argument looking alike a long option without being preceded by the stop option. This is bug#1343. * common/argparse.h (ARGPARSE_FLAG_STOP_SEEN): New. * common/argparse.c (arg_parse): Set new flag. * g10/gpg.c (main): Print the warning. * agent/gpg-agent.c (main): Ditto. * dirmngr/dirmngr.c (main): Ditto. * g13/g13.c (main): Ditto. * scd/scdaemon.c (main): Ditto. * sm/gpgsm.c (main): Ditto. * tools/gpg-connect-agent.c (main): Ditto. * tools/gpgconf.c (main): Ditto.
This commit is contained in:
parent
26ec6c7902
commit
de01c51ecb
@ -851,6 +851,16 @@ main (int argc, char **argv )
|
|||||||
/*log_info ("NOTE: this is a development version!\n");*/
|
/*log_info ("NOTE: this is a development version!\n");*/
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Print a warning if an argument looks like an option. */
|
||||||
|
if (!opt.quiet && !(pargs.flags & ARGPARSE_FLAG_STOP_SEEN))
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i=0; i < argc; i++)
|
||||||
|
if (argv[i][0] == '-' && argv[i][1] == '-')
|
||||||
|
log_info (_("NOTE: `%s' is not considered an option\n"), argv[i]);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_NLS
|
#ifdef ENABLE_NLS
|
||||||
/* gpg-agent usually does not output any messages because it runs in
|
/* gpg-agent usually does not output any messages because it runs in
|
||||||
the background. For log files it is acceptable to have messages
|
the background. For log files it is acceptable to have messages
|
||||||
|
@ -229,7 +229,7 @@ initialize( ARGPARSE_ARGS *arg, const char *filename, unsigned *lineno )
|
|||||||
arg->err = 0;
|
arg->err = 0;
|
||||||
arg->flags |= 1<<15; /* Mark as initialized. */
|
arg->flags |= 1<<15; /* Mark as initialized. */
|
||||||
if ( *arg->argc < 0 )
|
if ( *arg->argc < 0 )
|
||||||
jnlib_log_bug ("invalid argument for arg_parsee\n");
|
jnlib_log_bug ("invalid argument for arg_parse\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -671,6 +671,7 @@ arg_parse( ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts)
|
|||||||
{
|
{
|
||||||
/* Stop option processing. */
|
/* Stop option processing. */
|
||||||
arg->internal.stopped = 1;
|
arg->internal.stopped = 1;
|
||||||
|
arg->flags |= ARGPARSE_FLAG_STOP_SEEN;
|
||||||
argc--; argv++; idx++;
|
argc--; argv++; idx++;
|
||||||
goto next_one;
|
goto next_one;
|
||||||
}
|
}
|
||||||
|
@ -82,6 +82,8 @@ typedef struct
|
|||||||
#define ARGPARSE_FLAG_ONEDASH 32 /* Allow long options with one dash. */
|
#define ARGPARSE_FLAG_ONEDASH 32 /* Allow long options with one dash. */
|
||||||
#define ARGPARSE_FLAG_NOVERSION 64 /* No output for "--version". */
|
#define ARGPARSE_FLAG_NOVERSION 64 /* No output for "--version". */
|
||||||
|
|
||||||
|
#define ARGPARSE_FLAG_STOP_SEEN 256 /* Set to true if a "--" has been seen. */
|
||||||
|
|
||||||
/* Flags for each option (ARGPARSE_OPTS). The type code may be
|
/* Flags for each option (ARGPARSE_OPTS). The type code may be
|
||||||
ORed with the OPT flags. */
|
ORed with the OPT flags. */
|
||||||
#define ARGPARSE_TYPE_NONE 0 /* Does not take an argument. */
|
#define ARGPARSE_TYPE_NONE 0 /* Does not take an argument. */
|
||||||
|
@ -847,6 +847,16 @@ main (int argc, char **argv)
|
|||||||
log_info ("NOTE: this is a development version!\n");
|
log_info ("NOTE: this is a development version!\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Print a warning if an argument looks like an option. */
|
||||||
|
if (!opt.quiet && !(pargs.flags & ARGPARSE_FLAG_STOP_SEEN))
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i=0; i < argc; i++)
|
||||||
|
if (argv[i][0] == '-' && argv[i][1] == '-')
|
||||||
|
log_info (_("NOTE: `%s' is not considered an option\n"), argv[i]);
|
||||||
|
}
|
||||||
|
|
||||||
if (!access ("/etc/dirmngr", F_OK) && !strncmp (opt.homedir, "/etc/", 5))
|
if (!access ("/etc/dirmngr", F_OK) && !strncmp (opt.homedir, "/etc/", 5))
|
||||||
log_info
|
log_info
|
||||||
("NOTE: DirMngr is now a proper part of GnuPG. The configuration and"
|
("NOTE: DirMngr is now a proper part of GnuPG. The configuration and"
|
||||||
|
14
g10/gpg.c
14
g10/gpg.c
@ -2018,7 +2018,7 @@ main (int argc, char **argv)
|
|||||||
orig_argv = argv;
|
orig_argv = argv;
|
||||||
pargs.argc = &argc;
|
pargs.argc = &argc;
|
||||||
pargs.argv = &argv;
|
pargs.argv = &argv;
|
||||||
pargs.flags= 1|(1<<6); /* do not remove the args, ignore version */
|
pargs.flags= (ARGPARSE_FLAG_KEEP | ARGPARSE_FLAG_NOVERSION);
|
||||||
while( arg_parse( &pargs, opts) ) {
|
while( arg_parse( &pargs, opts) ) {
|
||||||
if( pargs.r_opt == oDebug || pargs.r_opt == oDebugAll )
|
if( pargs.r_opt == oDebug || pargs.r_opt == oDebugAll )
|
||||||
parse_debug++;
|
parse_debug++;
|
||||||
@ -2094,7 +2094,7 @@ main (int argc, char **argv)
|
|||||||
argv = orig_argv;
|
argv = orig_argv;
|
||||||
pargs.argc = &argc;
|
pargs.argc = &argc;
|
||||||
pargs.argv = &argv;
|
pargs.argv = &argv;
|
||||||
pargs.flags= 1; /* do not remove the args */
|
pargs.flags= ARGPARSE_FLAG_KEEP;
|
||||||
|
|
||||||
/* By this point we have a homedir, and cannot change it. */
|
/* By this point we have a homedir, and cannot change it. */
|
||||||
check_permissions(opt.homedir,0);
|
check_permissions(opt.homedir,0);
|
||||||
@ -3093,6 +3093,16 @@ main (int argc, char **argv)
|
|||||||
log_printf ("\n");
|
log_printf ("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Print a warning if an argument looks like an option. */
|
||||||
|
if (!opt.quiet && !(pargs.flags & ARGPARSE_FLAG_STOP_SEEN))
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i=0; i < argc; i++)
|
||||||
|
if (argv[i][0] == '-' && argv[i][1] == '-')
|
||||||
|
log_info (_("NOTE: `%s' is not considered an option\n"), argv[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
gcry_control (GCRYCTL_RESUME_SECMEM_WARN);
|
gcry_control (GCRYCTL_RESUME_SECMEM_WARN);
|
||||||
|
|
||||||
|
11
g13/g13.c
11
g13/g13.c
@ -599,6 +599,17 @@ main ( int argc, char **argv)
|
|||||||
if (may_coredump && !opt.quiet)
|
if (may_coredump && !opt.quiet)
|
||||||
log_info (_("WARNING: program may create a core file!\n"));
|
log_info (_("WARNING: program may create a core file!\n"));
|
||||||
|
|
||||||
|
/* Print a warning if an argument looks like an option. */
|
||||||
|
if (!opt.quiet && !(pargs.flags & ARGPARSE_FLAG_STOP_SEEN))
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i=0; i < argc; i++)
|
||||||
|
if (argv[i][0] == '-' && argv[i][1] == '-')
|
||||||
|
log_info (_("NOTE: `%s' is not considered an option\n"), argv[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (logfile)
|
if (logfile)
|
||||||
{
|
{
|
||||||
log_set_file (logfile);
|
log_set_file (logfile);
|
||||||
|
@ -618,6 +618,15 @@ main (int argc, char **argv )
|
|||||||
log_info ("NOTE: this is a development version!\n");
|
log_info ("NOTE: this is a development version!\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Print a warning if an argument looks like an option. */
|
||||||
|
if (!opt.quiet && !(pargs.flags & ARGPARSE_FLAG_STOP_SEEN))
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i=0; i < argc; i++)
|
||||||
|
if (argv[i][0] == '-' && argv[i][1] == '-')
|
||||||
|
log_info (_("NOTE: `%s' is not considered an option\n"), argv[i]);
|
||||||
|
}
|
||||||
|
|
||||||
if (atexit (cleanup))
|
if (atexit (cleanup))
|
||||||
{
|
{
|
||||||
|
10
sm/gpgsm.c
10
sm/gpgsm.c
@ -1473,6 +1473,16 @@ main ( int argc, char **argv)
|
|||||||
log_printf ("\n");
|
log_printf ("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Print a warning if an argument looks like an option. */
|
||||||
|
if (!opt.quiet && !(pargs.flags & ARGPARSE_FLAG_STOP_SEEN))
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i=0; i < argc; i++)
|
||||||
|
if (argv[i][0] == '-' && argv[i][1] == '-')
|
||||||
|
log_info (_("NOTE: `%s' is not considered an option\n"), argv[i]);
|
||||||
|
}
|
||||||
|
|
||||||
/*FIXME if (opt.batch) */
|
/*FIXME if (opt.batch) */
|
||||||
/* tty_batchmode (1); */
|
/* tty_batchmode (1); */
|
||||||
|
|
||||||
|
@ -1226,6 +1226,18 @@ main (int argc, char **argv)
|
|||||||
if (log_get_errorcount (0))
|
if (log_get_errorcount (0))
|
||||||
exit (2);
|
exit (2);
|
||||||
|
|
||||||
|
|
||||||
|
/* Print a warning if an argument looks like an option. */
|
||||||
|
if (!opt.quiet && !(pargs.flags & ARGPARSE_FLAG_STOP_SEEN))
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i=0; i < argc; i++)
|
||||||
|
if (argv[i][0] == '-' && argv[i][1] == '-')
|
||||||
|
log_info (_("NOTE: `%s' is not considered an option\n"), argv[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
use_tty = (gnupg_isatty (fileno (stdin)) && gnupg_isatty (fileno (stdout)));
|
use_tty = (gnupg_isatty (fileno (stdin)) && gnupg_isatty (fileno (stdout)));
|
||||||
|
|
||||||
if (opt.exec)
|
if (opt.exec)
|
||||||
|
@ -195,6 +195,16 @@ main (int argc, char **argv)
|
|||||||
if (log_get_errorcount (0))
|
if (log_get_errorcount (0))
|
||||||
exit (2);
|
exit (2);
|
||||||
|
|
||||||
|
/* Print a warning if an argument looks like an option. */
|
||||||
|
if (!opt.quiet && !(pargs.flags & ARGPARSE_FLAG_STOP_SEEN))
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i=0; i < argc; i++)
|
||||||
|
if (argv[i][0] == '-' && argv[i][1] == '-')
|
||||||
|
log_info (_("NOTE: `%s' is not considered an option\n"), argv[i]);
|
||||||
|
}
|
||||||
|
|
||||||
fname = argc ? *argv : NULL;
|
fname = argc ? *argv : NULL;
|
||||||
|
|
||||||
switch (cmd)
|
switch (cmd)
|
||||||
|
@ -227,6 +227,16 @@ main (int argc, char **argv)
|
|||||||
if (log_get_errorcount (0))
|
if (log_get_errorcount (0))
|
||||||
exit (2);
|
exit (2);
|
||||||
|
|
||||||
|
/* Print a warning if an argument looks like an option. */
|
||||||
|
if (!opt.quiet && !(pargs.flags & ARGPARSE_FLAG_STOP_SEEN))
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i=0; i < argc; i++)
|
||||||
|
if (argv[i][0] == '-' && argv[i][1] == '-')
|
||||||
|
log_info (_("NOTE: `%s' is not considered an option\n"), argv[i]);
|
||||||
|
}
|
||||||
|
|
||||||
switch (cmd)
|
switch (cmd)
|
||||||
{
|
{
|
||||||
case aList:
|
case aList:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user