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  * $FreeBSD: releng/5.0/sys/i386/ibcs2/ibcs2_other.c 91415 2002-02-27 19:09:30Z jhb $
   25  */
   26 
   27 /*
   28  * IBCS2 compatibility module.
   29  */
   30 
   31 #include "opt_spx_hack.h"
   32 
   33 #include <sys/param.h>
   34 #include <sys/systm.h>
   35 #include <sys/lock.h>
   36 #include <sys/mutex.h>
   37 #include <sys/sysproto.h>
   38 
   39 #include <i386/ibcs2/ibcs2_types.h>
   40 #include <i386/ibcs2/ibcs2_signal.h>
   41 #include <i386/ibcs2/ibcs2_util.h>
   42 #include <i386/ibcs2/ibcs2_proto.h>
   43 
   44 #define IBCS2_SECURE_GETLUID 1
   45 #define IBCS2_SECURE_SETLUID 2
   46 
   47 int
   48 ibcs2_secure(struct thread *td, struct ibcs2_secure_args *uap)
   49 {
   50         switch (uap->cmd) {
   51 
   52         case IBCS2_SECURE_GETLUID:              /* get login uid */
   53                 td->td_retval[0] = td->td_ucred->cr_uid;
   54                 return 0;
   55 
   56         case IBCS2_SECURE_SETLUID:              /* set login uid */
   57                 return EPERM;
   58 
   59         default:
   60                 printf("IBCS2: 'secure' cmd=%d not implemented\n", uap->cmd);
   61         }
   62 
   63         return EINVAL;
   64 }
   65 
   66 int
   67 ibcs2_lseek(struct thread *td, register struct ibcs2_lseek_args *uap)
   68 {
   69         struct lseek_args largs;
   70         int error;
   71 
   72         largs.fd = uap->fd;
   73         largs.offset = uap->offset;
   74         largs.whence = uap->whence;
   75         error = lseek(td, &largs);
   76         return (error);
   77 }
   78 
   79 #ifdef SPX_HACK
   80 #include <sys/socket.h>
   81 #include <sys/un.h>     
   82 
   83 int
   84 spx_open(struct thread *td, void *uap)
   85 {
   86         struct socket_args sock;
   87         struct connect_args conn;
   88         struct sockaddr_un *Xaddr;
   89         int fd, error;
   90         caddr_t sg = stackgap_init();
   91 
   92         /* obtain a socket. */
   93         DPRINTF(("SPX: open socket\n"));
   94         sock.domain = AF_UNIX;
   95         sock.type = SOCK_STREAM;
   96         sock.protocol = 0;
   97         error = socket(td, &sock);
   98         if (error)
   99                 return error;
  100 
  101         /* connect the socket to standard X socket */
  102         DPRINTF(("SPX: connect to /tmp/X11-unix/X0\n"));
  103         Xaddr = stackgap_alloc(&sg, sizeof(struct sockaddr_un));
  104         Xaddr->sun_family = AF_UNIX;
  105         Xaddr->sun_len = sizeof(struct sockaddr_un) - sizeof(Xaddr->sun_path) +
  106           strlen(Xaddr->sun_path) + 1;
  107         copyout("/tmp/.X11-unix/X0", Xaddr->sun_path, 18);
  108 
  109         conn.s = fd = td->td_retval[0];
  110         conn.name = (caddr_t)Xaddr;
  111         conn.namelen = sizeof(struct sockaddr_un);
  112         error = connect(td, &conn);
  113         if (error) {
  114                 struct close_args cl;
  115                 cl.fd = fd;
  116                 close(td, &cl);
  117                 return error;
  118         }
  119         td->td_retval[0] = fd;
  120         return 0;
  121 }
  122 #endif /* SPX_HACK */

Cache object: ad27f5afecd27b77c7d258e3ce8dfba4


[ 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.