Make build and run on Interix:

* Add check for sync(2) and setgroups(3), and don't use these if they
  don't exist on the host.

* Interix has a ... Special ... way of doing the "su" thing.

* Implement Interix-specific portion of mountlist.c.
This commit is contained in:
tv 2005-03-21 14:44:08 +00:00
parent 3ebb239623
commit c9a384ec9a
15 changed files with 315 additions and 15 deletions

View file

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.23 2004/12/28 08:55:31 minskim Exp $
# $NetBSD: Makefile,v 1.24 2005/03/21 14:44:08 tv Exp $
DISTNAME= coreutils-5.2.1
PKGREVISION= 1
@ -31,6 +31,13 @@ SUBST_SED.root= -e 's, root , ${ROOT_USER} ,g'
.include "../../mk/bsd.prefs.mk"
# Exclude programs from PLIST which aren't built on a platform.
.if ${OPSYS} == "Interix"
PLIST_SUBST+= COREUTILS_HAVE_HOSTID="@comment "
.else
PLIST_SUBST+= COREUTILS_HAVE_HOSTID=""
.endif
CONFIGURE_ARGS= --program-prefix=${GNU_PROGRAM_PREFIX}
# if GNU_PROGRAM_PREFIX == 'g'
# devel/id-utils installs a 'gid' program, so conflict with it

View file

