source: clfs-sysroot/patches/shadow-4.0.18.1-sysroot_hacks-1.patch@ 8765e79

Last change on this file since 8765e79 was 1d53724, checked in by Joe Ciccone <jciccone@…>, 18 years ago

Added: shadow-4.0.18.1-sysroot_hacks-1.patch

  • Property mode set to 100644
File size: 14.3 KB
RevLine 
[1d53724]1Submitted By: Joe Ciccone <jciccone@linuxfromscratch.org>
2Date: 2006-11-24
3Initial Package Version: 4.0.18.1
4Origin: Joe Ciccone
5Upstream Status: None
6Description: Changes the hardcoded /etc to the value of the --sysconfdir
7 parameter passed to configure. Allows the utilities to be run
8 as a user other then root and properly modify the passwd and group
9 files for the target system.
10
11diff -Naur shadow-4.0.18.1.orig/lib/Makefile.am shadow-4.0.18.1/lib/Makefile.am
12--- shadow-4.0.18.1.orig/lib/Makefile.am 2006-06-24 09:12:19.000000000 -0400
13+++ shadow-4.0.18.1/lib/Makefile.am 2006-11-24 14:24:57.000000000 -0500
14@@ -2,6 +2,7 @@
15 AUTOMAKE_OPTIONS = 1.0 foreign
16
17 DEFS =
18+AM_CPPFLAGS = -DSYSCONFDIR=\"$(sysconfdir)\"
19
20 lib_LTLIBRARIES = libshadow.la
21
22diff -Naur shadow-4.0.18.1.orig/lib/Makefile.in shadow-4.0.18.1/lib/Makefile.in
23--- shadow-4.0.18.1.orig/lib/Makefile.in 2006-08-03 06:25:10.000000000 -0400
24+++ shadow-4.0.18.1/lib/Makefile.in 2006-11-24 14:24:57.000000000 -0500
25@@ -217,6 +217,7 @@
26 sharedstatedir = @sharedstatedir@
27 sysconfdir = @sysconfdir@
28 target_alias = @target_alias@
29+AM_CPPFLAGS = -DSYSCONFDIR=\"$(sysconfdir)\"
30 AUTOMAKE_OPTIONS = 1.0 foreign
31 lib_LTLIBRARIES = libshadow.la
32 libshadow_la_LDFLAGS = -version-info 0:0:0
33diff -Naur shadow-4.0.18.1.orig/lib/commonio.c shadow-4.0.18.1/lib/commonio.c
34--- shadow-4.0.18.1.orig/lib/commonio.c 2006-06-08 09:36:11.000000000 -0400
35+++ shadow-4.0.18.1/lib/commonio.c 2006-11-24 14:24:57.000000000 -0500
36@@ -153,14 +153,6 @@
37 if (!fp)
38 return NULL;
39
40-#ifdef HAVE_FCHOWN
41- if (fchown (fileno (fp), sb->st_uid, sb->st_gid))
42- goto fail;
43-#else
44- if (chown (name, sb->st_mode))
45- goto fail;
46-#endif
47-
48 #ifdef HAVE_FCHMOD
49 if (fchmod (fileno (fp), sb->st_mode & 0664))
50 goto fail;
51@@ -703,7 +695,7 @@
52 * Default permissions for new [g]shadow files.
53 * (passwd and group always exist...)
54 */
55- sb.st_mode = 0400;
56+ sb.st_mode = 0600;
57 sb.st_uid = 0;
58 sb.st_gid = 0;
59 }
60diff -Naur shadow-4.0.18.1.orig/lib/defines.h shadow-4.0.18.1/lib/defines.h
61--- shadow-4.0.18.1.orig/lib/defines.h 2005-09-05 12:22:03.000000000 -0400
62+++ shadow-4.0.18.1/lib/defines.h 2006-11-24 14:24:57.000000000 -0500
63@@ -284,20 +284,20 @@
64 #endif
65
66 #ifndef PASSWD_FILE
67-#define PASSWD_FILE "/etc/passwd"
68+#define PASSWD_FILE SYSCONFDIR"/passwd"
69 #endif
70
71 #ifndef GROUP_FILE
72-#define GROUP_FILE "/etc/group"
73+#define GROUP_FILE SYSCONFDIR"/group"
74 #endif
75
76 #ifndef SHADOW_FILE
77-#define SHADOW_FILE "/etc/shadow"
78+#define SHADOW_FILE SYSCONFDIR"/shadow"
79 #endif
80
81 #ifdef SHADOWGRP
82 #ifndef SGROUP_FILE
83-#define SGROUP_FILE "/etc/gshadow"
84+#define SGROUP_FILE SYSCONFDIR"/gshadow"
85 #endif
86 #endif
87
88diff -Naur shadow-4.0.18.1.orig/lib/getdef.c shadow-4.0.18.1/lib/getdef.c
89--- shadow-4.0.18.1.orig/lib/getdef.c 2006-06-24 09:17:18.000000000 -0400
90+++ shadow-4.0.18.1/lib/getdef.c 2006-11-24 14:24:57.000000000 -0500
91@@ -114,7 +114,7 @@
92 };
93
94 #ifndef LOGINDEFS
95-#define LOGINDEFS "/etc/login.defs"
96+#define LOGINDEFS SYSCONFDIR"/login.defs"
97 #endif
98
99 static char def_fname[] = LOGINDEFS; /* login config defs file */
100diff -Naur shadow-4.0.18.1.orig/lib/gshadow_.h shadow-4.0.18.1/lib/gshadow_.h
101--- shadow-4.0.18.1.orig/lib/gshadow_.h 2005-03-31 00:14:49.000000000 -0500
102+++ shadow-4.0.18.1/lib/gshadow_.h 2006-11-24 14:24:57.000000000 -0500
103@@ -67,5 +67,5 @@
104 int putsgent ();
105 #endif
106
107-#define GSHADOW "/etc/gshadow"
108+#define GSHADOW SYSCONFDIR"/gshadow"
109 #endif /* ifndef _H_GSHADOW */
110diff -Naur shadow-4.0.18.1.orig/lib/port.h shadow-4.0.18.1/lib/port.h
111--- shadow-4.0.18.1.orig/lib/port.h 2005-03-31 00:14:49.000000000 -0500
112+++ shadow-4.0.18.1/lib/port.h 2006-11-24 14:24:57.000000000 -0500
113@@ -50,7 +50,7 @@
114 * PORT_DAY - Day of the week to a bit value (0 = Sunday).
115 */
116
117-#define PORTS "/etc/porttime"
118+#define PORTS SYSCONFDIR"/porttime"
119 #define PORT_IDS 64
120 #define PORT_TTY 64
121 #define PORT_TIMES 24
122diff -Naur shadow-4.0.18.1.orig/libmisc/Makefile.am shadow-4.0.18.1/libmisc/Makefile.am
123--- shadow-4.0.18.1.orig/libmisc/Makefile.am 2005-09-05 12:21:37.000000000 -0400
124+++ shadow-4.0.18.1/libmisc/Makefile.am 2006-11-24 14:24:57.000000000 -0500
125@@ -1,6 +1,8 @@
126
127 EXTRA_DOST = .indent.pro
128
129+AM_CPPFLAGS = -DSYSCONFDIR=\"$(sysconfdir)\"
130+
131 INCLUDES = -I$(top_srcdir)/lib
132
133 noinst_LIBRARIES = libmisc.a
134diff -Naur shadow-4.0.18.1.orig/libmisc/Makefile.in shadow-4.0.18.1/libmisc/Makefile.in
135--- shadow-4.0.18.1.orig/libmisc/Makefile.in 2006-08-03 06:25:10.000000000 -0400
136+++ shadow-4.0.18.1/libmisc/Makefile.in 2006-11-24 14:24:57.000000000 -0500
137@@ -224,6 +224,7 @@
138 target_alias = @target_alias@
139 EXTRA_DOST = .indent.pro
140 INCLUDES = -I$(top_srcdir)/lib
141+AM_CPPFLAGS = -DSYSCONFDIR=\"$(sysconfdir)\"
142 noinst_LIBRARIES = libmisc.a
143 libmisc_a_SOURCES = \
144 addgrps.c \
145diff -Naur shadow-4.0.18.1.orig/libmisc/limits.c shadow-4.0.18.1/libmisc/limits.c
146--- shadow-4.0.18.1.orig/libmisc/limits.c 2006-07-10 00:11:31.000000000 -0400
147+++ shadow-4.0.18.1/libmisc/limits.c 2006-11-24 14:24:57.000000000 -0500
148@@ -51,7 +51,7 @@
149 #endif
150 #ifdef LIMITS
151 #ifndef LIMITS_FILE
152-#define LIMITS_FILE "/etc/limits"
153+#define LIMITS_FILE SYSCONFDIR"/limits"
154 #endif
155 #define LOGIN_ERROR_RLIMIT 1
156 #define LOGIN_ERROR_LOGIN 2
157diff -Naur shadow-4.0.18.1.orig/src/Makefile.am shadow-4.0.18.1/src/Makefile.am
158--- shadow-4.0.18.1.orig/src/Makefile.am 2006-07-18 12:52:23.000000000 -0400
159+++ shadow-4.0.18.1/src/Makefile.am 2006-11-24 14:27:07.000000000 -0500
160@@ -3,7 +3,7 @@
161 .indent.pro
162
163 ubindir = ${prefix}/bin
164-usbindir = ${prefix}/sbin
165+usbindir = ${prefix}/bin
166
167 INCLUDES = \
168 -I${top_srcdir}/lib \
169@@ -51,7 +51,7 @@
170
171 LDADD = $(top_builddir)/libmisc/libmisc.a \
172 $(top_builddir)/lib/libshadow.la
173-AM_CPPFLAGS = -DLOCALEDIR=\"$(datadir)/locale\"
174+AM_CPPFLAGS = -DSYSCONFDIR=\"$(sysconfdir)\" -DLOCALEDIR=\"$(datadir)/locale\" -DSG=\"`echo sg | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`\" -DVIGR=\"`echo vigr | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`\"
175
176 chage_LDADD = $(LDADD) $(LIBPAM) $(LIBAUDIT) $(LIBSELINUX)
177 chfn_LDADD = $(LDADD) $(LIBPAM) $(LIBSELINUX)
178@@ -88,11 +88,12 @@
179
180 install-am: all-am
181 $(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
182- ln -sf newgrp $(DESTDIR)$(ubindir)/sg
183- ln -sf vipw $(DESTDIR)$(usbindir)/vigr
184+ ln -sf `echo newgrp | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'` $(DESTDIR)$(ubindir)/`echo sg | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`
185+ ln -sf `echo vipw | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'` $(DESTDIR)$(usbindir)/`echo vigr | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`
186 for i in $(suidbins); do \
187- chmod -f 4755 $(DESTDIR)$(bindir)/$$i; \
188+ chmod -f 4755 $(DESTDIR)$(bindir)/`echo $$i | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
189 done
190 for i in $(suidubins); do \
191- chmod -f 4755 $(DESTDIR)$(ubindir)/$$i; \
192+ chmod -f 4755 $(DESTDIR)$(ubindir)/`echo $$i | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
193 done
194+
195diff -Naur shadow-4.0.18.1.orig/src/Makefile.in shadow-4.0.18.1/src/Makefile.in
196--- shadow-4.0.18.1.orig/src/Makefile.in 2006-08-03 06:25:15.000000000 -0400
197+++ shadow-4.0.18.1/src/Makefile.in 2006-11-24 14:27:22.000000000 -0500
198@@ -368,7 +368,7 @@
199 .indent.pro
200
201 ubindir = ${prefix}/bin
202-usbindir = ${prefix}/sbin
203+usbindir = ${prefix}/bin
204 INCLUDES = \
205 -I${top_srcdir}/lib \
206 -I$(top_srcdir)/libmisc
207@@ -378,7 +378,7 @@
208 LDADD = $(top_builddir)/libmisc/libmisc.a \
209 $(top_builddir)/lib/libshadow.la
210
211-AM_CPPFLAGS = -DLOCALEDIR=\"$(datadir)/locale\"
212+AM_CPPFLAGS = -DSYSCONFDIR=\"$(sysconfdir)\" -DLOCALEDIR=\"$(datadir)/locale\" -DSG=\"`echo sg | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`\" -DVIGR=\"`echo vigr | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`\"
213 chage_LDADD = $(LDADD) $(LIBPAM) $(LIBAUDIT) $(LIBSELINUX)
214 chfn_LDADD = $(LDADD) $(LIBPAM) $(LIBSELINUX)
215 chgpasswd_LDADD = $(LDADD) $(LIBPAM) $(LIBSELINUX)
216@@ -914,14 +914,15 @@
217
218 install-am: all-am
219 $(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
220- ln -sf newgrp $(DESTDIR)$(ubindir)/sg
221- ln -sf vipw $(DESTDIR)$(usbindir)/vigr
222+ ln -sf `echo newgrp | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'` $(DESTDIR)$(ubindir)/`echo sg | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`
223+ ln -sf `echo vipw | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'` $(DESTDIR)$(usbindir)/`echo vigr | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`
224 for i in $(suidbins); do \
225- chmod -f 4755 $(DESTDIR)$(bindir)/$$i; \
226+ chmod -f 4755 $(DESTDIR)$(bindir)/`echo $$i | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
227 done
228 for i in $(suidubins); do \
229- chmod -f 4755 $(DESTDIR)$(ubindir)/$$i; \
230+ chmod -f 4755 $(DESTDIR)$(ubindir)/`echo $$i | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
231 done
232+
233 # Tell versions [3.59,3.63) of GNU make to not export all variables.
234 # Otherwise a system limit (for SysV at least) may be exceeded.
235 .NOEXPORT:
236diff -Naur shadow-4.0.18.1.orig/src/chage.c shadow-4.0.18.1/src/chage.c
237--- shadow-4.0.18.1.orig/src/chage.c 2006-07-19 12:38:57.000000000 -0400
238+++ shadow-4.0.18.1/src/chage.c 2006-11-24 14:24:57.000000000 -0500
239@@ -361,7 +361,7 @@
240 textdomain (PACKAGE);
241
242 ruid = getuid ();
243- amroot = (ruid == 0);
244+ amroot = 1; //(ruid == 0);
245 #ifdef WITH_SELINUX
246 if (amroot && is_selinux_enabled () > 0)
247 amroot = (selinux_check_passwd_access (PASSWD__ROOTOK) == 0);
248diff -Naur shadow-4.0.18.1.orig/src/chsh.c shadow-4.0.18.1/src/chsh.c
249--- shadow-4.0.18.1.orig/src/chsh.c 2006-07-13 17:26:35.000000000 -0400
250+++ shadow-4.0.18.1/src/chsh.c 2006-11-24 14:24:57.000000000 -0500
251@@ -55,7 +55,7 @@
252 #include "pam_defs.h"
253 #endif
254 #ifndef SHELLS_FILE
255-#define SHELLS_FILE "/etc/shells"
256+#define SHELLS_FILE SYSCONFDIR"/shells"
257 #endif
258 /*
259 * Global variables
260@@ -195,7 +195,7 @@
261 /*
262 * This command behaves different for root and non-root users.
263 */
264- amroot = getuid () == 0;
265+ amroot = 1; //getuid () == 0;
266
267 /*
268 * Get the program name. The program name is used as a prefix to
269diff -Naur shadow-4.0.18.1.orig/src/gpasswd.c shadow-4.0.18.1/src/gpasswd.c
270--- shadow-4.0.18.1.orig/src/gpasswd.c 2006-02-08 05:58:46.000000000 -0500
271+++ shadow-4.0.18.1/src/gpasswd.c 2006-11-24 14:24:57.000000000 -0500
272@@ -202,7 +202,7 @@
273 * prevent the invoker from issuing signals which would interfer
274 * with this command.
275 */
276- amroot = getuid () == 0;
277+ amroot = 1; //getuid () == 0;
278 bywho = getuid ();
279 Prog = Basename (argv[0]);
280
281@@ -628,16 +628,6 @@
282 * output, etc.
283 */
284 output:
285- if (setuid (0)) {
286- fprintf (stderr, _("Cannot change ID to root.\n"));
287- SYSLOG ((LOG_ERR, "can't setuid(0)"));
288-#ifdef WITH_AUDIT
289- audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "changing id to root",
290- group, -1, 0);
291-#endif
292- closelog ();
293- exit (1);
294- }
295 pwd_init ();
296
297 if (!gr_lock ()) {
298diff -Naur shadow-4.0.18.1.orig/src/login_nopam.c shadow-4.0.18.1/src/login_nopam.c
299--- shadow-4.0.18.1.orig/src/login_nopam.c 2005-09-07 11:00:45.000000000 -0400
300+++ shadow-4.0.18.1/src/login_nopam.c 2006-11-24 14:24:57.000000000 -0500
301@@ -60,7 +60,7 @@
302 /* Path name of the access control file. */
303
304 #ifndef TABLE
305-#define TABLE "/etc/login.access"
306+#define TABLE SYSCONFDIR"/login.access"
307 #endif
308
309 /* Delimiters for fields and for lists of users, ttys or hosts. */
310diff -Naur shadow-4.0.18.1.orig/src/logoutd.c shadow-4.0.18.1/src/logoutd.c
311--- shadow-4.0.18.1.orig/src/logoutd.c 2006-07-10 00:11:32.000000000 -0400
312+++ shadow-4.0.18.1/src/logoutd.c 2006-11-24 14:24:57.000000000 -0500
313@@ -48,7 +48,7 @@
314 #endif
315
316 #ifndef HUP_MESG_FILE
317-#define HUP_MESG_FILE "/etc/logoutd.mesg"
318+#define HUP_MESG_FILE SYSCONFDIR"/logoutd.mesg"
319 #endif
320
321 #if HAVE_UTMPX_H
322diff -Naur shadow-4.0.18.1.orig/src/newgrp.c shadow-4.0.18.1/src/newgrp.c
323--- shadow-4.0.18.1.orig/src/newgrp.c 2006-01-18 14:55:15.000000000 -0500
324+++ shadow-4.0.18.1/src/newgrp.c 2006-11-24 14:24:57.000000000 -0500
325@@ -153,7 +153,7 @@
326 */
327 Prog = Basename (argv[0]);
328 is_newgrp = (strcmp (Prog, "newgrp") == 0);
329- OPENLOG (is_newgrp ? "newgrp" : "sg");
330+ OPENLOG (is_newgrp ? "newgrp" : SG);
331 gid = getgid ();
332 argc--;
333 argv++;
334@@ -466,7 +466,7 @@
335 if (child < 0) {
336 /* error in fork() */
337 fprintf (stderr, _("%s: failure forking: %s"),
338- is_newgrp ? "newgrp" : "sg", strerror (errno));
339+ is_newgrp ? "newgrp" : SG, strerror (errno));
340 #ifdef WITH_AUDIT
341 audit_logger (AUDIT_USER_START, Prog, "changing",
342 NULL, getuid (), 0);
343diff -Naur shadow-4.0.18.1.orig/src/passwd.c shadow-4.0.18.1/src/passwd.c
344--- shadow-4.0.18.1.orig/src/passwd.c 2006-07-28 13:40:15.000000000 -0400
345+++ shadow-4.0.18.1/src/passwd.c 2006-11-24 14:24:57.000000000 -0500
346@@ -614,7 +614,7 @@
347 * The program behaves differently when executed by root than when
348 * executed by a normal user.
349 */
350- amroot = (getuid () == 0);
351+ amroot = 1; //(getuid () == 0);
352
353 /*
354 * Get the program name. The program name is used as a prefix to
355@@ -878,12 +878,6 @@
356 exit (E_SUCCESS);
357 }
358 #endif /* USE_PAM */
359- if (setuid (0)) {
360- fprintf (stderr, _("Cannot change ID to root.\n"));
361- SYSLOG ((LOG_ERR, "can't setuid(0)"));
362- closelog ();
363- exit (E_NOPERM);
364- }
365 if (spw_file_present ())
366 update_shadow ();
367 else
368diff -Naur shadow-4.0.18.1.orig/src/suauth.c shadow-4.0.18.1/src/suauth.c
369--- shadow-4.0.18.1.orig/src/suauth.c 2005-09-07 11:00:45.000000000 -0400
370+++ shadow-4.0.18.1/src/suauth.c 2006-11-24 14:24:57.000000000 -0500
371@@ -8,7 +8,7 @@
372 #include "prototypes.h"
373
374 #ifndef SUAUTHFILE
375-#define SUAUTHFILE "/etc/suauth"
376+#define SUAUTHFILE SYSCONFDIR"/suauth"
377 #endif
378
379 #define NOACTION 0
380diff -Naur shadow-4.0.18.1.orig/src/useradd.c shadow-4.0.18.1/src/useradd.c
381--- shadow-4.0.18.1.orig/src/useradd.c 2006-11-24 10:49:30.000000000 -0500
382+++ shadow-4.0.18.1/src/useradd.c 2006-11-24 14:25:12.000000000 -0500
383@@ -60,11 +60,11 @@
384 #include "shadowio.h"
385
386 #ifndef SKEL_DIR
387-#define SKEL_DIR "/etc/skel"
388+#define SKEL_DIR SYSCONFDIR"/skel"
389 #endif
390 #ifndef USER_DEFAULTS_FILE
391-#define USER_DEFAULTS_FILE "/etc/default/useradd"
392-#define NEW_USER_FILE "/etc/default/nuaddXXXXXX"
393+#define USER_DEFAULTS_FILE SYSCONFDIR"/default/useradd"
394+#define NEW_USER_FILE SYSCONFDIR"/default/nuaddXXXXXX"
395 #endif
396 /*
397 * Needed for MkLinux DR1/2/2.1 - J.
398diff -Naur shadow-4.0.18.1.orig/src/vipw.c shadow-4.0.18.1/src/vipw.c
399--- shadow-4.0.18.1.orig/src/vipw.c 2006-06-20 16:00:04.000000000 -0400
400+++ shadow-4.0.18.1/src/vipw.c 2006-11-24 14:24:57.000000000 -0500
401@@ -245,7 +245,7 @@
402 textdomain (PACKAGE);
403
404 progname = ((a = strrchr (*argv, '/')) ? a + 1 : *argv);
405- do_vipw = (strcmp (progname, "vigr") != 0);
406+ do_vipw = (strcmp (progname, VIGR) != 0);
407
408 {
409 /*
Note: See TracBrowser for help on using the repository browser.