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

Cache object: 119c7d46503b46e97707a27efd6b65ea


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