chiark / gitweb /
[PATCH] set default owner/group in db - update
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>
Tue, 20 Jan 2004 03:44:24 +0000 (19:44 -0800)
committerGreg KH <gregkh@suse.de>
Wed, 27 Apr 2005 04:13:17 +0000 (21:13 -0700)
I've edited the man page today, so this is alreay included :)

Also a few more trivials:
  o added the defaults to udev.conf.in
  o removed class_dev from get_default_mode(), to match with Hanna's
  o changed size of mode_str to MODE_SIZE
  o changed a few char compares from from 0x00 to '\0'

etc/udev/udev.conf.in
namedev.c
udev-add.c
udev.8
udev.h
udev_config.c

index d06b0b06989774d3299df08d349f348d15587662..f9a60ab3c8886b122d85d56e4aacc40fc4dde3c1 100644 (file)
@@ -17,7 +17,15 @@ udev_rules="/etc/udev/udev.rules"
 # udev_permissions - The name and location of the udev permission file
 udev_permissions="/etc/udev/udev.permissions"
 
-# default_mode - set the default mode for all nodes that have no 
+# default_mode - set the default mode for all nodes that have no
 #                explicit match in the permissions file
 default_mode="0600"
 
+# default_owner - set the default owner for all nodes that have no
+#                 explicit match in the permissions file
+default_owner="root"
+
+# default_group - set the default group for all nodes that have no
+#                 explicit match in the permissions file
+default_group="root"
+
index e39207e6a7c58dc63ef5a5c8a9ad9abfa1ea3a6b..7fd69f7778954332ab2075232fa98b7297b58001 100644 (file)
--- a/namedev.c
+++ b/namedev.c
@@ -141,7 +141,7 @@ static struct perm_device *find_perm(char *name)
        return NULL;
 }
 
-static mode_t get_default_mode(struct sysfs_class_device *class_dev)
+static mode_t get_default_mode(void)
 {
        mode_t mode = 0600;     /* default to owner rw only */
 
@@ -735,7 +735,7 @@ done:
                strfieldcpy(udev->group, perm->group);
        } else {
                /* no matching perms found :( */
-               udev->mode = get_default_mode(class_dev);
+               udev->mode = get_default_mode();
                strncpy(udev->owner, get_default_owner(), OWNER_SIZE);
                strncpy(udev->group, get_default_group(), GROUP_SIZE);
        }
index 9aa8bdb3e91bb113edda18917ceef50a624424d4..586911acc2956bc368e1fc30190bc8c9604c735d 100644 (file)
@@ -155,29 +155,29 @@ static int create_node(struct udevice *dev)
                dbg("chmod(%s, %#o) failed with error '%s'",
                    filename, dev->mode, strerror(errno));
 
-       if (*dev->owner) {
+       if (dev->owner[0]) {
                char *endptr;
                unsigned long id = strtoul(dev->owner, &endptr, 10);
-               if (*endptr == 0x00)
+               if (endptr[0] == '\0')
                        uid = (uid_t) id;
                else {
                        struct passwd *pw = getpwnam(dev->owner);
-                       if (!pw)
-                               dbg("user unknown '%s'", dev->owner);
+                       if (pw == NULL)
+                               dbg("specified user unknown '%s'", dev->owner);
                        else
                                uid = pw->pw_uid;
                }
        }
 
-       if (*dev->group) {
+       if (dev->group[0]) {
                char *endptr;
                unsigned long id = strtoul(dev->group, &endptr, 10);
-               if (*endptr == 0x00)
+               if (endptr[0] == '\0')
                        gid = (gid_t) id;
                else {
                        struct group *gr = getgrnam(dev->group);
-                       if (!gr)
-                               dbg("group unknown '%s'", dev->group);
+                       if (gr == NULL)
+                               dbg("specified group unknown '%s'", dev->group);
                        else
                                gid = gr->gr_gid;
                }
@@ -192,7 +192,7 @@ static int create_node(struct udevice *dev)
        }
 
        /* create symlink if requested */
-       if (*dev->symlink) {
+       if (dev->symlink[0]) {
                symlinks = dev->symlink;
                while (1) {
                        linkname = strsep(&symlinks, " ");
diff --git a/udev.8 b/udev.8
index ff89e435ffa31866d362168fc6fc125e206af235..9a597276c6fd00165c431523ca779bcb31f3733a 100644 (file)
--- a/udev.8
+++ b/udev.8
@@ -98,6 +98,16 @@ This is the location of the udev permission file.  The default value for this is
 This is the default mode for all nodes that have no explicit match in the
 permissions file.  The default value for this is
 .I 0666
+.TP
+.B default_owner
+This is the default owner for all nodes that have no explicit match in the
+permissions file.  The default value for this is
+.I root
+.TP
+.B default_group
+This is the default group for all nodes that have no explicit match in the
+permissions file.  The default value for this is
+.I root
 .br
 .P
 .RI "A sample " udev.conf " might look like this:
@@ -118,6 +128,14 @@ udev_permissions="/etc/udev/udev.permissions"
 # default_mode - set the default mode for all nodes that have no
 #                explicit match in the permissions file
 default_mode="0666"
+
+# default_owner - set the default owner for all nodes that have no
+#                 explicit match in the permissions file
+default_owner="root"
+
+# default_group - set the default group for all nodes that have no
+#                 explicit match in the permissions file
+default_group="root"
 .fi
 .P
 The rules for udev to use when naming devices may specified at
diff --git a/udev.h b/udev.h
index 963f8d2516d7c5c29656319bbc9bef7bd05c7f05..e5c983a212c1eb84c6ef6c3e778c29e1dc44bc1b 100644 (file)
--- a/udev.h
+++ b/udev.h
@@ -31,6 +31,7 @@
 #define NAME_SIZE      100
 #define OWNER_SIZE     30
 #define GROUP_SIZE     30
+#define MODE_SIZE      8
 
 struct udevice {
        char name[NAME_SIZE];
@@ -67,7 +68,7 @@ extern char udev_db_filename[PATH_MAX+NAME_MAX];
 extern char udev_permissions_filename[PATH_MAX+NAME_MAX];
 extern char udev_config_filename[PATH_MAX+NAME_MAX];
 extern char udev_rules_filename[PATH_MAX+NAME_MAX];
-extern char default_mode_str[NAME_MAX];
+extern char default_mode_str[MODE_SIZE];
 extern char default_owner_str[OWNER_SIZE];
 extern char default_group_str[GROUP_SIZE];
 
index d262f2af07112e8845d18f97de12819c598f4dee..e75ee3a3468995290d7bf2142c47833604422466 100644 (file)
@@ -45,7 +45,7 @@ char udev_db_filename[PATH_MAX+NAME_MAX];
 char udev_permissions_filename[PATH_MAX+NAME_MAX];
 char udev_rules_filename[PATH_MAX+NAME_MAX];
 char udev_config_filename[PATH_MAX+NAME_MAX];
-char default_mode_str[NAME_MAX];
+char default_mode_str[MODE_SIZE];
 char default_owner_str[OWNER_SIZE];
 char default_group_str[GROUP_SIZE];