Commit Graph

616 Commits

Author SHA1 Message Date
Roberto E. Vargas Caballero a570a80ed1 su: Fix running it without arguments
The commit 8f5a0c3 introduced a regression and the logic
to control the number of arguments was broken after it,
giving an error when su was executed without parameters.
2024-03-07 22:35:31 +01:00
neeshy 4cd0b14380 su: don't set $PATH
Just /bin is too restrictive, and login shells set the path anyway via
the default profile. Also, carrying the path over for non-login shells
conforms to the behavior of util-linux's su.
2024-03-06 10:12:49 +01:00
neeshy e9bcdcc341 su: check $SHELL for validity
If $SHELL isn't defined in the environment, the call to execve will
fail when -p is specified. Fallback to the user's login shell if $SHELL
is invalid.
2024-03-06 10:11:29 +01:00
neeshy cf9e26d7fa su: fix setting argv0
argv0 was being set to the user's login shell even when -p was
specified. Only populate newargv once the shell is properly determined.
2024-03-06 10:11:23 +01:00
neeshy 8f5a0c3236 su: simplify logic
Inline dologin, and simplify common code
2024-03-06 10:11:07 +01:00
Markus Rudy a015607af0 Explicitly include sys/sysmacros.h for makedev etc
This header used to be included by sys/types.h in glibc, and musl
adopted the behaviour. However, this dependency was never desired, so
glibc deprecated it in 2016 and finally removed it in 2019, and so did
musl. Explicitly including the header should be a no-op on older libc
versions and fixes the build on newer versions.

https://sourceware.org/bugzilla/show_bug.cgi?id=19239
https://git.musl-libc.org/cgit/musl/commit/?id=f552c79
2023-09-26 09:22:32 +02:00
Michael Forney 3c88778c6c umount: Fix use of uninitialized variable 2019-03-14 11:42:59 +00:00
Mario Rugiero 140efda3a2 passwd: fix crashes for unencrypted passwords starting with 'x'.
When deciding where the previous hash should come from, is is
assumed that 'x' started strings all mean to look in shadow.
This is probably harmless in practice, since modern Linux still
use only hashes instead of raw passwords.
However, this is more robust, and more importantly, it is more
consistent with the previous check, which explicitly tests for
the string to be "x".
2019-01-30 11:58:55 +00:00
John Regan 4f1b54dd92 passwd: prevent segfault when running as root
When running as root, passwd attempts to compare the new password to
the old password, without having grabbed the old passwd.

This checks if the previous password hash was grabbed before comparing
it against the new password hash.
2019-01-30 11:57:49 +00:00
parazyd 7ffe3cfacc uptime: Fix user/s printing (grammar error) when users == 0.
Signed-off-by: parazyd <parazyd@dyne.org>
2019-01-30 11:25:33 +00:00
sin 604b66ae8b Add blkdiscard(8) 2018-07-02 14:03:57 +01:00
Ioan-Adrian Ratiu 4f5837147a mount: don't call realpath on root target
Musl libc realpath implementation calls readlink on a procfs
path it computes via __procfdname (code at [1] & [2]).

This is problematic if ubase mount is used in a PID 1 because procfs
is not mounted and the kernel passes the rootfs mounted read-only, so
the first step is to read-write remount the rootfs, which can't be
done because procfs is not mounted. Thus we are in a dependency cycle:
procfs can't be mounted because the root is read-only and so on.

To break this cycle, don't call readlink on "/" (it doesn't really make
sense anyway) so the rootfs can be remounted read-write, after which
proc itself can be mounted and the rest of mount calls will succeed
so systems running ubase + musl can succesfully boot into userspace.

[1] https://git.musl-libc.org/cgit/musl/tree/src/misc/realpath.c?h=v1.1.19
[2] https://git.musl-libc.org/cgit/musl/tree/src/internal/procfdname.c?h=v1.1.19

Signed-off-by: Ioan-Adrian Ratiu <adi@adirat.com>
2018-06-30 17:38:07 +01:00
sin 11d2d1faaf Fix segfault in killall5 without -o
Original patch by Platon Ryzhikov <ihummer63@yandex.ru>
2018-06-30 17:31:53 +01:00
Mattias Andrée 2d58716c23 ps: fix argv0 position in usage line
Signed-off-by: Mattias Andrée <maandree@kth.se>
2018-06-30 17:27:45 +01:00
Eric Pruitt 55795531f0 dd: Use sigaction(2) to obviate select(2)
By setting the SIGINT handler with sigaction(2), automatic retries of
the splice(2) syscall can be disabled by not setting SA_RESTART. This
makes it possible to use Ctrl+C even if the "if" operand refers to the
controlling terminal. The SIGINT message has also been moved outside
the signal handler since fprintf(3) is not an async-signal-safe
function.
2017-10-10 16:28:15 +01:00
Michael Forney fae9ca81a2 passwd: Use a random salt when encrypting passwords 2017-08-22 13:36:56 +02:00
Michael Forney 3a5939e810 mount: Don't pass {,no}auto to kernel 2017-08-22 13:36:28 +02:00
Mattias Andrée e3dacbb542 respawn: reopen the fifo at end of line, and use read-only
Signed-off-by: Mattias Andrée <maandree@kth.se>
2016-09-26 09:57:54 +01:00
sin fa7ae96e0f passwd: fix function def style 2016-04-24 17:47:28 +01:00
Mattias Andrée 5b16e8a4eb pwdx: fix off-by-one bug
Signed-off-by: Mattias Andrée <maandree@kth.se>
2016-04-20 23:08:51 +01:00
Mattias Andrée f26a1449bf Add pwdx(1)
Signed-off-by: Mattias Andrée <maandree@kth.se>
2016-04-20 23:08:51 +01:00
Mattias Andrée 28795cffe2 fsfreeze: make it clear the either -f or -u must be specified, not optional
Signed-off-by: Mattias Andrée <maandree@kth.se>
2016-03-26 19:08:10 +00:00
sin 48728b2594 nologin: Sort includes 2016-03-26 19:08:10 +00:00
Mattias Andrée 6e7386edb3 Add nologin(8)
Signed-off-by: Mattias Andrée <maandree@kth.se>
2016-03-26 19:08:10 +00:00
Eivind Uggedal e0dc3f9546 dd: implement conv=notrunc support 2016-03-16 10:17:51 +00:00
Eivind Uggedal 596663c1b1 dd: truncate file when using seek= 2016-03-16 10:17:51 +00:00
Eivind Uggedal e358d74a80 dd: don't let failure to change pipe size affect exit code 2016-03-16 10:17:51 +00:00
Eivind Uggedal c64b5b04c7 dd: allow count=0 2016-03-16 10:17:51 +00:00
Eivind Uggedal e5d88b0f30 dd: remove if= noatime optimization 2016-03-16 10:17:51 +00:00
Eivind Uggedal 05a69d9d0d dd: always create of= even if seek= is used 2016-03-16 10:17:51 +00:00
Lucas Gabriel Vuotto 0e7ab0ca9e arg.h: fixed argv checks order
This prevents accessing to a potentially out-of-bounds memory section.

