aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2012-03-27 10:35:13 +0000
committerWerner Koch <[email protected]>2012-03-27 10:38:49 +0000
commitde01c51ecb3918f427aa76281351749c8ad07ed6 (patch)
tree944740e90c45a6bea9a0c539b5dab77d0142ec03
parentUpdate the maintenance instructions. (diff)
downloadgnupg-de01c51ecb3918f427aa76281351749c8ad07ed6.tar.gz
gnupg-de01c51ecb3918f427aa76281351749c8ad07ed6.zip
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.
-rw-r--r--agent/gpg-agent.c10
-rw-r--r--common/argparse.c3
-rw-r--r--common/argparse.h2
-rw-r--r--dirmngr/dirmngr.c10
-rw-r--r--g10/gpg.c14
-rw-r--r--g13/g13.c11
-rw-r--r--scd/scdaemon.c9
-rw-r--r--sm/gpgsm.c10
-rw-r--r--tools/gpg-connect-agent.c12
-rw-r--r--tools/gpgconf.c10
-rw-r--r--tools/gpgtar.c10
11 files changed, 98 insertions, 3 deletions
diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c
index 3a868676b..b6bf71edc 100644
--- a/agent/gpg-agent.c
+++ b/agent/gpg-agent.c
@@ -851,6 +851,16 @@ main (int argc, char **argv )
/*log_info ("NOTE: this is a development version!\n");*/
#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
/* gpg-agent usually does not output any messages because it runs in
the background. For log files it is acceptable to have messages
diff --git a/common/argparse.c b/common/argparse.c
index f55456d41..ce9caff86 100644
--- a/common/argparse.c
+++ b/common/argparse.c
@@ -229,7 +229,7 @@ initialize( ARGPARSE_ARGS *arg, const char *filename, unsigned *lineno )
arg->err = 0;
arg->flags |= 1<<15; /* Mark as initialized. */
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. */
arg->internal.stopped = 1;
+ arg->flags |= ARGPARSE_FLAG_STOP_SEEN;
argc--; argv++; idx++;
goto next_one;
}
diff --git a/common/argparse.h b/common/argparse.h
index dc9b07b42..c8f4c6019 100644
--- a/common/argparse.h
+++ b/common/argparse.h
@@ -82,6 +82,8 @@ typedef struct
#define ARGPARSE_FLAG_ONEDASH 32 /* Allow long options with one dash. */
#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
ORed with the OPT flags. */
#define ARGPARSE_TYPE_NONE 0 /* Does not take an argument. */
diff --git a/dirmngr/dirmngr.c b/dirmngr/dirmngr.c
index ee857189f..9425cd16e 100644
--- a/dirmngr/dirmngr.c
+++ b/dirmngr/dirmngr.c
@@ -847,6 +847,16 @@ main (int argc, char **argv)
log_info ("NOTE: this is a development version!\n");
#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))
log_info
("NOTE: DirMngr is now a proper part of GnuPG. The configuration and"
diff --git a/g10/gpg.c b/g10/gpg.c
index 07d5172c5..00ee9413c 100644
--- a/g10/gpg.c
+++ b/g10/gpg.c
@@ -2018,7 +2018,7 @@ main (int argc, char **argv)
orig_argv = argv;
pargs.argc = &argc;
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) ) {
if( pargs.r_opt == oDebug || pargs.r_opt == oDebugAll )
parse_debug++;
@@ -2094,7 +2094,7 @@ main (int argc, char **argv)
argv = orig_argv;
pargs.argc = &argc;
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. */
check_permissions(opt.homedir,0);
@@ -3093,6 +3093,16 @@ main (int argc, char **argv)
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);
diff --git a/g13/g13.c b/g13/g13.c
index 6fc83b52c..ee72f3385 100644
--- a/g13/g13.c
+++ b/g13/g13.c
@@ -599,6 +599,17 @@ main ( int argc, char **argv)
if (may_coredump && !opt.quiet)
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)
{
log_set_file (logfile);
diff --git a/scd/scdaemon.c b/scd/scdaemon.c
index 7e7850d91..86d092b62 100644
--- a/scd/scdaemon.c
+++ b/scd/scdaemon.c
@@ -618,6 +618,15 @@ main (int argc, char **argv )
log_info ("NOTE: this is a development version!\n");
#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))
{
diff --git a/sm/gpgsm.c b/sm/gpgsm.c
index b2d1d2f67..d8ddbee53 100644
--- a/sm/gpgsm.c
+++ b/sm/gpgsm.c
@@ -1473,6 +1473,16 @@ main ( int argc, char **argv)
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) */
/* tty_batchmode (1); */
diff --git a/tools/gpg-connect-agent.c b/tools/gpg-connect-agent.c
index d340c7f0e..0ef52fc14 100644
--- a/tools/gpg-connect-agent.c
+++ b/tools/gpg-connect-agent.c
@@ -1226,6 +1226,18 @@ main (int argc, char **argv)
if (log_get_errorcount (0))
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)));
if (opt.exec)
diff --git a/tools/gpgconf.c b/tools/gpgconf.c
index cff6e4b3c..a2bba180c 100644
--- a/tools/gpgconf.c
+++ b/tools/gpgconf.c
@@ -195,6 +195,16 @@ main (int argc, char **argv)
if (log_get_errorcount (0))
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;
switch (cmd)
diff --git a/tools/gpgtar.c b/tools/gpgtar.c
index b6dd5e10a..d71fe035a 100644
--- a/tools/gpgtar.c
+++ b/tools/gpgtar.c
@@ -227,6 +227,16 @@ main (int argc, char **argv)
if (log_get_errorcount (0))
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)
{
case aList: