Rob Browning [Wed, 2 Dec 2020 01:43:13 +0000 (19:43 -0600)]
bup: add support for "internal" subcommands
Look for the existing something-cmd.py commands as both
lib/cmd/bup-something and lib/bup/cmd/something.py, and don't load the
latter as a module unless specifically allowed, so that we can create
separate rename commits as we convert each relevant external command
to an internal command. This should make it easier to see what
actually changed in the git history, e.g. with --ignore-space-change.
Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Rob Browning [Wed, 6 Jan 2021 01:43:50 +0000 (19:43 -0600)]
prep-for-macos-build: don't run brew update
The update was causing tests to fail, and the previous attempt to
address the issue e244aa8ec2ea4b754d6242ee81dd0d3c6dace543 didn't.
Thanks to Johannes Berg proposing the fix.
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Johannes Berg [Thu, 31 Dec 2020 22:07:10 +0000 (23:07 +0100)]
index: add newline to 'corrupt index' message
This otherwise prints the traceback afterwards starting
on the same line, which looks odd.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Reviewed-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Johannes Berg [Thu, 31 Dec 2020 21:29:38 +0000 (22:29 +0100)]
index: remove pointless git.repo() invocation
Since the only way we can get to clear_index() is with
indexfile having previously been assigned
indexfile = git.repo(b'bupindex')
since opt.clear and opt.indexfile are explicitly mutually
exclusive, there's no point in calling git.repo() again,
it has no effect.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Reviewed-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
bup-web: handle 4 item getsockname() result for IPv6 sockets
So bup-web will create a new network socket to listen on for HTTP
connections and it may use either IPv4 or IPv6 (or both) addresses,
depending on the configuration of the system. This is done using the
tornado.netutil.bind_sockets().
Currently, bup-web does not restrict the address family to either
AF_INET/AF_INET6 and according to the documentation of
[tornado](https://www.tornadoweb.org/en/stable/netutil.html?highlight=netutil#tornado.netutil.bind_sockets)
it will use both address families and listen for connections on IPv4 and
IPv6 addresses.
> Family may be set to either socket.AF_INET or socket.AF_INET6 to
> restrict to IPv4 or IPv6 addresses, otherwise both will be used if
> available.
However, when your system has only IPv6 enabled, the print() statement
may fail with:
Traceback (most recent call last):
File "/opt/bup/lib/bup/cmd/bup-web", line 310, in <module>
print('Serving HTTP on %s:%d...' % sockets[0].getsockname())
TypeError: not all arguments converted during string formatting
For systems that have IPv4 as well as IPv6 enabled, it may or may not
fail, depending on whether the first returned socket by getsockname() is
for AF_INET6 or AF_INET4
The reason is, getsockname() for a AF_INET6 connections returns a tuple with
4 items: `(host, port, flowinfo, scope_id)`, while for AF_INET4
addresses, it contains only `(host, port)`.
Since we are only interested in the first 2 items, make sure to return
only the first 2 items, which are `host` and `port` for IPv4 (AF_INET)
and IPv6 (AF_INET6).
Signed-off-by: Christian Brabandt <cb@256bit.org> Reviewed-by: Rob Browning <rlb@defaultvalue.org>
[rlb@defaultvalue.org: adjust commit summary]
Johannes Berg [Tue, 29 Dec 2020 21:26:40 +0000 (22:26 +0100)]
restore: fix error message for inaccessible items
This actually shows up during tests, but it's hidden as it's
an error where we _expect_ bup to fail (and don't check why).
Fix the message in this case.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Rob Browning [Tue, 22 Dec 2020 17:17:45 +0000 (11:17 -0600)]
Replace atoi with explicit checks; rm unused atof
Replace atoi with explicit checks, making the intention a bit clearer
at each call site, and avoiding trouble we've had in the past with the
default to 0 for any unrecognized input.
This does make us stricter about the values (and the environment),
i.e. BUP_TTY_WIDTH=random-noise will now cause a crash.
Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Johannes Berg [Mon, 21 Dec 2020 20:45:55 +0000 (21:45 +0100)]
ssh: don't pass through bad BUP_TTY_WIDTH
If there's no BUP_TTY_WIDTH variable already, then environ.get()
will result in None, which cannot be converted to an integer so
we get 0. Then we pass 0 to the other side in the BUP_TTY_WIDTH
environment variable.
Unfortunately, 0 is a really bad default, since textwrap cannot
work with a width of 0, causing tracebacks such as the one Mark
J Hewitt reported:
https://groups.google.com/g/bup-list/c/rfIw3STN2EY/m/C5Y3UrMIAgAJ
Fix this by not passing it through if there's no good value.
Reported-by: Mark J Hewitt <mjh@idnet.com> Reported-by: Alexander Barton <alex@barton.de> Fixes: cd3647c81a25 ("bup: pass TTY width through to sub-command and remote") Reviewed-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Rob Browning [Sun, 20 Dec 2020 01:36:09 +0000 (19:36 -0600)]
Prefer python 3, and mention intent to drop python 2 support
For now, set the minimum supported 3 version at 3.7 since I just
tested that on a debian/buster system, and update the installation
instructions after seeing what was required to run the tests from
scratch there. Continue to search for 3.6 and 2.6 for now, since no
one's complained, and we can always lower the requirement later if it
seems appropriate.
Signed-off-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>
Johannes Berg [Tue, 4 Aug 2020 14:49:36 +0000 (16:49 +0200)]
test-web: redirect stdio to make test work standalone
Python (at least 3) behaves differently if somehow
stdio is connected to the terminal, and external
SIGTERM then doesn't cause the same behaviour as
actually pressing Ctrl-C. Redirect the output to
a file to make the test run standalone.
Print the file if any errors occur so that if there's
anything interesting in there, we can see it.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Reviewed-by: Rob Browning <rlb@defaultvalue.org> Tested-by: Rob Browning <rlb@defaultvalue.org>