Commit graph

47 commits

Author SHA1 Message Date
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
sw1tchbl4d3
c80be89ef9 Remove debug printf & use strlen() at write
In sessions.h, now line 95, we used sizeof(ts_str) to
determine how much to write, but as ts_str can be longer
than the actual string written, it wrote random data
after the actual timestamp.
2021-07-16 00:12:12 +02:00
sw1tchbl4d3
24638bc999 Add sessions feature
This is by far the heaviest feature of rdo, justifying
its own file for its 140loc.

It creates sessions, inspired by the way doas does it.
We use the /run/rdo temporary folder to store files in the
format of /run/rdo/pid-ts, pid being the PID of the process
that executed rdo, and ts being the timestamp at which said
process started.

As no 2 processes can have the exact same PID and startup time
(startup time is measured in the milliseconds), this seems secure.

Closes #4.
2021-07-15 23:47:27 +02:00
sw1tchbl4d3
2f4ff0812a Move type declerations to start of main 2021-07-15 16:17:54 +02:00
sw1tchbl4d3
225e6b0d6b Merge pull request 'Small fixes' (#3) from remoof/rdo:patch2 into main
Reviewed-on: https://codeberg.org/sw1tchbl4d3/rdo/pulls/3
2021-07-15 15:51:13 +02:00
remoof
9948bd3fc7 Check uid before opening file 2021-07-15 15:43:06 +02:00
sw1tchbl4d3
c5469393ab Merge pull request 'Add dependencies and fixed whitespace' (#2) from remoof/rdo:patch into main
Reviewed-on: https://codeberg.org/sw1tchbl4d3/rdo/pulls/2
2021-07-15 14:54:15 +02:00
remoof
a9fcfe3be9 Changed dependencies to list format 2021-07-15 14:45:21 +02:00
remoof
a657d0c2f5 Removed extra whitespace 2021-07-15 12:46:27 +02:00
remoof
f443a37f12 Add dependencies 2021-07-15 12:44:44 +02:00
sw1tchbl4d3
567899b1a1 Add AUR badge and instructions in README.md 2021-07-14 15:13:36 +02:00
sw1tchbl4d3
5443db5502 Various Makefile additions
We now have a normal and a debug build, both of which
have full RELRO, appropriate handling of warnings and
the default build has D_FORTIFY_SOURCE set to 2.
2021-07-14 06:13:34 +02:00
sw1tchbl4d3
61ebaafd0a Check return values of setuid() and setgid() 2021-07-14 06:12:50 +02:00
sw1tchbl4d3
9fa1190f7d Add sleep between wrong password attempts
This is required for #1
2021-07-13 23:42:11 +02:00
sw1tchbl4d3
a12c72a26a Add error message for faulty config 2021-07-13 23:31:23 +02:00
sw1tchbl4d3
f5bfafe269 Add config for rdo
This is needed for #1.
2021-07-13 23:21:34 +02:00
sw1tchbl4d3
3e4ffde3a4 Fix formatting in rdo.c 2021-07-13 22:46:57 +02:00
sw1tchbl4d3
604f5e7fdd Improve error messages
This commit makes rdo make use of the err.h header
for more pleasant and convenient error logging.
2021-07-13 22:39:28 +02:00
sw1tchbl4d3
336221e5e2 Get passphrase from TTY
This is required for #1.
2021-07-13 22:23:27 +02:00
sw1tchbl4d3
dcd1e4061c Fix various formatting mistakes in rdo.c 2021-07-13 22:14:46 +02:00
sw1tchbl4d3
16ab33147d Remove obsolete reference to Github 2021-07-13 21:34:38 +02:00
sw1tchbl4d3
f63e1b660a First Commit 2021-07-13 21:33:12 +02:00