From: Kay Sievers <kay.sievers@vrfy.org>
To: linux-hotplug@vger.kernel.org
Subject: Re: [PATCH] set default owner/group in db.
Date: Sat, 17 Jan 2004 15:12:42 +0000 [thread overview]
Message-ID: <20040117151242.GB20465@vrfy.org> (raw)
In-Reply-To: <32230000.1074291692@w-hlinder>
[-- Attachment #1: Type: text/plain, Size: 802 bytes --]
On Fri, Jan 16, 2004 at 05:33:23PM -0800, Hanna Linder wrote:
> --On Friday, January 16, 2004 05:10:15 PM -0800 Hanna Linder <hannal@us.ibm.com> wrote:
>
> > Good idea. This patch will now allow the admin to either set the default
> > owner and group in /etc/udev/udev.conf or it will default to root/root.
> > Greg, you can change udev.conf to set default_owner and default_group now.
> Oops. Here is a patch that will apply cleanly. Updated Documentation patch
> will do on Monday.
Hanna,
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'
thanks,
Kay
[-- Attachment #2: 01-default-owner.patch --]
[-- Type: text/plain, Size: 4932 bytes --]
diff -Nru a/etc/udev/udev.conf.in b/etc/udev/udev.conf.in
--- a/etc/udev/udev.conf.in Sat Jan 17 15:39:00 2004
+++ b/etc/udev/udev.conf.in Sat Jan 17 15:39:00 2004
@@ -17,7 +17,15 @@
# 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"
diff -Nru a/namedev.c b/namedev.c
--- a/namedev.c Sat Jan 17 15:39:00 2004
+++ b/namedev.c Sat Jan 17 15:39:00 2004
@@ -141,7 +141,7 @@
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 @@
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);
}
diff -Nru a/udev-add.c b/udev-add.c
--- a/udev-add.c Sat Jan 17 15:39:00 2004
+++ b/udev-add.c Sat Jan 17 15:39:00 2004
@@ -155,29 +155,29 @@
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 @@
}
/* create symlink if requested */
- if (*dev->symlink) {
+ if (dev->symlink[0]) {
symlinks = dev->symlink;
while (1) {
linkname = strsep(&symlinks, " ");
diff -Nru a/udev.8 b/udev.8
--- a/udev.8 Sat Jan 17 15:39:00 2004
+++ b/udev.8 Sat Jan 17 15:39:00 2004
@@ -98,6 +98,16 @@
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 @@
# 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 -Nru a/udev.h b/udev.h
--- a/udev.h Sat Jan 17 15:39:00 2004
+++ b/udev.h Sat Jan 17 15:39:00 2004
@@ -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_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];
diff -Nru a/udev_config.c b/udev_config.c
--- a/udev_config.c Sat Jan 17 15:39:00 2004
+++ b/udev_config.c Sat Jan 17 15:39:00 2004
@@ -45,7 +45,7 @@
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];
next prev parent reply other threads:[~2004-01-17 15:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-01-16 22:21 [PATCH] set default owner/group in db Hanna Linder
2004-01-16 22:51 ` Greg KH
2004-01-17 1:10 ` Hanna Linder
2004-01-17 1:33 ` Hanna Linder
2004-01-17 15:12 ` Kay Sievers [this message]
2004-01-19 18:41 ` Hanna Linder
2004-01-19 19:44 ` Greg KH
2004-01-19 19:45 ` Greg KH
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=20040117151242.GB20465@vrfy.org \
--to=kay.sievers@vrfy.org \
--cc=linux-hotplug@vger.kernel.org \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).