[Pkg-shadow-devel] shadow-4.1.2.1 and uclibc

Tobias Poschwatta tp at fonz.de
Mon Aug 25 11:24:37 UTC 2008


Hello,

the current shadow package doesn't compile on uclibc. I haven't found
a patch that addresses the issues, so I tried fixing them myself. A
patch is attached.

- struct stat.st_atim

  Test for _BSD_SOURCE and _SVID_SOURCE in copydir.c didn't work,
  so I added an explicit test for st_atim to configure.in.

  I also found that mail.c uses st_atime. It's not guarded with a
  test, though.

- futimes, lutimes
  uclibc doesn't seem to have these functions. I think futimes
  can be replaced with utimes in copydir.c

- nscd
  not present, I added --with-nscd (default: yes).

- posix_spawn
  not present, but no problem when using --without-nscd.

- uid_t, gid_t
  require <sys/types.h> in pwio.h and groupio.h

Thanks,

Tobias
-------------- next part --------------
diff -ur shadow-4.1.2.1.orig/configure.in shadow-4.1.2.1/configure.in
--- shadow-4.1.2.1.orig/configure.in	2008-06-24 01:53:43.000000000 +0200
+++ shadow-4.1.2.1/configure.in	2008-08-25 12:52:40.000000000 +0200
@@ -37,9 +37,9 @@
 dnl shadow now uses the libc's shadow implementation
 AC_CHECK_HEADER([shadow.h],,[AC_MSG_ERROR([You need a libc with shadow.h])])
 
-AC_CHECK_FUNCS(l64a fchmod fchown fsync getgroups gethostname getspnam \
+AC_CHECK_FUNCS(l64a fchmod fchown fsync futimes getgroups gethostname getspnam \
 	gettimeofday getusershell getutent initgroups lchown lckpwdf lstat \
-	memcpy memset setgroups sigaction strchr updwtmp updwtmpx innetgr \
+	lutimes memcpy memset setgroups sigaction strchr updwtmp updwtmpx innetgr \
 	getpwnam_r getpwuid_r getgrnam_r getgrgid_r getspnam_r)
 AC_SYS_LARGEFILE
 
@@ -51,6 +51,7 @@
 AC_TYPE_MODE_T
 AC_HEADER_STAT
 AC_CHECK_MEMBERS([struct stat.st_rdev])
+AC_CHECK_MEMBERS([struct stat.st_atim])
 AC_HEADER_TIME
 AC_STRUCT_TM
 
@@ -234,12 +235,20 @@
 AC_ARG_WITH(sha-crypt,
 	[AC_HELP_STRING([--with-sha-crypt], [allow the SHA256 and SHA512 password encryption algorithms @<:@default=yes@:>@])],
 	[with_sha_crypt=$withval], [with_sha_crypt=yes])
+AC_ARG_WITH(nscd,
+	[AC_HELP_STRING([--with-nscd], [enable support for nscd @<:@default=yes@:>@])],
+	[with_nscd=$withval], [with_nscd=yes])
 
 AM_CONDITIONAL(USE_SHA_CRYPT, test "x$with_sha_crypt" = "xyes")
 if test "$with_sha_crypt" = "yes"; then
 		AC_DEFINE(USE_SHA_CRYPT, 1, [Define to allow the SHA256 and SHA512 password encryption algorithms])
 fi
 
+AM_CONDITIONAL(USE_NSCD, test "x$with_nscd" = "xyes")
+if test "$with_nscd" = "yes"; then
+	AC_DEFINE(USE_NSCD, 1, [Define to support flushing of nscd caches])
+fi
+
 dnl Check for some functions in libc first, only if not found check for
 dnl other libraries.  This should prevent linking libnsl if not really
 dnl needed (Linux glibc, Irix), but still link it if needed (Solaris).
@@ -427,4 +436,5 @@
 echo "	shadow group support:		$enable_shadowgrp"
 echo "	S/Key support:			$with_skey"
 echo "	SHA passwords encryption:	$with_sha_crypt"
+echo "	nscd support:                   $with_nscd"
 echo
diff -ur shadow-4.1.2.1.orig/lib/groupio.h shadow-4.1.2.1/lib/groupio.h
--- shadow-4.1.2.1.orig/lib/groupio.h	2008-06-24 01:53:13.000000000 +0200
+++ shadow-4.1.2.1/lib/groupio.h	2008-08-25 12:49:17.000000000 +0200
@@ -31,6 +31,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <sys/types.h>
 #include <grp.h>
 extern int gr_close (void);
 extern const struct group *gr_locate (const char *);
diff -ur shadow-4.1.2.1.orig/lib/nscd.c shadow-4.1.2.1/lib/nscd.c
--- shadow-4.1.2.1.orig/lib/nscd.c	2008-06-24 01:53:13.000000000 +0200
+++ shadow-4.1.2.1/lib/nscd.c	2008-08-25 12:59:24.000000000 +0200
@@ -1,3 +1,6 @@
+#include <config.h>
+#ifdef USE_NSCD
+
 /* Author: Peter Vrabec <pvrabec at redhat.com> */
 
 /* because of TEMP_FAILURE_RETRY */
@@ -47,4 +50,5 @@
 
 	return 0;
 }
