Commit graph

12 commits

Author SHA1 Message Date
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
5bc96bc7f4 Move variable declerations to start of file 2021-07-29 17:29:38 +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
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
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
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