Commit Graph

15 Commits

Author SHA1 Message Date
Colin Walters 58980a717a lib/keyfile: Treat "group not found" the same as "key not found"
Prep for fsverity, where I want to create a new group
`[fsverity]` in the keyfile that has default values.  We should
treat the absence of a group the same as absence of a key
in these "with defaults" APIs.
2019-11-07 21:15:41 +00:00
Colin Walters 810f24d897 libotutil: Port keyfile-utils.c to new style
I was trying to fix a clang `scan-build` error that jlebon
ended up tracking down in
9344de1ce1

But in the process of tracing through this I found it
way easier to read as "new style" code, so this also ports the
code.

I added a `g_assert()` in there too to help assert that
`g_key_file_get_value` won't leak in the error path.
2019-10-16 13:30:21 +00:00
Jonathan Lebon 9344de1ce1 src/libotutil: Fix strv memory leak
We were only freeing the array and not the members.

Caught by `clang-analyzer` in:
https://github.com/ostreedev/ostree/pull/1931
2019-10-15 11:59:45 -04:00
Robert Fairley 99cf13b225 libotutil: Add ot_keyfile_get_value_with_default_group_optional()
Add ot_keyfile_get_value_with_default_group_optional() which allows
getting values from keys where the group is optional in the config
file. This is preparatory to add the sysroot.bootloader repo config
key, where the sysroot group is optional.

Closes: #1814
Approved by: jlebon
2019-03-01 21:20:35 +00:00
Robert Fairley 91892e3c3f libotutil: Rename to ot_keyfile_get_string_list_with_separator_choice()
Rename ot_keyfile_get_string_as_list() to
ot_keyfile_get_string_list_with_separator_choice() which expresses
more clearly why the function is needed. Also shorten the
function comment.

Closes: #1814
Approved by: jlebon
2019-03-01 21:20:35 +00:00
rfairley 05e8c7ef6a lib/repo: Search a list of paths in gpgkeypath for gpg keys
This allows specifying gpgpath as list of
paths that can point to a file or a directory. If a directory path
is given, paths to all regular files in the directory are added
to the remote as gpg ascii keys. If the path is not a directory,
the file is directly added (whether regular file, empty - errors
will be reported later when verifying gpg keys e.g. when pulling).

Adding the gpgkeypath property looks like:

ostree --repo=repo remote add --set=gpgpath="/path/key1.asc,/path/keys.d" R1 https://example.com/some/remote/ostree/repo

Closes #773

Closes: #1773
Approved by: cgwalters
2018-11-21 17:03:10 +00:00
Marcus Folkesson 6bf4b3e1d8 Add SPDX-License-Identifier to source files
SPDX License List is a list of (common) open source
licenses that can be referred to by a “short identifier”.
It has several advantages compared to the common "license header texts"
usually found in source files.

Some of the advantages:
* It is precise; there is no ambiguity due to variations in license header
  text
* It is language neutral
* It is easy to machine process
* It is concise
* It is simple and can be used without much cost in interpreted
  environments like java Script, etc.
* An SPDX license identifier is immutable.
* It provides simple guidance for developers who want to make sure the
  license for their code is respected

See http://spdx.org for further reading.

Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>

Closes: #1439
Approved by: cgwalters
2018-01-30 20:03:42 +00:00
Colin Walters 6e4146a354 tree-wide: Remove Emacs modelines
We added a `.dir-locals.el` in commit: 9a77017d87
There's no need to have it per-file, with that people might think
to add other editors, which is the wrong direction.

Closes: #1206
Approved by: jlebon
2017-09-21 21:38:34 +00:00
Matthew Barnes 302ac4dd89 Use g_auto(GStrv) instead of gs_strfreev 2015-05-06 22:07:11 -04:00
Matthew Barnes 7a62d64968 Use g_autofree instead of gs_free 2015-05-06 21:50:17 -04:00
Giuseppe Scrivano 021c55f430 ot_keyfile_copy_group: return FALSE on invalid inputs
The function returns a gboolean, replace g_return_if_fail with
g_return_val_if_fail.

Add similar checks to the other functions.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2015-03-06 18:45:37 +01:00
Matthew Barnes f3dcb7a052 libotutil: Add ot_keyfile_copy_group()
Copies all the keys of a group from one GKeyFile to another.
2014-12-08 12:47:19 -05:00
Colin Walters d0d98d3abe libotutil: Fix a possible uninitialized free() in error path
Spotted by gcc.
2014-01-18 04:52:45 -05:00
Colin Walters 4b170d656c Switch to libgsystem local allocation macros
And drop our compatibility wrapper.
2013-07-07 12:27:44 -04:00
Colin Walters 31153913ff Extract keyfile helpers into libotutil
Will be used by ostree-pull too soon.
2012-09-15 11:20:56 -04:00