Closed raboof closed 1 year ago
This has security implications: it executes more code as root. In particular, with this patch, files are opened as root.
ah, using pam here, indeed I didn't notice this is the case for the shadow backend :thinking:
OK, so:
Perhaps we could have the forked process look for the --debug flag itself, ignoring any other flags and the config file? Somewhat inconsistent and not very DRY, but possibly acceptable since '--debug' is a somewhat 'special' diagnostic flag anyway? WDYT?
Yeah that sounds reasonable!
Hm, unfortunately this is not quite enough. swayidle -- --debug
for instance processes --debug
as an argument, not an option.
Can we use getopt
to parse --debug
?
Can we use
getopt
to parse--debug
?
updated
We need to reset optind = 1
to allow getopt
to be called multiple times.
Hm, we need to reset optind = 1
between the two getopt
loops, ie. after the log_init
call.
We need to reset
optind = 1
to allowgetopt
to be called multiple times.
Gotcha! Can confirm this indeed makes cases where --debug
isn't the first parameter work :laughing: . Apologies for not testing sufficiently...
Hm, we need to reset
optind = 1
between the twogetopt
loops, ie. after thelog_init
call.
That was already the case (parse_options
set optind = 1
before entering the loop that calls getopt_long
). TBH this is pretty surprising API to me, but also setting optind = 1
before entering the loop in log_init
as well did improve behavior :thinking:
Thanks for the thorough review!
To make sure the pw backend picks up the loglevel when passing
--debug
.