summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--manifest9
-rw-r--r--usr/src/lib/brand/lx/Makefile4
-rw-r--r--usr/src/lib/brand/lx/cmd/Makefile4
-rw-r--r--usr/src/lib/brand/lx/cmd/lx_isaexec_wrapper.sh59
-rw-r--r--usr/src/lib/brand/lx/cmd/lx_lockd.sh36
-rw-r--r--usr/src/lib/brand/lx/cmd/lx_statd.sh36
-rw-r--r--usr/src/lib/brand/lx/cmd/lx_thunk.sh29
-rw-r--r--usr/src/lib/brand/lx/lx_brand/Makefile.com1
-rw-r--r--usr/src/lib/brand/lx/lx_brand/common/lx_brand.c4
-rw-r--r--usr/src/lib/brand/lx/lx_brand/common/lx_thunk_server.c1023
-rw-r--r--usr/src/lib/brand/lx/lx_brand/common/misc.c6
-rw-r--r--usr/src/lib/brand/lx/lx_brand/sys/lx_thunk_server.h140
-rw-r--r--usr/src/lib/brand/lx/lx_nametoaddr/Makefile52
-rw-r--r--usr/src/lib/brand/lx/lx_nametoaddr/Makefile.com68
-rw-r--r--usr/src/lib/brand/lx/lx_nametoaddr/amd64/Makefile35
-rw-r--r--usr/src/lib/brand/lx/lx_nametoaddr/common/lx_nametoaddr.c479
-rw-r--r--usr/src/lib/brand/lx/lx_nametoaddr/common/mapfile-vers51
-rw-r--r--usr/src/lib/brand/lx/lx_nametoaddr/i386/Makefile34
-rw-r--r--usr/src/lib/brand/lx/lx_thunk/Makefile52
-rw-r--r--usr/src/lib/brand/lx/lx_thunk/Makefile.com74
-rw-r--r--usr/src/lib/brand/lx/lx_thunk/amd64/Makefile34
-rw-r--r--usr/src/lib/brand/lx/lx_thunk/common/lx_thunk.c1115
-rw-r--r--usr/src/lib/brand/lx/lx_thunk/common/mapfile-vers57
-rw-r--r--usr/src/lib/brand/lx/lx_thunk/i386/Makefile33
-rw-r--r--usr/src/lib/brand/lx/lx_thunk/sys/lx_thunk.h56
-rw-r--r--usr/src/lib/brand/lx/netfiles/Makefile5
-rw-r--r--usr/src/lib/brand/lx/netfiles/etc_netconfig38
-rw-r--r--usr/src/pkg/manifests/system-zones-brand-lx.mf8
28 files changed, 8 insertions, 3534 deletions
diff --git a/manifest b/manifest
index 887acdf549..f34f21658c 100644
--- a/manifest
+++ b/manifest
@@ -5040,15 +5040,12 @@ d usr/lib/brand/lx 0755 root bin
s usr/lib/brand/lx/64=amd64
d usr/lib/brand/lx/amd64 0755 root bin
f usr/lib/brand/lx/amd64/lx_librtld_db.so.1 0755 root root
-f usr/lib/brand/lx/amd64/lx_nametoaddr.so.1 0755 root root
-f usr/lib/brand/lx/amd64/lx_thunk.so.1 0755 root root
f usr/lib/brand/lx/amd64/lx_vdso.so.1 0755 root root
d usr/lib/brand/lx/ld 0755 root root
f usr/lib/brand/lx/ld/ld.config 0755 root root
d usr/lib/brand/lx/ld/64 0755 root root
f usr/lib/brand/lx/ld/64/ld.config 0755 root root
f usr/lib/brand/lx/etc_default_nfs 0444 root root
-f usr/lib/brand/lx/etc_netconfig 0444 root root
f usr/lib/brand/lx/ltp_skiplist 0444 root root
f usr/lib/brand/lx/ltp_tests 0444 root root
f usr/lib/brand/lx/lx_boot 0755 root root
@@ -5057,15 +5054,9 @@ f usr/lib/brand/lx/lx_boot_zone_redhat 0755 root root
f usr/lib/brand/lx/lx_boot_zone_busybox 0755 root root
f usr/lib/brand/lx/lx_boot_zone_ubuntu 0755 root root
f usr/lib/brand/lx/lxinit 0755 root root
-f usr/lib/brand/lx/lx_isaexec_wrapper 0755 root root
f usr/lib/brand/lx/lx_librtld_db.so.1 0755 root root
-f usr/lib/brand/lx/lx_lockd 0755 root root
-f usr/lib/brand/lx/lx_nametoaddr.so.1 0755 root root
f usr/lib/brand/lx/lx_native 0755 root root
-f usr/lib/brand/lx/lx_statd 0755 root root
f usr/lib/brand/lx/lx_support 0755 root root
-f usr/lib/brand/lx/lx_thunk 0755 root root
-f usr/lib/brand/lx/lx_thunk.so.1 0755 root root
f usr/lib/brand/lx/platform.xml 0444 root root
d usr/lib/brand/shared 0755 root sys
f usr/lib/brand/shared/common.ksh 0444 root bin
diff --git a/usr/src/lib/brand/lx/Makefile b/usr/src/lib/brand/lx/Makefile
index b80fb4b91d..2c5a373e25 100644
--- a/usr/src/lib/brand/lx/Makefile
+++ b/usr/src/lib/brand/lx/Makefile
@@ -32,8 +32,8 @@ include Makefile.lx
# Build everything in parallel; use .WAIT for dependencies
.PARALLEL:
-SUBDIRS= cmd librtld_db lx_support lx_init lx_brand lx_thunk netfiles \
- zone lx_vdso testing .WAIT lx_nametoaddr
+SUBDIRS= cmd librtld_db lx_support lx_init lx_brand netfiles \
+ zone lx_vdso testing .WAIT
MSGSUBDIRS= lx_brand lx_support zone
all := TARGET= all
diff --git a/usr/src/lib/brand/lx/cmd/Makefile b/usr/src/lib/brand/lx/cmd/Makefile
index c302f9ebe3..3d9c4009b3 100644
--- a/usr/src/lib/brand/lx/cmd/Makefile
+++ b/usr/src/lib/brand/lx/cmd/Makefile
@@ -22,10 +22,10 @@
#
# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
-# Copyright 2014 Joyent, Inc. All rights reserved.
+# Copyright 2015 Joyent, Inc.
#
-PROGS = lx_lockd lx_native lx_isaexec_wrapper lx_statd lx_thunk
+PROGS = lx_native
include ../Makefile.lx
diff --git a/usr/src/lib/brand/lx/cmd/lx_isaexec_wrapper.sh b/usr/src/lib/brand/lx/cmd/lx_isaexec_wrapper.sh
deleted file mode 100644
index 618570011c..0000000000
--- a/usr/src/lib/brand/lx/cmd/lx_isaexec_wrapper.sh
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/bin/sh
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
-# Copyright 2014, Joyent, Inc. All rights reserved.
-#
-
-#
-# All native executables must be run using the native linker. By default, the
-# kernel loads the linker at /lib/ld.so.1, which in an lx zone is the gcc
-# linker. Hence when we run the native executable below, we explicitly specify
-# /native/lib/ld.so.1 as our 32-bit linker and /native/lib/64/ld.so.1 as our
-# 64-bit linker. For convience we define "n" to be the native path prefix. The
-# initial lx_native argument is used as a way to tell the brand emulation that
-# it needs to set up the process to run as an unbranded process.
-#
-# If this script gets setup with a mode that makes it suid, then things won't
-# work because the script will be running with the incorrect name.
-#
-# XXX For now, we only do 32-bit
-#
-
-n=/native
-
-bname=`/usr/bin/basename $0`
-dname=`/usr/bin/dirname $0`
-echo $dname | grep "^/" >/dev/null || dname=`/bin/pwd`/$dname
-dname=`(cd $dname 2>/dev/null && /bin/pwd 2>/dev/null)`
-
-if [ ! -f $n$dname/$bname ]; then
- echo "Error: \"$dname/$bname\" is not installed in the global zone"
- exit 1
-fi
-
-exec $n/usr/lib/brand/lx/lx_native \
- $n/lib/ld.so.1 \
- -e LD_NOENVIRON=1 \
- -e LD_NOCONFIG=1 \
- -e LD_PRELOAD_32=$n/usr/lib/brand/lx/lx_thunk.so.1 \
- -e LD_LIBRARY_PATH_32="$n/lib:$n/usr/lib" \
- $n$dname/$bname "$@"
diff --git a/usr/src/lib/brand/lx/cmd/lx_lockd.sh b/usr/src/lib/brand/lx/cmd/lx_lockd.sh
deleted file mode 100644
index cb60d19749..0000000000
--- a/usr/src/lib/brand/lx/cmd/lx_lockd.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/bin/sh
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-
-#
-# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# ident "%Z%%M% %I% %E% SMI"
-#
-
-LD_LIBRARY_PATH=/usr/lib/brand/lx
-LD_PRELOAD=/native/usr/lib/brand/lx/lx_thunk.so.1
-LD_BIND_NOW=1
-export LD_LIBRARY_PATH LD_PRELOAD LD_BIND_NOW
-
-exec /native/usr/lib/brand/lx/lx_native \
- /native/usr/lib/nfs/lockd -P -U 29 -G 29
diff --git a/usr/src/lib/brand/lx/cmd/lx_statd.sh b/usr/src/lib/brand/lx/cmd/lx_statd.sh
deleted file mode 100644
index 998fd90af2..0000000000
--- a/usr/src/lib/brand/lx/cmd/lx_statd.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/bin/sh
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-
-#
-# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# ident "%Z%%M% %I% %E% SMI"
-#
-
-LD_LIBRARY_PATH=/usr/lib/brand/lx
-LD_PRELOAD=/native/usr/lib/brand/lx/lx_thunk.so.1
-LD_BIND_NOW=1
-export LD_LIBRARY_PATH LD_PRELOAD LD_BIND_NOW
-
-exec /native/usr/lib/brand/lx/lx_native \
- /native/usr/lib/nfs/statd -P -U 29 -G 29
diff --git a/usr/src/lib/brand/lx/cmd/lx_thunk.sh b/usr/src/lib/brand/lx/cmd/lx_thunk.sh
deleted file mode 100644
index 4e1e6cbc03..0000000000
--- a/usr/src/lib/brand/lx/cmd/lx_thunk.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/sh
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-
-#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# ident "%Z%%M% %I% %E% SMI"
-#
-exec /native/usr/lib/brand/lx/lx_thunk
diff --git a/usr/src/lib/brand/lx/lx_brand/Makefile.com b/usr/src/lib/brand/lx/lx_brand/Makefile.com
index b18dd35eeb..b75657dbe9 100644
--- a/usr/src/lib/brand/lx/lx_brand/Makefile.com
+++ b/usr/src/lib/brand/lx/lx_brand/Makefile.com
@@ -40,7 +40,6 @@ COBJS = aio.o \
id.o \
iovec.o \
lx_brand.o \
- lx_thunk_server.o \
mem.o \
misc.o \
module.o \
diff --git a/usr/src/lib/brand/lx/lx_brand/common/lx_brand.c b/usr/src/lib/brand/lx/lx_brand/common/lx_brand.c
index 9109cd443a..e7083bec87 100644
--- a/usr/src/lib/brand/lx/lx_brand/common/lx_brand.c
+++ b/usr/src/lib/brand/lx/lx_brand/common/lx_brand.c
@@ -73,7 +73,6 @@
#include <sys/lx_signal.h>
#include <sys/lx_syscall.h>
#include <sys/lx_thread.h>
-#include <sys/lx_thunk_server.h>
#include <sys/lx_aio.h>
/*
@@ -689,9 +688,6 @@ lx_init(int argc, char *argv[], char *envp[])
}
}
- /* Do any thunk server initalization. */
- lxt_server_init(argc, argv);
-
/* Setup signal handler information. */
if (lx_siginit()) {
lx_err_fatal("failed to initialize lx signals for the "
diff --git a/usr/src/lib/brand/lx/lx_brand/common/lx_thunk_server.c b/usr/src/lib/brand/lx/lx_brand/common/lx_thunk_server.c
deleted file mode 100644
index 08e77572ab..0000000000
--- a/usr/src/lib/brand/lx/lx_brand/common/lx_thunk_server.c
+++ /dev/null
@@ -1,1023 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-
-/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- * Copyright 2015 Joyent, Inc.
- */
-
-/*
- * The BrandZ Linux thunking server.
- *
- * The interfaces defined in this file form the server side of a bridge
- * to allow native solaris process to access Linux services. Currently
- * the Linux services that is made accessible by these interfaces here
- * are:
- * - Linux host <-> address naming services
- * - Linux service <-> port naming services
- * - Linux syslog
- *
- * Access to all these services is provided through a doors server.
- * Currently the only client of these interfaces and the process that
- * initially starts up the doors server is lx_thunk.so.
- *
- * lx_thunk.so is a native solaris library that is loaded into native
- * solaris process that need to run inside a Linux zone and have access
- * to Linux services. When lx_thunk.so receives a request that requires
- * accessing Linux services it creates a "thunk server" process by
- * forking and executing the following shell script (which runs as
- * a branded /bin/sh Linux process):
- * /native/usr/lib/brand/lx/lx_thunk
- *
- * The first and only thing this shell script attempts to do is re-exec
- * itself. The brand library will detect when this script attempts to
- * re-exec itself and take control of the process. The exec() system
- * call made by the Linux shell will never return.
- *
- * At this point the process becomes a "thunk server" process.
- * The first thing it does is a bunch of initialization:
- *
- * - Sanity check that a file descriptor based communication mechanism
- * needed talk to the parent process is correctly initialized.
- *
- * - Verify that two predetermined file descriptors are FIFOs.
- * These FIFOs will be used to establish communications with
- * the client program that spawned us and which will be sending
- * us requests.
- *
- * - Use existing debugging libraries (libproc.so, librtld_db.so,
- * and the BrandZ lx plug-in to librtld_db.so) and /native/proc to
- * walk the Linux link maps in our own address space to determine
- * the address of the Linux dlsym() function.
- *
- * - Use the native Linux dlsym() function to look up other symbols
- * (for both functions and variables) that we will need access
- * to service thunking requests.
- *
- * - Create a doors server and notify the parent process that we
- * are ready to service requests.
- *
- * - Enter a service loop and wait for requests.
- *
- * At this point the lx_thunk process is ready to service door
- * based requests. When door service request is received the
- * following happens inside the lx_thunk process:
- *
- * - The doors server function is is invoked on a new solaris thread
- * that the kernel injects into the lx_thunk process. We sanity
- * check the incoming request, place it on a service queue, and
- * wait for notification that the request has been completed.
- *
- * - A Linux thread takes this request off the service queue
- * and dispatches it to a service function that will:
- * - Decode the request.
- * - Handle the request by invoking native Linux interfaces.
- * - Encode the results for the request.
- *
- * - The Linux thread then notifies the requesting doors server
- * thread that the request has been completed and goes to sleep
- * until it receives another request.
- *
- * - the solaris door server thread returns the results of the
- * operation to the caller.
- *
- * Notes:
- *
- * - The service request hand off operation from the solaris doors thread to
- * the "Linux thread" is required because only "Linux threads" can call
- * into Linux code. In this context a "Linux thread" is a thread that
- * is either the initial thread of a Linux process or a thread that was
- * created by calling the Linux version of thread_create(). The reason
- * for this restriction is that any thread that invokes Linux code needs
- * to have been initialized in the Linux threading libraries and have
- * things like Linux thread local storage properly setup.
- *
- * But under solaris all door server threads are created and destroyed
- * dynamically. This means that when a doors server function is invoked,
- * it is invoked via a thread that hasn't been initialized in the Linux
- * environment and there for can't call directly into Linux code.
- *
- * - Currently when a thunk server process is starting up, it communicated
- * with it's parent via two FIFOs. These FIFOs are setup by the
- * lx_thunk.so library. After creating the FIFOs and starting the lx_thunk
- * server, lx_thunk.so writes the name of the file that the door should
- * be attached to to the first pipe. The lx_thunk server reads in this
- * value, initialized the server, fattach()s it to the file request by
- * lx_thunk.so and does a write to the second FIFO to let lx_thunk.so
- * know that the server is ready to take requests.
- *
- * This negotiation could be simplified to use only use one FIFO.
- * lx_thunk.so would attempt to read from the FIFO and the lx_thunk
- * server process could send the new door server file descriptor
- * to this process via an I_SENDFD ioctl (see streamio.7I).
- *
- * - The lx_thunk server process will exit when the client process
- * that it's handling requests for exists. (ie, when there are no
- * more open file handles to the doors server.)
- */
-
-#include <assert.h>
-#include <door.h>
-#include <errno.h>
-#include <libproc.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <strings.h>
-#include <sys/lx_debug.h>
-#include <sys/lx_misc.h>
-#include <sys/lx_syscall.h>
-#include <sys/lx_thread.h>
-#include <sys/lx_thunk_server.h>
-#include <sys/varargs.h>
-#include <thread.h>
-#include <unistd.h>
-
-/*
- * Generic interfaces used for looking up and calling Linux functions.
- */
-typedef struct __lx_handle_dlsym *lx_handle_dlsym_t;
-typedef struct __lx_handle_sym *lx_handle_sym_t;
-
-uintptr_t lx_call0(lx_handle_sym_t);
-uintptr_t lx_call1(lx_handle_sym_t, uintptr_t);
-uintptr_t lx_call2(lx_handle_sym_t, uintptr_t, uintptr_t);
-uintptr_t lx_call3(lx_handle_sym_t, uintptr_t, uintptr_t, uintptr_t);
-uintptr_t lx_call4(lx_handle_sym_t, uintptr_t, uintptr_t, uintptr_t,
- uintptr_t);
-uintptr_t lx_call5(lx_handle_sym_t, uintptr_t, uintptr_t, uintptr_t,
- uintptr_t, uintptr_t);
-uintptr_t lx_call6(lx_handle_sym_t, uintptr_t, uintptr_t, uintptr_t,
- uintptr_t, uintptr_t, uintptr_t);
-uintptr_t lx_call7(lx_handle_sym_t, uintptr_t, uintptr_t, uintptr_t,
- uintptr_t, uintptr_t, uintptr_t, uintptr_t);
-uintptr_t lx_call8(lx_handle_sym_t, uintptr_t, uintptr_t, uintptr_t,
- uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t);
-
-/*
- * Flag indicating if this process is destined to become a thunking
- * server process.
- */
-static int lxt_server_processes = 0;
-
-/*
- * Linux function call defines and handles.
- */
-static lx_handle_dlsym_t lxh_init = NULL;
-
-#define LXTH_GETHOSTBYNAME_R 0
-#define LXTH_GETHOSTBYADDR_R 1
-#define LXTH_GETSERVBYNAME_R 2
-#define LXTH_GETSERVBYPORT_R 3
-#define LXTH_OPENLOG 4
-#define LXTH_SYSLOG 5
-#define LXTH_CLOSELOG 6
-#define LXTH_PROGNAME 7
-
-static struct lxt_handles {
- int lxth_index;
- char *lxth_name;
- lx_handle_sym_t lxth_handle;
-} lxt_handles[] = {
- { LXTH_GETHOSTBYNAME_R, "gethostbyname_r", NULL },
- { LXTH_GETHOSTBYADDR_R, "gethostbyaddr_r", NULL },
- { LXTH_GETSERVBYNAME_R, "getservbyname_r", NULL },
- { LXTH_GETSERVBYPORT_R, "getservbyport_r", NULL },
- { LXTH_OPENLOG, "openlog", NULL },
- { LXTH_SYSLOG, "syslog", NULL },
- { LXTH_CLOSELOG, "closelog", NULL },
- { LXTH_PROGNAME, "__progname", NULL },
- { -1, NULL, NULL },
-};
-
-/*
- * Door server operations dispatch functions and table.
- *
- * When the doors server get's a request for a particlar operation
- * this dispatch table controls what function will be invoked to
- * service the request. The function is invoked via Linux thread
- * so that it can call into native Linux code if necessary.
- */
-static void lxt_server_gethost(lxt_server_arg_t *request, size_t request_size,
- char **door_result, size_t *door_result_size);
-static void lxt_server_getserv(lxt_server_arg_t *request, size_t request_size,
- char **door_result, size_t *door_result_size);
-static void lxt_server_openlog(lxt_server_arg_t *request, size_t request_size,
- char **door_result, size_t *door_result_size);
-static void lxt_server_syslog(lxt_server_arg_t *request, size_t request_size,
- char **door_result, size_t *door_result_size);
-static void lxt_server_closelog(lxt_server_arg_t *request, size_t request_size,
- char **door_result, size_t *door_result_size);
-
-typedef void (*lxt_op_func_t)(lxt_server_arg_t *request, size_t request_size,
- char **door_result, size_t *door_result_size);
-
-static struct lxt_operations {
- int lxto_index;
- lxt_op_func_t lxto_fp;
-} lxt_operations[] = {
- { LXT_SERVER_OP_PING, NULL },
- { LXT_SERVER_OP_NAME2HOST, lxt_server_gethost },
- { LXT_SERVER_OP_ADDR2HOST, lxt_server_gethost },
- { LXT_SERVER_OP_NAME2SERV, lxt_server_getserv },
- { LXT_SERVER_OP_PORT2SERV, lxt_server_getserv },
- { LXT_SERVER_OP_OPENLOG, lxt_server_openlog },
- { LXT_SERVER_OP_SYSLOG, lxt_server_syslog },
- { LXT_SERVER_OP_CLOSELOG, lxt_server_closelog },
-};
-
-/*
- * Structures for passing off requests from doors threads (which are
- * solaris threads) to a Linux thread that that can handle them.
- */
-typedef struct lxt_req {
- lxt_server_arg_t *lxtr_request;
- size_t lxtr_request_size;
- char *lxtr_result;
- size_t lxtr_result_size;
- int lxtr_complete;
- cond_t lxtr_complete_cv;
-} lxt_req_t;
-
-static mutex_t lxt_req_lock = DEFAULTMUTEX;
-static cond_t lxt_req_cv = DEFAULTCV;
-static lxt_req_t *lxt_req_ptr = NULL;
-
-static mutex_t lxt_pid_lock = DEFAULTMUTEX;
-
-/*
- * Interfaces used to call from lx_brand.so into Linux code.
- */
-typedef struct lookup_cb_arg {
- struct ps_prochandle *lca_ph;
- caddr_t lca_ptr;
-} lookup_cb_arg_t;
-
-static int
-/*ARGSUSED*/
-lookup_cb(void *data, const prmap_t *pmp, const char *object)
-{
- lookup_cb_arg_t *lcap = (lookup_cb_arg_t *)data;
- prsyminfo_t si;
- GElf_Sym sym;
-
- if (Pxlookup_by_name(lcap->lca_ph,
- LM_ID_BASE, object, "dlsym", &sym, &si) != 0)
- return (0);
-
- if (sym.st_shndx == SHN_UNDEF)
- return (0);
-
- /*
- * XXX: we should be more paranoid and verify that the symbol
- * we just looked up is libdl.so.2`dlsym
- */
- lcap->lca_ptr = (caddr_t)(uintptr_t)sym.st_value;
- return (1);
-}
-
-lx_handle_dlsym_t
-lx_call_init(void)
-{
- struct ps_prochandle *ph;
- lookup_cb_arg_t lca;
- extern int __libc_threaded;
- int err;
-
- lx_debug("lx_call_init(): looking up Linux dlsym");
-
- /*
- * The handle is really the address of the Linux "dlsym" function.
- * Once we have this address we can call into the Linux "dlsym"
- * function to lookup other functions. It's the initial lookup
- * of "dlsym" that's difficult. To do this we'll leverage the
- * brand support that we added to librtld_db. We're going
- * to fire up a seperate native solaris process that will
- * attach to us via libproc/librtld_db and lookup the symbol
- * for us.
- */
-
- /* Make sure we're single threaded. */
- if (__libc_threaded) {
- lx_debug("lx_call_init() fail: "
- "process must be single threaded");
- return (NULL);
- }
-
- /* Tell libproc.so where the real procfs is mounted. */
- Pset_procfs_path("/native/proc");
-
- /* Tell librtld_db.so where the real /native is */
- (void) rd_ctl(RD_CTL_SET_HELPPATH, "/native");
-
- /* Grab ourselves but don't stop ourselves. */
- if ((ph = Pgrab(getpid(),
- PGRAB_FORCE | PGRAB_RDONLY | PGRAB_NOSTOP, &err)) == NULL) {
- lx_debug("lx_call_init() fail: Pgrab failed: %s",
- Pgrab_error(err));
- return (NULL);
- }
-
- lca.lca_ph = ph;
- lca.lca_ptr = NULL;
- if (Pobject_iter(ph, lookup_cb, &lca) == -1) {
- lx_debug("lx_call_init() fail: couldn't find Linux dlsym");
- return (NULL);
- }
-
- lx_debug("lx_call_init(): Linux dlsym = 0x%p", lca.lca_ptr);
- return ((lx_handle_dlsym_t)lca.lca_ptr);
-}
-
-#define LX_RTLD_DEFAULT ((void *)0)
-#define LX_RTLD_NEXT ((void *) -1l)
-
-lx_handle_sym_t
-lx_call_dlsym(lx_handle_dlsym_t lxh_dlsym, const char *str)
-{
- lx_handle_sym_t result;
- lx_debug("lx_call_dlsym: calling Linux dlsym for: %s", str);
- result = (lx_handle_sym_t)lx_call2((lx_handle_sym_t)lxh_dlsym,
- (uintptr_t)LX_RTLD_DEFAULT, (uintptr_t)str);
- lx_debug("lx_call_dlsym: Linux sym: \"%s\" = 0x%p", str, result);
- return (result);
-}
-
-static uintptr_t
-/*ARGSUSED*/
-lx_call(lx_handle_sym_t lx_ch, uintptr_t p1, uintptr_t p2,
- uintptr_t p3, uintptr_t p4, uintptr_t p5, uintptr_t p6, uintptr_t p7,
- uintptr_t p8)
-{
- typedef uintptr_t (*fp8_t)(uintptr_t, uintptr_t, uintptr_t,
- uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t);
- ucontext_t *ucp;
- uintptr_t ret;
- fp8_t lx_funcp = (fp8_t)lx_ch;
-#if defined(_ILP32)
- long cur_gs;
-#endif
-
- ucp = lx_syscall_regs();
-
-#if defined(_ILP32)
- lx_debug("lx_call: loading Linux gs, ucp = 0x%p, gs = 0x%p",
- ucp, LX_REG(ucp, GS));
- lx_swap_gs(LX_REG(ucp, GS), &cur_gs);
-#endif
-
- lx_debug("lx_call: calling to Linux code at 0x%p", lx_ch);
- ret = lx_funcp(p1, p2, p3, p4, p5, p6, p7, p8);
-
-#if defined(_ILP32)
- lx_swap_gs(cur_gs, (long *)&LX_REG(ucp, GS));
-#endif
-
- lx_debug("lx_call: returned from Linux code at 0x%p (%p)", lx_ch, ret);
- return (ret);
-}
-
-uintptr_t
-lx_call0(lx_handle_sym_t lx_ch)
-{
- return (lx_call(lx_ch, 0, 0, 0, 0, 0, 0, 0, 0));
-}
-
-uintptr_t
-lx_call1(lx_handle_sym_t lx_ch, uintptr_t p1)
-{
- return (lx_call(lx_ch, p1, 0, 0, 0, 0, 0, 0, 0));
-}
-
-uintptr_t
-lx_call2(lx_handle_sym_t lx_ch, uintptr_t p1, uintptr_t p2)
-{
- return (lx_call(lx_ch, p1, p2, 0, 0, 0, 0, 0, 0));
-}
-
-uintptr_t
-lx_call3(lx_handle_sym_t lx_ch, uintptr_t p1, uintptr_t p2, uintptr_t p3)
-{
- return (lx_call(lx_ch, p1, p2, p3, 0, 0, 0, 0, 0));
-}
-
-uintptr_t
-lx_call4(lx_handle_sym_t lx_ch, uintptr_t p1, uintptr_t p2, uintptr_t p3,
- uintptr_t p4)
-{
- return (lx_call(lx_ch, p1, p2, p3, p4, 0, 0, 0, 0));
-}
-
-uintptr_t
-lx_call5(lx_handle_sym_t lx_ch, uintptr_t p1, uintptr_t p2, uintptr_t p3,
- uintptr_t p4, uintptr_t p5)
-{
- return (lx_call(lx_ch, p1, p2, p3, p4, p5, 0, 0, 0));
-}
-
-uintptr_t
-lx_call6(lx_handle_sym_t lx_ch, uintptr_t p1, uintptr_t p2, uintptr_t p3,
- uintptr_t p4, uintptr_t p5, uintptr_t p6)
-{
- return (lx_call(lx_ch, p1, p2, p3, p4, p5, p6, 0, 0));
-}
-
-uintptr_t
-lx_call7(lx_handle_sym_t lx_ch, uintptr_t p1, uintptr_t p2, uintptr_t p3,
- uintptr_t p4, uintptr_t p5, uintptr_t p6, uintptr_t p7)
-{
- return (lx_call(lx_ch, p1, p2, p3, p4, p5, p6, p7, 0));
-}
-
-uintptr_t
-lx_call8(lx_handle_sym_t lx_ch, uintptr_t p1, uintptr_t p2, uintptr_t p3,
- uintptr_t p4, uintptr_t p5, uintptr_t p6, uintptr_t p7, uintptr_t p8)
-{
- return (lx_call(lx_ch, p1, p2, p3, p4, p5, p6, p7, p8));
-}
-
-/*
- * Linux Thunking Interfaces - Server Side
- */
-static int
-lxt_gethost_arg_check(lxt_gethost_arg_t *x, int x_size)
-{
- if (x_size != sizeof (*x) + x->lxt_gh_buf_len - 1)
- return (-1);
-
- if ((x->lxt_gh_token_len < 0) || (x->lxt_gh_buf_len < 0))
- return (-1);
-
- /* Token and buf should use up all the storage. */
- if ((x->lxt_gh_token_len + x->lxt_gh_buf_len) != x->lxt_gh_storage_len)
- return (-1);
-
- return (0);
-}
-
-static void
-lxt_server_gethost(lxt_server_arg_t *request, size_t request_size,
- char **door_result, size_t *door_result_size)
-{
- lxt_gethost_arg_t *data;
- struct hostent *result, *rv;
- int token_len, buf_len, type, data_size, i;
- char *token, *buf;
- int h_errnop;
-
- assert((request->lxt_sa_op == LXT_SERVER_OP_NAME2HOST) ||
- (request->lxt_sa_op == LXT_SERVER_OP_ADDR2HOST));
-
- /*LINTED*/
- data = (lxt_gethost_arg_t *)&request->lxt_sa_data[0];
- data_size = request_size - sizeof (*request) - 1;
-
- if (!lxt_gethost_arg_check(data, data_size)) {
- lx_debug("lxt_server_gethost: invalid request");
- *door_result = NULL;
- *door_result_size = 0;
- return;
- }
-
- /* Unpack the arguments. */
- type = data->lxt_gh_type;
- token = &data->lxt_gh_storage[0];
- token_len = data->lxt_gh_token_len;
- result = &data->lxt_gh_result;
- buf = &data->lxt_gh_storage[data->lxt_gh_token_len];
- buf_len = data->lxt_gh_buf_len - data->lxt_gh_token_len;
-
- if (request->lxt_sa_op == LXT_SERVER_OP_NAME2HOST) {
- (void) lx_call6(lxt_handles[LXTH_GETHOSTBYNAME_R].lxth_handle,
- (uintptr_t)token, (uintptr_t)result,
- (uintptr_t)buf, buf_len, (uintptr_t)&rv,
- (uintptr_t)&h_errnop);
- } else {
- (void) lx_call8(lxt_handles[LXTH_GETHOSTBYADDR_R].lxth_handle,
- (uintptr_t)token, token_len, type, (uintptr_t)result,
- (uintptr_t)buf, buf_len, (uintptr_t)&rv,
- (uintptr_t)&h_errnop);
- }
-
- if (rv == NULL) {
- /* the lookup failed */
- request->lxt_sa_success = 0;
- request->lxt_sa_errno = errno;
- data->lxt_gh_h_errno = h_errnop;
- *door_result = (char *)request;
- *door_result_size = request_size;
- return;
- }
- request->lxt_sa_success = 1;
- request->lxt_sa_errno = 0;
- data->lxt_gh_h_errno = 0;
-
- /*
- * The result structure that we would normally return contains a
- * bunch of pointers, but those pointers are useless to our caller
- * since they are in a different address space. So before returning
- * we'll convert all the result pointers into offsets. The caller
- * can then map the offsets back into pointers.
- */
- for (i = 0; result->h_aliases[i] != NULL; i++) {
- result->h_aliases[i] =
- LXT_PTR_TO_OFFSET(result->h_aliases[i], buf);
- }
- for (i = 0; result->h_addr_list[i] != NULL; i++) {
- result->h_addr_list[i] =
- LXT_PTR_TO_OFFSET(result->h_addr_list[i], buf);
- }
- result->h_name = LXT_PTR_TO_OFFSET(result->h_name, buf);
- result->h_aliases = LXT_PTR_TO_OFFSET(result->h_aliases, buf);
- result->h_addr_list = LXT_PTR_TO_OFFSET(result->h_addr_list, buf);
-
- *door_result = (char *)request;
- *door_result_size = request_size;
-}
-
-static int
-lxt_getserv_arg_check(lxt_getserv_arg_t *x, int x_size)
-{
- if (x_size != sizeof (*x) + x->lxt_gs_buf_len - 1)
- return (-1);
-
- if ((x->lxt_gs_token_len < 0) || (x->lxt_gs_buf_len < 0))
- return (-1);
-
- /* Token and buf should use up all the storage. */
- if ((x->lxt_gs_token_len + x->lxt_gs_buf_len) != x->lxt_gs_storage_len)
- return (-1);
-
- return (0);
-}
-
-static void
-lxt_server_getserv(lxt_server_arg_t *request, size_t request_size,
- char **door_result, size_t *door_result_size)
-{
- lxt_getserv_arg_t *data;
- struct servent *result, *rv;
- int token_len, buf_len, data_size, i, port;
- char *token, *buf, *proto = NULL;
-
- assert((request->lxt_sa_op == LXT_SERVER_OP_NAME2SERV) ||
- (request->lxt_sa_op == LXT_SERVER_OP_PORT2SERV));
-
- /*LINTED*/
- data = (lxt_getserv_arg_t *)&request->lxt_sa_data[0];
- data_size = request_size - sizeof (*request) - 1;
-
- if (!lxt_getserv_arg_check(data, data_size)) {
- lx_debug("lxt_server_getserv: invalid request");
- *door_result = NULL;
- *door_result_size = 0;
- return;
- }
-
- /* Unpack the arguments. */
- token = &data->lxt_gs_storage[0];
- token_len = data->lxt_gs_token_len;
- result = &data->lxt_gs_result;
- buf = &data->lxt_gs_storage[data->lxt_gs_token_len];
- buf_len = data->lxt_gs_buf_len - data->lxt_gs_token_len;
- if (strlen(data->lxt_gs_proto) > 0)
- proto = data->lxt_gs_proto;
-
- /* Do more sanity checks */
- if ((request->lxt_sa_op == LXT_SERVER_OP_PORT2SERV) &&
- (token_len != sizeof (int))) {
- lx_debug("lxt_server_getserv: invalid request");
- *door_result = NULL;
- *door_result_size = 0;
- return;
- }
-
- if (request->lxt_sa_op == LXT_SERVER_OP_NAME2SERV) {
- (void) lx_call6(lxt_handles[LXTH_GETSERVBYNAME_R].lxth_handle,
- (uintptr_t)token, (uintptr_t)proto, (uintptr_t)result,
- (uintptr_t)buf, buf_len, (uintptr_t)&rv);
- } else {
- bcopy(token, &port, sizeof (int));
- (void) lx_call6(lxt_handles[LXTH_GETSERVBYPORT_R].lxth_handle,
- port, (uintptr_t)proto, (uintptr_t)result,
- (uintptr_t)buf, buf_len, (uintptr_t)&rv);
- }
-
- if (rv == NULL) {
- /* the lookup failed */
- request->lxt_sa_success = 0;
- request->lxt_sa_errno = errno;
- *door_result = (char *)request;
- *door_result_size = request_size;
- return;
- }
- request->lxt_sa_success = 1;
- request->lxt_sa_errno = 0;
-
- /*
- * The result structure that we would normally return contains a
- * bunch of pointers, but those pointers are useless to our caller
- * since they are in a different address space. So before returning
- * we'll convert all the result pointers into offsets. The caller
- * can then map the offsets back into pointers.
- */
- for (i = 0; result->s_aliases[i] != NULL; i++) {
- result->s_aliases[i] =
- LXT_PTR_TO_OFFSET(result->s_aliases[i], buf);
- }
- result->s_proto = LXT_PTR_TO_OFFSET(result->s_proto, buf);
- result->s_aliases = LXT_PTR_TO_OFFSET(result->s_aliases, buf);
- result->s_name = LXT_PTR_TO_OFFSET(result->s_name, buf);
-
- *door_result = (char *)request;
- *door_result_size = request_size;
-}
-
-static void
-/*ARGSUSED*/
-lxt_server_openlog(lxt_server_arg_t *request, size_t request_size,
- char **door_result, size_t *door_result_size)
-{
- lxt_openlog_arg_t *data;
- int data_size;
- static char ident[128];
-
- assert(request->lxt_sa_op == LXT_SERVER_OP_OPENLOG);
-
- /*LINTED*/
- data = (lxt_openlog_arg_t *)&request->lxt_sa_data[0];
- data_size = request_size - sizeof (*request);
-
- if (data_size != sizeof (*data)) {
- lx_debug("lxt_server_openlog: invalid request");
- *door_result = NULL;
- *door_result_size = 0;
- return;
- }
-
- /*
- * Linux expects that the ident pointer passed to openlog()
- * points to a static string that won't go away. Linux
- * saves the pointer and references with syslog() is called.
- * Hence we'll make a local copy of the ident string here.
- */
- (void) mutex_lock(&lxt_pid_lock);
- (void) strlcpy(ident, data->lxt_ol_ident, sizeof (ident));
- (void) mutex_unlock(&lxt_pid_lock);
-
- /* Call Linx openlog(). */
- (void) lx_call3(lxt_handles[LXTH_OPENLOG].lxth_handle,
- (uintptr_t)ident, data->lxt_ol_logopt, data->lxt_ol_facility);
-
- request->lxt_sa_success = 1;
- request->lxt_sa_errno = 0;
- *door_result = (char *)request;
- *door_result_size = request_size;
-}
-
-static void
-/*ARGSUSED*/
-lxt_server_syslog(lxt_server_arg_t *request, size_t request_size,
- char **door_result, size_t *door_result_size)
-{
- lxt_syslog_arg_t *data;
- int data_size;
- char *progname_ptr_new;
- char *progname_ptr_old;
-
- assert(request->lxt_sa_op == LXT_SERVER_OP_SYSLOG);
-
- /*LINTED*/
- data = (lxt_syslog_arg_t *)&request->lxt_sa_data[0];
- data_size = request_size - sizeof (*request);
-
- if (data_size != sizeof (*data)) {
- lx_debug("lxt_server_openlog: invalid request");
- *door_result = NULL;
- *door_result_size = 0;
- return;
- }
- progname_ptr_new = data->lxt_sl_progname;
-
- (void) mutex_lock(&lxt_pid_lock);
-
- /*
- * Ensure the message has the correct pid.
- * We do this by telling our getpid() system call to return a
- * different value.
- */
- (void) syscall(SYS_brand, B_SET_THUNK_PID, data->lxt_sl_pid);
-
- /*
- * Ensure the message has the correct program name.
- * Normally instead of a program name an "ident" string is
- * used, this is the string passed to openlog(). But if
- * openlog() wasn't called before syslog() then Linux
- * syslog() will attempt to use the program name as
- * the ident string, and the program name is determined
- * by looking at the __progname variable. So we'll just
- * update the Linux __progname variable while we do the
- * call.
- */
- (void) uucopy(lxt_handles[LXTH_PROGNAME].lxth_handle,
- &progname_ptr_old, sizeof (char *));
- (void) uucopy(&progname_ptr_new,
- lxt_handles[LXTH_PROGNAME].lxth_handle, sizeof (char *));
-
- /* Call Linux syslog(). */
- (void) lx_call2(lxt_handles[LXTH_SYSLOG].lxth_handle,
- data->lxt_sl_priority, (uintptr_t)data->lxt_sl_message);
-
- /* Restore pid and program name. */
- (void) uucopy(&progname_ptr_old,
- lxt_handles[LXTH_PROGNAME].lxth_handle, sizeof (char *));
- (void) syscall(SYS_brand, B_SET_THUNK_PID, 0);
-
- (void) mutex_unlock(&lxt_pid_lock);
-
- request->lxt_sa_success = 1;
- request->lxt_sa_errno = 0;
- *door_result = (char *)request;
- *door_result_size = request_size;
-}
-
-static void
-/*ARGSUSED*/
-lxt_server_closelog(lxt_server_arg_t *request, size_t request_size,
- char **door_result, size_t *door_result_size)
-{
- int data_size;
-
- assert(request->lxt_sa_op == LXT_SERVER_OP_CLOSELOG);
-
- data_size = request_size - sizeof (*request);
- if (data_size != 0) {
- lx_debug("lxt_server_closelog: invalid request");
- *door_result = NULL;
- *door_result_size = 0;
- return;
- }
-
- /* Call Linux closelog(). */
- (void) lx_call0(lxt_handles[LXTH_CLOSELOG].lxth_handle);
-
- request->lxt_sa_success = 1;
- request->lxt_sa_errno = 0;
- *door_result = (char *)request;
- *door_result_size = request_size;
-}
-
-static void
-/*ARGSUSED*/
-lxt_server(void *cookie, char *argp, size_t request_size,
- door_desc_t *dp, uint_t n_desc)
-{
- /*LINTED*/
- lxt_server_arg_t *request = (lxt_server_arg_t *)argp;
- lxt_req_t lxt_req;
- char *door_path = cookie;
-
- /* Check if there's no callers left */
- if (argp == DOOR_UNREF_DATA) {
- (void) fdetach(door_path);
- (void) unlink(door_path);
- lx_debug("lxt_thunk_server: no clients, exiting");
- exit(0);
- }
-
- /* Sanity check the incomming request. */
- if (request_size < sizeof (*request)) {
- /* the lookup failed */
- lx_debug("lxt_thunk_server: invalid request size");
- (void) door_return(NULL, 0, NULL, 0);
- return;
- }
-
- if ((request->lxt_sa_op < LXT_SERVER_OP_MIN) ||
- (request->lxt_sa_op > LXT_SERVER_OP_MAX)) {
- lx_debug("lxt_thunk_server: invalid request op");
- (void) door_return(NULL, 0, NULL, 0);
- return;
- }
-
- /* Handle ping requests immediatly, return here. */
- if (request->lxt_sa_op == LXT_SERVER_OP_PING) {
- lx_debug("lxt_thunk_server: handling ping request");
- request->lxt_sa_success = 1;
- (void) door_return((char *)request, request_size, NULL, 0);
- return;
- }
-
- lx_debug("lxt_thunk_server: hand off request to Linux thread, "
- "request = 0x%p", request);
-
- /* Pack the request up so we can pass it to a Linux thread. */
- lxt_req.lxtr_request = request;
- lxt_req.lxtr_request_size = request_size;
- lxt_req.lxtr_result = NULL;
- lxt_req.lxtr_result_size = 0;
- lxt_req.lxtr_complete = 0;
- (void) cond_init(&lxt_req.lxtr_complete_cv, USYNC_THREAD, NULL);
-
- /* Pass the request onto a Linux thread. */
- (void) mutex_lock(&lxt_req_lock);
- while (lxt_req_ptr != NULL)
- (void) cond_wait(&lxt_req_cv, &lxt_req_lock);
- lxt_req_ptr = &lxt_req;
- (void) cond_broadcast(&lxt_req_cv);
-
- /* Wait for the request to be completed. */
- while (lxt_req.lxtr_complete == 0)
- (void) cond_wait(&lxt_req.lxtr_complete_cv, &lxt_req_lock);
- assert(lxt_req_ptr != &lxt_req);
- (void) mutex_unlock(&lxt_req_lock);
-
- lx_debug("lxt_thunk_server: hand off request completed, "
- "request = 0x%p", request);
-
- /*
- * If door_return() is successfull it never returns, so if we made
- * it here there was some kind of error, but there's nothing we can
- * really do about it.
- */
- (void) door_return(
- lxt_req.lxtr_result, lxt_req.lxtr_result_size, NULL, 0);
-}
-
-static void
-lxt_server_loop(void)
-{
- lxt_req_t *lxt_req;
- lxt_server_arg_t *request;
- size_t request_size;
- char *door_result;
- size_t door_result_size;
-
- for (;;) {
- /* Wait for a request from a doors server thread. */
- (void) mutex_lock(&lxt_req_lock);
- while (lxt_req_ptr == NULL)
- (void) cond_wait(&lxt_req_cv, &lxt_req_lock);
-
- /* We got a request, get a local pointer to it. */
- lxt_req = lxt_req_ptr;
- lxt_req_ptr = NULL;
- (void) cond_broadcast(&lxt_req_cv);
- (void) mutex_unlock(&lxt_req_lock);
-
- /* Get a pointer to the request. */
- request = lxt_req->lxtr_request;
- request_size = lxt_req->lxtr_request_size;
-
- lx_debug("lxt_server_loop: Linux thread request recieved, "
- "request = %p", request);
-
- /* Dispatch the request. */
- assert((request->lxt_sa_op > LXT_SERVER_OP_PING) ||
- (request->lxt_sa_op < LXT_SERVER_OP_MAX));
- lxt_operations[request->lxt_sa_op].lxto_fp(
- request, request_size, &door_result, &door_result_size);
-
- lx_debug("lxt_server_loop: Linux thread request completed, "
- "request = %p", request);
-
- (void) mutex_lock(&lxt_req_lock);
-
- /* Set the result pointers for the calling door thread. */
- lxt_req->lxtr_result = door_result;
- lxt_req->lxtr_result_size = door_result_size;
-
- /* Let the door thread know we're done. */
- lxt_req->lxtr_complete = 1;
- (void) cond_signal(&lxt_req->lxtr_complete_cv);
-
- (void) mutex_unlock(&lxt_req_lock);
- }
- /*NOTREACHED*/
-}
-
-static void
-lxt_server_enter(int fifo1_wr, int fifo2_rd)
-{
- struct stat stat;
- char door_path[MAXPATHLEN];
- int i, dfd, junk = 0;
-
- /*
- * Do some sanity checks. Make sure we've got the fifos
- * we need passed to us on the correct file descriptors.
- */
- if ((fstat(fifo1_wr, &stat) != 0) ||
- ((stat.st_mode & S_IFMT) != S_IFIFO) ||
- (fstat(fifo2_rd, &stat) != 0) ||
- ((stat.st_mode & S_IFMT) != S_IFIFO)) {
- lx_err("lx_thunk server aborting, can't contact parent");
- exit(-1);
- }
-
- /*
- * Get the initial Linux call handle so we can invoke other
- * Linux calls.
- */
- lxh_init = lx_call_init();
- if (lxh_init == NULL) {
- lx_err("lx_thunk server aborting, failed Linux call init");
- exit(-1);
- }
-
- /* Now lookup other Linux symbols we'll need access to. */
- for (i = 0; lxt_handles[i].lxth_name != NULL; i++) {
- assert(lxt_handles[i].lxth_index == i);
- if ((lxt_handles[i].lxth_handle = lx_call_dlsym(lxh_init,
- lxt_handles[i].lxth_name)) == NULL) {
- lx_err("lx_thunk server aborting, "
- "failed Linux symbol lookup: %s",
- lxt_handles[i].lxth_name);
- exit(-1);
- }
- }
-
- /* get the path to the door server */
- if (read(fifo2_rd, door_path, sizeof (door_path)) < 0) {
- lx_err("lxt_server_enter: failed to get door path");
- exit(-1);
- }
- (void) close(fifo2_rd);
-
- /* Create the door server. */
- if ((dfd = door_create(lxt_server, door_path,
- DOOR_UNREF | DOOR_REFUSE_DESC | DOOR_NO_CANCEL)) < 0) {
- lx_err("lxt_server_enter: door_create() failed");
- exit(-1);
- }
-
- /* Attach the door to a file system path. */
- (void) fdetach(door_path);
- if (fattach(dfd, door_path) < 0) {
- lx_err("lxt_server_enter: fattach() failed");
- exit(-1);
- }
-
- /* The door server is ready, signal this via a fifo write */
- (void) write(fifo1_wr, &junk, 1);
- (void) close(fifo1_wr);
-
- lx_debug("lxt_server_enter: doors server initialized");
- lxt_server_loop();
- /*NOTREACHED*/
-}
-
-void
-lxt_server_exec_check(void)
-{
- if (lxt_server_processes == 0)
- return;
-
- /*
- * We're a thunk server process, so we take over control of
- * the current Linux process here.
- */
- lx_debug("lx_thunk server initalization starting");
- lxt_server_enter(LXT_SERVER_FIFO_WR_FD, LXT_SERVER_FIFO_RD_FD);
- /*NOTREACHED*/
-}
-
-void
-lxt_server_init(int argc, char *argv[])
-{
- /*
- * The thunk server process is a shell script named LXT_SERVER_BINARY.
- * It is executed without any parameters. Since it's a shell script
- * the arguments passed to the shell's main entry point are:
- * 1) the name of the shell
- * 2) the name of the script to execute
- *
- * So to check if we're the thunk server process we first check
- * for the expected number of arduments and then we'll look at
- * the second parameter to see if it's LXT_SERVER_BINARY.
- */
- if ((argc != 2) ||
- (strcmp(argv[1], LXT_SERVER_BINARY) != 0))
- return;
-
- lxt_server_processes = 1;
- lx_debug("lx_thunk server detected, delaying initalization");
-}
diff --git a/usr/src/lib/brand/lx/lx_brand/common/misc.c b/usr/src/lib/brand/lx/lx_brand/common/misc.c
index 8b2d0d646c..95234b819c 100644
--- a/usr/src/lib/brand/lx/lx_brand/common/misc.c
+++ b/usr/src/lib/brand/lx/lx_brand/common/misc.c
@@ -41,12 +41,12 @@
#include <sys/epoll.h>
#include <sys/mman.h>
#include <sys/shm.h>
+#include <sys/socket.h>
#include <sys/lx_types.h>
#include <sys/lx_debug.h>
#include <sys/lx_misc.h>
#include <sys/lx_stat.h>
#include <sys/lx_syscall.h>
-#include <sys/lx_thunk_server.h>
#include <sys/lx_fcntl.h>
#include <sys/lx_thread.h>
#include <sys/inotify.h>
@@ -57,6 +57,7 @@
#include <libintl.h>
#include <zone.h>
#include <priv.h>
+#include <procfs.h>
#include <lx_syscall.h>
extern int sethostname(char *, int);
@@ -523,9 +524,6 @@ lx_execve(uintptr_t p1, uintptr_t p2, uintptr_t p3)
char *nullist[] = { NULL };
char path[64];
- /* First call the thunk server hook. */
- lxt_server_exec_check();
-
/* Get a copy of the executable we're trying to run */
path[0] = '\0';
(void) uucopystr(filename, path, sizeof (path));
diff --git a/usr/src/lib/brand/lx/lx_brand/sys/lx_thunk_server.h b/usr/src/lib/brand/lx/lx_brand/sys/lx_thunk_server.h
deleted file mode 100644
index 33704bffb6..0000000000
--- a/usr/src/lib/brand/lx/lx_brand/sys/lx_thunk_server.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-
-/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _LX_THUNK_SERVER_H
-#define _LX_THUNK_SERVER_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <netdb.h>
-#include <procfs.h>
-
-/*
- * Binary that should be exec'd to start up the thunking server
- */
-#define LXT_SERVER_BINARY "/native/usr/lib/brand/lx/lx_thunk"
-
-/*
- * When the thunking server is started it will need to communicate
- * to the client via two fifos. These fifos will be passed to the
- * thunking server via the following file descriptors:
- */
-#define LXT_SERVER_FIFO_RD_FD 3
-#define LXT_SERVER_FIFO_WR_FD 4
-
-/*
- * Operations supported by the thunking server
- */
-#define LXT_SERVER_OP_MIN 0
-#define LXT_SERVER_OP_PING 0
-#define LXT_SERVER_OP_NAME2HOST 1
-#define LXT_SERVER_OP_ADDR2HOST 2
-#define LXT_SERVER_OP_NAME2SERV 3
-#define LXT_SERVER_OP_PORT2SERV 4
-#define LXT_SERVER_OP_OPENLOG 5
-#define LXT_SERVER_OP_SYSLOG 6
-#define LXT_SERVER_OP_CLOSELOG 7
-#define LXT_SERVER_OP_MAX 8
-
-/*
- * Macros used to translate pointer into offsets for when they are
- * being transmitted between the client and server processes.
- *
- * NOTE: We're going to add 1 to every offset value. The reason
- * for this is that some of the pointers we're converting to offsets are
- * stored in NULL terminated arrays, and if one of the members of
- * one of these arrays happened to be at the beginning of the storage
- * buffer it would have an offset of 0 and when the client tries to
- * translate the offsets back into pointers it wouldn't be able
- * to differentiate between the 0 offset from the end of the array.
- */
-#define LXT_PTR_TO_OFFSET(ptr, base) \
- ((void *)((uintptr_t)(ptr) - (uintptr_t)(base) + 1))
-#define LXT_OFFSET_TO_PTR(offset, base) \
- ((void *)((uintptr_t)(offset) + (uintptr_t)(base) - 1))
-
-/*
- * Structures passed to the thunking server via door calls
- */
-typedef struct lxt_server_arg {
- int lxt_sa_op;
- int lxt_sa_success;
- int lxt_sa_errno;
- char lxt_sa_data[1];
-} lxt_server_arg_t;
-
-typedef struct lxt_gethost_arg {
- struct hostent lxt_gh_result;
-
- int lxt_gh_h_errno;
-
- int lxt_gh_type;
- int lxt_gh_token_len;
- int lxt_gh_buf_len;
-
- int lxt_gh_storage_len;
- char lxt_gh_storage[1];
-} lxt_gethost_arg_t;
-
-typedef struct lxt_getserv_arg {
- struct servent lxt_gs_result;
-
- int lxt_gs_token_len;
- int lxt_gs_buf_len;
- char lxt_gs_proto[5];
-
- int lxt_gs_storage_len;
- char lxt_gs_storage[1];
-} lxt_getserv_arg_t;
-
-typedef struct lxt_openlog_arg {
- int lxt_ol_logopt;
- int lxt_ol_facility;
- char lxt_ol_ident[128];
-} lxt_openlog_arg_t;
-
-typedef struct lxt_syslog_arg {
- int lxt_sl_priority;
- pid_t lxt_sl_pid;
- char lxt_sl_progname[PRFNSZ];
- char lxt_sl_message[1024];
-} lxt_syslog_arg_t;
-
-
-/*
- * Functions called by the brand library to manage startup of the
- * thunk server process.
- */
-void lxt_server_init(int, char *[]);
-void lxt_server_exec_check(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _LX_THUNK_SERVER_H */
diff --git a/usr/src/lib/brand/lx/lx_nametoaddr/Makefile b/usr/src/lib/brand/lx/lx_nametoaddr/Makefile
deleted file mode 100644
index f69dcec561..0000000000
--- a/usr/src/lib/brand/lx/lx_nametoaddr/Makefile
+++ /dev/null
@@ -1,52 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-
-#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# ident "%Z%%M% %I% %E% SMI"
-#
-
-include ../../../Makefile.lib
-
-SUBDIRS = $(MACH)
-$(BUILD64)SUBDIRS += $(MACH64)
-
-LINT_SUBDIRS = $(MACH)
-$(BUILD64)LINT_SUBDIRS += $(MACH64)
-
-all := TARGET= all
-clean := TARGET= clean
-clobber := TARGET= clobber
-install := TARGET= install
-lint := TARGET= lint
-
-.KEEP_STATE:
-
-all install clean clobber: $(SUBDIRS)
-
-lint: $(LINT_SUBDIRS)
-
-$(SUBDIRS): FRC
- @cd $@; pwd; $(MAKE) $(TARGET)
-
-FRC:
diff --git a/usr/src/lib/brand/lx/lx_nametoaddr/Makefile.com b/usr/src/lib/brand/lx/lx_nametoaddr/Makefile.com
deleted file mode 100644
index a0fd9da3fe..0000000000
--- a/usr/src/lib/brand/lx/lx_nametoaddr/Makefile.com
+++ /dev/null
@@ -1,68 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-
-#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# ident "%Z%%M% %I% %E% SMI"
-#
-
-LIBRARY = lx_nametoaddr.a
-VERS = .1
-
-COBJS = lx_nametoaddr.o
-OBJECTS = $(COBJS)
-
-include ../../../../Makefile.lib
-include ../../Makefile.lx
-
-MAPFILES = ../common/mapfile-vers
-MAPOPTS = $(MAPFILES:%=-M%)
-
-CSRCS = $(COBJS:%o=../common/%c)
-SRCS = $(CSRCS)
-
-SRCDIR = ../common
-LX_THUNK = ../../lx_thunk
-
-ASFLAGS += -P -D_ASM
-LDLIBS += -lc -lnsl
-CFLAGS += $(CCVERBOSE)
-CPPFLAGS += -D_REENTRANT -I../ -I$(LX_THUNK)
-DYNFLAGS += $(MAPOPTS) '-R$$ORIGIN'
-
-LIBS = $(DYNLIB)
-
-LINTFLAGS += $(LX_THUNK)/$(MACH)/llib-llx_thunk.ln
-LINTFLAGS64 += $(LX_THUNK)/$(MACH64)/llib-llx_thunk.ln
-
-CLEANFILES = $(DYNLIB)
-ROOTLIBDIR = $(ROOT)/usr/lib/brand/lx
-ROOTLIBDIR64 = $(ROOT)/usr/lib/brand/lx/$(MACH64)
-
-.KEEP_STATE:
-
-all: $(DYNLIB)
-
-lint: lintcheck
-
-include ../../../../Makefile.targ
diff --git a/usr/src/lib/brand/lx/lx_nametoaddr/amd64/Makefile b/usr/src/lib/brand/lx/lx_nametoaddr/amd64/Makefile
deleted file mode 100644
index a526d34834..0000000000
--- a/usr/src/lib/brand/lx/lx_nametoaddr/amd64/Makefile
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-
-#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# ident "%Z%%M% %I% %E% SMI"
-#
-
-include ../Makefile.com
-include $(SRC)/lib/Makefile.lib.64
-
-DYNFLAGS += $(LX_THUNK)/$(MACH64)/lx_thunk.so.1
-CLOBBERFILES = $(ROOTLIBDIR64)/$(DYNLIB) $(ROOTLIBDIR64)/$(LINTLIB)
-
-install: all $(ROOTLIBS64)
diff --git a/usr/src/lib/brand/lx/lx_nametoaddr/common/lx_nametoaddr.c b/usr/src/lib/brand/lx/lx_nametoaddr/common/lx_nametoaddr.c
deleted file mode 100644
index 4b6a0532a9..0000000000
--- a/usr/src/lib/brand/lx/lx_nametoaddr/common/lx_nametoaddr.c
+++ /dev/null
@@ -1,479 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-
-/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * BrandZ lx name services translation library.
- *
- * This library is specified as the default name services translation
- * library in a custom netconfig(4) file that is only used when running
- * native solaris processes in a Linux branded zone.
- *
- * What this means it that when a native solaris process runs in a
- * Linux branded zone and issues a name service request to libnsl.so
- * (either directly or indirectly via any libraries the program may
- * be linked against) libnsl.so will dlopen(3c) this library and call
- * into it to service these requests.
- *
- * This library is in turn linked against lx_thunk.so and will attempt
- * to call interfaces in lx_thunk.so to resolve these requests. The
- * functions that are called in lx_thunk.so are designed to have the
- * same signature and behavior as the existing solaris name service
- * interfaces. The name services interfaces we call are:
- *
- * Native Interface -> lx_thunk.so Interface
- * ---------------- -> ---------------------
- * gethostbyname_r -> lxt_gethostbyname_r
- * gethostbyaddr_r -> lxt_gethostbyaddr_r
- * getservbyname_r -> lxt_getservbyname_r
- * getservbyport_r -> lxt_getservbyport_r
- *
- * This library also uses one additional interface from lx_thunk.so:
- * lxt_debug
- * Information debugging messages are sent to lx_thunk.so via this
- * interface and that library can decided if it wants to drop the
- * messages or output them somewhere.
- */
-
-#include <assert.h>
-#include <dlfcn.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <netdb.h>
-#include <netdir.h>
-#include <nss_dbdefs.h>
-#include <rpc/clnt.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <strings.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/varargs.h>
-#include <sys/wait.h>
-#include <thread.h>
-#include <tiuser.h>
-#include <unistd.h>
-#include <sys/lx_thunk.h>
-
-
-/*
- * Private nametoaddr library interfaces.
- */
-static int
-netconfig_is_ipv4(struct netconfig *config)
-{
- int i;
- /*
- * If we look at the rpc services registered on a Linux system
- * (this can be done via rpcinfo(1M)) for both on the loopback
- * interface and on any remote interfaces we only see services
- * registered for tcp and udp. So here we'll limit our support
- * to these transports.
- */
- char *ipv4_netids[] = {
- "tcp",
- "udp",
- NULL
- };
-
- for (i = 0; ipv4_netids[i] != NULL; i++) {
- if (strcmp(ipv4_netids[i], config->nc_netid) == 0)
- return (1);
- }
- return (0);
-}
-
-/*
- * Public nametoaddr library interfaces.
- *
- * These are the functional entry points that libnsl will lookup (via
- * the symbol names) when it loads this nametoaddr translation library.
- */
-
-/*
- * _netdir_getbyname() returns all of the addresses for
- * a specified host and service.
- */
-struct nd_addrlist *
-_netdir_getbyname(struct netconfig *netconfigp,
- struct nd_hostserv *nd_hostservp)
-{
- struct nd_addrlist *rp = NULL;
- struct netbuf *nbp = NULL;
- struct sockaddr_in *sap = NULL;
- struct hostent n2h_result;
- struct servent n2s_result;
- char *n2h_buf = NULL, *n2s_buf = NULL;
- int h_errno, i, host_self = 0, r_count;
- int n2h_count = 0, n2s_count = 0;
-
- lxt_debug("_netdir_getbyname: request recieved\n");
-
- /* Make sure this is an ipv4 request. */
- if (!netconfig_is_ipv4(netconfigp)) {
- _nderror = ND_BADARG;
- goto fail;
- }
-
- /* Allocate memory for the queries. */
- if (((n2h_buf = malloc(NSS_BUFLEN_HOSTS)) == NULL) ||
- ((n2s_buf = malloc(NSS_BUFLEN_SERVICES)) == NULL))
- goto malloc_fail;
-
- /* Check if the host name specified is HOST_SELF. */
- if (strcmp(nd_hostservp->h_host, HOST_SELF) == 0)
- host_self = 1;
-
- /*
- * If the hostname specified is HOST_SELF, the we're just
- * just doing a service lookup so don't bother with trying
- * to lookup the host name.
- */
- if (!host_self) {
- /* Resolve the hostname. */
- lxt_debug("_netdir_getbyname: "
- "resolving host name: %s\n", nd_hostservp->h_host);
- if (lxt_gethostbyname_r(nd_hostservp->h_host, &n2h_result,
- n2h_buf, NSS_BUFLEN_HOSTS, &h_errno) == NULL) {
- if (errno == ERANGE) {
- _nderror = ND_SYSTEM;
- } else if (h_errno == HOST_NOT_FOUND) {
- _nderror = ND_NOHOST;
- } else if (h_errno == TRY_AGAIN) {
- _nderror = ND_TRY_AGAIN;
- } else if (h_errno == NO_RECOVERY) {
- _nderror = ND_NO_RECOVERY;
- } else if (h_errno == NO_DATA) {
- _nderror = ND_NO_DATA;
- } else {
- _nderror = ND_SYSTEM;
- }
- goto fail;
- }
- while (n2h_result.h_addr_list[n2h_count++] != NULL);
- n2h_count--;
- }
-
- if (nd_hostservp->h_serv != NULL) {
- /* Resolve the service name */
- lxt_debug("_netdir_getbyname: "
- "resolving service name: %s\n", nd_hostservp->h_serv);
- if (lxt_getservbyname_r(nd_hostservp->h_serv,
- netconfigp->nc_proto, &n2s_result,
- n2s_buf, NSS_BUFLEN_SERVICES) == NULL) {
- _nderror = ND_SYSTEM;
- goto fail;
- }
- n2s_count = 1;
- }
-
- /* Make sure we got some results. */
- if ((n2h_count + n2s_count) == 0) {
- lxt_debug("_netdir_getbyname: no results!\n");
- goto exit;
- }
- r_count = (n2h_count != 0) ? n2h_count : 1;
-
- /*
- * Allocate the return buffers. These buffers will be free'd
- * by libnsl`netdir_free(), so we need to allocate them in the
- * way that libnsl`netdir_free() expects.
- */
- if (((rp = calloc(1, sizeof (struct nd_addrlist))) == NULL) ||
- ((nbp = calloc(1, sizeof (struct netbuf) * r_count)) == NULL) ||
- ((sap = calloc(1, sizeof (struct sockaddr_in) * r_count)) == NULL))
- goto malloc_fail;
-
- /* Initialize the structures we're going to return. */
- rp->n_cnt = r_count;
- rp->n_addrs = nbp;
- for (i = 0; i < r_count; i++) {
-
- /* Initialize the netbuf. */
- nbp[i].maxlen = nbp[i].len = sizeof (struct sockaddr_in);
- nbp[i].buf = (char *)&sap[i];
-
- /* Initialize the sockaddr_in. */
- sap[i].sin_family = AF_INET;
-
- /* If we looked up any host address copy them out. */
- if (!host_self)
- bcopy(n2h_result.h_addr_list[i], &sap[i].sin_addr,
- sizeof (sap[i].sin_addr));
-
- /* If we looked up any service ports copy them out. */
- if (nd_hostservp->h_serv != NULL)
- sap[i].sin_port = n2s_result.s_port;
- }
-
- /* We're finally done. */
- lxt_debug("_netdir_getbyname: success\n");
- return (rp);
-
-malloc_fail:
- _nderror = ND_NOMEM;
-
-fail:
- lxt_debug("_netdir_getbyname: failed!\n");
-
-exit:
- if (n2h_buf == NULL)
- free(n2h_buf);
- if (n2s_buf == NULL)
- free(n2s_buf);
- if (rp == NULL)
- free(rp);
- if (nbp == NULL)
- free(nbp);
- if (sap == NULL)
- free(sap);
- return (NULL);
-}
-
-/*
- * _netdir_getbyaddr() takes an address (hopefully obtained from
- * someone doing a _netdir_getbyname()) and returns all hosts with
- * that address.
- */
-struct nd_hostservlist *
-/*ARGSUSED*/
-_netdir_getbyaddr(struct netconfig *netconfigp, struct netbuf *nbp)
-{
- struct nd_hostservlist *rp = NULL;
- struct nd_hostserv *hsp = NULL;
- struct sockaddr_in *sap;
- struct servent p2s_result;
- struct hostent a2h_result;
- char *a2h_buf = NULL, *p2s_buf = NULL;
- int h_errno, i;
- int r_count = 0;
- int a2h_count = 0, p2s_count = 0;
-
- lxt_debug("_netdir_getbyaddr: request recieved\n");
-
- /* Make sure this is an ipv4 request. */
- if (!netconfig_is_ipv4(netconfigp)) {
- _nderror = ND_BADARG;
- goto fail;
- }
-
- /*
- * Make sure the netbuf contains one struct sockaddr_in of
- * type AF_INET.
- */
- if ((nbp->len != sizeof (struct sockaddr_in)) ||
- (nbp->len < nbp->maxlen)) {
- _nderror = ND_BADARG;
- goto fail;
- }
- /*LINTED*/
- sap = (struct sockaddr_in *)nbp->buf;
- if (sap->sin_family != AF_INET) {
- _nderror = ND_BADARG;
- goto fail;
- }
-
- /* Allocate memory for the queries. */
- if (((a2h_buf = malloc(NSS_BUFLEN_HOSTS)) == NULL) ||
- ((p2s_buf = malloc(NSS_BUFLEN_SERVICES)) == NULL))
- goto malloc_fail;
-
- if (sap->sin_addr.s_addr != INADDR_ANY) {
- lxt_debug("_netdir_getbyaddr: "
- "resolving host address: 0x%x\n", sap->sin_addr.s_addr);
- if (lxt_gethostbyaddr_r((char *)&sap->sin_addr.s_addr,
- sizeof (sap->sin_addr.s_addr), AF_INET,
- &a2h_result, a2h_buf, NSS_BUFLEN_HOSTS,
- &h_errno) == NULL) {
- if (errno == ERANGE) {
- _nderror = ND_SYSTEM;
- } else if (h_errno == HOST_NOT_FOUND) {
- _nderror = ND_NOHOST;
- } else if (h_errno == TRY_AGAIN) {
- _nderror = ND_TRY_AGAIN;
- } else if (h_errno == NO_RECOVERY) {
- _nderror = ND_NO_RECOVERY;
- } else if (h_errno == NO_DATA) {
- _nderror = ND_NO_DATA;
- } else {
- _nderror = ND_SYSTEM;
- }
- goto fail;
- }
- while (a2h_result.h_aliases[a2h_count++] != NULL);
- /*
- * We need to count a2h_result.h_name as a valid name for
- * for the address we just looked up. Of course a2h_count
- * is actually over estimated by one, so instead of
- * decrementing it here we'll just leave it as it to
- * account for a2h_result.h_name.
- */
- }
-
- if (sap->sin_port != 0) {
- lxt_debug("_netdir_getbyaddr: "
- "resolving service port: 0x%x\n", sap->sin_port);
- if (lxt_getservbyport_r(sap->sin_port,
- netconfigp->nc_proto, &p2s_result,
- p2s_buf, NSS_BUFLEN_SERVICES) == NULL) {
- _nderror = ND_SYSTEM;
- goto fail;
- }
- p2s_count = 1;
- }
-
- /* Make sure we got some results. */
- if ((a2h_count + p2s_count) == 0) {
- lxt_debug("_netdir_getbyaddr: no results!\n");
- goto exit;
- }
- r_count = (a2h_count != 0) ? a2h_count : 1;
-
- /*
- * Allocate the return buffers. These buffers will be free'd
- * by libnsl`netdir_free(), so we need to allocate them in the
- * way that libnsl`netdir_free() expects.
- */
- if (((rp = calloc(1, sizeof (struct nd_hostservlist))) == NULL) ||
- ((hsp = calloc(1, sizeof (struct nd_hostserv) * r_count)) == NULL))
- goto malloc_fail;
-
- lxt_debug("_netdir_getbyaddr: hahaha0 - %d\n", r_count);
- rp->h_cnt = r_count;
- rp->h_hostservs = hsp;
- for (i = 0; i < r_count; i++) {
- /* If we looked up any host names copy them out. */
- lxt_debug("_netdir_getbyaddr: hahaha1 - %d\n", r_count);
- if ((a2h_count > 0) && (i == 0) &&
- ((hsp[i].h_host = strdup(a2h_result.h_name)) == NULL))
- goto malloc_fail;
-
- if ((a2h_count > 0) && (i > 0) &&
- ((hsp[i].h_host =
- strdup(a2h_result.h_aliases[i - 1])) == NULL))
- goto malloc_fail;
-
- lxt_debug("_netdir_getbyaddr: hahaha2 - %d\n", r_count);
- /* If we looked up any service names copy them out. */
- if ((p2s_count > 0) &&
- ((hsp[i].h_serv = strdup(p2s_result.s_name)) == NULL))
- goto malloc_fail;
- lxt_debug("_netdir_getbyaddr: hahaha3 - %d\n", r_count);
- }
-
- /* We're finally done. */
- lxt_debug("_netdir_getbyaddr: success\n");
- return (rp);
-
-malloc_fail:
- _nderror = ND_NOMEM;
-
-fail:
- lxt_debug("_netdir_getbyaddr: failed!\n");
-
-exit:
- if (a2h_buf == NULL)
- free(a2h_buf);
- if (p2s_buf == NULL)
- free(p2s_buf);
- if (rp == NULL)
- free(rp);
- if (hsp != NULL) {
- for (i = 0; i < r_count; i++) {
- if (hsp[i].h_host != NULL)
- free(hsp[i].h_host);
- if (hsp[i].h_serv != NULL)
- free(hsp[i].h_serv);
- }
- free(hsp);
- }
- return (NULL);
-}
-
-char *
-/* ARGSUSED */
-_taddr2uaddr(struct netconfig *netconfigp, struct netbuf *nbp)
-{
- extern char *inet_ntoa_r();
-
- struct sockaddr_in *sa;
- char tmp[RPC_INET6_MAXUADDRSIZE];
- unsigned short myport;
-
- if (netconfigp == NULL || nbp == NULL || nbp->buf == NULL) {
- _nderror = ND_BADARG;
- return (NULL);
- }
-
- if (strcmp(netconfigp->nc_protofmly, NC_INET) != 0) {
- /* we only support inet address translation */
- assert(0);
- _nderror = ND_SYSTEM;
- return (NULL);
- }
-
- /* LINTED pointer cast */
- sa = (struct sockaddr_in *)(nbp->buf);
- myport = ntohs(sa->sin_port);
- (void) inet_ntoa_r(sa->sin_addr, tmp);
-
- (void) sprintf(tmp + strlen(tmp), ".%d.%d",
- myport >> 8, myport & 255);
- return (strdup(tmp)); /* Doesn't return static data ! */
-}
-
-/*
- * _uaddr2taddr() translates a universal address back into a
- * netaddr structure. Since the universal address is a string,
- * put that into the TLI buffer (making sure to change all \ddd
- * characters back and strip off the trailing \0 character).
- */
-struct netbuf *
-/* ARGSUSED */
-_uaddr2taddr(struct netconfig *netconfigp, char *uaddr)
-{
- assert(0);
- _nderror = ND_SYSTEM;
- return (NULL);
-}
-
-/*
- * _netdir_options() is a "catch-all" routine that does
- * transport specific things. The only thing that these
- * routines have to worry about is ND_MERGEADDR.
- */
-int
-/* ARGSUSED */
-_netdir_options(struct netconfig *netconfigp, int option, int fd, void *par)
-{
- assert(0);
- _nderror = ND_SYSTEM;
- return (0);
-}
diff --git a/usr/src/lib/brand/lx/lx_nametoaddr/common/mapfile-vers b/usr/src/lib/brand/lx/lx_nametoaddr/common/mapfile-vers
deleted file mode 100644
index 3ed165195b..0000000000
--- a/usr/src/lib/brand/lx/lx_nametoaddr/common/mapfile-vers
+++ /dev/null
@@ -1,51 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-
-#
-# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-
-#
-# MAPFILE HEADER START
-#
-# WARNING: STOP NOW. DO NOT MODIFY THIS FILE.
-# Object versioning must comply with the rules detailed in
-#
-# usr/src/lib/README.mapfiles
-#
-# You should not be making modifications here until you've read the most current
-# copy of that file. If you need help, contact a gatekeeper for guidance.
-#
-# MAPFILE HEADER END
-#
-
-SUNWprivate_1.1 {
- global:
- _netdir_getbyname;
- _netdir_getbyaddr;
- _taddr2uaddr;
- _uaddr2taddr;
- _netdir_options;
-
- local:
- *;
-};
diff --git a/usr/src/lib/brand/lx/lx_nametoaddr/i386/Makefile b/usr/src/lib/brand/lx/lx_nametoaddr/i386/Makefile
deleted file mode 100644
index 67545e46cd..0000000000
--- a/usr/src/lib/brand/lx/lx_nametoaddr/i386/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-
-#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# ident "%Z%%M% %I% %E% SMI"
-#
-
-include ../Makefile.com
-
-DYNFLAGS += $(LX_THUNK)/$(MACH)/lx_thunk.so.1
-CLOBBERFILES = $(ROOTLIBDIR)/$(DYNLIB) $(ROOTLIBDIR)/$(LINTLIB)
-
-install: all $(ROOTLIBS)
diff --git a/usr/src/lib/brand/lx/lx_thunk/Makefile b/usr/src/lib/brand/lx/lx_thunk/Makefile
deleted file mode 100644
index f69dcec561..0000000000
--- a/usr/src/lib/brand/lx/lx_thunk/Makefile
+++ /dev/null
@@ -1,52 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-
-#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# ident "%Z%%M% %I% %E% SMI"
-#
-
-include ../../../Makefile.lib
-
-SUBDIRS = $(MACH)
-$(BUILD64)SUBDIRS += $(MACH64)
-
-LINT_SUBDIRS = $(MACH)
-$(BUILD64)LINT_SUBDIRS += $(MACH64)
-
-all := TARGET= all
-clean := TARGET= clean
-clobber := TARGET= clobber
-install := TARGET= install
-lint := TARGET= lint
-
-.KEEP_STATE:
-
-all install clean clobber: $(SUBDIRS)
-
-lint: $(LINT_SUBDIRS)
-
-$(SUBDIRS): FRC
- @cd $@; pwd; $(MAKE) $(TARGET)
-
-FRC:
diff --git a/usr/src/lib/brand/lx/lx_thunk/Makefile.com b/usr/src/lib/brand/lx/lx_thunk/Makefile.com
deleted file mode 100644
index 75629a6d61..0000000000
--- a/usr/src/lib/brand/lx/lx_thunk/Makefile.com
+++ /dev/null
@@ -1,74 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-
-#
-# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# ident "%Z%%M% %I% %E% SMI"
-#
-
-LIBRARY = lx_thunk.a
-VERS = .1
-
-COBJS = lx_thunk.o
-OBJECTS = $(COBJS)
-
-include ../../../../Makefile.lib
-include ../../Makefile.lx
-
-#
-# Since our name doesn't start with "lib", Makefile.lib incorrectly
-# calculates LIBNAME. Therefore, we set it here.
-#
-LIBNAME = lx_thunk
-
-MAPFILES = ../common/mapfile-vers
-MAPOPTS = $(MAPFILES:%=-M%)
-
-CSRCS = $(COBJS:%o=../common/%c)
-SRCS = $(CSRCS)
-
-SRCDIR = ../common
-UTSBASE = ../../../../../uts
-
-ASFLAGS += -P -D_ASM
-LDLIBS += -lc
-CFLAGS += $(CCVERBOSE)
-CPPFLAGS += -D_REENTRANT -I../ -I ../../lx_brand \
- -I$(UTSBASE)/common/brand/lx
-
-# lx_think.so.1 interposes on a number of libc.so.1 routines.
-DYNFLAGS += $(MAPOPTS) $(ZINTERPOSE)
-
-LIBS = $(DYNLIB)
-
-CLEANFILES = $(DYNLIB)
-ROOTLIBDIR = $(ROOT)/usr/lib/brand/lx
-ROOTLIBDIR64 = $(ROOT)/usr/lib/brand/lx/$(MACH64)
-
-.KEEP_STATE:
-
-all: $(DYNLIB)
-
-lint: $(LINTLIB) lintcheck
-
-include ../../../../Makefile.targ
diff --git a/usr/src/lib/brand/lx/lx_thunk/amd64/Makefile b/usr/src/lib/brand/lx/lx_thunk/amd64/Makefile
deleted file mode 100644
index dbb283dff1..0000000000
--- a/usr/src/lib/brand/lx/lx_thunk/amd64/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-
-#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# ident "%Z%%M% %I% %E% SMI"
-#
-
-include ../Makefile.com
-include $(SRC)/lib/Makefile.lib.64
-
-CLOBBERFILES = $(ROOTLIBDIR64)/$(DYNLIB) $(ROOTLIBDIR64)/$(LINTLIB)
-
-install: all $(ROOTLIBS64)
diff --git a/usr/src/lib/brand/lx/lx_thunk/common/lx_thunk.c b/usr/src/lib/brand/lx/lx_thunk/common/lx_thunk.c
deleted file mode 100644
index c81bae913b..0000000000
--- a/usr/src/lib/brand/lx/lx_thunk/common/lx_thunk.c
+++ /dev/null
@@ -1,1115 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-
-/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- * Copyright 2014 Joyent, Inc. All rights reserved.
- */
-
-/*
- * The BrandZ Linux thunking library.
- *
- * The interfaces defined in this file form the client side of a bridge
- * to allow native Solaris process to access Linux services. Currently
- * the Linux services that is made accessible by these interfaces here
- * are:
- * - Linux host <-> address naming services
- * - Linux service <-> port naming services
- * - Linux syslog
- *
- * Currently, to use this library it must be LD_PRELOADed into the
- * application that needs to access Linux services. Once loaded
- * Linux services are accessed by the client application in two
- * different ways:
- *
- * - Direct library calls:
- * lxt_gethostbyname_r
- * lxt_gethostbyaddr_r
- * lxt_getservbyname_r
- * lxt_getservbyport_r
- * lxt_debug
- *
- * These library functions are used by the BrandZ lx name services
- * translation library (lx_nametoaddr.so) to handle libnsl.so name
- * service requests.
- *
- * - Intercepted library calls:
- * openlog(3c)
- * syslog(3c)
- * vsyslog(3c)
- * closelog(3c)
- *
- * Via the LD_PRELOAD mechanism this library interposes itself on
- * these interfaces and when the application calls these interfaces
- * (either directly or indirectly via any libraries the program may
- * be linked against) this library intercepts the request and passes
- * it onto a Linux process to handle the request.
- *
- * Once this library receives a request that needs to be serviced by a
- * Linux process, it packs up that request and attempts to send it
- * to a doors server. The door server interfaces are defined in
- * lx_thunk_server.h. If the doors server is not running or not
- * responding, this library will attempt to spawn a new doors server
- * by forking and executing the following shell script (which runs as
- * a native /bin/sh Linux process):
- * /native/usr/lib/brand/lx/lx_thunk
- *
- * Notes:
- * - This library also intercepts the following system calls:
- * close(2) - We intercept close(2) to prevent the caller from
- * accidentally closing any of the file descriptors we
- * need to do our work.
- *
- * setppriv(2) - We intercept setppriv(2) to prevent a process
- * from dropping any of the privileges we'll need to create
- * a new lx_thunk server process and to deal with service
- * requests.
- *
- * - To facilitate the running of native Solaris programs and libraries
- * when this library is preloaded into an application it will chroot()
- * into /native. This way the Solaris application and libraries can
- * access files via their expected paths and we can avoid having to
- * either do path mapping or modifying all libraries to make them
- * aware of "/native" so that they can pre-pend it to all their
- * filesystem operations.
- *
- * - This library can only be used with processes that are initially
- * run by root in a zone. The reason is that we use the chroot()
- * system call and this requires the PRIV_PROC_CHROOT privilege,
- * which non-root users don't have.
- */
-
-#include <alloca.h>
-#include <assert.h>
-#include <dlfcn.h>
-#include <door.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <netdb.h>
-#include <netdir.h>
-#include <priv.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <strings.h>
-#include <synch.h>
-#include <sys/brand.h>
-#include <sys/fcntl.h>
-#include <sys/lx_thunk_server.h>
-#include <sys/lx_thunk.h>
-#include <sys/mman.h>
-#include <sys/priv_impl.h>
-#include <sys/stat.h>
-#include <sys/syscall.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <thread.h>
-#include <unistd.h>
-#include <sys/varargs.h>
-
-#define LXT_DOOR_DIR "/tmp"
-#define LXT_DOOR_PREFIX "lxt"
-#define LXT_MSG_MAXLEN (128 + MAXPATHLEN)
-
-#pragma init(init)
-
-typedef uintptr_t (*fp1_t)(uintptr_t);
-typedef uintptr_t (*fp3_t)(uintptr_t, uintptr_t, uintptr_t);
-
-static char *lxt_debug_path = NULL; /* debug output file path */
-static char lxt_debug_path_buf[MAXPATHLEN];
-static int debug_fd = -1;
-
-void lxt_debug(const char *msg, ...);
-
-void
-init(void)
-{
- if (getenv("LX_DEBUG") != NULL) {
-
- /* check if there's a debug log file specified */
- lxt_debug_path = getenv("LX_DEBUG_FILE");
- if (lxt_debug_path == NULL) {
- /* send all debugging output to /dev/tty */
- lxt_debug_path = "/dev/tty";
- }
-
- (void) strlcpy(lxt_debug_path_buf, lxt_debug_path,
- sizeof (lxt_debug_path_buf));
- lxt_debug_path = lxt_debug_path_buf;
-
- /*
- * Open the debugging output file. We need to open it
- * and hold it open because we're going to call chroot()
- * in just a second, so we won't be able to open it later.
- */
- if ((debug_fd = open(lxt_debug_path,
- O_WRONLY|O_APPEND|O_CREAT|O_NDELAY|O_NOCTTY,
- 0666)) != -1) {
- (void) fchmod(debug_fd, 0666);
- }
- }
- lxt_debug("lxt_init: executing native process");
-
- /*
- * Now, so that we can avoid having to do path mapping,
- * just chdir() and chroot() into /native.
- */
- if (chdir("/native") != 0) {
- lxt_debug("lxt_init(): "
- "failed to chdir to /native: %s", strerror(errno));
- exit(-1);
- }
- if (chroot("/native") != 0) {
- lxt_debug("lxt_init(): "
- "failed to chroot to /native: %s", strerror(errno));
- exit(-1);
- }
-}
-
-/*
- * Linux Thunking Interfaces - Client Side
- */
-static mutex_t lxt_door_lock = DEFAULTMUTEX;
-static int lxt_door_fd = -1;
-
-static void
-lxt_server_exec(int fifo_wr, int fifo_rd)
-{
- extern const char **environ;
- char *nullist[] = { NULL };
-
- lxt_debug("lxt_server_exec: server starting");
-
- /*
- * First we need to dup our fifos to the file descriptors
- * the brand library is expecting them to be at.
- */
-
- /* Check if the write fifo needs to be moved aside */
- if ((fifo_wr == LXT_SERVER_FIFO_RD_FD) &&
- ((fifo_wr = dup(fifo_wr)) < 0))
- return;
-
- /* Check if the read fifo needs to be moved aside */
- if ((fifo_rd == LXT_SERVER_FIFO_WR_FD) &&
- ((fifo_rd = dup(fifo_rd)) < 0))
- return;
-
- if ((fifo_wr != LXT_SERVER_FIFO_WR_FD) &&
- (dup2(fifo_wr, LXT_SERVER_FIFO_WR_FD) < 0))
- return;
- if ((fifo_rd != LXT_SERVER_FIFO_RD_FD) &&
- (dup2(fifo_rd, LXT_SERVER_FIFO_RD_FD) < 0))
- return;
-
- /*
- * We're about to execute a branded Linux process.
- * Since we've been loaded into a native Solaris process with
- * LD_PRELOAD and LD_LIBRARY_PATH we should clear these
- * variables from the environment before calling exec.
- */
- (void) unsetenv("LD_PRELOAD");
- (void) unsetenv("LD_LIBRARY_PATH");
-
- /*
- * Now we need to exec the thunk server process. This is a
- * branded Linux process that will act as a doors server and
- * service our requests to perform native Linux operations.
- * Since we're currently running as a native Solaris process,
- * to start up the server we'll use the brand system call to
- * tell the kernel that the target of the exec will be a branded
- * process.
- */
- lxt_debug("lxt_server_exec: execing as Linux process");
- (void) syscall(SYS_brand, B_EXEC_BRAND,
- LXT_SERVER_BINARY, nullist, environ);
-}
-
-
-static void *
-lxt_door_waitpid(void *arg)
-{
- pid_t child_pid = (pid_t)(uintptr_t)arg;
- int stat;
-
- (void) waitpid(child_pid, &stat, 0);
- return (NULL);
-}
-
-static char *
-lxt_door_mkfifo()
-{
- char *path;
-
- for (;;) {
- path = tempnam(LXT_DOOR_DIR, LXT_DOOR_PREFIX);
- if (path == NULL)
- return (NULL);
- if (mkfifo(path, S_IWUSR | S_IRUSR) != 0) {
- if (errno != EEXIST) {
- free(path);
- return (NULL);
- }
- /* This file path exists, pick a new name. */
- free(path);
- continue;
- }
- /* We successfully created the fifo */
- break;
- }
- return (path);
-}
-
-#define BRK_CHROOT_DIR "tmp/.brkchroot"
-
-static void
-breakout_chroot()
-{
- int i;
- struct stat sb;
-
- if (stat(BRK_CHROOT_DIR, &sb) < 0) {
- if (errno != ENOENT)
- exit(-1);
- if (mkdir(BRK_CHROOT_DIR, 0755) < 0)
- exit(-1);
- } else if (!S_ISDIR(sb.st_mode)) {
- exit(-1);
- }
-
- if (chroot(BRK_CHROOT_DIR) < 0)
- exit(-1);
-
- for (i = 0; i < 32; i++)
- chdir("..");
-
- chroot(".");
-}
-
-static void
-lxt_door_init()
-{
- char *fifo1_path = NULL, *fifo2_path = NULL;
- char fifo1_path_native[MAXPATHLEN];
- int fifo1_rd = -1, fifo1_wr = -1;
- int fifo2_rd = -1, fifo2_wr = -1;
- int junk;
- pid_t child_pid;
- thread_t tid;
-
- lxt_debug("lxt_door_init: preparint to start server");
-
- /* Create two new fifos. */
- if (((fifo1_path = lxt_door_mkfifo()) == NULL) ||
- ((fifo2_path = lxt_door_mkfifo()) == NULL))
- goto fail;
-
- (void) snprintf(fifo1_path_native, sizeof (fifo1_path_native),
- "/native%s", fifo1_path);
-
- /*
- * Open both fifos for reading and writing. We have to open
- * the read side of the fifo first (because the write side will
- * fail to open if there is no reader) and we have to use the
- * O_NONBLOCK flag (because the read open with hang without it).
- */
- if (((fifo1_rd = open(fifo1_path, O_RDONLY | O_NONBLOCK)) < 0) ||
- ((fifo1_wr = open(fifo1_path, O_WRONLY)) < 0) ||
- ((fifo2_rd = open(fifo2_path, O_RDONLY | O_NONBLOCK)) < 0) ||
- ((fifo2_wr = open(fifo2_path, O_WRONLY)) < 0))
- goto fail;
-
- /*
- * Now we have to close the read side of fifo1 and fifo2 and re-open
- * them without the O_NONBLOCK flag. This is because we're using
- * the fifos for synchronization and when we actually try to read
- * from them we want to block.
- */
- (void) close(fifo1_rd);
- if ((fifo1_rd = open(fifo1_path, O_RDONLY)) < 0)
- goto fail;
- (void) close(fifo2_rd);
- if ((fifo2_rd = open(fifo2_path, O_RDONLY)) < 0)
- goto fail;
-
- /*
- * Once fifo2 is opened no one will ever need to open it again
- * so delete it now.
- */
- (void) unlink(fifo2_path);
- free(fifo2_path);
- fifo2_path = NULL;
-
- /* Attempt to fork and start the door server */
- lxt_debug("lxt_door_init: starting server");
- switch (child_pid = fork1()) {
- case -1:
- /* fork1() failed. */
- goto fail;
- case 0:
- /* Child process - new door server. */
- (void) close(fifo1_rd);
- (void) close(fifo2_wr);
-
- /* Need to chroot back to the real root directory */
- breakout_chroot();
-
- /* Start the server */
- lxt_server_exec(fifo1_wr, fifo2_rd);
- lxt_debug("lxt_server_exec: server init failed");
- exit(-1);
- /*NOTREACHED*/
- }
- /* Parent process - door client. */
-
- /*
- * fifo2 is used to send the door path to the child.
- * (We can't simply pass it via the address space since the
- * child will need to exec.) We'll write the name of the door
- * file to fifo2 before we close the read end of the fifo2 so
- * that if the child has exited for some reason we won't get
- * a SIGPIPE. Note that we're reusing the name of fifo1 as
- * the door path. Also note that we've pre-pended /native
- * to the fifo/door path. The reason is that we're chroot'ed
- * to /native, but when the thunking server executes it will
- * be chroot'ed back to the real root directory.
- */
- (void) write(fifo2_wr,
- fifo1_path_native, strlen(fifo1_path_native) + 1);
- (void) close(fifo2_wr);
- (void) close(fifo2_rd);
-
- /*
- * Start up a thread that will perfom a waitpid() on the child
- * door server process. We do this because if the calling
- * application that is using our interfaces is forking it's own
- * children and using wait(), then it won't expect to see our
- * children. We take advantage of the fact that if there are
- * wait() and a waitpid() calls in progress at the same time
- * when a child exists, preference will be given to any
- * waitpid() calls that are explicity waiting for that child.
- * There is of course a window of time where the child could
- * exit after we've forked it but before we've called waitpid()
- * where another wait() in this process could collect the result.
- * There's nothing we can really do to prevent this short of
- * stopping all the other threads in this process.
- */
- (void) thr_create(NULL, 0,
- lxt_door_waitpid, (void *)(uintptr_t)child_pid, THR_DAEMON, &tid);
-
- /*
- * fifo1 is used for the child process to signal us that the
- * door server is ready to take requests.
- */
- (void) close(fifo1_wr);
- (void) read(fifo1_rd, &junk, 1);
- (void) close(fifo1_rd);
-
- /* If there was a door that was open, close it now. */
-
- if (lxt_door_fd >= 0)
- (void) close(lxt_door_fd);
- /*
- * The server should be started up by now and fattach()ed the door
- * server to the fifo/door path. so if we re-open that path now we
- * should get a fd to the door server.
- */
- lxt_door_fd = open(fifo1_path, O_RDWR);
-
- lxt_debug("lxt_door_init: new server door = %d", lxt_door_fd);
-
- /* We don't need the fifo/door anymore so delete it. */
- (void) unlink(fifo1_path);
- free(fifo1_path);
- return;
-
-fail:
- if (fifo1_path != NULL)
- (void) unlink(fifo1_path);
- if (fifo2_path != NULL)
- (void) unlink(fifo2_path);
- if (fifo1_rd != -1)
- (void) close(fifo1_rd);
- if (fifo1_wr != -1)
- (void) close(fifo1_wr);
- if (fifo2_rd != -1)
- (void) close(fifo2_rd);
- if (fifo2_wr != -1)
- (void) close(fifo2_wr);
-}
-
-static int
-lxt_door_call(door_arg_t *door_arg, int lock_held)
-{
- int fd;
-
- if (!lock_held)
- (void) mutex_lock(&lxt_door_lock);
-
- /* Get a copy of lxt_door_fd */
- fd = lxt_door_fd;
-
- if (!lock_held)
- (void) mutex_unlock(&lxt_door_lock);
-
- if (fd == -1) {
- lxt_debug("lxt_door_call: no door available");
- return (-1);
- }
-
- if (door_call(fd, door_arg) != 0) {
- lxt_debug("lxt_door_call: call failed");
- return (-1);
- }
- if (door_arg->rbuf == NULL) {
- lxt_debug("lxt_door_call: call returned NULL");
- return (-1);
- }
- return (0);
-}
-
-static int
-lxt_door_request(door_arg_t *door_arg)
-{
- door_arg_t door_ping;
- lxt_server_arg_t ping_request, *ping_result;
- int rv, ping_success = 0;
-
- /* First just try the door call. */
- lxt_debug("lxt_door_request: calling server");
- if (lxt_door_call(door_arg, 0) == 0)
- return (0);
-
- /* Prepare a door server ping request. */
- bzero(&door_ping, sizeof (door_ping));
- bzero(&ping_request, sizeof (ping_request));
- door_ping.data_ptr = (char *)&ping_request;
- door_ping.data_size = sizeof (ping_request);
- ping_request.lxt_sa_op = LXT_SERVER_OP_PING;
-
- (void) mutex_lock(&lxt_door_lock);
-
- /* Ping the doors server. */
- lxt_debug("lxt_door_request: pinging server");
- if (lxt_door_call(&door_ping, 1) == 0) {
- /*LINTED*/
- ping_result = (lxt_server_arg_t *)door_ping.rbuf;
- ping_success = ping_result->lxt_sa_success;
- (void) munmap(door_ping.rbuf, door_ping.rsize);
- }
-
- if (!ping_success) {
- /* The server is not responding so start up a new one. */
- lxt_door_init();
- }
- (void) mutex_unlock(&lxt_door_lock);
-
- /* Retry the original request */
- lxt_debug("lxt_door_request: calling server, retry");
- if ((rv = lxt_door_call(door_arg, 0)) == 0)
- return (0);
- return (rv);
-}
-
-static struct hostent *
-lxt_gethost(int op, const char *token, int token_len, int type,
- struct hostent *result, char *buf, int buf_len, int *h_errnop)
-{
- door_arg_t door_arg;
- lxt_gethost_arg_t *data;
- lxt_server_arg_t *request;
- int request_size, errno_tmp, i;
-
- lxt_debug("lxt_gethost: request caught");
-
- request_size = sizeof (*request) + sizeof (*data) +
- token_len + buf_len - 1;
- if ((request = calloc(1, request_size)) == NULL) {
- lxt_debug("lxt_gethost: calloc() failed");
- *h_errnop = TRY_AGAIN;
- return (NULL);
- }
- /*LINTED*/
- data = (lxt_gethost_arg_t *)&request->lxt_sa_data[0];
-
- /* Initialize the server request. */
- request->lxt_sa_op = op;
- data->lxt_gh_type = type;
- data->lxt_gh_token_len = token_len;
- data->lxt_gh_buf_len = buf_len;
- data->lxt_gh_storage_len = token_len + token_len;
- bcopy(token, &data->lxt_gh_storage[0], token_len);
-
- /* Initialize door_call() arguments. */
- bzero(&door_arg, sizeof (door_arg));
- door_arg.data_ptr = (char *)request;
- door_arg.data_size = request_size;
-
- if (lxt_door_request(&door_arg) != 0) {
- lxt_debug("lxt_gethost: door_call() failed");
- /* Don't know what caused the error so clear errno. */
- errno = 0;
- *h_errnop = ND_SYSTEM;
- free(request);
- return (NULL);
- }
-
- free(request);
-
- if (door_arg.rbuf == NULL) {
- lxt_debug("lxt_gethost: door_call() returned NULL");
- /* Don't know what caused the error so clear errno. */
- errno = 0;
- *h_errnop = ND_SYSTEM;
- return (NULL);
- }
-
- /*LINTED*/
- request = (lxt_server_arg_t *)door_arg.rbuf;
- /*LINTED*/
- data = (lxt_gethost_arg_t *)&request->lxt_sa_data[0];
-
- /* Check if the remote procedure call failed */
- if (!request->lxt_sa_success) {
- lxt_debug("lxt_gethost: remote function call failed");
- errno_tmp = request->lxt_sa_errno;
- *h_errnop = data->lxt_gh_h_errno;
- (void) munmap(door_arg.rbuf, door_arg.rsize);
- errno = errno_tmp;
- return (NULL);
- }
-
- /* Copy out the results and output buffer. */
- bcopy(&data->lxt_gh_result, result, sizeof (*result));
- bcopy(&data->lxt_gh_storage[token_len], buf, buf_len);
- (void) munmap(door_arg.rbuf, door_arg.rsize);
-
- /* Now go through the results and convert all offsets to pointers */
- result->h_name = LXT_OFFSET_TO_PTR(result->h_name, buf);
- result->h_aliases = LXT_OFFSET_TO_PTR(result->h_aliases, buf);
- result->h_addr_list = LXT_OFFSET_TO_PTR(result->h_addr_list, buf);
- for (i = 0; result->h_aliases[i] != NULL; i++) {
- result->h_aliases[i] =
- LXT_OFFSET_TO_PTR(result->h_aliases[i], buf);
- }
- for (i = 0; result->h_addr_list[i] != NULL; i++) {
- result->h_addr_list[i] =
- LXT_OFFSET_TO_PTR(result->h_addr_list[i], buf);
- }
-
- return (result);
-}
-
-static struct servent *
-lxt_getserv(int op, const char *token, const int token_len, const char *proto,
- struct servent *result, char *buf, int buf_len)
-{
- door_arg_t door_arg;
- lxt_getserv_arg_t *data;
- lxt_server_arg_t *request;
- int request_size, errno_tmp, i;
-
- lxt_debug("lxt_getserv: request caught");
-
- request_size = sizeof (*request) + sizeof (*data) +
- token_len + buf_len - 1;
- if ((request = calloc(1, request_size)) == NULL) {
- lxt_debug("lxt_getserv: calloc() failed");
- return (NULL);
- }
- /*LINTED*/
- data = (lxt_getserv_arg_t *)&request->lxt_sa_data[0];
-
- /* Initialize the server request. */
- request->lxt_sa_op = op;
- data->lxt_gs_token_len = token_len;
- data->lxt_gs_buf_len = buf_len;
- data->lxt_gs_storage_len = token_len + token_len;
- bcopy(token, &data->lxt_gs_storage[0], token_len);
-
- bzero(data->lxt_gs_proto, sizeof (data->lxt_gs_proto));
- if (proto != NULL)
- (void) strncpy(data->lxt_gs_proto, proto,
- sizeof (data->lxt_gs_proto));
-
- /* Initialize door_call() arguments. */
- bzero(&door_arg, sizeof (door_arg));
- door_arg.data_ptr = (char *)request;
- door_arg.data_size = request_size;
-
- /* Call the doors server */
- if (lxt_door_request(&door_arg) != 0) {
- lxt_debug("lxt_getserv: door_call() failed");
- /* Don't know what caused the error so clear errno */
- errno = 0;
- free(request);
- return (NULL);
- }
- free(request);
-
- if (door_arg.rbuf == NULL) {
- lxt_debug("lxt_getserv: door_call() returned NULL");
- /* Don't know what caused the error so clear errno */
- errno = 0;
- return (NULL);
- }
- /*LINTED*/
- request = (lxt_server_arg_t *)door_arg.rbuf;
- /*LINTED*/
- data = (lxt_getserv_arg_t *)&request->lxt_sa_data[0];
-
- /* Check if the remote procedure call failed */
- if (!request->lxt_sa_success) {
- lxt_debug("lxt_getserv: remote function call failed");
- errno_tmp = request->lxt_sa_errno;
- (void) munmap(door_arg.rbuf, door_arg.rsize);
- errno = errno_tmp;
- return (NULL);
- }
-
- /* Copy out the results and output buffer. */
- bcopy(&data->lxt_gs_result, result, sizeof (*result));
- bcopy(&data->lxt_gs_storage[token_len], buf, buf_len);
- (void) munmap(door_arg.rbuf, door_arg.rsize);
-
- /*
- * Now go through the results and convert all offsets to pointers.
- * See the comments in lxt_server_getserv() for why we need
- * to subtract 1 from each offset.
- */
- result->s_name = LXT_OFFSET_TO_PTR(result->s_name, buf);
- result->s_proto = LXT_OFFSET_TO_PTR(result->s_proto, buf);
- result->s_aliases = LXT_OFFSET_TO_PTR(result->s_aliases, buf);
- for (i = 0; result->s_aliases[i] != NULL; i++) {
- result->s_aliases[i] =
- LXT_OFFSET_TO_PTR(result->s_aliases[i], buf);
- }
-
- return (result);
-}
-
-static void
-lxt_openlog(const char *ident, int logopt, int facility)
-{
- door_arg_t door_arg;
- lxt_openlog_arg_t *data;
- lxt_server_arg_t *request;
- int request_size;
-
- request_size = sizeof (*request) + sizeof (*data);
- if ((request = calloc(1, request_size)) == NULL) {
- lxt_debug("lxt_openlog: calloc() failed");
- return;
- }
- /*LINTED*/
- data = (lxt_openlog_arg_t *)&request->lxt_sa_data[0];
-
- /* Initialize the server request. */
- request->lxt_sa_op = LXT_SERVER_OP_OPENLOG;
- data->lxt_ol_facility = facility;
- data->lxt_ol_logopt = logopt;
- (void) strlcpy(data->lxt_ol_ident, ident, sizeof (data->lxt_ol_ident));
-
- /* Initialize door_call() arguments. */
- bzero(&door_arg, sizeof (door_arg));
- door_arg.data_ptr = (char *)request;
- door_arg.data_size = request_size;
-
- /* Call the doors server */
- if (lxt_door_request(&door_arg) != 0) {
- lxt_debug("lxt_openlog: door_call() failed");
- free(request);
- return;
- }
- free(request);
-
- if (door_arg.rbuf == NULL) {
- lxt_debug("lxt_openlog: door_call() returned NULL");
- return;
- }
-
- /*LINTED*/
- request = (lxt_server_arg_t *)door_arg.rbuf;
-
- /* Check if the remote procedure call failed */
- if (!request->lxt_sa_success) {
- lxt_debug("lxt_openlog: remote function call failed");
- }
- (void) munmap(door_arg.rbuf, door_arg.rsize);
-}
-
-static void
-lxt_vsyslog(int priority, const char *message, va_list va)
-{
- door_arg_t door_arg;
- lxt_syslog_arg_t *data;
- lxt_server_arg_t *request;
- psinfo_t p;
- char procfile[PRFNSZ], *buf = NULL, *estr;
- int buf_len, buf_i, estr_len, request_size, procfd;
- int i, key, err_count = 0, tok_count = 0;
- int errno_backup = errno;
-
- /*
- * Here we're going to use vsnprintf() to expand the message
- * string passed in before we hand it off to a Linux process.
- * Before we can call vsnprintf() we'll need to do modify the
- * string to deal with certain special tokens.
- *
- * syslog() supports a special '%m' format token that expands to
- * the error message string associated with the current value
- * of errno. Unfortunatly if we pass this token to vsnprintf()
- * it will choke so we need to expand that token manually here.
- *
- * We also need to expand any "%%" characters into "%%%%".
- * The reason is that we'll be calling vsnprintf() which will
- * translate "%%%%" back to "%%", which is safe to pass to the
- * Linux version if syslog. If we didn't do this then vsnprintf()
- * would translate "%%" to "%" and then the Linux syslog would
- * attempt to intrepret "%" and whatever character follows it
- * as a printf format style token.
- */
- for (key = i = 0; message[i] != '\0'; i++) {
- if (!key && message[i] == '%') {
- key = 1;
- continue;
- }
- if (key && message[i] == '%')
- tok_count++;
- if (key && message[i] == 'm')
- err_count++;
- key = 0;
- }
-
- /* We found some tokens that we need to expand. */
- if (err_count || tok_count) {
- estr = strerror(errno_backup);
- estr_len = strlen(estr);
- assert(estr_len >= 2);
-
- /* Allocate a buffer to hold the expanded string. */
- buf_len = i + 1 +
- (tok_count * 2) + (err_count * (estr_len - 2));
- if ((buf = calloc(1, buf_len)) == NULL) {
- lxt_debug("lxt_vsyslog: calloc() failed");
- return;
- }
-
- /* Finally, expand %% and %m. */
- for (key = buf_i = i = 0; message[i] != '\0'; i++) {
- assert(buf_i < buf_len);
- if (!key && message[i] == '%') {
- buf[buf_i++] = '%';
- key = 1;
- continue;
- }
- if (key && message[i] == 'm') {
- (void) bcopy(estr, &buf[buf_i - 1], estr_len);
- buf_i += estr_len - 1;
- } else if (key && message[i] == '%') {
- (void) bcopy("%%%%", &buf[buf_i - 1], 4);
- buf_i += 4 - 1;
- } else {
- buf[buf_i++] = message[i];
- }
- key = 0;
- }
- assert(buf[buf_i] == '\0');
- assert(buf_i == (buf_len - 1));
-
- /* Use the expanded buffer as our format string. */
- message = buf;
- }
-
- /* Allocate the request we're going to send to the server */
- request_size = sizeof (*request) + sizeof (*data);
- if ((request = calloc(1, request_size)) == NULL) {
- lxt_debug("lxt_vsyslog: calloc() failed");
- return;
- }
-
- /*LINTED*/
- data = (lxt_syslog_arg_t *)&request->lxt_sa_data[0];
-
- /* Initialize the server request. */
- request->lxt_sa_op = LXT_SERVER_OP_SYSLOG;
- data->lxt_sl_priority = priority;
- data->lxt_sl_pid = getpid();
- (void) vsnprintf(data->lxt_sl_message, sizeof (data->lxt_sl_message),
- message, va);
-
- /* If we did token expansion then free the intermediate buffer. */
- if (err_count || tok_count)
- free(buf);
-
- /* Add the current program name into the request */
- (void) sprintf(procfile, "/proc/%u/psinfo", (int)getpid());
- /* (void) sprintf(procfile, "/native/proc/%u/psinfo", (int)getpid()); */
- if ((procfd = open(procfile, O_RDONLY)) >= 0) {
- if (read(procfd, &p, sizeof (psinfo_t)) >= 0) {
- (void) strncpy(data->lxt_sl_progname, p.pr_fname,
- sizeof (data->lxt_sl_progname));
- }
- (void) close(procfd);
- }
-
- /* Initialize door_call() arguments. */
- bzero(&door_arg, sizeof (door_arg));
- door_arg.data_ptr = (char *)request;
- door_arg.data_size = request_size;
-
- /* Call the doors server */
- if (lxt_door_request(&door_arg) != 0) {
- lxt_debug("lxt_vsyslog: door_call() failed");
- free(request);
- return;
- }
- free(request);
-
- if (door_arg.rbuf == NULL) {
- lxt_debug("lxt_vsyslog: door_call() returned NULL");
- return;
- }
-
- /*LINTED*/
- request = (lxt_server_arg_t *)door_arg.rbuf;
-
- /* Check if the remote procedure call failed */
- if (!request->lxt_sa_success) {
- lxt_debug("lxt_vsyslog: remote function call failed");
- }
- (void) munmap(door_arg.rbuf, door_arg.rsize);
-}
-
-static void
-lxt_closelog(void)
-{
- door_arg_t door_arg;
- lxt_server_arg_t *request;
- int request_size;
-
- request_size = sizeof (*request);
- if ((request = calloc(1, request_size)) == NULL) {
- lxt_debug("lxt_closelog: calloc() failed");
- return;
- }
-
- /* Initialize the server request. */
- request->lxt_sa_op = LXT_SERVER_OP_CLOSELOG;
-
- /* Initialize door_call() arguments. */
- bzero(&door_arg, sizeof (door_arg));
- door_arg.data_ptr = (char *)request;
- door_arg.data_size = request_size;
-
- /* Call the doors server */
- if (lxt_door_request(&door_arg) != 0) {
- lxt_debug("lxt_closelog: door_call() failed");
- free(request);
- return;
- }
- free(request);
-
- if (door_arg.rbuf == NULL) {
- lxt_debug("lxt_closelog: door_call() returned NULL");
- return;
- }
-
- /*LINTED*/
- request = (lxt_server_arg_t *)door_arg.rbuf;
-
- /* Check if the remote procedure call failed */
- if (!request->lxt_sa_success) {
- lxt_debug("lxt_closelog: remote function call failed");
- }
- (void) munmap(door_arg.rbuf, door_arg.rsize);
-}
-
-static void
-lxt_pset_keep(priv_op_t op, priv_ptype_t type, priv_set_t *pset,
- const char *priv)
-{
- if (priv_ismember(pset, priv) == B_TRUE) {
- if (op == PRIV_OFF) {
- (void) priv_delset(pset, priv);
- lxt_debug("lxt_pset_keep: "
- "preventing drop of \"%s\" from \"%s\" set",
- priv, type);
- }
- } else {
- if (op == PRIV_SET) {
- (void) priv_addset(pset, priv);
- lxt_debug("lxt_pset_keep: "
- "preventing drop of \"%s\" from \"%s\" set",
- priv, type);
- }
- }
-}
-
-/*
- * Public interfaces - used by lx_nametoaddr
- */
-void
-lxt_vdebug(const char *msg, va_list va)
-{
- char buf[LXT_MSG_MAXLEN + 1];
- int rv, n;
-
- if (debug_fd == -1)
- return;
-
- /* Prefix the message with pid/tid. */
- if ((n = snprintf(buf, sizeof (buf), "%u/%u: ",
- getpid(), thr_self())) == -1)
- return;
-
- /* Format the message. */
- if (vsnprintf(&buf[n], sizeof (buf) - n, msg, va) == -1)
- return;
-
- /* Add a carrige return if there isn't one already. */
- if ((buf[strlen(buf) - 1] != '\n') &&
- (strlcat(buf, "\n", sizeof (buf)) >= sizeof (buf)))
- return;
-
- /* We retry in case of EINTR */
- do {
- rv = write(debug_fd, buf, strlen(buf));
- } while ((rv == -1) && (errno == EINTR));
-}
-
-void
-lxt_debug(const char *msg, ...)
-{
- va_list va;
- int errno_backup;
-
- if (debug_fd == -1)
- return;
-
- errno_backup = errno;
- va_start(va, msg);
- lxt_vdebug(msg, va);
- va_end(va);
- errno = errno_backup;
-}
-
-struct hostent *
-lxt_gethostbyaddr_r(const char *addr, int addr_len, int type,
- struct hostent *result, char *buf, int buf_len, int *h_errnop)
-{
- lxt_debug("lxt_gethostbyaddr_r: request recieved");
- return (lxt_gethost(LXT_SERVER_OP_ADDR2HOST,
- addr, addr_len, type, result, buf, buf_len, h_errnop));
-}
-
-struct hostent *
-lxt_gethostbyname_r(const char *name,
- struct hostent *result, char *buf, int buf_len, int *h_errnop)
-{
- lxt_debug("lxt_gethostbyname_r: request recieved");
- return (lxt_gethost(LXT_SERVER_OP_NAME2HOST,
- name, strlen(name) + 1, 0, result, buf, buf_len, h_errnop));
-}
-
-struct servent *
-lxt_getservbyport_r(int port, const char *proto,
- struct servent *result, char *buf, int buf_len)
-{
- lxt_debug("lxt_getservbyport_r: request recieved");
- return (lxt_getserv(LXT_SERVER_OP_PORT2SERV,
- (const char *)&port, sizeof (int), proto, result, buf, buf_len));
-}
-
-struct servent *
-lxt_getservbyname_r(const char *name, const char *proto,
- struct servent *result, char *buf, int buf_len)
-{
- lxt_debug("lxt_getservbyname_r: request recieved");
- return (lxt_getserv(LXT_SERVER_OP_NAME2SERV,
- name, strlen(name) + 1, proto, result, buf, buf_len));
-}
-
-/*
- * "Public" interfaces - used to override public existing interfaces
- */
-int
-_setppriv(priv_op_t op, priv_ptype_t type, const priv_set_t *pset)
-{
- static fp3_t fp = NULL;
- priv_set_t *pset_new;
- int rv;
-
- lxt_debug("_setppriv: request caught");
-
- if (fp == NULL)
- fp = (fp3_t)dlsym(RTLD_NEXT, "_setppriv");
-
- while ((pset_new = priv_allocset()) == NULL)
- (void) sleep(1);
-
- priv_copyset(pset, pset_new);
- lxt_pset_keep(op, type, pset_new, PRIV_PROC_EXEC);
- lxt_pset_keep(op, type, pset_new, PRIV_PROC_FORK);
- lxt_pset_keep(op, type, pset_new, PRIV_PROC_CHROOT);
- lxt_pset_keep(op, type, pset_new, PRIV_FILE_DAC_READ);
- lxt_pset_keep(op, type, pset_new, PRIV_FILE_DAC_WRITE);
- lxt_pset_keep(op, type, pset_new, PRIV_FILE_DAC_SEARCH);
-
- rv = fp(op, (uintptr_t)type, (uintptr_t)pset_new);
- priv_freeset(pset_new);
- return (rv);
-}
-
-void
-openlog(const char *ident, int logopt, int facility)
-{
- lxt_debug("openlog: request caught");
- lxt_openlog(ident, logopt, facility);
-}
-
-void
-syslog(int priority, const char *message, ...)
-{
- va_list va;
-
- lxt_debug("syslog: request caught");
- va_start(va, message);
- lxt_vsyslog(priority, message, va);
- va_end(va);
-}
-
-void
-vsyslog(int priority, const char *message, va_list va)
-{
- lxt_debug("vsyslog: request caught");
- lxt_vsyslog(priority, message, va);
-}
-
-void
-closelog(void)
-{
- lxt_debug("closelog: request caught");
- lxt_closelog();
-}
diff --git a/usr/src/lib/brand/lx/lx_thunk/common/mapfile-vers b/usr/src/lib/brand/lx/lx_thunk/common/mapfile-vers
deleted file mode 100644
index fc245c3360..0000000000
--- a/usr/src/lib/brand/lx/lx_thunk/common/mapfile-vers
+++ /dev/null
@@ -1,57 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-
-#
-# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-
-#
-# MAPFILE HEADER START
-#
-# WARNING: STOP NOW. DO NOT MODIFY THIS FILE.
-# Object versioning must comply with the rules detailed in
-#
-# usr/src/lib/README.mapfiles
-#
-# You should not be making modifications here until you've read the most current
-# copy of that file. If you need help, contact a gatekeeper for guidance.
-#
-# MAPFILE HEADER END
-#
-
-SUNWprivate_1.1 {
- global:
- lxt_vdebug;
- lxt_debug;
- lxt_gethostbyaddr_r;
- lxt_gethostbyname_r;
- lxt_getservbyport_r;
- lxt_getservbyname_r;
- _setppriv;
- openlog;
- syslog;
- vsyslog;
- closelog;
-
- local:
- *;
-};
diff --git a/usr/src/lib/brand/lx/lx_thunk/i386/Makefile b/usr/src/lib/brand/lx/lx_thunk/i386/Makefile
deleted file mode 100644
index c4b6c71027..0000000000
--- a/usr/src/lib/brand/lx/lx_thunk/i386/Makefile
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-
-#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# ident "%Z%%M% %I% %E% SMI"
-#
-
-include ../Makefile.com
-
-CLOBBERFILES = $(ROOTLIBDIR)/$(DYNLIB) $(ROOTLIBDIR)/$(LINTLIB)
-
-install: all $(ROOTLIBS)
diff --git a/usr/src/lib/brand/lx/lx_thunk/sys/lx_thunk.h b/usr/src/lib/brand/lx/lx_thunk/sys/lx_thunk.h
deleted file mode 100644
index b19c91873a..0000000000
--- a/usr/src/lib/brand/lx/lx_thunk/sys/lx_thunk.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-
-/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _LX_THUNK_H
-#define _LX_THUNK_H
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct hostent *lxt_gethostbyaddr_r(const char *addr, int addr_len, int type,
- struct hostent *result, char *buf, int buf_len, int *h_errnop);
-struct hostent *lxt_gethostbyname_r(const char *name,
- struct hostent *result, char *buf, int buf_len, int *h_errnop);
-struct servent *lxt_getservbyport_r(int port, const char *proto,
- struct servent *result, char *buf, int buf_len);
-struct servent *lxt_getservbyname_r(const char *name, const char *proto,
- struct servent *result, char *buf, int buf_len);
-
-void openlog(const char *ident, int logopt, int facility);
-void syslog(int priority, const char *message, ...);
-void closelog(void);
-
-void lxt_debug(const char *msg, ...);
-void lxt_vdebug(const char *msg, va_list va);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _LX_THUNK_H */
diff --git a/usr/src/lib/brand/lx/netfiles/Makefile b/usr/src/lib/brand/lx/netfiles/Makefile
index 47be18db0f..1d15d69850 100644
--- a/usr/src/lib/brand/lx/netfiles/Makefile
+++ b/usr/src/lib/brand/lx/netfiles/Makefile
@@ -22,11 +22,10 @@
#
# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
-#
-# ident "%Z%%M% %I% %E% SMI"
+# Copyright 2015 Joyent, Inc.
#
-TXTS = etc_netconfig etc_default_nfs
+TXTS = etc_default_nfs
NFS_DFL = ../../../../cmd/fs.d/nfs/etc/nfs.dfl
all: $(TXTS)
diff --git a/usr/src/lib/brand/lx/netfiles/etc_netconfig b/usr/src/lib/brand/lx/netfiles/etc_netconfig
deleted file mode 100644
index 56222abf56..0000000000
--- a/usr/src/lib/brand/lx/netfiles/etc_netconfig
+++ /dev/null
@@ -1,38 +0,0 @@
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# ident "%Z%%M% %I% %E% SMI"
-#
-# The "Network Configuration" File.
-#
-# Each entry is of the form:
-#
-# <network_id> <semantics> <flags> <protofamily> <protoname> \
-# <device> <nametoaddr_libs>
-#
-# For running solaris daemons in a linux zone we use this non-default
-# /etc/netconfig. The reason is that all name resolution has to be
-# done linux name service interfaces. To do this we specify a custom
-# nametoaddr library that libnsl will invoke to do name service lookups.
-#
-udp tpi_clts v inet udp /dev/udp lx_nametoaddr.so.1
-tcp tpi_cots_ord v inet tcp /dev/tcp lx_nametoaddr.so.1
diff --git a/usr/src/pkg/manifests/system-zones-brand-lx.mf b/usr/src/pkg/manifests/system-zones-brand-lx.mf
index 38bd9de73d..58a016fa9c 100644
--- a/usr/src/pkg/manifests/system-zones-brand-lx.mf
+++ b/usr/src/pkg/manifests/system-zones-brand-lx.mf
@@ -81,8 +81,6 @@ file path=usr/kernel/fs/lx_proc group=sys mode=0755
file path=usr/kernel/strmod/$(ARCH64)/ldlinux group=sys mode=0755
file path=usr/kernel/strmod/ldlinux group=sys mode=0755
file path=usr/lib/brand/lx/$(ARCH64)/lx_librtld_db.so.1
-file path=usr/lib/brand/lx/$(ARCH64)/lx_nametoaddr.so.1
-file path=usr/lib/brand/lx/$(ARCH64)/lx_thunk.so.1
file path=usr/lib/brand/lx/config.xml mode=0444
file path=usr/lib/brand/lx/distros/centos35.distro mode=0444
file path=usr/lib/brand/lx/distros/centos36.distro mode=0444
@@ -94,7 +92,6 @@ file path=usr/lib/brand/lx/distros/rhel37.distro mode=0444
file path=usr/lib/brand/lx/distros/rhel38.distro mode=0444
file path=usr/lib/brand/lx/distros/rhel_centos_common mode=0444
file path=usr/lib/brand/lx/etc_default_nfs group=sys mode=0444
-file path=usr/lib/brand/lx/etc_netconfig group=sys mode=0444
file path=usr/lib/brand/lx/lx_distro_install mode=0755
file path=usr/lib/brand/lx/lxinit mode=0755
file path=usr/lib/brand/lx/lx_init_zone mode=0755
@@ -102,13 +99,8 @@ file path=usr/lib/brand/lx/lx_init_zone_debian mode=0755
file path=usr/lib/brand/lx/lx_init_zone_redhat mode=0755
file path=usr/lib/brand/lx/lx_install mode=0755
file path=usr/lib/brand/lx/lx_librtld_db.so.1
-file path=usr/lib/brand/lx/lx_lockd mode=0755
-file path=usr/lib/brand/lx/lx_nametoaddr.so.1
file path=usr/lib/brand/lx/lx_native mode=0755
-file path=usr/lib/brand/lx/lx_statd mode=0755
file path=usr/lib/brand/lx/lx_support mode=0755
-file path=usr/lib/brand/lx/lx_thunk mode=0755
-file path=usr/lib/brand/lx/lx_thunk.so.1
file path=usr/lib/brand/lx/platform.xml mode=0444
file path=usr/lib/devfsadm/linkmod/SUNW_lx_link_$(ARCH).so group=sys
file path=usr/lib/lx_brand.so.1