summaryrefslogtreecommitdiff
path: root/trans/fakeroot.c
AgeCommit message (Collapse)Author
2023-12-17Update server handlers to return kern_return_error to fix ↵Flavio Cruz
-Werror=enum-int-mismatch warnings MiG expects those to return kern_return_t. Message-ID: <ZXqbbXpVqQAwd2qv@jupiter.tail36e24.ts.net>
2023-08-08Homogeneize [gs]et_translator and get_dire[nc]ts into mach_msg_type_number_tSamuel Thibault
This makes netfs_[gs]et_translator use mach_msg_type_number_t like the RPC and diskfs. This also makes the fshelp_fetch_root_callback1_t for fshelp_fetch_root use mach_msg_type_number_t. This also makes procfs_get_translator and the get_translator proc method use mach_msg_type_number_t. This makes diskfs_get_directs use mach_msg_type_number_t like the dir_readdir RPC Also get rid of u_int. This notably fixes _diskfs_translator_callback1_fn's bogus cast of size_t *argz_len into (u_int *).
2023-05-10trans: Port to x86_64Sergey Bugaev
Message-Id: <20230508213136.608575-39-bugaevc@gmail.com>
2022-08-23file_exec: Homogeneize adding the gratuitous send rightSamuel Thibault
2022-08-23Fix spurious EINTR while exec() within fakerootSamuel Thibault
The scenario is: - process running inside fakeroot exec()s - fakeroot forwards the exec call - exec starts thrashing the previous process, and notably close its ports - the send port that pointed to fakeroot is thus closed - fakeroot thus receives a no-senders notification - its libports thus interrupts the current RPC on it, i.e. the exec(), because it thinks that the caller is no more, but that was exactly the point of the exec()... - exec tries to interrupt its own RPCs, at best the execution will fail, at worse the process is already thrashed and there's nothing better than burying it for good. The symptom is processes running inside fakeroot seeming randomly crashing with SIGKILL. Making fakeroot keep a send right avoids the no-senders notification, thus the whole interruption (which was meaningless).
2022-01-17Fix const warningsSamuel Thibault
Now that the RPCs have const, this forces us cleaning our const-meant functions.
2022-01-16Make RPC input array parameters constSamuel Thibault
This follows mig's cf4bcc3f1435 ("Also add const qualifiers on server side")
2022-01-01Fix build warningsSamuel Thibault
No actual behavior change.
2019-09-01Use the data_t type defined in hurd_types.h.Flavio Cruz
* boot/boot.c: Replace char* with data_t. * console-client/trans.c: Likewise. * exec/exec.c: Likewise. * ext2fs/storeinfo.c: Likewise. * fatfs/inode.c: Likewise. * fatfs/main.c: Likewise. * isofs/inode.c: Likewise. * libdiskfs/boot-start.c: Likewise. * libdiskfs/dir-readdir.c: Likewise. * libdiskfs/file-exec.c: Likewise. * libdiskfs/file-get-fs-opts.c: Likewise. * libdiskfs/file-get-trans.c: Likewise. * libdiskfs/file-getfh.c: Likewise. * libdiskfs/file-set-trans.c: Likewise. * libdiskfs/fsys-forward.c: Likewise. * libdiskfs/fsys-getfile.c: Likewise. * libdiskfs/fsys-options.c: Likewise. * libdiskfs/io-read.c: Likewise. * libdiskfs/io-write.c: Likewise. * libnetfs/dir-readdir.c: Likewise. * libnetfs/file-exec.c: Likewise. * libnetfs/file-get-fs-options.c: Likewise. * libnetfs/file-get-storage-info.c: Likewise. * libnetfs/file-get-translator.c: Likewise. * libnetfs/file-set-translator.c: Likewise. * libnetfs/fsstubs.c: Likewise. * libnetfs/fsys-get-options.c: Likewise. * libnetfs/fsys-set-options.c: Likewise. * libnetfs/fsysstubs.c: Likewise. * libnetfs/io-read.c: Likewise. * libnetfs/io-write.c: Likewise. * libtrivfs/dir-readdir.c: Likewise. * libtrivfs/file-get-fs-options.c: Likewise. * libtrivfs/file-get-storage-info.c: Likewise. * libtrivfs/file-get-trans.c: Likewise. * libtrivfs/file-getfh.c: Likewise. * libtrivfs/file-set-trans.c: Likewise. * libtrivfs/fsys-forward.c: Likewise. * libtrivfs/fsys-get-options.c: Likewise. * libtrivfs/fsys-set-options.c: Likewise. * libtrivfs/fsys-stubs.c: Likewise. * libtrivfs/io-read.c: Likewise. * libtrivfs/io-write.c: Likewise. * pfinet/io-ops.c: Likewise. * pfinet/pfinet-ops.c: Likewise. * pfinet/socket-ops.c: Likewise. * pfinet/tunnel.c: Likewise. * pflocal/io.c: Likewise. * pflocal/pf.c: Likewise. * pflocal/socket.c: Likewise. * proc/info.c: Likewise. * startup/startup.c: Likewise. * storeio/io.c: Likewise. * term/users.c: Likewise. * tmpfs/node.c: Likewise. * trans/crash.c: Likewise. * trans/fakeroot.c: Likewise. * trans/fifo.c: Likewise. * trans/firmlink.c: Likewise. * trans/hello-mt.c: Likewise. * trans/hello.c: Likewise. * trans/mtab.c: Likewise. * trans/new-fifo.c: Likewise. * trans/null.c: Likewise. * trans/proxy-defpager.c: Likewise. * trans/streamio.c: Likewise.
2019-07-27Fix missing gnu_dev_* prototypesSamuel Thibault
* isofs/rr.c: Include <sys/sysmacros.h>. * libdiskfs/file-set-trans.c: Likewise. * libfshelp/fetch-root.c: Likewise. * libnetfs/file-get-translator.c: Likewise. * libnetfs/file-set-translator.c: Likewise. * nfs/nfs.c: Likewise. * nfs/ops.c: Likewise. * storeio/storeio.c: Likewise. * trans/fakeroot.c: Likewise.
2018-06-13Hurd patches (fix compilation)Luca Weiss
* isofs/rr.c (rrip_work): Use gnu_dev_makedev instead of makedev. * libdiskfs/file-set-trans.c (diskfs_S_file_set_translator): Likewise. * libnetfs/file-set-translator.c (netfs_S_file_set_translator): Likeiwse. * nfs/nfs.c (xdr_decode_fattr): Likewise. * storeio/storeio.c (parse_opt): Likewise. * libfshelp/fetch-root.c (fshelp_short_circuited_callback1): Use gnu_dev_major and gnu_dev_minor instead of major and minor. * libnetfs/file-get-translator.c (netfs_S_file_get_translator): Likewise. * nfs/ops.c (netfs_attempt_link): Likewise. * storeio/storeio.c (trivfs_append_args): Likewise. * trans/fakeroot.c (netfs_attempt_mkdev): Likewise. * pfinet/glue-include/linux/mm.h: Include <mach/vm_param.h>. * term/users.c: Include <signal.h>
2018-03-05Add file_utimens RPC to use a struct timespecFlávio Cruz
and update the servers to use UTIME_NOW and UTIME_OMIT. * console-client/trans.c (netfs_attempt_utimes): Do not set current time ourself. * console/console.c (netfs_attempt_utimes): Likewise. * ftpfs/netfs.c (netfs_attempt_utimes): Likewise. * hostmux/node.c (netfs_attempt_utimes): Likewise. * usermux/node.c (netfs_attempt_utimes): Likewise. * nfs/ops.c (netfs_attempt_utimes): Likewise. * doc/hurd.texi (file_utimens): Add documentation. * hurd/fs.defs (file_utimens): Add RPC. * libdiskfs/file-utimes.c (diskfs_S_file_utimes): Move implementation and replace with translation layer with... (diskfs_S_file_utimens): ... new function. * libnetfs/file-utimes.c (netfs_S_file_utimes): Likewise with... (netfs_S_file_utimens): ... new function. * libnetfs/init-init.c: Include <error.h>. (netfs_mtime): New variable. (netfs_init): New function. * libnetfs/netfs.h (netfs_attempt_utimes): Update documentation. * libnetfs/priv.h (netfs_mtime): Declare variable. * libtreefs/s-file.c (treefs_S_file_utimes): Convert time values and call treefs_s_file_utimens instead of treefs_s_file_utimes. * libtreefs/treefs-hooks.h: Replace TREEFS_HOOK_S_FILE_UTIMES with TREEFS_HOOK_S_FILE_UTIMENS. * libtreefs/treefs-s-hooks.h: Replace s_file_utimes with s_file_utimens. * libtrivfs/file-utimes.c (trivfs_S_file_utimens): New function. * libtrivfs/times.c (trivfs_set_atime): Try to use file_utimens before using file_utimes. (trivfs_set_mtime): Likewise. * nfsd/ops.c (complete_setattr): Likewise. * trans/fakeroot.c (netfs_attempt_utimes): Likewise. * nfs/nfs.c (xdr_encode_sattr_times): Do not set atime or mtime when they are NULL. * configure.ac: Look for file_futimens, and define UTIME_NOW/OMIT, for compatibility with old glibcs.
2018-01-08Add a file_exec_file_name RPCEmilio Pozuelo Monfort
* hurd/fs.defs (file_exec): Deprecate in favor of... (file_exec_paths): ...this new RPC. * TODO: Update. * doc/hurd.texi: Update RPC name. * hurd/hurd_types.h: Update RPC name. * libdiskfs/boot-start.c: Update RPC name. * configure.ac: Check for presence of RPC stubs file_exec_paths exec_exec_paths. * exec/hashexec.c (check_hashbang): When file_exec_paths is available, use it instead of file_exec. * startup/startup.c (run, run_for_real, start_child): Likewise. * utils/login.c (main): Likewise. * libfshelp/start-translator-long.c (fshelp_start_translator_long): Likewise. * libdiskfs/file-exec.c (diskfs_S_file_exec): Move code to new function diskfs_S_file_exec_paths and call it. (diskfs_S_file_exec_paths): New function, use exec_exec_paths when available instead of exec_exec * libnetfs/file-exec.c (netfs_S_file_exec, netfs_S_file_exec_paths): Likewise. * trans/fakeroot.c (netfs_S_file_exec, netfs_S_file_exec_paths): Likewise. * libtrivfs/file-exec.c (trivfs_S_file_exec_paths): New function.
2017-08-05Use our own variant of 'assert' and 'assert_perror'.Justus Winter
Our variants print stack traces on failures. This will make locating errors much easier.
2017-06-20trans/fakeroot: Obey O_NOFOLLOW.Justus Winter
* trans/fakeroot.c (netfs_S_dir_lookup): Do not follow symlinks if the client used O_NOFOLLOW.
2016-03-21netfs: Remove global reference count lock.Flavio Cruz
* libnetfs/drop-node.c: Remove use of netfs_node_refcnt_lock. * libnetfs/init-init.c: Remove netfs_node_refcnt_lock. * libnetfs/make-node.c: Initialize refcounts in refcounts_init. * libnetfs/netfs.h: Use refcounts_t for tracking node references. Remove netfs_node_refcnt_lock. Add netfs_nref_light, netfs_nrele_light and handler netfs_try_dropping_softrefs. Adjust comments. * libnetfs/nput.c: Use refcounts_t. Call netfs_try_dropping_softrefs to remove any soft reference that the translator might have acquired during the lifetime of the node. Implement empty netfs_try_dropping_softrefs. * libnetfs/nref.c: Implement netfs_nref_light. * libnetfs/nrele.c: Use refcounts_t and netfs_try_dropping_softrefs. Implement netfs_nrele_light. * ftpfs/dir.c: Use netfs_nref without locking the old netfs_node_refcnt_lock. * ftpfs/node.c: Likewise. * usermux/mux.c: Use netfs_nref to increase hard references of the node. * hostmux/mux.c: Use netfs_nref to increase hard references of the node. * trans/fakeroot.c (new_node): Use a light reference when storing a node in the hash table. * trans/fakeroot.c (netfs_try_dropping_softrefs): Implement netfs_try_dropping_softrefs to remove the node from the hash table. * trans/fakeroot.c (netfs_node_norefs): Remove code to remove the node from the hash table. * trans/fakeroot.c (netfs_S_dir_lookup): Simplify lookup code since we don't need to lock netfs_node_refcnt_lock anymore. * procfs/netfs.c: Remove use of netfs_node_refcnt_lock. * nfs/cache.c: Add mutex to handle exclusive access to nodehash. This replaces the use of netfs_node_refcnt_lock. * nfs/cache.c (lookup_handle): Use nodehash_ihash_lock when accessing nodehash. Use netfs_nref_light to add one soft reference to the node just added to nodehash. * nfs/cache.c (netfs_node_norefs): Use netfs_nref. Don't use netfs_node_refcnt_lock and don't remove the node from nodehash here. * nfs/cache.c (netfs_try_dropping_softrefs): Drop the light reference when the node has no more hard references. * nfs/cache.c (recache_handle): Use nodehash_ihash_lock instead. * nfs/ops.c (netds_attempt_unlink): Use refcounts_references. * console/console.c (netfs_node_norefs): Use a soft reference to store a node in dir_node, cons_node, disp_node, inp_node. * console/console.c (netfs_try_dropping_softrefs): When dropping all soft references remove node pointer from the fields above.
2016-02-15Make fakeroot forward send errors instead of crashingSamuel Thibault
* trans/fakeroot.c (netfs_demuxer): When forwarding an unknown request fail, forward the error instead of crashing.
2016-02-14Fix hang on reauthenticationSamuel Thibault
One needs to keep the port being reauthenticated alive until we are sure the server has complete authentication. * libfshelp/fetch-root.c (fshelp_fetch_root): Deallocate `port' after auth_user_authenticate has completed. * trans/fakeroot.c (netfs_S_dir_lookup): Likewise with `file'.
2015-10-20Make fakerooted access() return real accessSvante Signell
Various realworld tests would otherwise think they can write to /, while they actually can't. * trans/fakeroot.c (netfs_report_access): Call file_check_access instead of returning O_RDWR|O_EXEC when faking mode too.
2015-10-12Make dir_lookup create files with user permissions enabledSamuel Thibault
So we will always be able to re-open them. * trans/fakeroot.c (netfs_S_dir_lookup): Call real_from_fake_mode() on modes before calling the underlying filesystem's dir_lookup.
2015-08-14Fake full file access only for faked nodesSamuel Thibault
Otherwise some scripts may try to modify system files just because they find they seem to be able to. * trans/fakeroot.c (netfs_report_access): When FAKE_MODE is not set on `np', call file_check_access on the underlying node instead of returning O_RDWR|O_EXEC.
2015-08-14Make fakeroot return file types from underly fsSamuel Thibault
Fakeroot does not support faking them anyway, and they may change on the underlying fs, e.g. when creating a local socket. * trans/fakeroot.c (netfs_validate_stat): Return S_IFMT part of st_mode as provided by underlying filesystem.
2015-06-17Cope with scripts which chmod -x directoriesSvante Signell
As well as other potential mode changes which are indeed supposed to still work as root. * trans/fakeroot.c (netfs_attempt_chmod): Always set S_IRUSR and S_IWUSR in real_mode, and set S_IXUSR also when this is a directory.
2015-05-23fakeroot: Fix reopening files after a chmodSamuel Thibault
Huge thanks to Svante Signell for having tracked the bug. * trans/fakeroot.c (netfs_attempt_chmod): Make the file_chmod call additionally include the modes from nn->openmodes.
2015-05-23Make comment clearerSamuel Thibault
* trans/fakeroot.c (check_openmodes): Make comment clearer about missing new openmodes.
2015-05-23Make sure to record only RWX open modesSamuel Thibault
Thanks Svante Signell for the investigation and proposed patch. * trans/fakeroot.c (new_node): Assert that `openmodes' includes only O_RDWR|O_EXEC (check_openmodes): Likewise with `newmodes'. (netfs_S_dir_lookup): Keep only O_RDWR|O_EXEC from `flags' when calling new_node.
2015-05-14Fix creating named sockets inside fakeroot-hurdSvante Signell
* trans/fakeroot.c (netfs_set_translator): New function.
2014-12-10fakeroot: Fix initializing default faked field of nodesSamuel Thibault
* trans/fakeroot.c (new_node): Initialize faked field to FAKE_DEFAULT.
2014-12-09Fix mode of nodes created with mkfileSamuel Thibault
Their faked field was not initialized. Thanks a lot to Svante Signell for the investigation * trans/fakeroot.c (new_node): Initialize faked field of nn to 0. (netfs_attempt_mkfile): Call set_default_attributes on newly-allocated node, and if the real mode is not the same as the requested mode, fake the mode.
2014-12-07trans/fakeroot: make the demuxer payload-awareJustus Winter
* trans/fakeroot.c (netfs_demuxer): Make the demuxer payload-aware.
2014-06-18trans/fakeroot: fix error handlingJustus Winter
Found using the Clang Static Analyzer. * trans/fakeroot.c (new_node): Do not leak a pointer to freed memory. Store NULL at *np instead. This fixes a node use-after-free in netfs_S_dir_lookup.
2014-05-28trans/fakeroot: use netfs_node_netnode instead of np->nnJustus Winter
When using fat nodes, expressions of the form E->nn can be rewritten as netfs_node_netnode (E). This is much faster as it only involves a offset calculation. For reference, I used the following semantic patch to create the patch: @@ expression E; @@ - E->nn + netfs_node_netnode (E) * trans/fakeroot.c: Use netfs_node_netnode instead of np->nn.
2014-05-28trans/fakeroot: use fat nodes to simplify the node cacheJustus Winter
Previously, fakeroot stored netnodes in the hash table. But we are not interested in a cache for netnodes, we need a node cache. So fakeroot kept pointers to the associated node object in each netnode object. Use fat netfs nodes, which combine node and netnode objects. * trans/fakeroot.c (struct netnode): Remove np. (idport_ihash): Fix ihash location pointer offset. (new_node): Allocate fat nodes, store the node pointer in the hash table. (netfs_node_norefs): Adjust accordingly. (netfs_S_dir_lookup): Likewise.
2014-05-22trans/fakeroot: override fshelp_isownerJustus Winter
As of recently, fakeroot would fail to create symlinks: % fakeroot-hurd ln -s foo a ln: failed to create symbolic link ‘a’: Operation not permitted Fix this by overriding fshelp_isowner. Various netfs functions will call fshelp_isowner to check whether USER is allowed to do some operation. As fakeroot is not running within the fakeauth'ed environment, USER contains the real user. I have no explanation why this ever worked. * trans/fakeroot.c (fshelp_isowner): New function.
2014-05-16trans/fakeroot: use C99-style struct initializationJustus Winter
* trans/fakeroot.c (main): Use C99-style struct initialization to initialize argp. This avoids a warning about missing field initializers.
2014-05-16trans/fakeroot: fix comparison between signed and unsignedJustus Winter
* trans/fakeroot.c (netfs_attempt_chown): Fix comparison between signed and unsigned integer expressions.
2014-05-16trans/fakeroot: remove spurious semicolonJustus Winter
A spurious semicolon caused a control flow bug in check_openmodes, leading to a port leak. * trans/fakeroot.c (check_openmodes): Remove spurious semicolon.
2014-04-15Include the MIG-generated server header filesJustus Winter
This enables the compiler to check that the server function declarations match MIGs expectations. Fix a few oddities along the way. * console-client/trans.c: Include MIG-generated server header file(s). * console/console.c: Likewise. Also, fix declarations. * console/mutations.h (TIOCTL_IMPORTS): Just use libnetfs/priv.h. * console/priv.h: Delete now unused file. * ext2fs/storeinfo.c: Include MIG-generated server header file(s). * fatfs/inode.c: Likewise. * fatfs/main.c: Likewise. Also, fix declaration. * isofs/inode.c: Likewise. * libdiskfs/boot-start.c: Likewise. * libdiskfs/file-chg.c: Include the correct MIG-generated server header file. * libdiskfs/file-chmod.c: Include MIG-generated server header file(s). * libdiskfs/file-get-fs-opts.c: Likewise. * libdiskfs/init-startup.c: Likewise. * libnetfs/file-get-children.c: Likewise. * libnetfs/file-getcontrol.c: Include the correct MIG-generated server header file. * libnetfs/file-set-translator.c: Include MIG-generated server header file(s). * libnetfs/fsstubs.c: Likewise. * libtrivfs/file-access.c: Likewise. * libtrivfs/file-chauthor.c: Likewise. * libtrivfs/file-chflags.c: Likewise. * libtrivfs/file-chg.c: Likewise. * libtrivfs/file-chmod.c: Likewise. * libtrivfs/file-chown.c: Likewise. * libtrivfs/file-exec.c: Likewise. * libtrivfs/file-get-children.c: Likewise. * libtrivfs/file-get-fs-options.c: Likewise. * libtrivfs/file-get-source.c: Likewise. * libtrivfs/file-get-storage-info.c: Likewise. * libtrivfs/file-get-trans.c: Likewise. * libtrivfs/file-get-transcntl.c: Likewise. * libtrivfs/file-getcontrol.c: Likewise. * libtrivfs/file-getfh.c: Likewise. * libtrivfs/file-getlinknode.c: Likewise. * libtrivfs/file-lock.c: Likewise. * libtrivfs/file-reparent.c: Likewise. * libtrivfs/file-set-size.c: Likewise. * libtrivfs/file-set-trans.c: Likewise. * libtrivfs/file-statfs.c: Likewise. * libtrivfs/file-sync.c: Likewise. * libtrivfs/file-syncfs.c: Likewise. * libtrivfs/file-utimes.c: Likewise. * libtrivfs/fsys-forward.c: Likewise. * libtrivfs/fsys-get-options.c: Likewise. * libtrivfs/fsys-getroot.c: Likewise. * libtrivfs/fsys-goaway.c: Likewise. * libtrivfs/fsys-set-options.c: Likewise. * libtrivfs/fsys-stubs.c: Likewise. * libtrivfs/fsys-syncfs.c: Likewise. * libtrivfs/io-async-icky.c: Likewise. * libtrivfs/io-async.c: Likewise. * libtrivfs/io-duplicate.c: Likewise. * libtrivfs/io-identity.c: Likewise. * libtrivfs/io-map.c: Likewise. * libtrivfs/io-modes-get.c: Likewise. * libtrivfs/io-modes-off.c: Likewise. * libtrivfs/io-modes-on.c: Likewise. * libtrivfs/io-modes-set.c: Likewise. * libtrivfs/io-owner-get.c: Likewise. * libtrivfs/io-owner-mod.c: Likewise. * libtrivfs/io-pathconf.c: Likewise. * libtrivfs/io-read.c: Likewise. * libtrivfs/io-readable.c: Likewise. * libtrivfs/io-reauthenticate.c: Likewise. * libtrivfs/io-restrict-auth.c: Likewise. * libtrivfs/io-revoke.c: Likewise. * libtrivfs/io-seek.c: Likewise. * libtrivfs/io-select.c: Likewise. * libtrivfs/io-stat.c: Likewise. * libtrivfs/io-stubs.c: Likewise. * libtrivfs/io-version.c: Likewise. * libtrivfs/io-write.c: Likewise. * pfinet/tunnel.c: Likewise. * storeio/io.c: Likewise. * storeio/storeio.c: Likewise. * term/users.c: Likewise. * tmpfs/node.c: Likewise. * trans/fakeroot.c: Likewise. Also, include all server headers that provide the X_server_routine functions... (netfs_demuxer): ... that were previously declared here. * trans/fifo.c: Include MIG-generated server header file(s). * trans/firmlink.c: Likewise. * trans/hello-mt.c: Likewise. * trans/hello.c: Likewise. * trans/magic.c: Likewise. * trans/mtab.c: Likewise. * trans/new-fifo.c: Likewise. * trans/null.c: Likewise. * trans/proxy-defpager.c: Likewise. * trans/streamio.c: Likewise. * libdiskfs/fsmutations.h: Qualify the import with the libraries path. Without this change, out-of-tree builds would no longer work. * libnetfs/mutations.h: Likewise. * libtrivfs/mig-mutate.h: Likewise.
2014-02-07trans/fakeroot: fix cached node retrieval on lookupRichard Braun
When a client finds a node from the hash table, it could happen that another thread is still holding one reference on it before the current thread has acquired its own. Simply checking for a non zero refcount isn't enough, the new client must atomically acquire its own reference. * trans/fakeroot.c (netfs_S_dir_lookup): Find and acquire node reference while holding netfs_node_refcnt_lock.
2014-02-06trans/fakeroot: fix netfs_S_dir_lookupRichard Braun
* trans/fakeroot.c (netfs_S_dir_lookup): Fix node dereference.
2014-02-05trans/fakeroot: rework node cachingRichard Braun
Instead of the FAKE_REFERENCE flag, rework node caching so that nodes are retained only if their attributes are actually changed. In addition, don't remove unreferenced nodes from the hash table at protid release, since their reference counter is unstable. Do it on node destruction, once the reference counter has reached 0. This means lookups can return nodes not referenced (other than by the hash table), a condition for which a check is added. By never acquiring a reference on such nodes, their counter is guaranteed to remain stable once unreferenced. * trans/fakeroot.c (FAKE_REFERENCE): Remove macro. (FAKE_DEFAULT): New macro. (set_default_attributes): New function. (set_faked_attribute): Likewise. (netfs_node_norefs): Remove node from hash table, properly taking care of all the locks involved. (fakeroot_netfs_release_protid): Remove node handling code, merely call netfs_release_protid. (netfs_S_dir_lookup): Handle unreferenced nodes, call set_default_attributes on node creation, remove call to netfs_attempt_chown. (netfs_attempt_chown): Call set_faked_attribute instead of accessing faked flags directly. (netfs_attempt_chauthor): Likewise. (netfs_attempt_chmod): Likewise. (main): Likewise.
2014-02-05trans/fakeroot: fix chmodRichard Braun
Unconditionally relay chmod requests instead of filtering those that don't change the executable bit. * trans/fakeroot.c (netfs_attempt_chmod): Unconditionally call file_chmod with an unaltered mode.
2014-02-05Revert "trans: fix locking issue in fakeroot"Richard Braun
This reverts commit 672005782e57e049c7c8f4d6d0b2a80c0df512b4. That change is apparently not needed and introduced a deadlock. * trans/fakeroot.c (netfs_attempt_mkfile): Unlock directory node before creating new node.
2014-02-05trans/fakeroot: fix right leakRichard Braun
* trans/fakeroot.c (netfs_S_dir_lookup): Deallocate rights to intermediate file systems.
2013-12-19trans/fakeroot: shutdown the translator if the last client is goneJustus Winter
Previously, fakeroot would not exit if a process outlived the original process started by settrans. This caused bugs like this: % fakeroot-hurd /bin/sh -c 'sleep 1&' 2>&1 | tee <hangs> Fix this by exiting if the last client of fakeroot goes away. If noone has a right to any control or protid port, noone can ever reacquire any such right. So it is safe to shutdown the fakeroot translator in that case. * trans/fakeroot.c (fakeroot_netfs_release_protid): Shutdown the translator if the last protid object is destroyed and no control port is around either.
2013-12-10trans/fakeroot: remove dead codeJustus Winter
* trans/fakeroot.c (netfs_S_dir_lookup): Remove dead code.
2013-12-10trans/fakeroot: remove dead codeJustus Winter
* trans/fakeroot.c (netfs_S_dir_lookup): Remove dead code.
2013-12-10trans/fakeroot: drop elseJustus Winter
* trans/fakeroot.c (netfs_S_dir_lookup): Drop else.
2013-12-10trans/fakeroot: fix ownership of newly created filesJustus Winter
Previously, files created in the fakeroot environment were created with the uid and gid of the user running fakeroot: % fakeroot-hurd /bin/sh -c 'touch /tmp/$$; stat --format=%u:%g /tmp/$$' 1000:1000 * trans/fakeroot.c (netfs_S_dir_lookup): Fix ownership of newly created files.
2013-12-09trans: unlock nodes with faked attributes in fakerootJustus Winter
When a node has faked attributes, we cannot drop our node. Reinitialize the lock box as if the node was dropped. This fixes the following bug: % fakeroot-hurd /bin/sh -c 'touch /tmp/$$.lock chown 0 /tmp/$$.lock l(){ flock /tmp/$$.lock true; }; l; l' <hangs> * trans/fakeroot.c (fake_node_dropweak): Unlock the node if the last real reference is dropped but we keep a fake one.