Accepting request 807368 from home:Andreas_Schwab:Factory

- nss-mdns-config: Use /usr/etc/nsswitch.conf as input if
  /etc/nsswitch.conf doesn't exist yet

OBS-URL: https://build.opensuse.org/request/show/807368
OBS-URL: https://build.opensuse.org/package/show/GNOME:Factory/nss-mdns?expand=0&rev=20
This commit is contained in:
Dominique Leuenberger 2020-05-20 10:37:18 +00:00 committed by Git OBS Bridge
parent d27268435a
commit 9dac397c2c
3 changed files with 22 additions and 5 deletions

View File

@ -36,6 +36,7 @@
#
NSSWITCH=/etc/nsswitch.conf
NSSWITCH_VENDOR=/usr/etc/nsswitch.conf
usage() {
echo "nss-mdns-config [--enable|--disable] [-4|-6] [--no-backup]"
@ -78,14 +79,20 @@ if test "$IPv4" -ne 1 -a "$IPv6" -ne 1; then
IPvALL=1
fi
if test ! -f "$NSSWITCH"; then
if test ! -f "$NSSWITCH" && test ! -f "$NSSWITCH_VENDOR"; then
if test "$ENABLE" -ne 1 -a "$DISABLE" -ne 1; then
echo "No $NSSWITCH file."
fi
exit 0
fi
HOSTS=$(grep -m1 "^\s*hosts:" "$NSSWITCH")
if test ! -f "$NSSWITCH"; then
NSSWITCH_IN=$NSSWITCH_VENDOR
else
NSSWITCH_IN=$NSSWITCH
fi
HOSTS=$(grep -m1 "^\s*hosts:" "$NSSWITCH_IN")
if test $? -ne 0; then
echo "No hosts configuration in $NSSWITCH."
@ -155,7 +162,9 @@ elif test "$DISABLE" -eq 1; then
NEWVALUE=$(echo $NEWVALUE | sed "s/^\s*//;s/^\s*$//")
if test "$BACKUP" -eq 1; then
if test "$NSSWITCH_IN" = "$NSSWITCH_VENDOR"; then
cp -a "$NSSWITCH_IN" "$NSSWITCH"
elif test "$BACKUP" -eq 1; then
cp -a "$NSSWITCH" "${NSSWITCH}bak"
fi
sed -i "s/\(^\s*hosts:\s*\).*/\1$NEWVALUE/" "$NSSWITCH"
@ -225,7 +234,9 @@ elif test "$ENABLE" -eq 1; then
NEWVALUE=$(echo $NEWVALUE | sed "s/^\s*//;s/^\s*$//")
if test "$BACKUP" -eq 1; then
if test "$NSSWITCH_IN" = "$NSSWITCH_VENDOR"; then
cp -a "$NSSWITCH_IN" "$NSSWITCH"
elif test "$BACKUP" -eq 1; then
cp -a "$NSSWITCH" "${NSSWITCH}bak"
fi
sed -i "s/\(^\s*hosts:\s*\).*/\1$NEWVALUE/" "$NSSWITCH"

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Tue May 19 10:48:50 UTC 2020 - Andreas Schwab <schwab@suse.de>
- nss-mdns-config: Use /usr/etc/nsswitch.conf as input if
/etc/nsswitch.conf doesn't exist yet
-------------------------------------------------------------------
Thu Apr 18 18:12:46 UTC 2019 - Jan Engelhardt <jengelh@inai.de>

View File

@ -1,7 +1,7 @@
#
# spec file for package nss-mdns
#
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2020 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed