summaryrefslogtreecommitdiffstats
path: root/gnu/libexec/uucp/libunix/ufopen.c
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/libexec/uucp/libunix/ufopen.c')
-rw-r--r--gnu/libexec/uucp/libunix/ufopen.c89
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. */
OpenPOWER on IntegriCloud