1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

setres[ug]id, NORETURN

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1106 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
eban 2001-01-10 07:30:18 +00:00
parent ab9be24857
commit 6b5ad7c5b2
7 changed files with 58 additions and 39 deletions

View file

@ -1,3 +1,17 @@
Wed Jan 10 16:15:08 2001 WATANABE Hirofumi <eban@ruby-lang.org>
* ruby.h: NORETURN macro is changed for VC++ 6.0.
* eval.c, intern.h: ditto.
Wed Jan 10 13:54:53 2001 WATANABE Hirofumi <eban@ruby-lang.org>
* process.c (proc_setuid): use setresuid() if available.
* process.c (proc_setgid): use setresgid() if available.
* configure.in: ditto.
Wed Jan 10 01:50:45 2001 Yukihiro Matsumoto <matz@ruby-lang.org> Wed Jan 10 01:50:45 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (rb_str_reverse_bang): forgot to call rb_str_modify(). * string.c (rb_str_reverse_bang): forgot to call rb_str_modify().

View file

@ -262,7 +262,8 @@ AC_REPLACE_FUNCS(dup2 memmove mkdir strcasecmp strncasecmp strerror strftime\
isinf isnan finite) isinf isnan finite)
AC_CHECK_FUNCS(fmod killpg drand48 random wait4 waitpid syscall getcwd chroot\ AC_CHECK_FUNCS(fmod killpg drand48 random wait4 waitpid syscall getcwd chroot\
truncate chsize times utimes fcntl lockf lstat symlink readlink\ truncate chsize times utimes fcntl lockf lstat symlink readlink\
setitimer setruid seteuid setreuid setrgid setegid setregid pause\ setitimer setruid seteuid setreuid setresuid \
setrgid setegid setregid setresgid pause\
getpgrp setpgrp getpgid setpgid getgroups getpriority getrlimit\ getpgrp setpgrp getpgid setpgid getgroups getpriority getrlimit\
dlopen sigprocmask sigaction _setjmp setsid telldir seekdir fchmod) dlopen sigprocmask sigaction _setjmp setsid telldir seekdir fchmod)
AC_STRUCT_TIMEZONE AC_STRUCT_TIMEZONE

6
eval.c
View file

