Commit graph

32 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
46872e4ebd Fix string format, push version 1.4.2 2022-07-28 17:21:52 +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
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
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
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
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
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
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
remoof
f2137dc28d Add version and usage if no arguments are given. 2021-07-18 23:04:45 +02:00
sw1tchbl4d3
95b3581737 Normalize the way we check for errors 2021-07-16 00:38:50 +02:00
sw1tchbl4d3
e1147f4c7c Don't multiply session_ttl by 100 2021-07-16 00:15:04 +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
remoof
9948bd3fc7 Check uid before opening file 2021-07-15 15:43:06 +02:00
remoof
a657d0c2f5 Removed extra whitespace 2021-07-15 12:46:27 +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
f63e1b660a First Commit 2021-07-13 21:33:12 +02:00