aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac6
-rw-r--r--crypto/Makefile.am7
-rw-r--r--crypto/compat/arc4random.h3
-rw-r--r--crypto/compat/issetugid_hpux.c26
4 files changed, 42 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 51e35a8..e92b602 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,6 +22,11 @@ case $host_os in
22 HOST_ABI=elf 22 HOST_ABI=elf
23 AC_SUBST([PROG_LDADD], ['-lthr']) 23 AC_SUBST([PROG_LDADD], ['-lthr'])
24 ;; 24 ;;
25 *hpux*)
26 HOST_OS=hpux;
27 CFLAGS="$CFLAGS -mlp64 -D_XOPEN_SOURCE=600 -D__STRICT_ALIGNMENT"
28 AC_SUBST([PLATFORM_LDADD], ['-lpthread'])
29 ;;
25 *linux*) 30 *linux*)
26 HOST_OS=linux 31 HOST_OS=linux
27 HOST_ABI=elf 32 HOST_ABI=elf
@@ -53,6 +58,7 @@ esac
53 58
54AM_CONDITIONAL([HOST_DARWIN], [test x$HOST_OS = xdarwin]) 59AM_CONDITIONAL([HOST_DARWIN], [test x$HOST_OS = xdarwin])
55AM_CONDITIONAL([HOST_FREEBSD], [test x$HOST_OS = xfreebsd]) 60AM_CONDITIONAL([HOST_FREEBSD], [test x$HOST_OS = xfreebsd])
61AM_CONDITIONAL([HOST_HPUX], [test x$HOST_OS = xhpux])
56AM_CONDITIONAL([HOST_LINUX], [test x$HOST_OS = xlinux]) 62AM_CONDITIONAL([HOST_LINUX], [test x$HOST_OS = xlinux])
57AM_CONDITIONAL([HOST_SOLARIS], [test x$HOST_OS = xsolaris]) 63AM_CONDITIONAL([HOST_SOLARIS], [test x$HOST_OS = xsolaris])
58AM_CONDITIONAL([HOST_WIN], [test x$HOST_OS = xwin]) 64AM_CONDITIONAL([HOST_WIN], [test x$HOST_OS = xwin])
diff --git a/crypto/Makefile.am b/crypto/Makefile.am
index e5a4d4d..9f5311a 100644
--- a/crypto/Makefile.am
+++ b/crypto/Makefile.am
@@ -86,6 +86,9 @@ endif
86if HOST_WIN 86if HOST_WIN
87libcompat_la_SOURCES += compat/getentropy_win.c 87libcompat_la_SOURCES += compat/getentropy_win.c
88endif 88endif
89if HOST_HPUX
90libcompat_la_SOURCES += compat/getentropy_hpux.c
91endif
89endif 92endif
90 93
91endif 94endif
@@ -97,6 +100,9 @@ endif
97if HOST_WIN 100if HOST_WIN
98libcompat_la_SOURCES += compat/issetugid_win.c 101libcompat_la_SOURCES += compat/issetugid_win.c
99endif 102endif
103if HOST_HPUX
104libcompat_la_SOURCES += compat/issetugid_hpux.c
105endif
100endif 106endif
101 107
102noinst_HEADERS = 108noinst_HEADERS =
@@ -106,6 +112,7 @@ noinst_HEADERS += compat/arc4random_linux.h
106noinst_HEADERS += compat/arc4random_osx.h 112noinst_HEADERS += compat/arc4random_osx.h
107noinst_HEADERS += compat/arc4random_solaris.h 113noinst_HEADERS += compat/arc4random_solaris.h
108noinst_HEADERS += compat/arc4random_win.h 114noinst_HEADERS += compat/arc4random_win.h
115noinst_HEADERS += compat/arc4random_hpux.h
109noinst_HEADERS += compat/chacha_private.h 116noinst_HEADERS += compat/chacha_private.h
110 117
111libcrypto_la_SOURCES = 118libcrypto_la_SOURCES =
diff --git a/crypto/compat/arc4random.h b/crypto/compat/arc4random.h
index 53b5a46..ed812ba 100644
--- a/crypto/compat/arc4random.h
+++ b/crypto/compat/arc4random.h
@@ -6,6 +6,9 @@
6#if defined(__FreeBSD__) 6#if defined(__FreeBSD__)
7#include "arc4random_freebsd.h" 7#include "arc4random_freebsd.h"
8 8
9#elif defined(__hpux)
10#include "arc4random_hpux.h"
11
9#elif defined(__linux__) 12#elif defined(__linux__)
10#include "arc4random_linux.h" 13#include "arc4random_linux.h"
11 14
diff --git a/crypto/compat/issetugid_hpux.c b/crypto/compat/issetugid_hpux.c
new file mode 100644
index 0000000..73def9b
--- /dev/null
+++ b/crypto/compat/issetugid_hpux.c
@@ -0,0 +1,26 @@
1#include <stdio.h>
2#include <unistd.h>
3#include <sys/pstat.h>
4
5/*
6 * HP-UX does not have issetugid().
7 * This experimental implementation uses pstat_getproc() and get*id().
8 * First, try pstat_getproc() and check PS_CHANGEDPRIV bit of pst_flag.
9 * In case unsuccessful calling pstat_getproc(), using get*id().
10 *
11 */
12int issetugid(void)
13{
14 struct pst_status buf;
15 if(pstat_getproc(&buf, sizeof(buf), 0, getpid()) != 1) {
16 perror("pstat_getproc()");
17 } else {
18 if(buf.pst_flag & PS_CHANGEDPRIV)
19 return 1;
20 }
21 if(getuid() != geteuid())
22 return 1;
23 if(getgid() != getegid())
24 return 1;
25 return 0;
26}