libpriv: Sanity check that paths are OSTree compatible
I originally was going to add the check here and error out to the user, but `add-files` is handled all the way near the end of the compose, which meant that users would have to wait through it all before getting an error. Though the check is enforced at parsing time now, I think it's still useful at postprocess time as well as a sanity check. Closes: #1643 Approved by: cgwalters
This commit is contained in:
parent
940fc1364a
commit
f3b8ef043e
@ -37,6 +37,7 @@
|
||||
#include "rpmostree-core.h"
|
||||
#include "rpmostree-rojig-assembler.h"
|
||||
#include "rpmostree-rpm-util.h"
|
||||
#include "rpmostree-util.h"
|
||||
#include <rpm/rpmlib.h>
|
||||
#include <rpm/rpmlog.h>
|
||||
#include <rpm/rpmfi.h>
|
||||
@ -605,13 +606,7 @@ path_is_ostree_compliant (const char *path)
|
||||
{
|
||||
g_assert (*path == '/');
|
||||
path++;
|
||||
return (*path == '\0' ||
|
||||
g_str_equal (path, "usr") || (g_str_has_prefix (path, "usr/")
|
||||
&& !g_str_has_prefix (path, "usr/local/")) ||
|
||||
g_str_equal (path, "bin") || g_str_has_prefix (path, "bin/") ||
|
||||
g_str_equal (path, "sbin") || g_str_has_prefix (path, "sbin/") ||
|
||||
g_str_equal (path, "lib") || g_str_has_prefix (path, "lib/") ||
|
||||
g_str_equal (path, "lib64") || g_str_has_prefix (path, "lib64/"));
|
||||
return (*path == '\0' || rpmostree_relative_path_is_ostree_compliant (path));
|
||||
}
|
||||
|
||||
static OstreeRepoCommitFilterResult
|
||||
|
@ -1400,6 +1400,7 @@ copy_additional_files (int rootfs_dfd,
|
||||
dest = dest_owned;
|
||||
}
|
||||
|
||||
g_assert (rpmostree_relative_path_is_ostree_compliant (dest));
|
||||
g_print ("Adding file '%s'\n", dest);
|
||||
|
||||
g_string_truncate (dnbuf, 0);
|
||||
|
@ -1058,3 +1058,16 @@ rpmostree_timestamp_str_from_unix_utc (guint64 t)
|
||||
return g_date_time_format (timestamp, "%FT%H:%M:%SZ");
|
||||
return g_strdup_printf ("(invalid timestamp)");
|
||||
}
|
||||
|
||||
gboolean
|
||||
rpmostree_relative_path_is_ostree_compliant (const char *path)
|
||||
{
|
||||
g_assert (path);
|
||||
g_assert (*path != '/');
|
||||
return (g_str_equal (path, "usr") || (g_str_has_prefix (path, "usr/")
|
||||
&& !g_str_has_prefix (path, "usr/local/")) ||
|
||||
g_str_equal (path, "bin") || g_str_has_prefix (path, "bin/") ||
|
||||
g_str_equal (path, "sbin") || g_str_has_prefix (path, "sbin/") ||
|
||||
g_str_equal (path, "lib") || g_str_has_prefix (path, "lib/") ||
|
||||
g_str_equal (path, "lib64") || g_str_has_prefix (path, "lib64/"));
|
||||
}
|
||||
|
@ -229,3 +229,6 @@ rpmostree_str_to_auto_update_policy (const char *str,
|
||||
|
||||
char*
|
||||
rpmostree_timestamp_str_from_unix_utc (guint64 t);
|
||||
|
||||
gboolean
|
||||
rpmostree_relative_path_is_ostree_compliant (const char *path);
|
||||
|
Loading…
Reference in New Issue
Block a user