aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/LResource.cc
diff options
context:
space:
mode:
authorPavel Labath <pavelo@centrum.sk>2011-07-08 22:32:22 (GMT)
committerPavel Labath <pavelo@centrum.sk>2011-11-01 09:57:21 (GMT)
commit9f84eb3c7b18e3a1f6ec6e0f1f3fd181a496e25c (patch)
treefb4e896f45eb451d05c64a58b46b490f9a410d36 /src/FbTk/LResource.cc
parentb8a7503a30a06f53e0cfbc602b210bea1b49ec82 (diff)
downloadfluxbox_pavel-9f84eb3c7b18e3a1f6ec6e0f1f3fd181a496e25c.zip
fluxbox_pavel-9f84eb3c7b18e3a1f6ec6e0f1f3fd181a496e25c.tar.bz2
Lua: Make global variables read-only
This prevents the user from inadvertently overwriting e.g. the session table and then wondering why it does not work. I'm still not sure about this approach, as it's not 100% secure (the script can still use raw access to mess with it) and it adds some overhead to any operation referencing a global variable.
Diffstat (limited to 'src/FbTk/LResource.cc')
-rw-r--r--src/FbTk/LResource.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/FbTk/LResource.cc b/src/FbTk/LResource.cc
index 6671b89..d7627c9 100644
--- a/src/FbTk/LResource.cc
+++ b/src/FbTk/LResource.cc
@@ -105,9 +105,13 @@ LResourceManager::LResourceManager(const std::string &root, Lua &l)
105 l.checkstack(2); 105 l.checkstack(2);
106 lua::stack_sentry s(l); 106 lua::stack_sentry s(l);
107 107
108 l.pushstring(root);
109
108 l.getfield(lua::REGISTRYINDEX, make_root); 110 l.getfield(lua::REGISTRYINDEX, make_root);
109 l.pushstring(root); 111 l.pushstring(root);
110 l.call(1, 0); 112 l.call(1, 1);
113
114 l.readOnlySet(lua::GLOBALSINDEX);
111} 115}
112 116
113bool LResourceManager::save(const char *filename, const char *) { 117bool LResourceManager::save(const char *filename, const char *) {