diff options
author | kinichiro <kinichiro.inoguchi@gmail.com> | 2014-12-08 11:08:45 +0900 |
---|---|---|
committer | Brent Cook <busterb@gmail.com> | 2015-01-06 17:47:16 -0600 |
commit | 0308b63cbf9983a9bcddc2794b1c9fa0d92f18ac (patch) | |
tree | 778a1d147f6719016103fa04aa36bbf53526a804 | |
parent | 4b7e78153c47ae08420558e7e6d8b0bc2591039c (diff) | |
download | portable-0308b63cbf9983a9bcddc2794b1c9fa0d92f18ac.tar.gz portable-0308b63cbf9983a9bcddc2794b1c9fa0d92f18ac.tar.bz2 portable-0308b63cbf9983a9bcddc2794b1c9fa0d92f18ac.zip |
Add support for HP-UX
tested on: HP-UX 11.31 ia64,
gcc 4.7.1(HP AllianceOne version)
gcc 4.2.3(http://hpux.connect.org.uk)
HP C/aC++
HP-UX defaults to use LP32 and it treats long as 32 bit (= 4 bytes).
This build forces LP64 for treating long as 64 bit.
-rw-r--r-- | configure.ac | 6 | ||||
-rw-r--r-- | crypto/Makefile.am | 7 | ||||
-rw-r--r-- | crypto/compat/arc4random.h | 3 | ||||
-rw-r--r-- | crypto/compat/issetugid_hpux.c | 26 |
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 | ||
54 | AM_CONDITIONAL([HOST_DARWIN], [test x$HOST_OS = xdarwin]) | 59 | AM_CONDITIONAL([HOST_DARWIN], [test x$HOST_OS = xdarwin]) |
55 | AM_CONDITIONAL([HOST_FREEBSD], [test x$HOST_OS = xfreebsd]) | 60 | AM_CONDITIONAL([HOST_FREEBSD], [test x$HOST_OS = xfreebsd]) |
61 | AM_CONDITIONAL([HOST_HPUX], [test x$HOST_OS = xhpux]) | ||
56 | AM_CONDITIONAL([HOST_LINUX], [test x$HOST_OS = xlinux]) | 62 | AM_CONDITIONAL([HOST_LINUX], [test x$HOST_OS = xlinux]) |
57 | AM_CONDITIONAL([HOST_SOLARIS], [test x$HOST_OS = xsolaris]) | 63 | AM_CONDITIONAL([HOST_SOLARIS], [test x$HOST_OS = xsolaris]) |
58 | AM_CONDITIONAL([HOST_WIN], [test x$HOST_OS = xwin]) | 64 | AM_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 | |||
86 | if HOST_WIN | 86 | if HOST_WIN |
87 | libcompat_la_SOURCES += compat/getentropy_win.c | 87 | libcompat_la_SOURCES += compat/getentropy_win.c |
88 | endif | 88 | endif |
89 | if HOST_HPUX | ||
90 | libcompat_la_SOURCES += compat/getentropy_hpux.c | ||
91 | endif | ||
89 | endif | 92 | endif |
90 | 93 | ||
91 | endif | 94 | endif |
@@ -97,6 +100,9 @@ endif | |||
97 | if HOST_WIN | 100 | if HOST_WIN |
98 | libcompat_la_SOURCES += compat/issetugid_win.c | 101 | libcompat_la_SOURCES += compat/issetugid_win.c |
99 | endif | 102 | endif |
103 | if HOST_HPUX | ||
104 | libcompat_la_SOURCES += compat/issetugid_hpux.c | ||
105 | endif | ||
100 | endif | 106 | endif |
101 | 107 | ||
102 | noinst_HEADERS = | 108 | noinst_HEADERS = |
@@ -106,6 +112,7 @@ noinst_HEADERS += compat/arc4random_linux.h | |||
106 | noinst_HEADERS += compat/arc4random_osx.h | 112 | noinst_HEADERS += compat/arc4random_osx.h |
107 | noinst_HEADERS += compat/arc4random_solaris.h | 113 | noinst_HEADERS += compat/arc4random_solaris.h |
108 | noinst_HEADERS += compat/arc4random_win.h | 114 | noinst_HEADERS += compat/arc4random_win.h |
115 | noinst_HEADERS += compat/arc4random_hpux.h | ||
109 | noinst_HEADERS += compat/chacha_private.h | 116 | noinst_HEADERS += compat/chacha_private.h |
110 | 117 | ||
111 | libcrypto_la_SOURCES = | 118 | libcrypto_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 | */ | ||
12 | int 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 | } | ||