Patchwork override the hardcoded paths with configurable conterparts.

login
register
mail settings
Submitter Benda Xu
Date Dec. 3, 2014, 12:55 p.m.
Message ID <1417611348-28647-2-git-send-email-heroxbd@gentoo.org>
Download mbox | patch
Permalink /patch/4052/
State New
Headers show

Comments

Benda Xu - Dec. 3, 2014, 12:55 p.m.
Hello,

This patch replace the hardcoded /etc with that deduced from configure.

This is of perticular interest on a system where /etc does not exist, or on a sys

Cheers,
Benda

2014-12-03  Benda Xu <heroxbd@gentoo.org>

	* nis/nss_compat/compat-grp.c nis/nss_compat/compat-initgroups.c
	nis/nss_compat/compat-pwd.c nis/nss_compat/compat-spwd.c: use SYSCONFDIR to
	override /etc.
	* nis/Makefile: define SYSCONFDIR from configure when building the files above.
	* nss/bug-erange.c nss/nss_files/files-init.c nss/nss_files/files-initgroups.c:
	use SYSCONFDIR to override /etc.
	* nss/Makefile: define SYSCONFDIR from configure when building the files above.
	Prefix objpfx to db-Makefile generated by configure.
	* nss/db-Makefile, resolv/netdb.h, resolv/resolv.h: use @libc_cv_sysconfdir@,
	to override /etc
	* configure.ac: generate nss/db-Makefile, resolv/netdb.h, resolv/resolv.h
	* confgiure: regenerate.
	* shadow/lckpwdf.c: use SYSCONFDIR to override /etc.
	* shadow/Makefile: define SYSCONFDIR from configure when building
	shadow/lckpwdf.c.
---
 configure                           |  5 ++++-
 configure.ac                        |  2 +-
 nis/Makefile                        |  5 +++++
 nis/nss_compat/compat-grp.c         |  2 +-
 nis/nss_compat/compat-initgroups.c  |  2 +-
 nis/nss_compat/compat-pwd.c         |  2 +-
 nis/nss_compat/compat-spwd.c        |  2 +-
 nss/Makefile                        |  6 +++++-
 nss/bug-erange.c                    |  2 +-
 nss/{db-Makefile => db-Makefile.in} | 31 +++++++++++++++++++------------
 nss/nss_files/files-init.c          | 24 ++++++++++++------------
 nss/nss_files/files-initgroups.c    |  2 +-
 resolv/{netdb.h => netdb.h.in}      | 12 ++++++------
 resolv/{resolv.h => resolv.h.in}    |  2 +-
 shadow/Makefile                     |  1 +
 shadow/lckpwdf.c                    |  2 +-
 16 files changed, 61 insertions(+), 41 deletions(-)
 rename nss/{db-Makefile => db-Makefile.in} (85%)
 rename resolv/{netdb.h => netdb.h.in} (98%)
 rename resolv/{resolv.h => resolv.h.in} (99%)
Mike Frysinger - March 2, 2015, 4:08 a.m.
On 03 Dec 2014 21:55, Benda Xu wrote:
> --- a/nis/Makefile
> +++ b/nis/Makefile
>
>  libnss_compat-routines	:= $(addprefix compat-,grp pwd spwd initgroups)
> +SYSCONF-FLAGS := -D'SYSCONFDIR="$(sysconfdir)"'
> +CPPFLAGS-compat-grp.c = $(SYSCONF-FLAGS)
> +CPPFLAGS-compat-pwd.c = $(SYSCONF-FLAGS)
> +CPPFLAGS-compat-spwd.c = $(SYSCONF-FLAGS)
> +CPPFLAGS-compat-initgroups.c = $(SYSCONF-FLAGS)

just add it to CPPFLAGS for the whole dir ?

> --- a/nss/Makefile
> +++ b/nss/Makefile
>
>  tests			= test-netdb tst-nss-test1 test-digits-dots
>  xtests			= bug-erange
> +SYSCONF-FLAGS := -D'SYSCONFDIR="$(sysconfdir)"'
> +CPPFLAGS-bug-erange.c = $(SYSCONF-FLAGS)

same here ?

