udev: also allow resolve_names= to be specified in udev.conf

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2018-11-13 11:33:32 +01:00
parent bc768f0475
commit a14e7af162
5 changed files with 31 additions and 5 deletions

View File

@ -87,6 +87,19 @@
</listitem>
</varlistentry>
<varlistentry>
<term><varname>resolve_names=</varname></term>
<listitem>
<para>Specifes when systemd-udevd should resolve names of users and groups. When set to
<option>early</option> (the default), names will be resolved when the rules are parsed.
When set to <option>late</option>, names will be resolved for every event. When set to
<option>never</option>, names will never be resolved and all devices will be owned by
root.</para>
<para>This is the same as the <option>--resolve-names=</option> option.</para>
</listitem>
</varlistentry>
</variablelist>
<para>

View File

@ -23,9 +23,10 @@ DEFINE_STRING_TABLE_LOOKUP(resolve_name_timing, ResolveNameTiming);
int udev_parse_config_full(
unsigned *ret_children_max,
usec_t *ret_exec_delay_usec,
usec_t *ret_event_timeout_usec) {
usec_t *ret_event_timeout_usec,
ResolveNameTiming *ret_resolve_name_timing) {
_cleanup_free_ char *log_val = NULL, *children_max = NULL, *exec_delay = NULL, *event_timeout = NULL;
_cleanup_free_ char *log_val = NULL, *children_max = NULL, *exec_delay = NULL, *event_timeout = NULL, *resolve_names = NULL;
int r;
r = parse_env_file(NULL, "/etc/udev/udev.conf", NEWLINE,
@ -78,5 +79,15 @@ int udev_parse_config_full(
log_notice_errno(r, "/etc/udev/udev.conf: failed to set parse event_timeout=%s, ignoring: %m", event_timeout);
}
if (ret_resolve_name_timing && resolve_names) {
ResolveNameTiming t;
t = resolve_name_timing_from_string(resolve_names);
if (t < 0)
log_notice("/etc/udev/udev.conf: failed to set parse resolve_names=%s, ignoring.", resolve_names);
else
*ret_resolve_name_timing = t;
}
return 0;
}

View File

@ -17,8 +17,9 @@ const char *resolve_name_timing_to_string(ResolveNameTiming i) _const_;
int udev_parse_config_full(
unsigned *ret_children_max,
usec_t *ret_exec_delay_usec,
usec_t *ret_event_timeout_usec);
usec_t *ret_event_timeout_usec,
ResolveNameTiming *ret_resolve_name_timing);
static inline int udev_parse_config(void) {
return udev_parse_config_full(NULL, NULL, NULL);
return udev_parse_config_full(NULL, NULL, NULL, NULL);
}

View File

@ -7,3 +7,4 @@
#children_max=
#exec_delay=
#event_timeout=180
#resolve_names=early

View File

@ -1703,7 +1703,7 @@ int main(int argc, char *argv[]) {
int r;
log_set_target(LOG_TARGET_AUTO);
udev_parse_config_full(&arg_children_max, &arg_exec_delay_usec, &arg_event_timeout_usec);
udev_parse_config_full(&arg_children_max, &arg_exec_delay_usec, &arg_event_timeout_usec, &arg_resolve_name_timing);
log_parse_environment();
log_open();