aboutsummaryrefslogtreecommitdiffstats
path: root/pseudo.c
AgeCommit message (Collapse)Author
2011-11-02Implement PSEUDO_UNLOAD, replacing existing PSEUDO_RELOADED semantics.Mark Hatle
Change from internal PSEUDO_RELOADED to external PSEUDO_UNLOAD environment variable. Enable external programs to have a safe and reliable way to unload pseudo on the next exec*. PSEUDO_UNLOAD also will disable pseudo if we're in a fork/clone situation in the same way PSEUDO_DISABLED=1 would. Rename the PSEUDO_DISABLED tests, and create a similar set for the new PSEUDO_UNLOAD. Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2011-03-25Merge in ports workPeter Seebach
This is a spiffied-up rebase of a bunch of intermediate changes, presented as a whole because it is, surprisingly, less confusing that way. The basic idea is to separate the guts code into categories ranging from generic stuff that can be the same everywhere and specific variants. The big scary one is the Darwin support, which actually seems to run okay on 64-bit OS X 10.6. (No other variants were tested.) The other example given is support for the old clone() syscall on RHEL 4, which affects some wrlinux use cases. There's a few minor cleanup bits here, such as a function with inconsistent calling conventions, but nothing really exciting.
2011-02-10Whoops! If LOCALSTATEDIR doesn't exist, and you invoke pseudoPeter Seebach
directly rather than via an on-demand spawn from the client, the directory is never created.
2011-01-24Revert "Add a cache of the last object found in pseudo_op"Mark Hatle
This reverts commit 49d4d35918d457b0e9206679ecad3b9c84f11e66.
2011-01-18Do not cache OP_EXEC callsMark Hatle
The cached data values were being collected when an OP_EXEC call was made. This is incorrect as the values are only for logging purposes. It's believed this caused an occasional crash in certain instances. Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2011-01-13Fixup: The path code could double-free.Peter Seebach
The problem is that path_by_ino could end up being the same pointer as cache_path, after which, if cache_path were freed (or kept around for later), there would be malloc arena problems. Also, fix the calculation for pathlen to increase cache hits. The IPC messages use length of path *plus one* as the length, because the buffer is defined to include its terminating null byte.
2010-12-17Fix the msg cache codeMark Hatle
The pathlen that is cached could be wrong in certain operations (RENAME). Fix this by resetting it to the proper path length. Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2010-12-16Add a cache of the last object found in pseudo_opMark Hatle
Add a cache of the last object found in pseudo_op. Profiling has indiciated that many operations come in clusters. So instead of doing select, operation for each item in the cluster, we check to see if we already know the item and perform the op.. Performance improvement when processing 500k or so files: Previous: real 7m11.778s user 0m35.929s sys 2m46.723s This commit: real 6m42.093s user 0m34.321s sys 2m46.086s Also validation of the component can be added by compiling with NVALIDATE. This verifies the result of the cache is the same as what would have come from the database. Differences are logged to the standard pseudo.log. Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2010-12-16Restructure the pseudo_op file identificationMark Hatle
We restructure the pseudo_op file identification, which involves a fairly significant performance increase. The old method would do: if pdb_find_file_path: found_path = 1; if found_path && pdb_find_file_exact: found_ino = 1; else if pdb_find_file_dev: found_ino = 1; This resulted in at least two select calls for each file. One for "path" and one for exact or dev. The new method instead does: if pdb_find_file_exact: found_path = 1; found_ino = 1; else if pdb_find_file_path: found_path = 1; if pdb_find_file_dev: found_ino = 1; This shrinks the number of selects to either one or three. Potentially cutting the number of selects in half -- or increasing the number to three on an empty set... (Profiling has shown this is a net win) Timing numbers when manipulating a large number (500k) of files in a ramdisk: real 7m48.354s user 0m32.895s sys 2m50.274s After this change: real 7m11.778s user 0m35.929s sys 2m46.723s Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2010-12-16Add sqlite call profilingMark Hatle
Add sqlite call profiling, this allows us to see the sqlite calls that are being made as the system runs, via the pseudo log. It was noted that by this profiling that a small change to pseudo.c, when a file was found, reduced the sqlite SELECT calls by about 1/3. Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2010-12-13Further amend the system to enable/disable sudo during fork/exec.Mark Hatle
2010-12-09: * (mhatle) Add doc/program_flow to attempt to explain startup/running * (mhatle) guts/* minor cleanup * (mhatle) Reorganize into a new constructor for libpseudo ONLY pseudo main() now manually calls the util init new / revised init for client, wrappers and utils * (mhatle) Add central "reinit" function * (mhatle) Add manul execv* functions * (mhatle) rename pseudo_populate_wrappers to pseudo_check_wrappers Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2010-11-17First pass of some cleanups -- support moving a tracked directory fromPeter Seebach
one device to another, for instance.
2010-08-17Draft one effort at making unlink more robust and fixing an obviousseebs
bug in the speculative-unlink operation. The intent is to mark and then confirm or cancel the delete. This removes the quirk where we tried to stash old database entries, which didn't handle directories anyway; "rmdir non-empty-directory" is a bit too common a case to dismiss as unthinkable.
2010-08-11Enable local variable cacheMark Hatle
Add local variable cache via get_value and set_value. The local cache is setup at constructor time (or soon after). Rewrite the pseudo_setupenv and pseudo_dropenv routines, add a new pseudo_setupenvp and pseudo_dropenvp as well to handle the execve cases. We can now successfully use /usr/bin/env -i env and get pseudo values back!
2010-08-04Add new environment values to allow easy override of default locationsMark Hatle
Add PSEUDO_BINDIR, PSEUDO_LIBDIR, and PSEUDO_LOCALSTATEDIR to allow for more easy customization of PSEUDO components at run-time. If these are not set they will be automatically generated based on the existing PSEUDO_PREFIX path. PSEUDO_BINDIR = PSEUDO_PREFIX /bin PSEUDO_LIBDIR = PSEUDO_PREFIX /lib PSEUDO_LOCALSTATEDIR = PSEUDO_PREFIX /var/pseudo Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
2010-07-30Linking a file now does not unlink the contents of a fileKonrad Scherer
CQ: WIND00225366 When moving a directory, pseudo performs the following sequence: stat old, unlink new, link old and then rename. When linking a file, pseudo first makes sure the file does not already exist in the database and does an unlink. So the full sequence was stat old, unlink new, link old ( unlink old, unlink contents of old, relink old ), rename. The fix removes the unlinking of the contents of old.
2010-06-29Fix suffix handling so the right thing happens when usingPeter Seebach
libpseudo-foo.so.
2010-06-28Remove PSEUDO_SUFFIX from sourcePeter Seebach
The PSEUDO_SUFFIX thing is an installation quirk to allow our build system to tag libpseudo.so with a checksum of the host libc. However, we reuse a prebuilt pseudo server with the new pseudo libraries; this means that encoding the suffix in the environment hackery is a Bad Idea. Update version number to 0.3, since this seems to wrap up a hunk of development effort.
2010-04-26Handle execve() betterPeter Seebach
You can't use setenv() to modify the environment that will be passed to a child process through execve()... Also, fix the setupenv() to use PSEUDO_SUFFIX if defined. Use execve() to spawn child processes, so we can use setupenv() and dropenv().
2010-04-26Don't report inode or path mismatches on OP_EXEC.Peter Seebach
We don't canonicalize OP_EXEC names (because they don't want to be adapted for the chroot environment -- maybe we should be doing that anyway, but right now we're not), so mismatches with them are meaningless. So are mismatches with the inode 0 reported for something that we never tried to stat.
2010-04-26Handle rename(3) across devices.Peter Seebach
When you rename across devices, inode can change. Until now, pseudo had no tools for handling a change in inode, but this is clearly a legitimate case.
2010-04-26Reduce race condition for unlinks.Peter Seebach
If multiple clients are active at once, the following could occur: * Client #1 unlinks file A * Client #2 creates file B, which reuses A's inode * Client #2 sends request to server * Client #1 sends request to server * Processing client #2's request creates a mismatch warning for file A/B. * Processing client #1's request creates a mismatch warning too. Note that this can happen even if Client #2 sends its request later, as there's no intrinsic guarantee of the order in which requests are processed; any SINGLE client is presumably executing operations in order, but multiple clients aren't. Fixing this in rmdir, unlink, and rename.
2010-04-26Report on deletions more carefully.Peter Seebach
2010-04-26Add sanity checkPeter Seebach
It is possible for the database to get out of sync with the filesystem. Detecting this after the fact can be hard. Provide a hook for requesting a check. Also merge in some LD_LIBRARY_PATH fixes.
2010-04-26Updates/improvements for loggingPeter Seebach
Send program name (program_invocation_name from glibc) along with the tag. Along the way, restructure the fds/pids/tags arrays to be an array of client structures in pseudo_server, and add the message type to the set of things logged -- logging that a message was a ping is more useful than appending the text "ping" to it. Add support for type and program to pseudolog. Add deletion to pseudolog. Handle usage message formatting when there's an odd number of known specifiers for pseudolog. Conflicts: ChangeLog.txt pseudo_server.c
2010-03-29Add password/group call emulation.Peter Seebach
This is a first pass at handling password/group calls, allowing the use of custom password/group files. In particular, when chroot()ed to a particular directory, pseudo picks files in that directory by default, to improve support for the typical use case where pseudo uses chroot() only to jump into a virtual target filesystem.
2010-03-29cleanup FALLTHROUGH comments on case labelsPeter Seebach
2010-03-26Add support for intercepting execve()Peter Seebach
This allows us to track execution, although the tracking for it requires some additional thought -- the basic assumption is that we don't want to canonicalize names into the chroot() directory, but since all the filename canonicalization assumes that we want this, that will take some sneaking. It's a little useful as is, though, so I'm running with it.
2010-03-26Track file open flagsPeter Seebach
This patch adds support for checking whether a file was opened for reading, writing, or both, as well as tracking append flags. It is not very well tested. This is preparation for improved host contamination checking.
2010-03-26Updates: Enable additional warnings, fix a number of things.Peter Seebach
None of them seem to have been genuine problems, but it's prettier now, and some were questionable.
2010-03-25initial chroot() supportPeter Seebach
Add chroot() and a large number of things needed to make it work. The list of intercepted calls is large but not exhaustive.
2010-03-24Prep for chroot handling:Peter Seebach
* Improve makewrappers handling of function pointer arguments. * Regenerate wrappers when makewrappers is touched. * Move path resolution from pseudo_client_op into wrapper functions. * Eliminate dependency on PATH_MAX. * Related cleanup, such as tracking CWD better, and using the tracked value for getcwd().
2010-03-17Add -h option to pseudo.Peter Seebach
Add the -h (help) option to pseudo, and document -h for both pseudo and pseudolog.
2010-03-16initial public releasePeter Seebach