summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-11-18 03:47:14 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-11-18 03:47:14 +0000
commitdb8a49614ff65c6e85416e495f9c375fef021942 (patch)
treeac8333df2988012b718fbad399295a011b809252 /process.c
parent1fff70f8b3d22adfa82f989080ecbdc32480b4ef (diff)
* process.c (proc_getpgrp): prohibit for $SAFE=2.
[ruby-dev:24899] * process.c (get_pid): ditto. [ruby-dev:24904] * process.c (get_ppid): ditto. * array.c (rb_ary_delete): defer rb_ary_modify() until actual modification. [ruby-dev:24901] * parse.y (newline_node): should not use FL_SET. [ruby-dev:24874] * parse.y (string_content): should not use FL_UNSET. * node.h (NODE_NEWLINE): remove unused bit to utilize flag field in nodes. * string.c (rb_str_splice): move rb_str_modify() after StringValue(), which may alter the receiver. [ruby-dev:24878] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r--process.c56
1 files changed, 27 insertions, 29 deletions
diff --git a/process.c b/process.c
index 5fa1b9510b..cb77275ccc 100644
--- a/process.c
+++ b/process.c
@@ -124,6 +124,7 @@ static VALUE S_Tms;
static VALUE
get_pid()
{
+ rb_secure(2);
return INT2FIX(getpid());
}
@@ -147,6 +148,7 @@ get_pid()
static VALUE
get_ppid()
{
+ rb_secure(2);
#ifdef _WIN32
return INT2FIX(0);
#else
@@ -724,6 +726,7 @@ proc_wait(argc, argv)
VALUE vpid, vflags;
int pid, flags, status;
+ rb_secure(2);
flags = 0;
rb_scan_args(argc, argv, "02", &vpid, &vflags);
if (argc == 0) {
@@ -798,6 +801,7 @@ proc_waitall()
VALUE result;
int pid, status;
+ rb_secure(2);
result = rb_ary_new();
#ifdef NO_WAITPID
if (pid_tbl) {
@@ -899,6 +903,7 @@ static VALUE
proc_detach(obj, pid)
VALUE pid;
{
+ rb_secure(2);
return rb_detach_process(NUM2INT(pid));
}
@@ -1590,6 +1595,7 @@ proc_getpgrp()
{
int pgrp;
+ rb_secure(2);
#if defined(HAVE_GETPGRP) && defined(GETPGRP_VOID)
pgrp = getpgrp();
if (pgrp < 0) rb_sys_fail(0);
@@ -1617,12 +1623,13 @@ proc_getpgrp()
static VALUE
proc_setpgrp()
{
+ rb_secure(2);
/* check for posix setpgid() first; this matches the posix */
/* getpgrp() above. It appears that configure will set SETPGRP_VOID */
/* even though setpgrp(0,0) would be prefered. The posix call avoids */
/* this confusion. */
#ifdef HAVE_SETPGID
- if (setpgid(0,0) < 0) rb_sys_fail(0);
+ if (setpgid(0,0) < 0) rb_sys_fail(0);
#elif defined(HAVE_SETPGRP) && defined(SETPGRP_VOID)
if (setpgrp() < 0) rb_sys_fail(0);
#else
@@ -1647,8 +1654,10 @@ proc_getpgid(obj, pid)
VALUE obj, pid;
{
#if defined(HAVE_GETPGID) && !defined(__CHECKER__)
- int i = getpgid(NUM2INT(pid));
+ int i;
+ rb_secure(2);
+ i = getpgid(NUM2INT(pid));
if (i < 0) rb_sys_fail(0);
return INT2NUM(i);
#else
@@ -1756,6 +1765,7 @@ proc_getpriority(obj, which, who)
#ifdef HAVE_GETPRIORITY
int prio, iwhich, iwho;
+ rb_secure(2);
iwhich = NUM2INT(which);
iwho = NUM2INT(who);
@@ -2314,6 +2324,7 @@ p_sys_issetugid(obj)
VALUE obj;
{
#if defined HAVE_ISSETUGID
+ rb_secure(2);
if (issetugid()) {
return Qtrue;
} else {
@@ -3454,26 +3465,18 @@ Init_process()
rb_define_module_function(rb_mProcGID, "rid", proc_getgid, 0);
rb_define_module_function(rb_mProcUID, "eid", proc_geteuid, 0);
rb_define_module_function(rb_mProcGID, "eid", proc_getegid, 0);
- rb_define_module_function(rb_mProcUID, "change_privilege",
- p_uid_change_privilege, 1);
- rb_define_module_function(rb_mProcGID, "change_privilege",
- p_gid_change_privilege, 1);
- rb_define_module_function(rb_mProcUID, "grant_privilege",
- p_uid_grant_privilege, 1);
- rb_define_module_function(rb_mProcGID, "grant_privilege",
- p_gid_grant_privilege, 1);
+ rb_define_module_function(rb_mProcUID, "change_privilege", p_uid_change_privilege, 1);
+ rb_define_module_function(rb_mProcGID, "change_privilege", p_gid_change_privilege, 1);
+ rb_define_module_function(rb_mProcUID, "grant_privilege", p_uid_grant_privilege, 1);
+ rb_define_module_function(rb_mProcGID, "grant_privilege", p_gid_grant_privilege, 1);
rb_define_alias(rb_mProcUID, "eid=", "grant_privilege");
rb_define_alias(rb_mProcGID, "eid=", "grant_privilege");
rb_define_module_function(rb_mProcUID, "re_exchange", p_uid_exchange, 0);
rb_define_module_function(rb_mProcGID, "re_exchange", p_gid_exchange, 0);
- rb_define_module_function(rb_mProcUID, "re_exchangeable?",
- p_uid_exchangeable, 0);
- rb_define_module_function(rb_mProcGID, "re_exchangeable?",
- p_gid_exchangeable, 0);
- rb_define_module_function(rb_mProcUID, "sid_available?",
- p_uid_have_saved_id, 0);
- rb_define_module_function(rb_mProcGID, "sid_available?",
- p_gid_have_saved_id, 0);
+ rb_define_module_function(rb_mProcUID, "re_exchangeable?", p_uid_exchangeable, 0);
+ rb_define_module_function(rb_mProcGID, "re_exchangeable?", p_gid_exchangeable, 0);
+ rb_define_module_function(rb_mProcUID, "sid_available?", p_uid_have_saved_id, 0);
+ rb_define_module_function(rb_mProcGID, "sid_available?", p_gid_have_saved_id, 0);
rb_define_module_function(rb_mProcUID, "switch", p_uid_switch, 0);
rb_define_module_function(rb_mProcGID, "switch", p_gid_switch, 0);
@@ -3493,15 +3496,10 @@ Init_process()
rb_define_module_function(rb_mProcID_Syscall, "seteuid", p_sys_seteuid, 1);
rb_define_module_function(rb_mProcID_Syscall, "setegid", p_sys_setegid, 1);
- rb_define_module_function(rb_mProcID_Syscall, "setreuid",
- p_sys_setreuid, 2);
- rb_define_module_function(rb_mProcID_Syscall, "setregid",
- p_sys_setregid, 2);
-
- rb_define_module_function(rb_mProcID_Syscall, "setresuid",
- p_sys_setresuid, 3);
- rb_define_module_function(rb_mProcID_Syscall, "setresgid",
- p_sys_setresgid, 3);
- rb_define_module_function(rb_mProcID_Syscall, "issetugid",
- p_sys_issetugid, 0);
+ rb_define_module_function(rb_mProcID_Syscall, "setreuid", p_sys_setreuid, 2);
+ rb_define_module_function(rb_mProcID_Syscall, "setregid", p_sys_setregid, 2);
+
+ rb_define_module_function(rb_mProcID_Syscall, "setresuid", p_sys_setresuid, 3);
+ rb_define_module_function(rb_mProcID_Syscall, "setresgid", p_sys_setresgid, 3);
+ rb_define_module_function(rb_mProcID_Syscall, "issetugid", p_sys_issetugid, 0);
}