Age | Commit message (Collapse) | Author |
|
This adds SPDX license headers to all source files in pseudo so license
identification models current best practise.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
|
|
Patch was submitted by <dan.dedrick@gmail.com>, revised to make it
a subport in case someone cares about a Linux system which doesn't
have this function. (Which is probably unlikely, but I am a cautious
sort.)
Signed-off-by: Seebs <seebs@seebs.net>
|
|
It turns out that these diagnostics can be spurious now on
some hosts, also that they've probably been wrong forever;
for instance, on some Linux, there's not a real "mknod" function
and probably never was, so reporting this error is pointless.
Signed-off-by: Seebs <seebs@seebs.net>
|
|
When tclsh forks it can create new threads in the child process, in a
pthread_atfork() handler. Running this under pseudo results in a
deadlock since the pseudo_lock() call in the new thread in the child
process premanently believes that the mutex is already locked by another
thread (which actually only existed in the parent process).
The provided test cases reproduces this. Similar hangs can also been
seen in other cases, such as when attempting to use vim's cscope support
under pseudo.
Fix it by reseting the mutex in a pthread_atfork() child function.
Signed-off-by: Rabin Vincent <rabinv@axis.com>
Signed-off-by: Seebs <seebs@seebs.net>
|
|
So a recent change to ld.so behavior revealed that pseudo was not
always correctly detecting that a function hadn't been found by the
RTLD_NEXT search. This only happened for functions which genuinely
didn't exist and wouldn't get called (like mknod on Linux, which
is actually always done as an inline function that calls __xmknod),
but when the diagnostics started showing up, it broke things. Fix it
so the diagnostics would have shown up when things were originally
broken, also fix the resulting diagnostics.
Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
|
|
Since the pseudo socket is actually created by a call to bind, the
bind call could create a file, which means it needs to record a
database entry.
|
|
So we had this really strange problem where, sometimes but not always,
pseudo would have strange problems on startup, where the pseudo server
would end up running under pseudo. And this produced the most fascinating
thing, which was:
unsetenv("LD_PRELOAD");
assert(getenv("LD_PRELOAD") == NULL);
for (int i = 0; environ[i]; ++i) {
assert(strncmp(environ[i], "LD_PRELOAD=", 11));
}
(pseudocode untested)
This would crash on the environ search. Because getenv() was not searching
environ.
WHAT.
So it turns out, *bash overrides getenv, setenv, and so on*. Under those
names. Hiding the glibc ones. And this creates horrible problems if you
assumed that your code could call those functions and expect them to work.
So as a workaround, pseudo now uses dlsym to find getenv, etc., from
glibc, and invokes those directly if possible. Also the client now uses
unwrapped fork/exec for spawning the server, which cleans up the
behavior of that code quite a bit.
|
|
For debugging the client/server startup, add an event logger to allow
better recording of events that we may, or may not, want to dump out
listings of later.
|
|
For sound reasons, the server wants to be sure no client is on fd 2. However,
the client shouldn't force the pseudo log file to be fd 2; it should leave
stderr alone when a log file is specified.
|
|
lstat can fail on XFS if the inode number won't fit in a 32-bit value.
Use base_lstat. Also, just in case, don't call it if it's not initialized
yet (which should never happen).
Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
|
|
This is a moderately experimental feature which stores values in an
extended attribute called 'user.pseudo_data' instead of in the database.
Still missing: Database<->filesystem synchronization for this.
For at least some workloads, this can dramatically improve performance.
Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
|
|
A partially-implemented profiler for client time, which basically just
inserts (optional) gettimeofday calls in various places and stashes data
in a flat file containing one data block per pid.
Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
|
|
Initial, incomplete, support for extended attributes. Extended
attributes are implemented fairly naively, using a second table
in the file database using the primary file table's id as a
foreign key. The ON DELETE CASCADE behavior requires sqlite 3.6.19
or later with foreign key and trigger support compiled in.
To reduce round-trips, the client does not check for existing
attributes, but rather, sends three distinct set messages;
OP_SET_XATTR, OP_CREATE_XATTR, OP_REPLACE_XATTR. A SET message
always succeeds, a CREATE fails if the attribute already
exists, and a REPLACE fails if the attribute does not already
exist.
The /* flags */ feature of makewrappers is used to correct
path names appropriately, so all functions are already working
with complete paths, and can always use functions that work
on links; if they were supposed to dereference, the path
fixup code got that.
The xattr support is enabled, for now, conditional on
whether getfattr --help succeeds.
Not yet implemented: Translation for system.posix_acl_access,
which is used by "cp -a" (or "cp --preserve-all") on some
systems to try to copy modes.
Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
|
|
The _plain thing was added because of clashes between Linux
("struct stat64 for 64-bit file sizes") and Darwin ("struct stat
is already 64 bits"). But it turns out not to be enough,
because stat will *fail* if it cannot represent a file size,
so when something like unlinkat() calls a non-64-bit stat in
order to determine whether a file exists, it gets the wrong
answer if the file is over 2GB in size.
Solution: Continue using PSEUDO_STATBUF, and also provide
defines for base_stat() which can be either real_stat() or
real_stat64(), etcetera.
This eliminates any reason to need the _plain functions. It
also suggests that the other real___fxstatat() calls should
someday go away because that is an ugly, ugly, implementation
detail.
As part of testing this, fix up some bitrot which affected
Darwin (such as the continue outside of a loop, but inside
an #ifdef; that was left over from the conversion of
init_one_wrapper to a separate function).
|
|
You might be wondering why this wasn't caught. Answer: gcc's too smart.
Consider:
int x;
if (condition)
x = 23;
return x;
This function will just return 23. Since gcc knows that it doesn't
matter what happens if x is used uninitialized (it's an indeterminate
value, thus a possible trap representation, thus undefined behavior
to use it), it simplifies the initial part of this away. Thus there's
no use of an uninitialized value.
Something similar seems to be at issue with the use of the uninitialized
f in pseudo_init_one_wrapper.
The variable wasn't initialized in the pre-realpath-fix version either,
but in that version, the assignment from dlsym was completely unconditional.
|
|
On some Linux systems, dlsym("realpath", RTLD_NEXT) prefers
for reasons of its own to give a symbol that is also known
as old_realpath, which fails and yields EINVAL when called
with a null pointer as the second argument. This can be
avoided, on some systems, by using dlvsym() to request
the GLIBC_2.3 version of the symbol.
The wrapper logic is enhanced to allow for specifying
versions, although this currently only works for Linux
(Darwin has no dlvsym, apparently?). The test case is
a trivial program which calls realpath(name, NULL) run
with PSEUDO_DISABLED=1.
|
|
that we add an extra fork() so we can do the setup in a child process,
but still just pass the command string to the standard system()
call.
|
|
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.
|
|
Restructure wrapfuncs.c in an attempt to improve PSEUDO_DISABLED=1
performance.
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
|
|
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>
|
|
* (mhatle) Add guts/clone.c to cleanup the clone support
* (mhatle) guts/clone.c only run setupenv and reinit when NOT PSEUDO_RELOADED
* (mhatle) guts/execve.c whitespace fixe
* (mhatle) guts/fork.c similar to guts/clone.c change
* (mhatle) pseudo_client.c add reinit function
* (mhatle) pseudo_client.c revise client reset, include code from pseudo_wrappers.c
* (mhatle) pseudo_server.c move the pid writing to the parent
* (mhatle) pseudo_wrappers.c clone cleanup and populate cleanup
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
|
|
be out of sync in a very inconvenient way.
Changes include:
* Some whitespace fixes, also move the pseudo_variables definition
into pseudo_util.c since it's not used anywhere else.
* Further improvements in the fork() support:
We now recognize both positive and negative forms of PSEUDO_DISABLED,
so we can distinguish between "it was removed from the environment
by env -i" (restore the old value) and "it was intentionally turned
off" (the new value wins).
* clone(2) support. This is a little primitive, and programs might still
fail horribly due to clone's semantics, but at least it's there and
passes easy test cases.
Plus a big patch from Mark Hatle:
Cleanup fork/clone and PSEUDO_DISABLED
guts/fork.c:
* cleanup function and make it more robust
* be sure to call pseudo_setupenv prior to pseudo_client_reset
to match exec behavior
pseudo_wrappers.c:
* fix mismatched type in execl_to_v call via typecast
* Simplify fork call via single call to wrap_fork()
* be sure to save pseudo_disabled
* be sure to call pseudo_setupenv prior to pseudo_client_reset
to match exec behavior
tests:
* Add a test of whether pseudo can be disabled/enabled on a fork.
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
|
|
one.
There's a long story here, but to abbreviate it:
The shell script was annoying at best to maintain and starting to
show signs of not really being the right tool for the job. For
various reasons, we have some other Python stuff in our build system,
so we picked Python as the language we were already using for other
stuff. We think this works with anything reasonably recent (around
Python 2.4 through 2.6).
There's a little bit of cleanup, also, of the wrapper templates.
|
|
in processes started under pseudo.
|
|
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!
|
|
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>
|
|
In fakechroot, which pseudo tries to match the functionality of,
the default behavior when creating a symlink with an absolute target
is to prepend the chroot path, so that underlying syscalls will
get the right file.
It is necessary to be able to disable this behavior to create target
filesystems in some cases. To that end, support a new environment
variable, PSEUDO_NOSYMLINKEXP, which disables that behavior.
|
|
The PSEUDO_DEBUG_FILE feature is enhanced, and is now also used by the
pseudo server.
|
|
This includes allowing %s (program name) and %d (pid).
|
|
remake(1) can try to close a file from a signal handler. Since
any entrance to a pseudo-emulated function requires the mutex,
this can result in a deadlock. Solution: Suspend SIGCHLD (and
a couple of other signals likely to result in filesystem
operations) for the duration of the lock.
|
|
Moved readlink fixup into a general-purpose function for
removing chroot prefixes.
|
|
Migrate the stable part of the wrapper code (not machine-generated)
out of makewrappers, to make it easier to maintain.
|