From 69b3b1d6bffff9061153cd71d92c301bf02cd445 Mon Sep 17 00:00:00 2001 From: Robert Rosengren Date: Mon, 10 May 2021 12:50:18 +0200 Subject: [PATCH] registrybinary: registry file mode via GST_REGISTRY_MODE In an embedded system where all services run as seperate users it is useful to have the gstreamer registry readable by all so it can be re-used, in similar manner as a host system where one user have seperate applications running but all share same registry. To make this possible introducing GST_REGISTRY_MODE for adjusting the changing mode of the registry binary when finishing up with the temporary file (which has restricted access). Fixes: #692 Part-of: --- subprojects/gstreamer/gst/gstregistrybinary.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/subprojects/gstreamer/gst/gstregistrybinary.c b/subprojects/gstreamer/gst/gstregistrybinary.c index db2846f..1e86464 100644 --- a/subprojects/gstreamer/gst/gstregistrybinary.c +++ b/subprojects/gstreamer/gst/gstregistrybinary.c @@ -252,6 +252,7 @@ static gboolean gst_registry_binary_cache_finish (BinaryRegistryCache * cache, gboolean success) { gint fclose_ret; + const gchar *registry_mode; if (success) { /* flush the file and make sure the OS's buffer has been written to disk */ @@ -292,6 +293,22 @@ gst_registry_binary_cache_finish (BinaryRegistryCache * cache, gboolean success) if (g_rename (cache->tmp_location, cache->location) < 0) goto rename_failed; + /* Change mode of registry if set in environment */ + registry_mode = g_getenv ("GST_REGISTRY_MODE"); + if (registry_mode) { + gchar *endptr; + gint64 mode; + + /* Expect numeric mode as one to four octal digits */ + mode = g_ascii_strtoll (registry_mode, &endptr, 8); + if (mode > G_MAXINT || *endptr != '\0') + GST_ERROR ("GST_REGISTRY_MODE not an integer value"); + else if (g_chmod (cache->location, mode) < 0) + GST_ERROR ("g_chmod failed: %s", g_strerror (errno)); + else + GST_INFO ("Changed mode of registry cache to %s", registry_mode); + } + g_free (cache->tmp_location); g_slice_free (BinaryRegistryCache, cache); GST_INFO ("Wrote binary registry cache"); -- 2.7.4