lib/ref: Add OstreeCollectionRef type for globally unique refs
This is a type representing the tuple (collection ID, ref name), which is guaranteed to be globally unique. It will be used in upcoming commits. It introduces the concept of a ‘collection’ which is a unique, curated set of refs which lie in the same trust domain (i.e. all signed by the same key and validated by the same developer). Flathub might be a collection, for example; or the set of OS refs coming from a particular OS vendor. It includes a function for validating collection IDs. Signed-off-by: Philip Withnall <withnall@endlessm.com> Closes: #924 Approved by: cgwalters
This commit is contained in:
1 parent
bf1f8eb0fa
commit
0a20e7d43c
12 files changed
+374
No files matched your search
@@ -210,6 +210,38 @@ ostree_validate_remote_name (const char *remote_name,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* ostree_validate_collection_id:
|
||||
* @rev: (nullable): A collection ID
|
||||
* @error: Error
|
||||
*
|
||||
* Check whether the given @collection_id is valid. Return an error if it is
|
||||
* invalid or %NULL.
|
||||
*
|
||||
* Valid collection IDs are reverse DNS names:
|
||||
* * They are composed of 1 or more elements separated by a period (`.`) character.
|
||||
* All elements must contain at least one character.
|
||||
* * Each element must only contain the ASCII characters `[A-Z][a-z][0-9]_` and must not
|
||||
* begin with a digit.
|
||||
* * They must contain at least one `.` (period) character (and thus at least two elements).
|
||||
* * They must not begin with a `.` (period) character.
|
||||
* * They must not exceed 255 characters in length.
|
||||
*
|
||||
* (This makes their format identical to D-Bus interface names, for consistency.)
|
||||
*
|
||||
* Returns: %TRUE if @collection_id is a valid collection ID, %FALSE if it is invalid
|
||||
* or %NULL
|
||||
*/
|
||||
gboolean
|
||||
ostree_validate_collection_id (const char *collection_id, GError **error)
|
||||
{
|
||||
/* Abuse g_dbus_is_interface_name(), since collection IDs have the same format. */
|
||||
if (collection_id == NULL || !g_dbus_is_interface_name (collection_id))
|
||||
return glnx_throw (error, "Invalid collection ID %s", collection_id);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GVariant *
|
||||
_ostree_file_header_new (GFileInfo *file_info,
|
||||
GVariant *xattrs)
|
||||
|
||||
Reference in new issue
Block a user