> --- a/nss/db-Makefile
> +++ b/nss/db-Makefile.in
> @@ -1,3 +1,4 @@
> +
>  # Makefile to (re-)generate db versions of system database files.
>  # Copyright (C) 1996-2014 Free Software Foundation, Inc.
>  # This file is part of the GNU C Library.

useless hunk ?

> --- a/resolv/netdb.h
> +++ b/resolv/netdb.h.in
>
>  /* Absolute file name for network data base files.  */
> -#define	_PATH_HEQUIV		"/etc/hosts.equiv"
> -#define	_PATH_HOSTS		"/etc/hosts"
> -#define	_PATH_NETWORKS		"/etc/networks"
> -#define	_PATH_NSSWITCH_CONF	"/etc/nsswitch.conf"
> -#define	_PATH_PROTOCOLS		"/etc/protocols"
> -#define	_PATH_SERVICES		"/etc/services"
> +#define	_PATH_HEQUIV		"@libc_cv_sysconfdir@/hosts.equiv"
> +#define	_PATH_HOSTS		"@libc_cv_sysconfdir@/hosts"
> +#define	_PATH_NETWORKS		"@libc_cv_sysconfdir@/networks"
> +#define	_PATH_NSSWITCH_CONF	"@libc_cv_sysconfdir@/nsswitch.conf"
> +#define	_PATH_PROTOCOLS		"@libc_cv_sysconfdir@/protocols"
> +#define	_PATH_SERVICES		"@libc_cv_sysconfdir@/services"

the glibc-specific files make sense.  i'm not sure about the non-glibc files.  
otherwise, wouldn't we also update paths.h/fstab.h/etc... ?
-mike

Patch

diff --git a/configure b/configure
index 0cb54ec..0b34cc0 100755
--- a/configure
+++ b/configure
@@ -7136,7 +7136,7 @@  RELEASE=`sed -n -e 's/^#define RELEASE "\([^"]*\)"/\1/p' < $srcdir/version.h`
 
 
 
-ac_config_files="$ac_config_files config.make Makefile"
+ac_config_files="$ac_config_files config.make Makefile nss/db-Makefile resolv/netdb.h resolv/resolv.h"
 
 ac_config_commands="$ac_config_commands default"
 
@@ -7844,6 +7844,9 @@  do
     "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
     "config.make") CONFIG_FILES="$CONFIG_FILES config.make" ;;
     "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+    "nss/db-Makefile") CONFIG_FILES="$CONFIG_FILES nss/db-Makefile" ;;
+    "resolv/netdb.h") CONFIG_FILES="$CONFIG_FILES resolv/netdb.h" ;;
+    "resolv/resolv.h") CONFIG_FILES="$CONFIG_FILES resolv/resolv.h" ;;
     "default") CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
diff --git a/configure.ac b/configure.ac
index b2c4b1f..6222857 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2022,7 +2022,7 @@  RELEASE=`sed -n -e 's/^#define RELEASE "\([^"]*\)"/\1/p' < $srcdir/version.h`
 AC_SUBST(VERSION)
 AC_SUBST(RELEASE)
 
