No empty .Rs/.Re
[netbsd-mini2440.git] / sys / compat / osf1 / osf1_prot.c
blobbb14486b8ca88c89d4ebbd46ed32018b537fde73
1 /* $NetBSD: osf1_prot.c,v 1.12 2007/12/08 18:36:21 dsl Exp $ */
3 /*
4 * Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by Christopher G. Demetriou
17 * for the NetBSD Project.
18 * 4. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 * Copyright (c) 1994, 1995 Carnegie-Mellon University.
35 * All rights reserved.
37 * Author: Chris G. Demetriou
39 * Permission to use, copy, modify and distribute this software and
40 * its documentation is hereby granted, provided that both the copyright
41 * notice and this permission notice appear in all copies of the
42 * software, derivative works or modified versions, and any portions
43 * thereof, and that both notices appear in supporting documentation.
45 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
46 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
47 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
49 * Carnegie Mellon requests users of this software to return to
51 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
52 * School of Computer Science
53 * Carnegie Mellon University
54 * Pittsburgh PA 15213-3890
56 * any improvements or extensions that they make and grant Carnegie the
57 * rights to redistribute these changes.
60 #include <sys/cdefs.h>
61 __KERNEL_RCSID(0, "$NetBSD: osf1_prot.c,v 1.12 2007/12/08 18:36:21 dsl Exp $");
63 #include <sys/param.h>
64 #include <sys/systm.h>
65 #include <sys/proc.h>
66 #include <sys/prot.h>
67 #include <sys/mount.h>
68 #include <sys/syscallargs.h>
70 #include <compat/osf1/osf1.h>
71 #include <compat/osf1/osf1_syscallargs.h>
72 #include <compat/osf1/osf1_cvt.h>
75 * OSF/1 defines _POSIX_SAVED_IDS, which means that our normal
76 * setgid() won't work.
78 * If you change "uid" to "gid" in the discussion, below, about
79 * setuid(), you'll get a correct description of setgid().
81 int
82 osf1_sys_setgid(struct lwp *l, const struct osf1_sys_setgid_args *uap, register_t *retval)
84 gid_t gid = SCARG(uap, gid);
85 int error;
87 error = do_setresgid(l, gid, gid, gid, 0);
88 if (error != 0)
89 error = do_setresgid(l, -1, gid, -1, ID_E_EQ_R | ID_E_EQ_S );
90 return error;
94 * OSF/1 defines _POSIX_SAVED_IDS, which means that our normal
95 * setuid() won't work.
97 * Instead, by P1003.1b-1993, setuid() is supposed to work like:
98 * If the process has appropriate [super-user] privileges, the
99 * setuid() function sets the real user ID, effective user
100 * ID, and the saved set-user-ID to uid.
101 * If the process does not have appropriate privileges, but uid
102 * is equal to the real user ID or the saved set-user-ID, the
103 * setuid() function sets the effective user ID to uid; the
104 * real user ID and saved set-user-ID remain unchanged by
105 * this function call.
108 osf1_sys_setuid(struct lwp *l, const struct osf1_sys_setuid_args *uap, register_t *retval)
110 uid_t uid = SCARG(uap, uid);
111 int error;
113 error = do_setresuid(l, uid, uid, uid, 0);
114 if (error != 0)
115 error = do_setresuid(l, -1, uid, -1, ID_E_EQ_R | ID_E_EQ_S );
116 return error;