Commit graph

71 commits

Author SHA1 Message Date
sw1tchbl4d3
abab0046ee Add ability to read password from stdin
This can be done by supplying `-` as the first argument.
2022-12-17 00:25:24 +01:00
sw1tchbl4d3
9ce20a62a4 Simplify tty finding process in readpassphrase
This went through a bunch of hoops before to acquire a file descriptor
we already had, this is now ommited.
2022-12-17 00:12:03 +01:00
sw1tchbl4d3
c1acb73270 Merge pull request 'Allow specifying custom installation directory' (#16) from henriquehbr/rdo:custom-destdir into main
Reviewed-on: https://codeberg.org/sw1tchbl4d3/rdo/pulls/16
2022-12-15 17:34:59 +00:00
Henrique Borges
415eab0e6b Allow specifying custom installation directory 2022-12-15 14:10:01 -03:00
sw1tchbl4d3
7ab7f4bd65 Merge pull request 'Add static compilation rule to makefile' (#12) from henriquehbr/rdo:main into main
Reviewed-on: https://codeberg.org/sw1tchbl4d3/rdo/pulls/12
2022-12-04 11:05:53 +00:00
Henrique Borges
30c3a46310 Replace --static flag with -static-pie 2022-12-04 08:03:31 -03:00
Henrique Borges
ac5b102245 Add static compilation rule to makefile 2022-12-03 18:52:46 -03:00
sw1tchbl4d3
46872e4ebd Fix string format, push version 1.4.2 2022-07-28 17:21:52 +02:00
sw1tchbl4d3
fd4ee6a712 Use the correct file descriptor for printing
Before we used printf("\n"); to simulate the enter key the user pressed,
which prints to normal stdout, which could have been redirected.
Now we directly write to the found TTY.

We also close the TTY file descriptor on every code path now.
2022-05-06 08:19:18 +02:00
sw1tchbl4d3
66d15caad4 Bump version to 1.4.1
From now on we will bump the minor version for feature additions, and
the patch version will signify smaller changes.
As we removed the libbsd dependency, I'd like to publish this version.
2022-05-05 08:28:36 +02:00
sw1tchbl4d3
d09a59a77e Add own readpassphrase function
This removes the libbsd dependency.
Fixed #10.
2022-05-05 08:21:48 +02:00
sw1tchbl4d3
c82d7e777e Change HOME to /root on exec
This affected some programs like vim, which put root-owned swap files
into the normal user's swap directory, since $HOME didn't change.

Fixes #11
2022-05-05 07:28:12 +02:00
sw1tchbl4d3
599aa73a8c Update install procedure to new group feature
I knew I forgot it somewhere...
2022-03-08 18:12:42 +01:00
sw1tchbl4d3
6e02a05f10 Update benchmarks
You may wonder why the benchmark times overall increased, on a
seemingly better processor.
That is most likely because the single core performance of the
FX series is worse than the single core performance of the Intel laptop
processor I benchmarked on before.
2022-03-08 18:10:57 +01:00
sw1tchbl4d3
c901cbb6c1 Push version to 1.4
With groups support now added, this warrants a new full release.
2022-03-08 17:35:03 +01:00
sw1tchbl4d3
35232fef05 Add groups support
rdo now supports taking a group name instead of only allowing a single
user.
This also completely removes the user option, as it isn't necessary
anymore with groups support.
2022-03-08 17:32:53 +01:00
sw1tchbl4d3
5404c11700 Rename sleep_ms to sleep_us
The variable name was misleading, as we didn't calculate the time to
sleep in milliseconds, but in microseconds.
2022-03-08 17:03:14 +01:00
sw1tchbl4d3
368026d4b4 Remove unnecessary ruid==0 check
This is not necessary, as we checked it already on line 62.
2022-03-08 16:59:45 +01:00
sw1tchbl4d3
41dfdb321f Remove LSAN from the debug build
For some unknown reason LSAN catches a SIGSEGV (rdo.c:45) when enabled,
but removing it also removes the supposed SIGSEGV it catches.
To repro, build the earlier build with LSAN, and enter a file that
doesnt exist.
As long as I don't know why LSAN thinks this simple error message causes
a segmentation fault, I will remove it.
2022-03-08 16:51:04 +01:00
sw1tchbl4d3
08d66239fa Reduce memory access in runprog
Previously, we used a for loop to rearrange argv to omit the first
argument, the rdo call itself.
It's way smarter to just dereference the first argv argument, and use it
as an argv pointer, to achieve the same result.
2022-03-08 16:42:43 +01:00
sw1tchbl4d3
9395a6ca7e Fix debug build
GCC doesnt want to compile a binary with fortify when optimizations are
disabled, so we move the fortification process into the release flags.
2022-03-08 16:26:18 +01:00
sw1tchbl4d3
cfa1b3b10f Make the hashing failure error message more descriptive
This error occurs when the user we try to hash the password for doesn't
have a password, as seen in #8.

We now mention this, to avoid future confusion.
2022-02-12 08:07:48 +01:00
sw1tchbl4d3
8c0e7560ba Error if euid != 0
This can happen if the rdo binary isn't set up as SUID.
2022-02-09 20:17:45 +01:00
sw1tchbl4d3
a76a602886 Clarify build instructions in README 2022-02-09 20:16:13 +01:00
sw1tchbl4d3
6b6d607ea6 Be more specific with getpwnam() errors
getpwnam() does not populate errno when the user simply doesn't exist,
making err() print "Success" as the error.

We now check for errno == 0, and print a different error message for it.
2022-02-09 20:06:28 +01:00
sw1tchbl4d3
f1b75ffe48 Tighten permissions for the config file 2022-02-09 19:48:32 +01:00
sw1tchbl4d3
97bb40e37b Refactor Makefile
These changes make rdo build on my rpi, probably because this specific
GCC version requires arguments in the order we now supply.

We also disable ASAN in the debug build (for now), as it seems to cause
a segfault on my rpi.
2022-02-09 19:37:43 +01:00
sw1tchbl4d3
1bc833693b Add checks for crypt() and getspnam() failure 2022-02-08 21:09:36 +01:00
sw1tchbl4d3
860f9cbf47 Clear password after we're done using it
Previously, the password would not be cleared after we hashed it with
crypt(), which lead to the password staying in memory for the duration
of program runtime.

This was only really an issue for incorrect passwords, as execve()
purges our memory anyway, but attackers could use an incorrect but
mostly correct password for privilege escalation.

Due to this being a security issue, this commit also introduces rdo
version 1.3.

Fixes #7
2022-02-07 14:37:54 +01:00
sw1tchbl4d3
5d79415618 Add whoami version in README.md 2021-07-29 19:10:36 +02:00
sw1tchbl4d3
1f74a18f4c Add version numbers to benchmarked programs 2021-07-29 18:58:47 +02:00
sw1tchbl4d3
c692d9d9c9 Add benchmarks to the README.md
I myself was astonished by the difference between rdo
and doas, so I felt like including it in the README.
2021-07-29 18:38:33 +02:00
sw1tchbl4d3
5bc96bc7f4 Move variable declerations to start of file 2021-07-29 17:29:38 +02:00
sw1tchbl4d3
a30dffcf5d Add -fsanitize=undefined to Makefile
Now we also check for undefined behaviour in our debug build.
2021-07-29 17:28:17 +02:00
sw1tchbl4d3
b2caacbf68 Avoid unnecessary recursion in ensuredir()
Before we made the ensuredir() function recurse on itself
if we couldn't open /run/rdo, after mkdir()'ing it,
to retry opening the directory.

Now we simplify and add a simple fd = open([...]) directly
after the mkdir(), to avoid the recursion.
If the second open fails, we error out.
2021-07-29 17:25:34 +02:00
sw1tchbl4d3
4ed6a6d75a Fix memory leak in getconf()
As getline() calls malloc() to allocate new memory
for our usage, we have to free() it after.
2021-07-18 23:34:31 +02:00
sw1tchbl4d3
1bb71b46cc Build debug build with fsanitize=leak,address
This option warns us if something leaks memory
or other errors in memory occur.
2021-07-18 23:31:53 +02:00
sw1tchbl4d3
10147b324d Merge pull request 'Command line options' (#6) from remoof/rdo:main into main
Reviewed-on: https://codeberg.org/sw1tchbl4d3/rdo/pulls/6
2021-07-18 23:07:28 +02:00
remoof
f2137dc28d Add version and usage if no arguments are given. 2021-07-18 23:04:45 +02:00
sw1tchbl4d3
7df91d5f0b Merge pull request 'Restructured ensuredir and other small fixes' (#5) from remoof/rdo:main into main
Reviewed-on: https://codeberg.org/sw1tchbl4d3/rdo/pulls/5
2021-07-17 15:58:11 +02:00
remoof
df1cb0d70c Avoid closing on bad file descriptors 2021-07-17 15:54:39 +02:00
remoof
d44301d8fa Close file descriptors earlier 2021-07-17 15:31:18 +02:00
remoof
66e2cb0c42 Restructured ensuredir and other small fixes 2021-07-16 23:55:59 +02:00
sw1tchbl4d3
ea15c5631a Close directory fd + openat -> open 2021-07-16 08:13:59 +02:00
sw1tchbl4d3
5ba40256a0 Fix some more whitespaces...
I should probably switch IDEs
2021-07-16 00:47:53 +02:00
sw1tchbl4d3
6cabebefed Add some explanations for the config to the README 2021-07-16 00:43:18 +02:00
sw1tchbl4d3
95b3581737 Normalize the way we check for errors 2021-07-16 00:38:50 +02:00
sw1tchbl4d3
7f10e354de Fix whitespaces 2021-07-16 00:37:13 +02:00
sw1tchbl4d3
a23bb67985 Null-terminate read data 2021-07-16 00:35:02 +02:00
sw1tchbl4d3
e1147f4c7c Don't multiply session_ttl by 100 2021-07-16 00:15:04 +02:00