</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>--load-credentials</option></term>
+ <listitem>
+ <para>When specified, the following credentials are used when passed in:</para>
+
+ <variablelist>
+ <varlistentry>
+ <term><varname>udev.conf.*</varname></term>
+ <listitem>
+ <para>These credentials should contain valid
+ <citerefentry><refentrytitle>udev.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>
+ configuration data. From each matching credential a separate file is created. Example: a
+ passed credential <filename>udev.conf.50-foobar</filename> will be copied into a
+ configuration file <filename>/run/udev/udev.conf.d/50-foobar.conf</filename>.</para>
+
+ <xi:include href="version-info.xml" xpointer="v256"/>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><varname>udev.rules.*</varname></term>
+ <listitem>
+ <para>These credentials should contain valid
+ <citerefentry><refentrytitle>udev</refentrytitle><manvolnum>7</manvolnum></citerefentry>
+ rules. From each matching credential a separate file is created. Example: a passed credential
+ <filename>udev.rules.50-foobar</filename> will be copied into a configuration file
+ <filename>/run/udev/rules.d/50-foobar.rules</filename>.</para>
+
+ <xi:include href="version-info.xml" xpointer="v256"/>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+
+ <para>Note, this <emphasis>does not</emphasis> imply <option>--reload</option> option. So, if
+ <command>systemd-udevd</command> is already running, please consider to also specify
+ <option>-reload</option> to make the copied udev rules files used by
+ <command>systemd-udevd</command>.</para>
+
+ <xi:include href="version-info.xml" xpointer="v256"/>
+ </listitem>
+ </varlistentry>
+
<xi:include href="standard-options.xml" xpointer="help" />
</variablelist>
</refsect2>
#include <string.h>
#include <unistd.h>
+#include "creds-util.h"
#include "parse-util.h"
#include "process-util.h"
#include "static-destruct.h"
static int arg_max_children = -1;
static int arg_log_level = -1;
static int arg_start_exec_queue = -1;
+static bool arg_load_credentials = false;
STATIC_DESTRUCTOR_REGISTER(arg_env, strv_freep);
" -p --property=KEY=VALUE Set a global property for all events\n"
" -m --children-max=N Maximum number of children\n"
" --ping Wait for udev to respond to a ping message\n"
- " -t --timeout=SECONDS Maximum time to block for a reply\n",
+ " -t --timeout=SECONDS Maximum time to block for a reply\n"
+ " --load-credentials Load udev rules from credentials\n",
program_invocation_short_name);
return 0;
static int parse_argv(int argc, char *argv[]) {
enum {
ARG_PING = 0x100,
+ ARG_LOAD_CREDENTIALS,
};
static const struct option options[] = {
- { "exit", no_argument, NULL, 'e' },
- { "log-level", required_argument, NULL, 'l' },
- { "log-priority", required_argument, NULL, 'l' }, /* for backward compatibility */
- { "stop-exec-queue", no_argument, NULL, 's' },
- { "start-exec-queue", no_argument, NULL, 'S' },
- { "reload", no_argument, NULL, 'R' },
- { "reload-rules", no_argument, NULL, 'R' }, /* alias for -R */
- { "property", required_argument, NULL, 'p' },
- { "env", required_argument, NULL, 'p' }, /* alias for -p */
- { "children-max", required_argument, NULL, 'm' },
- { "ping", no_argument, NULL, ARG_PING },
- { "timeout", required_argument, NULL, 't' },
- { "version", no_argument, NULL, 'V' },
- { "help", no_argument, NULL, 'h' },
+ { "exit", no_argument, NULL, 'e' },
+ { "log-level", required_argument, NULL, 'l' },
+ { "log-priority", required_argument, NULL, 'l' }, /* for backward compatibility */
+ { "stop-exec-queue", no_argument, NULL, 's' },
+ { "start-exec-queue", no_argument, NULL, 'S' },
+ { "reload", no_argument, NULL, 'R' },
+ { "reload-rules", no_argument, NULL, 'R' }, /* alias for -R */
+ { "property", required_argument, NULL, 'p' },
+ { "env", required_argument, NULL, 'p' }, /* alias for -p */
+ { "children-max", required_argument, NULL, 'm' },
+ { "ping", no_argument, NULL, ARG_PING },
+ { "timeout", required_argument, NULL, 't' },
+ { "load-credentials", no_argument, NULL, ARG_LOAD_CREDENTIALS },
+ { "version", no_argument, NULL, 'V' },
+ { "help", no_argument, NULL, 'h' },
{}
};
return log_error_errno(r, "Failed to parse timeout value '%s': %m", optarg);
break;
+ case ARG_LOAD_CREDENTIALS:
+ arg_load_credentials = true;
+ break;
+
case 'V':
return print_version();
assert_not_reached();
}
- if (!arg_has_control_commands())
+ if (!arg_has_control_commands() && !arg_load_credentials)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"No control command option is specified.");
if (r <= 0)
return r;
+ if (arg_load_credentials) {
+ static const PickUpCredential table[] = {
+ { "udev.conf.", "/run/udev/udev.conf.d/", ".conf" },
+ { "udev.rules.", "/run/udev/rules.d/", ".rules" },
+ };
+ r = pick_up_credentials(table, ELEMENTSOF(table));
+ if (r < 0)
+ return r;
+ }
+
if (arg_has_control_commands()) {
r = send_control_commands();
if (r < 0)