[tahoe-lafs-trac-stream] [Tahoe-LAFS] #2533: magic-folder CLI parsing error
Tahoe-LAFS
trac at tahoe-lafs.org
Tue Oct 13 18:08:27 UTC 2015
#2533: magic-folder CLI parsing error
----------------------------------------+---------------------------
Reporter: warner | Owner: daira
Type: defect | Status: new
Priority: normal | Milestone: undecided
Component: code-frontend-magic-folder | Version: 1.10.1
Keywords: | Launchpad Bug:
----------------------------------------+---------------------------
In a demo today, Zooko tried to join a magic-folder instance with the
following (incorrect) command:
{{{
% tahoe magic-folder join
"URI:DIR2-RO:geydj2tsjteoxiezxwxmff46jq:nfczfkluafttupukia2umqthm2mqh3lu5olouby4nxcdcc36s3fa+URI:DIR2:yy5l52jcuj7k5khumae7stbtry:feo2jnoqcnhktoyggewibqjbr26unjajnudogaa2sbxhafnlvidq"
--basedir=c
}}}
This is wrong for two reasons:
* the `--basedir` option needs to come between `magic-folder` and `join`,
rather than at the end of the command
* it lacks the `LOCALDIR` positional argument, which is supposed to come
after the `INVITATION-CODE` pair-of-dircaps
What happened was even worse:
* the command modified tahoe.cfg in the default basedir (`~/.tahoe/`),
rather than the intended `./c`
* the command recorded `--basedir=c` as the name of the directory to sync.
As in `./--basedir=c/files`.
I'm somewhat surprised that twisted.python.usage (the argument parser) was
willing to accept a `--` -prefixed string as a positional argument.. it's
a legal (if ill-advised) pathname, so it makes sense that it "worked", but
leads to bad failure modes like this one. Some argument parsers (maybe
argparse?) remove all `--`-prefixed strings first, attempt to parser them
as options, then use only the remaining arguments to fill the positional
slots. Such a parser would reject that command twice: once for having no
--basedir option (at that level of the subcommands), and again for failing
to have a positional argument at the expected location (since
`--basedir=c` would have been removed by that point).
I'm not sure what tahoe can do about this, but it's tempting to make a
rule that filenames must start with one of `[a-zA-Z0-9\.\/]`, or at least
reject filenames that start with - or -- (and remind users to say `./-foo`
if they really want that).
--
Ticket URL: <https://tahoe-lafs.org/trac/tahoe-lafs/ticket/2533>
Tahoe-LAFS <https://Tahoe-LAFS.org>
secure decentralized storage
More information about the tahoe-lafs-trac-stream
mailing list