Deleted Added
full compact
ibcs2_other.c (76166) ibcs2_other.c (83366)
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

--- 7 unchanged lines hidden (view full) ---

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 *
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

--- 7 unchanged lines hidden (view full) ---

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: head/sys/i386/ibcs2/ibcs2_other.c 76166 2001-05-01 08:13:21Z markm $
24 * $FreeBSD: head/sys/i386/ibcs2/ibcs2_other.c 83366 2001-09-12 08:38:13Z julian $
25 */
26
27/*
28 * IBCS2 compatibility module.
29 */
30
31#include "opt_spx_hack.h"
32

--- 7 unchanged lines hidden (view full) ---

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
47int
25 */
26
27/*
28 * IBCS2 compatibility module.
29 */
30
31#include "opt_spx_hack.h"
32

--- 7 unchanged lines hidden (view full) ---

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
47int
48ibcs2_secure(struct proc *p, struct ibcs2_secure_args *uap)
48ibcs2_secure(struct thread *td, struct ibcs2_secure_args *uap)
49{
50 switch (uap->cmd) {
51
52 case IBCS2_SECURE_GETLUID: /* get login uid */
49{
50 switch (uap->cmd) {
51
52 case IBCS2_SECURE_GETLUID: /* get login uid */
53 PROC_LOCK(p);
54 p->p_retval[0] = p->p_ucred->cr_uid;
55 PROC_UNLOCK(p);
53 PROC_LOCK(td->td_proc);
54 td->td_retval[0] = td->td_proc->p_ucred->cr_uid;
55 PROC_UNLOCK(td->td_proc);
56 return 0;
57
58 case IBCS2_SECURE_SETLUID: /* set login uid */
59 return EPERM;
60
61 default:
62 printf("IBCS2: 'secure' cmd=%d not implemented\n", uap->cmd);
63 }
64
65 return EINVAL;
66}
67
68int
56 return 0;
57
58 case IBCS2_SECURE_SETLUID: /* set login uid */
59 return EPERM;
60
61 default:
62 printf("IBCS2: 'secure' cmd=%d not implemented\n", uap->cmd);
63 }
64
65 return EINVAL;
66}
67
68int
69ibcs2_lseek(struct proc *p, register struct ibcs2_lseek_args *uap)
69ibcs2_lseek(struct thread *td, register struct ibcs2_lseek_args *uap)
70{
71 struct lseek_args largs;
72 int error;
73
74 largs.fd = uap->fd;
75 largs.offset = uap->offset;
76 largs.whence = uap->whence;
70{
71 struct lseek_args largs;
72 int error;
73
74 largs.fd = uap->fd;
75 largs.offset = uap->offset;
76 largs.whence = uap->whence;
77 error = lseek(p, &largs);
77 error = lseek(td, &largs);
78 return (error);
79}
80
81#ifdef SPX_HACK
82#include <sys/socket.h>
83#include <sys/un.h>
84
85int
78 return (error);
79}
80
81#ifdef SPX_HACK
82#include <sys/socket.h>
83#include <sys/un.h>
84
85int
86spx_open(struct proc *p, void *uap)
86spx_open(struct thread *td, void *uap)
87{
88 struct socket_args sock;
89 struct connect_args conn;
90 struct sockaddr_un *Xaddr;
91 int fd, error;
92 caddr_t sg = stackgap_init();
93
94 /* obtain a socket. */
95 DPRINTF(("SPX: open socket\n"));
96 sock.domain = AF_UNIX;
97 sock.type = SOCK_STREAM;
98 sock.protocol = 0;
87{
88 struct socket_args sock;
89 struct connect_args conn;
90 struct sockaddr_un *Xaddr;
91 int fd, error;
92 caddr_t sg = stackgap_init();
93
94 /* obtain a socket. */
95 DPRINTF(("SPX: open socket\n"));
96 sock.domain = AF_UNIX;
97 sock.type = SOCK_STREAM;
98 sock.protocol = 0;
99 error = socket(p, &sock);
99 error = socket(td, &sock);
100 if (error)
101 return error;
102
103 /* connect the socket to standard X socket */
104 DPRINTF(("SPX: connect to /tmp/X11-unix/X0\n"));
105 Xaddr = stackgap_alloc(&sg, sizeof(struct sockaddr_un));
106 Xaddr->sun_family = AF_UNIX;
107 Xaddr->sun_len = sizeof(struct sockaddr_un) - sizeof(Xaddr->sun_path) +
108 strlen(Xaddr->sun_path) + 1;
109 copyout("/tmp/.X11-unix/X0", Xaddr->sun_path, 18);
110
100 if (error)
101 return error;
102
103 /* connect the socket to standard X socket */
104 DPRINTF(("SPX: connect to /tmp/X11-unix/X0\n"));
105 Xaddr = stackgap_alloc(&sg, sizeof(struct sockaddr_un));
106 Xaddr->sun_family = AF_UNIX;
107 Xaddr->sun_len = sizeof(struct sockaddr_un) - sizeof(Xaddr->sun_path) +
108 strlen(Xaddr->sun_path) + 1;
109 copyout("/tmp/.X11-unix/X0", Xaddr->sun_path, 18);
110
111 conn.s = fd = p->p_retval[0];
111 conn.s = fd = td->td_retval[0];
112 conn.name = (caddr_t)Xaddr;
113 conn.namelen = sizeof(struct sockaddr_un);
112 conn.name = (caddr_t)Xaddr;
113 conn.namelen = sizeof(struct sockaddr_un);
114 error = connect(p, &conn);
114 error = connect(td, &conn);
115 if (error) {
116 struct close_args cl;
117 cl.fd = fd;
115 if (error) {
116 struct close_args cl;
117 cl.fd = fd;
118 close(p, &cl);
118 close(td, &cl);
119 return error;
120 }
119 return error;
120 }
121 p->p_retval[0] = fd;
121 td->td_retval[0] = fd;
122 return 0;
123}
124#endif /* SPX_HACK */
122 return 0;
123}
124#endif /* SPX_HACK */