@ -167,7 +167,7 @@ rb_check_safe_str(x)
} }
} }
static void print_undef _((VALUE, ID)) NORETURN; NORETURN(static void print_undef _((VALUE, ID)));
static void static void
print_undef(klass, id) print_undef(klass, id)
VALUE klass; VALUE klass;
@ -3312,7 +3312,7 @@ rb_iter_break()
JUMP_TAG(TAG_BREAK); JUMP_TAG(TAG_BREAK);
} }
static void rb_longjmp _((int, VALUE)) NORETURN; NORETURN(static void rb_longjmp _((int, VALUE)));
static VALUE make_backtrace _((void)); static VALUE make_backtrace _((void));
static void static void
@ -5635,7 +5635,7 @@ rb_f_local_variables()
} }
static VALUE rb_f_catch _((VALUE,VALUE)); static VALUE rb_f_catch _((VALUE,VALUE));
static VALUE rb_f_throw _((int,VALUE*)) NORETURN; NORETURN(static VALUE rb_f_throw _((int,VALUE*)));
struct end_proc_data { struct end_proc_data {
void (*func)(); void (*func)();

View file

@ -104,13 +104,13 @@ EXTERN int ruby_nerrs;
VALUE rb_exc_new _((VALUE, const char*, long)); VALUE rb_exc_new _((VALUE, const char*, long));
VALUE rb_exc_new2 _((VALUE, const char*)); VALUE rb_exc_new2 _((VALUE, const char*));
VALUE rb_exc_new3 _((VALUE, VALUE)); VALUE rb_exc_new3 _((VALUE, VALUE));
void rb_loaderror __((const char*, ...)) NORETURN; NORETURN(void rb_loaderror __((const char*, ...)));
void rb_compile_error __((const char*, ...)); void rb_compile_error __((const char*, ...));
void rb_compile_error_append __((const char*, ...)); void rb_compile_error_append __((const char*, ...));
void rb_error_frozen _((char*)) NORETURN; NORETURN(void rb_error_frozen _((char*)));
/* eval.c */ /* eval.c */
void rb_exc_raise _((VALUE)) NORETURN; NORETURN(void rb_exc_raise _((VALUE)));
void rb_exc_fatal _((VALUE)) NORETURN; NORETURN(void rb_exc_fatal _((VALUE)));
void rb_remove_method _((VALUE, const char*)); void rb_remove_method _((VALUE, const char*));
void rb_disable_super _((VALUE, const char*)); void rb_disable_super _((VALUE, const char*));
void rb_enable_super _((VALUE, const char*)); void rb_enable_super _((VALUE, const char*));
@ -132,7 +132,7 @@ ID rb_frame_last_func _((void));
VALUE rb_obj_instance_eval _((int, VALUE*, VALUE)); VALUE rb_obj_instance_eval _((int, VALUE*, VALUE));
void rb_load _((VALUE, int)); void rb_load _((VALUE, int));
void rb_load_protect _((VALUE, int, int*)); void rb_load_protect _((VALUE, int, int*));
void rb_jump_tag _((int)) NORETURN; NORETURN(void rb_jump_tag _((int)));
int rb_provided _((const char*)); int rb_provided _((const char*));
void rb_provide _((const char*)); void rb_provide _((const char*));
VALUE rb_f_require _((VALUE, VALUE)); VALUE rb_f_require _((VALUE, VALUE));

View file

@ -952,10 +952,11 @@ proc_setuid(obj, id)
int uid; int uid;
uid = NUM2INT(id); uid = NUM2INT(id);
#ifdef HAVE_SETREUID #if defined HAVE_SETRESUID
setresuid(uid, -1, -1);
#elif defined HAVE_SETREUID
setreuid(uid, -1); setreuid(uid, -1);
#else #elif defined HAVE_SETRUID
#ifdef HAVE_SETRUID
setruid(uid); setruid(uid);
#else #else
{ {
@ -964,7 +965,6 @@ proc_setuid(obj, id)
else else
rb_notimplement(); rb_notimplement();
} }
#endif
#endif #endif
return INT2FIX(uid); return INT2FIX(uid);
} }
@ -984,11 +984,12 @@ proc_setgid(obj, id)
int gid; int gid;
gid = NUM2INT(id); gid = NUM2INT(id);
#ifdef HAS_SETRGID #if defined HAVE_SETRESGID
setrgid((GIDTYPE)gid); setresgid(gid, -1, -1);
#else #elif defined HAVE_SETREGID
#ifdef HAVE_SETREGID
setregid(gid, -1); setregid(gid, -1);
#elif defined HAS_SETRGID
setrgid((GIDTYPE)gid);
#else #else
{ {
if (getegid() == gid) if (getegid() == gid)
@ -996,7 +997,6 @@ proc_setgid(obj, id)
else else
rb_notimplement(); rb_notimplement();
} }
#endif
#endif #endif
return INT2FIX(gid); return INT2FIX(gid);
} }
@ -1013,18 +1013,18 @@ static VALUE
proc_seteuid(obj, euid) proc_seteuid(obj, euid)
VALUE obj, euid; VALUE obj, euid;
{ {
#ifdef HAVE_SETEUID #if defined HAVE_SETRESUID
if (seteuid(NUM2INT(euid)) < 0) rb_sys_fail(0); if (setresuid(-1, NUM2INT(euid), -1) < 0) rb_sys_fail(0);
#else #elif defined HAVE_SETREUID
#ifdef HAVE_SETREUID
if (setreuid(-1, NUM2INT(euid)) < 0) rb_sys_fail(0); if (setreuid(-1, NUM2INT(euid)) < 0) rb_sys_fail(0);
#elif defined HAVE_SETEUID
if (seteuid(NUM2INT(euid)) < 0) rb_sys_fail(0);
#else #else
euid = NUM2INT(euid); euid = NUM2INT(euid);
if (euid == getuid()) if (euid == getuid())
setuid(euid); setuid(euid);
else else
rb_notimplement(); rb_notimplement();
#endif
#endif #endif
return euid; return euid;
} }
@ -1042,18 +1042,18 @@ proc_setegid(obj, egid)
VALUE obj, egid; VALUE obj, egid;
{ {
rb_secure(2); rb_secure(2);
#ifdef HAVE_SETEGID #if defined HAVE_SETRESGID
if (setegid(NUM2INT(egid)) < 0) rb_sys_fail(0); if (setresgid(-1, NUM2INT(egid), -1) < 0) rb_sys_fail(0);
#else #elif defined HAVE_SETREGID
#ifdef HAVE_SETREGID
if (setregid(-1, NUM2INT(egid)) < 0) rb_sys_fail(0); if (setregid(-1, NUM2INT(egid)) < 0) rb_sys_fail(0);
#elif defined HAVE_SETEGID
if (setegid(NUM2INT(egid)) < 0) rb_sys_fail(0);
#else #else
egid = NUM2INT(egid); egid = NUM2INT(egid);
if (egid == getgid()) if (egid == getgid())
setgid(egid); setgid(egid);
else else
rb_notimplement(); rb_notimplement();
#endif
#endif #endif
return egid; return egid;
} }