Signed-off-by: Lucas Gabriel Vuotto <l.vuotto92@gmail.com>
2016-02-22 14:36:21 +00:00
sin ac4fcddd50 df: Don't scream if statvfs() fails 2016-02-16 15:20:10 +00:00
FRIGN 4c33cf2a98 Use estrlcat where possible 2016-02-11 14:36:54 +00:00
Brad Barden 4dbd00fc94 mount: fix mount helper fs option handling
If a mount helper is used, only argopts (given on commandline) are
passed to the helper via -o parameter. Option strings from fstab are
ignored.

This patch replaces global argopts pointer with a character array
fsopts. A maximum length for filesytem options is #defined (used by
fsopts and data), and argument/mntent options are length-checked to fit.
A filesystem with too long an option string will print an error, cause
mount to exit with an error status, and not attempt to mount the
filesystem. This obviates the need for overflow checking of data in
parseopts(), though it hasn't been removed.
2016-02-11 10:16:41 +00:00
Hiltjo Posthuma 4ece17d605 LICENSE: update year and bump to top 2016-02-11 10:16:41 +00:00
izabera 3af0bbd564 fix several problems in dd 2016-01-04 18:07:44 +00:00
sin 4c34f6b100 Update copyright years 2016-01-01 12:20:11 +00:00
sin a8f95b2f9a Use SLIST instead of TAILQ for pidof(8) 2015-10-07 13:57:24 +01:00
sin d3efa66c82 Use SLIST instead of TAILQ for killall5(8)
No need to teardown the list at the end.
2015-10-07 13:57:24 +01:00
FRIGN 3e7e1e9644 Fix fallocate(1) manpage
To be honest, I had a little misunderstanding of the fallocate(1)-
utility.
It turns out that it only adds preallocated space if the length
exceeds the size of an already existing file.
No truncation happens.

Thus, I fixed the wording accordingly.
2015-09-14 10:15:55 +01:00
FRIGN e3b20bbda0 Refactor fallocate(1)
1) Simplify the manpage. Just refer to fallocate(2) and stop trying
   to list supported file systems. This can change and everbody
   with common sense can bring up the relevant manpages of a given
   operating system himself.
   Use the num-semantics.
2) Use estrtonum() instead of estrtol().
3) Allow multiple arguments.
2015-09-14 10:15:55 +01:00
FRIGN 90c7584089 Refactor eject(1)
Reword manpage to be more general (you do not only eject CD-ROM-drives,
but BluRay-drives, floppy drives, LaserDisk-readers, toaster, whatever).

Allow to specify multiple devices in the command line. Doesn't add
LOC (the few more lines added are due to stricter error-checking)
and might become handy for somebody in the future while not
breaking scripts that assume only one argument.

Crying like GNU coreutils when more than one device is given is
not suckless:

$ eject /dev/sr0 /dev/sr1
eject: too many arguments
2015-09-09 23:33:17 +01:00
FRIGN 4c714a9299 Minor newline fix in ctrlaltdel.8 2015-09-07 12:09:59 +01:00
FRIGN 2f766ec92d Add myself to LICENSE 2015-09-07 12:09:59 +01:00
FRIGN 2d38b7cb9e Refactor ctrlaltdel(8)
1) Rewrite the manpage, don't just copy the util-linux manpage.
2) Fix usage() to reflect exclusivity of flags
3) Style changes.
2015-09-07 12:09:59 +01:00
FRIGN 6dedded859 Remove stdlib.h from clear(1)
This is a remnant of the old EXIT_ days we all want to quickly forget...
2015-09-07 11:47:10 +01:00
FRIGN 7b27c7f87c Refactor clear(1)
Adopting best practices(tm) we developed with sbase.
2015-09-07 11:47:10 +01:00
FRIGN b6669b5f19 Refactor chvt(1)
1) Properly implement arg.h.
2) Use estrtonum instead of estrtol.
3) Check close().
4) Small fixes.
5) Update manpage.
2015-09-07 11:47:10 +01:00
FRIGN cdaa7b860e Fix build
Dimitris forgot to change one line, which could, depending on the
environment, break the build ($LD would be empty).
2015-09-07 11:47:10 +01:00
sin 570a2bf4ce Use CC for ubase-box, remove LD 2015-09-03 19:57:21 +01:00