M-x shuffle-functions-and-documentation

basically, move things around so documentation is in the correct place,
and bump appropriate functions into the 'compat' section.
This commit is contained in:
cgd 1994-04-06 23:28:36 +00:00
parent a601e055c5
commit a2770ef528
11 changed files with 677 additions and 9 deletions

View File

@ -1,9 +1,13 @@
# from: @(#)Makefile.inc 5.3 (Berkeley) 2/20/91
# $Id: Makefile.inc,v 1.4 1993/12/04 02:34:20 cgd Exp $
# $Id: Makefile.inc,v 1.5 1994/04/06 23:28:36 cgd Exp $
# compat-43 sources
.PATH: ${.CURDIR}/arch/${MACHINE_ARCH}/compat-43 ${.CURDIR}/compat-43
SRCS+= creat.c getwd.c killpg.c setpgrp.c sigcompat.c
SRCS+= creat.c getwd.c killpg.c setpgrp.c setregid.c setreuid.c \
setrgid.c setruid.c sigcompat.c
MAN2+= creat.0 killpg.0 sigblock.0 sigpause.0 sigsetmask.0 sigvec.0
MAN2+= creat.0 killpg.0 setregid.0 setreuid.0 setruid.0 \
sigblock.0 sigpause.0 sigsetmask.0 sigvec.0
MLINKS+=setruid.2 setrgid.2

View File

@ -0,0 +1,93 @@
.\" Copyright (c) 1983, 1991 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)setregid.2 6.4 (Berkeley) 3/10/91
.\" $Id: setregid.2,v 1.1 1994/04/06 23:28:40 cgd Exp $
.\"
.Dd March 10, 1991
.Dt SETREGID 2
.Os BSD 4.2
.Sh NAME
.Nm setregid
.Nd set real and effective group ID's
.Sh SYNOPSIS
.Fd #include <unistd.h>
.Ft int
.Fn setregid "int rgid" "int egid"
.Sh DESCRIPTION
The real and effective group ID's of the current process
are set to the arguments.
Unprivileged users may change the real group
ID to the effective group ID and vice-versa; only the super-user may
make other changes.
.Pp
Supplying a value of -1 for either the real or effective
group ID forces the system to substitute the current
ID in place of the -1 parameter.
.Pp
The
.Fn setregid
function was intended to allow swapping the real and
effective group IDs in set-group-ID programs to temporarily relinquish
the set-group-ID value. This function did not work correctly, and its
purpose is now better served by the use of the
.Fn setegid
function (see
.Xr setuid 2 ).
.Pp
When setting the real and effective group IDs to the same value, the
standard
.Fn setgid
function is preferred.
.Sh RETURN VALUES
Upon successful completion, a value of 0 is returned. Otherwise,
a value of -1 is returned and
.Va errno
is set to indicate the error.
.Sh ERRORS
.Bl -tag -width Er
.It Bq Er EPERM
The current process is not the super-user and a change
other than changing the effective group-id to the real group-id
was specified.
.El
.Sh SEE ALSO
.Xr getgid 2 ,
.Xr setegid 2 ,
.Xr setgid 2 ,
.Xr setuid 2
.Sh HISTORY
The
.Fn setregid
function call appeared in
.Bx 4.2
and was dropped in
.Bx 4.4 .

View File

