1
0
Fork 0
mirror of https://github.com/vbatts/go-mtree.git synced 2024-11-28 19:15:40 +00:00
Commit graph

284 commits

Author SHA1 Message Date
Aleksa Sarai
d0f7e8cb8b
keywords: correctly handle time keywords
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>
2016-11-01 17:47:06 +11:00
c5fc89d0f1 Merge pull request #80 from vbatts/bsd_compat
keywords: BSD compat for a few keywords
2016-10-31 18:13:33 +00:00
3732fa351f Merge pull request #79 from vbatts/bsd_flags
keywords: don't fail on presence of "flags"
2016-10-31 17:48:02 +00:00
e45837faea
keywords: don't fail on presence of "flags"
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>
2016-10-31 13:25:11 -04:00
b493e2920f keywords: BSD compat for a few keywords
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-10-31 14:10:42 +00:00
84f1e6ebc6 Merge pull request #78 from vbatts/update_golang
travis: update versions of golang
2016-10-31 13:47:21 +00:00
8672a4bc93
travis: update versions of golang
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-10-31 09:42:23 -04:00
8c6b32c842 Merge pull request #74 from vbatts/fix_digest_symlink
keywords: fix xattrs for broken symlinks
2016-09-01 15:54:19 -04:00
c805a855bd
keywords: fix xattrs for broken symlinks
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-09-01 15:52:24 -04:00
3aa50a7a50 Merge pull request #73 from stephen679/tar_cleanup
tar: remove completed TODO's and dead code
2016-08-21 16:15:14 -04:00
Stephen Chung
3973da9b81 tar: remove completed TODO's and dead code
minor clean-up of some comments and code that is not used
in tar functionality

Signed-off-by: Stephen Chung <spchung@andrew.cmu.edu>
2016-08-21 15:41:28 -04:00
bc52946f8e Merge pull request #72 from vbatts/test_cleanup
test: cleanup testdir after testing
2016-08-17 10:33:39 -04:00
fdf37fcebf test: cleanup testdir after testing
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-08-17 10:25:15 -04:00
bd52b623df Merge pull request #70 from vbatts/version
Add versioning
2016-08-16 11:42:19 -04:00
23a95a1c97 version: bump for a dev cycle
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-08-16 11:37:47 -04:00
92b6fc1af3 main: expose the version with a flag
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-08-16 11:37:11 -04:00
475c51cbd7 version: adding a version variable
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-08-16 11:34:01 -04:00
a63446dc6f Merge pull request #67 from stephen679/tar_test_extra_missing
tar_test: don't check for extra/missing when validating relative to "."
2016-08-12 09:04:06 -04:00
Stephen Chung
0e2cf67ac3 tar_test: don't check for extra/missing when validating relative to "."
right now, Check() doesn't check for missing/extra files. So, for the
sake of this test, we don't want to do this check for extra/missing files
when we validate the validation manifest produced from a tar against
the "." root directory (which would be /testdata).

Signed-off-by: Stephen Chung <schung@redhat.com>
2016-08-11 22:23:26 -04:00
52985ee3a5 Merge pull request #66 from vbatts/list_used_JSON
gomtree: `-list-used` can output JSON
2016-08-11 15:00:19 -04:00
6d8cd9fe4c gomtree: -list-used can output JSON
Piggybacking on `-result-format`:

```bash
$ tar c .git/ | gomtree -c -T - > git.mtree
$ gomtree -result-format=json -list-used -f ./git.mtree
{
  "./git.mtree": [
    "type",
    "mode",
    "uid",
    "gid",
    "tar_time",
    "size"
  ]
}
$ tar c .git/ | gomtree -c -T - -K sha512digest > git.mtree
$ gomtree -result-format=json -list-used -f ./git.mtree
{
  "./git.mtree": [
    "type",
    "mode",
    "uid",
    "gid",
    "tar_time",
    "size",
    "sha512digest"
  ]
}
```

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-08-11 14:50:20 -04:00
97a2505b8b Merge pull request #65 from vbatts/stdin_tar
gomtree: allow tar from stdin
2016-08-11 14:12:10 -04:00
90bdfb6c29 gomtree: allow tar from stdin
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-08-11 14:07:07 -04:00
232b80f320 Merge pull request #63 from stephen679/resolve_hardlinks
tar: resolve hardlinks when streaming archive
2016-08-11 13:39:28 -04:00
Stephen Chung
5837d00b07 tar: resolve hardlinks when streaming archive
Fill in the data of the Entry with the data of the
file that a hardlink actually represents.

Signed-off-by: Stephen Chung <schung@redhat.com>
2016-08-11 13:24:44 -04:00
ea6c6eff1b Merge pull request #57 from stephen679/tar_symlink_size
keywords: return non-zero symlink size
2016-08-11 12:44:03 -04:00
7dbe113002 Merge pull request #62 from stephen679/evaluating_symlink
check: functionality for symlinks
2016-08-10 15:22:32 -04:00
Stephen Chung
2facedc401 check: functionality for symlinks
Default behavior (according to upstream mtree) for validating symlinks
is to just validate the link itself, not to follow it.

