[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#827105: libc-bin: Updating /etc/nsswitch.conf to current default



Package: libc-bin
Version: 2.22-11

Dear glibc maintainers:

As Sven Joachim has pointed out in Bug#827095, the file
/etc/nsswitch.conf is currently both in base-files and libc-bin.

I've created the following patches for the transition to be complete.

The first patch just updates /usr/share/libc-bin/nsswitch.conf
to be in sync with base-files default after adding gshadow line.

The second and third patches add code borrowed from base-files
postinst so that the file is updated to current default if the user
never modified it.

You will see that this code is some kind of "poor's man UCF system"
but it has worked flawlessly for me in base-files and it has the added
benefit that the user is never bothered with stupid questions: Either
the user changed the file and we do nothing at all, or the file was
not changed from the old default and we update it to the new default.

Note 1: The file nsswitch.conf.md5sums could be trimmed down a little
bit on the basis that we "do not support upgrades skipping releases",
but IMHO, I would not remove the last three lines (that is, the lines
from "base-files 3.1.16 to 7.2 and libc-bin 2.19-18 to 2.22-11" to the
end).

Note 2: To test this I have copied the files to /usr/share/libc-bin
and libc-bin.postinst to /var/lib/dpkg/info.

Then I removed the gshadow line from /etc and checked that
"dpkg-reconfigure libc-bin" works as expected.

What I have not tested is a complete build of glibc source package, but
if the patches are still not ok, I trust they will be easy to fix.

Thanks.
From 2aee8524a0ea508d77b72cbbc2928c3f5622d70b Mon Sep 17 00:00:00 2001
From: Santiago Vila <sanvila@debian.org>
Date: Sun, 12 Jun 2016 11:43:05 +0200
Subject: [PATCH 1/3] Add gshadow line to default /etc/nsswitch.conf (Bug
 #699090)

---
 debian/local/etc/nsswitch.conf | 1 +
 1 file changed, 1 insertion(+)

diff --git a/debian/local/etc/nsswitch.conf b/debian/local/etc/nsswitch.conf
index d2f03b0..1142be1 100644
--- a/debian/local/etc/nsswitch.conf
+++ b/debian/local/etc/nsswitch.conf
@@ -7,6 +7,7 @@
 passwd:         compat
 group:          compat
 shadow:         compat
+gshadow:        files
 
 hosts:          files dns
 networks:       files
-- 
2.8.1

From 96f9245571823ea8ab8499d29a0df5b9e110ac4e Mon Sep 17 00:00:00 2001
From: Santiago Vila <sanvila@debian.org>
Date: Sun, 12 Jun 2016 11:56:14 +0200
Subject: [PATCH 2/3] Create nsswitch.conf.md5sums for updates to the current
 default if unchanged

---
 debian/debhelper.in/libc-bin.install   | 1 +
 debian/local/etc/nsswitch.conf.md5sums | 5 +++++
 2 files changed, 6 insertions(+)
 create mode 100644 debian/local/etc/nsswitch.conf.md5sums

diff --git a/debian/debhelper.in/libc-bin.install b/debian/debhelper.in/libc-bin.install
index dfab166..77ad21d 100644
--- a/debian/debhelper.in/libc-bin.install
+++ b/debian/debhelper.in/libc-bin.install
@@ -2,6 +2,7 @@ debian/local/etc/bindresvport.blacklist etc
 debian/local/etc/ld.so.conf etc
 debian/local/etc/ld.so.conf.d etc
 debian/local/etc/nsswitch.conf usr/share/libc-bin
+debian/local/etc/nsswitch.conf.md5sums usr/share/libc-bin
 nis/nss etc/default
 posix/gai.conf etc
 debian/tmp-libc/sbin/ldconfig sbin
diff --git a/debian/local/etc/nsswitch.conf.md5sums b/debian/local/etc/nsswitch.conf.md5sums
new file mode 100644
index 0000000..657fe79
--- /dev/null
+++ b/debian/local/etc/nsswitch.conf.md5sums
@@ -0,0 +1,5 @@
+109e33e2c91d1853b5bc56078a96aa18 base-files 3.0.0 to 3.1.15
+3114ea9cf2f3bd8d120b4da96e3832d5 base-files 3.1.8 and 3.1.9
+295c15c4bdac80e50b37689ef08f359c base-files 3.1.16 to 7.2 and libc-bin 2.19-18 to 2.22-11
+30b82cb1ce20d480703da2208a4607b4 base-files 6.6
+f8e97bf611374634c7cb3a6085503ab5 base-files 7.3 and libc-bin 2.22-12
-- 
2.8.1

From c51efa83cdf0250db2186d3092e590c73a160be6 Mon Sep 17 00:00:00 2001
From: Santiago Vila <sanvila@debian.org>
Date: Sun, 12 Jun 2016 12:03:34 +0200
Subject: [PATCH 3/3] libc-bin.postinst: Add code to update /etc/nsswitch.conf

---
 debian/debhelper.in/libc-bin.postinst | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/debian/debhelper.in/libc-bin.postinst b/debian/debhelper.in/libc-bin.postinst
index 50f3e79..29effc8 100644
--- a/debian/debhelper.in/libc-bin.postinst
+++ b/debian/debhelper.in/libc-bin.postinst
@@ -8,10 +8,26 @@ install_from_default() {
   fi
 }
 
+update_to_current_default() {
+  if [ -f $2 ]; then
+    md5=`md5sum $2 | cut -f 1 -d " "`
+    if grep -q "$md5" $1.md5sums; then
+      if ! cmp -s $1 $2; then
+        cp -p $1 $2
+        echo Updating $2 to current default.
+      fi
+    fi
+  fi
+}
+
 if [ "$1" = "configure" ] && [ "$2" = "" ] ; then
   install_from_default /usr/share/libc-bin/nsswitch.conf /etc/nsswitch.conf
 fi
 
+if [ "$1" = "configure" ] && [ "$2" != "" ]; then
+  update_to_current_default /usr/share/libc-bin/nsswitch.conf /etc/nsswitch.conf
+fi
+
 if [ "$1" = "triggered" ] || [ "$1" = "configure" ]; then
   ldconfig || ldconfig --verbose
   exit 0
-- 
2.8.1


Reply to: