Deleted Added
full compact
kern_prot.c (92987) kern_prot.c (93264)
1/*
2 * Copyright (c) 1982, 1986, 1989, 1990, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

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

32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 *
39 * @(#)kern_prot.c 8.6 (Berkeley) 1/21/94
1/*
2 * Copyright (c) 1982, 1986, 1989, 1990, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

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

32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 *
39 * @(#)kern_prot.c 8.6 (Berkeley) 1/21/94
40 * $FreeBSD: head/sys/kern/kern_prot.c 92987 2002-03-22 22:32:04Z jhb $
40 * $FreeBSD: head/sys/kern/kern_prot.c 93264 2002-03-27 05:39:23Z dillon $
41 */
42
43/*
44 * System calls related to processes and protection
45 */
46
47#include "opt_compat.h"
48

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

333 td->td_retval[0] = cred->cr_ngroups;
334 return (0);
335 }
336 if (ngrp < cred->cr_ngroups)
337 return (EINVAL);
338 ngrp = cred->cr_ngroups;
339 error = copyout((caddr_t)cred->cr_groups, (caddr_t)uap->gidset,
340 ngrp * sizeof(gid_t));
41 */
42
43/*
44 * System calls related to processes and protection
45 */
46
47#include "opt_compat.h"
48

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

