summaryrefslogtreecommitdiff
path: root/utils
AgeCommit message (Collapse)Author
2023-05-21Remove an unused includeSergey Bugaev
Message-Id: <20230518165719.90745-2-bugaevc@gmail.com>
2023-05-10Style tweaksSergey Bugaev
Message-Id: <20230508213136.608575-42-bugaevc@gmail.com>
2023-05-10utils: Avoid warnings about prototype mismatchSergey Bugaev
Message-Id: <20230508213136.608575-16-bugaevc@gmail.com>
2023-05-10utils: Port to x86_64Sergey Bugaev
Message-Id: <20230508213136.608575-15-bugaevc@gmail.com>
2023-05-04Use designated initializers when building mach_msg_type_tFlavio Cruz
Message-Id: <ZFLcIs0iwiC9kQDf@jupiter.tail36e24.ts.net>
2023-04-24Improve portability for rpctrace on x86_64Flavio Cruz
Defined alignment as __alignof__(uintptr_t) to match MiG. Also used char* instead of void* during the message iteration since it's more portable as pointer arithmetic on void* is a GNU extension. Message-Id: <ZEYMUWHf/2VH2KlD@jupiter.tail36e24.ts.net>
2023-04-18utils/msgport.c: Add cmd_report_waitSergey Bugaev
This exposes msg_report_wait. For example: $ msgport --report-wait --pid $$ 26997: 2 threads 26997: thread 0: proc_wait_request [init#3] 26997: thread 1: msgport Message-Id: <20230418104915.12301-1-bugaevc@gmail.com>
2023-04-08Further modernize Hurd code by enforcing strict prototypes and no implicit ↵Flavio Cruz
function declarations. Most of the changes land in one of these buckets: * Removed unused declarations. * Used (void) to represent no parameters instead of () which means an undeterminate number of parameters. * Included missing header files whenever necessary (stdlib.h, sys/mman.h, etc) * Typedefed function pointers to be able to fully declare the parameter types. * Added declarations of library functions that are used elsewhere (example is libps/ps.h). * Made functions static whenever they are only used in that file. * Forwarded declarations of some methods that were made static. Message-Id: <ZDD1o7/tVYeZew+G@jupiter.tail36e24.ts.net>
2023-04-07Use default pager MiG stubs from Hurd instead of gnumachFlavio Cruz
Hurd code relies on gnumach default_pager.defs headers when making calls using the default pager RPC. Those stubs were checked in back in the 90s and are essentially unused because gnumach does not implement or use that interface. Instead use the Hurd interface directly. This is safe since the Hurd stubs are a super set of the gnumach stubs. Later, we won't need to install the gnumach stubs anymore through glibc. Message-Id: <ZC5WqPKfCCiE8D29@jupiter.tail36e24.ts.net>
2023-04-03Modernize code by removing use of old style definitions.Flavio Cruz
Also add -Werror=old-style-definition to enforce new code. Message-Id: <ZBZ+8xf7GHy2RT/h@jupiter.tail36e24.ts.net>
2023-02-02Avoid variable length array with size zeroSamuel Thibault
2023-01-01utils: Fix calling multi-line macroSamuel Thibault
2023-01-01vmstat: Support 64bit memory sizeSamuel Thibault
2023-01-01settrans: Fix checking len being negativeSamuel Thibault
2023-01-01pids: Fix pointer arithmeticSamuel Thibault
2023-01-01nonsugid: Fix memleakSamuel Thibault
2022-12-06Fix *printf specifier for user space mach ports.Flavio Cruz
mach_port_t are mach_port_name_t and thus require %u instead of %lu. Message-Id: <Y42RELMbulK4xaKM@reue>
2022-08-10Remove the concept of process ownerSergey Bugaev
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.
2022-02-20mount: Avoid appending empty options to empty mntoptsSamuel Thibault
argz_append does not actually support this.
2022-02-20mount: Fix deleting noauto/bind optionSamuel Thibault
After deleting an option, we have to let the loop continue from there instead of skipping another option.
2022-02-12Silence warningSamuel Thibault
Since gcc doesn't seem to discover that underlying is not used uninitialized. * utils/mount.c (do_mount): Initialize underlying to MACH_PORT_NULL.
2022-02-12Fix warningSamuel Thibault
* utils/msgport.c (cmd_umask): Use int instead of mode_t for umask, since msg_get_init_int takes an int*.
2022-01-17Pass mach_task_self when deallocating INIT_PORT_CWDIRFlavio Cruz
Message-Id: <YeXBjT8t777b8+AF@viriathus>
2022-01-16Make RPC input array parameters constSamuel Thibault
This follows mig's cf4bcc3f1435 ("Also add const qualifiers on server side")
2022-01-04login: More port leaks fixesSamuel Thibault
ports[INIT_PORT_CRDIR] and [INIT_PORT_CWDIR] were obtained from getcrdir() and getcwdir(), so a referenced needs to be released when replacing them.
2022-01-04Fix leaking auth portsSamuel Thibault
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.
2022-01-01Fix build warningsSamuel Thibault
No actual behavior change.
2021-05-18utils/ps.c: Don't limit output width to 80 on non-ttySergey Bugaev
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>
2021-05-08settrans: get rid of translator that couldn't be attachedSergey Bugaev
* utils/settrans.c (main): When file_set_translator fails, make the just-started translator go away.
2020-11-23libps: support getting RPC names for WAIT outputSamuel Thibault
* 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.
2020-03-31Fix build with -fno-commonSamuel Thibault
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 #
2019-11-17Make libcrypt really optionalSamuel Thibault
* 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.
2019-11-11login: Set non-insecure default umaskSamuel Thibault
* utils/login.c (default_args): Set UMASK to 022.
2019-09-01Fix password checking with as-needed linkingSamuel Thibault
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.
2018-03-05Fix warningsSamuel Thibault
* 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>.
2018-02-11Add missing lib in linkSamuel Thibault
* Makefile (rpcscan): Depend on ../libshouldbeinlibc/libshouldbeinlibc.a.
2018-01-28Fix warningsSamuel Thibault
* utils/nullauth.c (argp_program_version, options, doc[], args_doc): Drop duplicate const qualifier.
2018-01-08rpctrace: Pass prefixed_name to _hurd_exec_paths.Kalle Olavi Niemitalo
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.
2018-01-08Use the new _hurd_exec_file_name functionEmilio Pozuelo Monfort
* 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.
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-11-07Make devprobe able to talk with userland driversSamuel Thibault
* utils/devprobe.c: Include <fcntl.h> (options): Add "master-device" ('M') option. (main): Handle 'M' option by opening the given filename for `device_master'.
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-08-05Fix harmless indentation errors tripping [-Wmisleading-indentation].Justus Winter
* trans/new-fifo.c (main): Fix indentation. * utils/rpctrace.c (discover_receive_right): Likewise.
2016-10-29Fix typoBrent W. Baccala
* utils/rpctrace.c: Fix typo.
2016-10-05Avoid fatal error handling in option parsers.Justus Winter
* 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.
2016-09-17fakeroot: set FAKED_MODESamuel Thibault
* utils/fakeroot.sh (FAKED_MODE): Set to unknown-is-root.
2016-08-23rpctrace: Print beyond '\0' in MACH_MSG_TYPE_CHAR.Kalle Olavi Niemitalo
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.
2016-05-19utils/settrans: implement active translator stackingJustus Winter
* 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.
2016-04-17utils/settrans: add option to specify the underlying nodeJustus Winter
* utils/settrans.c (options): Add '--underlying'. (main): Handle new option. (open_node): Open the node if given.
2016-04-17utils/settrans: get an authenticated root node in chroot modeJustus Winter
* 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>