@ -0,0 +1,93 @@
.\" Copyright (c) 1983, 1991 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)setregid.2 6.4 (Berkeley) 3/10/91
.\" $Id: setregid.3,v 1.1 1994/04/06 23:28:40 cgd Exp $
.\"
.Dd March 10, 1991
.Dt SETREGID 2
.Os BSD 4.2
.Sh NAME
.Nm setregid
.Nd set real and effective group ID's
.Sh SYNOPSIS
.Fd #include <unistd.h>
.Ft int
.Fn setregid "int rgid" "int egid"
.Sh DESCRIPTION
The real and effective group ID's of the current process
are set to the arguments.
Unprivileged users may change the real group
ID to the effective group ID and vice-versa; only the super-user may
make other changes.
.Pp
Supplying a value of -1 for either the real or effective
group ID forces the system to substitute the current
ID in place of the -1 parameter.
.Pp
The
.Fn setregid
function was intended to allow swapping the real and
effective group IDs in set-group-ID programs to temporarily relinquish
the set-group-ID value. This function did not work correctly, and its
purpose is now better served by the use of the
.Fn setegid
function (see
.Xr setuid 2 ).
.Pp
When setting the real and effective group IDs to the same value, the
standard
.Fn setgid
function is preferred.
.Sh RETURN VALUES
Upon successful completion, a value of 0 is returned. Otherwise,
a value of -1 is returned and
.Va errno
is set to indicate the error.
.Sh ERRORS
.Bl -tag -width Er
.It Bq Er EPERM
The current process is not the super-user and a change
other than changing the effective group-id to the real group-id
was specified.
.El
.Sh SEE ALSO
.Xr getgid 2 ,
.Xr setegid 2 ,
.Xr setgid 2 ,
.Xr setuid 2
.Sh HISTORY
The
.Fn setregid
function call appeared in
.Bx 4.2
and was dropped in
.Bx 4.4 .

View File

@ -0,0 +1,60 @@
/*
* Copyright (c) 1982, 1986, 1989, 1990, 1991 Regents of the University
* of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)kern_prot.c 7.21 (Berkeley) 5/3/91
* $Id: setregid.c,v 1.1 1994/04/06 23:28:41 cgd Exp $
*/
#include <sys/types.h>
#include <errno.h>
int
setregid(rgid, egid)
gid_t rgid, egid;
{
static gid_t svgid = -1;
if (svgid == -1)
svgid = getegid();
/*
* we assume that the intent of setting rgid is to be able to get
* back rgid priviledge. So we make sure that we will be able to
* do so, but do not actually set the rgid.
*/
if (rgid != -1 && rgid != getgid() && rgid != svgid) {
errno = EPERM;
return (-1);
}
if (egid != -1 && setegid(egid) < 0)
return (-1);
return (0);
}

View File

@ -0,0 +1,91 @@
.\" Copyright (c) 1980, 1991 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)setreuid.2 6.4 (Berkeley) 3/10/91
.\" $Id: setreuid.2,v 1.1 1994/04/06 23:28:44 cgd Exp $
.\"
.Dd March 10, 1991
.Dt SETREUID 2
.Os BSD 4
.Sh NAME
.Nm setreuid
.Nd set real and effective user ID's
.Sh SYNOPSIS
.Fd #include <unistd.h>
.Ft int
.Fn setreuid "int ruid" "int euid"
.Sh DESCRIPTION
The real and effective user ID's of the
current process are set according to the arguments.
If
.Fa ruid
or
.Fa euid
is -1, the current uid is filled in by the system.
Unprivileged users may change the real user
ID to the effective user ID and vice-versa; only the super-user may
make other changes.
.Pp
The
.Fn setreuid
function has been used to swap the real and effective user
IDs in set-user-ID programs to temporarily relinquish the set-user-ID
value. This purpose is now better served by the use of the
.Fn seteuid
function (see
.Xr setuid 2 ).
.Pp
When setting the real and effective user IDs to the same value, the standard
.Fn setuid
function is preferred.
.Sh RETURN VALUES
Upon successful completion, a value of 0 is returned. Otherwise,
a value of -1 is returned and
.Va errno
is set to indicate the error.
.Sh ERRORS
.Bl -tag -width Er
.It Bq Er EPERM
The current process is not the super-user and a change
other than changing the effective user-id to the real user-id
was specified.
.El
.Sh SEE ALSO
.Xr getuid 2 ,
.Xr seteuid 2 ,
.Xr setuid 2
.Sh HISTORY
The
.Fn setreuid
function call appeared in
.Bx 4.2
and was dropped in
.Bx 4.4 .

View File