-AC_CONFIG_FILES([config.make Makefile])
+AC_CONFIG_FILES([config.make Makefile nss/db-Makefile resolv/netdb.h resolv/resolv.h])
 AC_CONFIG_COMMANDS([default],[[
 case $CONFIG_FILES in *config.make*)
 echo "$config_vars" >> config.make;;
diff --git a/nis/Makefile b/nis/Makefile
index 7688604..456eb4f 100644
--- a/nis/Makefile
+++ b/nis/Makefile
@@ -58,6 +58,11 @@  libnsl-routines = yp_xdr ypclnt ypupdate_xdr \
 		  nis_clone_res nss-default
 
 libnss_compat-routines	:= $(addprefix compat-,grp pwd spwd initgroups)
+SYSCONF-FLAGS := -D'SYSCONFDIR="$(sysconfdir)"'
+CPPFLAGS-compat-grp.c = $(SYSCONF-FLAGS)
+CPPFLAGS-compat-pwd.c = $(SYSCONF-FLAGS)
+CPPFLAGS-compat-spwd.c = $(SYSCONF-FLAGS)
+CPPFLAGS-compat-initgroups.c = $(SYSCONF-FLAGS)
 libnss_compat-inhibit-o	= $(filter-out .os,$(object-suffixes))
 
 libnss_nis-routines	:= $(addprefix nis-,$(databases)) nis-initgroups \
diff --git a/nis/nss_compat/compat-grp.c b/nis/nss_compat/compat-grp.c
index 78e14d6..02b9106 100644
--- a/nis/nss_compat/compat-grp.c
+++ b/nis/nss_compat/compat-grp.c
@@ -120,7 +120,7 @@  internal_setgrent (ent_t *ent, int stayopen, int needent)
 
   if (ent->stream == NULL)
     {
-      ent->stream = fopen ("/etc/group", "rme");
+      ent->stream = fopen (SYSCONFDIR "/group", "rme");
 
       if (ent->stream == NULL)
 	status = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;
diff --git a/nis/nss_compat/compat-initgroups.c b/nis/nss_compat/compat-initgroups.c
index c5ba606..4dbe7fc 100644
--- a/nis/nss_compat/compat-initgroups.c
+++ b/nis/nss_compat/compat-initgroups.c
@@ -136,7 +136,7 @@  internal_setgrent (ent_t *ent)
   else
     ent->blacklist.current = 0;
 
-  ent->stream = fopen ("/etc/group", "rme");
+  ent->stream = fopen (SYSCONFDIR "/group", "rme");
 
   if (ent->stream == NULL)
     status = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;
diff --git a/nis/nss_compat/compat-pwd.c b/nis/nss_compat/compat-pwd.c
index 127673c..3a058b8 100644
--- a/nis/nss_compat/compat-pwd.c
+++ b/nis/nss_compat/compat-pwd.c
@@ -235,7 +235,7 @@  internal_setpwent (ent_t *ent, int stayopen, int needent)
 
   if (ent->stream == NULL)
     {
-      ent->stream = fopen ("/etc/passwd", "rme");
+      ent->stream = fopen (SYSCONFDIR "/passwd", "rme");
 
       if (ent->stream == NULL)
 	status = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;
diff --git a/nis/nss_compat/compat-spwd.c b/nis/nss_compat/compat-spwd.c
index 4890ce6..c5df88b 100644
--- a/nis/nss_compat/compat-spwd.c
+++ b/nis/nss_compat/compat-spwd.c
@@ -191,7 +191,7 @@  internal_setspent (ent_t *ent, int stayopen)
 
   if (ent->stream == NULL)
     {
-      ent->stream = fopen ("/etc/shadow", "rme");
+      ent->stream = fopen (SYSCONFDIR "/shadow", "rme");
 
       if (ent->stream == NULL)
 	status = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;
diff --git a/nss/Makefile b/nss/Makefile
index e0adf90..1d29822 100644
--- a/nss/Makefile
+++ b/nss/Makefile
@@ -41,6 +41,8 @@  extra-objs		+= $(makedb-modules:=.o)
 
 tests			= test-netdb tst-nss-test1 test-digits-dots
 xtests			= bug-erange
+SYSCONF-FLAGS := -D'SYSCONFDIR="$(sysconfdir)"'
+CPPFLAGS-bug-erange.c = $(SYSCONF-FLAGS)
 
 # Specify rules for the nss_* modules.  We have some services.
 services		:= files db
@@ -57,6 +59,8 @@  vpath %.c $(subdir-dirs) ../locale/programs ../intl
 
 libnss_files-routines	:= $(addprefix files-,$(databases)) \
 			   files-initgroups files-have_o_cloexec files-init
+CPPFLAGS-files-init.c = $(SYSCONF-FLAGS)
+CPPFLAGS-files-initgroups.c = $(SYSCONF-FLAGS)
 
 libnss_db-dbs		:= $(addprefix db-,\
 				       $(filter-out hosts network key alias,\
@@ -102,7 +106,7 @@  $(libnss_db-dbs:%=$(objpfx)%.c): $(objpfx)db-%.c: nss_files/files-%.c
 
 $(objpfx)makedb: $(makedb-modules:%=$(objpfx)%.o)
 
-$(inst_vardbdir)/Makefile: db-Makefile $(+force)
+$(inst_vardbdir)/Makefile: $(objpfx)db-Makefile $(+force)
 	$(do-install)
 
 libof-nss_test1 = extramodules
diff --git a/nss/bug-erange.c b/nss/bug-erange.c
index b709418..7873d14 100644
--- a/nss/bug-erange.c
+++ b/nss/bug-erange.c
@@ -37,7 +37,7 @@  main (void)
     {
       printf ("gethostbyname_r failed: %s (errno: %m)\n", strerror (res));
 
-      if (access ("/etc/resolv.conf", R_OK))
+      if (access (SYSCONFDIR "/resolv.conf", R_OK))
 	{
 	  puts ("DNS probably not set up");
 	  return 0;
diff --git a/nss/db-Makefile b/nss/db-Makefile.in
similarity index 85%
rename from nss/db-Makefile
rename to nss/db-Makefile.in
index d0009d0..03a6e21 100644
--- a/nss/db-Makefile
+++ b/nss/db-Makefile.in
@@ -1,3 +1,4 @@ 
+
 # Makefile to (re-)generate db versions of system database files.
 # Copyright (C) 1996-2014 Free Software Foundation, Inc.
 # This file is part of the GNU C Library.
@@ -18,9 +19,15 @@ 
 # License along with the GNU C Library; if not, see
 # <http://www.gnu.org/licenses/>.
 
-DATABASES = $(wildcard /etc/passwd /etc/group /etc/ethers /etc/protocols \
-		       /etc/rpc /etc/services /etc/shadow /etc/gshadow \
-		       /etc/netgroup)
+DATABASES = $(wildcard @libc_cv_sysconfdir@/passwd	\
+		       @libc_cv_sysconfdir@/group	\
+		       @libc_cv_sysconfdir@/ethers	\
+		       @libc_cv_sysconfdir@/protocols	\
+		       @libc_cv_sysconfdir@/rpc		\
+		       @libc_cv_sysconfdir@/services	\
+		       @libc_cv_sysconfdir@/shadow	\
+		       @libc_cv_sysconfdir@/gshadow	\
+		       @libc_cv_sysconfdir@/netgroup)
 
 VAR_DB = /var/db
 
@@ -30,7 +37,7 @@  MAKEDB = makedb --quiet
 all: $(patsubst %,$(VAR_DB)/%.db,$(notdir $(DATABASES)))
 
 
-$(VAR_DB)/passwd.db: /etc/passwd
+$(VAR_DB)/passwd.db: @libc_cv_sysconfdir@/passwd
 	@echo -n "$(patsubst %.db,%,$(@F))... "
 	@$(AWK) 'BEGIN { FS=":"; OFS=":" } \
 		 /^[ \t]*$$/ { next } \
@@ -40,7 +47,7 @@  $(VAR_DB)/passwd.db: /etc/passwd
 	$(MAKEDB) -o $@ -
 	@echo "done."
 
-$(VAR_DB)/group.db: /etc/group
+$(VAR_DB)/group.db: @libc_cv_sysconfdir@/group
 	@echo -n "$(patsubst %.db,%,$(@F))... "
 	@$(AWK) 'BEGIN { FS=":"; OFS=":" } \
 		 /^[ \t]*$$/ { next } \
@@ -62,7 +69,7 @@  $(VAR_DB)/group.db: /etc/group
 	$(MAKEDB) -o $@ -
 	@echo "done."
 
-$(VAR_DB)/ethers.db: /etc/ethers
+$(VAR_DB)/ethers.db: @libc_cv_sysconfdir@/ethers
 	@echo -n "$(patsubst %.db,%,$(@F))... "
 	@$(AWK) '/^[ \t]*$$/ { next } \
 		 /^[ \t]*#/ { next } \
@@ -71,7 +78,7 @@  $(VAR_DB)/ethers.db: /etc/ethers
 	$(MAKEDB) -o $@ -
 	@echo "done."
 
-$(VAR_DB)/protocols.db: /etc/protocols
+$(VAR_DB)/protocols.db: @libc_cv_sysconfdir@/protocols
 	@echo -n "$(patsubst %.db,%,$(@F))... "
 	@$(AWK) '/^[ \t]*$$/ { next } \
 		 /^[ \t]*#/ { next } \
@@ -82,7 +89,7 @@  $(VAR_DB)/protocols.db: /etc/protocols
 	$(MAKEDB) -o $@ -
 	@echo "done."
 
-$(VAR_DB)/rpc.db: /etc/rpc
+$(VAR_DB)/rpc.db: @libc_cv_sysconfdir@/rpc
 	@echo -n "$(patsubst %.db,%,$(@F))... "
 	@$(AWK) '/^[ \t]*$$/ { next } \
 		 /^[ \t]*#/ { next } \
@@ -93,7 +100,7 @@  $(VAR_DB)/rpc.db: /etc/rpc
 	$(MAKEDB) -o $@ -
 	@echo "done."
 
-$(VAR_DB)/services.db: /etc/services
+$(VAR_DB)/services.db: @libc_cv_sysconfdir@/services
 	@echo -n "$(patsubst %.db,%,$(@F))... "
 	@$(AWK) 'BEGIN { FS="[ \t/]+" } \
 		 /^[ \t]*$$/ { next } \
@@ -109,7 +116,7 @@  $(VAR_DB)/services.db: /etc/services
 	$(MAKEDB) -o $@ -
 	@echo "done."
 
-$(VAR_DB)/shadow.db: /etc/shadow
+$(VAR_DB)/shadow.db: @libc_cv_sysconfdir@/shadow
 	@echo -n "$(patsubst %.db,%,$(@F))... "
 	@$(AWK) 'BEGIN { FS=":"; OFS=":" } \
 		 /^[ \t]*$$/ { next } \
@@ -129,7 +136,7 @@  $(VAR_DB)/shadow.db: /etc/shadow
 	  echo; \
 	fi
 
-$(VAR_DB)/gshadow.db: /etc/gshadow
+$(VAR_DB)/gshadow.db: @libc_cv_sysconfdir@/gshadow
 	@echo -n "$(patsubst %.db,%,$(@F))... "
 	@$(AWK) 'BEGIN { FS=":"; OFS=":" } \
 		 /^[ \t]*$$/ { next } \
@@ -149,7 +156,7 @@  $(VAR_DB)/gshadow.db: /etc/gshadow
 	  echo; \
 	fi
 
-$(VAR_DB)/netgroup.db: /etc/netgroup
+$(VAR_DB)/netgroup.db: @libc_cv_sysconfdir@/netgroup
 	@echo -n "$(patsubst %.db,%,$(@F))... "
 	@$(AWK) 'BEGIN { ini=1 } \
 		 /^[ \t]*$$/ { next } \
diff --git a/nss/nss_files/files-init.c b/nss/nss_files/files-init.c
index 346395c..a348a3c 100644
--- a/nss/nss_files/files-init.c
+++ b/nss/nss_files/files-init.c
@@ -35,33 +35,33 @@  static union							\
     }								\
   }
 
-TF (pwd, "/etc/passwd");
-TF (grp, "/etc/group");
-TF (hst, "/etc/hosts");
-TF (resolv, "/etc/resolv.conf", .call_res_init = 1);
-TF (serv, "/etc/services");
-TF (netgr, "/etc/netgroup");
+TF (pwd, SYSCONFDIR "/passwd");
+TF (grp, SYSCONFDIR "/group");
+TF (hst, SYSCONFDIR "/hosts");
+TF (resolv, SYSCONFDIR "/resolv.conf", .call_res_init = 1);
+TF (serv, SYSCONFDIR "/services");
+TF (netgr, SYSCONFDIR "/netgroup");
 
 
 void
 _nss_files_init (void (*cb) (size_t, struct traced_file *))
 {
-  strcpy (pwd_traced_file.file.fname, "/etc/passwd");
+  strcpy (pwd_traced_file.file.fname, SYSCONFDIR "/passwd");
   cb (pwddb, &pwd_traced_file.file);
 
-  strcpy (grp_traced_file.file.fname, "/etc/group");
+  strcpy (grp_traced_file.file.fname, SYSCONFDIR "/group");
   cb (grpdb, &grp_traced_file.file);
 
-  strcpy (hst_traced_file.file.fname, "/etc/hosts");
+  strcpy (hst_traced_file.file.fname, SYSCONFDIR "/hosts");
   cb (hstdb, &hst_traced_file.file);
 
-  strcpy (resolv_traced_file.file.fname, "/etc/resolv.conf");
+  strcpy (resolv_traced_file.file.fname, SYSCONFDIR "/resolv.conf");
   cb (hstdb, &resolv_traced_file.file);
 
-  strcpy (serv_traced_file.file.fname, "/etc/services");
+  strcpy (serv_traced_file.file.fname, SYSCONFDIR "/services");
   cb (servdb, &serv_traced_file.file);
 
-  strcpy (netgr_traced_file.file.fname, "/etc/netgroup");
+  strcpy (netgr_traced_file.file.fname, SYSCONFDIR "/netgroup");
   cb (netgrdb, &netgr_traced_file.file);
 }
 
diff --git a/nss/nss_files/files-initgroups.c b/nss/nss_files/files-initgroups.c
index 9249c24..47846d8 100644
--- a/nss/nss_files/files-initgroups.c
+++ b/nss/nss_files/files-initgroups.c
@@ -31,7 +31,7 @@  _nss_files_initgroups_dyn (const char *user, gid_t group, long int *start,
 			   long int *size, gid_t **groupsp, long int limit,
 			   int *errnop)
 {
-  FILE *stream = fopen ("/etc/group", "rce");
+  FILE *stream = fopen (SYSCONFDIR "/group", "rce");
   if (stream == NULL)
     {
       *errnop = errno;
diff --git a/resolv/netdb.h b/resolv/netdb.h.in
similarity index 98%
rename from resolv/netdb.h
rename to resolv/netdb.h.in
index c3386db..578a414 100644
--- a/resolv/netdb.h
+++ b/resolv/netdb.h.in
@@ -42,12 +42,12 @@ 
 #include <bits/netdb.h>
 
 /* Absolute file name for network data base files.  */
-#define	_PATH_HEQUIV		"/etc/hosts.equiv"
-#define	_PATH_HOSTS		"/etc/hosts"
-#define	_PATH_NETWORKS		"/etc/networks"
-#define	_PATH_NSSWITCH_CONF	"/etc/nsswitch.conf"
-#define	_PATH_PROTOCOLS		"/etc/protocols"
-#define	_PATH_SERVICES		"/etc/services"
+#define	_PATH_HEQUIV		"@libc_cv_sysconfdir@/hosts.equiv"
+#define	_PATH_HOSTS		"@libc_cv_sysconfdir@/hosts"
+#define	_PATH_NETWORKS		"@libc_cv_sysconfdir@/networks"
+#define	_PATH_NSSWITCH_CONF	"@libc_cv_sysconfdir@/nsswitch.conf"
+#define	_PATH_PROTOCOLS		"@libc_cv_sysconfdir@/protocols"
+#define	_PATH_SERVICES		"@libc_cv_sysconfdir@/services"
 
 
 __BEGIN_DECLS
diff --git a/resolv/resolv.h b/resolv/resolv.h.in
similarity index 99%
rename from resolv/resolv.h
rename to resolv/resolv.h.in
index 53c3bba..fca40f0 100644
--- a/resolv/resolv.h
+++ b/resolv/resolv.h.in
@@ -170,7 +170,7 @@  typedef struct __res_state *res_state;
  */
 
 #ifndef _PATH_RESCONF
-#define _PATH_RESCONF        "/etc/resolv.conf"
+#define _PATH_RESCONF        "@libc_cv_sysconfdir@/resolv.conf"
 #endif
 
 struct res_sym {
diff --git a/shadow/Makefile b/shadow/Makefile
index 72ee8e4..5f6934f 100644
--- a/shadow/Makefile
+++ b/shadow/Makefile
@@ -36,5 +36,6 @@  CFLAGS-fgetspent_r.c = -fexceptions $(libio-mtsafe)
 CFLAGS-putspent.c = -fexceptions $(libio-mtsafe)
 CFLAGS-getspnam.c = -fexceptions
 CFLAGS-getspnam_r.c = -fexceptions
+CPPFLAGS-lckpwdf.c = -DSYSCONFDIR='"$(sysconfdir)"'
 
 include ../Rules
diff --git a/shadow/lckpwdf.c b/shadow/lckpwdf.c
index bedfc16..df51afe 100644
--- a/shadow/lckpwdf.c
+++ b/shadow/lckpwdf.c
@@ -29,7 +29,7 @@ 
 
 
 /* Name of the lock file.  */
-#define PWD_LOCKFILE "/etc/.pwd.lock"
+#define PWD_LOCKFILE SYSCONFDIR "/.pwd.lock"
 
 /* How long to wait for getting the lock before returning with an
    error.  */