summaryrefslogtreecommitdiff
path: root/lua_scripts/argvenvp.lua
AgeCommit message (Collapse)AuthorFilesLines
2009-03-30Prefer -U LD_PRELOAD over -drop-ld-preloadRiku Voipio1-7/+12
We want to get rid of the stupid -drop-ld-preload flag in qemu upstream. Therefor mandatory for sb2 2.0. release :) Only lightly tested but appears to work as expected. Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-02-16Script interpreter mapping: Added support for multiple mapping rulesLauri Aarnio1-12/+22
- an exec policy can now define more than one rule to map the script interpreter (previously only one rule was allowed) - "devel" mode: Added yet another SB1 compatibility feature: Support for mapping interpreters from /scratchbox/tools/bin to <tools_root>/usr/bin - Interface version of the mapping engine <-> mapping rules interface was incremented (this is the lua<->lua interface version, C<->lua interface was not modified)
2009-02-10Bugfix: script execution failed to find correct exec policyLauri Aarnio1-1/+1
- happened because C->Lua interface left trash to Lua's stack => script execution failed to find corect exec_policy for the script interpreter - Also included: - added new debugging level NOISE3 - added dump_lua_stack() (luaif/argvenvp.c), name says it all..
2009-02-10Fix to script interpreter exec: exec policy is selected in correct placeLauri Aarnio1-2/+2
- Exec policy for scripts is now correctly selected when the script interpreter is selected (things were messed up when the exec policy had requirements for the interpreters..)
2009-02-10Argv&envp mangling rules are now generated only once per session.Mika Westerberg1-21/+42
- There is new lua script: create_argvmods_rules.lua which is used to create explicit rules based rules created by argvenvp_xxx.lua. - Separated mangling rules for misc binaries to be in file argvenvp_misc.lua - Rules are generated by sb2 script and placed under $SBOX_SESSION_DIR/argvmods/*. Signed-off-by: Lauri Aarnio <Lauri.Aarnio@iki.fi>
2009-02-10Added a mechanism for finding currently active exec policyLauri Aarnio1-0/+4
- set name of the selected exec policy to an environment variable before every exec, and also added a lua function which locates the currently active policy (soon to be used by the "devel"mode..)
2009-02-10Exec algorithm improvements: Policy-based mapping of script interpretersLauri Aarnio1-30/+115
- this commit adds support for exec policy based mapping of script interpreter: A script interpreter can be selected based on location of the script. For example, perl scripts from tools_root may map /usr/bin/perl to tools_root, while perl scripts from the target_root can map /usr/bin/perl to target_root. - This commit does not contain changes to the mapping rules => everything still works just as before (related changes to the "devel" mode will be added by another commit)
2009-01-20SB2's Configuration & Initialization Redesign: part 2: Gcc toochain configLauri Aarnio1-4/+7
Summary: * Now it is possible to have several toolchains available simultaneously: The primary gcc will be available as "gcc", while components of the secondary toolchain(s) are available as "gcc-X.Y", etc. * sb2-init now calls a new script, sb2-config-gcc-toolchain to set up toolchain configurations * Toolchain configuration variables were moved to new config files, two files/toolchain Some details: - "sb2-upgrade-config" automatically upgrades existing config files - "sb2-config-gcc-toolchain" was created by separating all target-gcc-related actions from "sb2-init"; this was not as straightforward as it sounds. All toolchain-related configuration variables had to be moved from the old-style config file (sb2.config) to the new files, and then every place where the variables were needed had to be checked. This turned out to be more like a separation of siamese twins...but the result is that it is possible to have more than one toolchain configured, finally!
2008-12-07Workaround for a system call bug in older "libattr" libraries of ARM targetsLauri Aarnio1-0/+10
- Older "libattr" libraries for ARM use an incorrect format for some system calls; Maemo's patched qemu now has workaround for that. Now sb2 detects if the selected qemu knows about this "libattr hack" and enables it if possible.
2008-11-02More fixes to gcc tools exec preprocesing - My previous patch was simply too ↵Lauri Aarnio1-6/+22
simple...
2008-11-02Fixes to exec preprocessing: Processing of gcc tools requires abs.paths etc. ↵Lauri Aarnio1-5/+12
- Fix: exec parameters are now modified only when gcc tools are called from /usr/bin (previously the path was ignored, only basename was used to identify the tools) - Enhancement/fix: This includes support for rewriting paths like /usr/bin/gcc-3.4; sb2-init writes compiler version to the config files, so that exec preprocessing can register wrappers with version number for gcc, g++ and cpp - This patch also increments SB2's configuration file version number; sb2-init must be used to register gcc's version number to the config.files
2008-11-02Minor fixes to Lua scripts: More variables are now "local"Lauri Aarnio1-1/+1
2008-10-25Fixed exec policy based setting of LD_LIBRARY_PATH for native applications - ↵Lauri Aarnio1-18/+83
new attributes "native_app_ld_library_path_prefix" and "native_app_ld_library_path_suffix" are available - "emulate" mode works better now when target architecture == host arch and libsb2.so has not been installed to target_root. (native applications, "emulate" mode)
2008-10-23Introduced basic support for exec_policy based localization.Mika Westerberg1-13/+20
With this commit it is possible to instruct sb2 to load localization files and message catalogs from specific path (for example under target_root). (Reviewed by Lauri T. Aarnio)
2008-10-23Cpu transparency logic is now completely implemented in Lua. - "sbrsh" is ↵Lauri Aarnio1-1/+144
now also handled by an exec postprocessor: Replaced that hard-coded logic what we had in sb_exec.c; all that is now handled by argvenvp.lua but the logic is still quite hard-coded and can't be controlled by an exec policy, yet. - "sb.getcwd()" was added to luaif.c, argvenvp.lua needs it - one more environment variable was removed (SBRSH_CONFIG)
2008-10-18"emulate" mode bugfix: Disabled mangling of gcc & related commands - A ↵Lauri Aarnio1-2/+4
mapping mode can now disable the cross-gcc toolchain by setting "enable_cross_gcc_toolchain" variable to false. - "emulate" mode does that now, because it should provide as accurate emulation of the target environment as possible (i.e. "gcc" must be executed from the target_root iff it has been installed to target_root) - previously "gcc" & other cross-toolchain commands were always mangled, and then execution failed because the path produced by exec preprocessing was mapped to target_root, which didn't contain the toolchain, of course..
2008-09-27Bugfix: Fixed compatibility with older qemu versions (in exec postprocessor)Lauri Aarnio1-0/+4
2008-09-27CPU transparency changes: Qemu is now handled by an exec postprocessor - ↵Lauri Aarnio1-2/+67
Execution of target binaries (with qemu) is now handled by the exec postprocessor in lua_scripts/argvenvp.lua, just like what has been used for native binaries. - If the CPU transparency method is "sbrsh", postprocessing is not used, but the old code in sb_exec.c is still applied; this will be changed later by another commit - "sb2" script tests if the Qemu knows about "-0" and "-E" options; the exec posprocessor uses them if they are available: - option -0 is used to preserve exec semantics. Without it argv[0] will be overwritten with the file name (and it is not always the same thing) - option -E is used to inject environment variables to qemu's emulated environment. "prelink" won't work without this trick. both options were implemented for Maemo SDK+, and are present in their patched qemu. - These changes were originally written by Mika Westerberg and Pas
2008-09-27Changes to executing native binaries from tools/target by ld.so - The ↵Lauri Aarnio1-9/+17
default ld.so (ld-linux.so) will loose argv[0], when the binary is executed by ld.so's command line (which is supportted by sb2). It will always copy the filename to argv[0]. - We now have a patch for ld.so which introduces a new option, "--argv0 argument", and a flag is used to tell to the lua scripts if a patched ld.so is available (the "sb2" script finds that out during startup phase). That patch is not included in this commit, but will be available soon..
2008-09-27Removed the only call to getenv from argvenvp.luaLauri Aarnio1-2/+1
2008-09-27Eliminated env.var. SBOX_LUA_SCRIPTS - replaced SBOX_LUA_SCRIPTS by ↵Lauri Aarnio1-1/+1
SBOX_SESSION_DIR + a symlink in the session directory. SBOX_LUA_SCRIPTS variable still exists inside the "sb2" script, but it is not exported anymore.
2008-09-27Eliminated env.var. SBOX_MAPMODE; Mode is now passed thru files - sb2 does ↵Lauri Aarnio1-7/+1
not anymore load all mapping modes to memory, only the rules of the selected mode will be loaded. Rules will be copied to $SBOX_SESSION_DIR/rules.lua at startup. - There is a new "-M" option to sb2, which can be used to provide direct path to the mapping rule file (so that rules don't have to be under $SBOX_LUA_SCRIPTS/pathmaps anymore) - sb2 now creates a new configuration file, $SBOX_SESSION_DIR/sb2-session.conf That file will be used to pass per-session information about sb2's environment to the various child processes; we have had far too many environment variables in use. Currently "sbox_mapmode" is the only thing passed via the new file, but other environment variables will follow.. - This should have a positive effect on performance, too.
2008-09-27Changed logging level of missing exec.policies (warning -> notice) - Other ↵Lauri Aarnio1-1/+1
mapping modes than maemo do not yet contain exec policies, so the world is not yet ready for warnings about missing policies..
2008-09-27Implemented policy-based execution of native binaries. - Exec policies can ↵Lauri Aarnio1-2/+185
be used to define how native binaries are started: For example, the tools that are used from "tools_root" may need to load dynamic libraries from nonstandard locations and/or use a nonstandard ld.so; also, if the target architecture is the same as the host architecture, binaries may also need special settings and a special ld.so. - These features are off by default, but can be taken into use by installing a libsb2.so to tools_root (or to the rootstrap, if target arch.==host arch) - NOTE/WARNING: These features are currently off because the current ld.so (which is part of glibc) is not fully transparent to the application. See comments in the source for a longer explanation of this.
2008-09-27sb_execve_mod and sbox_execve_mod renamed to exec preprocessing functionsLauri Aarnio1-3/+8
2008-05-10Made cross-gcc optionalLauri Aarnio1-2/+8
- the cross compiler is an optional feature now; if not specified to sb2-init, all related commands ("gcc","as","ld",etc) will not be mapped by the "argvenvp" exec argument mangling system, instead the commands will be executed just as any other binary - Now there are two ways to specify target architecture to sb2-init: the "old way" autodetects it from the cross compiler, the second option is to set it manually by a new command line option (-A).
2008-01-18Separate gcc argv mangling rule generation to argvenvp_gcc.luaLauri Leukkunen1-133/+23
Signed-off-by: Lauri Leukkunen <lle@rahina.org>
2008-01-03Added log post-processing tool and improved logging messages.Lauri Aarnio1-0/+2
- added sb2logz, which extracts information from logs and produces summaries - general: log format changed (each line now contains log level, too) - *.c: log messages which are needed by sb2logz are now at INFO level - interface.master & libsb2.c: Added gates to _exit() and _Exit(), so that exit status can be logged - sb_exec.c: bugfix: sb_execve_mod() returns nonzero if error, not zero - sb2: location of log files changed: logs now go to ~/sb2_logs/, and initial environment is printed to the log file
2007-12-14Fix extra args for compiler and linker, support tool distroLauri Leukkunen1-0/+14
These changes allow use of a separate tool distribution when using the "maemo" ruleset. Tested on Fedora 8 using Debian/sid for tools. Signed-off-by: Lauri Leukkunen <lle@rahina.org>
2007-12-11Improve exec*() handlingLauri Leukkunen1-10/+18
Cleans the sequence by pushing hashbang detection further down the pipeline, improves code structure and hopefully fixes some breakage. Signed-off-by: Lauri Leukkunen <lle@rahina.org>
2007-12-10Fix host-gccLauri Leukkunen1-3/+18
host-gcc is run with all manglings disabled Signed-off-by: Lauri Leukkunen <lle@rahina.org>
2007-12-10Generic execve() manglingLauri Leukkunen1-3/+155
sb_gcc_wrapper functionality is now implemented directly in libsb2.so as a lua script directly managing the execve(file, argv, envp) call. Same functionality can be used to do other things as well, see for the dpkg-architecture example in lua_scripts/argvenvp.lua Signed-off-by: Lauri Leukkunen <lle@rahina.org>
2007-12-02Flesh out the argv/envp processingLauri Leukkunen1-0/+8
For now this is just a pass-through, doesn't do anything, but from here it's just a matter of building up the lua scripts. Signed-off-by: Lauri Leukkunen <lle@rahina.org>
2007-11-26Handle lua engine initialization properlyLauri Leukkunen1-0/+0
The engine initialization will end up going through scratchbox_path2 so we have to have a "in process" state to know what to do. Signed-off-by: Lauri Leukkunen <lle@rahina.org>