+#endif
 
diff -ur shadow-4.1.2.1.orig/lib/nscd.h shadow-4.1.2.1/lib/nscd.h
--- shadow-4.1.2.1.orig/lib/nscd.h	2008-06-24 01:53:13.000000000 +0200
+++ shadow-4.1.2.1/lib/nscd.h	2008-08-25 12:59:33.000000000 +0200
@@ -4,6 +4,10 @@
 /*
  * nscd_flush_cache - flush specified service buffer in nscd cache
  */
+#ifdef USE_NSCD
 extern int nscd_flush_cache (const char *service);
+#else
+#define nscd_flush_cache(service) (0)
+#endif
 
 #endif
diff -ur shadow-4.1.2.1.orig/lib/pwio.h shadow-4.1.2.1/lib/pwio.h
--- shadow-4.1.2.1.orig/lib/pwio.h	2008-06-24 01:53:13.000000000 +0200
+++ shadow-4.1.2.1/lib/pwio.h	2008-08-25 12:49:17.000000000 +0200
@@ -31,6 +31,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <sys/types.h>
 #include <pwd.h>
 extern int pw_close (void);
 extern const struct passwd *pw_locate (const char *);
diff -ur shadow-4.1.2.1.orig/libmisc/copydir.c shadow-4.1.2.1/libmisc/copydir.c
--- shadow-4.1.2.1.orig/libmisc/copydir.c	2008-06-24 01:53:06.000000000 +0200
+++ shadow-4.1.2.1/libmisc/copydir.c	2008-08-25 12:49:17.000000000 +0200
@@ -285,7 +285,7 @@
 	if (LSTAT (src, &sb) == -1) {
 		/* If we cannot stat the file, do not care. */
 	} else {
-#if  defined(_BSD_SOURCE) || defined(_SVID_SOURCE)
+#ifdef HAVE_STRUCT_STAT_ST_ATIM
 		mt[0].tv_sec  = sb.st_atim.tv_sec;
 		mt[0].tv_usec = sb.st_atim.tv_nsec / 1000;
 		mt[1].tv_sec  = sb.st_mtim.tv_sec;
@@ -428,12 +428,14 @@
 		return -1;
 	}
 
+#ifdef HAVE_LUTIMES
 	/* 2007-10-18: We don't care about
 	 *  exit status of lutimes because
 	 *  it returns ENOSYS on many system
 	 *  - not implemented
 	 */
 	lutimes (dst, mt);
+#endif
 
 	return err;
 }
@@ -545,9 +547,15 @@
 
 	(void) close (ifd);
 
+#ifdef HAVE_FUTIMES
 	if (futimes (ofd, mt) != 0) {
 		return -1;
 	}
+#else
+	if (utimes(dst, mt) != 0) {
+		return -1;
+	}
+#endif
 
 	if (close (ofd) != 0) {
 		return -1;


More information about the Pkg-shadow-devel mailing list