summaryrefslogtreecommitdiff
path: root/ext/tk/tcltklib.c
diff options
context:
space:
mode:
authornagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-11-18 08:39:29 +0000
committernagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-11-18 08:39:29 +0000
commitd3a17b1ee02e2828ccaf8171385f45d9383ce6d1 (patch)
tree796c091c6c9154d12066cf2bdbfaab3bb49a4ea8 /ext/tk/tcltklib.c
parent147dcb2236416f0d40497caf2cc5eba754bbbefb (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/branches/ruby_1_8@9562 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/tcltklib.c')
-rw-r--r--ext/tk/tcltklib.c28
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);