all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Liliana Marie Prikler <liliana.prikler@gmail.com>
To: 63508@debbugs.gnu.org
Cc: felix.lechner@lease-up.com
Subject: [bug#63508] [PATCH] gnu: udev: Allow EUDEV_RULES_DIRECTORY to shadow built-in rules.
Date: Mon, 15 May 2023 21:11:54 +0200	[thread overview]
Message-ID: <06ea6673ca13ed6bc7fb00336dafc7a3457412ee.1684178049.git.liliana.prikler@gmail.com> (raw)
In-Reply-To: <cover.1684100044.git.felix.lechner@lease-up.com>

* gnu/packages/patches/eudev-rules-directory.patch (rules_dirs):
Move placeholder to the start of the array.
(rules_dirs_real): New procedure.
(udev_rules_dirs_new, udev_rules_check_timestamp): Adjust accordingly.
---
Hi Felix,

Am Sonntag, dem 14.05.2023 um 21:56 -0700 schrieb Felix Lechner:
> > I don't see how this change allows users *or upstream package
> > maintainers* to continue using onboard names as they have done for
> > ages and as they would want to continue to do.
> 
> I have one of those cards. While the interface name did not change
> when I fiddled with the PCI configuration, I am not sure that
> prioritizing ID_NET_NAME_ONBOARD over ID_NET_NAME_MAC is a reasonable
> default for Guix.
> 
> To rank ID_NET_NAME_ONBOARD below ID_NET_NAME_MAC would not address
> the shortcoming you perceived because the latter always exists.
> 
> Instead, I think people wishing to use ID_NET_NAME_ONBOARD should
> install a custom udev script (and those should be recognized by the
> udevadm we ship).
I think the current default is probably fine for more users than the
proposed change (ain't no one got the time to type their MAC addresses).

I do however see your point in that udev should let you choose to prefer
ID_NET_NAME_MAC over the other rules.  Now, the shortcoming here
actually lies with our incomplete support for EUDEV_RULES_DIRECTORY,
see the patch :)

> For Guix, I think we would like to see ID_NET_NAME_MAC at the top.
Now, I respectully disagree on that proposition, but am here to fix the
original bug of udev not honouring your preference.  With the following
patch your udev-rule-service should be able to override the default
behaviour.  If not, try matching the file name.  There shouldn't be any
weird predicates on the name, but if there are, that's how we'll find
out.

Cheers

 .../patches/eudev-rules-directory.patch       | 44 ++++++++++++++++---
 1 file changed, 37 insertions(+), 7 deletions(-)

diff --git a/gnu/packages/patches/eudev-rules-directory.patch b/gnu/packages/patches/eudev-rules-directory.patch
index 54fc01c6d5..7cc3f97451 100644
--- a/gnu/packages/patches/eudev-rules-directory.patch
+++ b/gnu/packages/patches/eudev-rules-directory.patch
@@ -4,14 +4,17 @@ The old udev 182 supported $UDEV_CONFIG_FILE, which in turn allowed
 the search path to be customized, but eudev no longer has this, hence
 this hack.
 
---- eudev-3.1.5/src/udev/udev-rules.c	2015-10-13 06:22:14.000000000 +0800
-+++ eudev-3.1.5/src/udev/udev-rules.c	2015-10-16 20:45:38.491934336 +0800
-@@ -47,15 +47,11 @@
+Index: eudev/src/udev/udev-rules.c
+===================================================================
+--- eudev.orig/src/udev/udev-rules.c
++++ eudev/src/udev/udev-rules.c
+@@ -48,15 +48,11 @@ struct uid_gid {
          };
  };
  
 -static const char* const rules_dirs[] = {
 +static const char* rules_dirs[] = {
++        NULL,			/* placeholder for $EUDEV_RULES_DIRECTORY */
          UDEV_CONF_DIR "/rules.d",
          UDEV_RULES_DIR,
 -        UDEV_ROOT_RUN "/udev/rules.d",
@@ -20,17 +23,44 @@ this hack.
 -        "/lib/udev/rules.d",
 -        "/usr/lib/udev/rules.d",
 -#endif
-+        NULL,			/* placeholder for $EUDEV_RULES_DIRECTORY */
          NULL};
  
  struct udev_rules {
-@@ -1704,6 +1700,9 @@
+@@ -1691,6 +1687,14 @@ static int parse_file(struct udev_rules
+         return 0;
+ }
+ 
++static const char** rules_dirs_real()
++{
++        if (rules_dirs[0])
++                return rules_dirs;
++        else
++                return rules_dirs + 1;
++}
++
+ struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names) {
+         struct udev_rules *rules;
+         struct udev_list file_list;
+@@ -1717,7 +1721,10 @@ struct udev_rules *udev_rules_new(struct
  
          udev_rules_check_timestamp(rules);
  
+-        r = conf_files_list_strv(&files, ".rules", NULL, rules_dirs);
 +        /* Allow the user to specify an additional rules directory.  */
-+        rules_dirs[3] = getenv("EUDEV_RULES_DIRECTORY");
++        rules_dirs[0] = getenv("EUDEV_RULES_DIRECTORY");
 +
-         r = conf_files_list_strv(&files, ".rules", NULL, rules_dirs);
++        r = conf_files_list_strv(&files, ".rules", NULL, rules_dirs_real ());
          if (r < 0) {
                  log_error_errno(r, "failed to enumerate rules files: %m");
+                 return udev_rules_unref(rules);
+@@ -1776,7 +1783,9 @@ bool udev_rules_check_timestamp(struct u
+         if (!rules)
+                 return false;
+ 
+-        return paths_check_timestamp(rules_dirs, &rules->dirs_ts_usec, true);
++        return paths_check_timestamp(rules_dirs_real (),
++                                     &rules->dirs_ts_usec,
++                                     true);
+ }
+ 
+ static int match_key(struct udev_rules *rules, struct token *token, const char *val) {

base-commit: 28bfc5cd081458313fa8601133386209b23deb12
-- 
2.40.1





  parent reply	other threads:[~2023-05-15 19:26 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-14 21:41 [bug#63508] [PATCH 0/3] Use MAC-based names for network interfaces Felix Lechner via Guix-patches via
2023-05-14 21:42 ` [bug#63508] [PATCH 1/3] gnu: eudev: Convert native-inputs to new style Felix Lechner via Guix-patches via
2023-05-14 21:42 ` [bug#63508] [PATCH 2/3] gnu: eudev: Convert build arguments to gexps Felix Lechner via Guix-patches via
2023-05-14 21:42 ` [bug#63508] [PATCH 3/3] gnu: eudev: Always use MAC-based names for network interfaces Felix Lechner via Guix-patches via
2023-05-15  4:31   ` Liliana Marie Prikler
2023-05-15  4:56     ` Felix Lechner via Guix-patches via
2023-05-15 19:11 ` Liliana Marie Prikler [this message]
2023-05-18  0:52 ` [bug#63508] [PATCH v2 1/4] gnu: eudev: Convert native-inputs to new style Felix Lechner via Guix-patches via
2023-05-18  0:52   ` [bug#63508] [PATCH v2 2/4] gnu: eudev: Convert build arguments to gexps Felix Lechner via Guix-patches via
2023-05-18  4:12     ` Liliana Marie Prikler
2023-05-18  0:52   ` [bug#63508] [PATCH v2 3/4] gnu: eudev: Use new project URL Felix Lechner via Guix-patches via
2023-05-18  0:52   ` [bug#63508] [PATCH v2 4/4] gnu: eudev: Have udevadm look in /etc/udev/rules.d. (Closes: #63508) Felix Lechner via Guix-patches via
2023-05-18  4:19     ` Liliana Marie Prikler
2023-05-28 23:23       ` Felix Lechner via Guix-patches via
2023-05-29  8:29         ` Liliana Marie Prikler
2023-05-28 23:28 ` [bug#63508] [PATCH v3 1/3] gnu: eudev: Convert native-inputs to new style, and build arguments to Gexps Felix Lechner via Guix-patches via
2023-05-28 23:28   ` [bug#63508] [PATCH v3 2/3] gnu: eudev: Use new project URL Felix Lechner via Guix-patches via
2023-05-29  7:49     ` Liliana Marie Prikler
2023-05-28 23:28   ` [bug#63508] [PATCH v3 3/3] gnu: eudev: Have udevadm look in /etc/udev/rules.d. (Closes: #63508) Felix Lechner via Guix-patches via
2023-05-29  7:38     ` Liliana Marie Prikler
2023-05-29  7:40   ` [bug#63508] [PATCH v3 1/3] gnu: eudev: Convert native-inputs to new style, and build arguments to Gexps Liliana Marie Prikler
2023-05-29 16:57 ` [bug#63508] [PATCH v4 1/2] gnu: eudev: Use new project URL for Git repo and home page Felix Lechner via Guix-patches via
2023-05-29 16:57   ` [bug#63508] [PATCH v4 2/2] gnu: eudev: Have udevadm look in /etc/udev/rules.d. (Closes: #63508) Felix Lechner via Guix-patches via
2023-05-29 20:28     ` Bruno Victal
2023-05-29 21:06       ` Felix Lechner via Guix-patches via

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=06ea6673ca13ed6bc7fb00336dafc7a3457412ee.1684178049.git.liliana.prikler@gmail.com \
    --to=liliana.prikler@gmail.com \
    --cc=63508@debbugs.gnu.org \
    --cc=felix.lechner@lease-up.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.