xref: /freebsd/crypto/openssl/crypto/uid.c (revision 5c87c606cde085944937b11c908b8c1232fef219)
15740a5e3SKris Kennaway /* crypto/uid.c */
25740a5e3SKris Kennaway /* ====================================================================
35740a5e3SKris Kennaway  * Copyright (c) 2001 The OpenSSL Project.  All rights reserved.
45740a5e3SKris Kennaway  *
55740a5e3SKris Kennaway  * Redistribution and use in source and binary forms, with or without
65740a5e3SKris Kennaway  * modification, are permitted provided that the following conditions
75740a5e3SKris Kennaway  * are met:
85740a5e3SKris Kennaway  *
95740a5e3SKris Kennaway  * 1. Redistributions of source code must retain the above copyright
105740a5e3SKris Kennaway  *    notice, this list of conditions and the following disclaimer.
115740a5e3SKris Kennaway  *
125740a5e3SKris Kennaway  * 2. Redistributions in binary form must reproduce the above copyright
135740a5e3SKris Kennaway  *    notice, this list of conditions and the following disclaimer in
145740a5e3SKris Kennaway  *    the documentation and/or other materials provided with the
155740a5e3SKris Kennaway  *    distribution.
165740a5e3SKris Kennaway  *
175740a5e3SKris Kennaway  * 3. All advertising materials mentioning features or use of this
185740a5e3SKris Kennaway  *    software must display the following acknowledgment:
195740a5e3SKris Kennaway  *    "This product includes software developed by the OpenSSL Project
205740a5e3SKris Kennaway  *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
215740a5e3SKris Kennaway  *
225740a5e3SKris Kennaway  * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
235740a5e3SKris Kennaway  *    endorse or promote products derived from this software without
245740a5e3SKris Kennaway  *    prior written permission. For written permission, please contact
255740a5e3SKris Kennaway  *    licensing@OpenSSL.org.
265740a5e3SKris Kennaway  *
275740a5e3SKris Kennaway  * 5. Products derived from this software may not be called "OpenSSL"
285740a5e3SKris Kennaway  *    nor may "OpenSSL" appear in their names without prior written
295740a5e3SKris Kennaway  *    permission of the OpenSSL Project.
305740a5e3SKris Kennaway  *
315740a5e3SKris Kennaway  * 6. Redistributions of any form whatsoever must retain the following
325740a5e3SKris Kennaway  *    acknowledgment:
335740a5e3SKris Kennaway  *    "This product includes software developed by the OpenSSL Project
345740a5e3SKris Kennaway  *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
355740a5e3SKris Kennaway  *
365740a5e3SKris Kennaway  * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
375740a5e3SKris Kennaway  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
385740a5e3SKris Kennaway  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
395740a5e3SKris Kennaway  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
405740a5e3SKris Kennaway  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
415740a5e3SKris Kennaway  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
425740a5e3SKris Kennaway  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
435740a5e3SKris Kennaway  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
445740a5e3SKris Kennaway  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
455740a5e3SKris Kennaway  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
465740a5e3SKris Kennaway  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
475740a5e3SKris Kennaway  * OF THE POSSIBILITY OF SUCH DAMAGE.
485740a5e3SKris Kennaway  * ====================================================================
495740a5e3SKris Kennaway  *
505740a5e3SKris Kennaway  * This product includes cryptographic software written by Eric Young
515740a5e3SKris Kennaway  * (eay@cryptsoft.com).  This product includes software written by Tim
525740a5e3SKris Kennaway  * Hudson (tjh@cryptsoft.com).
535740a5e3SKris Kennaway  *
545740a5e3SKris Kennaway  */
555740a5e3SKris Kennaway 
565740a5e3SKris Kennaway #include <openssl/crypto.h>
575c87c606SMark Murray #include <openssl/opensslconf.h>
585740a5e3SKris Kennaway 
595740a5e3SKris Kennaway #if defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD__ > 2)
605740a5e3SKris Kennaway 
615c87c606SMark Murray #include OPENSSL_UNISTD
625740a5e3SKris Kennaway 
635740a5e3SKris Kennaway int OPENSSL_issetugid(void)
645740a5e3SKris Kennaway 	{
655740a5e3SKris Kennaway 	return issetugid();
665740a5e3SKris Kennaway 	}
675740a5e3SKris Kennaway 
685c87c606SMark Murray #elif defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VXWORKS)
695740a5e3SKris Kennaway 
705740a5e3SKris Kennaway int OPENSSL_issetugid(void)
715740a5e3SKris Kennaway 	{
725740a5e3SKris Kennaway 	return 0;
735740a5e3SKris Kennaway 	}
745740a5e3SKris Kennaway 
755740a5e3SKris Kennaway #else
765740a5e3SKris Kennaway 
775c87c606SMark Murray #include OPENSSL_UNISTD
785740a5e3SKris Kennaway #include <sys/types.h>
795740a5e3SKris Kennaway 
805740a5e3SKris Kennaway int OPENSSL_issetugid(void)
815740a5e3SKris Kennaway 	{
825740a5e3SKris Kennaway 	if (getuid() != geteuid()) return 1;
835740a5e3SKris Kennaway 	if (getgid() != getegid()) return 1;
845740a5e3SKris Kennaway 	return 0;
855740a5e3SKris Kennaway 	}
865740a5e3SKris Kennaway #endif
875740a5e3SKris Kennaway 
885740a5e3SKris Kennaway 
895740a5e3SKris Kennaway 
90