diff options
author | ache <ache@FreeBSD.org> | 1995-08-19 21:30:30 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1995-08-19 21:30:30 +0000 |
commit | b06a057b826e638a06edc1f92d5eed32662e0077 (patch) | |
tree | e1ea6a3b65e0f2e9f5d6e0f0f3956a82ada4b85b /gnu/libexec/uucp/libunix/ufopen.c | |
parent | a80ddb7b20df1716802b47c395201f120b369ee6 (diff) | |
download | FreeBSD-src-b06a057b826e638a06edc1f92d5eed32662e0077.zip FreeBSD-src-b06a057b826e638a06edc1f92d5eed32662e0077.tar.gz |
Commit delta: current -> 1.06 + FreeBSD configuration
Diffstat (limited to 'gnu/libexec/uucp/libunix/ufopen.c')
-rw-r--r-- | gnu/libexec/uucp/libunix/ufopen.c | 89 |
1 files changed, 3 insertions, 86 deletions
diff --git a/gnu/libexec/uucp/libunix/ufopen.c b/gnu/libexec/uucp/libunix/ufopen.c index 76ee1d1..d79d9a0 100644 --- a/gnu/libexec/uucp/libunix/ufopen.c +++ b/gnu/libexec/uucp/libunix/ufopen.c @@ -1,7 +1,7 @@ /* ufopen.c Open a file with the permissions of the invoking user. - Copyright (C) 1992 Ian Lance Taylor + Copyright (C) 1992, 1995 Ian Lance Taylor This file is part of the Taylor UUCP package. @@ -17,10 +17,10 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. The author of the program may be contacted at ian@airs.com or - c/o Cygnus Support, Building 200, 1 Kendall Square, Cambridge, MA 02139. + c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144. */ #include "uucp.h" @@ -53,89 +53,6 @@ #define FD_CLOEXEC 1 #endif -/* Local functions. */ - -static boolean fsuser_perms P((uid_t *pieuid)); -static boolean fsuucp_perms P((long ieuid)); - -/* Switch to permissions of the invoking user. */ - -static boolean -fsuser_perms (pieuid) - uid_t *pieuid; -{ - uid_t ieuid, iuid; - - ieuid = geteuid (); - iuid = getuid (); - if (pieuid != NULL) - *pieuid = ieuid; - -#if HAVE_SETREUID - /* Swap the effective user id and the real user id. We can then - swap them back again when we want to return to the uucp user's - permissions. */ - if (setreuid (ieuid, iuid) < 0) - { - ulog (LOG_ERROR, "setreuid (%ld, %ld): %s", - (long) ieuid, (long) iuid, strerror (errno)); - return FALSE; - } -#else /* ! HAVE_SETREUID */ -#if HAVE_SAVED_SETUID - /* Set the effective user id to the real user id. Since the - effective user id is saved (it's the saved setuid) we will able - to set back to it later. If the real user id is root we will not - be able to switch back and forth, so don't even try. */ - if (iuid != 0) - { - if (setuid (iuid) < 0) - { - ulog (LOG_ERROR, "setuid (%ld): %s", (long) iuid, strerror (errno)); - return FALSE; - } - } -#else /* ! HAVE_SAVED_SETUID */ - /* There's no way to switch between real permissions and effective - permissions. Just try to open the file with the uucp - permissions. */ -#endif /* ! HAVE_SAVED_SETUID */ -#endif /* ! HAVE_SETREUID */ - - return TRUE; -} - -/* Restore the uucp permissions. */ - -/*ARGSUSED*/ -static boolean -fsuucp_perms (ieuid) - long ieuid; -{ -#if HAVE_SETREUID - /* Swap effective and real user id's back to what they were. */ - if (! fsuser_perms ((uid_t *) NULL)) - return FALSE; -#else /* ! HAVE_SETREUID */ -#if HAVE_SAVED_SETUID - /* Set ourselves back to our original effective user id. */ - if (setuid ((uid_t) ieuid) < 0) - { - ulog (LOG_ERROR, "setuid (%ld): %s", (long) ieuid, strerror (errno)); - /* Is this error message helpful or confusing? */ - if (errno == EPERM) - ulog (LOG_ERROR, - "Probably HAVE_SAVED_SETUID in policy.h should be set to 0"); - return FALSE; - } -#else /* ! HAVE_SAVED_SETUID */ - /* We didn't switch, no need to switch back. */ -#endif /* ! HAVE_SAVED_SETUID */ -#endif /* ! HAVE_SETREUID */ - - return TRUE; -} - /* Open a file with the permissions of the invoking user. Ignore the fbinary argument since Unix has no distinction between text and binary files. */ |