From: Jamie Herre Date: 2002-07-06T01:12:14+09:00 Subject: openbsd system call changes Hi, I'm assuming that this is the right place to send proposed patches for ruby. I made the following changes in order to get the current ruby to compile on my OpenBSD system. Mostly just a matter of changing the order of preference for various system calls. Let me know if I'm barking up the wrong tree with this. Thanks, -J ------------------------------------------------------ Jamie Herre Gettys Group Software, Inc. jfh@gettys.com Index: process.c =================================================================== RCS file: /src/ruby/process.c,v retrieving revision 1.52 diff -u -r1.52 process.c --- process.c 2002/05/14 06:22:26 1.52 +++ process.c 2002/07/05 15:49:40 @@ -996,13 +996,13 @@ { int pgrp; -#if defined(HAVE_GETPGRP) && defined(GETPGRP_VOID) - pgrp = getpgrp(); +#ifdef HAVE_GETPGID + pgrp = getpgid(0); if (pgrp < 0) rb_sys_fail(0); return INT2FIX(pgrp); #else -# ifdef HAVE_GETPGID - pgrp = getpgid(0); +# if defined(HAVE_GETPGRP) && defined(GETPGRP_VOID) + pgrp = getpgrp(); if (pgrp < 0) rb_sys_fail(0); return INT2FIX(pgrp); # else @@ -1014,11 +1014,11 @@ static VALUE proc_setpgrp() { -#if defined(HAVE_SETPGRP) && defined(SETPGRP_VOID) - if (setpgrp() < 0) rb_sys_fail(0); -#else -# ifdef HAVE_SETPGID +#ifdef HAVE_SETPGID if (setpgid(0, 0) < 0) rb_sys_fail(0); +#else +# if defined(HAVE_SETPGRP) && defined(SETPGRP_VOID) + if (setpgrp() < 0) rb_sys_fail(0); # else rb_notimplement(); # endif @@ -1151,10 +1151,10 @@ uid = NUM2INT(id); #if defined(HAVE_SETRESUID) && !defined(__CHECKER__) if (setresuid(uid, -1, -1) < 0) rb_sys_fail(0); -#elif defined HAVE_SETREUID - if (setreuid(uid, -1) < 0) rb_sys_fail(0); #elif defined HAVE_SETRUID if (setruid(uid) < 0) rb_sys_fail(0); +#elif defined HAVE_SETREUID + if (setreuid(uid, -1) < 0) rb_sys_fail(0); #else { if (geteuid() == uid) { @@ -1185,6 +1185,8 @@ gid = NUM2INT(id); #if defined(HAVE_SETRESGID) && !defined(__CHECKER__) if (setresgid(gid, -1, -1) < 0) rb_sys_fail(0); +#elif defined HAVE_SETEGID + if (setgid(gid) < 0) rb_sys_fail(0); #elif defined HAVE_SETREGID if (setregid(gid, -1) < 0) rb_sys_fail(0); #elif defined HAS_SETRGID @@ -1214,12 +1216,12 @@ proc_seteuid(obj, euid) VALUE obj, euid; { -#if defined(HAVE_SETRESUID) && !defined(__CHECKER__) +#if defined HAVE_SETEUID + if (seteuid(NUM2INT(euid)) < 0) rb_sys_fail(0); +#elif defined(HAVE_SETRESUID) && !defined(__CHECKER__) if (setresuid(-1, NUM2INT(euid), -1) < 0) rb_sys_fail(0); #elif defined HAVE_SETREUID if (setreuid(-1, NUM2INT(euid)) < 0) rb_sys_fail(0); -#elif defined HAVE_SETEUID - if (seteuid(NUM2INT(euid)) < 0) rb_sys_fail(0); #else euid = NUM2INT(euid); if (euid == getuid()) { @@ -1247,10 +1249,10 @@ rb_secure(2); #if defined(HAVE_SETRESGID) && !defined(__CHECKER__) if (setresgid(-1, NUM2INT(egid), -1) < 0) rb_sys_fail(0); -#elif defined HAVE_SETREGID - if (setregid(-1, NUM2INT(egid)) < 0) rb_sys_fail(0); #elif defined HAVE_SETEGID if (setegid(NUM2INT(egid)) < 0) rb_sys_fail(0); +#elif defined HAVE_SETREGID + if (setregid(-1, NUM2INT(egid)) < 0) rb_sys_fail(0); #else egid = NUM2INT(egid); if (egid == getgid()) { Index: ext/dl/dl.h =================================================================== RCS file: /src/ruby/ext/dl/dl.h,v retrieving revision 1.6 diff -u -r1.6 dl.h --- ext/dl/dl.h 2002/05/20 15:35:48 1.6 +++ ext/dl/dl.h 2002/07/05 15:49:41 @@ -15,6 +15,16 @@ #if defined(HAVE_DLFCN_H) # include +# /* some stranger systems may not define all these */ +# ifndef RTLD_LAZY +# define RTLD_LAZY 0 +# endif +# ifndef RTLD_GLOBAL +# define RTLD_GLOBAL 0 +# endif +# ifndef RTLD_NOW +# define RTLD_NOW 0 +# endif #else # if defined(HAVE_WINDOWS_H) # include