22
ruby.h
View file

@ -64,9 +64,9 @@ extern "C" {
#endif #endif
#ifdef HAVE_ATTR_NORETURN #ifdef HAVE_ATTR_NORETURN
# define NORETURN __attribute__ ((noreturn)) # define NORETURN(x) x __attribute__ ((noreturn))
#else #elif !defined NORETURN
# define NORETURN # define NORETURN(x) x
#endif #endif
#if defined(HAVE_ALLOCA_H) && !defined(__GNUC__) #if defined(HAVE_ALLOCA_H) && !defined(__GNUC__)
@ -453,13 +453,13 @@ VALUE rb_equal _((VALUE,VALUE));
EXTERN VALUE ruby_verbose, ruby_debug; EXTERN VALUE ruby_verbose, ruby_debug;
void rb_raise __((VALUE, const char*, ...)) NORETURN; NORETURN(void rb_raise __((VALUE, const char*, ...)));
void rb_fatal __((const char*, ...)) NORETURN; NORETURN(void rb_fatal __((const char*, ...)));
void rb_bug __((const char*, ...)) NORETURN; NORETURN(void rb_bug __((const char*, ...)));
void rb_sys_fail _((const char*)) NORETURN; NORETURN(void rb_sys_fail _((const char*)));
void rb_iter_break _((void)) NORETURN; NORETURN(void rb_iter_break _((void)));
void rb_exit _((int)) NORETURN; NORETURN(void rb_exit _((int)));
void rb_notimplement _((void)) NORETURN; NORETURN(void rb_notimplement _((void)));
void rb_warn __((const char*, ...)); void rb_warn __((const char*, ...));
void rb_warning __((const char*, ...)); /* reports if `-w' specified */ void rb_warning __((const char*, ...)); /* reports if `-w' specified */
@ -472,7 +472,7 @@ VALUE rb_rescue _((VALUE(*)(),VALUE,VALUE(*)(),VALUE));
VALUE rb_rescue2 __((VALUE(*)(),VALUE,VALUE(*)(),VALUE,...)); VALUE rb_rescue2 __((VALUE(*)(),VALUE,VALUE(*)(),VALUE,...));
VALUE rb_ensure _((VALUE(*)(),VALUE,VALUE(*)(),VALUE)); VALUE rb_ensure _((VALUE(*)(),VALUE,VALUE(*)(),VALUE));
VALUE rb_catch _((const char*,VALUE(*)(),VALUE)); VALUE rb_catch _((const char*,VALUE(*)(),VALUE));
void rb_throw _((const char*,VALUE)) NORETURN; NORETURN(void rb_throw _((const char*,VALUE)));
VALUE rb_require _((const char*)); VALUE rb_require _((const char*));

View file

@ -16,6 +16,10 @@
#define EXTERN extern __declspec(dllexport) #define EXTERN extern __declspec(dllexport)
#endif #endif
#if defined _MSC_VER
#define NORETURN(x) __declspec(noreturn) x
#endif
// //
// Definitions for NT port of Perl // Definitions for NT port of Perl
// //