333 td->td_retval[0] = cred->cr_ngroups;
334 return (0);
335 }
336 if (ngrp < cred->cr_ngroups)
337 return (EINVAL);
338 ngrp = cred->cr_ngroups;
339 error = copyout((caddr_t)cred->cr_groups, (caddr_t)uap->gidset,
340 ngrp * sizeof(gid_t));
341 if (error)
342 return (error);
343 td->td_retval[0] = ngrp;
344 return (0);
341 if (error == 0)
342 td->td_retval[0] = ngrp;
343 return (error);
345}
346
347#ifndef _SYS_SYSPROTO_H_
348struct setsid_args {
349 int dummy;
350};
351#endif
352/*

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

1107 */
1108/* ARGSUSED */
1109int
1110getresuid(td, uap)
1111 register struct thread *td;
1112 struct getresuid_args *uap;
1113{
1114 struct ucred *cred;
344}
345
346#ifndef _SYS_SYSPROTO_H_
347struct setsid_args {
348 int dummy;
349};
350#endif
351/*

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

1106 */
1107/* ARGSUSED */
1108int
1109getresuid(td, uap)
1110 register struct thread *td;
1111 struct getresuid_args *uap;
1112{
1113 struct ucred *cred;
1115 struct proc *p = td->td_proc;
1116 int error1 = 0, error2 = 0, error3 = 0;
1117
1114 int error1 = 0, error2 = 0, error3 = 0;
1115
1118 mtx_lock(&Giant);
1119 cred = p->p_ucred;
1116 cred = td->td_ucred;
1120 if (uap->ruid)
1121 error1 = copyout((caddr_t)&cred->cr_ruid,
1122 (caddr_t)uap->ruid, sizeof(cred->cr_ruid));
1123 if (uap->euid)
1124 error2 = copyout((caddr_t)&cred->cr_uid,
1125 (caddr_t)uap->euid, sizeof(cred->cr_uid));
1126 if (uap->suid)
1127 error3 = copyout((caddr_t)&cred->cr_svuid,
1128 (caddr_t)uap->suid, sizeof(cred->cr_svuid));
1117 if (uap->ruid)
1118 error1 = copyout((caddr_t)&cred->cr_ruid,
1119 (caddr_t)uap->ruid, sizeof(cred->cr_ruid));
1120 if (uap->euid)
1121 error2 = copyout((caddr_t)&cred->cr_uid,
1122 (caddr_t)uap->euid, sizeof(cred->cr_uid));
1123 if (uap->suid)
1124 error3 = copyout((caddr_t)&cred->cr_svuid,
1125 (caddr_t)uap->suid, sizeof(cred->cr_svuid));
1129 mtx_unlock(&Giant);
1130 return (error1 ? error1 : error2 ? error2 : error3);
1131}
1132
1133#ifndef _SYS_SYSPROTO_H_
1134struct getresgid_args {
1135 gid_t *rgid;
1136 gid_t *egid;
1137 gid_t *sgid;

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

1142 */
1143/* ARGSUSED */
1144int
1145getresgid(td, uap)
1146 register struct thread *td;
1147 struct getresgid_args *uap;
1148{
1149 struct ucred *cred;
1126 return (error1 ? error1 : error2 ? error2 : error3);
1127}
1128
1129#ifndef _SYS_SYSPROTO_H_
1130struct getresgid_args {
1131 gid_t *rgid;
1132 gid_t *egid;
1133 gid_t *sgid;

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

1138 */
1139/* ARGSUSED */
1140int
1141getresgid(td, uap)
1142 register struct thread *td;
1143 struct getresgid_args *uap;
1144{
1145 struct ucred *cred;
1150 struct proc *p = td->td_proc;
1151 int error1 = 0, error2 = 0, error3 = 0;
1152
1146 int error1 = 0, error2 = 0, error3 = 0;
1147
1153 mtx_lock(&Giant);
1154 cred = p->p_ucred;
1148 cred = td->td_ucred;
1155 if (uap->rgid)
1156 error1 = copyout((caddr_t)&cred->cr_rgid,
1157 (caddr_t)uap->rgid, sizeof(cred->cr_rgid));
1158 if (uap->egid)
1159 error2 = copyout((caddr_t)&cred->cr_groups[0],
1160 (caddr_t)uap->egid, sizeof(cred->cr_groups[0]));
1161 if (uap->sgid)
1162 error3 = copyout((caddr_t)&cred->cr_svgid,
1163 (caddr_t)uap->sgid, sizeof(cred->cr_svgid));
1149 if (uap->rgid)
1150 error1 = copyout((caddr_t)&cred->cr_rgid,
1151 (caddr_t)uap->rgid, sizeof(cred->cr_rgid));
1152 if (uap->egid)
1153 error2 = copyout((caddr_t)&cred->cr_groups[0],
1154 (caddr_t)uap->egid, sizeof(cred->cr_groups[0]));
1155 if (uap->sgid)
1156 error3 = copyout((caddr_t)&cred->cr_svgid,
1157 (caddr_t)uap->sgid, sizeof(cred->cr_svgid));
1164 mtx_unlock(&Giant);
1165 return (error1 ? error1 : error2 ? error2 : error3);
1166}
1167
1168#ifndef _SYS_SYSPROTO_H_
1169struct issetugid_args {
1170 int dummy;
1171};
1172#endif

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

1228#else /* !REGRESSION */
1229
1230 return (ENOSYS);
1231#endif /* REGRESSION */
1232}
1233
1234/*
1235 * Check if gid is a member of the group set.
1158 return (error1 ? error1 : error2 ? error2 : error3);
1159}
1160
1161#ifndef _SYS_SYSPROTO_H_
1162struct issetugid_args {
1163 int dummy;
1164};
1165#endif

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

1221#else /* !REGRESSION */
1222
1223 return (ENOSYS);
1224#endif /* REGRESSION */
1225}
1226
1227/*
1228 * Check if gid is a member of the group set.
1229 *
1230 * MPSAFE (cred must be held)
1236 */
1237int
1238groupmember(gid, cred)
1239 gid_t gid;
1240 struct ucred *cred;
1241{
1242 register gid_t *gp;
1243 gid_t *egp;

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

1284suser_td(td)
1285 struct thread *td;
1286{
1287 return (suser_xxx(0, td->td_proc, 0));
1288}
1289
1290/*
1291 * wrapper to use if you have the thread on hand but not the proc.
1231 */
1232int
1233groupmember(gid, cred)
1234 gid_t gid;
1235 struct ucred *cred;
1236{
1237 register gid_t *gp;
1238 gid_t *egp;

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

1279suser_td(td)
1280 struct thread *td;
1281{
1282 return (suser_xxx(0, td->td_proc, 0));
1283}
1284
1285/*
1286 * wrapper to use if you have the thread on hand but not the proc.
1287 *
1288 * MPSAFE (cred must be held)
1292 */
1293int
1294suser_xxx_td(cred, td, flag)
1295 struct ucred *cred;
1296 struct thread *td;
1297 int flag;
1298{
1299 return(suser_xxx(cred, td->td_proc, flag));

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

1325 * implements (securelevel > level). securelevel_ge() implements
1326 * (securelevel >= level). Note that the logic is inverted -- these
1327 * functions return EPERM on "success" and 0 on "failure".
1328 *
1329 * cr is permitted to be NULL for the time being, as there were some
1330 * existing securelevel checks that occurred without a process/credential
1331 * context. In the future this will be disallowed, so a kernel message
1332 * is displayed.
1289 */
1290int
1291suser_xxx_td(cred, td, flag)
1292 struct ucred *cred;
1293 struct thread *td;
1294 int flag;
1295{
1296 return(suser_xxx(cred, td->td_proc, flag));

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

1322 * implements (securelevel > level). securelevel_ge() implements
1323 * (securelevel >= level). Note that the logic is inverted -- these
1324 * functions return EPERM on "success" and 0 on "failure".
1325 *
1326 * cr is permitted to be NULL for the time being, as there were some
1327 * existing securelevel checks that occurred without a process/credential
1328 * context. In the future this will be disallowed, so a kernel message
1329 * is displayed.
1330 *
1331 * MPSAFE
1333 */
1334int
1335securelevel_gt(struct ucred *cr, int level)
1336{
1337 int active_securelevel;
1338
1339 active_securelevel = securelevel;
1340 if (cr == NULL)

--- 687 unchanged lines hidden ---
1332 */
1333int
1334securelevel_gt(struct ucred *cr, int level)
1335{
1336 int active_securelevel;
1337
1338 active_securelevel = securelevel;
1339 if (cr == NULL)

--- 687 unchanged lines hidden ---