summaryrefslogtreecommitdiff
path: root/utils
AgeCommit message (Collapse)Author
2014-11-21Always canonicalize fstab entries with realpathSamuel Thibault
To avoid spurious ./, /, symlinks, etc. * sutils/fstab.c (fs_set_mntent): Try to call realpath on mnt_fsname and mnt_dir field of `mntent'. (fstab_find_mount): Try to call realpath on `name' parameter. (fstab_find): Do not try to call realpath. (fstab_read): Reset errno to zero before calling getmntent. * utils/umount.c (main): Do not warn about missing fstab entries for active translators.
2014-11-12utils/rpctrace: fix crash while printing messagesJustus Winter
% fakeroot rpctrace install [...] 63<--66(pid5363)->io_read (-1 8192) = 0 [... rpctrace crashes] /bin/fakeauth: Segmentation fault for child 5362 /bin/settrans: Error 139 for child 5361 * utils/rpctrace.c (print_data): Fix this by guarding the code escaping non-printable characters introduced in 84932431 against `data' being NULL.
2014-11-02Fix proc_getprocinfo callsSamuel Thibault
The deallocation also needs to be fixed. Also, fetch_procinfo already took care of the conversion. * exec/elfcore.c (dump_core): Fix procinfoCnt taken from proc_getprocinfo. * utils/login.c (check_owned): Likewise. * libps/procstat.c (merge_procinfo): Remove conversion between bytes and int, already handled by fetch_procinfo.
2014-11-02Fix proc_getprocinfo callsSamuel Thibault
The procinfoCnt argument is the number of elements of the procinfo_t array, not its size in bytes. * exec/elfcore.c (dump_core): Fix procinfoCnt given to proc_getprocinfo. * libps/procstat.c (merge_procinfo): Likewise. * utils/login.c (check_owned): Likewise.
2014-10-05libports: lock-less reference counting for port_info objectsJustus Winter
* libports/ports.h (struct port_info): Use the new type. * libports/lookup-port.c: No need to lock _ports_lock anymore. * libports/bucket-iterate.c: Likewise. * libports/complete-deallocate.c: Check if someone reacquired a reference through a hash table lookup. * libports/create-internal.c: Use the new reference counting primitives. * libports/get-right.c: Likewise. * libports/import-port.c: Likewise. * libports/port-deref-weak.c: Likewise. * libports/port-deref.c: Likewise. * libports/port-ref-weak.c: Likewise. * libports/port-ref.c: Likewise. * libports/reallocate-from-external.c: Likewise. * libports/transfer-right.c: Likewise. * utils/rpctrace.c: Likewise.
2014-10-05utils/mount: add mount options to create firmlinks.Gabriele Giacone
* utils/mount.c (parse_opt): Add -B/--bind/--firmlink/-o bind mount options. (do_mount): Do not pass bind mount option to settrans, set firmlink fstype. (main): Likewise.
2014-10-04utils/umount: clean upGabriele Giacone
According to f2640263468aced5c91ac5fc1f15bb5691f7eb20, passive translators are no longer removed. * utils/umount.c (do_umount) Remove -p option from verbose message. (passive_flags): Remove.
2014-08-19Make settrans return value returned by chroot commandSvante Signell
* utils/settrans.c (main): In case of chroot_command, get status from waitpid() call, and call error() appropriately.
2014-06-15utils/settrans: implement settrans --startJustus Winter
Start the translator specified by the NODE's passive translator record and set it as NODE's active translator. This is the equivalent of doing: % settrans --active /node $(showtrans /node) * utils/settrans.c (argp_option): Add --start. (parse_opt): Handle --start. (main): Retrieve the passive translator record if --start is given.
2014-04-22Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/hurdSamuel Thibault
2014-04-22Add TODO about fork() making rpctrace emit an errorSamuel Thibault
* utils/rpctrace.c (rewrite_right): Explain why the unknown send right error happens on fork().
2014-04-22build: Remove configure check for libcrypt.Ludovic Courtès
GNU libc has provided the 'crypt' function in libcrypt for a long time, making this check unnecessary. * configure.ac: Remove libcrypt check and 'LIBCRYPT' substitution. * config.make.in (LIBCRYPT): Remove. * trans/Makefile (password-LDLIBS): Change $(LIBCRYPT) to -lcrypt. * utils/Makefile (login-LDLIBS, addauth-LDLIBS, setauth-LDLIBS): Likewise.
2014-03-01auth: improve the mig mutator functionsJustus Winter
Previously, the mig mutator function auth_port_to_handle was defined in auth.c (fakeauth.c), preventing it from being inlined into the mig-generated server functions. Put it in mig-decls.h instead. Rename authmutations.h to mig-mutate.h, auth_mig.h to mig-decls.h. This is the naming convention used for pflocal. * auth/auth.h: New file. * auth/auth_mig.h: Rename to mig-decls.h, add copyright notice, define mutator functions. * auth/authmutations.h: Rename to mig-mutate.h, restore copyright notice, adjust accordingly. * auth/auth.c: Include auth.h, remove auth_port_to_handle. * utils/fakeauth.c: Likewise. * auth/Makefile: Adjust accordingly. * utils/Makefile: Likewise.
2014-02-25utils/umount: do not remove passive translator recordsJustus Winter
Passive translator records are a Hurd concept. Therefore, the umount compatibility program should not remove them. * utils/umount.c (passive_flags): Unset FS_TRANS_SET. (doc): Adjust accordingly.
2014-02-25Fix fakeroot and remap parsing corner casesSamuel Thibault
Fix case when $PWD contains spaces. Pass directly arguments to command, to directly avoid escaping issues. Based on suggestion by Ivan Shmakov <oneingray@gmail.com> * utils/fakeroot.sh (TARGET): Do not define. (sh): Rather pass PWD and commandline as parameters. * utils/remap.sh: Likewise.
2014-01-20utils: include the mig-generated server headers in fakeauth.cJustus Winter
GNU MIG recently gained support for emitting x_server_routine declarations in the generated server header file. Using this declaration, the x_server_routine functions can be inlined into the demuxer function. * utils/fakeauth.c: Include the mig-generated server headers.
2013-12-16utils/rpctrace: fix output so that replies can be attributed to requestsJustus Winter
Currently, it is impossible to properly attribute response messages to requests. Even though rpctrace is single-threaded, its tracee may not. Or there might be more than one tracee. In any such case it is not guaranteed that the reply message we just processed is for the request we just printed. Fix this by printing ellipsis with the port name, so that reply messages can be properly attributed: task129(pid3312)->mach_port_allocate (3) ...134 task129(pid3312)->mach_port_deallocate (pn{ 1}) ...160 134... = 0 pn{ 30} 160... = 0 * utils/rpctrace.c (last_reply_port): New variable. (print_ellipsis): New function. (print_request_header): Optionally print ellipsis and update last_reply_port. (print_reply_header): Likewise.
2013-12-16utils/rpctrace: escape non-printable characters in stringsJustus Winter
* utils/rpctrace.c (escape_sequences): New char array mapping characters to their escape sequence. (print_data): Escape non-printable characters when printing strings.
2013-12-16utils/rpctrace: handle MACH_MSG_TYPE_PORT_SEND rights in trace_and_forwardJustus Winter
This allows one to rpctrace processes doing select(2). * utils/rpctrace.c (trace_and_forward): Handle MACH_MSG_TYPE_PORT_SEND rights.
2013-12-16utils/rpctrace: generalize tracing codeJustus Winter
Currently, rpctrace dies if a tracee uses select(2) because it asserts that reply_type is a MACH_MSG_TYPE_PORT_SEND_ONCE right. Generalize the code surrounding the failing assertion. * utils/rpctrace.c (trace_and_forward): Generalize code by switching over reply_type.
2013-12-16utils/rpctrace: generalize code in rewrite_rightJustus Winter
* utils/rpctrace.c (rewrite_right): Generalize the code so we can use rewrite_right to rewrite MACH_MSG_TYPE_PORT_SEND rights for non-rpc ports.
2013-12-13utils/mount: fix autodetection of fat file systemsJustus Winter
mount uses libblkid (if available) to detect the file system type when using mount -t auto. libblkid calls fat file systems "vfat", our fat translator is called "fatfs". Fix this discrepancy in mount. * utils/mount.c (do_mount): Fix autodetection of fat file systems.
2013-12-10utils/settrans: fix the teardown of chrooted environmentsJustus Winter
Previously, settrans --chroot would just exec the target. Create a new process for that purpose. Wait for its completion, then ask the translator (nicely by default) to go away. If it refuses with EBUSY, it might be because some process has daemonized inside the chrooted environment. This fixes the following bug when settrans is used with fakeroot: % fakeroot-hurd /bin/true 2>&1 | tee <hangs> Here, fakeroot-hurd execs settrans with --chroot, settrans execs /hurd/fakeauth which will eventually exec the target /bin/true. When true terminates, it will close its stdout and stderr. But /hurd/fakeroot's stderr is also connected to tee's stdin, preventing tee from exiting. * utils/settrans.c (main): Fix the teardown of chrooted environments.
2013-12-04utils: improve the auth_demuxer function in fakeauth.cJustus Winter
Handle multiple request types as recommended by the Mach Server Writer's Guide section 4, subsection "Handling Multiple Request Types". This avoids initializing the reply message in every X_server function. The reply message has already been properly initialized in libports, so there is no need to call mig_reply_setup. * utils/fakeauth.c (auth_demuxer): Improve the demuxer function.
2013-11-21utils: fix dead initializationJustus Winter
Found using the Clang Static Analyzer. * utils/frobauth.c (posix_parse_opt): Fix dead initialization. (no_ugids_parse_opt): Likewise.
2013-11-10utils: implement portinfo --searchJustus Winter
Implement the --search switch of portinfo. The feature was suggested in the source code and partly implemented. portinfo --search locates the target ports (or all ports) in any other process and prints the port mapping and information about the port in the remote process. * utils/Makefile: Link portinfo against libps. * utils/portinfo.c (options): Enable --search option. (search_for_port): New function. (search_for_ports): Likewise. (main): Call search_for_port{,s} as appropiate.
2013-11-09utils: implement settrans --pid-fileJustus Winter
This switch makes settrans write the pid file of the active translator it starts to a file. This makes the pid easily retrievable for test suites. * utils/settrans.c (options): Add --pid-file. (main): Add variable pid_file. (parse_opt): Handle --pid-file switch. (open_node): Write pid file.
2013-09-21Fix spurious port deallocationSamuel Thibault
* utils/storeinfo.c (parse_opt): Do not deallocate `file` port, `store_free` does it already.
2013-09-21Fix sscanf format for c99Samuel Thibault
* utils/rpctrace.c (parse_msgid_list): Use %ms instead of %as in sscanf format.
2013-09-16Add match-options to utils sourcesJustus Winter
* utils/Makefile (SRCS): Add match-options.c
2013-09-10Fix variable namesSamuel Thibault
* utils/Makefile (mount-LDLIBS): Define to libblkid_LIBS instead of libblkid-LIBS (mount-CPPFLAGS): Likewise.
2013-09-09mount: handle -t autoJustus Winter
Use libblkid to detect the filesystem type if "auto" is given as type. Remove the translator localization from main, this is also done in do_mount and any errors are propagated properly. This way "auto" is handled correctly if given on the command line or used as filesystem type in the fstab. * configure.ac: Add check for libblkid. * config.make.in: Make libblkid specific values available. * utils/Makefile: Use libblkid specific values. * utils/mount.c (DEFAULT_FSTYPE): Use "auto" as default type. (do_mount): Detect type using libblkid. (main): Drop translator localization.
2013-08-29Fix buildSamuel Thibault
* utils/umount.c: Do not include useless <blkid/blkid.h>.
2013-08-29Merge branch 'master-merge'Samuel Thibault
2013-08-29umount: add a umount utilityJustus Winter
This adds a umount utility that implements most of the functions that the Linux umount utility provides, especially that subset that is used by the Debian package initscripts. * utils/umount.c: New file.
2013-08-28utils: add nullauth utilityJustus Winter
nullauth drops all authentication credentials and runs the given program. This is also useful to drop privileges on behalf of translators that do not need any credentials in some circumstances, e.g. % settrans -ap /hurd/nullauth -- /hurd/storeio -Tzero makes storeio run without any credentials. * utils/nullauth.c: New file. * utils/Makefile: Build nullauth.
2013-08-28umount: add a umount utilityJustus Winter
This adds a umount utility that implements most of the functions that the Linux umount utility provides, especially that subset that is used by the Debian package initscripts. * utils/umount.c: New file.
2013-08-28mount: ignore mounted filesystems if --all is givenJustus Winter
Linux' mount utility ignores mounted filesystems if mount --all is invoked. This patch makes our mount do the same. utils/mount.c (main): Ignore mounted filesystems if --all is given.
2013-08-28mount: implement -O, --test-optsJustus Winter
--test-opts in combination with --all mounts only those filesystems with options matching the given set of options. Note that the semantic of the inverting "no" prefix differs from --types: While --types=nonfs,ufs means neither nfs nor ufs, --test-opts=nofoo,bar means not foo, but bar. * utils/match-options.h: New file. * utils/match-options.c: Likewise. (test_opts): New variable. (test_opts_len): Likewise. (match_options): New function. * utils/mount.c (parse_opt): Handle -O, --test-opts. (main): Use match_options as filter.
2013-08-28mount: add -f and --fake argumentsJustus Winter
Add -f and --fake arguments. This makes our mount more compatible with Linux mount. * utils/mount.c (argp_opts): Add -f and --fake. (do_mount): Fake the translator startup if --fake is given.
2013-08-28mount: fix mount -oremount with one parameterJustus Winter
This fixes mount -oremount when just given the mountpoint, e. g.: % mount -oremount,ro /tmp * util/mount.c (main): Add a one-argument form for remount.
2013-08-28mount: add -n and --no-mtab argumentsJustus Winter
Add -n and --no-mtab arguments. As we do not write an mtab file, this is a trivial patch that just ignores this argument to be more compatible with Linux mount. * utils/mount.c (argp_opts): Add -n and --no-mtab. (parse_opt): Do nothing on 'n'.
2013-08-25utils: escape arguments in remap.shJustus Winter
remap.sh uses /bin/sh to first change the working directory and then execute the given program in the remap context. But the arguments given on the command line were not properly escaped: % '/bin/sh' '-c' 'echo $0' /bin/sh % remap '/bin/sh' '-c' 'echo $0' <empty line> % remap-fixed '/bin/sh' '-c' 'echo $0' /bin/sh * utils/remap.sh: Escape arguments handed to /bin/sh so that they are not evaluated prematurely.
2013-08-25utils: escape arguments in fakeroot.shJustus Winter
fakeroot.sh uses /bin/sh to first change the working directory and then execute the given program in the fakeroot context. But the arguments given on the command line were not properly escaped: % '/bin/sh' '-c' 'echo $0' /bin/sh % fakeroot-tcp '/bin/sh' '-c' 'echo $0' /bin/sh % fakeroot-hurd '/bin/sh' '-c' 'echo $0' <empty line> % fakeroot-hurd-fixed '/bin/sh' '-c' 'echo $0' /bin/sh * utils/fakeroot.sh: Escape arguments handed to /bin/sh so that they are not evaluated prematurely.
2013-06-02Remove unused variableMiguel Figueiredo
* utils/x.c (main): Remove unused variable.
2013-05-13Revert "utils/vmstat: Use gnumach.defs from gnumach"Samuel Thibault
This reverts commit 202339d49461ce6dcffd3a5b3690537daea5ef38.
2013-05-05utils/vmstat: Use gnumach.defs from gnumachDavid Michael
The gnumach installation provides the include file mach/gnumach.defs instead of mach/gnumach.h. This runs the defs file through MIG and builds the result for vmstat. * utils/vmstat.c: Replace <mach/gnumach.h> with "gnumach_U.h". * utils/Makefile (vmstat): Add rule to depend on gnumach_U.o. * Makeconf (mach_defs_names): Add gnumach.
2013-03-26Fix remap invocationSamuel Thibault
* utils/remap.sh (REMAPPED): Default to empty. (while): Break as soon as there are no arguments any more. Do not break on mapping parameters
2013-03-01rpctrace: implement -EPino Toscano
Add a -E option to rpctrace, much like its strace's equivalent, to add/change/unset environment variables among the ones inherited by the process. Implements the savannah task #9331. * utils/rpctrace.c: Include <envz.h>. (options): Add the 'E' option. (parse_opt) <'E'>: Handle case. Create ENVZ from ENVP, and change it according to ARG. (main): Create CMD_ENVP from ENVZ if not null, or assign ENVP to it. Pass CMD_ENVP to traced_spawn.
2013-02-26Add remap translatorSamuel Thibault
* trans/remap.c: New file. * trans/Makefile (targets): Add remap. (SRCS): Add remap.c. (remap): Add rule. * utils/remap.sh: New script. * utils/Makefile (targets): Add remap. (special-targets): Add remap. (SRCS): Add remap.sh. * NEWS: Advertise new translator