Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/crypto/krb5/src/include/k5-util.h
34879 views
1
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
/*
3
* Copyright (C) 1989-1998,2002 by the Massachusetts Institute of Technology,
4
* Cambridge, MA, USA. All Rights Reserved.
5
*
6
* This software is being provided to you, the LICENSEE, by the
7
* Massachusetts Institute of Technology (M.I.T.) under the following
8
* license. By obtaining, using and/or copying this software, you agree
9
* that you have read, understood, and will comply with these terms and
10
* conditions:
11
*
12
* Export of this software from the United States of America may
13
* require a specific license from the United States Government.
14
* It is the responsibility of any person or organization contemplating
15
* export to obtain such a license before exporting.
16
*
17
* WITHIN THAT CONSTRAINT, permission to use, copy, modify and distribute
18
* this software and its documentation for any purpose and without fee or
19
* royalty is hereby granted, provided that you agree to comply with the
20
* following copyright notice and statements, including the disclaimer, and
21
* that the same appear on ALL copies of the software and documentation,
22
* including modifications that you make for internal use or for
23
* distribution:
24
*
25
* THIS SOFTWARE IS PROVIDED "AS IS", AND M.I.T. MAKES NO REPRESENTATIONS
26
* OR WARRANTIES, EXPRESS OR IMPLIED. By way of example, but not
27
* limitation, M.I.T. MAKES NO REPRESENTATIONS OR WARRANTIES OF
28
* MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF
29
* THE LICENSED SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY
30
* PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
31
*
32
* The name of the Massachusetts Institute of Technology or M.I.T. may NOT
33
* be used in advertising or publicity pertaining to distribution of the
34
* software. Title to copyright in this software and any associated
35
* documentation shall at all times remain with M.I.T., and USER agrees to
36
* preserve same.
37
*
38
* Furthermore if you modify this software you must label
39
* your software as modified software and not distribute it in such a
40
* fashion that it might be confused with the original M.I.T. software.
41
*/
42
43
/*
44
* "internal" utility functions used by various applications.
45
* They live in libkrb5util.
46
*/
47
48
#include "autoconf.h"
49
50
#ifdef HAVE_SYS_TYPES_H
51
#include <sys/types.h>
52
#endif
53
54
#ifdef HAVE_UNISTD_H
55
#include <unistd.h>
56
#endif
57
58
#ifdef HAVE_STDLIB_H
59
#include <stdlib.h>
60
#endif
61
62
#include <errno.h>
63
64
#ifndef krb5_seteuid
65
66
#if defined(HAVE_SETEUID)
67
# define krb5_seteuid(EUID) (seteuid((uid_t)(EUID)))
68
#elif defined(HAVE_SETRESUID)
69
# define krb5_seteuid(EUID) setresuid(getuid(), (uid_t)(EUID), geteuid())
70
#elif defined(HAVE_SETREUID)
71
# define krb5_seteuid(EUID) setreuid(geteuid(), (uid_t)(EUID))
72
#else
73
/* You need to add a case to deal with this operating system.*/
74
# define krb5_seteuid(EUID) (errno = EPERM, -1)
75
#endif
76
77
#ifdef HAVE_SETEGID
78
# define krb5_setegid(EGID) (setegid((gid_t)(EGID)))
79
#elif defined(HAVE_SETRESGID)
80
# define krb5_setegid(EGID) (setresgid(getgid(), (gid_t)(EGID), getegid()))
81
#elif defined(HAVE_SETREGID)
82
# define krb5_setegid(EGID) (setregid(getegid(), (gid_t)(EGID)))
83
#else
84
/* You need to add a case to deal with this operating system.*/
85
# define krb5_setegid(EGID) (errno = EPERM, -1)
86
#endif
87
88
#endif
89
90