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 HOST_ABI=elf AC_SUBST([PROG_LDADD], ['-lthr']) ;; + *hpux*) + HOST_OS=hpux; + CFLAGS="$CFLAGS -mlp64 -D_XOPEN_SOURCE=600 -D__STRICT_ALIGNMENT" + AC_SUBST([PLATFORM_LDADD], ['-lpthread']) + ;; *linux*) HOST_OS=linux HOST_ABI=elf @@ -53,6 +58,7 @@ esac AM_CONDITIONAL([HOST_DARWIN], [test x$HOST_OS = xdarwin]) AM_CONDITIONAL([HOST_FREEBSD], [test x$HOST_OS = xfreebsd]) +AM_CONDITIONAL([HOST_HPUX], [test x$HOST_OS = xhpux]) AM_CONDITIONAL([HOST_LINUX], [test x$HOST_OS = xlinux]) AM_CONDITIONAL([HOST_SOLARIS], [test x$HOST_OS = xsolaris]) 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 if HOST_WIN libcompat_la_SOURCES += compat/getentropy_win.c endif +if HOST_HPUX +libcompat_la_SOURCES += compat/getentropy_hpux.c +endif endif endif @@ -97,6 +100,9 @@ endif if HOST_WIN libcompat_la_SOURCES += compat/issetugid_win.c endif +if HOST_HPUX +libcompat_la_SOURCES += compat/issetugid_hpux.c +endif endif noinst_HEADERS = @@ -106,6 +112,7 @@ noinst_HEADERS += compat/arc4random_linux.h noinst_HEADERS += compat/arc4random_osx.h noinst_HEADERS += compat/arc4random_solaris.h noinst_HEADERS += compat/arc4random_win.h +noinst_HEADERS += compat/arc4random_hpux.h noinst_HEADERS += compat/chacha_private.h 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 @@ #if defined(__FreeBSD__) #include "arc4random_freebsd.h" +#elif defined(__hpux) +#include "arc4random_hpux.h" + #elif defined(__linux__) #include "arc4random_linux.h" 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 @@ +#include +#include +#include + +/* + * HP-UX does not have issetugid(). + * This experimental implementation uses pstat_getproc() and get*id(). + * First, try pstat_getproc() and check PS_CHANGEDPRIV bit of pst_flag. + * In case unsuccessful calling pstat_getproc(), using get*id(). + * + */ +int issetugid(void) +{ + struct pst_status buf; + if(pstat_getproc(&buf, sizeof(buf), 0, getpid()) != 1) { + perror("pstat_getproc()"); + } else { + if(buf.pst_flag & PS_CHANGEDPRIV) + return 1; + } + if(getuid() != geteuid()) + return 1; + if(getgid() != getegid()) + return 1; + return 0; +}