@ -0,0 +1,91 @@
.\" Copyright (c) 1980, 1991 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)setreuid.2 6.4 (Berkeley) 3/10/91
.\" $Id: setreuid.3,v 1.1 1994/04/06 23:28:44 cgd Exp $
.\"
.Dd March 10, 1991
.Dt SETREUID 2
.Os BSD 4
.Sh NAME
.Nm setreuid
.Nd set real and effective user ID's
.Sh SYNOPSIS
.Fd #include <unistd.h>
.Ft int
.Fn setreuid "int ruid" "int euid"
.Sh DESCRIPTION
The real and effective user ID's of the
current process are set according to the arguments.
If
.Fa ruid
or
.Fa euid
is -1, the current uid is filled in by the system.
Unprivileged users may change the real user
ID to the effective user ID and vice-versa; only the super-user may
make other changes.
.Pp
The
.Fn setreuid
function has been used to swap the real and effective user
IDs in set-user-ID programs to temporarily relinquish the set-user-ID
value. This purpose is now better served by the use of the
.Fn seteuid
function (see
.Xr setuid 2 ).
.Pp
When setting the real and effective user IDs to the same value, the standard
.Fn setuid
function is preferred.
.Sh RETURN VALUES
Upon successful completion, a value of 0 is returned. Otherwise,
a value of -1 is returned and
.Va errno
is set to indicate the error.
.Sh ERRORS
.Bl -tag -width Er
.It Bq Er EPERM
The current process is not the super-user and a change
other than changing the effective user-id to the real user-id
was specified.
.El
.Sh SEE ALSO
.Xr getuid 2 ,
.Xr seteuid 2 ,
.Xr setuid 2
.Sh HISTORY
The
.Fn setreuid
function call appeared in
.Bx 4.2
and was dropped in
.Bx 4.4 .

View File

@ -0,0 +1,60 @@
/*
* Copyright (c) 1982, 1986, 1989, 1990, 1991 Regents of the University
* of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)kern_prot.c 7.21 (Berkeley) 5/3/91
* $Id: setreuid.c,v 1.1 1994/04/06 23:28:45 cgd Exp $
*/
#include <sys/types.h>
#include <errno.h>
int
setreuid(ruid, euid)
uid_t ruid, euid;
{
static uid_t svuid = -1;
if (svuid == -1)
svuid = geteuid();
/*
* we assume that the intent of setting ruid is to be able to get
* back ruid priviledge. So we make sure that we will be able to
* do so, but do not actually set the ruid.
*/
if (ruid != -1 && ruid != getuid() && ruid != svuid) {
errno = EPERM;
return (-1);
}
if (euid != -1 && seteuid(euid) < 0)
return (-1);
return (0);
}

View File

@ -0,0 +1,51 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)setrgid.c 5.5 (Berkeley) 2/23/91";*/
static char *rcsid = "$Id: setrgid.c,v 1.1 1994/04/06 23:28:46 cgd Exp $";
#endif /* LIBC_SCCS and not lint */
#include <unistd.h>
int
#ifdef __STDC__
setrgid(gid_t rgid)
#else
setrgid(rgid)
int rgid;
#endif
{
return (setregid(rgid, -1));
}

View File

@ -0,0 +1,77 @@
.\" Copyright (c) 1983, 1991 Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)setuid.3 6.4 (Berkeley) 4/19/91
.\" $Id: setruid.3,v 1.1 1994/04/06 23:28:47 cgd Exp $
.\"
.Dd April 19, 1991
.Dt SETRUID 3
.Os BSD 4.2
.Sh NAME
.Nm setruid ,
.Nm setrgid
.Nd set user and group ID
.Sh SYNOPSIS
.Fd #include <sys/types.h>
.Ft int
.Fn setruid "uid_t uid"
.Ft int
.Fn setrgid "gid_t gid"
.Sh DESCRIPTION
The
.Fn setruid
function
.Pq Fn setrgid
sets the real user ID (group ID)
of the current process to the specified value.
.Sh RETURN VALUES
Upon success, these functions return 0;
otherwise \-1 is returned.
.Pp
If the user is not the super user, or the uid (gid) specified is not
the real or effective ID of the process,
these functions return \-1.
.Sh SEE ALSO
.Xr setuid 2 ,
.Xr setgid 2 ,
.Xr seteuid 2 ,
.Xr setegid 2 ,
.Xr getuid 2 ,
.Xr getgid 2
.Sh HISTORY
The
.Fn setruid
and
.Fn setrgid
syscalls appeared in
.Bx 4.2
and were dropped in
.Bx 4.4 .

View File

@ -0,0 +1,51 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)setruid.c 5.5 (Berkeley) 2/23/91";*/
static char *rcsid = "$Id: setruid.c,v 1.1 1994/04/06 23:28:48 cgd Exp $";
#endif /* LIBC_SCCS and not lint */
#include <unistd.h>
int
#ifdef __STDC__
setruid(uid_t ruid)
#else
setruid(ruid)
int ruid;
#endif
{
return (setreuid(ruid, -1));
}

View File

@ -1,5 +1,5 @@
# from: @(#)Makefile.inc 5.21 (Berkeley) 5/24/91
# $Id: Makefile.inc,v 1.34 1994/01/27 23:58:34 cgd Exp $
# $Id: Makefile.inc,v 1.35 1994/04/06 23:29:13 cgd Exp $
# gen sources
.PATH: ${.CURDIR}/arch/${MACHINE_ARCH}/gen ${.CURDIR}/gen
@ -16,8 +16,7 @@ SRCS+= alarm.c assert.c clock.c confstr.c ctermid.c ctime.c ctype_.c \
msgctl.c msgget.c msgsnd.c msgrcv.c \
mktemp.c nice.c nlist.c pause.c popen.c psignal.c pwcache.c raise.c \
scandir.c semconfig.c semctl.c semget.c semop.c setjmperr.c setmode.c \
setrgid.c setruid.c shmat.c shmctl.c shmdt.c shmget.c \
siginterrupt.c \
shmat.c shmctl.c shmdt.c shmget.c siginterrupt.c \
siglist.c signal.c signame.c sigsetops.c sleep.c syslog.c \
termios.c time.c times.c timezone.c tolower_.c ttyname.c ttyslot.c \
toupper_.c \
@ -58,7 +57,7 @@ MAN3+= alarm.0 clock.0 ctermid.0 ctime.0 ctype.0 cuserid.0 \
isalpha.0 isascii.0 isblank.0 iscntrl.0 isdigit.0 isgraph.0 isinf.0 \
islower.0 isprint.0 ispunct.0 isspace.0 isupper.0 isxdigit.0 \
ldexp.0 lsearch.0 modf.0 nice.0 nlist.0 pause.0 popen.0 psignal.0 \
pwcache.0 raise.0 scandir.0 setjmp.0 setmode.0 setuid.0 \
pwcache.0 raise.0 scandir.0 setjmp.0 setmode.0 \
siginterrupt.0 signal.0 sigsetops.0 sleep.0 syslog.0 tcgetpgrp.0 \
tcsendbreak.0 tcsetattr.0 tcsetpgrp.0 time.0 times.0 timezone.0 \
tolower.0 toupper.0 ttyname.0 tzset.0 \
@ -98,8 +97,6 @@ MLINKS+=scandir.3 alphasort.3
MLINKS+=setjmp.3 _longjmp.3 setjmp.3 _setjmp.3 setjmp.3 longjmp.3 \
setjmp.3 sigsetjmp.3 setjmp.3 siglongjmp.3 setjmp.3 longjmperror.3
MLINKS+=setmode.3 getmode.3
MLINKS+=setuid.3 setegid.3 setuid.3 seteuid.3 setuid.3 setgid.3 \
setuid.3 setrgid.3 setuid.3 setruid.3
MLINKS+=sigsetops.3 sigemptyset.3 sigsetops.3 sigfillset.3 \
sigsetops.3 sigaddset.3 sigsetops.3 sigdelset.3 \
sigsetops.3 sigismember.3