id.c revision 9acbbeaf2a1ffe5c14b244867d427714fab43c5c
/*
* 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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/lx_types.h>
#include <sys/lx_syscall.h>
#include <sys/cred_impl.h>
#include <alloca.h>
#include <errno.h>
#include <ucred.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
int
{
}
int
lx_getuid16(void)
{
return ((int)LX_UID32_TO_UID16(getuid()));
}
int
{
}
int
lx_getgid16(void)
{
return ((int)LX_GID32_TO_GID16(getgid()));
}
int
lx_geteuid16(void)
{
return ((int)LX_UID32_TO_UID16(geteuid()));
}
int
lx_getegid16(void)
{
return ((int)LX_GID32_TO_GID16(getegid()));
}
int
lx_geteuid(void)
{
return ((int)geteuid());
}
int
lx_getegid(void)
{
return ((int)getegid());
}
int
{
/*
* We allocate a ucred_t ourselves rather than call ucred_get(3C)
* because ucred_get() calls malloc(3C), which the brand library cannot
* use. Because we allocate the space with SAFE_ALLOCA(), there's
* no need to free it when we're done.
*/
sz = ucred_size();
return (-ENOMEM);
return (-errno);
return (-errno);
}
return (-errno);
return (-errno);
? -errno : 0);
}
int
{
int rv;
return (rv);
return (-errno);
return (-errno);
? -errno : 0);
}
int
{
/*
* We allocate a ucred_t ourselves rather than call ucred_get(3C)
* because ucred_get() calls malloc(3C), which the brand library cannot
* use. Because we allocate the space with SAFE_ALLOCA(), there's
* no need to free it when we're done.
*/
sz = ucred_size();
return (-ENOMEM);
return (-errno);
return (-errno);
}
return (-errno);
return (-errno);
? -errno : 0);
}
int
{
int rv;
return (rv);
return (-errno);
return (-errno);
? -errno : 0);
}
int
{
}
int
{
}
/*
* would require significant rework of Solaris' privilege mechanisms, so
* instead return the current effective [ug]id.
*
* In Linux, fsids track effective IDs, so returning the effective IDs works
* as a substitute; returning the current value also denotes failure of the
* call if the caller had specified something different. We don't need to
* worry about setting error codes because the Linux calls don't set any.
*/
/*ARGSUSED*/
int
{
return (lx_geteuid16());
}
/*ARGSUSED*/
int
{
return (lx_getegid16());
}
/*ARGSUSED*/
int
{
return (geteuid());
}
/*ARGSUSED*/
int
{
return (getegid());
}