aboutsummaryrefslogtreecommitdiff
path: root/utils
Commit message (Collapse)AuthorAgeFilesLines
* Modernize code by removing use of old style definitions.Flavio Cruz2023-04-034-6/+6
| | | | | Also add -Werror=old-style-definition to enforce new code. Message-Id: <ZBZ+8xf7GHy2RT/h@jupiter.tail36e24.ts.net>
* Avoid variable length array with size zeroSamuel Thibault2023-02-021-1/+1
|
* utils: Fix calling multi-line macroSamuel Thibault2023-01-011-1/+3
|
* vmstat: Support 64bit memory sizeSamuel Thibault2023-01-011-2/+2
|
* settrans: Fix checking len being negativeSamuel Thibault2023-01-011-1/+1
|
* pids: Fix pointer arithmeticSamuel Thibault2023-01-011-1/+1
|
* nonsugid: Fix memleakSamuel Thibault2023-01-011-0/+5
|
* Fix *printf specifier for user space mach ports.Flavio Cruz2022-12-061-6/+6
| | | | | mach_port_t are mach_port_name_t and thus require %u instead of %lu. Message-Id: <Y42RELMbulK4xaKM@reue>
* Remove the concept of process ownerSergey Bugaev2022-08-101-0/+1
| | | | | | | | | | Now that it's completely unused. procinfo.owner is now simply set to the first UID that a process has. proc_setowner () is kept for compatibility, but now does nothing. The clients still try to call it, though, for compatibility with older proc server versions.
* mount: Avoid appending empty options to empty mntoptsSamuel Thibault2022-02-201-1/+2
| | | | argz_append does not actually support this.
* mount: Fix deleting noauto/bind optionSamuel Thibault2022-02-201-2/+11
| | | | | After deleting an option, we have to let the loop continue from there instead of skipping another option.
* Silence warningSamuel Thibault2022-02-121-1/+1
| | | | | | | Since gcc doesn't seem to discover that underlying is not used uninitialized. * utils/mount.c (do_mount): Initialize underlying to MACH_PORT_NULL.
* Fix warningSamuel Thibault2022-02-121-1/+1
| | | | | * utils/msgport.c (cmd_umask): Use int instead of mode_t for umask, since msg_get_init_int takes an int*.
* Pass mach_task_self when deallocating INIT_PORT_CWDIRFlavio Cruz2022-01-171-1/+1
| | | | Message-Id: <YeXBjT8t777b8+AF@viriathus>
* Make RPC input array parameters constSamuel Thibault2022-01-161-5/+5
| | | | | This follows mig's cf4bcc3f1435 ("Also add const qualifiers on server side")
* login: More port leaks fixesSamuel Thibault2022-01-041-2/+9
| | | | | | ports[INIT_PORT_CRDIR] and [INIT_PORT_CWDIR] were obtained from getcrdir() and getcwdir(), so a referenced needs to be released when replacing them.
* Fix leaking auth portsSamuel Thibault2022-01-044-9/+34
| | | | | | | | | | | We need to be extremely careful with auth ports since leaking them into subprocesses may expose a root-auth port to non-root processes. Notably, get_nonsugid_ids was caching it, thus preventing glibc's exec implementation from dropping it. Login is also reimplementing hurdexec but without all the cloexec logic. This commit fixes various auth leaks.
* Fix build warningsSamuel Thibault2022-01-011-0/+1
| | | | No actual behavior change.
* utils/ps.c: Don't limit output width to 80 on non-ttySergey Bugaev2021-05-181-0/+5
| | | | | | | | If no output width limit has been set explicitly, and we're not printing to a tty, do not limit output width. In particular, this fixes grepping ps output. Message-Id: <20210518122150.1490468-1-bugaevc@gmail.com>
* settrans: get rid of translator that couldn't be attachedSergey Bugaev2021-05-081-1/+5
| | | | | * utils/settrans.c (main): When file_set_translator fails, make the just-started translator go away.
* libps: support getting RPC names for WAIT outputSamuel Thibault2020-11-233-22/+42
| | | | | | | | | | | * libps/Makefile (SRCS): Add ../utils/msgids.c. (../utils/msgids-CPPFLAGS): Add DATADIR macro. * libps/spec.c: Include "../utils/msgids.h". (get_rpc_name): Implement with msgid_info. * utils/msgids.c (parse_opt): Move end code to ... (msgids_scan_std): ... new function. * utils/msgids.h (msgids_scan_std): New prototype. * utils/ps.c (main): Call msgids_scan_std.
* Fix build with -fno-commonSamuel Thibault2020-03-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | which will be the default in gcc-10. * acpi/acpifs.h (fs, acpifs_maptime): Add extern qualifier. * boot/private.h (verbose): Likewise. * eth-multiplexer/netfs_impl.h (multiplexer_maptime): Likewise. * eth-multiplexer/vdev.h (port_bucket, vdev_portclass): Likewise. * exec/priv.h (port_bucket, execboot_portclass): Likewise. * ext2fs/ext2fs.h (sblock, sblock_dirty, block_size, log2_block_size, log2_dev_blocks_per_fs_block, log2_stat_blocks_per_fs_block, zeroblock, frag_size, frags_per_block, inodes_per_block, itb_per_group, db_per_group, desc_per_block, addr_per_block, groups_count, node_to_page_lock, generation_lock, next_generation, group_desc_image, global_pokel, modified_global_blocks, use_xattr_translator_records): Likewise. * hostmux/hostmux.h (hostmux_maptime): Likewise. * isofs/isofs.h (host_name, mounted_on, disk_image, disk_image_len, logical_block_size, sblock): Likewise. * libdiskfs/diskfs.h (diskfs_shortcut_symlink, diskfs_shortcut_chrdev, diskfs_shortcut_blkdev, diskfs_shortcut_fifo, diskfs_shortcut_ifsock, diskfs_create_symlink_hook, diskfs_read_symlink_hook): Likewise. * libnetfs/callbacks.h (_netfs_translator_callback1, _netfs_translator_callback2): Likewise. * libnetfs/priv.h (netfs_mtime): Likewise. * libpager/priv.h (_pager_class): Likewise. * libtrivfs/trivfs.h (trivfs_check_access_hook, trivfs_check_open_hook, trivfs_open_hook, trivfs_protid_create_hook, trivfs_peropen_create_hook, trivfs_protid_destroy_hook, trivfs_peropen_destroy_hook, trivfs_getroot_hook): Likewise. * lwip/lwip-hurd.h (lwip_bucket, socketport_class, addrport_class, shutdown_notify_class, lwip_protid_portclasses, lwip_cntl_portclasses, lwip_bootstrap_portclass, fsys_identity, lwipcntl, lwip_owner, lwip_group): Likewise. * lwip/port/include/netif/hurdtunif.h (tunnel_cntlclass, tunnel_class): Likewise. * nfs/nfs.h (main_udp_socket, hostname, mapped_time): Likewise. * nfsd/nfsd.h (mapped_time, authserver): Likewise. * pci-arbiter/pcifs.h (fs, pcifs_maptime): Likewise. * pci-arbiter/startup.h (pci_shutdown_notify_class, arrange_shutdown_notification): Likewise. * pfinet/pfinet.h (pfinet_bucket, addrport_class, socketport_class, fsys_identity, pfinetctl, pfinet_owner, pfinet_group): Likewise. * pflocal/sserver.h (sock_port_bucket): Likewise. * proc/proc.h (authserver, self_proc, init_proc, startup_proc, proc_bucket, proc_class, generic_port_class, exc_class, generic_port, kernel_proc, global_lock): Likewise. * term/term.h (termstate, termflags, global_lock, carrier_alert, select_alert, pty_select_alert, term_bucket, tty_cntl_class, tty_class, cttyid_class, pty_class, pty_cntl_class, termctl, ptyctl, inputq, rawq, outputq, remote_input_mode, external_processing, term_owner, term_group, term_mode, bottom): Likewise. * usermux/usermux.h (usermux_maptime): Likewise. * utils/msgids.h (msgid_argp): Likewise. * libdiskfs/priv.h (_diskfs_mtime): Remove definition. * lwip/options.h (lwip_argp): Add prototype. * mach-defpager/priv.h (partitions): Name structure. (all_partitions): Add extern qualifier. * acpi/main.c (acpifs_maptime, fs): New variables. * exec/main.c (port_bucket, execboot_portclass): Likewise. * ext2fs/ext2fs.c (sblock, sblock_dirty, block_size, log2_block_size, log2_dev_blocks_per_fs_block, log2_stat_blocks_per_fs_block, frag_size, frags_per_block, inodes_per_block, itb_per_group, db_per_group, desc_per_block, addr_per_block, groups_count, next_generation, group_desc_image, global_pokel, use_xattr_translator_records): Likewise. * isofs/main.c (host_name, mounted_on, logical_block_size, sblock): Likewise. * libpager/pager-create.c (_pager_class): Likewise. * lwip/port/netif/hurdtunif.c (tunnel_cntlclass, tunnel_class): Likewise. * mach-defpager/default_pager.c (all_partitions): Likewise. * nfs/main.c (main_udp_socket, hostname, mapped_time): Likewise. * nfsd/main.c (mapped_time, authserver): Likewise. * pci-arbiter/main.c (fs, pcifs_maptime): Likewise. * pci-arbiter/startup.c (*pci_shutdown_notify_class): Likewise. * pfinet/main.c (pfinetctl, pfinet_owner, pfinet_group, pfinet_bucket, addrport_class, socketport_class, fsys_identity): Likewise. * proc/main.c (authserver, self_proc, init_proc, startup_proc, proc_bucket, proc_class, generic_port_class, exc_class, generic_port, kernel_proc, global_lock): Likewise. * term/main.c (termstate, termflags, global_lock, carrier_alert, select_alert, pty_select_alert, term_bucket, tty_cntl_class, tty_class, cttyid_class, pty_class, pty_cntl_class, termctl, ptyctl, outputq, remote_input_mode, external_processing, term_owner, term_group, term_mode, bottom): Likewise. * usermux/usermux.c (usermux_mapped_time): Rename to usermux_maptime. * lwip/main.c: Include "options.h". (lwip_argp, netif_list): Remove declarations. (lwip_bucket, socketport_class, addrport_class, shutdown_notify_class, lwip_cntl_portclasses, lwip_bootstrap_portclass, lwip_owner, lwip_group, fsys_identity, lwipcntl): New variables. * eth-multiplexer/multiplexer.c (multiplexer_maptime): Add variable. * hostmux/hostmux.c (hostmux_mapped_time): Rename variable to hostmux_maptime * libdiskfs/extra-version.c: Rename file to... * libdiskfs/priv.c: ... new file. (diskfs_shortcut_symlink, diskfs_shortcut_chrdev, diskfs_shortcut_blkdev, diskfs_shortcut_fifo, diskfs_shortcut_ifsock, diskfs_create_symlink_hook, diskfs_read_symlink_hook): Add weak variables. * libdiskfs/Makefile (OTHERSRCS): Replace extra-version.c with priv.c. * libtrivfs/priv.c: New file. * libtrivfs/Makefile (OTHERSRCS): Add priv.c * libcons/extra-version.c: Rename file to... * libcons/priv.c: ... new file. * libcons/Makefile (SRCS): Replace extra-version.c with priv.c. Fix build with #
* Make libcrypt really optionalSamuel Thibault2019-11-171-3/+3
| | | | | | | * configure.ac (--without-libcrypt): Add option. Only test for libcrypt if it is not set. * utils/Makefile (login-LDLIBS, addauth-LDLIBS, setauth-LDLIBS): Only add -lcrypt when libcrypt is available.
* login: Set non-insecure default umaskSamuel Thibault2019-11-111-1/+1
| | | | * utils/login.c (default_args): Set UMASK to 022.
* Fix password checking with as-needed linkingSamuel Thibault2019-09-011-1/+6
| | | | | | | | | | | | | | | Newer gcc toolchains tend to enable as-needed by default, so runtime detection of libcrypt will fail. We can just explicitly link against libcrypt anyway. * configure.ac: Check for `crypt()' in libcrypt. * config.make.in: Substitute HAVE_LIBCRYPT. * libshouldbeinlibc/idvec-verify.c: Include <crypt.h> only when libcrypt is available. Replace weak reference with explicit call and fallback macro. * utils/x.c: Likewise. * libshouldbeinlibc/Makefile (LDLIBS): Add -lcrypt when libcrypt is available.
* Fix warningsSamuel Thibault2018-03-058-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * libdiskfs/boot-start.c (diskfs_start_bootstrap): Fix printf format. * libfshelp/delegate.c: Include <alloca.h> and <stdlib.h>. * libfshelp/start-translator-long.c: Include <stdlib.h>. * libshouldbeinlibc/ugids-verify-auth.c (server_verify_make_auth): Fix prototypes for password_check_group and password_check_user. * libstore/argp.c: Include <stdlib.h>. * libstore/task.c: Include <stdlib.h>. * exec/exec.c: Include <mach/vm_param.h>. * libbpf/bpf_impl.c: Include <stdlib.h>. * proc/info.c (S_proc_getloginpids): Remove local variables leader_task and leader_sub. * proc/main.c (main): Remove local variable original_argv. * boot/boot.c (task_died, S_mach_notify_new_task): Fix printf format. * exec/elfcore.c: Include <alloca.h> and <mach/vm_param.h>. * trans/crash.c: Include <hurd/msg.h>. * trans/random.c: Include <signal.h>. * utils/login.c: Include <signal.h>. * utils/id.c: Include <hurd/msg.h>. * utils/devprobe.c: Include <stdlib.h>. * utils/addauth.c: Include <hurd/msg.h>. * utils/frobauth-mod.c: Include <hurd/msg.h>. * utils/storeread.c: Include <stdlib.h>. * utils/msgport.c: Include <hurd/msg.h>. * sutils/clookup.c (file_name_lookup_carefully): Fix lookup function prototype, make head and tail const. * utils/rpcscan.c: Include <stdlib.h>. * sutils/bless.c: Include <stdlib.h>. * fstests/fstests.c: Include <stdlib.h>. * startup/startup.c (argz_task_insert_right): Fix printf format. * init/init.c: Include <stdlib.h>.
* Add missing lib in linkSamuel Thibault2018-02-111-1/+2
| | | | * Makefile (rpcscan): Depend on ../libshouldbeinlibc/libshouldbeinlibc.a.
* Fix warningsSamuel Thibault2018-01-281-4/+4
| | | | | * utils/nullauth.c (argp_program_version, options, doc[], args_doc): Drop duplicate const qualifier.
* rpctrace: Pass prefixed_name to _hurd_exec_paths.Kalle Olavi Niemitalo2018-01-081-2/+5
| | | | | | | | | | | | | | | | | | | | | This fixes the following test case: mkdir testy echo '#! /bin/bash' > testy/prog echo 'printf "%s\n" "$0"' >> testy/prog chmod +x testy/prog PATH=$(pwd)/testy /bin/rpctrace -E PATH=/usr/bin:/bin -o /dev/null prog Before this patch, the output is: /bin/bash: prog: No such file or directory After this patch, the output is similar to: /home/kalle/testy/prog * utils/rpctrace.c (traced_spawn): Get prefixed_name from file_name_path_lookup and pass it to _hurd_exec_paths.
* Use the new _hurd_exec_file_name functionEmilio Pozuelo Monfort2018-01-083-5/+17
| | | | | | | | | * configure.in: Check for _hurd_exec_paths. * utils/fakeauth.c: Call _hurd_exec_paths instead of _hurd_exec if it's available. * utils/shd.c: Likewise. * utils/rpctrace.c: Get prefixed_name from file_name_path_lookup and pass it to _hurd_exec_paths instead of calling _hurd_exec.
* Add a file_exec_file_name RPCEmilio Pozuelo Monfort2018-01-081-7/+18
| | | | | | | | | | | | | | | | | | | | | | * 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.
* Make devprobe able to talk with userland driversSamuel Thibault2017-11-071-0/+13
| | | | | | | * utils/devprobe.c: Include <fcntl.h> (options): Add "master-device" ('M') option. (main): Handle 'M' option by opening the given filename for `device_master'.
* Use our own variant of 'assert' and 'assert_perror'.Justus Winter2017-08-058-53/+55
| | | | | Our variants print stack traces on failures. This will make locating errors much easier.
* Fix harmless indentation errors tripping [-Wmisleading-indentation].Justus Winter2017-08-051-3/+3
| | | | | * trans/new-fifo.c (main): Fix indentation. * utils/rpctrace.c (discover_receive_right): Likewise.
* Fix typoBrent W. Baccala2016-10-291-1/+1
| | | | * utils/rpctrace.c: Fix typo.
* Avoid fatal error handling in option parsers.Justus Winter2016-10-051-1/+4
| | | | | | | * trans/crash.c (parse_opt): Avoid 'error' in favor of the appropriate argp error reporting mechanism. * trans/remap.c (parse_opt): Likewise. * utils/msgids.c (parse_opt): Likewise.
* fakeroot: set FAKED_MODESamuel Thibault2016-09-171-0/+3
| | | | * utils/fakeroot.sh (FAKED_MODE): Set to unknown-is-root.
* rpctrace: Print beyond '\0' in MACH_MSG_TYPE_CHAR.Kalle Olavi Niemitalo2016-08-231-1/+2
| | | | | | | | | | | | | | | | This will now display the 'argv: data_t' argument of file_exec as e.g. "who\0am\0i\0" rather than just "who". In contrast, the 'file_name: string_t' argument of dir_lookup will still be truncated at the first null character. The previous implementation might crash if an out-of-line char array exactly fills a page and does not contain any null characters. * utils/rpctrace.c (print_data): On MACH_MSG_TYPE_STRING and MACH_MSG_TYPE_CHAR, check for end of buffer before checking for a null character. On MACH_MSG_TYPE_CHAR only, continue printing past null characters.
* utils/settrans: implement active translator stackingJustus Winter2016-05-191-1/+20
| | | | | | | | * utils/settrans.c (OPT_STACK): New macro. (options): New option. (main): Handle new option. (open_node): Use different flags for the lookup of the underlying node.
* utils/settrans: add option to specify the underlying nodeJustus Winter2016-04-171-1/+22
| | | | | | * utils/settrans.c (options): Add '--underlying'. (main): Handle new option. (open_node): Open the node if given.
* utils/settrans: get an authenticated root node in chroot modeJustus Winter2016-04-171-1/+44
| | | | | | | | * utils/settrans.c (get_credentials): New function. (main): Get an authenticated root node for the process we are chrooting. Signed-off-by: Justus Winter <justus@gnupg.org>
* utils/fakeauth: fix invocation of programs from PATHJustus Winter2016-03-071-1/+1
| | | | | * utils/fakeauth.c (main): Replace the right element of the argument vector. This fixes running scripts from PATH using fakeroot.
* utils/mount: start translators with stderr closedJustus Winter2016-02-221-3/+30
| | | | | | | Apparently some users of 'mount' do not cope with any output being generated from the spawned translator. * utils/mount.c (do_mount): Start translators with stderr closed.
* utils/vmallocate: new utilityJustus Winter2016-02-132-1/+273
| | | | | * utils/Makefile (targets): Add 'vmallocate'. * utils/vmallocate.c: New file.
* utils/settrans: improve --chroot functionalityJustus Winter2016-02-054-20/+47
| | | | | | | | | | | | | | | | | Add an option '--chroot-chdir' to settrans and make it chdir to this directory before executing the target program. Also, look up the executable in PATH. With these changes we no longer need to use the shell inside the chroot in the convenience scripts, and hence do not require it to be installed inside the chroot. * utils/fakeroot.sh: Simplify using the new option. * utils/remap.sh: Likewise. * utils/settrans.c (OPT_CHROOT_CHDIR): New constant. (options): New option 'chroot-chdir'. (main): Handle new option. Search for target executable in PATH. * utils/fakeauth.c (main): Likewise.
* Add missing libraries to fix link errorsFlavio Cruz2015-12-301-3/+4
| | | | | | | | | | | | | | This fixes several linking problems I had in my recent cross-compilation of the Hurd. I added missing static libraries and also organized some of the targets for more concise rules. * console-client/Makefile: Add libiohelp.a and libihash.a. * daemons/Makefile: Add libihash.a and libshouldbeinlibc.a. * devnode/Makefile: Add iohelp and ihash to HURDLIBS. * random/Makefile: Likewise. * trans/Makefile: Reorder targets alphabetically and add libiohelp.a and libihash.a. * utils/Makefile: Add libihash.a.
* fix compiler warnings in hurd/utilsFlavio Cruz2015-12-296-34/+42
| | | | | | | | | | | | | | | | | | utils: Fix compiler warnings. * utils/rpcscan.c (setup_extract_target): Remove name variable. * utils/rpcscan.c (setup_extract_target): Fix bad initializer. * utils/rpctrace.c (new_send_wrapper, wrap_all_threads, wrap_new_thread, wrap_new_task, traced_spawn): Fix format strings. * utils/rpctrace.c (trace_and_forward): Cast to unsigned int. * utils/rpctrace.c (trace_and_forward): Use memcmp instead of pointer dereferencing to compare structures. * utils/rpctrace.c (wrap_all_threads): Cast to vm_address_t. * utils/rpctrace.c (main): Fix bad initializer. * utils/shd.c (run): Initialize save0. * utils/vminfo.c: Fix format strings. * utils/vmstat.c: Remove PSEP macro and expand the code. * utils/w.c (add_utmp_procs): Remove unused pos variable.
* umount: Do not report errors on making the device go awaySamuel Thibault2015-09-091-0/+2
| | | | | | | | This fixes umounting bind mounts or other mounts for which the device can not be made away. * utils/umount.c (do_umount): When the --force option is not passed, ignore errors from file_set_translator call on the device file.
* utils/rpcscan: new utilityJustus Winter2015-06-302-3/+407
| | | | | * utils/rpcscan.c: New file. * utils/Makefile: Add `rpcscan'.
* utils: split-off the message id parsingJustus Winter2015-06-304-197/+298
| | | | | | | * utils/rpctrace.c: Move all the code handling the message id files... * utils/msgids.c: ... to a new file. * utils/msgids.h: And add the relevand declarations. * utils/Makefile (SRCS): Add the new file.