public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Milos Malik <mmalik@redhat.com>
To: git-commits@fedoraproject.org
Subject: [tests/selinux] pr775-checkpolicy-revdeps: remove users forcefully
Date: Fri, 11 Sep 2026 13:19:42 GMT	[thread overview]
Message-ID: <178913278264.1.197437162279836046.tests-selinux-a8158ee0bf7d@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : tests/selinux
            Branch : pr775-checkpolicy-revdeps
            Commit : a8158ee0bf7dd21acf908357a702396ba1dfc1f8
            Author : Milos Malik <mmalik@redhat.com>
            Date   : 2022-03-14T08:39:51+01:00
            Stats  : +16/-16 in 2 file(s)
            URL    : https://src.fedoraproject.org/tests/selinux/c/a8158ee0bf7dd21acf908357a702396ba1dfc1f8?branch=pr775-checkpolicy-revdeps

            Log:
            remove users forcefully

Sometimes the userdel commands end up with the following error:

  userdel: user <username> is currently used by process <PID>

which leads to a situation where the subsequent useradd commands
(which use the same username) also end up with an error:

  useradd: user <username> already exists

To avoid such errors, the '-f' option was added to all userdel
commands.

---
diff --git a/libsemanage/usepasswd-in-semanage-conf/Makefile b/libsemanage/usepasswd-in-semanage-conf/Makefile
index 04e5715..f63aae5 100644
--- a/libsemanage/usepasswd-in-semanage-conf/Makefile
+++ b/libsemanage/usepasswd-in-semanage-conf/Makefile
@@ -53,7 +53,7 @@ $(METADATA): Makefile
 	@echo "Type:            Sanity" >> $(METADATA)
 	@echo "TestTime:        10m" >> $(METADATA)
 	@echo "RunFor:          libsemanage" >> $(METADATA)
-	@echo "Requires:        libselinux libselinux-utils libsemanage policycoreutils policycoreutils-python-utils selinux-policy selinux-policy-devel" >> $(METADATA)
+	@echo "Requires:        libselinux libselinux-utils libsemanage policycoreutils policycoreutils-python-utils selinux-policy selinux-policy-devel shadow-utils" >> $(METADATA)
 	@echo "Priority:        Normal" >> $(METADATA)
 	@echo "License:         GPLv2" >> $(METADATA)
 	@echo "Confidential:    no" >> $(METADATA)

diff --git a/libsemanage/usepasswd-in-semanage-conf/runtest.sh b/libsemanage/usepasswd-in-semanage-conf/runtest.sh
index 8aadf23..b1ec6fd 100755
--- a/libsemanage/usepasswd-in-semanage-conf/runtest.sh
+++ b/libsemanage/usepasswd-in-semanage-conf/runtest.sh
@@ -61,9 +61,9 @@ rlJournalStart
         rlRun "semodule -B" # rebuild file_contexts.homedirs
         rlRun "semanage fcontext -l 2>&1 > ${OUTPUT_FILE}" # file context with new selinux login
         rlRun "diff -u ${CMP_FILE} ${OUTPUT_FILE}" 0
-        rlRun "userdel duck-home"
-        rlRun "userdel duck-tmp"
-        rlRun "userdel duck-var-lib"
+        rlRun "userdel -f duck-home"
+        rlRun "userdel -f duck-tmp"
+        rlRun "userdel -f duck-var-lib"
 
         rlLog "SELinux users with home in / shoud not trigger a policy change"
         rlRun "useradd -Z unconfined_u -d /tmp duck-tmp"
@@ -71,8 +71,8 @@ rlJournalStart
         rlRun "semodule -B" # rebuild file_contexts.homedirs
         rlRun "semanage fcontext -l 2>&1 > ${OUTPUT_FILE}" # file context with new selinux login
         rlRun "diff -u ${CMP_FILE} ${OUTPUT_FILE}" 0
-        rlRun "userdel -Z duck-tmp"
-        rlRun "userdel -Z duck-var"
+        rlRun "userdel -fZ duck-tmp"
+        rlRun "userdel -fZ duck-var"
 
         rlLog "Other SELinux users should trigger a policy change"
         rlRun "useradd -Z unconfined_u duck-home"
