Extension talk:Scribunto

Jump to: navigation, search

About this board

Safely remove LuaSandbox build from source for PHP 5.6

Kghbln (talkcontribs)

I upgraded to Debian 9 and installed LuaSandbox from the provided package for it to work with PHP 7.0. So far so good. Everything is fluffy and working fine. This is great and thanks a lot for this improvement!

Now I came up with the idea to kill the LuaSandbox stuff I build from source for PHP 5.6. Yeah, I should have done this before. Is it safe to just remove everything that I added to /usr/local/bin/luasandbox and subdirectories as well as /etc/php5/conf.d/luasandbox.ini and /usr/lib/php5/20131226/luasandbox.so? I am not sure if this is somehow mixing with php-luasandbox I installed from the package. I do not think so but one never knows.

Reply to "Safely remove LuaSandbox build from source for PHP 5.6"

chcon: can't apply partial context to unlabeled file ‘lua’

AndyPKU (talkcontribs)

When I follow the manual instruction, and did "chcon -t httpd_sys_script_exec_t /path/to/extensions/Scribunto/engines/LuaStandalone/binaries/yourOS/lua" this, it sais that can't aplly partial context to unlabeled file 'lua'. What should I do?

Dinoguy1000 (talkcontribs)

Did you change the system path as appropriate for your environment? The path shown on the page is only a sample and won't work verbatim unless you intentionally set up your server with that directory structure. Specifically, the /path/to/extensions refers to the /extensions directory in MediaWiki's base directory; on a default server this might therefore be /var/www/html/extensions. Additionally, the /yourOS directory is just an example and needs to be replaced as appropriate; check what directories are contained in /extensions/Scribunto/engines/LuaStandalone/binaries and select the correct one for the operating system your server is running.

AndyPKU (talkcontribs)

in fact, my lua is in the path /var/www/html/extension/Scribunto/engines/LuaStandalone/binaries/lua5_1_5_linux_64_generic,and I use the command CD into this directory and use command as chcon -t httpd_sys_script_exec_t lua, I am not sure whether it is suitable, but I take it for grunted..

Reply to "chcon: can't apply partial context to unlabeled file ‘lua’"

Lua error: Cannot create process: proc_open(/dev/null): failed to open stream:

Adrianevs (talkcontribs)

Hello Everyone,

I hard trying to setup correctly Scribunto but I get the following error:

Lua error: Cannot create process: proc_open(/dev/null): failed to open stream: Operation not permittedScript error: No such module "Check for unknown parameters". Script error: No such module "documentation".

And php debug:

Warning: proc_open(): open_basedir restriction in effect. File(/dev/null) is not within the allowed path(s): (/var/sentora/hostdata/zadmin/public_html/mydomain_com:/var/sentora/temp/) in /var/sentora/hostdata/zadmin/public_html/mydomain_com/extensions/Scribunto/engines/LuaStandalone/LuaStandaloneEngine.php on line 267

Any idea how to fix that ?

Thanks in advance.

Legoktm (talkcontribs)

The problem itself is in the warning message: "open_basedir restriction in effect". You'll need to disable that. You'll need to talk to your hosting provider, it might be an option in the configuration panel.

Adrianevs (talkcontribs)

@Legoktm I run the mediawiki on a dedicated server. Any advice ?

Legoktm (talkcontribs)

You should edit your PHP configuration (php.ini) and disable the open_basedir restriction.

Zoglun (talkcontribs)

There is nothing set in my php.ini of CLI. But still got same error. What should I do?

Using 2G ram server.

Reply to "Lua error: Cannot create process: proc_open(/dev/null): failed to open stream:"

error when loading luasandbox.so

Summary by Tessus

The Lua library has to be compiled with -fPIC and the Lua library has to be explicitly put in LUA_LIBS for the sandbox.

Tessus (talkcontribs)

I've compiled the PHP module as follows:

LUA_CFLAGS="-I/usr/local/lua-5.1.5/include" LUA_LIBS="-L/usr/local/lua-5.1.5/lib" ./configure
make install

The module is created successfully, but when I start php-fpm, I get the following error message:

luasandbox.so: undefined symbol: luaopen_debug in Unknown on line 0

I'd appreciate any help with this.

Anomie (talkcontribs)

You seem to have forgotten the '-l' to actually link against the Lua library. Try LUA_LIBS="-L/usr/local/lua-5.1.5/lib -llua5.1", assuming the actual library is /usr/local/lua-5.1.5/lib/liblua5.1.so.

Tessus (talkcontribs)

Thanks for the reply.

The Lua 5.1.5 source code does not generate a shared object, but only a static library. There are no options in the Lua Makefile to generate a dynamic lib.

Usually it should not be necessary to add the lib to the X_LIBS var, since configure is supposed to do that. These env vars should only show the locations of the include and library files (and necessary 3rd party libs - not the lib itself!!!).

