blob: 4e1890f2d285172aef45102f574c435c5fa23517 [file] [log] [blame]
Rich Salzd2e9e322016-05-17 14:51:26 -04001/*
2 * Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved.
Ulf Möller36fafff2001-02-14 01:35:44 +00003 *
Rich Salzd2e9e322016-05-17 14:51:26 -04004 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
Ulf Möller36fafff2001-02-14 01:35:44 +00008 */
9
Richard Levitte74cd3652001-02-19 22:04:02 +000010#include <openssl/crypto.h>
Richard Levitte91dc71f2001-04-26 08:26:18 +000011#include <openssl/opensslconf.h>
Ulf Möller36fafff2001-02-14 01:35:44 +000012
jrmarino2df7f112016-10-21 08:48:31 -050013#if defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD__ > 2) || defined(__DragonFly__)
Ulf Möller36fafff2001-02-14 01:35:44 +000014
Matt Caswell0f113f32015-01-22 03:40:55 +000015# include OPENSSL_UNISTD
Ulf Möller36fafff2001-02-14 01:35:44 +000016
17int OPENSSL_issetugid(void)
Matt Caswell0f113f32015-01-22 03:40:55 +000018{
19 return issetugid();
20}
Ulf Möller36fafff2001-02-14 01:35:44 +000021
Qin Longcff55b92017-03-15 23:33:57 +080022#elif defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI)
Ulf Möller36fafff2001-02-14 01:35:44 +000023
24int OPENSSL_issetugid(void)
Matt Caswell0f113f32015-01-22 03:40:55 +000025{
26 return 0;
27}
Ulf Möller36fafff2001-02-14 01:35:44 +000028
29#else
30
Matt Caswell0f113f32015-01-22 03:40:55 +000031# include OPENSSL_UNISTD
32# include <sys/types.h>
Ulf Möller36fafff2001-02-14 01:35:44 +000033
34int OPENSSL_issetugid(void)
Matt Caswell0f113f32015-01-22 03:40:55 +000035{
36 if (getuid() != geteuid())
37 return 1;
38 if (getgid() != getegid())
39 return 1;
40 return 0;
41}
Ulf Möller36fafff2001-02-14 01:35:44 +000042#endif