The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/i386/ibcs2/ibcs2_other.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    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: src/sys/i386/ibcs2/ibcs2_other.c,v 1.15.4.1 2005/01/31 23:26:03 imp Exp $");
   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/sysproto.h>
   39 
   40 #include <i386/ibcs2/ibcs2_types.h>
   41 #include <i386/ibcs2/ibcs2_signal.h>
   42 #include <i386/ibcs2/ibcs2_util.h>
   43 #include <i386/ibcs2/ibcs2_proto.h>
   44 
   45 #define IBCS2_SECURE_GETLUID 1
   46 #define IBCS2_SECURE_SETLUID 2
   47 
   48 int
   49 ibcs2_secure(struct thread *td, struct ibcs2_secure_args *uap)
   50 {
   51         switch (uap->cmd) {
   52 
   53         case IBCS2_SECURE_GETLUID:              /* get login uid */
   54                 td->td_retval[0] = td->td_ucred->cr_uid;
   55                 return 0;
   56 
   57         case IBCS2_SECURE_SETLUID:              /* set login uid */
   58                 return EPERM;
   59 
   60         default:
   61                 printf("IBCS2: 'secure' cmd=%d not implemented\n", uap->cmd);
   62         }
   63 
   64         return EINVAL;
   65 }
   66 
   67 int
   68 ibcs2_lseek(struct thread *td, register struct ibcs2_lseek_args *uap)
   69 {
   70         struct lseek_args largs;
   71         int error;
   72 
   73         largs.fd = uap->fd;
   74         largs.offset = uap->offset;
   75         largs.whence = uap->whence;
   76         error = lseek(td, &largs);
   77         return (error);
   78 }
   79 
   80 #ifdef SPX_HACK
   81 #include <sys/socket.h>
   82 #include <sys/un.h>     
   83 
   84 int
   85 spx_open(struct thread *td, void *uap)
   86 {
   87         struct socket_args sock;
   88         struct connect_args conn;
   89         struct sockaddr_un *Xaddr;
   90         int fd, error;
   91         caddr_t sg = stackgap_init();
   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 = socket(td, &sock);
   99         if (error)
  100                 return error;
  101 
  102         /* connect the socket to standard X socket */
  103         DPRINTF(("SPX: connect to /tmp/X11-unix/X0\n"));
  104         Xaddr = stackgap_alloc(&sg, sizeof(struct sockaddr_un));
  105         Xaddr->sun_family = AF_UNIX;
  106         Xaddr->sun_len = sizeof(struct sockaddr_un) - sizeof(Xaddr->sun_path) +
  107           strlen(Xaddr->sun_path) + 1;
  108         copyout("/tmp/.X11-unix/X0", Xaddr->sun_path, 18);
  109 
  110         conn.s = fd = td->td_retval[0];
  111         conn.name = (caddr_t)Xaddr;
  112         conn.namelen = sizeof(struct sockaddr_un);
  113         error = connect(td, &conn);
  114         if (error) {
  115                 struct close_args cl;
  116                 cl.fd = fd;
  117                 close(td, &cl);
  118                 return error;
  119         }
  120         td->td_retval[0] = fd;
  121         return 0;
  122 }
  123 #endif /* SPX_HACK */

Cache object: d9b4095320b36fb80b3bac6228c735a8


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.