From 97f12c7440423b5c527e0072720db9ee36863592 Mon Sep 17 00:00:00 2001 From: si-gui <245140120@qq.com> Date: Thu, 3 Sep 2020 17:36:25 +0800 Subject: [PATCH 1/2] Modify nss_wrapper.pl to directly change the /etc/group --- ...ctly-in-case-of-selinux-attr-changes.patch | 32 +++++++++++++++++++ nss_wrapper.spec | 6 +++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 0001-Modify-etc-group-file-directly-in-case-of-selinux-attr-changes.patch diff --git a/0001-Modify-etc-group-file-directly-in-case-of-selinux-attr-changes.patch b/0001-Modify-etc-group-file-directly-in-case-of-selinux-attr-changes.patch new file mode 100644 index 0000000..64a8054 --- /dev/null +++ b/0001-Modify-etc-group-file-directly-in-case-of-selinux-attr-changes.patch @@ -0,0 +1,32 @@ +From b737cd29a5c0911a968050a927154d44e9ec9a53 Mon Sep 17 00:00:00 2001 +From: si-gui <245140120@qq.com> +Date: Thu, 3 Sep 2020 17:10:27 +0800 +Subject: [PATCH] Subject: Modify etc group file directly in case of selinux + attr changes + +Modify nss_wrapper.pl when it add user to group, the nss_wrapper.pl will change the /etc/group file's selinux attr from passwd_file_t to etc_t,so we modify the /etc/group directly + +Signed-off-by: si-gui <245140120@qq.com> +--- + nss_wrapper.pl | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/nss_wrapper.pl b/nss_wrapper.pl +index 48fa2c5..73dd655 100755 +--- a/nss_wrapper.pl ++++ b/nss_wrapper.pl +@@ -386,10 +386,9 @@ sub group_save($) + push(@lines, $line); + } + +- open(GROUP, ">$tmppath") or die("Unable to open '$tmppath' for write"); ++ open(GROUP, ">$path") or die("Unable to open '$path' for write"); + print GROUP join("\n", @lines)."\n"; + close(GROUP); +- rename($tmppath, $path) or die("Unable to rename $tmppath => $path"); + } + + sub passwd_add($$$$$) +-- +2.23.0 + diff --git a/nss_wrapper.spec b/nss_wrapper.spec index fd1c00d..cb2f8a8 100644 --- a/nss_wrapper.spec +++ b/nss_wrapper.spec @@ -1,10 +1,11 @@ Name: nss_wrapper Version: 1.1.3 -Release: 2 +Release: 3 License: BSD Summary: A wrapper for the user, group and hosts NSS API Url: https://cwrap.org/ Source0: https://ftp.samba.org/pub/cwrap/%{name}-%{version}.tar.gz +Patch0000: 0001-Modify-etc-group-file-directly-in-case-of-selinux-attr-changes.patch BuildRequires: cmake libcmocka-devel Requires: cmake pkgconfig @@ -71,5 +72,8 @@ make test %{_mandir}/man1/nss_wrapper.1* %changelog +* Thu Sep 3 2020 Guoshuai Sun - 1.1.3-3 +- Modify nss_wrapper.pl to directly change the /etc/group + * Thu Nov 28 2019 yangjian - 1.1.3-2 - Package init -- Gitee From 712ffae423b6719c6a923c529417d22ae1fbb747 Mon Sep 17 00:00:00 2001 From: si-gui <245140120@qq.com> Date: Fri, 4 Sep 2020 14:59:59 +0800 Subject: [PATCH 2/2] Optimized group_save implemenation in case of selinux attr changes --- ...ctly-in-case-of-selinux-attr-changes.patch | 32 ------------------- ...tion-in-case-of-selinux-attr-changes.patch | 28 ++++++++++++++++ nss_wrapper.spec | 4 +-- 3 files changed, 30 insertions(+), 34 deletions(-) delete mode 100644 0001-Modify-etc-group-file-directly-in-case-of-selinux-attr-changes.patch create mode 100644 0001-Optimized-group_save-implemenation-in-case-of-selinux-attr-changes.patch diff --git a/0001-Modify-etc-group-file-directly-in-case-of-selinux-attr-changes.patch b/0001-Modify-etc-group-file-directly-in-case-of-selinux-attr-changes.patch deleted file mode 100644 index 64a8054..0000000 --- a/0001-Modify-etc-group-file-directly-in-case-of-selinux-attr-changes.patch +++ /dev/null @@ -1,32 +0,0 @@ -From b737cd29a5c0911a968050a927154d44e9ec9a53 Mon Sep 17 00:00:00 2001 -From: si-gui <245140120@qq.com> -Date: Thu, 3 Sep 2020 17:10:27 +0800 -Subject: [PATCH] Subject: Modify etc group file directly in case of selinux - attr changes - -Modify nss_wrapper.pl when it add user to group, the nss_wrapper.pl will change the /etc/group file's selinux attr from passwd_file_t to etc_t,so we modify the /etc/group directly - -Signed-off-by: si-gui <245140120@qq.com> ---- - nss_wrapper.pl | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -diff --git a/nss_wrapper.pl b/nss_wrapper.pl -index 48fa2c5..73dd655 100755 ---- a/nss_wrapper.pl -+++ b/nss_wrapper.pl -@@ -386,10 +386,9 @@ sub group_save($) - push(@lines, $line); - } - -- open(GROUP, ">$tmppath") or die("Unable to open '$tmppath' for write"); -+ open(GROUP, ">$path") or die("Unable to open '$path' for write"); - print GROUP join("\n", @lines)."\n"; - close(GROUP); -- rename($tmppath, $path) or die("Unable to rename $tmppath => $path"); - } - - sub passwd_add($$$$$) --- -2.23.0 - diff --git a/0001-Optimized-group_save-implemenation-in-case-of-selinux-attr-changes.patch b/0001-Optimized-group_save-implemenation-in-case-of-selinux-attr-changes.patch new file mode 100644 index 0000000..13e9f75 --- /dev/null +++ b/0001-Optimized-group_save-implemenation-in-case-of-selinux-attr-changes.patch @@ -0,0 +1,28 @@ +From a846e000b590c68ba4532c5b796614262f734328 Mon Sep 17 00:00:00 2001 +From: si-gui <245140120@qq.com> +Date: Fri, 4 Sep 2020 14:46:49 +0800 +Subject: [PATCH] Optimized group_save implemenation in case of selinux attr changes +Optimized group_save implemenation in case of selinux attr changes, and +calling the shell's cp command would be a good decision until a better +way is found + +Signed-off-by: si-gui <245140120@qq.com> +--- + nss_wrapper.pl | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/nss_wrapper.pl b/nss_wrapper.pl +index 48fa2c5..6c3f666 100755 +--- a/nss_wrapper.pl ++++ b/nss_wrapper.pl +@@ -375,6 +375,7 @@ sub group_save($) + my @lines = (); + my $path = $group->{path}; + my $tmppath = $path.$$; ++ system("cp -a $path $tmppath"); + + foreach my $eref (@{$group->{array}}) { + next unless defined($eref); +-- +2.23.0 + diff --git a/nss_wrapper.spec b/nss_wrapper.spec index cb2f8a8..0757da0 100644 --- a/nss_wrapper.spec +++ b/nss_wrapper.spec @@ -5,7 +5,7 @@ License: BSD Summary: A wrapper for the user, group and hosts NSS API Url: https://cwrap.org/ Source0: https://ftp.samba.org/pub/cwrap/%{name}-%{version}.tar.gz -Patch0000: 0001-Modify-etc-group-file-directly-in-case-of-selinux-attr-changes.patch +Patch0000: 0001-Optimized-group_save-implemenation-in-case-of-selinux-attr-changes.patch BuildRequires: cmake libcmocka-devel Requires: cmake pkgconfig @@ -73,7 +73,7 @@ make test %changelog * Thu Sep 3 2020 Guoshuai Sun - 1.1.3-3 -- Modify nss_wrapper.pl to directly change the /etc/group +- Optimized group_save implemenation in case of selinux attr changes * Thu Nov 28 2019 yangjian - 1.1.3-2 - Package init -- Gitee