aboutsummaryrefslogtreecommitdiff
path: root/mkfs
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-05-11 00:35:29 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-05-19 14:27:34 +0200
commit28b24512622785d1634a089f7d1d5c25edfb7577 (patch)
treea9ff798441dd71dc99ac73cb20edc0e0ca45fc7b /mkfs
parent0bbd84e31ec8bbe8d1e28e981c577fd56c8b8664 (diff)
Add SELinux option to gensquashfs
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'mkfs')
-rw-r--r--mkfs/Makemodule.am2
-rw-r--r--mkfs/mkfs.c9
-rw-r--r--mkfs/mkfs.h1
-rw-r--r--mkfs/options.c16
4 files changed, 28 insertions, 0 deletions
diff --git a/mkfs/Makemodule.am b/mkfs/Makemodule.am
index 33471fc..d8e75a2 100644
--- a/mkfs/Makemodule.am
+++ b/mkfs/Makemodule.am
@@ -1,6 +1,7 @@
gensquashfs_SOURCES = mkfs/mkfs.c mkfs/mkfs.h mkfs/block.c
gensquashfs_SOURCES += mkfs/options.c mkfs/meta.c
gensquashfs_LDADD = libsquashfs.a libfstree.a libcompress.a libutil.a
+gensquashfs_CPPFLAGS = $(AM_CPPFLAGS)
if WITH_XZ
gensquashfs_LDADD += $(XZ_LIBS)
@@ -19,6 +20,7 @@ gensquashfs_LDADD += $(LZ4_LIBS)
endif
if WITH_SELINUX
+gensquashfs_CPPFLAGS += -DWITH_SELINUX
gensquashfs_LDADD += $(LIBSELINUX_LIBS)
endif
diff --git a/mkfs/mkfs.c b/mkfs/mkfs.c
index ae6210b..d028a9d 100644
--- a/mkfs/mkfs.c
+++ b/mkfs/mkfs.c
@@ -72,6 +72,15 @@ int main(int argc, char **argv)
if (fstree_from_file(&info.fs, info.opt.infile))
goto out_fstree;
+#ifdef WITH_SELINUX
+ if (info.opt.selinux != NULL) {
+ if (fstree_relabel_selinux(&info.fs, info.opt.selinux))
+ goto out_fstree;
+ }
+#endif
+
+ fstree_xattr_deduplicate(&info.fs);
+
fstree_sort(&info.fs);
info.cmp = compressor_create(info.super.compression_id, true,
diff --git a/mkfs/mkfs.h b/mkfs/mkfs.h
index c689848..33e9970 100644
--- a/mkfs/mkfs.h
+++ b/mkfs/mkfs.h
@@ -28,6 +28,7 @@ typedef struct {
bool quiet;
const char *infile;
const char *outfile;
+ const char *selinux;
} options_t;
typedef struct {
diff --git a/mkfs/options.c b/mkfs/options.c
index 0a556eb..d7bdf16 100644
--- a/mkfs/options.c
+++ b/mkfs/options.c
@@ -18,11 +18,18 @@ static struct option long_opts[] = {
{ "defaults", required_argument, NULL, 'd' },
{ "force", no_argument, NULL, 'f' },
{ "quiet", no_argument, NULL, 'q' },
+#ifdef WITH_SELINUX
+ { "selinux", required_argument, NULL, 's' },
+#endif
{ "version", no_argument, NULL, 'V' },
{ "help", no_argument, NULL, 'h' },
};
+#ifdef WITH_SELINUX
+static const char *short_opts = "s:c:b:B:d:fqhV";
+#else
static const char *short_opts = "c:b:B:d:fqhV";
+#endif
enum {
DEF_UID = 0,
@@ -97,6 +104,10 @@ static const char *help_string =
" mode=<value> 0755 if not set.\n"
" mtime=<value> 0 if not set.\n"
"\n"
+#ifdef WITH_SELINUX
+" --selinux, s <file> Specify an SELinux label file to get context\n"
+" attributes from.\n"
+#endif
" --force, -f Overwrite the output file if it exists.\n"
" --quiet, -q Do not print out progress reports.\n"
" --help, -h Print help text and exit.\n"
@@ -265,6 +276,11 @@ void process_command_line(options_t *opt, int argc, char **argv)
case 'q':
opt->quiet = true;
break;
+#ifdef WITH_SELINUX
+ case 's':
+ opt->selinux = optarg;
+ break;
+#endif
case 'h':
printf(help_string, __progname,
SQFS_DEFAULT_BLOCK_SIZE, SQFS_DEVBLK_SIZE);