[systemd-devel] [PATCH 1/5] shared/import-util: tag renamed to reference to support v2 pull by digest

Pavel Odvody podvody at redhat.com
Thu May 7 08:47:04 PDT 2015


Signed-off-by: Pavel Odvody <podvody at redhat.com>
---
 src/shared/import-util.c | 19 +++++++++++++++++++
 src/shared/import-util.h |  1 +
 2 files changed, 20 insertions(+)

diff --git a/src/shared/import-util.c b/src/shared/import-util.c
index 660d92a..f2fb6d0 100644
--- a/src/shared/import-util.c
+++ b/src/shared/import-util.c
@@ -150,6 +150,25 @@ int raw_strip_suffixes(const char *p, char **ret) {
         return 0;
 }
 
+bool dkr_ref_is_valid(const char *ref) {
+        const char *colon;
+
+        if (isempty(ref))
+                return false;
+
+        colon = strchr(ref, ':');
+        if (!colon)
+                return filename_is_valid(ref);
+
+        else if (!startswith(ref, "sha256"))
+                return false;
+
+        else if (!in_charset(colon + 1, "0123456789abcdef"))
+                return false;
+
+        return true;
+}
+
 bool dkr_name_is_valid(const char *name) {
         const char *slash, *p;
 
diff --git a/src/shared/import-util.h b/src/shared/import-util.h
index ff155b0..8f47f91 100644
--- a/src/shared/import-util.h
+++ b/src/shared/import-util.h
@@ -44,4 +44,5 @@ int raw_strip_suffixes(const char *name, char **ret);
 
 bool dkr_name_is_valid(const char *name);
 bool dkr_id_is_valid(const char *id);
+bool dkr_ref_is_valid(const char *ref);
 #define dkr_tag_is_valid(tag) filename_is_valid(tag)
-- 
2.1.0

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20150507/7f420ac9/attachment.sig>


More information about the systemd-devel mailing list