summaryrefslogtreecommitdiff
path: root/preload
AgeCommit message (Collapse)AuthorFilesLines
2009-02-16Corrected few compilation warnings.Mika Westerberg1-0/+4
Signed-off-by: Lauri Aarnio <Lauri.Aarnio@iki.fi>
2009-02-10Bugfix: /proc/<PID>/exe must be an absolute symlinkLauri Aarnio1-21/+45
2009-02-10Bugfix: /proc/<PID>/exe was incorrect for scriptsLauri Aarnio1-33/+77
- Enivironment variables __SB2_ORIG_BINARYNAME and __SB2_REAL_BINARYNAME were not updated to point to the script interpreter, fixed that.
2009-02-10Oops. Removed an extra temporary debug message from the interface generatorLauri Aarnio1-1/+0
- removed one line which "escaped" to a previous commit - (fortunately, it was completely harmless)
2009-02-10interface.master: Added #ifdefs around wrappers which need AT_SYMLINK_NOFOLLOWLauri Aarnio1-0/+8
- AT_SYMLINK_NOFOLLOW is defined only in newer systems, for example debian etch does not have it. - As a side effect, this removes c.a 8 wrappers from the preload library on systems where AT_SYMLINK_NOFOLLOW is not defined, but that should be harmless: If that symbol isn't defined, then the wrapped functions should not exist either.
2009-02-10Bugfix: Added handling of AT_SYMLINK_NOFOLLOW to fchownat()Lauri Aarnio1-0/+1
2009-02-10Bugfix: handle AT_SYMLINK_NOFOLLOW in fstatat() and many other *at() wrappersLauri Aarnio2-2/+16
2009-02-10Added wrappers for fcntl() and fcntl64()Lauri Aarnio3-0/+62
- fcntl() and fcntl64() need to be wrapped so that we can update fdpathdb when the application uses F_DUPFD or F_DUPFD_CLOEXEC. - Newer versions of "chmod -R" use these (that version of chmod which ships with Debiann "lenny")
2009-02-10Fix to script interpreter exec: exec policy is selected in correct placeLauri Aarnio1-6/+16
- 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-10procfs: restored the original exe-symlink-replacement naming schemeLauri Aarnio1-3/+3
- This one does not create "symlink clutter", but the created links are fully reusable
2009-02-10/proc/pid/exe emulation completedPasi Savanainen1-11/+186
Signed-off-by: Lauri Aarnio <Lauri.Aarnio@iki.fi>
2009-02-10sb2-show: new option "-p X" uses "X" as active exec policyLauri Aarnio2-0/+7
2009-02-10Added a mechanism for finding currently active exec policyLauri Aarnio1-0/+5
- 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-10/+25
- 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-02-10reorganized code in sb_exec.c so; call prepare_envp_for_do_exec() only onceLauri Aarnio1-39/+53
- prepare_hashbang(), which is called by prepare_exec(), makes a recursive call to prepare_exec(). Moved the call to prepare_envp_for_do_exec() from prepare_exec() to do_exec(); the result is that prepare_envp_for_do_exec() is called only once for scripts, as it should be.
2009-02-10fdpathdb: adjusted debug message levelsLauri Aarnio1-5/+5
2009-02-10Changed how "libsb2.so" is located from tools or native rootstrapsLauri Aarnio1-0/+1
- when "sb2" is initializing a new session, it tries to locate a compatibe libsb2.so from tools and/or native rootstraps. Previously the global version id (version of SB2 itself) was used as a component in the path candidates; this change replaces that version ID with the Lua <-> C interface version string. This is much more correct solution.
2009-02-10Bugfix: Changed log writing function to use nomap version of close().Mika Westerberg1-1/+2
Signed-off-by: Lauri Aarnio <Lauri.Aarnio@iki.fi>
2009-01-20Added wrappers for close(), dup() and dup2()Lauri Aarnio3-30/+83
- used to update fdpathdb
2009-01-20Bugfix: Ensure that absolute paths are always registered to fdpathdbLauri Aarnio1-4/+12
- Fixes mapping problems with "*at()" functions - This is a partial fix: Disables temporarily relative mapping results (see comment in luaif/paths.c)
2009-01-20Bugfix to glob(): Removed side-effects caused by the Mac OS X patchesLauri Aarnio3-2/+29
The Mac OS X support added a copy of "glob.h" to SB2. That causes problems on Linux; So, the fix is that for Linux systems we'll continue to use the system's glob.h with our private copies of glob.c and glob64.c. I renamed "glob.h" (the copy which was intended for the Mac OS X's) to "sb2_mac_glob.h. However, while doing so, I might have broken things on Mac OS X... see glob.c for details.
2009-01-20Added new function base_version() to sb2.Mika Westerberg1-1/+2
The function which returns first part of the full version string (before first '-'). Also corrected compilation warnings from files glob64.c. Signed-off-by: Lauri Aarnio <Lauri.Aarnio@iki.fi>
2009-01-15Bugfix to preload/glob.h: added missing newlineLauri Aarnio1-1/+1
- newline was missing from end of preload/glob.h => compilation failed on Ubuntu hardy
2009-01-10Builds for OS X 10.4 with these changesLauri Leukkunen3-2/+9
A bit more ifdef __APPLE__ testing was needed. Signed-off-by: Lauri Leukkunen <lle@rahina.org>
2008-12-30This version compiles on os xJoshua Pollak5-18/+16
2008-12-30More OS X compatibility changes - addded mempcpy (and check in configure.ac ↵Joshua Pollak5-5/+371
for it) - tweaks and changes to glob.c and glob64.c - added glob.h, since OS X's glob.h doesn't include a lot of the flags glob.c was depending on.
2008-12-30Added "#define __THROW" to null define __THROW on platforms that have ↵Joshua Pollak2-4/+7
__APPLE__ defined A \ was missing in interface.master causing export.h to be generated incorrectly on the Mac.
2008-12-30Added procfs.c, which was left out from an earlier commitLauri Aarnio1-0/+149
2008-12-11Fixed /proc/self/exe (and /proc/<MY_PID>/exe)Lauri Aarnio4-16/+31
- Implemented a special mapping function for /proc, to be able to map the symlink at /proc/self/exe. - This can be described as a countermeasure to side-effects of mapping exec parameters: /proc/self/exe (as well as /proc/<MY_PID>/exe, which is the same thing) need special care if the binary was started by anything else than direct exec. Examples: a) if CPU transparency is used, the real /proc/self/exe points to e.g. Qemu. Now SB2 can make it look like the link points to the binary which is running under qemu. b) if "ld.so-start" was used, the real /proc/self/exe points to ld.so and not to the binary itself. Again, SB2 maps that to a symlink which points to the correct binary. Other related things: - all mapping modes use this feature now - Lua <=> C interface version had to be incremented - Lua mapping code <=> mapping rules version had to be incremented
2008-12-11Added wrapper for "ldd"Lauri Aarnio4-3/+45
- The new "ldd" wrapper uses sb2-show to detect type of the binary, and then executes either ldd from target_root or simulates the host version - a new command "binarytype" was added to sb2-show
2008-12-07A bizarre bugfix to glob()Lauri Aarnio1-0/+10
- glob() was fixed by changing the order in which system's include files are used. For a full explanation, see the comment above #include <dirent.h> in glob.c
2008-12-07Made it possible to change mapping modes on the flyLauri Aarnio1-2/+32
- mapping mode may be changed by setting SBOX_SESSION_MODE to a value which is a valid mode for the current session (i.e. mode can be changed only to one of the values that were listed when the session was created)
2008-12-07interface generator: generated code checks if the real function is missingLauri Aarnio1-0/+22
- wrappers log errors and abort() if the real function does not exist, gates log warnings and continue to the gate function.
2008-12-07emulate mode: target_root is now R/O for "normal" use, "sb2 -R" makes it R/WLauri Aarnio2-2/+19
- A stricter policy protects agains accidental writing to target_root (rootstrap): - When the "emulate" mode is entered with option "-R" (e.g. "sb2 -eR" or "sb2 -m emulate -R") target_root will be "mounted" for read/write access. The "-R" option also activates "fakeroot", so the user experience should be as close to a "normal" system as possible.
2008-12-07Fixed mapping mode selection within persistent sessionsLauri Aarnio2-11/+33
Multiple -m, -e and/or -M options can now be specified to "sb2" command when a persistent session is created (opt. -S). One of those modes can then be selected when the user joins a session (opt. -J). For example, "sb2 -S sessionfile -m devel -m emulate" creates a persistent session which can be used in "devel" and "emulate" modes. The first listed mode becomes the default. Examples: "sb2 -J sessionfile" => devel mode, "sb2 -J sessionfile -e" => emulate mode, "sb2 -J sessionfile -m emulate" => emulate mode, but "sb2 -J sessionfile -m simple" fails, because "simple" was not listed when the session was created.
2008-12-07Fixes for dirfd handling for openat(), faccessat(), etc *at() functionsLauri Aarnio6-13/+268
- Added a pathname cache/db, which keeps fd=>path mappings. Those are needed for correct operation of openat() and friends. - NOTE: This is an initial version; there are still features that missing! To be extended later..
2008-11-03Minor changes to C code, based on warnings from gcc 4.3.2Lauri Aarnio1-10/+29
- Newest Ubuntu uses gcc 4.3.2 which was not happy when asprintf()'s return value was ignored almost everywhere => added checks, most places just log an error if asprintf() fails. + other small, similar changes because of the same reason
2008-11-02Bugfix: inspect_binary() crashed when the file was empty - min.size of an ↵Lauri Aarnio1-0/+8
executable is now 4 bytes. Smaller files are rejected. - sb2-show: better diagnostics, if "sb2-show exec" fails.
2008-11-02Optimized use of sb2's own environment variables - __SB2_BINARYNAME and ↵Lauri Aarnio3-9/+20
__SB2_REAL_BINARYNAME are now copied to global vars at startup (previously those were fetched by getenv() before every call to Lua functions, which is unsafe and slow) - env.var. SBOX_EMULATE_SB1_BUGS was replaced by conf.var. sbox_emulate_sb1_bugs
2008-10-23Added path reversing logic; getcwd() etc now return backward-mapped results ↵Lauri Aarnio2-10/+73
- i.e. getcwd(), realpath(), get_current_dir_name_gate() and getwd() now return the place where SB2 pretends to be, not the real path anymore - reverse mapping rules are created automatically when the session is created. However, there are still some situations where reverse mapping is disabled (see lua_scripts/create_reverse_rules.lua for details) - This also fixes a nasty bug with "mkdir -p" (which created directories to wrong locations in certain situations. "mkdir" witout "-p" was OK) - sb2-show: added new command "realcwd" - "devel" mapping mode: some paths were classified as virtual (virtual_path is a new attribute for rules: It disables reversing of that rule) - "simple" mapping mode: ~/.scratchbox2, .../share/scratchbox2 and /usr/bin/sb2-show were added to mapping rules - luaif.c: sb.decolonize_path() was disabled (It isn't anymore used from our Lua scripts, but I didn't
2008-10-23Introduced basic support for exec_policy based localization.Mika Westerberg4-11/+265
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-166/+5
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-18For x86_64, both 386 and x86_64 binaries are hostLauri Leukkunen1-1/+6
This prevents sb2 from spitting out warnings about unidentified binaries when running codesourcery toolchains on amd64 hosts. Signed-off-by: Lauri Leukkunen <lle@rahina.org>
2008-10-18sb_exec.c: small fixes: improved the way how missing executables are handledLauri Aarnio1-1/+14
2008-10-18sb_exec.c cleanup: "sb2-show exec" now displays all exec param.modification ↵Lauri Aarnio1-215/+158
- sb_exec.c was reorganized so that all modifications to parameters and environment were moved to functions that are separate from the actual exec call (sb_next_execve()) - The most important effect of this is that "sb2-show exec" can now display the exact and complete modifications that are performed (previously, sb2-show could only show results of the preprosessing phase, but postprocessing was left out) - "sb2-show exec" displays also modifications to the environment now (the algorithm is quite simple, but at least it exists now!)
2008-10-18Fixes to preload library initialization - The preload library may be called ↵Lauri Aarnio3-2/+69
even before the library constructor is called (for example, while other libraries are being initialized) - Moved initialization of some important global variables (those that hold copies of environment variables) to a new function, which will be called from all exported interface functions until the library has been initialized
2008-10-18Interface generator: modifier create_nomap_nolog_version is available for ↵Lauri Aarnio2-12/+11
GATES - interface.master: create_nomap_nolog_version is used for "getcwd"
2008-10-18sb2-show can be used to manually execute lua scripts in the sb2 context - ↵Lauri Aarnio1-0/+1
added flags & command to sb2-show so that Lua scripts for testing, debugging and benchmarking can be easily executed in the lua context which is created by the preload library.
2008-09-27Export dlmopen only for post glibc-2.3.4Lauri Leukkunen1-1/+2
Patch by Linus Walleij <triad@df.lth.se> Signed-off-by: Lauri Leukkunen <lle@rahina.org>
2008-09-27Fix sb2 building with older perl (5.8)Lauri Leukkunen1-1/+1
Patch by Linus Walleij <triad@df.lth.se> Signed-off-by: Lauri Leukkunen <lle@rahina.org>