set default owner/group in db.
PATCH 1/1 set default owner/group in db.
This patch fixes a bug where the udev database stored empty strings for Owner and Group if they were default. This patch stores the default value into the database if not set otherwise. See example output:
crw------- 1 root root 4, 65 Jan 16 11:13 ttyS1
P: /class/tty/ttyS1
N: ttyS1
S:
O: root
G: root
This is a bit of a hack. However, until udev supports setting the o/g values they will be root/root anyway so the database might as well reflect the truth instead of empty strings.
Hanna
----
# This is a BitKeeper generated diff -Nru style patch. #
# ChangeSet
# 2004/01/16 15:17:20-08:00 hlinder@w-hlinder2.(none)
# set o/g defaults until udev supports setting them.
#
# namedev.c
# 2004/01/16 15:17:19-08:00 hlinder@w-hlinder2.(none) +3 -2
# Set o/g defaults.
#
diff -Nru a/namedev.c b/namedev.c
--- a/namedev.c Fri Jan 16 15:18:18 2004
+++ b/namedev.c Fri Jan 16 15:18:18 2004
@@ -720,8 +720,9 @@
} else {
/* no matching perms found :( */
udev->mode = get_default_mode(class_dev);
- udev->owner[0] = 0x00;
- udev->group[0] = 0x00;
+ /* HACK until udev sets the owner and group */
+ strncpy(udev->owner, "root", sizeof(udev->owner));
+ strncpy(udev->group, "root", sizeof(udev->group));
}
dbg("name, '%s' is going to have owner='%s', group='%s', mode = %#o",
udev->name, udev->owner, udev->group, udev->mode);-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 14 lines · Hanna Linder
This patch fixes a bug where the udev database stored empty strings for Owner and Group if they were default. This patch stores the default value into the database if not set otherwise. See example output:
crw------- 1 root root 4, 65 Jan 16 11:13 ttyS1
P: /class/tty/ttyS1
N: ttyS1
S:
O: root
G: root
Quoted 3 lines
This is a bit of a hack. However, until udev supports setting the o/g values they will be root/root anyway so the database might as well reflect the truth instead of empty strings.
Hm, in thinking about this some more, how about just adding support for a default owner and default group to the main udev.config file? Then your patch here would turn into something like:
Quoted 4 lines
diff -Nru
a/namedev.cb/namedev.c
namedev.c line 727
Quoted 10 lines
namedev.c +2
-2@@ -720,8 +720,8 @@ }else {/* no matching perms found :( */ udev->mode =get_default_mode (class_dev); - udev->owner[0 ] =0x00 ; - udev->group[0 ] =0x00 ; + udev->owner[0 ] =get_default_owner (class_dev); + udev->group[0 ] =get_default_group (class_dev); }dbg ("name, '%s' is going to have owner='%s', group='%s', mode = %#o" , udev->name, udev->owner, udev->group, udev->mode);
That way the owner and group would end up in the database properly.
thanks,
greg k-h
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 15 lines · --On Friday, January 16, 2004 02:51:00 PM -0800 Greg KH <[email protected]> wrote:
Quoted 14 lines · Hanna Linder
This patch fixes a bug where the udev database stored empty strings for Owner and Group if they were default. This patch stores the default value into the database if not set otherwise. See example output:
crw------- 1 root root 4, 65 Jan 16 11:13 ttyS1
P: /class/tty/ttyS1
N: ttyS1
S:
O: root
G: root
Quoted 6 lines
Quoted 3 lines
This is a bit of a hack. However, until udev supports setting the o/g values they will be root/root anyway so the database might as well reflect the truth instead of empty strings.
Hm, in thinking about this some more, how about just adding support for a default owner and default group to the main udev.config file? Then
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.
Hanna
----
=== namedev.c 1.93 vs edited ==--- 1.93/namedev.c Fri Jan 16 15:17:19 2004
+++ edited/namedev.c Fri Jan 16 18:17:57 2004
@@ -151,6 +151,22 @@
return mode;
}
+static char * get_default_owner(void)
+{
+ if (strlen(default_owner_str) = 0) {
+ strncpy(default_owner_str, "root", OWNER_SIZE);
+ }
+ return default_owner_str;
+}
+
+static char * get_default_group(void)
+{
+ if (strlen(default_group_str) = 0) {
+ strncpy(default_group_str, "root", GROUP_SIZE);
+ }
+ return default_group_str;
+}
+
static void apply_format(struct udevice *udev, unsigned char *string) {
char temp[NAME_SIZE];
@@ -720,9 +736,8 @@
} else {
/* no matching perms found :( */
udev->mode = get_default_mode(class_dev);
- /* HACK until udev sets the owner and group */
- strncpy(udev->owner, "root", sizeof(udev->owner));
- strncpy(udev->group, "root", sizeof(udev->group));
+ strncpy(udev->owner, get_default_owner(), OWNER_SIZE);
+ strncpy(udev->group, get_default_group(), GROUP_SIZE);
}
dbg("name, '%s' is going to have owner='%s', group='%s', mode = %#o",
udev->name, udev->owner, udev->group, udev->mode);
=== udev.h 1.32 vs edited ==--- 1.32/udev.h Thu Jan 15 07:22:25 2004
+++ edited/udev.h Fri Jan 16 18:15:57 2004
@@ -68,5 +68,7 @@
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_owner_str[OWNER_SIZE];
+extern char default_group_str[GROUP_SIZE];
#endif
=== udev_config.c 1.4 vs edited ==--- 1.4/udev_config.c Thu Jan 15 07:22:25 2004
+++ edited/udev_config.c Fri Jan 16 18:10:13 2004
@@ -46,6 +46,8 @@
char udev_rules_filename[PATH_MAX+NAME_MAX];
char udev_config_filename[PATH_MAX+NAME_MAX];
char default_mode_str[NAME_MAX];
+char default_owner_str[OWNER_SIZE];
+char default_group_str[GROUP_SIZE];
static void init_variables(void)
@@ -117,6 +119,8 @@
set_var("udev_rules", udev_rules_filename); set_var("udev_permissions", udev_permissions_filename); set_var("default_mode", default_mode_str);
+ set_var("default_owner", default_owner_str);
+ set_var("default_group", default_group_str);
}
dbg_parse("%s:%d:%Zd: error parsing '%s'", udev_config_filename,
lineno, temp - line, temp);
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 5 lines · --On Friday, January 16, 2004 05:10:15 PM -0800 Hanna Linder…
Good idea. This patch will now allow the admin to either set the default owner and group in
/etc/udev/udev.confor it will default to root/root. Greg, you can change udev.conf to setdefault_owneranddefault_groupnow.Hanna
Oops. Here is a patch that will apply cleanly. Updated Documentation patch will do on Monday.
Hanna
namedev.c +18 -2
@@ -151,6 +151,22 @@return mode; } +static char *get_default_owner (void ) +{ +if (strlen (default_owner_str) =0 ) { +strncpy (default_owner_str,"root" ,OWNER_SIZE ); + } +return default_owner_str; +} + +static char *get_default_group (void ) +{ +if (strlen (default_group_str) =0 ) { +strncpy (default_group_str,"root" ,GROUP_SIZE ); + } +return default_group_str; +} +static void apply_format (struct udevice *udev,unsigned char *string) {char temp[NAME_SIZE ];
@@ -720,8 +736,8 @@ }else {/* no matching perms found :( */ udev->mode =get_default_mode (class_dev); - udev->owner[0 ] =0x00 ; - udev->group[0 ] =0x00 ; +strncpy (udev->owner,get_default_owner (),OWNER_SIZE ); +strncpy (udev->group,get_default_group (),GROUP_SIZE ); }dbg ("name, '%s' is going to have owner='%s', group='%s', mode = %#o" , udev->name, udev->owner, udev->group, udev->mode);
udev.h +2 -0
@@ -68,5 +68,7 @@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_owner_str[OWNER_SIZE ]; +extern char default_group_str[GROUP_SIZE ];#endif
udev_config.c +4 -0
@@ -46,6 +46,8 @@char udev_rules_filename[PATH_MAX +NAME_MAX ];char udev_config_filename[PATH_MAX +NAME_MAX ];char default_mode_str[NAME_MAX ]; +char default_owner_str[OWNER_SIZE ]; +char default_group_str[GROUP_SIZE ];static void init_variables (void )
@@ -117,6 +119,8 @@set_var ("udev_rules" , udev_rules_filename);set_var ("udev_permissions" , udev_permissions_filename);set_var ("default_mode" , default_mode_str); +set_var ("default_owner" , default_owner_str); +set_var ("default_group" , default_group_str); }dbg_parse ("%s:%d:%Zd: error parsing '%s'" , udev_config_filename, lineno, temp - line, temp);
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 8 lines · Hanna Linder
Quoted 3 lines · --On Friday, January 16, 2004 05:10:15 PM -0800 Hanna Linder…
Good idea. This patch will now allow the admin to either set the default owner and group in
/etc/udev/udev.confor it will default to root/root. Greg, you can change udev.conf to setdefault_owneranddefault_groupnow.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
etc/udev/udev.conf.in +9 -1
@@ -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"
namedev.c +2 -2
@@ -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 ); }
udev-add.c +9 -9
@@ -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," " );
udev.8 +18 -0
@@ -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
udev.h +2 -1
@@ -31,6 +31,7 @@#define NAME_SIZE 100#define OWNER_SIZE 30#define GROUP_SIZE 30 +#define MODE_SIZE 8struct 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 ];
udev_config.c +1 -1
@@ -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 ];
Quoted 11 lines · --On Saturday, January 17, 2004 04:12:42 PM +0100 Kay Sievers…
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 removedclass_devfromget_default_mode(), to match with Hanna's
o changed size ofmode_strtoMODE_SIZE
o changed a few char compares from from0x00to '\0'thanks,
Kay
Thanks Kay!
You've completed about half my todo list for today :)
I'm going to work on adding a Mode field to the database since the info is already there we might as well store it.
I haven't tested your patch yet but I will today.
Hanna
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Greg KH
AppliedQuoted 10 lines · Hanna Linder
Quoted 5 lines · --On Friday, January 16, 2004 05:10:15 PM -0800 Hanna Linder…
Good idea. This patch will now allow the admin to either set the default owner and group in
/etc/udev/udev.confor it will default to root/root. Greg, you can change udev.conf to setdefault_owneranddefault_groupnow.Hanna
Oops. Here is a patch that will apply cleanly. Updated Documentation patch will do on Monday.
Applied, thanks.
greg k-h
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Greg KH
AppliedQuoted 10 lines · Kay Sievers
Quoted 8 lines · Hanna Linder
Quoted 3 lines · --On Friday, January 16, 2004 05:10:15 PM -0800 Hanna Linder…
Good idea. This patch will now allow the admin to either set the default owner and group in
/etc/udev/udev.confor it will default to root/root. Greg, you can change udev.conf to setdefault_owneranddefault_groupnow.Oops. Here is a patch that will apply cleanly. Updated Documentation patch will do on Monday.
Quoted 8 lines
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 removedclass_devfromget_default_mode(), to match with Hanna's
o changed size ofmode_strtoMODE_SIZE
o changed a few char compares from from0x00to '\0'
Applied, thanks.
greg k-h
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel