/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */1/*2* Copyright (C) 1989-1998,2002 by the Massachusetts Institute of Technology,3* Cambridge, MA, USA. All Rights Reserved.4*5* This software is being provided to you, the LICENSEE, by the6* Massachusetts Institute of Technology (M.I.T.) under the following7* license. By obtaining, using and/or copying this software, you agree8* that you have read, understood, and will comply with these terms and9* conditions:10*11* Export of this software from the United States of America may12* require a specific license from the United States Government.13* It is the responsibility of any person or organization contemplating14* export to obtain such a license before exporting.15*16* WITHIN THAT CONSTRAINT, permission to use, copy, modify and distribute17* this software and its documentation for any purpose and without fee or18* royalty is hereby granted, provided that you agree to comply with the19* following copyright notice and statements, including the disclaimer, and20* that the same appear on ALL copies of the software and documentation,21* including modifications that you make for internal use or for22* distribution:23*24* THIS SOFTWARE IS PROVIDED "AS IS", AND M.I.T. MAKES NO REPRESENTATIONS25* OR WARRANTIES, EXPRESS OR IMPLIED. By way of example, but not26* limitation, M.I.T. MAKES NO REPRESENTATIONS OR WARRANTIES OF27* MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF28* THE LICENSED SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY29* PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.30*31* The name of the Massachusetts Institute of Technology or M.I.T. may NOT32* be used in advertising or publicity pertaining to distribution of the33* software. Title to copyright in this software and any associated34* documentation shall at all times remain with M.I.T., and USER agrees to35* preserve same.36*37* Furthermore if you modify this software you must label38* your software as modified software and not distribute it in such a39* fashion that it might be confused with the original M.I.T. software.40*/4142/*43* "internal" utility functions used by various applications.44* They live in libkrb5util.45*/4647#include "autoconf.h"4849#ifdef HAVE_SYS_TYPES_H50#include <sys/types.h>51#endif5253#ifdef HAVE_UNISTD_H54#include <unistd.h>55#endif5657#ifdef HAVE_STDLIB_H58#include <stdlib.h>59#endif6061#include <errno.h>6263#ifndef krb5_seteuid6465#if defined(HAVE_SETEUID)66# define krb5_seteuid(EUID) (seteuid((uid_t)(EUID)))67#elif defined(HAVE_SETRESUID)68# define krb5_seteuid(EUID) setresuid(getuid(), (uid_t)(EUID), geteuid())69#elif defined(HAVE_SETREUID)70# define krb5_seteuid(EUID) setreuid(geteuid(), (uid_t)(EUID))71#else72/* You need to add a case to deal with this operating system.*/73# define krb5_seteuid(EUID) (errno = EPERM, -1)74#endif7576#ifdef HAVE_SETEGID77# define krb5_setegid(EGID) (setegid((gid_t)(EGID)))78#elif defined(HAVE_SETRESGID)79# define krb5_setegid(EGID) (setresgid(getgid(), (gid_t)(EGID), getegid()))80#elif defined(HAVE_SETREGID)81# define krb5_setegid(EGID) (setregid(getegid(), (gid_t)(EGID)))82#else83/* You need to add a case to deal with this operating system.*/84# define krb5_setegid(EGID) (errno = EPERM, -1)85#endif8687#endif888990