aboutsummaryrefslogtreecommitdiffstats
path: root/ports/unix
AgeCommit message (Collapse)Author
2018-01-16handle O_TMPFILE and linkat()Seebs
This is a rework which replaces a previous patch. In this version, files created with O_TMPFILE don't get recorded in the database at all, but if we get a link request for /proc/self/fd/N, and the corresponding file is not in the database, we send a CREAT request for it instead of a LINK, and that appears to work with a MUCH reduced chance of database leakage. Also the O_TMPFILE won't be creating bogus database entries anymore. Signed-off-by: Seebs <seebs@seebs.net> linkat fix
2016-09-30Fix renameat (parallel to previous fix to rename)Seebs
There was a bug in rename(), which was duplicated when renameat() was implemented, and which got fixed two years ago for rename(), but no one ever uses renameat() so it didn't get fixed there. Thanks to Anton Gerasimov <anton@advancedtelematic.com> for the bug report and patch. Signed-off-by: Seebs <seebs@seebs.net>
2016-07-05Mark ports/unix/subports executableJoshua Lock
Signed-off-by: Joshua Lock <joshua.g.lock@intel.com>
2016-05-18better handling of missing real_foo functionsPeter Seebach
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>
2016-03-10add wrapper for bindPeter Seebach
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.
2016-03-02Server launch rework continued, probably finishedPeter Seebach
Server process now waits for its forked child when daemonizing, allowing us to yield meaningful exit status. Lock is now taken by the child, since it has a way to tell the parent about the exit status. (We send SIGUSR1 to the server to cause the wait loop to stop when the client is ready to go.) This allows us to switch to fcntl locking, which should in theory allow us to run with the pseudo directory NFS-mounted. Woot! Also mark a couple of overly spammy messages as PDBGF_VERBOSE to reduce the volume of uninteresting dup spam when looking at client behaviors. Client now uses execve to spawn server to work around a very strange behavior of unsetenv. Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
2016-01-22Fix mknod(...) with no file type bitsPeter Seebach
mknod(2) automatically defaults to S_IFREG if not given an explicit file type, so pseudo should too. Otherwise, GNU tar can (for some reason, it mostly does this when extracting xattrs?) invoke mknod instead of open with O_CREAT to create a file, and just provide the permission bits, and pseudo creates a "weird file" with no type bits in the database, which is unhelpful. Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
2015-09-22f*open*: Use more-correct mode.pseudo-1.7.4PSEUDO_1_7_4Peter Seebach
The f{re,}open{64,} functions use a default mode of 0666 & ~umask, and defaulting to 0600 for the post-open chmod was breaking some use cases. Problem and solution identified by Ross Burton, I just made the local copy of the patch. Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
2015-09-04Don't have mkdirat set errno unintentionallyPeter Seebach
mkdirat() was calling real_fchmodat with invalid arguments (it turns out that AT_SYMLINK_NOFOLLOW is both irrelevant and forbidden by Linux), and the wrapper function did not restore errno to its previous value. This breaks localedef, because localedef is unconditionally storing the value of errno after a mkdir *whether or not the mkdir failed*, which is almost certainly wrong. Similar issue with mkfifoat. Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
2015-09-03Finish (I hope) working around 0700 umasks.Peter Seebach
There's some changes to allow things to work even if umask is 0700; originally this was just regarded as a broken state, but it became necessary to fix it in order for the xattrdb code to work, only the fix could result in files having a raw filesystem mode that lacked execute bits it should have had. Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
2015-09-01realpath: allocate memory when null pointer givenPeter Seebach
When I trimmed the spurious free()s for the new lower-allocation path strategy, I forgot to look for cases where I was relying on the allocation, such as realpath(path, NULL). Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
2015-08-24Small cleanups in passingPeter Seebach
gcc is better about warnings and spotted variables being assigned but not used. Clever gcc. Cleaned up the old bits. Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
2015-08-24xattrdb bug fixesPeter Seebach
When xattr emulation is used to store extended attributes, dummy entries get made in the db using whatever UID/GID were in the real stat buffer if no entry already existed. Change these to -1, and treat -1 uid/gid as a missing entry for stat purposes. xattrdb was not merging existing uid/gid values. Change this by loading existing values to merge them in when executing chown/chmod commands. Newly-created files could end up with a filesystem mode of 0 if you used umask, but this breaks xattrdb. Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
2015-08-21New option: Use extended attributes to store db values.Peter Seebach
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>
2015-08-20Drop the allocation in pseudo_fix_path/pseudo_root_path/etc.Peter Seebach
Instead of allocating (and then freeing) these paths all the time, use a rotating selection of buffers of fixed but probably large enough size (the same size that would have been the maximum anyway in general). With the exception of fts_open, there's no likely way to end up needing more than two or three such paths at a time. fts_open dups the paths since it could have a large number and need them for a while. This dramatically reduces (in principle) the amount of allocation and especially reallocation going on. Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
2015-07-171.6.7: fix mkfifopseudo-1.6.7PSEUDO_1_6_7Peter Seebach
Worked for trivial cases, but spuriously closed fd 0 and had other issues. Separated implementations out.
2015-07-16Allow fifosPeter Seebach
Some years back, there was a historical reason (lost to the mists of time) for which we had problems if we allowed actual creation of fifos, but so far as we know we don't expect any problems with them now, and there's a bitbake change which would like to be able to use fifos for logging, so let's try enabling them and see what happens.
2014-10-03Possibly fix strange corruptionsPeter Seebach
Trying to track down problems which sometimes result in files showing up as nameless files, producing clashes later. Looks like there were two issues; one is we were creating links for files that we'd already found by inode. The other is that rename was sending bogus LINK messages in some cases. Also simplified the find_file_dev path to extract the path as part of the initial operation, since there wasn't any case where that wasn't being done immediately afterwards.
2014-06-13Don't follow symlinks for lutimes()Peter Seebach
Also for lstat, but that probably never matters because in Linux you will never actually call lstat without working really hard at it, because you end up calling __lxstat anyway. (Was already doing the right thing for Darwin.)
2014-05-27Typo fixPeter Seebach
So it turns out that if you fix a bug inside an #ifdef that hasn't applied to anything in years, it doesn't actually fix the bug.
2014-05-27Honor umaskPeter Seebach
We used to rely on filesystem operations to apply the umask when appropriate, but when we started masking out 022, that stopped working. Start watching umask.
2014-05-16pseudo_has_unload: add functionPeter Seebach
Various wrappers checked for a non-null pseudo_get_value("PSEUDO_UNLOAD") to determine whether the environment should include the pseudo variables. None of those checks freed the returned value when it was not null. The new check function does. The new check function also sees whether PSEUDO_UNLOAD was defined in the environment that should be used in the wrapped system call. This allows pkg_postinst scripts to strip out the LD_PRELOAD setting, for example before invoking qemu to execute commands in an environment that does not have libpseudo.so. [YOCTO #4843] Signed-off-by: Peter A. Bigot <pab@pabigot.com> Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
2014-05-16Permissions handling tweaks (fchmodat, mask out write bits)Peter Seebach
Change the handling of fchmodat(AT_SYMLINK_NOFOLLOW) to reject it if the host system does, so we preserve host system behavior. Mask out group/other write bits when actually creating files to reduce risks to filesystem integrity.
2014-05-15fchmodat: don't pass AT_SYMLINK_NOFOLLOWseebs/xattrPeter Seebach
underlying fchmodat() will just fail, but GNU tar calls it that way anyway, figuring it'll just retry on failure, but we don't report the failure. Nor do we want to, because that's expensive and slow and will result in additional database round trips. But I don't want to fail out right away, so for now, just strip the flag.
2014-01-23mkdir was storing/reporting modes with 0700 addedPeter Seebach
2014-01-23mknod apparently got broken a long time ago, fixedPeter Seebach
2013-06-25Change debugging to use flags rather than levelsPeter Seebach
This is a moderately intrusive change. The basic overall effect: Debugging messages are now controlled, not by a numeric "level", but by a series of flags, which are expressed as a string of letters. Each flag has a single-letter form used for string specifications, a name, a description, a numeric value (1 through N), and a flag value (which is 1 << the numeric value). (This does mean that no flag has the value 1, so we only have 31 bits available. Tiny violins play.) The other significant change is that the pseudo_debug calls are now implemented with a do/while macro containing a conditional, so that computationally-expensive arguments are never evaluated if the corresponding debug flags weren't set. The assumption is that in the vast majority of cases (specifically, all of them so far) the debug flags for a given call are a compile-time constant, so the nested conditional will never actually show up in code when compiled with optimization; we'll just see the appropriate conditional test. The VERBOSE flag is magical, in that if the VERBOSE flag is used in a message, the debug flags have to have both VERBOSE and at least one other flag for the call to be made. This should dramatically improve performance for a lot of cases without as much need for PSEUDO_NDEBUG, and improve the ability of users to get coherent debugging output that means something and is relevant to a given case. It's also intended to set the stage for future development work involving improving the clarity and legibility of pseudo's diagnostic messages in general. Old things which used numeric values for PSEUDO_DEBUG will sort of continue to work, though they will almost always be less verbose than they used to. There should probably be a pass through adding "| PDBGF_CONSISTENCY" to a lot of the messages that are specific to some other type.
2013-02-17Darwin fixes for fsync changes, uninitialized variablePeter Seebach
Darwin's off_t is a 64-bit type, so there's no off64_t. Also, there's an uninitialized variable usage in unlinkat which LLVM catches. Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
2013-02-16If you don't want the answer, don't ask the question.Peter Seebach
Most pseudo operations don't actually USE the server's response. So why wait for a response? This patch introduces a new message type, PSEUDO_MSG_FASTOP. It also tags pseudo operation types with whether or not they need to give a response. This requires updates to maketables to allow non-string types for additional columns, and the addition of some quotes to the SQL query enums/query_type.in table. A few routines are altered to change their behavior and whether or not they perform a stat operation. The only operations that do wait are OP_FSTAT and OP_STAT, OP_MKNOD, and OP_MAY_UNLINK. Rationale: You can't query the server for replacement information and not wait for it. Makes no sense. There's extra checking in mknod, because we really do want to fail out if we couldn't do that -- that implies that we haven't created a thing that will look like a node. The result from OP_MAY_UNLINK is checked because it's used to determine whether we need to send a DID_UNLINK or CANCEL_UNLINK. It might be cheaper to send two messages without waiting than to send one, wait, and maybe send another, but I don't want to send invalid messages. This is highly experimental.
2013-02-16allow pseudo to force asynchronous behaviorPeter Seebach
The openembedded build, at least with RPM or SMART, is heavily affected by the cost of calling fsync or fdatasync on package databases all the time. Gosh, wouldn't it be nice if we could suppress that without making dozens of highly intrusive and risky changes into RPM, various database packages, and so on? Yes, yes it would. If only there were a program which could intercept system calls and change their behavior! Enter --enable-force-async. There are now wrappers for fsync, fdatasync, and a few related functions. If --enable-force-async is set, these wrappers instantly return 0, even if PSEUDO_DISABLED is set. And with any luck, bitbake will now perform a bit better. Credit for this insight goes to Richard Purdie. I've reimplemented this to add the configure option, and make the fsync suppression work even when PSEUDO_DISABLED is set.
2013-02-13Fix linkat() again.pseudo-1.4.5PSEUDO_1_4_5Peter Seebach
wrap_linkat() was trying to avoid "redundantly" expanding paths before calling real_linkat(). Which is fine when you're not using an absolute path in a chroot environment, but if you are, it ends up calling the real syscall with the absolute path and no chroot prefix. General observation: All the *at() implementations are expanding paths into absolute paths, then dutifully calling real_*at() functions with them anyway. This is silly. Added a note to Futures.txt to fix it some day. In the mean time, linkat() is fixed correctly; it always expands paths, does so exactly once, and then uses the underlying link() call because it doesn't need special processing of directory fds anymore. Also fixed errno stashing to reduce the risk that link() will change errno in a circumstance where it doesn't actually fail.
2013-02-12Fix link() to work when chrootedpseudo-1.4.4PSEUDO_1_4_4Peter Seebach
The automatic path fixups invoked for names which end in the string "path" was still applying to link(), which then called linkat(), which would do the same path fixups; if you were chrooted, this would produce bogus paths. On systems which actually have linkat(), this would produce the even more mysterious behavior that the link would succeed, but the following stat would fail. Solution: Change the wrapfuncs prototypes for link() so it doesn't invoke automatic path name fixups.
2012-12-12add linkat() implementationPeter Seebach
We never had an implementation for linkat() because no one used it; now someone uses it. link() is now implemented on top of linkat(). Note the abnormal AT_SYMLINK_FOLLOW (as opposed to _NOFOLLOW) flag.
2012-08-02Remove the _plain thing, use PSEUDO_STATBUF everywhere.Peter Seebach
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).
2012-03-28cleanup and fixesPeter Seebach
Spotted a couple of things during the last batch of fixes; fixing these up so things are more consistent or clearer.
2012-03-27add popen() callPeter Seebach
We weren't trapping popen(), so if environment variables were in an inconsistent state when popen() was called, Bad Things Happened. Add a popen() wrapper. Like a couple of other special cases, is applied even when pseudo is theoretically disabled, and that includes the antimagic case. (But we never use popen() so that's fine.)
2012-02-06Fix *at() function interface holesPeter Seebach
1. Fix *at() where dirfd is obtained through dirfd(DIR *). The dirfd(DIR *) interface allows you to get the fd for a DIR *, meaning you can use it with openat(), meaning you can need its path. This causes a segfault. Also fixed the base_path code not to segfault in that case, but first fix the underlying problem. 2. Implement renameat() After three long years, someone tried to use this. This was impossibly hard back when pseudo was written, because there was only one dirfd provided for. Thing is, now, the canonicalization happens in wrapfuncs, so a small tweak to makewrappers to recognize that oldpath should use olddirfd if it exists is enough to get us fully canonicalized paths when needed.
2011-06-09Fix realpath(name, NULL) when PSEUDO_DISABLED=1Peter Seebach
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.
2011-06-06Improve system()Peter Seebach
2011-06-02Add system() wrapper to force setup of the pseudo environment. NotePeter Seebach
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.
2011-05-31Change logic on file creation/chmod so that we only secretly mask inPeter Seebach
the 0100 bit for directories. The reason is that otherwise we create plain files which are 0700 on disk, which means they're non-zero &0111, which breaks euidaccess(X_OK).
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.