Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package policycoreutils for openSUSE:Factory 
checked in at 2026-12-05 19:09:02
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/policycoreutils (Old)
 and      /work/SRC/openSUSE:Factory/.policycoreutils.new.1340718 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "policycoreutils"

Sat Dec  5 19:09:02 2026 rev:93 rq:1402969 version:3.12

Changes:
--------
--- /work/SRC/openSUSE:Factory/policycoreutils/policycoreutils.changes  
2026-07-20 09:59:57.609382191 +0200
+++ 
/work/SRC/openSUSE:Factory/.policycoreutils.new.1340718/policycoreutils.changes 
    2026-12-05 19:09:07.587940334 +0100
@@ -1,0 +2,47 @@
+Thu Dec  3 09:00:36 UTC 2026 - Cathy Hu <[email protected]>
+
+- Update to version 3.12
+  https://github.com/SELinuxProject/selinux/releases/tag/v3.12
+  - Fixes security vulnerabilities in newrole: GHSA-5x46-m349-ccgh 
(bsc#1291835), GHSA-r6x4-p3xh-v976 (bsc#1291828), GHSA-fqvm-r5xf-5g32 
(bsc#1291829), GHSA-7wv5-qfrr-wx45 (bsc#1291824)
+  - Fixes security vulnerabilities in semanage: GHSA-634v-6r3g-q866 
(bsc#1291836)
+  - Fixes security vulnerabilities in fixfiles: GHSA-647q-jhqw-6p4w 
(CVE-2026-19079)
+  - User-visible changes:
+    - semodule and other libsemanage users now block on the module store lock
+      by default instead of giving up after five seconds, making overlapping
+      semodule transactions from rpm scriptlets or configuration management
+      reliable (#181).
+    - setfiles now uses all available CPU cores by default, honors the
+      RESTORECON_THREADS environment variable, enables
+      SELINUX_RESTORECON_REALPATH by default so that files are labeled based
+      on their canonical pathname (#540), and provides a new -j option to skip
+      files with multiple hard links.
+    - fixfiles passes -I and -D through to setfiles/restorecon, omits excluded
+      mounts from the relabel list, and no longer performs the obsolete /tmp
+      cleanup.
+  - Security/hardening changes:
+    - Hardened sandbox, newrole, restorecond and mcstrans handling of
+      commands, temporary files, signals and configuration data, including
+      constant-time comparison of shadow password hashes in newrole, bounded
+      Include nesting depth in mcstrans, a hardened mcstrans systemd service
+      file, and use of openat2() where available in sandbox/seunshare,
+      restorecond and selinux_restorecon(3).
+  - Development-relevant changes:
+    - Added pyproject.toml build configuration for the libselinux and sepolicy
+      Python modules.
+  - Notable bug fixes:
+    - newrole: fix minor leaks and uninitialized status
+    - python/semanage: fix permissive add with bytes module bindings
+    - policycoreutils/setfiles: reject invalid -T arguments
+    - policycoreutils/run_init: handle NULL from crypt() in non-PAM build
+    - python/sepolicy: escape literal paths written to generated .fc files
+- Drop 1271645-drop-tmp-cleanup.patch (bsc#1271645), merged upstream
+- Drop usr_etc.patch, merged upstream (sestatus reads vendor settings via
+  libeconf)
+- Source URLs: upstream tags are prefixed with "v" now
+
+-------------------------------------------------------------------
+Wed Dec  2 13:07:50 UTC 2026 - Cathy Hu <[email protected]>
+
+- keyring: update bachradsusi.gpg for next release 
+
+-------------------------------------------------------------------

Old:
----
  1271645-drop-tmp-cleanup.patch
  policycoreutils-3.11.tar.gz
  policycoreutils-3.11.tar.gz.asc
  selinux-dbus-3.11.tar.gz
  selinux-dbus-3.11.tar.gz.asc
  selinux-gui-3.11.tar.gz
  selinux-gui-3.11.tar.gz.asc
  selinux-python-3.11.tar.gz
  selinux-python-3.11.tar.gz.asc
  semodule-utils-3.11.tar.gz
  semodule-utils-3.11.tar.gz.asc
  usr_etc.patch

New:
----
  policycoreutils-3.12.tar.gz
  policycoreutils-3.12.tar.gz.asc
  selinux-dbus-3.12.tar.gz
  selinux-dbus-3.12.tar.gz.asc
  selinux-gui-3.12.tar.gz
  selinux-gui-3.12.tar.gz.asc
  selinux-python-3.12.tar.gz
  selinux-python-3.12.tar.gz.asc
  semodule-utils-3.12.tar.gz
  semodule-utils-3.12.tar.gz.asc

----------(Old B)----------
  Old:    - python/sepolicy: escape literal paths written to generated .fc files
- Drop 1271645-drop-tmp-cleanup.patch (bsc#1271645), merged upstream
- Drop usr_etc.patch, merged upstream (sestatus reads vendor settings via
  Old:- Drop 1271645-drop-tmp-cleanup.patch (bsc#1271645), merged upstream
- Drop usr_etc.patch, merged upstream (sestatus reads vendor settings via
  libeconf)
----------(Old E)----------

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ policycoreutils.spec ++++++
--- /var/tmp/diff_new_pack.M5PKNZ/_old  2026-12-05 19:09:08.934997099 +0100
+++ /var/tmp/diff_new_pack.M5PKNZ/_new  2026-12-05 19:09:08.936997183 +0100
@@ -30,37 +30,35 @@
 %endif
 
 %define libaudit_ver     2.2
-%define libsepol_ver     3.11
-%define libsemanage_ver  3.11
-%define libselinux_ver   3.11
+%define libsepol_ver     3.12
+%define libsemanage_ver  3.12
+%define libselinux_ver   3.12
 %define setools_ver      4.1.1
 Name:           policycoreutils
-Version:        3.11
+Version:        3.12
 Release:        0
 Summary:        SELinux policy core utilities
 License:        GPL-2.0-or-later
 Group:          Productivity/Security
 URL:            https://github.com/SELinuxProject/selinux
-Source0:        
https://github.com/SELinuxProject/selinux/releases/download/%{version}/%{name}-%{version}.tar.gz
-Source1:        
https://github.com/SELinuxProject/selinux/releases/download/%{version}/%{name}-%{version}.tar.gz.asc
+Source0:        
https://github.com/SELinuxProject/selinux/releases/download/v%{version}/%{name}-%{version}.tar.gz
+Source1:        
https://github.com/SELinuxProject/selinux/releases/download/v%{version}/%{name}-%{version}.tar.gz.asc
 Source2:        policycoreutils.keyring
-Source3:        
https://github.com/SELinuxProject/selinux/releases/download/%{version}/selinux-python-%{version}.tar.gz
-Source4:        
https://github.com/SELinuxProject/selinux/releases/download/%{version}/selinux-python-%{version}.tar.gz.asc
-Source5:        
https://github.com/SELinuxProject/selinux/releases/download/%{version}/semodule-utils-%{version}.tar.gz
-Source6:        
https://github.com/SELinuxProject/selinux/releases/download/%{version}/semodule-utils-%{version}.tar.gz.asc
+Source3:        
https://github.com/SELinuxProject/selinux/releases/download/v%{version}/selinux-python-%{version}.tar.gz
+Source4:        
https://github.com/SELinuxProject/selinux/releases/download/v%{version}/selinux-python-%{version}.tar.gz.asc
+Source5:        
https://github.com/SELinuxProject/selinux/releases/download/v%{version}/semodule-utils-%{version}.tar.gz
+Source6:        
https://github.com/SELinuxProject/selinux/releases/download/v%{version}/semodule-utils-%{version}.tar.gz.asc
 Source13:       newrole.pam
-Source14:       
https://github.com/SELinuxProject/selinux/releases/download/%{version}/selinux-gui-%{version}.tar.gz
-Source15:       
https://github.com/SELinuxProject/selinux/releases/download/%{version}/selinux-gui-%{version}.tar.gz.asc
-Source16:       
https://github.com/SELinuxProject/selinux/releases/download/%{version}/selinux-dbus-%{version}.tar.gz
-Source17:       
https://github.com/SELinuxProject/selinux/releases/download/%{version}/selinux-dbus-%{version}.tar.gz.asc
+Source14:       
https://github.com/SELinuxProject/selinux/releases/download/v%{version}/selinux-gui-%{version}.tar.gz
+Source15:       
https://github.com/SELinuxProject/selinux/releases/download/v%{version}/selinux-gui-%{version}.tar.gz.asc
+Source16:       
https://github.com/SELinuxProject/selinux/releases/download/v%{version}/selinux-dbus-%{version}.tar.gz
+Source17:       
https://github.com/SELinuxProject/selinux/releases/download/v%{version}/selinux-dbus-%{version}.tar.gz.asc
 Source20:       policycoreutils-rpmlintrc
 Source21:       sepolgen.conf
 Patch0:         make_targets.patch
 Patch2:         get_os_version.patch
 Patch3:         run_init.pamd.patch
-Patch4:         usr_etc.patch
 # PATCH-FIX-UPSTREAM [email protected] bsc#1271645 2026-07-17 upstream patch, can 
be dropped in next release 
-Patch5:                1271645-drop-tmp-cleanup.patch
 BuildRequires:  audit-devel >= %{libaudit_ver}
 BuildRequires:  bison
 BuildRequires:  dbus-1-glib-devel
@@ -212,8 +210,6 @@
 %patch -P0 -p1
 %patch -P2 -p2 -d selinux-python-%{version}
 %patch -P3 -p1
-%patch -P4 -p1
-%patch -P5 -p2
 mv ${setools_python_pwd}/audit2allow ${setools_python_pwd}/chcat 
${setools_python_pwd}/semanage ${setools_python_pwd}/sepolgen 
${setools_python_pwd}/sepolicy .
 mv ${semodule_utils_pwd}/semodule_expand ${semodule_utils_pwd}/semodule_link 
${semodule_utils_pwd}/semodule_package .
 

++++++ policycoreutils-3.11.tar.gz -> policycoreutils-3.12.tar.gz ++++++
++++ 1642 lines of diff (skipped)

++++++ policycoreutils.keyring ++++++
++++ 626 lines (skipped)
++++ between policycoreutils.keyring
++++ and 
/work/SRC/openSUSE:Factory/.policycoreutils.new.1340718/policycoreutils.keyring

++++++ selinux-dbus-3.11.tar.gz -> selinux-dbus-3.12.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/selinux-dbus-3.11/VERSION 
new/selinux-dbus-3.12/VERSION
--- old/selinux-dbus-3.11/VERSION       2026-07-01 18:51:05.000000000 +0200
+++ new/selinux-dbus-3.12/VERSION       2026-12-02 18:39:01.000000000 +0100
@@ -1 +1 @@
-3.11
+3.12

++++++ selinux-gui-3.11.tar.gz -> selinux-gui-3.12.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/selinux-gui-3.11/VERSION new/selinux-gui-3.12/VERSION
--- old/selinux-gui-3.11/VERSION        2026-07-01 18:51:05.000000000 +0200
+++ new/selinux-gui-3.12/VERSION        2026-12-02 18:39:01.000000000 +0100
@@ -1 +1 @@
-3.11
+3.12
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/selinux-gui-3.11/statusPage.py 
new/selinux-gui-3.12/statusPage.py
--- old/selinux-gui-3.11/statusPage.py  2026-07-01 18:51:05.000000000 +0200
+++ new/selinux-gui-3.12/statusPage.py  2026-12-02 18:39:01.000000000 +0100
@@ -30,6 +30,10 @@
 modearray = ("disabled", "permissive", "enforcing")
 
 SELINUXDIR = "/etc/selinux/"
+# Fallback configuration roots searched (in order) for installed policy
+# types when populating the type menu. Writes always go to SELINUXDIR
+# via selinux_path().
+SELINUX_CONFDIRS = (SELINUXDIR, "/usr/lib/selinux/")
 RELABELFILE = "/.autorelabel"
 
 ##
@@ -195,13 +199,20 @@
         n = 0
         current = n
 
-        for i in os.listdir(SELINUXDIR):
-            if os.path.isdir(SELINUXDIR + i) and os.path.isdir(SELINUXDIR + i 
+ "/policy"):
-                self.types.append(i)
-                self.selinuxTypeOptionMenu.append_text(i)
-                if i == self.initialtype:
-                    current = n
-                n = n + 1
+        for confdir in SELINUX_CONFDIRS:
+            try:
+                entries = sorted(os.listdir(confdir))
+            except OSError:
+                continue
+            for i in entries:
+                if i in self.types:
+                    continue
+                if os.path.isdir(confdir + i + "/policy"):
+                    self.types.append(i)
+                    self.selinuxTypeOptionMenu.append_text(i)
+                    if i == self.initialtype:
+                        current = n
+                    n = n + 1
         self.selinuxTypeOptionMenu.set_active(current)
         self.typeHistory = current
 

++++++ selinux-python-3.11.tar.gz -> selinux-python-3.12.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/selinux-python-3.11/VERSION 
new/selinux-python-3.12/VERSION
--- old/selinux-python-3.11/VERSION     2026-07-01 18:51:05.000000000 +0200
+++ new/selinux-python-3.12/VERSION     2026-12-02 18:39:01.000000000 +0100
@@ -1 +1 @@
-3.11
+3.12
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/selinux-python-3.11/chcat/chcat 
new/selinux-python-3.12/chcat/chcat
--- old/selinux-python-3.11/chcat/chcat 2026-07-01 18:51:05.000000000 +0200
+++ new/selinux-python-3.12/chcat/chcat 2026-12-02 18:39:01.000000000 +0100
@@ -365,7 +365,7 @@
 
 
 def listcats():
-    fd = open(selinux.selinux_translations_path())
+    fd = selinux.policy_open(selinux.selinux_translations_path())
     for l in fd.read().split("\n"):
         if l.startswith("#"):
             continue
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/selinux-python-3.11/chcat/chcat.8 
new/selinux-python-3.12/chcat/chcat.8
--- old/selinux-python-3.11/chcat/chcat.8       2026-07-01 18:51:05.000000000 
+0200
+++ new/selinux-python-3.12/chcat/chcat.8       2026-12-02 18:39:01.000000000 
+0100
@@ -59,6 +59,21 @@
 .br
 When operating on files this script wraps the chcon command.
 .SH "FILES"
-/etc/selinux/{SELINUXTYPE}/setrans.conf 
-.br
+.TP
+.I /etc/selinux/{SELINUXTYPE}/setrans.conf
+.TP
+.I /usr/lib/selinux/{SELINUXTYPE}/setrans.conf
+The SELinux context translation configuration file. The file in
+.B /etc
+overrides the default configuration provided by the vendor in
+.BR /usr/lib .
+.TP
+.I
 /etc/selinux/{SELINUXTYPE}/seusers
+.TP
+.I
+/usr/lib/selinux/{SELINUXTYPE}/seusers
+The SELinux users configuration. The file in
+.B /etc
+overrides the default configuration provided by the vendor in
+.BR /usr/lib .
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/selinux-python-3.11/semanage/Makefile 
new/selinux-python-3.12/semanage/Makefile
--- old/selinux-python-3.11/semanage/Makefile   2026-07-01 18:51:05.000000000 
+0200
+++ new/selinux-python-3.12/semanage/Makefile   2026-12-02 18:39:01.000000000 
+0100
@@ -32,7 +32,9 @@
        install -m 644 $(BASHCOMPLETIONS) 
$(DESTDIR)$(BASHCOMPLETIONDIR)/semanage
 
 test:
+       @$(PYTHON) test-permissive-store.py
        @$(PYTHON) test-semanage.py -a
 clean:
+       rm -rf __pycache__
 
 relabel:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/selinux-python-3.11/semanage/semanage 
new/selinux-python-3.12/semanage/semanage
--- old/selinux-python-3.11/semanage/semanage   2026-07-01 18:51:05.000000000 
+0200
+++ new/selinux-python-3.12/semanage/semanage   2026-12-02 18:39:01.000000000 
+0100
@@ -206,7 +206,7 @@
 
 
 def parser_add_store(parser, name):
-    parser.add_argument('-S', '--store', default='', help=_("Select an 
alternate SELinux Policy Store to manage"))
+    parser.add_argument('-S', '--store', default=argparse.SUPPRESS, 
help=_("Select an alternate SELinux Policy Store to manage"))
 
 
 def parser_add_priority(parser, name):
@@ -416,7 +416,8 @@
     userParser.add_argument('-R', '--roles', default=[],
                             action=CheckRole,
                             help=_("SELinux Roles. You must enclose multiple 
roles within quotes, separate by spaces. Or specify -R multiple times."))
-    userParser.add_argument('-P', '--prefix', default="user", 
help=argparse.SUPPRESS)
+    userParser.add_argument('-P', '--prefix', default="user",
+                            help=_("Labeling prefix for the SELinux user, used 
by genhomedircon when generating home directory labels. Defaults to 'user'."))
     userParser.add_argument('selinux_name', nargs='?', default=None, 
help=_('selinux_name'))
     userParser.set_defaults(func=handleUser)
 
@@ -808,6 +809,8 @@
             while i < len(l) and dquote not in l[i]:
                 quote.append(l[i])
                 i = i + 1
+            if i == len(l):
+                raise ValueError(_("Unterminated quote in import data: %s") % 
line)
             quote.append(l[i].strip(dquote))
             ret.append(" ".join(quote))
             i = i + 1
@@ -825,6 +828,8 @@
                 quote.append(l[i])
                 i = i + 1
 
+            if i == len(l):
+                raise ValueError(_("Unterminated quote in import data: %s") % 
line)
             quote.append(l[i].strip(squote))
             ret.append(" ".join(quote))
             i = i + 1
@@ -864,8 +869,10 @@
 def importHelper(commands):
     for l in commands:
         try:
-            commandParser = createCommandParser()
+            commandParser = createCommandParser(importing=True)
             args = commandParser.parse_args(mkargv(l))
+            if hasattr(args, "store"):
+                commandParser.error(_("Select the policy store on the import 
command, not in an import record"))
             args.func(args)
         except ValueError as e:
             sys.stderr.write("%s: %s\n" % (e.__class__.__name__, str(e)))
@@ -885,7 +892,7 @@
     importParser.set_defaults(func=handleImport)
 
 
-def createCommandParser():
+def createCommandParser(importing=False):
     commandParser = seParser(prog='semanage',
                              
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
                              description=_(
@@ -895,8 +902,12 @@
     #To add a new subcommand define the parser for it in a function above and 
call it here.
     subparsers = commandParser.add_subparsers(dest='subcommand')
     subparsers.required = True
-    setupImportParser(subparsers)
-    setupExportParser(subparsers)
+    # The lines of an import are customization records only: a nested import
+    # cannot start a second transaction, and a nested export would redirect
+    # stdout to the file named by -f and exit before the import is committed.
+    if not importing:
+        setupImportParser(subparsers)
+        setupExportParser(subparsers)
     setupLoginParser(subparsers)
     setupUserParser(subparsers)
     setupPortParser(subparsers)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/selinux-python-3.11/semanage/semanage-bash-completion.sh 
new/selinux-python-3.12/semanage/semanage-bash-completion.sh
--- old/selinux-python-3.11/semanage/semanage-bash-completion.sh        
2026-07-01 18:51:05.000000000 +0200
+++ new/selinux-python-3.12/semanage/semanage-bash-completion.sh        
2026-12-02 18:39:01.000000000 +0100
@@ -57,18 +57,18 @@
 __get_all_modules () {
     semodule -l
 }
-__get_import_opts () { echo '$ALL_OPTS --f --input_file' ; }
-__get_export_opts () { echo '$ALL_OPTS --f --output_file' ; }
-__get_boolean_opts () { echo '$ALL_OPTS --on -off -1 -0' ; }
-__get_user_opts () { echo '$ALL_OPTS $MANAGED_OPTS -L --level -r --range -R 
--role '; }
-__get_login_opts () { echo '$ALL_OPTS $MANAGED_OPTS -s --seuser -r --range'; }
-__get_port_opts () { echo '$ALL_OPTS $MANAGED_OPTS -t --type -r --range -p 
--proto'; }
-__get_interface_opts () { echo '$ALL_OPTS $MANAGED_OPTS -t --type '; }
-__get_node_opts () { echo '$ALL_OPTS $MANAGED_OPTS -t --type -M --mask -p 
--proto'; }
-__get_fcontext_opts () { echo '$ALL_OPTS $MANAGED_OPTS -t --type -e --equal -f 
--ftype '; }
-__get_module_opts () { echo '$ALL_OPTS $MANAGED_OPTS --enable --disable '; }
-__get_dontaudit_opts () { echo '-S on off' ; }
-__get_permissive_opts () { echo '$ALL_OPTS -a --add -d --delete' ; }
+__get_import_opts () { echo "$ALL_OPTS --f --input_file" ; }
+__get_export_opts () { echo "$ALL_OPTS --f --output_file" ; }
+__get_boolean_opts () { echo "$ALL_OPTS --on -off -1 -0" ; }
+__get_user_opts () { echo "$ALL_OPTS $MANAGED_OPTS -L --level -r --range -R 
--role "; }
+__get_login_opts () { echo "$ALL_OPTS $MANAGED_OPTS -s --seuser -r --range"; }
+__get_port_opts () { echo "$ALL_OPTS $MANAGED_OPTS -t --type -r --range -p 
--proto"; }
+__get_interface_opts () { echo "$ALL_OPTS $MANAGED_OPTS -t --type "; }
+__get_node_opts () { echo "$ALL_OPTS $MANAGED_OPTS -t --type -M --mask -p 
--proto"; }
+__get_fcontext_opts () { echo "$ALL_OPTS $MANAGED_OPTS -t --type -e --equal -f 
--ftype "; }
+__get_module_opts () { echo "$ALL_OPTS $MANAGED_OPTS --enable --disable "; }
+__get_dontaudit_opts () { echo "-S on off" ; }
+__get_permissive_opts () { echo "$ALL_OPTS -a --add -d --delete" ; }
 
 _semanage () {
         local command=${COMP_WORDS[1]}
@@ -150,7 +150,9 @@
                 COMPREPLY=( $(compgen -W "$( __get_node_opts ) " -- "$cur") )
                return 0
         elif __contains_word "$command" ${VERBS[FCONTEXT]} ; then
-                COMPREPLY=( $(compgen -W "$( __get_fcontext_opts ) " -- 
"$cur") )
+               if [[ -z "$cur" || "$cur" == -* ]] ; then
+                       COMPREPLY=( $(compgen -W "$( __get_fcontext_opts ) " -- 
"$cur") )
+               fi
                return 0
         elif __contains_word "$command" ${VERBS[BOOLEAN]} ; then
                 COMPREPLY=( $(compgen -W "$( __get_boolean_opts ) " -- "$cur") 
)
@@ -171,4 +173,4 @@
         COMPREPLY=( $(compgen -W "$comps" -- "$cur") )
         return 0
 }
-complete -F _semanage semanage
+complete -o default -o bashdefault -F _semanage semanage
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/selinux-python-3.11/semanage/semanage-fcontext.8 
new/selinux-python-3.12/semanage/semanage-fcontext.8
--- old/selinux-python-3.11/semanage/semanage-fcontext.8        2026-07-01 
18:51:05.000000000 +0200
+++ new/selinux-python-3.12/semanage/semanage-fcontext.8        2026-12-02 
18:39:01.000000000 +0100
@@ -15,10 +15,16 @@
 
 FILE_SPEC may contain either a fully qualified path,
 or a Perl compatible regular expression (PCRE),
-describing fully qualified path(s). The only PCRE flag in use is PCRE2_DOTALL,
-which causes a wildcard '.' to match anything, including a new line.
+describing fully qualified path(s).
+The regular expression is anchored at both ends,
+so the whole path must match; a leading ^ or trailing $ is not required.
+The PCRE flags in use are PCRE2_DOTALL,
+which causes a wildcard '.' to match anything, including a new line,
+PCRE2_DOLLAR_ENDONLY, and PCRE2_EXTRA_MATCH_LINE,
+which apply the anchoring.
 Strings representing paths are processed as bytes (as opposed to Unicode),
 meaning that non-ASCII characters are not matched by a single wildcard.
+If you need to match a non-ASCII character with a wildcard, put it in a group, 
e.g. '(č)*'
 
 Note, that file context definitions specified using 'semanage fcontext'
 (i.e. local file context modifications stored in file_contexts.local)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/selinux-python-3.11/semanage/semanage-user.8 
new/selinux-python-3.12/semanage/semanage-user.8
--- old/selinux-python-3.11/semanage/semanage-user.8    2026-07-01 
18:51:05.000000000 +0200
+++ new/selinux-python-3.12/semanage/semanage-user.8    2026-12-02 
18:39:01.000000000 +0100
@@ -2,7 +2,7 @@
 .SH "NAME"
 .B semanage\-user \- SELinux Policy Management SELinux User mapping tool
 .SH "SYNOPSIS"
-.B  semanage user [\-h] [\-n] [\-N] [\-S STORE] [ \-\-add ( \-L LEVEL \-R 
ROLES \-r RANGE SEUSER) | \-\-delete SEUSER | \-\-deleteall  | \-\-extract  | 
\-\-list [\-C] | \-\-modify ( \-L LEVEL \-R ROLES \-r RANGE SEUSER ) ]
+.B  semanage user [\-h] [\-n] [\-N] [\-S STORE] [ \-\-add ( \-L LEVEL \-R 
ROLES \-r RANGE \-P PREFIX SEUSER) | \-\-delete SEUSER | \-\-deleteall  | 
\-\-extract  | \-\-list [\-C] | \-\-modify ( \-L LEVEL \-R ROLES \-r RANGE \-P 
PREFIX SEUSER ) ]
 
 .SH "DESCRIPTION"
 semanage is used to configure certain elements of
@@ -54,6 +54,14 @@
 .TP
 .I   \-R [ROLES], \-\-roles [ROLES]
 SELinux Roles. You must enclose multiple roles within quotes, separate by 
spaces. Or specify \-R multiple times.
+.TP
+.I   \-P PREFIX, \-\-prefix PREFIX
+Labeling prefix for the SELinux user, stored in
+.I users_extra
+and used by
+.BR genhomedircon (8)
+when generating home directory context entries. Defaults to
+.BR user .
 
 .SH EXAMPLE
 .nf
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/selinux-python-3.11/semanage/seobject.py 
new/selinux-python-3.12/semanage/seobject.py
--- old/selinux-python-3.11/semanage/seobject.py        2026-07-01 
18:51:05.000000000 +0200
+++ new/selinux-python-3.12/semanage/seobject.py        2026-12-02 
18:39:01.000000000 +0100
@@ -509,7 +509,7 @@
         name = "permissive_%s" % type
         modtxt = "(typepermissive %s)" % type
 
-        rc = semanage_module_install(self.sh, modtxt, len(modtxt), name, "cil")
+        rc = semanage_module_install(self.sh, modtxt.encode("utf-8"), name, 
"cil")
         if rc >= 0:
             self.commit()
 
@@ -1043,10 +1043,12 @@
         l = []
         ddict = self.get_all(True)
         for k in sorted(ddict.keys()):
-            if ddict[k][1] or ddict[k][2]:
-                l.append("-a -L %s -r %s -R '%s' %s" % (ddict[k][1], 
ddict[k][2], ddict[k][3], k))
+            prefix, level, srange, roles = ddict[k]
+            popt = "-P %s " % prefix if prefix and prefix != "user" else ""
+            if level or srange:
+                l.append("-a %s-L %s -r %s -R '%s' %s" % (popt, level, srange, 
roles, k))
             else:
-                l.append("-a -R '%s' %s" % (ddict[k][3], k))
+                l.append("-a %s-R '%s' %s" % (popt, roles, k))
         return l
 
     def list(self, heading=1, locallist=0):
@@ -1103,7 +1105,7 @@
             low = int(ports[0])
             high = int(ports[1])
 
-        if high > 65535:
+        if low < 1 or low > high or high > 65535:
             raise ValueError(_("Invalid Port"))
 
         (rc, k) = semanage_port_key_create(self.sh, low, high, proto_d)
@@ -2373,7 +2375,7 @@
         self.equiv_dist = {}
         self.equal_ind = False
         try:
-            fd = open(selinux.selinux_file_context_subs_path(), "r")
+            fd = selinux.policy_open(selinux.selinux_file_context_subs_path())
             for i in fd.readlines():
                 i = i.strip()
                 if len(i) == 0:
@@ -2386,7 +2388,7 @@
         except IOError:
             pass
         try:
-            fd = open(selinux.selinux_file_context_subs_dist_path(), "r")
+            fd = 
selinux.policy_open(selinux.selinux_file_context_subs_dist_path())
             for i in fd.readlines():
                 i = i.strip()
                 if len(i) == 0:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/selinux-python-3.11/semanage/test-permissive-store.py 
new/selinux-python-3.12/semanage/test-permissive-store.py
--- old/selinux-python-3.11/semanage/test-permissive-store.py   1970-01-01 
01:00:00.000000000 +0100
+++ new/selinux-python-3.12/semanage/test-permissive-store.py   2026-12-02 
18:39:01.000000000 +0100
@@ -0,0 +1,122 @@
+#!/usr/bin/python3
+#
+# Exercise seobject.permissiveRecords against a private, throw-away policy
+# store so that the Python calls into the libsemanage bindings are checked
+# against their actual signatures. This needs neither root nor an SELinux
+# enabled system, only the semanage bindings and seobject importable.
+
+import os
+import shutil
+import sys
+import tempfile
+import types
+import unittest
+
+import semanage
+
+# seobject imports sepolicy (which requires setools) at module level, but
+# the permissive record operations exercised here never use it. Provide an
+# empty placeholder when setools is not available, e.g. in CI, so that the
+# bindings themselves are still exercised.
+try:
+    import sepolicy  # noqa: F401
+except ImportError:
+    sys.modules["sepolicy"] = types.ModuleType("sepolicy")
+
+try:
+    import setools  # noqa: F401
+except ImportError:
+    setools = types.ModuleType("setools")
+    setools.policyrep = types.ModuleType("setools.policyrep")
+    setools.policyrep.SELinuxPolicy = type("SELinuxPolicy", (), {})
+    setools.typequery = types.ModuleType("setools.typequery")
+    setools.typequery.TypeQuery = type("TypeQuery", (), {})
+    sys.modules["setools"] = setools
+    sys.modules["setools.policyrep"] = setools.policyrep
+    sys.modules["setools.typequery"] = setools.typequery
+
+import seobject
+
+BASE_CIL = b"""
+(typeattribute cil_gen_require)
+(roleattribute cil_gen_require)
+(handleunknown allow)
+(mls true)
+(sid security)
+(sidorder (security))
+(sensitivity s0)
+(sensitivityorder (s0))
+(user system_u)
+(userrole system_u object_r)
+(userlevel system_u (s0))
+(userrange system_u ((s0) (s0)))
+(role object_r)
+(roletype object_r test_t)
+(type test_t)
+(sidcontext security (system_u object_r test_t ((s0) (s0))))
+(class test_class (test_perm))
+(classorder (test_class))
+(allow test_t self (test_class (test_perm)))
+"""
+
+STORE = "store"
+
+
+class PermissiveStoreTests(unittest.TestCase):
+
+    def setUp(self):
+        self.root = tempfile.mkdtemp(prefix="semanage-permissive-test-")
+        os.makedirs(os.path.join(self.root, "etc", "selinux"))
+        with open(os.path.join(self.root, "etc", "selinux", "semanage.conf"), 
"w") as f:
+            f.write("disable-genhomedircon = true\n")
+            f.write("[sefcontext_compile]\n")
+            f.write("path = /bin/true\n")
+            f.write("args = $@\n")
+            f.write("[end]\n")
+        base = os.path.join(self.root, STORE, "active", "modules", "100", 
"base")
+        os.makedirs(base)
+        with open(os.path.join(base, "cil"), "wb") as f:
+            f.write(BASE_CIL)
+        with open(os.path.join(base, "lang_ext"), "w") as f:
+            f.write("cil")
+
+        semanage.semanage_set_root(self.root)
+        self.sh = semanage.semanage_handle_create()
+        self.assertIsNotNone(self.sh)
+        semanage.semanage_set_create_store(self.sh, 1)
+        semanage.semanage_set_reload(self.sh, 0)
+        # Do not spawn setfiles to validate file contexts: the test policy
+        # defines none, and the host setfiles may not match the libsepol
+        # this test was built against (or may not exist at all).
+        semanage.semanage_set_check_contexts(self.sh, 0)
+        semanage.semanage_set_store_root(self.sh, "")
+        semanage.semanage_select_store(self.sh, STORE, 
semanage.SEMANAGE_CON_DIRECT)
+        self.assertGreaterEqual(semanage.semanage_connect(self.sh), 0)
+
+        # Bypass semanageRecords.__init__(), which consults the policy
+        # configuration of the running system.
+        self.records = object.__new__(seobject.permissiveRecords)
+        self.records.sh = self.sh
+        self.records.noreload = True
+        self.records.mylog = seobject.nulllogger()
+
+    def tearDown(self):
+        semanage.semanage_disconnect(self.sh)
+        semanage.semanage_handle_destroy(self.sh)
+        semanage.semanage_set_root("/")
+        shutil.rmtree(self.root)
+
+    def test_add_delete(self):
+        self.assertEqual(self.records.get_all(), [])
+
+        self.records.begin()
+        self.records.add("test_t")
+        self.assertEqual(self.records.get_all(), ["test_t"])
+
+        self.records.begin()
+        self.records.delete("test_t")
+        self.assertEqual(self.records.get_all(), [])
+
+
+if __name__ == "__main__":
+    unittest.main()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/selinux-python-3.11/semanage/test-semanage.py 
new/selinux-python-3.12/semanage/test-semanage.py
--- old/selinux-python-3.11/semanage/test-semanage.py   2026-07-01 
18:51:05.000000000 +0200
+++ new/selinux-python-3.12/semanage/test-semanage.py   2026-12-02 
18:39:01.000000000 +0100
@@ -1,3 +1,5 @@
+import os
+import tempfile
 import unittest
 import sys
 from subprocess import Popen, PIPE
@@ -35,8 +37,11 @@
             self.assertSuccess(p.returncode, err)
 
     def test_input_output(self):
-        print("Verify semanage export -f /tmp/out")
-        p = Popen(['semanage', "export", '-f', '/tmp/out'], stdout=PIPE)
+        fd, out_path = tempfile.mkstemp(prefix="semanage-out-")
+        os.close(fd)
+        self.addCleanup(os.unlink, out_path)
+        print("Verify semanage export -f %s" % out_path)
+        p = Popen(['semanage', "export", '-f', out_path], stdout=PIPE)
         out, err = p.communicate()
         self.assertSuccess(p.returncode, err)
         print("Verify semanage export -S targeted -f -")
@@ -47,16 +52,16 @@
         p = Popen(["semanage", "-S", "targeted", "-o", "-"], stdout=PIPE)
         out, err = p.communicate()
         self.assertSuccess(p.returncode, err)
-        print("Verify semanage import -f /tmp/out")
-        p = Popen(['semanage', "import", '-f', '/tmp/out'], stdout=PIPE)
+        print("Verify semanage import -f %s" % out_path)
+        p = Popen(['semanage', "import", '-f', out_path], stdout=PIPE)
         out, err = p.communicate()
         self.assertSuccess(p.returncode, err)
-        print("Verify semanage import -S targeted -f /tmp/out")
-        p = Popen(["semanage", "import", "-S", "targeted", "-f", "/tmp/out"], 
stdout=PIPE)
+        print("Verify semanage import -S targeted -f %s" % out_path)
+        p = Popen(["semanage", "import", "-S", "targeted", "-f", out_path], 
stdout=PIPE)
         out, err = p.communicate()
         self.assertSuccess(p.returncode, err)
-        print("Verify semanage -S targeted -i /tmp/out")
-        p = Popen(["semanage", "-S", "targeted", "-i", "/tmp/out"], 
stdout=PIPE)
+        print("Verify semanage -S targeted -i %s" % out_path)
+        p = Popen(["semanage", "-S", "targeted", "-i", out_path], stdout=PIPE)
         out, err = p.communicate()
         self.assertSuccess(p.returncode, err)
 
@@ -219,7 +224,7 @@
 
 def semanage_suite():
     semanage_suite = unittest.TestSuite()
-    semanage_suite.addTest(unittest.makeSuite(SemanageTests))
+    
semanage_suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(SemanageTests))
 
     return semanage_suite
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/selinux-python-3.11/sepolgen/VERSION 
new/selinux-python-3.12/sepolgen/VERSION
--- old/selinux-python-3.11/sepolgen/VERSION    2026-07-01 18:51:05.000000000 
+0200
+++ new/selinux-python-3.12/sepolgen/VERSION    2026-12-02 18:39:01.000000000 
+0100
@@ -1 +1 @@
-3.11
+3.12
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/selinux-python-3.11/sepolgen/src/sepolgen/defaults.py 
new/selinux-python-3.12/sepolgen/src/sepolgen/defaults.py
--- old/selinux-python-3.11/sepolgen/src/sepolgen/defaults.py   2026-07-01 
18:51:05.000000000 +0200
+++ new/selinux-python-3.12/sepolgen/src/sepolgen/defaults.py   2026-12-02 
18:39:01.000000000 +0100
@@ -25,7 +25,14 @@
 class PathChooser(object):
     def __init__(self, pathname):
         self.config = dict()
-        if not os.path.exists(pathname):
+        if isinstance(pathname, str):
+            candidates = (pathname,)
+        else:
+            candidates = tuple(pathname)
+        for pathname in candidates:
+            if os.path.exists(pathname):
+                break
+        else:
             self.config_pathname = "(defaults)"
             self.config["SELINUX_DEVEL_PATH"] = 
"/usr/share/selinux/default:/usr/share/selinux/mls:/usr/share/selinux/devel"
             return
@@ -68,14 +75,19 @@
 def attribute_info():
     return data_dir() + "/attribute_info"
 
+SEPOLGEN_CONF_PATHS = (
+    "/etc/selinux/sepolgen.conf",
+    "/usr/lib/selinux/sepolgen.conf",
+)
+
 def refpolicy_makefile():
-    chooser = PathChooser("/etc/selinux/sepolgen.conf")
+    chooser = PathChooser(SEPOLGEN_CONF_PATHS)
     result = chooser("Makefile")
     if not os.path.exists(result):
         result = chooser("include/Makefile")
     return result
 
 def headers():
-    chooser = PathChooser("/etc/selinux/sepolgen.conf")
+    chooser = PathChooser(SEPOLGEN_CONF_PATHS)
     return chooser("include")
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/selinux-python-3.11/sepolgen/src/sepolgen/policygen.py 
new/selinux-python-3.12/sepolgen/src/sepolgen/policygen.py
--- old/selinux-python-3.11/sepolgen/src/sepolgen/policygen.py  2026-07-01 
18:51:05.000000000 +0200
+++ new/selinux-python-3.12/sepolgen/src/sepolgen/policygen.py  2026-12-02 
18:39:01.000000000 +0100
@@ -26,9 +26,9 @@
 
 import selinux.audit2why as audit2why
 try:
-    from setools import *
-except:
-    pass
+    import setools
+except ImportError:
+    setools = None
 
 from . import refpolicy
 from . import objectmodel
@@ -85,6 +85,7 @@
         self.dontaudit = False
         self.xperms = False
 
+        self.policy = None
         self.domains = None
         self.gen_cil = False
         self.comment_start = '#'
@@ -206,23 +207,31 @@
                 rule.comment += "\n%s" % self.comment_start
                 rule.comment += "\tPossible cause is the source %s and target 
%s are different." % reason
 
-        try:
-            if ( av.type == audit2why.TERULE and
-                 "write" in av.perms and
-                 ( "dir" in av.obj_class or "open" in av.perms )):
-                if not self.domains:
-                    self.domains = seinfo(ATTRIBUTE, name="domain")[0]["types"]
-                types=[]
-
-                for i in [x[TCONTEXT] for x in sesearch([ALLOW], {SCONTEXT: 
av.src_type, CLASS: av.obj_class, PERMS: av.perms})]:
-                    if i not in self.domains:
-                        types.append(i)
+        if ( setools and
+             av.type == audit2why.TERULE and
+             "write" in av.perms and
+             ( "dir" in av.obj_class or "open" in av.perms )):
+            try:
+                if not self.policy:
+                    self.policy = setools.SELinuxPolicy()
+                    self.domains = set(str(t) for t in
+                                       
self.policy.lookup_typeattr("domain").expand())
+                q = setools.TERuleQuery(self.policy,
+                                        ruletype=[setools.TERuletype.allow],
+                                        source=av.src_type,
+                                        tclass=[av.obj_class],
+                                        perms=av.perms, perms_subset=True)
+                types = set()
+                for r in q.results():
+                    types.update(str(t) for t in r.target.expand())
+                types -= self.domains
+                types = sorted(types)
                 if len(types) == 1:
                     rule.comment += "\n%s!!!! The source type '%s' can write 
to a '%s' of the following type:\n%s %s\n" % (self.comment_start, av.src_type, 
av.obj_class, self.comment_start, ", ".join(types))
                 elif len(types) >= 1:
                     rule.comment += "\n%s!!!! The source type '%s' can write 
to a '%s' of the following types:\n%s %s\n" % (self.comment_start, av.src_type, 
av.obj_class, self.comment_start, ", ".join(types))
-        except:
-            pass
+            except setools.exception.SEToolsException:
+                pass
 
         self.module.children.append(rule)
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/selinux-python-3.11/sepolicy/pyproject.toml 
new/selinux-python-3.12/sepolicy/pyproject.toml
--- old/selinux-python-3.11/sepolicy/pyproject.toml     1970-01-01 
01:00:00.000000000 +0100
+++ new/selinux-python-3.12/sepolicy/pyproject.toml     2026-12-02 
18:39:01.000000000 +0100
@@ -0,0 +1,12 @@
+[build-system]
+requires = ["setuptools", "wheel"]
+build-backend = "setuptools.build_meta"
+
+[project]
+name = "sepolicy"
+version = "3.12"
+description = "Python tools for SELinux policy analysis (sepolicy, sepolgen)"
+license = "GPL-2.0-or-later"
+authors = [
+    { name = "SELinux Project", email = "[email protected]" }
+]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/selinux-python-3.11/sepolicy/sepolicy/__init__.py 
new/selinux-python-3.12/sepolicy/sepolicy/__init__.py
--- old/selinux-python-3.11/sepolicy/sepolicy/__init__.py       2026-07-01 
18:51:05.000000000 +0200
+++ new/selinux-python-3.12/sepolicy/sepolicy/__init__.py       2026-12-02 
18:39:01.000000000 +0100
@@ -589,7 +589,7 @@
 
 def read_file_equiv(edict, fc_path, modify):
     try:
-        with open(fc_path, "r") as fd:
+        with selinux.policy_open(fc_path) as fd:
             for e in fd:
                 f = e.split()
                 if f and not f[0].startswith('#'):
@@ -624,7 +624,7 @@
         return local_files
     local_files = []
     try:
-        with open(fc_path + ".local", "r") as fd:
+        with selinux.policy_open(fc_path + ".local") as fd:
             fc = fd.readlines()
     except OSError as e:
         if e.errno != errno.ENOENT:
@@ -650,15 +650,15 @@
     global fcdict
     if fcdict:
         return fcdict
-    fd = open(fc_path, "r")
+    fd = selinux.policy_open(fc_path)
     fc = fd.readlines()
     fd.close()
-    fd = open(fc_path + ".homedirs", "r")
+    fd = selinux.policy_open(fc_path + ".homedirs")
     fc += fd.readlines()
     fd.close()
     fcdict = {}
     try:
-        with open(fc_path + ".local", "r") as fd:
+        with selinux.policy_open(fc_path + ".local") as fd:
             fc += fd.readlines()
     except OSError as e:
         if e.errno != errno.ENOENT:
@@ -957,7 +957,7 @@
     if login_mappings:
         return login_mappings
 
-    fd = open(selinux.selinux_usersconf_path(), "r")
+    fd = selinux.policy_open(selinux.selinux_usersconf_path())
     buf = fd.read()
     fd.close()
     login_mappings = []
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/selinux-python-3.11/sepolicy/sepolicy/generate.py 
new/selinux-python-3.12/sepolicy/sepolicy/generate.py
--- old/selinux-python-3.11/sepolicy/sepolicy/generate.py       2026-07-01 
18:51:05.000000000 +0200
+++ new/selinux-python-3.12/sepolicy/sepolicy/generate.py       2026-12-02 
18:39:01.000000000 +0100
@@ -212,8 +212,6 @@
             print("Can not get port types", e)
 
         self.symbols = {}
-        self.symbols["openlog"] = "set_use_kerberos(True)"
-        self.symbols["openlog"] = "set_use_kerb_rcache(True)"
         self.symbols["openlog"] = "set_use_syslog(True)"
         self.symbols["gethostby"] = "set_use_resolve(True)"
         self.symbols["getaddrinfo"] = "set_use_resolve(True)"
@@ -226,8 +224,7 @@
         self.symbols["getpwnam"] = "set_use_uid(True)"
         self.symbols["getpwuid"] = "set_use_uid(True)"
         self.symbols["dbus_"] = "set_use_dbus(True)"
-        self.symbols["pam_"] = "set_use_pam(True)"
-        self.symbols["pam_"] = "set_use_audit(True)"
+        self.symbols["pam_"] = "set_use_pam(True);set_use_audit(True)"
         self.symbols["fork"] = "add_process('fork')"
         self.symbols["transition"] = "add_process('transition')"
         self.symbols["sigchld"] = "add_process('sigchld')"
@@ -1095,12 +1092,12 @@
                 t1 = re.sub("TEMPLATETYPE", self.name, 
self.files[i][2].fc_sock_file)
             else:
                 t1 = re.sub("TEMPLATETYPE", self.name, 
self.files[i][2].fc_file)
-            t2 = re.sub("FILENAME", i, t1)
+            t2 = t1.replace("FILENAME", re.escape(i))
             fclist.append(re.sub("FILETYPE", self.files[i][0], t2))
 
         for i in self.dirs.keys():
             t1 = re.sub("TEMPLATETYPE", self.name, self.dirs[i][2].fc_dir)
-            t2 = re.sub("FILENAME", i, t1)
+            t2 = t1.replace("FILENAME", re.escape(i))
             fclist.append(re.sub("FILETYPE", self.dirs[i][0], t2))
 
         if self.type in USERS + [SANDBOX]:
@@ -1111,11 +1108,11 @@
             raise ValueError(_("You must enter the executable path for your 
confined process"))
 
         if self.program:
-            t1 = re.sub("EXECUTABLE", self.program, executable.fc_program)
+            t1 = executable.fc_program.replace("EXECUTABLE", 
re.escape(self.program))
             fclist.append(re.sub("TEMPLATETYPE", self.name, t1))
 
         if self.initscript != "":
-            t1 = re.sub("EXECUTABLE", self.initscript, 
executable.fc_initscript)
+            t1 = executable.fc_initscript.replace("EXECUTABLE", 
re.escape(self.initscript))
             fclist.append(re.sub("TEMPLATETYPE", self.name, t1))
 
         fclist.sort()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/selinux-python-3.11/sepolicy/sepolicy/templates/etc_rw.py 
new/selinux-python-3.12/sepolicy/sepolicy/templates/etc_rw.py
--- old/selinux-python-3.11/sepolicy/sepolicy/templates/etc_rw.py       
2026-07-01 18:51:05.000000000 +0200
+++ new/selinux-python-3.12/sepolicy/sepolicy/templates/etc_rw.py       
2026-12-02 18:39:01.000000000 +0100
@@ -134,6 +134,10 @@
 FILENAME               --      
gen_context(system_u:object_r:TEMPLATETYPE_etc_rw_t,s0)
 """
 
+fc_sock_file="""\
+FILENAME               -s      
gen_context(system_u:object_r:TEMPLATETYPE_etc_rw_t,s0)
+"""
+
 fc_dir="""\
 FILENAME(/.*)?         gen_context(system_u:object_r:TEMPLATETYPE_etc_rw_t,s0)
 """
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/selinux-python-3.11/sepolicy/sepolicy/templates/tmp.py 
new/selinux-python-3.12/sepolicy/sepolicy/templates/tmp.py
--- old/selinux-python-3.11/sepolicy/sepolicy/templates/tmp.py  2026-07-01 
18:51:05.000000000 +0200
+++ new/selinux-python-3.12/sepolicy/sepolicy/templates/tmp.py  2026-12-02 
18:39:01.000000000 +0100
@@ -127,3 +127,16 @@
        files_search_tmp($1)
        admin_pattern($1, TEMPLATETYPE_tmp_t)
 """
+
+########################### File Context ##################################
+fc_file="""\
+FILENAME               --      
gen_context(system_u:object_r:TEMPLATETYPE_tmp_t,s0)
+"""
+
+fc_sock_file="""\
+FILENAME               -s      
gen_context(system_u:object_r:TEMPLATETYPE_tmp_t,s0)
+"""
+
+fc_dir="""\
+FILENAME(/.*)?         gen_context(system_u:object_r:TEMPLATETYPE_tmp_t,s0)
+"""
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/selinux-python-3.11/sepolicy/sepolicy/templates/unit_file.py 
new/selinux-python-3.12/sepolicy/sepolicy/templates/unit_file.py
--- old/selinux-python-3.11/sepolicy/sepolicy/templates/unit_file.py    
2026-07-01 18:51:05.000000000 +0200
+++ new/selinux-python-3.12/sepolicy/sepolicy/templates/unit_file.py    
2026-12-02 18:39:01.000000000 +0100
@@ -66,9 +66,15 @@
        allow $1 TEMPLATETYPE_unit_file_t:service all_service_perms;
 """
 
+te_stream_rules = ""
+
+if_stream_rules = ""
+
 ########################### File Context ##################################
 fc_file="""\
 FILENAME               --      
gen_context(system_u:object_r:TEMPLATETYPE_unit_file_t,s0)
 """
 
+fc_sock_file = ""
+
 fc_dir=""
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/selinux-python-3.11/sepolicy/sepolicy/templates/var_cache.py 
new/selinux-python-3.12/sepolicy/sepolicy/templates/var_cache.py
--- old/selinux-python-3.11/sepolicy/sepolicy/templates/var_cache.py    
2026-07-01 18:51:05.000000000 +0200
+++ new/selinux-python-3.12/sepolicy/sepolicy/templates/var_cache.py    
2026-12-02 18:39:01.000000000 +0100
@@ -152,6 +152,10 @@
 FILENAME               --      
gen_context(system_u:object_r:TEMPLATETYPE_cache_t,s0)
 """
 
+fc_sock_file="""\
+FILENAME               -s      
gen_context(system_u:object_r:TEMPLATETYPE_cache_t,s0)
+"""
+
 fc_dir="""\
 FILENAME(/.*)?         gen_context(system_u:object_r:TEMPLATETYPE_cache_t,s0)
 """
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/selinux-python-3.11/sepolicy/sepolicy/templates/var_log.py 
new/selinux-python-3.12/sepolicy/sepolicy/templates/var_log.py
--- old/selinux-python-3.11/sepolicy/sepolicy/templates/var_log.py      
2026-07-01 18:51:05.000000000 +0200
+++ new/selinux-python-3.12/sepolicy/sepolicy/templates/var_log.py      
2026-12-02 18:39:01.000000000 +0100
@@ -106,10 +106,18 @@
 """
 
 ########################### File Context ##################################
+te_stream_rules = ""
+
+if_stream_rules = ""
+
 fc_file="""\
 FILENAME               --      
gen_context(system_u:object_r:TEMPLATETYPE_log_t,s0)
 """
 
+fc_sock_file="""\
+FILENAME               -s      
gen_context(system_u:object_r:TEMPLATETYPE_log_t,s0)
+"""
+
 fc_dir="""\
 FILENAME(/.*)?         gen_context(system_u:object_r:TEMPLATETYPE_log_t,s0)
 """
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/selinux-python-3.11/sepolicy/sepolicy/templates/var_spool.py 
new/selinux-python-3.12/sepolicy/sepolicy/templates/var_spool.py
--- old/selinux-python-3.11/sepolicy/sepolicy/templates/var_spool.py    
2026-07-01 18:51:05.000000000 +0200
+++ new/selinux-python-3.12/sepolicy/sepolicy/templates/var_spool.py    
2026-12-02 18:39:01.000000000 +0100
@@ -151,6 +151,10 @@
 FILENAME               --      
gen_context(system_u:object_r:TEMPLATETYPE_spool_t,s0)
 """
 
+fc_sock_file="""\
+FILENAME               -s      
gen_context(system_u:object_r:TEMPLATETYPE_spool_t,s0)
+"""
+
 fc_dir="""\
 FILENAME(/.*)?         gen_context(system_u:object_r:TEMPLATETYPE_spool_t,s0)
 """
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/selinux-python-3.11/sepolicy/setup.py 
new/selinux-python-3.12/sepolicy/setup.py
--- old/selinux-python-3.11/sepolicy/setup.py   2026-07-01 18:51:05.000000000 
+0200
+++ new/selinux-python-3.12/sepolicy/setup.py   2026-12-02 18:39:01.000000000 
+0100
@@ -6,10 +6,8 @@
 
 setup(
     name="sepolicy",
-    version="3.11",
+    version="3.12",
     description="Python SELinux Policy Analyses bindings",
-    author="Daniel Walsh",
-    author_email="[email protected]",
     packages=[
         "sepolicy",
         "sepolicy.templates",

++++++ semodule-utils-3.11.tar.gz -> semodule-utils-3.12.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/semodule-utils-3.11/Makefile 
new/semodule-utils-3.12/Makefile
--- old/semodule-utils-3.11/Makefile    2026-07-01 18:51:05.000000000 +0200
+++ new/semodule-utils-3.12/Makefile    2026-12-02 18:39:01.000000000 +0100
@@ -6,3 +6,4 @@
        done
 
 test:
+       ./tests/bad-data/run.sh
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/semodule-utils-3.11/VERSION 
new/semodule-utils-3.12/VERSION
--- old/semodule-utils-3.11/VERSION     2026-07-01 18:51:05.000000000 +0200
+++ new/semodule-utils-3.12/VERSION     2026-12-02 18:39:01.000000000 +0100
@@ -1 +1 @@
-3.11
+3.12
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/semodule-utils-3.11/semodule_package/semodule_package.c 
new/semodule-utils-3.12/semodule_package/semodule_package.c
--- old/semodule-utils-3.11/semodule_package/semodule_package.c 2026-07-01 
18:51:05.000000000 +0200
+++ new/semodule-utils-3.12/semodule_package/semodule_package.c 2026-12-02 
18:39:01.000000000 +0100
@@ -285,7 +285,7 @@
        if (sepol_module_package_write(pkg, out)) {
                fprintf(stderr,
                        "%s:  Error while writing module package to %s\n",
-                       argv[0], argv[1]);
+                       argv[0], outfile);
                goto failure;
        }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/semodule-utils-3.11/tests/bad-data/fixtures/base/minimal_base.conf 
new/semodule-utils-3.12/tests/bad-data/fixtures/base/minimal_base.conf
--- old/semodule-utils-3.11/tests/bad-data/fixtures/base/minimal_base.conf      
1970-01-01 01:00:00.000000000 +0100
+++ new/semodule-utils-3.12/tests/bad-data/fixtures/base/minimal_base.conf      
2026-12-02 18:39:01.000000000 +0100
@@ -0,0 +1,15 @@
+# Base .conf: bare class declaration, then permission block (checkmodule 
requires both).
+class file
+sid kernel
+class file { read write ioctl }
+
+type base_t;
+
+allow base_t base_t : file read;
+neverallow base_t base_t : file write;
+neverallowxperm base_t base_t : file ioctl 0x1000;
+
+role object_r;
+role object_r types { base_t };
+user user_u roles { object_r };
+sid kernel user_u:object_r:base_t
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/semodule-utils-3.11/tests/bad-data/fixtures/file_contexts/bad_context.mod.fc
 
new/semodule-utils-3.12/tests/bad-data/fixtures/file_contexts/bad_context.mod.fc
--- 
old/semodule-utils-3.11/tests/bad-data/fixtures/file_contexts/bad_context.mod.fc
    1970-01-01 01:00:00.000000000 +0100
+++ 
new/semodule-utils-3.12/tests/bad-data/fixtures/file_contexts/bad_context.mod.fc
    2026-12-02 18:39:01.000000000 +0100
@@ -0,0 +1 @@
+/usr/bin/bad   not_a_valid_selinux_context
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/semodule-utils-3.11/tests/bad-data/fixtures/file_contexts/bad_fields.mod.fc 
new/semodule-utils-3.12/tests/bad-data/fixtures/file_contexts/bad_fields.mod.fc
--- 
old/semodule-utils-3.11/tests/bad-data/fixtures/file_contexts/bad_fields.mod.fc 
    1970-01-01 01:00:00.000000000 +0100
+++ 
new/semodule-utils-3.12/tests/bad-data/fixtures/file_contexts/bad_fields.mod.fc 
    2026-12-02 18:39:01.000000000 +0100
@@ -0,0 +1 @@
+only_one_field_on_this_line
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/semodule-utils-3.11/tests/bad-data/fixtures/file_contexts/bad_mls.mod.fc 
new/semodule-utils-3.12/tests/bad-data/fixtures/file_contexts/bad_mls.mod.fc
--- 
old/semodule-utils-3.11/tests/bad-data/fixtures/file_contexts/bad_mls.mod.fc    
    1970-01-01 01:00:00.000000000 +0100
+++ 
new/semodule-utils-3.12/tests/bad-data/fixtures/file_contexts/bad_mls.mod.fc    
    2026-12-02 18:39:01.000000000 +0100
@@ -0,0 +1 @@
+/usr/bin/bad_mls       --      system_u:object_r:test_good_exec_t:s0:c999
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/semodule-utils-3.11/tests/bad-data/fixtures/file_contexts/good.mod.fc 
new/semodule-utils-3.12/tests/bad-data/fixtures/file_contexts/good.mod.fc
--- old/semodule-utils-3.11/tests/bad-data/fixtures/file_contexts/good.mod.fc   
1970-01-01 01:00:00.000000000 +0100
+++ new/semodule-utils-3.12/tests/bad-data/fixtures/file_contexts/good.mod.fc   
2026-12-02 18:39:01.000000000 +0100
@@ -0,0 +1 @@
+/usr/bin/test_good     --      system_u:object_r:test_good_exec_t:s0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/semodule-utils-3.11/tests/bad-data/fixtures/modules/good.te 
new/semodule-utils-3.12/tests/bad-data/fixtures/modules/good.te
--- old/semodule-utils-3.11/tests/bad-data/fixtures/modules/good.te     
1970-01-01 01:00:00.000000000 +0100
+++ new/semodule-utils-3.12/tests/bad-data/fixtures/modules/good.te     
2026-12-02 18:39:01.000000000 +0100
@@ -0,0 +1,8 @@
+module test_good 1.0;
+
+require {
+       type test_good_t;
+       class file { read };
+}
+
+allow test_good_t self:file read;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/semodule-utils-3.11/tests/bad-data/fixtures/modules/module_a.te 
new/semodule-utils-3.12/tests/bad-data/fixtures/modules/module_a.te
--- old/semodule-utils-3.11/tests/bad-data/fixtures/modules/module_a.te 
1970-01-01 01:00:00.000000000 +0100
+++ new/semodule-utils-3.12/tests/bad-data/fixtures/modules/module_a.te 
2026-12-02 18:39:01.000000000 +0100
@@ -0,0 +1,8 @@
+module module_a 1.0;
+
+require {
+       type other_t;
+       class file { read };
+}
+
+allow other_t other_t : file read;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/semodule-utils-3.11/tests/bad-data/fixtures/modules/module_b.te 
new/semodule-utils-3.12/tests/bad-data/fixtures/modules/module_b.te
--- old/semodule-utils-3.11/tests/bad-data/fixtures/modules/module_b.te 
1970-01-01 01:00:00.000000000 +0100
+++ new/semodule-utils-3.12/tests/bad-data/fixtures/modules/module_b.te 
2026-12-02 18:39:01.000000000 +0100
@@ -0,0 +1,8 @@
+module module_b 1.0;
+
+require {
+       class file { read };
+}
+
+type other_t;
+allow other_t other_t : file read;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/semodule-utils-3.11/tests/bad-data/fixtures/modules/neverallow_good.te 
new/semodule-utils-3.12/tests/bad-data/fixtures/modules/neverallow_good.te
--- old/semodule-utils-3.11/tests/bad-data/fixtures/modules/neverallow_good.te  
1970-01-01 01:00:00.000000000 +0100
+++ new/semodule-utils-3.12/tests/bad-data/fixtures/modules/neverallow_good.te  
2026-12-02 18:39:01.000000000 +0100
@@ -0,0 +1,8 @@
+module neverallow_good 1.0;
+
+require {
+       type base_t;
+       class file { read };
+}
+
+allow base_t base_t : file read;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/semodule-utils-3.11/tests/bad-data/fixtures/modules/neverallow_self.te 
new/semodule-utils-3.12/tests/bad-data/fixtures/modules/neverallow_self.te
--- old/semodule-utils-3.11/tests/bad-data/fixtures/modules/neverallow_self.te  
1970-01-01 01:00:00.000000000 +0100
+++ new/semodule-utils-3.12/tests/bad-data/fixtures/modules/neverallow_self.te  
2026-12-02 18:39:01.000000000 +0100
@@ -0,0 +1,10 @@
+module neverallow_self 1.0;
+
+require {
+       class file { read write };
+}
+
+type foo_t;
+
+allow foo_t foo_t : file { read write };
+neverallow foo_t foo_t : file write;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/semodule-utils-3.11/tests/bad-data/fixtures/modules/neverallow_violator.te 
new/semodule-utils-3.12/tests/bad-data/fixtures/modules/neverallow_violator.te
--- 
old/semodule-utils-3.11/tests/bad-data/fixtures/modules/neverallow_violator.te  
    1970-01-01 01:00:00.000000000 +0100
+++ 
new/semodule-utils-3.12/tests/bad-data/fixtures/modules/neverallow_violator.te  
    2026-12-02 18:39:01.000000000 +0100
@@ -0,0 +1,8 @@
+module neverallow_violator 1.0;
+
+require {
+       type base_t;
+       class file { read write };
+}
+
+allow base_t base_t : file write;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/semodule-utils-3.11/tests/bad-data/fixtures/modules/neverallow_xperm_self.te
 
new/semodule-utils-3.12/tests/bad-data/fixtures/modules/neverallow_xperm_self.te
--- 
old/semodule-utils-3.11/tests/bad-data/fixtures/modules/neverallow_xperm_self.te
    1970-01-01 01:00:00.000000000 +0100
+++ 
new/semodule-utils-3.12/tests/bad-data/fixtures/modules/neverallow_xperm_self.te
    2026-12-02 18:39:01.000000000 +0100
@@ -0,0 +1,11 @@
+module neverallow_xperm_self 1.0;
+
+require {
+       class file { read write ioctl };
+}
+
+type foo_t;
+
+allow foo_t foo_t : file ioctl;
+allowxperm foo_t foo_t : file ioctl 0x2000;
+neverallowxperm foo_t foo_t : file ioctl 0x2000;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/semodule-utils-3.11/tests/bad-data/fixtures/modules/neverallow_xperm_violator.te
 
new/semodule-utils-3.12/tests/bad-data/fixtures/modules/neverallow_xperm_violator.te
--- 
old/semodule-utils-3.11/tests/bad-data/fixtures/modules/neverallow_xperm_violator.te
        1970-01-01 01:00:00.000000000 +0100
+++ 
new/semodule-utils-3.12/tests/bad-data/fixtures/modules/neverallow_xperm_violator.te
        2026-12-02 18:39:01.000000000 +0100
@@ -0,0 +1,9 @@
+module neverallow_xperm_violator 1.0;
+
+require {
+       type base_t;
+       class file { read write ioctl };
+}
+
+allow base_t base_t : file ioctl;
+allowxperm base_t base_t : file ioctl 0x1000;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/semodule-utils-3.11/tests/bad-data/run.sh 
new/semodule-utils-3.12/tests/bad-data/run.sh
--- old/semodule-utils-3.11/tests/bad-data/run.sh       1970-01-01 
01:00:00.000000000 +0100
+++ new/semodule-utils-3.12/tests/bad-data/run.sh       2026-12-02 
18:39:01.000000000 +0100
@@ -0,0 +1,904 @@
+#!/bin/sh
+#
+# Bad-data tests for semodule_package, sefcontext_compile, and
+# semodule_link/semodule_expand in the modular policy packaging pipeline.
+# Covers packaging path edge cases (-m/-f), documents deferred rejection of bad
+# .mod.fc content at packaging time, validates labeling through 
sefcontext_compile,
+# and exercises neverallow enforcement at link/expand. Unreadable -m/-f cases 
skip
+# when run as root; CI runs this script as non-root.
+#
+
+set -u
+
+# Prefer an absolute script dir, but keep a relative dirname when cd fails.
+# Non-root CI can inherit the repo as CWD without being able to traverse
+# /home/runner/work/...; relative paths from that CWD still work.
+BASEDIR=$(dirname -- "$0")
+ABS_BASEDIR=$(CDPATH= cd -- "${BASEDIR}" 2>/dev/null && pwd) || ABS_BASEDIR=
+if [ -n "${ABS_BASEDIR}" ]; then
+       BASEDIR="${ABS_BASEDIR}"
+fi
+FIXTURES="${BASEDIR}/fixtures"
+if [ ! -d "${FIXTURES}" ]; then
+       echo "FAIL: cannot resolve fixtures directory (\$0=$0 
BASEDIR=${BASEDIR})" >&2
+       exit 1
+fi
+OUTDIR=$(mktemp -d "${TMPDIR:-/tmp}/semodule-package-bad-data.XXXXXX")
+PASS=0
+FAIL=0
+
+CHECKMODULE=${CHECKMODULE:-checkmodule}
+# Modular TE for MCS/MLS builds (checkmodule -M -m).
+CHECKMODULE_MOD_FLAGS=${CHECKMODULE_MOD_FLAGS:--M -m}
+SEMODULE_PACKAGE=${SEMODULE_PACKAGE:-semodule_package}
+SEMODULE_UNPACKAGE=${SEMODULE_UNPACKAGE:-semodule_unpackage}
+SEFCONTEXT_COMPILE=${SEFCONTEXT_COMPILE:-sefcontext_compile}
+SEMODULE_LINK=${SEMODULE_LINK:-semodule_link}
+SEMODULE_EXPAND=${SEMODULE_EXPAND:-semodule_expand}
+
+GOOD_TE="${FIXTURES}/modules/good.te"
+GOOD_MOD="${OUTDIR}/test_good.mod"
+
+cleanup() {
+       rm -rf "${OUTDIR}"
+}
+trap cleanup EXIT
+
+die() {
+       echo "FAIL: $*" >&2
+       FAIL=$((FAIL + 1))
+}
+
+pass() {
+       echo "==== $*"
+       PASS=$((PASS + 1))
+       echo ""
+}
+
+build_good_mod() {
+       echo "==== Setup: build control module ${GOOD_MOD} from good.te"
+       rm -f "${GOOD_MOD}"
+
+       set +e
+       # shellcheck disable=SC2086
+       "${CHECKMODULE}" ${CHECKMODULE_MOD_FLAGS} -o "${GOOD_MOD}" "${GOOD_TE}" 
\
+               2>"${OUTDIR}/build_good.err"
+       rc=$?
+       set -e
+
+       if [ "${rc}" -ne 0 ]; then
+               echo "FAIL: could not build control module from ${GOOD_TE}" >&2
+               cat "${OUTDIR}/build_good.err" >&2
+               exit 1
+       fi
+       if [ ! -s "${GOOD_MOD}" ]; then
+               echo "FAIL: ${GOOD_MOD} is empty" >&2
+               exit 1
+       fi
+       echo ""
+}
+
+expect_package_pass() {
+       desc="$1"
+       outname="$2"
+       shift 2
+
+       outpp="${OUTDIR}/${outname}.pp"
+       stderr="${OUTDIR}/${outname}.err"
+
+       echo "==== POSITIVE (expect semodule_package success): ${desc}"
+       rm -f "${outpp}"
+
+       set +e
+       "${SEMODULE_PACKAGE}" -o "${outpp}" "$@" 2>"${stderr}"
+       rc=$?
+       set -e
+
+       if [ "${rc}" -ne 0 ]; then
+               echo "stderr:" >&2
+               cat "${stderr}" >&2
+               die "${desc}: expected exit 0, got rc=${rc}"
+               return 0
+       fi
+       if [ ! -s "${outpp}" ]; then
+               die "${desc}: expected non-empty ${outpp}"
+               return 0
+       fi
+
+       pass "${desc} (exit 0, .pp created)"
+}
+
+expect_package_pass_deferred() {
+       desc="$1"
+       outname="$2"
+       shift 2
+
+       outpp="${OUTDIR}/${outname}.pp"
+       stderr="${OUTDIR}/${outname}.err"
+
+       echo "==== DOCUMENT (semodule_package accepts input; validate in 
sefcontext_compile): ${desc}"
+       rm -f "${outpp}"
+
+       set +e
+       "${SEMODULE_PACKAGE}" -o "${outpp}" "$@" 2>"${stderr}"
+       rc=$?
+       set -e
+
+       if [ "${rc}" -ne 0 ]; then
+               echo "stderr:" >&2
+               cat "${stderr}" >&2
+               die "${desc}: expected exit 0 at packaging stage, got rc=${rc}"
+               return 0
+       fi
+       if [ ! -s "${outpp}" ]; then
+               die "${desc}: expected non-empty ${outpp} at packaging stage"
+               return 0
+       fi
+
+       pass "${desc} (packaging exit 0; labeling validation deferred to 
sefcontext_compile)"
+}
+
+expect_package_fail() {
+       desc="$1"
+       pattern="$2"
+       outname="$3"
+       shift 3
+
+       outpp="${OUTDIR}/${outname}.pp"
+       stderr="${OUTDIR}/${outname}.err"
+
+       echo "==== NEGATIVE (expect semodule_package failure): ${desc}"
+       rm -f "${outpp}"
+
+       set +e
+       "${SEMODULE_PACKAGE}" -o "${outpp}" "$@" 2>"${stderr}"
+       rc=$?
+       set -e
+
+       if [ "${rc}" -eq 0 ]; then
+               die "${desc}: expected non-zero exit, got rc=0"
+               return 0
+       fi
+       if [ -f "${outpp}" ]; then
+               die "${desc}: did not expect output ${outpp}"
+               return 0
+       fi
+       if ! grep -Eq "${pattern}" "${stderr}"; then
+               echo "FAIL: stderr did not match /${pattern}/" >&2
+               cat "${stderr}" >&2
+               FAIL=$((FAIL + 1))
+               return 0
+       fi
+
+       pass "${desc} (rejected as expected, rc=${rc})"
+}
+
+expect_package_fail_unreadable() {
+       desc="unreadable -m file"
+       mod="${OUTDIR}/unreadable.mod"
+       outpp="${OUTDIR}/unreadable.pp"
+       stderr="${OUTDIR}/unreadable.err"
+
+       echo "==== NEGATIVE (expect semodule_package failure): ${desc}"
+       if [ "$(id -u)" -eq 0 ]; then
+               echo "SKIP: root can read mode 000 files; unreadable check is 
non-root only"
+               PASS=$((PASS + 1))
+               echo ""
+               return 0
+       fi
+
+       rm -f "${outpp}"
+       cp "${GOOD_MOD}" "${mod}"
+       chmod 000 "${mod}"
+
+       set +e
+       "${SEMODULE_PACKAGE}" -o "${outpp}" -m "${mod}" 2>"${stderr}"
+       rc=$?
+       set -e
+
+       if [ "${rc}" -eq 0 ]; then
+               die "${desc}: expected non-zero exit, got rc=0"
+               return 0
+       fi
+       if [ -f "${outpp}" ]; then
+               die "${desc}: did not expect output ${outpp}"
+               return 0
+       fi
+       if ! grep -Eq 'Permission denied|Could not open|Failed to open' 
"${stderr}"; then
+               echo "FAIL: stderr did not mention permission or open failure" 
>&2
+               cat "${stderr}" >&2
+               FAIL=$((FAIL + 1))
+               return 0
+       fi
+
+       pass "${desc} (rejected as expected, rc=${rc})"
+}
+
+expect_package_fail_unreadable_fc() {
+       desc="unreadable -f file"
+       fc="${OUTDIR}/unreadable.mod.fc"
+       outpp="${OUTDIR}/unreadable_fc.pp"
+       stderr="${OUTDIR}/unreadable_fc.err"
+
+       echo "==== NEGATIVE (expect semodule_package failure): ${desc}"
+       if [ "$(id -u)" -eq 0 ]; then
+               echo "SKIP: root can read mode 000 files; unreadable check is 
non-root only"
+               PASS=$((PASS + 1))
+               echo ""
+               return 0
+       fi
+
+       rm -f "${outpp}"
+       cp "${GOOD_FC}" "${fc}"
+       chmod 000 "${fc}"
+
+       set +e
+       "${SEMODULE_PACKAGE}" -o "${outpp}" -m "${GOOD_MOD}" -f "${fc}" \
+               2>"${stderr}"
+       rc=$?
+       set -e
+
+       if [ "${rc}" -eq 0 ]; then
+               die "${desc}: expected non-zero exit, got rc=0"
+               return 0
+       fi
+       if [ -f "${outpp}" ]; then
+               die "${desc}: did not expect output ${outpp}"
+               return 0
+       fi
+       if ! grep -Eq 'Permission denied|Could not open|Failed to open' 
"${stderr}"; then
+               echo "FAIL: stderr did not mention permission or open failure" 
>&2
+               cat "${stderr}" >&2
+               FAIL=$((FAIL + 1))
+               return 0
+       fi
+
+       pass "${desc} (rejected as expected, rc=${rc})"
+}
+
+find_policy_file() {
+       if [ -n "${POLICY_FILE:-}" ] && [ -f "${POLICY_FILE}" ]; then
+               echo "${POLICY_FILE}"
+               return 0
+       fi
+
+       # Prefer the active policy store (SELINUXTYPE); fall back to targeted, 
then any
+       # installed policy.* (POLICY_FILE overrides all of this).
+       selinuxtype=targeted
+       if [ -r /etc/selinux/config ]; then
+               selinuxtype=$(grep -E '^[[:space:]]*SELINUXTYPE=' 
/etc/selinux/config 2>/dev/null \
+                       | tail -1 | cut -d= -f2- | tr -d ' "')
+               [ -n "${selinuxtype}" ] || selinuxtype=targeted
+       fi
+
+       # shellcheck disable=SC2086
+       set -- /etc/selinux/"${selinuxtype}"/policy/policy.*
+       if [ -f "$1" ]; then
+               echo "$1"
+               return 0
+       fi
+
+       for policy in /etc/selinux/*/policy/policy.*; do
+               [ -f "${policy}" ] || continue
+               echo "${policy}"
+               return 0
+       done
+
+       return 1
+}
+
+expect_sefcontext_pass() {
+       desc="$1"
+       outname="$2"
+       fc="$3"
+       policy="${4:-}"
+
+       outbin="${OUTDIR}/${outname}.bin"
+       stderr="${OUTDIR}/${outname}.err"
+
+       echo "==== POSITIVE (expect sefcontext_compile success): ${desc}"
+       rm -f "${outbin}"
+
+       set +e
+       if [ -n "${policy}" ]; then
+               "${SEFCONTEXT_COMPILE}" -p "${policy}" -o "${outbin}" "${fc}" \
+                       2>"${stderr}"
+       else
+               "${SEFCONTEXT_COMPILE}" -o "${outbin}" "${fc}" 2>"${stderr}"
+       fi
+       rc=$?
+       set -e
+
+       if [ "${rc}" -ne 0 ]; then
+               cat "${stderr}" >&2
+               die "${desc}: expected exit 0, got rc=${rc}"
+               return 0
+       fi
+       if [ ! -s "${outbin}" ]; then
+               die "${desc}: expected non-empty ${outbin}"
+               return 0
+       fi
+
+       pass "${desc} (sefcontext_compile succeeded)"
+}
+
+expect_sefcontext_fail() {
+       desc="$1"
+       pattern="$2"
+       outname="$3"
+       fc="$4"
+       policy="${5:-}"
+
+       outbin="${OUTDIR}/${outname}.bin"
+       stderr="${OUTDIR}/${outname}.err"
+
+       echo "==== NEGATIVE (expect sefcontext_compile failure): ${desc}"
+       rm -f "${outbin}"
+
+       set +e
+       if [ -n "${policy}" ]; then
+               "${SEFCONTEXT_COMPILE}" -p "${policy}" -o "${outbin}" "${fc}" \
+                       2>"${stderr}"
+       else
+               "${SEFCONTEXT_COMPILE}" -o "${outbin}" "${fc}" 2>"${stderr}"
+       fi
+       rc=$?
+       set -e
+
+       if [ "${rc}" -eq 0 ]; then
+               die "${desc}: expected non-zero exit, got rc=0"
+               return 0
+       fi
+       if [ -f "${outbin}" ] && [ -s "${outbin}" ]; then
+               die "${desc}: did not expect successful ${outbin}"
+               return 0
+       fi
+       if ! grep -Eq "${pattern}" "${stderr}"; then
+               echo "FAIL: stderr did not match /${pattern}/" >&2
+               cat "${stderr}" >&2
+               FAIL=$((FAIL + 1))
+               return 0
+       fi
+
+       pass "${desc} (rejected as expected, rc=${rc})"
+}
+
+expect_sefcontext_fail_or_skip_no_policy() {
+       desc="$1"
+       pattern="$2"
+       outname="$3"
+       fc="$4"
+
+       policy=$(find_policy_file) || policy=
+       if [ -z "${policy}" ]; then
+               echo "==== SKIP (no binary policy for -p validation): ${desc}"
+               echo "Set POLICY_FILE= to enable this check."
+               PASS=$((PASS + 1))
+               echo ""
+               return 0
+       fi
+
+       expect_sefcontext_fail "${desc}" "${pattern}" "${outname}" "${fc}" \
+               "${policy}"
+}
+
+expect_sefcontext_pass_deferred() {
+       desc="$1"
+       outname="$2"
+       fc="$3"
+
+       outbin="${OUTDIR}/${outname}.bin"
+       stderr="${OUTDIR}/${outname}.err"
+
+       echo "==== DOCUMENT (sefcontext_compile accepts input; complements 
packaging deferral): ${desc}"
+       rm -f "${outbin}"
+
+       set +e
+       "${SEFCONTEXT_COMPILE}" -o "${outbin}" "${fc}" 2>"${stderr}"
+       rc=$?
+       set -e
+
+       if [ "${rc}" -ne 0 ]; then
+               cat "${stderr}" >&2
+               die "${desc}: expected exit 0 at compile stage, got rc=${rc}"
+               return 0
+       fi
+       if [ ! -s "${outbin}" ]; then
+               die "${desc}: expected non-empty ${outbin} at compile stage"
+               return 0
+       fi
+
+       pass "${desc} (sefcontext_compile exit 0; complements packaging 
deferral)"
+}
+
+build_loadable_package() {
+       te="$1"
+       mod="$2"
+       pp="$3"
+
+       set +e
+       # Non-MLS modular build to match fixtures/base/minimal_base.conf.
+       "${CHECKMODULE}" -m -o "${mod}" "${te}" 2>"${mod}.err"
+       rc=$?
+       set -e
+       if [ "${rc}" -ne 0 ]; then
+               echo "FAIL: checkmodule could not build ${te}" >&2
+               cat "${mod}.err" >&2
+               exit 1
+       fi
+
+       set +e
+       "${SEMODULE_PACKAGE}" -o "${pp}" -m "${mod}" 2>"${pp}.err"
+       rc=$?
+       set -e
+       if [ "${rc}" -ne 0 ]; then
+               echo "FAIL: semodule_package could not build ${pp}" >&2
+               cat "${pp}.err" >&2
+               exit 1
+       fi
+}
+
+expect_checkmodule_pass() {
+       desc="$1"
+       te="$2"
+       mod="${OUTDIR}/$(basename "${te}" .te).mod"
+
+       echo "==== DOCUMENT (checkmodule accepts module; enforcement deferred 
to expand): ${desc}"
+       rm -f "${mod}" "${mod}.err"
+
+       set +e
+       "${CHECKMODULE}" -m -o "${mod}" "${te}" 2>"${mod}.err"
+       rc=$?
+       set -e
+       if [ "${rc}" -ne 0 ]; then
+               cat "${mod}.err" >&2
+               die "${desc}: expected checkmodule success, got rc=${rc}"
+               return 0
+       fi
+       if [ ! -s "${mod}" ]; then
+               die "${desc}: expected non-empty ${mod}"
+               return 0
+       fi
+
+       pass "${desc} (checkmodule exit 0, .mod created)"
+}
+
+# Sets LINK_EXPAND_LINK_RC and LINK_EXPAND_EXPAND_RC (-1 if expand not run).
+run_link_expand() {
+       link_out="$1"
+       expand_out="$2"
+       base_pp="$3"
+       shift 3
+
+       rm -f "${link_out}" "${expand_out}" "${link_out}.err" 
"${expand_out}.err"
+
+       set +e
+       "${SEMODULE_LINK}" -o "${link_out}" "${base_pp}" "$@" \
+               2>"${link_out}.err"
+       LINK_EXPAND_LINK_RC=$?
+       set -e
+       if [ "${LINK_EXPAND_LINK_RC}" -ne 0 ]; then
+               cat "${link_out}.err" >&2
+               LINK_EXPAND_EXPAND_RC=-1
+               return 0
+       fi
+
+       set +e
+       "${SEMODULE_EXPAND}" "${link_out}" "${expand_out}" \
+               2>"${expand_out}.err"
+       LINK_EXPAND_EXPAND_RC=$?
+       set -e
+       if [ "${LINK_EXPAND_EXPAND_RC}" -ne 0 ]; then
+               cat "${expand_out}.err" >&2
+       fi
+}
+
+expect_link_expand_pass() {
+       desc="$1"
+       link_out="$2"
+       expand_out="$3"
+       base_pp="$4"
+       shift 4
+
+       echo "==== POSITIVE (expect link + expand success): ${desc}"
+       run_link_expand "${link_out}" "${expand_out}" "${base_pp}" "$@"
+       if [ "${LINK_EXPAND_LINK_RC}" -ne 0 ]; then
+               die "${desc}: semodule_link failed, rc=${LINK_EXPAND_LINK_RC}"
+               return 0
+       fi
+       if [ "${LINK_EXPAND_EXPAND_RC}" -ne 0 ]; then
+               die "${desc}: semodule_expand failed, 
rc=${LINK_EXPAND_EXPAND_RC}"
+               return 0
+       fi
+       if [ ! -s "${expand_out}" ]; then
+               die "${desc}: expected non-empty ${expand_out}"
+               return 0
+       fi
+
+       pass "${desc} (link and expand succeeded)"
+}
+
+expect_link_expand_fail() {
+       desc="$1"
+       pattern="$2"
+       link_out="$3"
+       expand_out="$4"
+       base_pp="$5"
+       shift 5
+
+       echo "==== NEGATIVE (expect neverallow failure at expand): ${desc}"
+       run_link_expand "${link_out}" "${expand_out}" "${base_pp}" "$@"
+       if [ "${LINK_EXPAND_LINK_RC}" -ne 0 ]; then
+               die "${desc}: expected semodule_link success before expand, 
rc=${LINK_EXPAND_LINK_RC}"
+               return 0
+       fi
+       if [ "${LINK_EXPAND_EXPAND_RC}" -eq 0 ]; then
+               die "${desc}: expected semodule_expand failure, got rc=0"
+               return 0
+       fi
+       if ! grep -Eq "${pattern}" "${expand_out}.err"; then
+               echo "FAIL: stderr did not match /${pattern}/" >&2
+               cat "${expand_out}.err" >&2
+               FAIL=$((FAIL + 1))
+               return 0
+       fi
+
+       pass "${desc} (expand failed on neverallow as expected, 
rc=${LINK_EXPAND_EXPAND_RC})"
+}
+
+# Same-module neverallowxperm: enforced at expand on libsepol 3.11+, deferred 
on older userspace.
+expect_link_expand_fail_or_deferred() {
+       desc="$1"
+       pattern="$2"
+       link_out="$3"
+       expand_out="$4"
+       base_pp="$5"
+       shift 5
+
+       echo "==== NEGATIVE or DOCUMENT (same-module neverallowxperm at 
expand): ${desc}"
+       run_link_expand "${link_out}" "${expand_out}" "${base_pp}" "$@"
+       if [ "${LINK_EXPAND_LINK_RC}" -ne 0 ]; then
+               die "${desc}: expected semodule_link success, 
rc=${LINK_EXPAND_LINK_RC}"
+               return 0
+       fi
+       if [ "${LINK_EXPAND_EXPAND_RC}" -eq 0 ]; then
+               if [ ! -s "${expand_out}" ]; then
+                       die "${desc}: expected non-empty ${expand_out} when 
expand deferred"
+                       return 0
+               fi
+               pass "${desc} (link and expand succeeded; enforcement deferred 
on this userspace)"
+               return 0
+       fi
+       if ! grep -Eq "${pattern}" "${expand_out}.err"; then
+               echo "FAIL: stderr did not match /${pattern}/" >&2
+               cat "${expand_out}.err" >&2
+               FAIL=$((FAIL + 1))
+               return 0
+       fi
+
+       pass "${desc} (expand failed on neverallowxperm as expected, 
rc=${LINK_EXPAND_EXPAND_RC})"
+}
+
+build_base_package() {
+       base_conf="$1"
+       base_mod="$2"
+       base_pp="$3"
+
+       set +e
+       "${CHECKMODULE}" -o "${base_mod}" "${base_conf}" 2>"${base_mod}.err"
+       rc=$?
+       set -e
+       if [ "${rc}" -ne 0 ]; then
+               echo "FAIL: checkmodule could not build base from ${base_conf}" 
>&2
+               cat "${base_mod}.err" >&2
+               exit 1
+       fi
+
+       set +e
+       "${SEMODULE_PACKAGE}" -o "${base_pp}" -m "${base_mod}" 
2>"${base_pp}.err"
+       rc=$?
+       set -e
+       if [ "${rc}" -ne 0 ]; then
+               echo "FAIL: semodule_package could not build ${base_pp}" >&2
+               cat "${base_pp}.err" >&2
+               exit 1
+       fi
+}
+
+expect_link_fail() {
+       desc="$1"
+       pattern="$2"
+       link_out="$3"
+       base_pp="$4"
+       shift 4
+
+       echo "==== NEGATIVE (expect semodule_link failure): ${desc}"
+       rm -f "${link_out}" "${link_out}.err"
+
+       set +e
+       "${SEMODULE_LINK}" -o "${link_out}" "${base_pp}" "$@" \
+               2>"${link_out}.err"
+       rc=$?
+       set -e
+       if [ "${rc}" -eq 0 ]; then
+               die "${desc}: expected semodule_link failure, got rc=0"
+               return 0
+       fi
+       if ! grep -Eq "${pattern}" "${link_out}.err"; then
+               echo "FAIL: stderr did not match /${pattern}/" >&2
+               cat "${link_out}.err" >&2
+               FAIL=$((FAIL + 1))
+               return 0
+       fi
+
+       pass "${desc} (link failed on unmet require as expected, rc=${rc})"
+}
+
+build_good_mod
+
+# Ephemeral path fixtures for packaging path tests.
+ln -sf /nonexistent/test_good.mod "${OUTDIR}/broken_symlink.mod"
+ln -sf /nonexistent/test_good.mod.fc "${OUTDIR}/broken_symlink.mod.fc"
+printf '' > "${OUTDIR}/empty.mod.fc"
+
+# NUL byte inside path column (packaging accepts; sefcontext_compile rejects).
+printf '/bin/foo\000bar\t--\tsystem_u:object_r:test_good_exec_t:s0\n' \
+       > "${OUTDIR}/nul_bytes.mod.fc"
+
+GOOD_FC="${FIXTURES}/file_contexts/good.mod.fc"
+
+# --- semodule_package input paths ---
+expect_package_pass \
+       "control good .mod without file contexts" \
+       good_mod \
+       -m "${GOOD_MOD}"
+
+expect_package_pass \
+       "control good .mod with good .mod.fc" \
+       good_mod_fc \
+       -m "${GOOD_MOD}" -f "${GOOD_FC}"
+
+expect_package_fail \
+       "missing -m path" \
+       "Could not open|Failed to open" \
+       missing_mod \
+       -m "${OUTDIR}/does_not_exist.mod"
+
+expect_package_fail \
+       "missing -f path" \
+       "Failed to open|Could not open" \
+       missing_fc \
+       -m "${GOOD_MOD}" -f "${OUTDIR}/does_not_exist.mod.fc"
+
+expect_package_fail \
+       "directory instead of -m file" \
+       "Error while reading policy module|Could not open" \
+       directory_mod \
+       -m "${BASEDIR}"
+
+expect_package_fail \
+       "broken symlink for -m" \
+       "Could not open|Failed to open|No such file" \
+       symlink_mod \
+       -m "${OUTDIR}/broken_symlink.mod"
+
+expect_package_fail_unreadable
+
+expect_package_fail \
+       "empty -m path argument" \
+       "Could not open|Failed to open" \
+       empty_mod \
+       -m ""
+
+expect_package_fail \
+       "directory instead of -f file" \
+       "Permission denied|Failed to mmap|Failed to open|Could not open" \
+       directory_fc \
+       -m "${GOOD_MOD}" -f "${BASEDIR}"
+
+expect_package_fail \
+       "broken symlink for -f" \
+       "Could not open|Failed to open|No such file" \
+       symlink_fc \
+       -m "${GOOD_MOD}" -f "${OUTDIR}/broken_symlink.mod.fc"
+
+expect_package_fail_unreadable_fc
+
+expect_package_fail \
+       "empty -f path argument" \
+       "Could not open|Failed to open" \
+       empty_fc_arg \
+       -m "${GOOD_MOD}" -f ""
+
+# --- bad .mod.fc at packaging time ---
+expect_package_pass_deferred \
+       "invalid SELinux context in .mod.fc" \
+       bad_context \
+       -m "${GOOD_MOD}" -f "${FIXTURES}/file_contexts/bad_context.mod.fc"
+
+expect_package_pass_deferred \
+       "wrong field count in .mod.fc" \
+       bad_fields \
+       -m "${GOOD_MOD}" -f "${FIXTURES}/file_contexts/bad_fields.mod.fc"
+
+expect_package_pass_deferred \
+       "NUL byte in .mod.fc path field" \
+       nul_bytes \
+       -m "${GOOD_MOD}" -f "${OUTDIR}/nul_bytes.mod.fc"
+
+expect_package_pass_deferred \
+       "empty .mod.fc file" \
+       empty_fc \
+       -m "${GOOD_MOD}" -f "${OUTDIR}/empty.mod.fc"
+
+# --- sefcontext_compile / unpackage validation ---
+expect_sefcontext_pass \
+       "control good .mod.fc through sefcontext_compile" \
+       good_fc \
+       "${GOOD_FC}"
+
+expect_sefcontext_fail \
+       "wrong field count in .mod.fc (after packaging)" \
+       "missing fields|process_file failed" \
+       sefcontext_bad_fields \
+       "${FIXTURES}/file_contexts/bad_fields.mod.fc"
+
+expect_sefcontext_fail \
+       "NUL byte in .mod.fc path field (after packaging)" \
+       "missing fields|process_file failed" \
+       sefcontext_nul_bytes \
+       "${OUTDIR}/nul_bytes.mod.fc"
+
+expect_sefcontext_fail_or_skip_no_policy \
+       "invalid SELinux context requires policy validation (-p)" \
+       "invalid context|malformed context|process_file failed" \
+       sefcontext_bad_context \
+       "${FIXTURES}/file_contexts/bad_context.mod.fc"
+
+expect_sefcontext_pass_deferred \
+       "empty .mod.fc file through sefcontext_compile" \
+       sefcontext_empty_fc \
+       "${OUTDIR}/empty.mod.fc"
+
+expect_sefcontext_fail_or_skip_no_policy \
+       "invalid MLS context requires policy validation (-p)" \
+       "invalid context|malformed context|process_file failed" \
+       sefcontext_bad_mls \
+       "${FIXTURES}/file_contexts/bad_mls.mod.fc"
+
+BAD_PP="${OUTDIR}/bad_context.pp"
+EXTRACTED_MOD="${OUTDIR}/extracted.mod"
+EXTRACTED_FC="${OUTDIR}/extracted.fc"
+
+echo "==== Setup: extract file contexts from packaged module with invalid 
context"
+rm -f "${EXTRACTED_MOD}" "${EXTRACTED_FC}"
+set +e
+"${SEMODULE_UNPACKAGE}" "${BAD_PP}" "${EXTRACTED_MOD}" "${EXTRACTED_FC}" \
+       2>"${OUTDIR}/unpackage.err"
+rc=$?
+set -e
+if [ "${rc}" -ne 0 ] || [ ! -s "${EXTRACTED_FC}" ]; then
+       die "unpackage setup: could not extract .fc from ${BAD_PP}"
+       cat "${OUTDIR}/unpackage.err" >&2
+else
+       echo "==== unpackage setup succeeded"
+       echo ""
+       expect_sefcontext_fail_or_skip_no_policy \
+               "invalid context from unpackage'd .pp file contexts" \
+               "invalid context|malformed context|process_file failed" \
+               unpackaged_bad_context \
+               "${EXTRACTED_FC}"
+fi
+
+# --- semodule_link / semodule_expand neverallow ---
+BASE_CONF="${FIXTURES}/base/minimal_base.conf"
+BASE_MOD="${OUTDIR}/minimal_base.mod"
+BASE_PP="${OUTDIR}/minimal_base.pp"
+GOOD_LOADABLE_MOD="${OUTDIR}/neverallow_good.mod"
+GOOD_LOADABLE_PP="${OUTDIR}/neverallow_good.pp"
+VIOLATOR_MOD="${OUTDIR}/neverallow_violator.mod"
+VIOLATOR_PP="${OUTDIR}/neverallow_violator.pp"
+SELF_MOD="${OUTDIR}/neverallow_self.mod"
+SELF_PP="${OUTDIR}/neverallow_self.pp"
+XPERM_VIOLATOR_MOD="${OUTDIR}/neverallow_xperm_violator.mod"
+XPERM_VIOLATOR_PP="${OUTDIR}/neverallow_xperm_violator.pp"
+XPERM_SELF_MOD="${OUTDIR}/neverallow_xperm_self.mod"
+XPERM_SELF_PP="${OUTDIR}/neverallow_xperm_self.pp"
+
+echo "==== Setup: build minimal base and loadable module packages (non-MLS)"
+build_base_package "${BASE_CONF}" "${BASE_MOD}" "${BASE_PP}"
+build_loadable_package "${FIXTURES}/modules/neverallow_good.te" \
+       "${GOOD_LOADABLE_MOD}" "${GOOD_LOADABLE_PP}"
+build_loadable_package "${FIXTURES}/modules/neverallow_violator.te" \
+       "${VIOLATOR_MOD}" "${VIOLATOR_PP}"
+build_loadable_package "${FIXTURES}/modules/neverallow_self.te" \
+       "${SELF_MOD}" "${SELF_PP}"
+build_loadable_package "${FIXTURES}/modules/neverallow_xperm_violator.te" \
+       "${XPERM_VIOLATOR_MOD}" "${XPERM_VIOLATOR_PP}"
+build_loadable_package "${FIXTURES}/modules/neverallow_xperm_self.te" \
+       "${XPERM_SELF_MOD}" "${XPERM_SELF_PP}"
+echo ""
+
+expect_checkmodule_pass \
+       "neverallow module passes checkmodule before expand rejects it" \
+       "${FIXTURES}/modules/neverallow_self.te"
+
+expect_checkmodule_pass \
+       "neverallowxperm module passes checkmodule before link/expand" \
+       "${FIXTURES}/modules/neverallow_xperm_self.te"
+
+expect_link_expand_pass \
+       "control base + good module link and expand" \
+       "${OUTDIR}/link_good.pp" \
+       "${OUTDIR}/expand_good.bin" \
+       "${BASE_PP}" \
+       "${GOOD_LOADABLE_PP}"
+
+expect_link_expand_fail \
+       "loadable module violates base neverallow on expand" \
+       "neverallow violated|neverallow failures occurred" \
+       "${OUTDIR}/link_violator.pp" \
+       "${OUTDIR}/expand_violator.bin" \
+       "${BASE_PP}" \
+       "${VIOLATOR_PP}"
+
+expect_link_expand_fail \
+       "same-module neverallow violated on expand" \
+       "neverallow violated|neverallow failures occurred" \
+       "${OUTDIR}/link_self.pp" \
+       "${OUTDIR}/expand_self.bin" \
+       "${BASE_PP}" \
+       "${SELF_PP}"
+
+expect_link_expand_fail \
+       "loadable module violates base neverallowxperm on expand" \
+       "neverallowxperm|neverallow failures occurred" \
+       "${OUTDIR}/link_xperm_violator.pp" \
+       "${OUTDIR}/expand_xperm_violator.bin" \
+       "${BASE_PP}" \
+       "${XPERM_VIOLATOR_PP}"
+
+expect_link_expand_fail_or_deferred \
+       "same-module neverallowxperm violated on expand" \
+       "neverallowxperm|neverallow failures occurred" \
+       "${OUTDIR}/link_xperm_self.pp" \
+       "${OUTDIR}/expand_xperm_self.bin" \
+       "${BASE_PP}" \
+       "${XPERM_SELF_PP}"
+
+# --- cross-module require (§2c.9) ---
+REQUIRE_CONSUMER_MOD="${OUTDIR}/module_a.mod"
+REQUIRE_CONSUMER_PP="${OUTDIR}/module_a.pp"
+REQUIRE_PROVIDER_MOD="${OUTDIR}/module_b.mod"
+REQUIRE_PROVIDER_PP="${OUTDIR}/module_b.pp"
+
+build_loadable_package "${FIXTURES}/modules/module_a.te" \
+       "${REQUIRE_CONSUMER_MOD}" "${REQUIRE_CONSUMER_PP}"
+build_loadable_package "${FIXTURES}/modules/module_b.te" \
+       "${REQUIRE_PROVIDER_MOD}" "${REQUIRE_PROVIDER_PP}"
+
+expect_checkmodule_pass \
+       "consumer module passes checkmodule before link rejects missing 
require" \
+       "${FIXTURES}/modules/module_a.te"
+
+expect_link_fail \
+       "module requires type only declared in another module" \
+       "requirements were not met|global requirements" \
+       "${OUTDIR}/link_require_consumer.pp" \
+       "${BASE_PP}" \
+       "${REQUIRE_CONSUMER_PP}"
+
+expect_link_expand_pass \
+       "consumer and provider modules link and expand together" \
+       "${OUTDIR}/link_require_both.pp" \
+       "${OUTDIR}/expand_require_both.bin" \
+       "${BASE_PP}" \
+       "${REQUIRE_CONSUMER_PP}" \
+       "${REQUIRE_PROVIDER_PP}"
+
+echo "========================================"
+echo "Results: ${PASS} passed, ${FAIL} failed"
+if [ "${FAIL}" -ne 0 ]; then
+       exit 1
+fi
+exit 0

Reply via email to