diff options
author | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-11-18 08:39:29 +0000 |
---|---|---|
committer | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-11-18 08:39:29 +0000 |
commit | ed9a1f3e8fc3f8ccc6fd824dd11e28afb3582e76 (patch) | |
tree | 9a627ac05979783c4c8811230de6eac6040e5405 /ext/tk/tcltklib.c | |
parent | e93a1c580ef8ea27fcb153835539ace16900ae47 (diff) |
* ext/tk/lib/multi-tk.rb: add restriction to access the entried
command table and manipulate other IPs (for reason of security).
Now, a IP object can be controlled by only its master IP or the
default IP.
* ext/tk/lib/remote-tk.rb: add restriction to manipulate.
* ext/tk/tcltklib.c (ip_is_slave_of_p): add TclTkIp#slave_of?(ip)
to check manipulability.
* ext/tk/lib/tk.rb: bug fix on handling of Tcl's namespaces.
* ext/tk/lib/tk/namespace.rb: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9562 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/tcltklib.c')
-rw-r--r-- | ext/tk/tcltklib.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/ext/tk/tcltklib.c b/ext/tk/tcltklib.c index da162d8d22..74eb500294 100644 --- a/ext/tk/tcltklib.c +++ b/ext/tk/tcltklib.c @@ -4,7 +4,7 @@ * Oct. 24, 1997 Y. Matsumoto */ -#define TCLTKLIB_RELEASE_DATE "2005-11-07" +#define TCLTKLIB_RELEASE_DATE "2005-11-18" #include "ruby.h" #include "rubysig.h" @@ -94,6 +94,8 @@ static VALUE eTkCallbackRetry; static VALUE eTkCallbackRedo; static VALUE eTkCallbackThrow; +static VALUE tcltkip_class; + static ID ID_at_enc; static ID ID_at_interp; @@ -4926,6 +4928,25 @@ ip_create_slave(argc, argv, self) return tk_funcall(ip_create_slave_core, 2, callargv, self); } + +/* self is slave of master? */ +static VALUE +ip_is_slave_of_p(self, master) + VALUE self, master; +{ + if (!rb_obj_is_kind_of(master, tcltkip_class)) { + rb_raise(rb_eArgError, "expected TclTkIp object"); + } + + if (Tcl_GetMaster(get_ip(self)->ip) == get_ip(master)->ip) { + return Qtrue; + } else { + return Qfalse; + } +} + + +/* create console (if supported) */ #if defined(MAC_TCL) || defined(__WIN32__) #if TCL_MAJOR_VERSION < 8 \ || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0) \ @@ -7625,6 +7646,10 @@ Init_tcltklib() /* --------------------------------------------------------------- */ + tcltkip_class = ip; + + /* --------------------------------------------------------------- */ + rb_global_variable(&eTkCallbackReturn); rb_global_variable(&eTkCallbackBreak); rb_global_variable(&eTkCallbackContinue); @@ -7766,6 +7791,7 @@ Init_tcltklib() rb_define_alloc_func(ip, ip_alloc); rb_define_method(ip, "initialize", ip_init, -1); rb_define_method(ip, "create_slave", ip_create_slave, -1); + rb_define_method(ip, "slave_of?", ip_is_slave_of_p, 1); rb_define_method(ip, "make_safe", ip_make_safe, 0); rb_define_method(ip, "safe?", ip_is_safe_p, 0); rb_define_method(ip, "allow_ruby_exit?", ip_allow_ruby_exit_p, 0); |