Wolfgang Bumiller
62f2422f6a
backup/chunk_store: verify chunk file names
...
get_chunk_iterator() should skip over files which aren't an
actual chunk
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-14 12:37:31 +01:00
Wolfgang Bumiller
3dacd9a660
backup/datastore: fn open is a private implementation detail
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-14 12:37:31 +01:00
Wolfgang Bumiller
9739aca41f
backup/chunk_store: open base dir in get_chunk_iterator
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-14 12:37:31 +01:00
Wolfgang Bumiller
18a1aa4858
make: use --no-deps for cargo doc
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-14 10:17:10 +01:00
Wolfgang Bumiller
dd1bfe6c12
tools/timer: add module documentation
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-14 10:13:42 +01:00
Wolfgang Bumiller
c7f481b642
backup: replace ChunkIterator
...
Instead we just build the iterator using our
tools::fs::read_subdir iterator as follows:
Use the index range (0..0x10000) as an iterator, map() it
to yield a subdirectory iterator for each index, then
flatten it.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-14 10:09:59 +01:00
Wolfgang Bumiller
121f18efb7
tools: use scan_subdir iterator for scandir
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-14 10:09:59 +01:00
Wolfgang Bumiller
32286b039c
tools/fs: add file_name_utf8_unchecked shortcut
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-14 10:09:59 +01:00
Wolfgang Bumiller
806d7a6a35
tools/fs: change scan_subdir to use filter_file_name_regex
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-14 10:09:59 +01:00
Wolfgang Bumiller
53e1e7ca72
tools/fs: add filter_file_name_regex to FileIterOps
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-14 10:09:59 +01:00
Wolfgang Bumiller
23fba9d777
tools/fs: add FileIterOps trait and FileTypeFilter
...
FileIterOps will provide operations on file entry iterators.
For now this provides a file type filter.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-14 10:09:59 +01:00
Wolfgang Bumiller
1db416150d
tools/fs: let ReadDir iterator yield ReadDirEntry
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-14 10:09:59 +01:00
Wolfgang Bumiller
b12505da69
tools/fs: add ReadDirEntry helper
...
This wraps nix::dir::Entry with the parent and additionally
exposes the parent directory file descriptor since we need
it to perform openat().
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-14 10:09:59 +01:00
Wolfgang Bumiller
a25f863afd
tools/fs: add scan_subdir helper
...
This filters the results of read_subdir with a regex.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-14 10:09:59 +01:00
Wolfgang Bumiller
b4d5787de9
tools: start fs submodule, add read_subdir
...
This creates an iterator relative to a RawFd via
nix::dir::Dir over nix::dir::Entrys.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-14 10:09:59 +01:00
Wolfgang Bumiller
4a3f65172c
client: use hyper-tls for now
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-13 11:03:09 +01:00
Wolfgang Bumiller
42d6e4fb05
tools: borrow: implement Deref for Tied
...
Eg. if you have an x: Tied<Dir, Iterator> now you can simply
call x.next() as it'll dereference to the Iterator.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-13 11:03:09 +01:00
Wolfgang Bumiller
82bc0ad40c
backup: fixup warnings and readd lost file type check
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-12 10:43:43 +01:00
Wolfgang Bumiller
9349d2a1d2
backup: cleanup long lines
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-12 10:39:11 +01:00
Wolfgang Bumiller
fdd71f5286
backup: use ChunkIterator for sweep_unused_chunks
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-12 10:39:11 +01:00
Wolfgang Bumiller
c9e7f4dc8b
backup: add optional progress callback to ChunkIterator
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-12 10:39:11 +01:00
Wolfgang Bumiller
4070096c6a
backup: add ChunkIterator
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-12 10:39:11 +01:00
Wolfgang Bumiller
6ed25cbe3a
tools: add Tied value
...
Tie two dependent values together, such as a nix::Dir with
its nix::dir::Iter<'a> where 'a is tied to the Dir's
lifetime, making it otherwise impossible to return them or
store them in a struct.
Alternatively we could try the 'rental' crate.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-12 10:39:11 +01:00
Wolfgang Bumiller
9ac1045c7b
bin: manager: fixup datastore parameter name
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-12 10:39:11 +01:00
Wolfgang Bumiller
ace9e3531a
access: use proxmox-backup-auth for pam
...
allows customization via /etc/pam.d/proxmox-backup-auth
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-07 13:40:22 +01:00
Wolfgang Bumiller
517dfc4258
add generated files to .gitignore
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-05 14:17:30 +01:00
Wolfgang Bumiller
13f8310cac
api2: time: use /etc/localtime as fallback
...
in case there is no /etc/timezone
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-05 14:14:56 +01:00
Wolfgang Bumiller
a7cac14ed9
tools: use std::fs::read for file_get_contents
...
Until we add the extra options like we have in pve, just use
the already existing (since 1.26) shortcut.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-04 15:35:32 +01:00
Wolfgang Bumiller
e937034c86
remove some rather inconvenient debug output
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-04 15:34:38 +01:00
Wolfgang Bumiller
9d02e5c38a
proxy: use <configdir>/server.pfx for tls
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-04 15:19:32 +01:00
Wolfgang Bumiller
9f4962d396
introduce buildcfg module and PROXMOX_CONFIGDIR
...
buildcfg.rs should contain convenience variables or macros
for using build-time configured variables
For now we replace hardcoded "/etc/proxmox-backup/<foo>"
with configdir!("<foo>").
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-04 15:13:08 +01:00
Wolfgang Bumiller
0d176f3681
proxy: use TLS via tokio-tls
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-04 14:56:07 +01:00
Wolfgang Bumiller
b369f720f5
buildsys: don't cache non-binary data
...
etc/ and www/ should be clean in the build/ dir
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-01 10:09:34 +00:00
Wolfgang Bumiller
844d13326b
etc: remove obsolete syslog.target dependency
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-01 10:02:56 +00:00
Wolfgang Bumiller
0ae7ac1545
make deb: use --no-pre-clean
...
We create a clean build/ directory anyway.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-01 10:01:57 +00:00
Wolfgang Bumiller
1a9cb80c44
make clean: cleanup source package files
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-01 10:41:54 +01:00
Wolfgang Bumiller
7406f6260a
debian: add debian/source/format file
...
We need 1.0: We have a native package with a revision, so
anything >1.0 doesn't work...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-01 10:41:54 +01:00
Wolfgang Bumiller
418f3a5f48
add missing build depends
...
lintian complains about a missing bash-completion dependency
which is implied required the bash completion debhelper...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-01 10:41:54 +01:00
Wolfgang Bumiller
7ba5fb4aef
buildsys: re-enable build caching for deb target
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-01 10:41:54 +01:00
Wolfgang Bumiller
18fad34433
make: add dsc target and use lintian
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-01 10:41:54 +01:00
Wolfgang Bumiller
304db5da3d
use libexecdir for service binaries
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-01 10:41:54 +01:00
Wolfgang Bumiller
bed78ccd63
use BUILD_MODE via the environment
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-01 10:41:54 +01:00
Wolfgang Bumiller
069f2d16bf
also apply cargo build flags to tests
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-01 10:41:54 +01:00
Wolfgang Bumiller
13b77d1060
buildsys: fixup package building
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-01 10:41:54 +01:00
Wolfgang Bumiller
a10bb8b941
ignore casync test by default
...
because there's no casync package we can build-depend on to
actually run the tests on normal systems...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-01 10:41:54 +01:00
Wolfgang Bumiller
e0a5d1ca2f
tests: chunk_store: cleanup .testdir
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-01 10:41:54 +01:00
Wolfgang Bumiller
a4f9188300
tests: import lazy_static as needed
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-01 10:41:54 +01:00
Wolfgang Bumiller
6285b251e7
don't hardcode /usr/share paths
...
Add a defines.mk file defining the standard default layout
for installation (PREFIX, DATAROOTDIR, LIBDIR etc.).
Add a $(JSDIR) variable and use env!("JSDIR") in place of
the hardcoded /usr/share/javascript/proxmox-backup path.
Have defines.mk include an *optional* local.mak to override
JSDIR to www/ during local development.
Add `make install` targets and remove debian/install.
Note that service files are now in $libdir/proxmox-backup/
as there's usually no point in starting them from the
command line, so /usr/sbin makes no sense.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-01 10:41:54 +01:00
Wolfgang Bumiller
9fa03fa2d3
www: build proxmox-backup-gui.js into the js/ subdir
...
The server expects an images/ subdir and a js/ subdir, so we
should also compile our files using the same structure.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-01 10:41:54 +01:00
Wolfgang Bumiller
8e4df103dd
remove useless command option from daemons
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-01 10:41:54 +01:00
Wolfgang Bumiller
7028d088b4
add missing build dependencies
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-02-01 10:41:54 +01:00
Wolfgang Bumiller
1bf446a33e
fix timer_delete call
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-01-30 12:04:20 +01:00
Wolfgang Bumiller
37b98249f4
upload: don't return NotReady
...
We need to kick (poll) the stream's next element, so simply
reiterate, the try_read!() will then return NotReady from
the next stream item for us.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-01-16 15:17:26 +01:00
Wolfgang Bumiller
1dcd52e5df
cleanup previous commit...
...
This kind of notation is weird...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-01-16 14:19:13 +01:00
Wolfgang Bumiller
6a50b77e72
listen on :: instead of 0.0.0.0
...
Since this supports both ipv6 & ipv4 unless v6only is
explicitly enabled.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-01-16 14:18:16 +01:00
Wolfgang Bumiller
1ed86a0bae
rest: rename utf-8-checked 'bytes' to 'utf8'
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-01-08 14:22:43 +01:00
Wolfgang Bumiller
9fec7ae593
rest: don't copy the body
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-01-08 14:21:54 +01:00
Wolfgang Bumiller
d9fbcc4631
tools/timer: fixup doc formatting
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-01-08 14:11:10 +01:00
Wolfgang Bumiller
40c45a4b98
Cargo.toml: [lib] has no authors/version
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-01-08 12:47:35 +01:00
Wolfgang Bumiller
4968bc3ac0
cli::command: wrap usage errors in a UsageError
...
So we can distinguish them and show usage output
conditionally.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2019-01-03 16:08:51 +01:00
Wolfgang Bumiller
7ebb173352
getopt: cleanup: add trailing commas
...
It is customary in rust to always use trailing commas. (also
suggested by rustfmt)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2018-12-28 14:27:38 +01:00
Wolfgang Bumiller
2767c5d39b
getopt: cleanup: don't condense 'if' statements too much
...
In a language which enforces curly braces this looks weird
and rustfmt doesn't like it.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2018-12-28 14:27:38 +01:00
Wolfgang Bumiller
7d95c10da0
getopt: whitespace cleanup
...
to make rustfmt happy
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2018-12-28 14:27:38 +01:00
Wolfgang Bumiller
03fb895197
getopt: condense nested match to reduce indentation
...
The `match value` statement is the only thing covering the
entire RawArgument::Option case. `rustfmt` suggests this
more condensed way of writing this case.
See the `git diff -w` of this patch:
|diff --git a/src/getopts.rs b/src/getopts.rs
|index 9755af2..4db4579 100644
|--- a/src/getopts.rs
|+++ b/src/getopts.rs
|@@ -72,8 +72,7 @@ pub fn parse_arguments<T: AsRef<str>>(
| RawArgument::Separator => {
| break;
| }
|- RawArgument::Option { name, value } => {
|- match value {
|+ RawArgument::Option { name, value } => match value {
| None => {
| let mut want_bool = false;
| let mut can_default = false;
|@@ -125,7 +124,6 @@ pub fn parse_arguments<T: AsRef<str>>(
| data.push((name, v));
| }
| }
|- }
| RawArgument::Argument { value } => {
| rest.push(value);
| }
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2018-12-28 14:16:58 +01:00
Wolfgang Bumiller
4d0ea9978b
getopt: let parse_arguments() take a slice of AsRef<str>
...
We don't need the content to be owned strings, and we don't
need the list to be a Vec, since we only care about being
able to iterate through and copy out portions of the strings
we need, so take an &[T] where T: AsRef<str>.
This avoids .iter().map(to_string).collect() before calling
parse_arguments().
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2018-12-28 14:05:05 +01:00
Wolfgang Bumiller
2482c095b1
getopt: remove skip logic
...
The 'skip' variable was set to indicate that the "rest of
the args" is to be copied into the 'rest' vec. We can do
this directly and avoid the 'if' case in the loop
altogether.
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2018-12-28 13:59:44 +01:00
Wolfgang Bumiller
99da3a073d
getopt: indentation reduction
...
See the `git diff -w` output:
|diff --git a/src/getopts.rs b/src/getopts.rs
|index 6548a01..517cc37 100644
|--- a/src/getopts.rs
|+++ b/src/getopts.rs
|@@ -72,7 +72,10 @@ pub fn parse_arguments(
| while pos < args.len() {
| if skip {
| rest.push(args[pos].clone());
|- } else {
|+ pos += 1;
|+ continue;
|+ }
|+
| match parse_argument(&args[pos]) {
| RawArgument::Separator => {
| skip = true;
|@@ -135,7 +138,6 @@ pub fn parse_arguments(
| rest.push(value);
| }
| }
|- }
|
| pos += 1;
| }
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2018-12-28 13:54:20 +01:00
Wolfgang Bumiller
ad8a98f7e4
parse_arguments: work with utf8 bytes and reduce indentation
...
We are only caring about '=' and '-' which are single-byte
codepoints, so there's no reason not to work on a byte
slice.
Also, some indentation reduction:
Transform
if (a) {
...
return A;
}
return B;
into
if (!a)
return B;
return A;
and
if (a)
if (b)
foo()
into
if (a && b)
return;
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2018-12-28 13:47:29 +01:00
Wolfgang Bumiller
fba3437f1e
timer: setup_timeout_handler cannot fail
...
and if it does it panics anyway
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2018-12-27 10:36:28 +01:00
Wolfgang Bumiller
1628a4c731
use timers with a signal for file locking
...
* rename lock_file -> open_file_locked,
* add lock_file as a function working on already-opened
files
* change timeout types to std::time::Duration
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2018-12-19 11:23:00 +01:00
Wolfgang Bumiller
8cf6e764ad
add tools::timer module
...
This wraps POSIX timers via timer_create(2).
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2018-12-19 11:23:00 +01:00
Wolfgang Bumiller
2aea95210e
add rust standard .gitignore file
...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com >
2018-12-19 11:06:51 +01:00