@ -1,4 +1,4 @@
@comment $NetBSD: PLIST,v 1.4 2004/12/06 16:00:57 adam Exp $
@comment $NetBSD: PLIST,v 1.5 2005/03/21 14:44:08 tv Exp $
bin/${GNU_PROGRAM_PREFIX}[
bin/${GNU_PROGRAM_PREFIX}basename
bin/${GNU_PROGRAM_PREFIX}cat
@ -28,7 +28,7 @@ bin/${GNU_PROGRAM_PREFIX}fmt
bin/${GNU_PROGRAM_PREFIX}fold
bin/${GNU_PROGRAM_PREFIX}groups
bin/${GNU_PROGRAM_PREFIX}head
bin/${GNU_PROGRAM_PREFIX}hostid
${COREUTILS_HAVE_HOSTID}bin/${GNU_PROGRAM_PREFIX}hostid
bin/${GNU_PROGRAM_PREFIX}hostname
bin/${GNU_PROGRAM_PREFIX}id
bin/${GNU_PROGRAM_PREFIX}install

View file

@ -1,8 +1,18 @@
$NetBSD: distinfo,v 1.8 2005/02/24 13:40:51 agc Exp $
$NetBSD: distinfo,v 1.9 2005/03/21 14:44:08 tv Exp $
SHA1 (coreutils-5.2.1.tar.bz2) = 1028755ae0fa9be840576e4837004cf5a9981c45
RMD160 (coreutils-5.2.1.tar.bz2) = a72bdb360371c026e77281ae0d543bdcce55a4e6
Size (coreutils-5.2.1.tar.bz2) = 4270776 bytes
SHA1 (patch-aa) = 36c3a4a810bdc9efd7b0c3a6dc4203e0cfcbfae5
SHA1 (patch-ab) = a38174cf4c85cdddc23f3b59c7c04679c898c232
SHA1 (patch-ac) = e5db45fbb7f4e424fa7ce5474d99f863b4b46bd2
SHA1 (patch-ab) = 2fdd6dcccc20038afbb145d10b2988829702b285
SHA1 (patch-ac) = 982848fe7c82a6601893eed5122de544484b4cf9
SHA1 (patch-ad) = 3b61ead0225d17667d27a6a0e379d5aabc75b0df
SHA1 (patch-ae) = 1dda20cdc03336694b2c8dd42de159168de1f28d
SHA1 (patch-af) = cd7deba7a8ecdf17b39668a9d5a80323e1a02c06
SHA1 (patch-ag) = 20deb326e88b2d0a275b4a16b84ea43a9e280d79
SHA1 (patch-ah) = 3f56cd4e1c657551f4967928ebea19df23c0d850
SHA1 (patch-ai) = e9964ba9e3fd6ec8f2728e53439a960a6dd0a32f
SHA1 (patch-ba) = 3867a17e0ad8f7c87c91ec8e511972a6255062dd
SHA1 (patch-bb) = ade6f8e0aa73478270f568dba25e79f825374c02
SHA1 (patch-ca) = 414af007d0afe03a0e95f1f26f9e8fdff10702e4
SHA1 (patch-cb) = de1896d77504b8fd82da8e2cdf6b8a82a31ba09f

View file

@ -1,8 +1,8 @@
$NetBSD: patch-ab,v 1.5 2004/05/18 19:07:57 tron Exp $
$NetBSD: patch-ab,v 1.6 2005/03/21 14:44:08 tv Exp $
--- lib/mountlist.c.orig 2004-01-26 09:58:12.000000000 +0100
+++ lib/mountlist.c 2004-05-18 20:56:57.000000000 +0200
@@ -173,6 +173,11 @@
--- lib/mountlist.c.orig Mon Jan 26 03:58:12 2004
+++ lib/mountlist.c
@@ -173,6 +173,11 @@ xatoi (char *cp)
#if MOUNTED_GETMNTINFO
@ -14,3 +14,66 @@ $NetBSD: patch-ab,v 1.5 2004/05/18 19:07:57 tron Exp $
# if ! HAVE_F_FSTYPENAME_IN_STATFS
static char *
fstype_to_string (short t)
@@ -296,6 +301,11 @@ fstype_to_string (int t)
}
#endif /* MOUNTED_VMOUNT */
+#ifdef __INTERIX
+# include <dirent.h>
+# include <sys/statvfs.h>
+#endif
+
/* Return a list of the currently mounted filesystems, or NULL on error.
Add each entry to the tail of the list so that they stay in order.
If NEED_FS_TYPE is nonzero, ensure that the filesystem type fields in
@@ -804,6 +814,50 @@ read_filesystem_list (int need_fs_type)
free (entries);
}
#endif /* MOUNTED_VMOUNT. */
+
+#ifdef __INTERIX /* Interix. */
+ {
+ DIR *devfs = opendir ("/dev/fs");
+ struct dirent *de;
+ struct statvfs svfs;
+ char fsname[] = "/dev/fs/#"; /* writable */
+
+ if (devfs == NULL)
+ return NULL;
+
+ while ((de = readdir (devfs)) != NULL)
+ {
+ if (strlen (de->d_name) != 1)
+ {
+ /* "Drive letters" should all be exactly one character long. */
+ continue;
+ }
+
+ fsname[8] = de->d_name[0];
+
+ if (statvfs (fsname, &svfs) != 0)
+ {
+ /* Could be an offline network fs or empty removable; don't fail. */
+ continue;
+ }
+
+ me = xmalloc (sizeof *me);
+
+ me->me_devname = xstrdup (svfs.f_mntfromname);
+ me->me_mountdir = xstrdup (svfs.f_mntonname);
+ me->me_type = xstrdup (svfs.f_fstypename);
+ me->me_dev = (dev_t)svfs.f_fsid;
+ me->me_dummy = (svfs.f_type == ST_FSTYPE_OFS ? 1 : 0);
+ me->me_remote = ((svfs.f_type == ST_FSTYPE_SAMBA
+ || svfs.f_type == ST_FSTYPE_NFS) ? 1 : 0);
+ me->me_type_malloced = 1;
+
+ /* Add to the linked list. */
+ *mtail = me;
+ mtail = &me->me_next;
+ }
+ }
+#endif
*mtail = NULL;
return mount_list;

View file

@ -1,12 +1,13 @@
$NetBSD: patch-ac,v 1.4 2004/05/18 19:07:58 tron Exp $
$NetBSD: patch-ac,v 1.5 2005/03/21 14:44:08 tv Exp $
--- src/stat.c.orig 2004-02-05 14:46:12.000000000 +0100
+++ src/stat.c 2004-05-18 21:02:54.000000000 +0200
@@ -86,6 +86,11 @@
--- src/stat.c.orig Thu Feb 5 08:46:12 2004
+++ src/stat.c
@@ -86,6 +86,12 @@
# endif
#endif
+#if defined(__NetBSD__) && (__NetBSD_Version__ > 200030000)
+#if (defined(__NetBSD__) && (__NetBSD_Version__ > 200030000)) || defined(__INTERIX)
+#include <sys/statvfs.h>
+#define statfs statvfs
+#define STATXFS_FILE_SYSTEM_TYPE_MEMBER_NAME f_fstypename
+#endif

View file

@ -0,0 +1,49 @@
$NetBSD: patch-ad,v 1.1 2005/03/21 14:44:08 tv Exp $
--- src/su.c.orig Wed Jan 21 17:27:02 2004
+++ src/su.c
@@ -141,6 +141,12 @@
/* The user to become if none is specified. */
#define DEFAULT_USER "root"
+#ifdef __INTERIX
+# include <interix/security.h>
+# undef DEFAULT_USER
+# define DEFAULT_USER (strdup(getpwuid(197108)->pw_name))
+#endif
+
char *crypt ();
char *getpass ();
char *getusershell ();
@@ -291,9 +297,13 @@ correct_password (const struct passwd *p
error (0, 0, _("getpass: cannot open /dev/tty"));
return 0;
}
+#ifdef __INTERIX
+ return setuser (pw->pw_name, unencrypted, SU_CHECK) == 0;
+#else
encrypted = crypt (unencrypted, correct);
memset (unencrypted, 0, strlen (unencrypted));
return strcmp (encrypted, correct) == 0;
+#endif
}
/* Update `environ' for the new shell based on PW, with SHELL being
@@ -343,6 +353,9 @@ modify_environment (const struct passwd
static void
change_identity (const struct passwd *pw)
{
+#ifdef __INTERIX
+ setuser (pw->pw_name, NULL, SU_COMPLETE);
+#else
#ifdef HAVE_INITGROUPS
errno = 0;
if (initgroups (pw->pw_name, pw->pw_gid) == -1)
@@ -353,6 +366,7 @@ change_identity (const struct passwd *pw
error (EXIT_FAIL, errno, _("cannot set group id"));
if (setuid (pw->pw_uid))
error (EXIT_FAIL, errno, _("cannot set user id"));
+#endif
}
/* Run SHELL, or DEFAULT_SHELL if SHELL is empty.

View file

@ -0,0 +1,15 @@
$NetBSD: patch-ae,v 1.1 2005/03/21 14:44:08 tv Exp $
--- src/setuidgid.c.orig Wed Jan 21 17:27:02 2004
+++ src/setuidgid.c
@@ -106,8 +106,10 @@ main (int argc, char **argv)
error (SETUIDGID_FAILURE, errno,
_("unknown user-ID: %s"), quote (user_id));
+#if HAVE_SETGROUPS
if (setgroups (1, &pwd->pw_gid))
error (SETUIDGID_FAILURE, errno, _("cannot set supplemental group"));
+#endif
if (setgid (pwd->pw_gid))
error (SETUIDGID_FAILURE, errno,

View file

@ -0,0 +1,15 @@
$NetBSD: patch-af,v 1.1 2005/03/21 14:44:08 tv Exp $
--- src/system.h.orig Thu Feb 5 04:23:23 2004
+++ src/system.h
@@ -92,6 +92,10 @@ you must include <sys/types.h> before in
#endif
#undef HAVE_MAJOR
+#if !defined(makedev) && defined(mkdev)
+# define makedev(a, b) (mkdev((a), (b)))
+#endif
+
#if HAVE_UTIME_H
# include <utime.h>
#endif

View file

@ -0,0 +1,28 @@
$NetBSD: patch-ag,v 1.1 2005/03/21 14:44:08 tv Exp $
--- src/shred.c.orig Wed Jan 21 17:27:02 2004
+++ src/shred.c
@@ -1398,7 +1398,11 @@ wipename (char *oldname, char const *qol
{
if (dir_fd < 0
|| (fdatasync (dir_fd) < 0 && fsync (dir_fd) < 0))
+#if HAVE_SYNC
sync (); /* Force directory out */
+#else
+ ; /* No sync(2) call */
+#endif
if (flags->verbose)
{
/*
@@ -1431,7 +1435,11 @@ wipename (char *oldname, char const *qol
free (newname);
err = unlink (oldname);
if (dir_fd < 0 || (fdatasync (dir_fd) < 0 && fsync (dir_fd) < 0))
+#if HAVE_SYNC
sync ();
+#else
+ ; /* No sync(2) call */
+#endif
close (dir_fd);
if (!err && flags->verbose)
error (0, 0, _("%s: removed"), qoldname);

View file

@ -0,0 +1,15 @@
$NetBSD: patch-ah,v 1.1 2005/03/21 14:44:08 tv Exp $
--- src/df.c.orig Tue Jan 27 10:55:38 2004
+++ src/df.c
@@ -923,8 +923,10 @@ main (int argc, char **argv)
_("%scannot read table of mounted filesystems"), warning);
}
+#if HAVE_SYNC
if (require_sync)
sync ();
+#endif
if (optind < argc)
{

View file

@ -0,0 +1,13 @@
$NetBSD: patch-ai,v 1.1 2005/03/21 14:44:08 tv Exp $
--- src/sync.c.orig Wed Jan 21 17:27:02 2004
+++ src/sync.c
@@ -70,6 +70,8 @@ main (int argc, char **argv)
if (1 < argc)
error (0, 0, _("ignoring all arguments"));
+#if HAVE_SYNC
sync ();
+#endif
exit (EXIT_SUCCESS);
}

View file

@ -0,0 +1,15 @@
$NetBSD: patch-ba,v 1.1 2005/03/21 14:44:08 tv Exp $
--- m4/ls-mntd-fs.m4.orig Mon Jan 26 04:18:10 2004
+++ m4/ls-mntd-fs.m4
@@ -271,6 +271,10 @@ if test -z "$ac_list_mounted_fs"; then
fi
fi
+case $host in
+*-interix3*) ac_list_mounted_fs=found;;
+esac
+
if test -z "$ac_list_mounted_fs"; then
AC_MSG_ERROR([could not determine how to read list of mounted filesystems])
# FIXME -- no need to abort building the whole package

View file

@ -0,0 +1,17 @@
$NetBSD: patch-bb,v 1.1 2005/03/21 14:44:08 tv Exp $
--- m4/jm-macros.m4.orig Sat Dec 20 12:57:18 2003
+++ m4/jm-macros.m4
@@ -94,10 +94,12 @@ AC_DEFUN([jm_MACROS],
mempcpy \
mkfifo \
realpath \
+ setgroups \
sethostname \
strchr \
strerror \
strrchr \
+ sync \
sysctl \
sysinfo \
wcrtomb \

View file

@ -0,0 +1,28 @@
$NetBSD: patch-ca,v 1.1 2005/03/21 14:44:08 tv Exp $
--- configure.orig Thu Mar 11 03:58:11 2004
+++ configure
@@ -27323,6 +27323,10 @@ _ACEOF
fi
fi
+case $host in
+*-interix3*) ac_list_mounted_fs=found;;
+esac
+
if test -z "$ac_list_mounted_fs"; then
{ { echo "$as_me:$LINENO: error: could not determine how to read list of mounted filesystems" >&5
echo "$as_me: error: could not determine how to read list of mounted filesystems" >&2;}
@@ -44983,10 +44987,12 @@ for ac_func in \
mempcpy \
mkfifo \
realpath \
+ setgroups \
sethostname \
strchr \
strerror \
strrchr \
+ sync \
sysctl \
sysinfo \
wcrtomb \

View file

@ -0,0 +1,24 @@
$NetBSD: patch-cb,v 1.1 2005/03/21 14:44:08 tv Exp $
--- config.hin.orig Thu Mar 11 03:59:16 2004
+++ config.hin
@@ -669,6 +669,9 @@
/* Define to 1 if you have run the test for working tzset. */
#undef HAVE_RUN_TZSET_TEST
+/* Define to 1 if you have the `setgroups' function. */
+#undef HAVE_SETGROUPS
+
/* Define to 1 if you have the `sethostname' function. */
#undef HAVE_SETHOSTNAME
@@ -920,6 +923,9 @@
/* Define if struct stat has an st_dm_mode member. */
#undef HAVE_ST_DM_MODE
+
+/* Define to 1 if you have the `sync' function. */
+#undef HAVE_SYNC
/* Define to 1 if you have the `sysctl' function. */
#undef HAVE_SYSCTL