Subject: Re: While we're talking about binary emulation (FreeBSD)
To: David Maxwell <david@fundy.ca>
From: Todd Vierling <tv@pobox.com>
List: port-i386
Date: 09/30/1998 09:41:50
On Wed, 30 Sep 1998, David Maxwell wrote:

: Okay, further along now... on 3.0 FreeBSD libs, the bin dies, trying
: syscall [253].

Hrm.  That's issetugid().  `It's implemented in -current....'

: No big loss - The 2.x libs get past that part. In fact,
: I can now get the server configured and 'running'. However, as soon
: as I connect from a client, the client gets Ccbfh, and the server
: goes like this...
: 
: /usr/libexec/ld.so: Undefined symbol "___inet_ntoa" called from typhoond:typhoond at 0x810fc

This is definitely a problem; this means __inet_ntoa() is not in the 2.x
libs, preventing you from running the server on those libs.  So looks like
you'll have to (1) find out if there are newer 2.x libs they actually linked
against, or (2) try to use 3.0 libs after the following diff has been
applied to src/sys/compat/freebsd (which backports the issetugid() changes).

Note that I have submitted requests to get the issetugid() syscall and the
madvise() change into 1.3.3.

--- freebsd_misc.c	1997/10/20 22:05:23	1.3
+++ freebsd_misc.c	1998/05/02 18:14:06	1.4
@@ -103,4 +103,22 @@
 #endif
 
 	return ENOSYS;	/* XXX */
+}
+
+int
+freebsd_sys_issetugid(p, v, retval)
+	struct proc *p;
+	void *v;
+	register_t *retval;
+{
+	/*
+	 * Note: OpenBSD sets a P_SUGIDEXEC flag set at execve() time,
+	 * we use P_SUGID because we consider changing the owners as
+	 * "tainting" as well.
+	 * This is significant for procs that start as root and "become"
+	 * a user without an exec - programs cannot know *everything*
+	 * that libc *might* have put in their data segment.
+	 */
+	*retval = (p->p_flag & P_SUGID) != 0;
+	return 0;
 }
--- freebsd_syscall.h	1998/02/19 03:34:15	1.21
+++ freebsd_syscall.h	1998/05/02 18:14:56	1.22
@@ -552,6 +552,9 @@
 
 /* syscall: "undelete" ret: "int" args: "char *" */
 #define	FREEBSD_SYS_undelete	205
+
+/* syscall: "issetugid" ret: "int" args: */
+#define	FREEBSD_SYS_issetugid	253
 
 /* syscall: "lchown" ret: "int" args: "char *" "int" "int" */
 #define	FREEBSD_SYS_lchown	254
--- freebsd_syscallargs.h	1998/02/19 03:34:16	1.20
+++ freebsd_syscallargs.h	1998/05/02 18:14:56	1.21
@@ -439,4 +439,5 @@
 int	freebsd_sys_undelete	__P((struct proc *, void *, register_t *));
 #else
 #endif
+int	freebsd_sys_issetugid	__P((struct proc *, void *, register_t *));
 int	freebsd_sys_lchown	__P((struct proc *, void *, register_t *));
--- freebsd_syscalls.c	1998/02/19 03:34:16	1.20
+++ freebsd_syscalls.c	1998/05/02 18:14:56	1.21
@@ -312,6 +312,6 @@
 	"#250 (unimplemented)",		/* 250 = unimplemented */
 	"#251 (unimplemented)",		/* 251 = unimplemented */
 	"#252 (unimplemented)",		/* 252 = unimplemented */
-	"#253 (unimplemented)",		/* 253 = unimplemented */
+	"issetugid",			/* 253 = issetugid */
 	"lchown",			/* 254 = lchown */
 };
--- freebsd_sysent.c	1998/02/19 03:34:16	1.22
+++ freebsd_sysent.c	1998/05/02 18:14:57	1.23
@@ -578,7 +578,7 @@
 	{ 0, 0,
 	    sys_nosys },			/* 252 = unimplemented */
 	{ 0, 0,
-	    sys_nosys },			/* 253 = unimplemented */
+	    freebsd_sys_issetugid },		/* 253 = issetugid */
 	{ 3, s(struct freebsd_sys_lchown_args),
 	    freebsd_sys_lchown },		/* 254 = lchown */
 };
--- syscalls.master	1998/02/19 00:36:04	1.15
+++ syscalls.master	1998/05/02 18:14:06	1.16
@@ -439,6 +439,6 @@
 250	UNIMPL
 251	UNIMPL
 252	UNIMPL
-253	UNIMPL
+253	STD		{ int freebsd_sys_issetugid(void); }
 254	STD		{ int freebsd_sys_lchown(char *path, int uid, \
 			    int gid); }

-- 
-- Todd Vierling (Personal tv@pobox.com; Bus. todd_vierling@xn.xerox.com)