The current Vis() and Unvis() are using the C implementation from
MTREE(8).
But that means that cgo is used, which is not always desired.
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This cleans up the Makefile target, and drops the dependency to point to
the $root path of the repo.
Fixes https://github.com/vbatts/go-mtree/issues/98
Reported-by: Aleksa Sarai <asarai@suse.de>
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
The BSD format needed a slight tweak to handle mtree.Extra
and mtree.Missing cases. It currently only handled the 'Modified'
cases and therefore was not showing missing or extra files during
validation.
Since not every keyword applies to every type entry, include a comment
with the keywords the manifest was generated with.
Signed-off-by: Aleksa Sarai <asarai@suse.de>
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
Adding another test validated from the FreeBSD workflow.
Just because the keywords requested to be validated are not present in
the manifest, it is not an error.
Also, if the keywords from a new manifest are not present in a prior
manifest, then only compare the common keywords.
Fixes https://github.com/vbatts/go-mtree/issues/86
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
symlink(2) is a very dumb syscall, and allows you to put any damn value
you please inside a symlink. In addition, spaces are valid path
characters which causes issues with keyword parsing. So use Vis() and
Unvis() to safely store an encoded version of the path.
This also adds a cli test for this behaviour.
Signed-off-by: Aleksa Sarai <asarai@suse.de>
Due to several unsolveable problems in tar generation, such as the
size=... keyword, we have to special case quite a few things in the
checking code. We might want to move this to mtree properly (but I'm
hesitant about ignoring errors that only happen for tar DHes).
Signed-off-by: Aleksa Sarai <asarai@suse.de>
This removes all of the special handling code for both TarCheck() and
Check() so that everything now uses the new (generic) Compare() code. In
addition, the tests had to be modified to reflect the new classes of
errors.
Signed-off-by: Aleksa Sarai <asarai@suse.de>
While the full testing is broken due to bugs in the tar DH generator, we
ignore known bugs in the tar generator to at least allow us to test some
of the other semantics of Compare.
Signed-off-by: Aleksa Sarai <asarai@suse.de>
Switch the commandline to use the .Compare() API when checking
specification files against the state of a tar archive or other archive.
The main purpose is to completely remove the check.go code from being
necessary (outside of a wrapper).
Signed-off-by: Aleksa Sarai <asarai@suse.de>
This is part of a patchset that refactors all of the checking logic into
comparison operations. Essentially, provide a Compare(...) function that
allows for two different manifests to be compared. Extra and missing
entries are supported in addition to the standard modified entry, and by
implementing as a manifest comparison there is no double-scanning of the
manifest source.
The main annoyance is that we have to also include tar_time handling,
which has not been abstracted inside keywords.go. This is a bit ugly
right now, but works fine for the moment.
Signed-off-by: Aleksa Sarai <asarai@suse.de>
Fix a bug in the parser that caused all iterators to have to handle the
/set and /unset semantics separately. In addition, provide a helper
function to correctly generate the merged set of keywords for a
particular entry.
Signed-off-by: Aleksa Sarai <asarai@suse.de>
Previously, the time generation code would inexplicably drop parts of
the nanotime -- potentially causing validation to succeed when it should
fail. This was probably do to a bug in the remainder logic, but instead
we should be using .Nanosecond() anyway.
After changing the time of a file with a test case like this:
// Change the time to something known with nanosec != 0.
chtime := time.Unix(100, 987654321)
if err := os.Chtimes("somefile", chtime, chtime); err != nil {
// panic
}
timeKeywordFunc() would return the wrong value (time=100.000000021).
This fixes the issue and adds a test case.
Signed-off-by: Aleksa Sarai <asarai@suse.de>
BSD file's support "flags". These have some similarity with xattr, but
for specific features, rather than general purpose key/values.
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>