@@ -80,8 +80,8 @@ rlJournalStart
         rlRun "semodule -B" # rebuild file_contexts.homedirs
         rlRun "semanage fcontext -l 2>&1 > ${OUTPUT_FILE}" # file context with new selinux login
         rlRun "diff -u ${CMP_FILE} ${OUTPUT_FILE} | grep -E 'duck-(home|var-home)'" 0
-        rlRun "userdel -Z duck-home"
-        rlRun "userdel -Z duck-var-home"
+        rlRun "userdel -fZ duck-home"
+        rlRun "userdel -fZ duck-var-home"
 
         rlFileRestore
     rlPhaseEnd
@@ -98,14 +98,14 @@ rlJournalStart
         rlRun "semodule -B" # rebuild file_contexts.homedirs
         rlRun "semanage fcontext -l 2>&1 > ${OUTPUT_FILE}" # file context with new selinux login
         rlRun "diff -u ${CMP_FILE} ${OUTPUT_FILE}" 0
-        rlRun "userdel duck-home"
+        rlRun "userdel -f duck-home"
 
         rlLog "Standard users with home in directory like /var/home should trigger a policy change"
         rlRun "useradd -d /var/home/duck duck-var-home"
         rlRun "semodule -B" # rebuild file_contexts.homedirs
         rlRun "semanage fcontext -l 2>&1 > ${OUTPUT_FILE}" # file context with new selinux login
         rlRun "diff -u ${CMP_FILE} ${OUTPUT_FILE} | grep -E '/var/home/'" 0
-        rlRun "userdel duck-var-home"
+        rlRun "userdel -f duck-var-home"
 
         rlLog "Standard users with home in / shoud not trigger a policy change"
         rlRun "useradd -d /tmp duck-tmp"
@@ -113,8 +113,8 @@ rlJournalStart
         rlRun "semodule -B" # rebuild file_contexts.homedirs
         rlRun "semanage fcontext -l 2>&1 > ${OUTPUT_FILE}" # file context with new selinux login
         rlRun "diff -u ${CMP_FILE} ${OUTPUT_FILE}" 0
-        rlRun "userdel -Z duck-tmp"
-        rlRun "userdel -Z duck-var"
+        rlRun "userdel -fZ duck-tmp"
+        rlRun "userdel -fZ duck-var"
 
         rlLog "SELinux users with home in / shoud not trigger a policy change"
         rlRun "useradd -Z unconfined_u -d /tmp duck-tmp"
@@ -122,8 +122,8 @@ rlJournalStart
         rlRun "semodule -B" # rebuild file_contexts.homedirs
         rlRun "semanage fcontext -l 2>&1 > ${OUTPUT_FILE}" # file context with new selinux login
         rlRun "diff -u ${CMP_FILE} ${OUTPUT_FILE}" 0
-        rlRun "userdel -Z duck-tmp"
-        rlRun "userdel -Z duck-var"
+        rlRun "userdel -fZ duck-tmp"
+        rlRun "userdel -fZ duck-var"
 
         rlLog "Other SELinux users should trigger a policy change"
         rlRun "useradd -Z unconfined_u duck-home"
@@ -131,8 +131,8 @@ rlJournalStart
         rlRun "semodule -B" # rebuild file_contexts.homedirs
         rlRun "semanage fcontext -l 2>&1 > ${OUTPUT_FILE}" # file context with new selinux login
         rlRun "diff -u ${CMP_FILE} ${OUTPUT_FILE} | grep -E 'duck-(home|var-home)'" 0
-        rlRun "userdel -Z duck-home"
-        rlRun "userdel -Z duck-var-home"
+        rlRun "userdel -fZ duck-home"
+        rlRun "userdel -fZ duck-var-home"
 
         rlFileRestore
     rlPhaseEnd

                 reply	other threads:[~2026-09-11 13:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=178913278264.1.197437162279836046.tests-selinux-a8158ee0bf7d@fedoraproject.org \
    --to=mmalik@redhat.com \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox