1/*- 2 * Copyright (c) 1995 Steven Wallace 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. The name of the author may not be used to endorse or promote products 11 * derived from this software without specific prior written permission 12 * 13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 15 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 16 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 17 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 19 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 20 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 */ 24 25#include <sys/cdefs.h> 26__FBSDID("$FreeBSD$"); 27 28/* 29 * IBCS2 compatibility module. 30 */ 31 32#include "opt_spx_hack.h" 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/lock.h> 37#include <sys/mutex.h> 38#include <sys/syscallsubr.h> 39#include <sys/sysproto.h> 40#include <sys/un.h> 41 42#include <i386/ibcs2/ibcs2_types.h> 43#include <i386/ibcs2/ibcs2_signal.h> 44#include <i386/ibcs2/ibcs2_util.h> 45#include <i386/ibcs2/ibcs2_proto.h> 46 47#define IBCS2_SECURE_GETLUID 1 48#define IBCS2_SECURE_SETLUID 2 49 50int 51ibcs2_secure(struct thread *td, struct ibcs2_secure_args *uap) 52{ 53 switch (uap->cmd) { 54 55 case IBCS2_SECURE_GETLUID: /* get login uid */ 56 td->td_retval[0] = td->td_ucred->cr_uid; 57 return 0; 58 59 case IBCS2_SECURE_SETLUID: /* set login uid */ 60 return EPERM; 61 62 default: 63 printf("IBCS2: 'secure' cmd=%d not implemented\n", uap->cmd); 64 } 65 66 return EINVAL; 67} 68 69int 70ibcs2_lseek(struct thread *td, register struct ibcs2_lseek_args *uap) 71{ 72 struct lseek_args largs; 73 int error; 74 75 largs.fd = uap->fd; 76 largs.offset = uap->offset; 77 largs.whence = uap->whence; 78 error = sys_lseek(td, &largs); 79 return (error); 80} 81 82#ifdef SPX_HACK 83#include <sys/socket.h> 84#include <sys/un.h> 85 86int 87spx_open(struct thread *td) 88{ 89 struct socket_args sock; 90 struct sockaddr_un sun; 91 int fd, error; 92 93 /* obtain a socket. */ 94 DPRINTF(("SPX: open socket\n")); 95 sock.domain = AF_UNIX; 96 sock.type = SOCK_STREAM; 97 sock.protocol = 0; 98 error = sys_socket(td, &sock); 99 if (error) 100 return error; 101 fd = td->td_retval[0]; 102 103 /* connect the socket to standard X socket */ 104 DPRINTF(("SPX: connect to /tmp/X11-unix/X0\n")); 105 sun.sun_family = AF_UNIX; 106 strcpy(sun.sun_path, "/tmp/.X11-unix/X0"); 107 sun.sun_len = sizeof(struct sockaddr_un) - sizeof(sun.sun_path) + 108 strlen(sun.sun_path) + 1; 109 110 error = kern_connect(td, fd, (struct sockaddr *)&sun); 111 if (error) { 112 kern_close(td, fd); 113 return error; 114 } 115 td->td_retval[0] = fd; 116 return 0; 117} 118#endif /* SPX_HACK */ 119