diff options
| author | deraadt <> | 2014-04-15 22:37:36 +0000 |
|---|---|---|
| committer | deraadt <> | 2014-04-15 22:37:36 +0000 |
| commit | bb8b53bd274a5e5460eaaa47daaa06dcda619ecc (patch) | |
| tree | 9723ffd6a1b025f3df496371e7dd34e70449ca82 | |
| parent | 7f13870b8c22e29cdec3fb7f416847e3e15e3b7e (diff) | |
| download | openbsd-bb8b53bd274a5e5460eaaa47daaa06dcda619ecc.tar.gz openbsd-bb8b53bd274a5e5460eaaa47daaa06dcda619ecc.tar.bz2 openbsd-bb8b53bd274a5e5460eaaa47daaa06dcda619ecc.zip | |
Remove wraparounds for operating systems which lack issetugid().
I will note that some were missing, looking at you Solaris!!! Anyone home?
Using my own copyright on the file now, since this is a rewrite of
a trivial wrapper around a system call I invented.
ok beck
| -rw-r--r-- | src/lib/libcrypto/uid.c | 96 | ||||
| -rw-r--r-- | src/lib/libssl/src/crypto/uid.c | 96 |
2 files changed, 30 insertions, 162 deletions
diff --git a/src/lib/libcrypto/uid.c b/src/lib/libcrypto/uid.c index fcfa05ce0c..80a033270d 100644 --- a/src/lib/libcrypto/uid.c +++ b/src/lib/libcrypto/uid.c | |||
| @@ -1,91 +1,25 @@ | |||
| 1 | /* crypto/uid.c */ | 1 | /* |
| 2 | /* ==================================================================== | 2 | * Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org> |
| 3 | * Copyright (c) 2001 The OpenSSL Project. All rights reserved. | 3 | * |
| 4 | * | 4 | * Permission to use, copy, modify, and distribute this software for any |
| 5 | * Redistribution and use in source and binary forms, with or without | 5 | * purpose with or without fee is hereby granted, provided that the above |
| 6 | * modification, are permitted provided that the following conditions | 6 | * copyright notice and this permission notice appear in all copies. |
| 7 | * are met: | 7 | * |
| 8 | * | 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 9 | * 1. Redistributions of source code must retain the above copyright | 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 | * notice, this list of conditions and the following disclaimer. | 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 11 | * | 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 13 | * notice, this list of conditions and the following disclaimer in | 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 14 | * the documentation and/or other materials provided with the | 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 15 | * distribution. | ||
| 16 | * | ||
| 17 | * 3. All advertising materials mentioning features or use of this | ||
| 18 | * software must display the following acknowledgment: | ||
| 19 | * "This product includes software developed by the OpenSSL Project | ||
| 20 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 21 | * | ||
| 22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 23 | * endorse or promote products derived from this software without | ||
| 24 | * prior written permission. For written permission, please contact | ||
| 25 | * licensing@OpenSSL.org. | ||
| 26 | * | ||
| 27 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 28 | * nor may "OpenSSL" appear in their names without prior written | ||
| 29 | * permission of the OpenSSL Project. | ||
| 30 | * | ||
| 31 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 32 | * acknowledgment: | ||
| 33 | * "This product includes software developed by the OpenSSL Project | ||
| 34 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 35 | * | ||
| 36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 47 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 48 | * ==================================================================== | ||
| 49 | * | ||
| 50 | * This product includes cryptographic software written by Eric Young | ||
| 51 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 52 | * Hudson (tjh@cryptsoft.com). | ||
| 53 | * | ||
| 54 | */ | 15 | */ |
| 55 | 16 | ||
| 56 | #include <openssl/crypto.h> | 17 | #include <openssl/crypto.h> |
| 57 | #include <openssl/opensslconf.h> | 18 | #include <openssl/opensslconf.h> |
| 58 | 19 | #include <unistd.h> | |
| 59 | #if defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD__ > 2) | ||
| 60 | |||
| 61 | #include OPENSSL_UNISTD | ||
| 62 | 20 | ||
| 63 | int | 21 | int |
| 64 | OPENSSL_issetugid(void) | 22 | OPENSSL_issetugid(void) |
| 65 | { | 23 | { |
| 66 | return issetugid(); | 24 | return issetugid(); |
| 67 | } | 25 | } |
| 68 | |||
| 69 | #elif defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE) | ||
| 70 | |||
| 71 | int | ||
| 72 | OPENSSL_issetugid(void) | ||
| 73 | { | ||
| 74 | return 0; | ||
| 75 | } | ||
| 76 | |||
| 77 | #else | ||
| 78 | |||
| 79 | #include OPENSSL_UNISTD | ||
| 80 | #include <sys/types.h> | ||
| 81 | |||
| 82 | int | ||
| 83 | OPENSSL_issetugid(void) | ||
| 84 | { | ||
| 85 | if (getuid() | ||
| 86 | != geteuid()) return 1; | ||
| 87 | if (getgid() | ||
| 88 | != getegid()) return 1; | ||
| 89 | return 0; | ||
| 90 | } | ||
| 91 | #endif | ||
diff --git a/src/lib/libssl/src/crypto/uid.c b/src/lib/libssl/src/crypto/uid.c index fcfa05ce0c..80a033270d 100644 --- a/src/lib/libssl/src/crypto/uid.c +++ b/src/lib/libssl/src/crypto/uid.c | |||
| @@ -1,91 +1,25 @@ | |||
| 1 | /* crypto/uid.c */ | 1 | /* |
| 2 | /* ==================================================================== | 2 | * Copyright (c) 2014 Theo de Raadt <deraadt@openbsd.org> |
| 3 | * Copyright (c) 2001 The OpenSSL Project. All rights reserved. | 3 | * |
| 4 | * | 4 | * Permission to use, copy, modify, and distribute this software for any |
| 5 | * Redistribution and use in source and binary forms, with or without | 5 | * purpose with or without fee is hereby granted, provided that the above |
| 6 | * modification, are permitted provided that the following conditions | 6 | * copyright notice and this permission notice appear in all copies. |
| 7 | * are met: | 7 | * |
| 8 | * | 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 9 | * 1. Redistributions of source code must retain the above copyright | 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 | * notice, this list of conditions and the following disclaimer. | 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 11 | * | 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 13 | * notice, this list of conditions and the following disclaimer in | 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 14 | * the documentation and/or other materials provided with the | 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 15 | * distribution. | ||
| 16 | * | ||
| 17 | * 3. All advertising materials mentioning features or use of this | ||
| 18 | * software must display the following acknowledgment: | ||
| 19 | * "This product includes software developed by the OpenSSL Project | ||
| 20 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 21 | * | ||
| 22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 23 | * endorse or promote products derived from this software without | ||
| 24 | * prior written permission. For written permission, please contact | ||
| 25 | * licensing@OpenSSL.org. | ||
| 26 | * | ||
| 27 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 28 | * nor may "OpenSSL" appear in their names without prior written | ||
| 29 | * permission of the OpenSSL Project. | ||
| 30 | * | ||
| 31 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 32 | * acknowledgment: | ||
| 33 | * "This product includes software developed by the OpenSSL Project | ||
| 34 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 35 | * | ||
| 36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 47 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 48 | * ==================================================================== | ||
| 49 | * | ||
| 50 | * This product includes cryptographic software written by Eric Young | ||
| 51 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 52 | * Hudson (tjh@cryptsoft.com). | ||
| 53 | * | ||
| 54 | */ | 15 | */ |
| 55 | 16 | ||
| 56 | #include <openssl/crypto.h> | 17 | #include <openssl/crypto.h> |
| 57 | #include <openssl/opensslconf.h> | 18 | #include <openssl/opensslconf.h> |
| 58 | 19 | #include <unistd.h> | |
| 59 | #if defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD__ > 2) | ||
| 60 | |||
| 61 | #include OPENSSL_UNISTD | ||
| 62 | 20 | ||
| 63 | int | 21 | int |
| 64 | OPENSSL_issetugid(void) | 22 | OPENSSL_issetugid(void) |
| 65 | { | 23 | { |
| 66 | return issetugid(); | 24 | return issetugid(); |
| 67 | } | 25 | } |
| 68 | |||
| 69 | #elif defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_NETWARE) | ||
| 70 | |||
| 71 | int | ||
| 72 | OPENSSL_issetugid(void) | ||
| 73 | { | ||
| 74 | return 0; | ||
| 75 | } | ||
| 76 | |||
| 77 | #else | ||
| 78 | |||
| 79 | #include OPENSSL_UNISTD | ||
| 80 | #include <sys/types.h> | ||
| 81 | |||
| 82 | int | ||
| 83 | OPENSSL_issetugid(void) | ||
| 84 | { | ||
| 85 | if (getuid() | ||
| 86 | != geteuid()) return 1; | ||
| 87 | if (getgid() | ||
| 88 | != getegid()) return 1; | ||
| 89 | return 0; | ||
| 90 | } | ||
| 91 | #endif | ||