Signed-off-by: Stephen Chung <schung@redhat.com>
2016-08-10 15:01:07 -04:00
d6b0881515 Merge pull request #61 from vbatts/clearer_branch
tar: more clear `if` predicate
2016-08-10 14:02:02 -04:00
2a99b062a7 tar: more clear if predicate
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-08-10 13:46:14 -04:00
48e7ab8031 Merge pull request #54 from stephen679/keywords-used-list
hierarchy: provide option to list the used keywords in a spec
2016-08-10 13:35:46 -04:00
71abbd944f Merge pull request #55 from stephen679/refactor_tar
tar: refactoring and resolve race condition
2016-08-10 13:31:53 -04:00
Stephen Chung
00a4a2e674 tar: remove "time" keyword before tree creation
Instead of checking each time during keyword evaluation if
the keyword is "time", just remove it from the start and
replace it with "tar_time" (if necessary).

Signed-off-by: Stephen Chung <schung@redhat.com>
2016-08-10 13:17:16 -04:00
Stephen Chung
3d6b74d6f7 tar: populate Entry tree under a common root
Resolves #56. Now, the Entry tree will be populated
under a common root (if necessary), so that a manifest can
be accurately generate from a tar file that has been
created using multiple directories.

Signed-off-by: Stephen Chung <schung@redhat.com>
2016-08-09 12:09:36 -04:00
Stephen Chung
5372b5fc47 hierarchy: provide option to list the used keywords in a spec
To increase a user's control on how they validate a directory or
tar archive with a specification, it is helpful to know which
keywords are actually used in the spec provided. This way, the user
can see what keywords to use or not use with the '-k' or '-K' flags.

Signed-off-by: Stephen Chung <schung@redhat.com>
2016-08-05 10:50:54 -04:00
Stephen Chung
4dc5000106 keywords: return non-zero symlink size
Previously, the symlink size reported by a archive/tar header
was 0. This is incorrect, as the size of a symlink should be
the size of its contents, which is just the path to where
the symlink points to. Thus, the size of this file would just
be len(Linkname).

Signed-off-by: Stephen Chung <schung@redhat.com>
2016-08-02 15:39:54 -04:00
Stephen Chung
6a37331074 tar: flatten the pseudo-tree only after readHeaders() is done
Flattening within the readHeaders() function call was problematic
because readHeaders() is called as a goroutine; thus, as the
main program was calling `tdh.writeTo(os.Stdout)`, readHeaders() was
still in the process of flattening the tree structure. To get around this,
we now call flatten in ts.Hierarchy(), such that only when the main program
is ready to retrieve a "valid" DirectoryHierarchy from the archive, should
we flatten the tree.

Signed-off-by: Stephen Chung <schung@redhat.com>
2016-08-02 11:42:02 -04:00
Stephen Chung
822f319224 tar: minor refactoring of populateTree and flatten
Cleaned up some dead code, and made populateTree not
take in a *tar.Streamer argument, as the ts argument was
only used to set an error. The function now returns
an error (if any). Also made flatten not have to take in
a *tar.Streamer argument as well.

Signed-off-by: Stephen Chung <schung@redhat.com>
2016-07-31 22:26:55 -04:00
aa6d7c2c6e Merge pull request #53 from vbatts/xattrs_base64
keywords: switch 'xattr' to base64
2016-07-27 18:40:15 -04:00
7e2ed0b70b keywords: switch 'xattr' to base64
Rather than an arbitrary election of hashing the xattr value with SHA1
to avoid leaking the value. By going with base64 encoding it allows for
the possibility of restoring a directory with the values stored in the
manifest.

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-07-27 18:38:10 -04:00
27459241ae Merge pull request #51 from stephen679/readme-with-tar
readme: update details about go-mtree in readme
2016-07-27 18:34:39 -04:00
Stephen Chung
a320d77a6f readme: update details about go-mtree in readme
Include details about tar compatibility, as well as
other aspects that have changed

Signed-off-by: Stephen Chung <schung@redhat.com>
2016-07-27 18:11:34 -04:00
94f9a10253 Merge pull request #49 from stephen679/full_digest_output
keywords: synonyms of keywords should produce same output
2016-07-27 15:24:39 -04:00
Stephen Chung
877272303b keywords: synonyms of keywords should produce same output
Currently, if you create a manifest with, say 'sha1', and another
manifest with 'sha1digest', gomtree will produce different output
with regard to the keyword name. I.e, `sha1=[...]` vs. `sha1digest=[...]`.
If we want to use synonyms for keywords, as well as align with upstream mtree
output, specifying 'sha1' and 'sha1digest' should impact gomtree's
in the same way.

Signed-off-by: Stephen Chung <schung@redhat.com>
2016-07-27 10:59:58 -04:00
3d7e24b48a Merge pull request #45 from vbatts/bsd_keywords
Bsd keywords
2016-07-26 16:48:49 -04:00
919d71c105 main: add -bsd-keywords
To support either producing or checking manifests that are compatible
with upstream FreeBSD mtree(8) keywords, this flag will only operate on
upstream keywords. Completely ignoring non-upstream keywords, though
printing out an INFO to stderr for information purposes.

Example:
```bash
INFO: ignoring "xattrs" as it is not an upstream keyword

/set type=file nlink=1 mode=0664 uid=1000 gid=100
. size=4096 type=dir mode=0755 nlink=2 time=1469556206.235575511

[...]
```

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-07-26 14:31:39 -04:00
b790afae01 keywords: include list of upstream keywords
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-07-26 14:21:44 -04:00
664ad32ff6 Merge pull request #44 from vbatts/xattrs
fix xattr ERANGE
2016-07-26 14:03:16 -04:00
2685cd3cc5 xattr: fix the failure on empty list
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-07-26 13:55:25 -04:00
ed6b293839 debug: add an mtree.Debugf and -debug flag
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-07-26 13:54:45 -04:00