/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
/*
* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
*/
#include <sys/sysmacros.h>
#include <sys/tuneable.h>
#include <sys/cred_impl.h>
int
{
proc_t *p;
int error;
int do_nocd = 0;
int uidchge = 0;
} else {
}
/*
* Need to pre-allocate the new cred structure before grabbing
* the p_crlock mutex. We can't hold on to the p_crlock for most
* if this though, now that we allow kernel upcalls from the
* policy routines.
*/
newcr = cralloc_ksid();
mutex_enter(&p->p_crlock);
mutex_exit(&p->p_crlock);
mutex_enter(&p->p_crlock);
goto retry_locked;
error = 0;
mutex_exit(&p->p_crlock);
mutex_enter(&p->p_crlock);
goto retry_locked;
/*
* The ruid of the process is going to change. In order
* to avoid a race condition involving the
* process-count associated with the newly given ruid,
* we increment the count before assigning the
* credential to the process.
* To do that, we'll have to take pidlock, so we first
* release p_crlock.
*/
mutex_exit(&p->p_crlock);
uidchge = 1;
/*
* As we released p_crlock we can't rely on the cr
* we read. So retry the whole thing.
*/
goto retry;
}
/*
* A privileged process that gives up its privilege
* must be marked to produce no core dump.
*/
do_nocd = 1;
/* Remove the PRIV_PFEXEC, we changed the real uid. */
if (uidchge)
mutex_exit(&p->p_crlock);
} else {
}
/*
* We decrement the number of processes associated with the oldruid
* to match the increment above, even if the ruid of the process
* did not change or an error occurred (oldruid == uid).
*/
if (uidchge) {
}
if (error == 0) {
if (do_nocd) {
mutex_enter(&p->p_lock);
mutex_exit(&p->p_lock);
}
return (0);
}
}
getuid(void)
{
rval_t r;
return (r.r_vals);
}
int
{
proc_t *p;
int do_nocd = 0;
} else {
}
/*
* Need to pre-allocate the new cred structure before grabbing
* the p_crlock mutex.
*/
newcr = cralloc_ksid();
mutex_enter(&p->p_crlock);
mutex_exit(&p->p_crlock);
/*
* A privileged process that makes itself look like a
* set-uid process must be marked to produce no core dump,
* if the effective uid did changed.
*/
mutex_enter(&p->p_crlock);
goto retry;
do_nocd = 1;
error = 0;
mutex_exit(&p->p_crlock);
if (do_nocd) {
mutex_enter(&p->p_lock);
mutex_exit(&p->p_lock);
}
return (0);
}
}
/*
* Buy-back from SunOS 4.x
*
* Like setuid() and seteuid() combined -except- that non-root users
* can change cr_ruid to cr_uid, and the semantics of cr_suid are
* subtly different.
*/
int
{
proc_t *p;
int error = 0;
int do_nocd = 0;
int uidchge = 0;
} else {
}
/*
* Need to pre-allocate the new cred structure before grabbing
* the p_crlock mutex.
*/
newcr = cralloc_ksid();
mutex_enter(&p->p_crlock);
mutex_exit(&p->p_crlock);
mutex_enter(&p->p_crlock);
goto retry_locked;
} else if (euid != -1 &&
mutex_enter(&p->p_crlock);
goto retry_locked;
} else {
mutex_enter(&p->p_crlock);
goto retry_locked;
/*
* The ruid of the process is going to change. In order
* to avoid a race condition involving the
* process-count associated with the newly given ruid,
* we increment the count before assigning the
* credential to the process.
* To do that, we'll have to take pidlock, so we first
* release p_crlock.
*/
mutex_exit(&p->p_crlock);
uidchge = 1;
/*
* As we released p_crlock we can't rely on the cr
* we read. So retry the whole thing.
*/
goto retry;
}
if (euid != -1) {
}
if (ruid != -1) {
/* Remove the PRIV_PFEXEC, we changed the real uid. */
if (uidchge)
}
/*
* "If the real uid is being changed, or the effective uid is
* being changed to a value not equal to the real uid, the
* saved uid is set to the new effective uid."
*/
if (ruid != -1 ||
/*
* A process that gives up its privilege
* must be marked to produce no core dump.
*/
do_nocd = 1;
}
mutex_exit(&p->p_crlock);
/*
* We decrement the number of processes associated with the oldruid
* to match the increment above, even if the ruid of the process
* did not change or an error occurred (oldruid == uid).
*/
if (uidchge) {
}
if (error == 0) {
if (do_nocd) {
mutex_enter(&p->p_lock);
mutex_exit(&p->p_lock);
}
return (0);
}
}