Anyway, adding the lib to LUA_LIBS made it worse. The module did not even compile anymore.

cc -shared  .libs/alloc.o .libs/data_conversion.o .libs/library.o .libs/luasandbox.o .libs/timer.o .libs/luasandbox_lstrlib.o  -L/usr/local/lua-5.1.5/lib -lrt -llua  -Wl,-rpath -Wl,/usr/local/lua-5.1.5/lib -Wl,-soname -Wl,luasandbox.so -o .libs/luasandbox.so
/bin/ld: /usr/local/lua-5.1.5/lib/liblua.a(lapi.o): relocation R_X86_64_32 against `luaO_nilobject_' can not be used when making a shared object; recompile with -fPIC
/usr/local/lua-5.1.5/lib/liblua.a: could not read symbols: Bad value
collect2: error: ld returned 1 exit status
make: *** [luasandbox.la] Error 1
Tessus (talkcontribs)

Wow, ok, the build system of Lua 5.1.5 sucks. It still does not give you a dynamic lib, but adding -fPIC to the CFLAGS in src/Makefile did the trick.

The following works to compile the sandbox:

LUA_CFLAGS="-I/usr/local/lua-5.1.5/include" LUA_LIBS="-L/usr/local/lua-5.1.5/lib -llua" ./configure
make install

Summary: The Lua library has to be compiled with -fPIC and the Lua library has to be explicitly stated in LUA_LIBS for the sandbox.

Tessus (talkcontribs)

I was in the process of trying to install the luasandbox Apache module, but the LUA 5.1 requirement is truly a problem, unless I'm compiling LUA myself. Even on my rather ancient server OS (a few years old), the LUA that comes with it is LUA 5.2. The latest LUA version is 5.3.4. I doubt someone will ever find a LUA 5.1 package on a current distro.

Thus my question: Is there a plan to support newer LUA versions in the future?

Mr. Stradivarius (talkcontribs)

That's task T178146 in Phabricator, but I don't know if there is a timetable for implementing it. The motivation isn't really there for WMF wikis, as all the modules on the wikis have been written for Lua 5.1.

Tessus (talkcontribs)

Thanks for the info. That pretty much explains it. See, I didn't know that LUA code is not backwards compatible.

Mr. Stradivarius (talkcontribs)

I think the modules on the wikis should be able to run on Lua 5.2 and 5.3, as Scribunto restricts or disables the features (like getfenv and setfenv) that would break on moving from Lua 5.1. It's just the Scribunto extension code itself that needs updating (although that is by no means a small job, especially when you factor in the security review).

Tessus (talkcontribs)

Ok, that explains it even more. I have never looked into the extension code (e.g. I don't know if it was written in C or in Lua, but I always assumed backwards compatibility to a certain point.) I mean I can still compile C code from the 70s. Even APIs are mostly compatible and are phased out via deprecation (e.g. Objective C classes and methods). Therefore I would have never thought that this would be such a challenge. Well, I guess I learned something new.

Thanks again for the explanation.

Reply to "Why the LUA 5.1 requirement?"
2600:1003:B45D:D34B:D4EB:D72B:9F2:C36E (talkcontribs)

I installed this extension so I would be able to install modules, but I can't figure out how to install them.

I followed the instructions on this page and the extension is working, but if I wanted to install something like the String module, do I just copy the script, save it as something.extension and upload it to my extensions/Scribunto/modules/ directory?

Even the "hello world" Bananas module doesn't say where or how to save it.

Mr. Stradivarius (talkcontribs)

You save them as pages on the wiki itself. To "install" the string module, copy it, edit the page "Module:String" on your wiki, paste the contents, and save the page. If the modules you install depend on any other modules, you will need to install those as well, or you may get errors. I'm not aware of any way to automatically find module dependencies like that - I usually just eyeball them for "require" statements.

2600:1003:B45D:D34B:D4EB:D72B:9F2:C36E (talkcontribs)

Thank you very much!

Reply to "Installing Modules"

Cannot create process: proc_open: failed to open stream: Permission denied

Summary last edited by Jamal22066 02:12, 20 September 2017 5 months ago

The parent directory needs write permissions.

If you do not want to give the entire parent directory write permissions for security reasons, change the errorlog file path to /tmp/errorfile.log. It should look like this:

$wgScribuntoEngineConf['luastandalone']['errorFile'] = "C:/tmp/errorFile";
Stromoxpage (talkcontribs)

I'm trying to use Scribunto for Template:Navbox

The error I'm getting:

Lua error: Cannot create process: proc_open(/usr/share/webapps/mediawiki/extensions/Scribunto/errorFile): failed to open stream: Permission denied

The LocalSettings.php lines:

require_once "$IP/extensions/Scribunto/Scribunto.php";

$wgScribuntoDefaultEngine = 'luastandalone';

$wgScribuntoEngineConf['luastandalone']['errorFile'] = "$IP/extensions/Scribunto/errorFile";

And the permissions:

$ ls -l extensions/Scribunto/

total 96

-rw-r--r-- 1 root root 19917 Nov 18 19:15 COPYING

-rw-r--r-- 1 root root   609 Nov 18 19:15 Gruntfile.js

-rw-r--r-- 1 root root  2793 Nov 18 19:15 Scribunto.magic.php

-rw-r--r-- 1 root root  8111 Nov 18 19:15 Scribunto.namespaces.php

-rw-r--r-- 1 root root  9437 Nov 18 19:15 Scribunto.php

drwxr-xr-x 2 root root  4096 Nov 18 19:15 common

-rw-r--r-- 1 root root   702 Nov 18 19:15 composer.json

-rw-r--r-- 1 root root  3945 Nov 18 19:15 composer.lock

drwxr-xr-x 5 root root  4096 Jan  9  2016 engines

-rwxrwxrwx 1 root root     0 Feb 26 23:44 errorFile

-rw-r--r-- 1 root root   278 Nov 18 19:15 gitinfo.json

drwxr-xr-x 2 root root  4096 Nov 18 19:15 i18n

drwxr-xr-x 2 root root  4096 Nov 18 19:15 modules

-rw-r--r-- 1 root root   276 Nov 18 19:15 package.json

-rw-r--r-- 1 root root   505 Nov 18 19:15 phpcs.xml

drwxr-xr-x 3 root root  4096 Jan  9  2016 tests

drwxr-xr-x 3 root root  4096 Nov 18 19:15 vendor

-rw-r--r-- 1 root root    48 Nov 18 19:15 version

Do you know what's wrong?

Stromoxpage (talkcontribs)

Setting the parent directory permissions to 777 will work. Maybe moving the log to a directory owned by the web server's process owner also?

Reply to "Cannot create process: proc_open: failed to open stream: Permission denied"
2002:43F4:3186:1234:4D53:5039:7DA7:BDF7 (talkcontribs)

I am trying to update from LuaSandbox 2.0.14-alpha to 2.0.15-alpha. I updated the code using git and than ran

phpize && ./configure && make && sudo make install

but it still shows that I'm on 2.0.14-alpha. How can I fix this? I did restart apache.

Legoktm (talkcontribs)

How did you install LuaSandbox originally? Did you put the newly generated luasandbox.so file in the right place? (talkcontribs)

I followed the instructions on this page.

Alex Mashin (talkcontribs)

Check, if PHP loads the extension from the directory, where it was compiled to.

MacFan4000 (talkcontribs)

It seems to be loaded correctly. Any other ideas?

Reply to "LuaSandbox Update"

How to nominate a module for speedy deletion?

Liuxinyu970226 (talkcontribs)

I doubt just inserting {{delete}} in "the header of" codes shall be helpful...

Maybe I should create its /doc subpage with that?!

Mr. Stradivarius (talkcontribs)

You're right - leaving the template on the module itself won't add the module page to the relevant category, so doing that won't help. Instead you could put it on the /doc page or the talk page, and explain that it is the module itself that you want deleted. Or you could leave a request on the relevant admin noticeboard. As far as I'm aware, those are the best solutions available at the moment.

Reply to "How to nominate a module for speedy deletion?"
Negative24 (talkcontribs)

So I'm getting the very common error "The lua binary (/home/u249147388/public_html/testing/extensions/Scribunto/engines/LuaStandalone/binaries/lua5_1_5_linux_64_generic/lua) is not executable" but I did mark the executable as executable (with chmod code 755). For some reason the error still keeps coming up when the executable does have the executable flag. Any ideas? Could it be an annoying noexec flag somewhere? I'm running MediaWiki version 1.22.7 and Scribunto for MW 1.22. Thanks.

Wmat (talkcontribs)

What does

ls -l 

say for that file?

Negative24 (talkcontribs)

ls -l output:

-rwxr-xr-x 1 u249147388 u249147388 195476 Jun  4 17:18 lua
Anomie (talkcontribs)
Could it be an annoying noexec flag somewhere?

That would be my guess.

Negative24 (talkcontribs)

I guess it is. I'll be switching to a new hosting company anyways because this one also doesn't support proc_open which is needed for many scripts.

Elia1995 (talkcontribs)

I got the same error, although I even set "executable" to the whole extensions folder and subfolders.

Alex Mashin (talkcontribs)

Try to run your /home/u249147388/public_html/testing/extensions/Scribunto/engines/LuaStandalone/binaries/lua5_1_5_linux_64_generic/lua from command line.

Also, check if the partition where this file is situated is mounted with noexec option (/etc/fsab).

Reply to "Lua not executable"