changeset 3336:3d776dff7839

6350890 usb desktop devices should have the permission 0600 to the login user 6494635 BenQ usb mouse does not work on Nevada, works on Solaris 10 U3
author gc161489
date Mon, 25 Dec 2006 23:20:44 -0800
parents b76eeecb535e
children d73d4a90c8ad
files usr/src/cmd/login/logindevperm.sh usr/src/pkgdefs/SUNWugen/postinstall usr/src/pkgdefs/SUNWugen/preremove usr/src/pkgdefs/SUNWusb/postinstall usr/src/pkgdefs/common_files/i.logindevperm usr/src/uts/common/io/usb/clients/hidparser/hidparser.c
diffstat 6 files changed, 148 insertions(+), 139 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/login/logindevperm.sh	Mon Dec 25 22:04:48 2006 -0800
+++ b/usr/src/cmd/login/logindevperm.sh	Mon Dec 25 23:20:44 2006 -0800
@@ -66,6 +66,9 @@
 /dev/console	0400	/dev/removable-media/rdsk/*	# removable media
 /dev/console	0400	/dev/hotpluggable/dsk/*		# hotpluggable storage
 /dev/console	0400	/dev/hotpluggable/rdsk/*	# hotpluggable storage
+/dev/console	0600	/dev/video[0-9]+	# video devices
+/dev/console	0600	/dev/usb/hid[0-9]+	# hid devices should have the same permission with conskbd and consms
+/dev/console	0600	/dev/usb/[0-9a-f]+[.][0-9a-f]+/[0-9]+/* driver=scsa2usb,usb_mid,usbprn,ugen	#libusb/ugen devices
 EOM
 
 case "$MACH" in
--- a/usr/src/pkgdefs/SUNWugen/postinstall	Mon Dec 25 22:04:48 2006 -0800
+++ b/usr/src/pkgdefs/SUNWugen/postinstall	Mon Dec 25 23:20:44 2006 -0800
@@ -3,9 +3,8 @@
 # CDDL HEADER START
 #
 # The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
 #
 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 # or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
 #
 # CDDL HEADER END
 #
-# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 # ident	"%Z%%M%	%I%	%E% SMI"
@@ -33,9 +32,6 @@
 	BASEDIR_OPT="-b $BASEDIR" 
 fi
 
-LOGIN_ENTRY_RE="/dev/console    0600    /dev/usb/[0-9a-f]+[.][0-9a-f]+/[0-9]+/* driver=scsa2usb,usb_mid,usbprn # libusb/ugen devices"
-LOGIN_ENTRY_NON_RE="/dev/usb/\[0-9a-f\]\+\[.\]\[0-9a-f\]\+/\[0-9\]\+/\*"
-
 not_installed() {
 	driver=$1
 	grep "^${driver} " $BASEDIR/etc/name_to_major > /dev/null 2>&1
@@ -43,20 +39,9 @@
 	return $?
 }
 
-# ugen devices should be default be accessible by console owner only
-# so libusb applications will just work
-
-no_logindevperm() {
-	egrep "$LOGIN_ENTRY_NON_RE" $BASEDIR/etc/logindevperm > /dev/null 2>&1
-
-	return $?
-}
-
 EXIT=0
 
 not_installed ugen || add_drv ${BASEDIR_OPT} -m '* 0644 root sys' \
 	ugen || EXIT=1
 
-no_logindevperm || echo "$LOGIN_ENTRY_RE" >> $BASEDIR/etc/logindevperm
-
 exit $EXIT
--- a/usr/src/pkgdefs/SUNWugen/preremove	Mon Dec 25 22:04:48 2006 -0800
+++ b/usr/src/pkgdefs/SUNWugen/preremove	Mon Dec 25 23:20:44 2006 -0800
@@ -3,9 +3,8 @@
 # CDDL HEADER START
 #
 # The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
 #
 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 # or http://www.opensolaris.org/os/licensing.
@@ -20,14 +19,13 @@
 #
 # CDDL HEADER END
 #
-# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
 # ident	"%Z%%M%	%I%	%E% SMI"
 #
  
 PATH="/usr/bin:/usr/sbin:${PATH}"
-LOGIN_ENTRY_NON_RE="/dev/console    0600    /dev/usb/\[0-9a-f\]\+\[.\]\[0-9a-f\]\+/\[0-9\]\+/\*"
 export PATH
 
 EXIT=0
@@ -47,7 +45,4 @@
 	no_user_aliases ugen || rem_drv -b ${BASEDIR} ugen || EXIT=1
 fi
 
-egrep -v "$LOGIN_ENTRY_NON_RE" $BASEDIR/etc/logindevperm > /tmp/logindevperm$$
-mv /tmp/logindevperm$$ $BASEDIR/etc/logindevperm
-
 exit $EXIT
--- a/usr/src/pkgdefs/SUNWusb/postinstall	Mon Dec 25 22:04:48 2006 -0800
+++ b/usr/src/pkgdefs/SUNWusb/postinstall	Mon Dec 25 23:20:44 2006 -0800
@@ -3,9 +3,8 @@
 # CDDL HEADER START
 #
 # The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
 #
 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 # or http://www.opensolaris.org/os/licensing.
@@ -23,7 +22,7 @@
 #
 #pragma ident	"%Z%%M%	%I%	%E% SMI"
 #
-# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
  
@@ -53,7 +52,7 @@
 
 EXIT=0
 
-not_installed hid || add_drv ${BASEDIR_OPT} -m '* 0666 root sys' \
+not_installed hid || add_drv ${BASEDIR_OPT} -m '* 0600 root sys' \
 	-i '"usbif,class3"' -n hid || EXIT=1
 
 not_installed hubd || add_drv ${BASEDIR_OPT} -m '* 0644 root sys' \
--- a/usr/src/pkgdefs/common_files/i.logindevperm	Mon Dec 25 22:04:48 2006 -0800
+++ b/usr/src/pkgdefs/common_files/i.logindevperm	Mon Dec 25 23:20:44 2006 -0800
@@ -53,8 +53,17 @@
 			continue
 		fi
 
+		# extract 'drivers' field
+		drivers=`echo "$line" | awk '{print $4}'`
+		found_driver=`echo "$drivers" | egrep "^driver="`
+		if [ -z "$found_driver" ]; then
+			drivers=""
+		fi
+
+		devices=`echo "$devices" | sed 's/\[/\\\[/g' | sed 's/\]/\\\]/g' | sed 's/\+/\\\+/g' | sed 's/\*/\\\*/g'`
+
 		# if dest has an entry for these devices, preserve that
-		dest_entry=`egrep "^[# 	]*/[a-zA-Z0-9\/]+[ 	]+[0-9]+[ 	]+$devices" $dest | tail -1 2>/dev/null`
+		dest_entry=`egrep "^[# 	]*/[a-zA-Z0-9\/]+[ 	]+[0-9]+[ 	]+$devices[ 	]*$drivers" $dest | tail -1 2>/dev/null`
 		if [ -n "$dest_entry" ]; then
 			echo "$dest_entry"
 		else
@@ -76,8 +85,17 @@
 			continue
 		fi
 
+		# extract 'drivers' field
+		drivers=`echo "$line" | awk '{print $4}'`
+		found_driver=`echo "$drivers" | egrep "^driver="`
+		if [ -z "$found_driver" ]; then
+			drivers=""
+		fi
+
+		devices=`echo "$devices" | sed 's/\[/\\\[/g' | sed 's/\]/\\\]/g' | sed 's/\+/\\\+/g' | sed 's/\*/\\\*/g'`
+
 		# if dest has an entry for these devices, preserve that
-		dest_entry=`egrep "^[# 	]*/[a-zA-Z0-9\/]+[ 	]+[0-9]+[ 	]+$devices" $newdest | tail -1 2>/dev/null`
+		dest_entry=`egrep "^[# 	]*/[a-zA-Z0-9\/]+[ 	]+[0-9]+[ 	]+"$devices"[ 	]*"$drivers"" $newdest | tail -1 2>/dev/null`
 		if [ -z "$dest_entry" ]; then
 			echo "$line"
 		fi
--- a/usr/src/uts/common/io/usb/clients/hidparser/hidparser.c	Mon Dec 25 22:04:48 2006 -0800
+++ b/usr/src/uts/common/io/usb/clients/hidparser/hidparser.c	Mon Dec 25 23:20:44 2006 -0800
@@ -2,9 +2,8 @@
  * CDDL HEADER START
  *
  * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
  *
  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  * or http://www.opensolaris.org/os/licensing.
@@ -20,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -849,12 +848,11 @@
 	entity_item_t *current = parser_handle;
 	entity_attribute_t *attribute;
 	uchar_t foundreportid, right_report_id, valid_usage;
-	uchar_t found_usage_min, found_usage_max;
-	int i = 0;
+	uchar_t found_usage_min, found_usage_max, found_usage;
+	int i, j;
 	int rval;
-	uint32_t usage, usage_min, usage_max;
-	hidparser_usage_info_t ui;
-	boolean_t	delim_pre = B_FALSE;
+	uint32_t usage, usage_min, usage_max, usage_id[USAGE_MAX];
+	hidparser_usage_info_t *ui;
 
 	found_usage_min = 0;
 	found_usage_max = 0;
@@ -902,6 +900,7 @@
 			right_report_id = 0;
 			found_usage_min = 0;
 			found_usage_max = 0;
+			found_usage = 0;
 			valid_usage = 0;
 
 			attribute = current->entity_item_attributes;
@@ -921,97 +920,59 @@
 					}
 
 					break;
+				case R_ITEM_USAGE:
+					if (found_usage >= USAGE_MAX) {
+
+						return (HIDPARSER_FAILURE);
+					}
+					usage = hidparser_find_unsigned_val(
+					    attribute);
+					if (usage) {
+						usage_id[found_usage] = usage;
+						found_usage++;
+					}
+
+					break;
 				case R_ITEM_USAGE_MIN:
 					found_usage_min = 1;
 					usage_min = hidparser_find_unsigned_val(
 					    attribute);
-					ui.usage_min = HID_USAGE_ID(usage_min);
 
 					break;
 				case R_ITEM_USAGE_MAX:
 					found_usage_max = 1;
 					usage_max = hidparser_find_unsigned_val(
 					    attribute);
-					ui.usage_max = HID_USAGE_ID(usage_max);
-					if (attribute->
-					    entity_attribute_length == 3) {
-						ui.usage_page = HID_USAGE_PAGE(
-								    usage_max);
-					}
 
 					break;
 				case R_ITEM_SET_DELIMITER:
-					delim_pre = B_TRUE;
-					attribute =
-					    attribute->entity_attribute_next;
+					/* skip over alternate usages */
+					do {
+						attribute = attribute->
+						    entity_attribute_next;
+					} while (attribute->
+					    entity_attribute_tag !=
+					    R_ITEM_SET_DELIMITER);
 
 					break;
 				}
 
-				/*
-				 * If we have a usage item, and we had
-				 * a report id match (or report ids
-				 * are not present), put the usage
-				 * item into the list.
-				 * Don't put undefined usage items
-				 * (HID_USAGE_UNDEFINED, 0) into
-				 * the list; a 0 usage item is
-				 * used to match padding fields
-				 * that don't have an attached
-				 * usage.
-				 */
-				if ((!foundreportid ||
-				    (foundreportid && right_report_id)) &&
-				    (attribute->entity_attribute_tag ==
-				    R_ITEM_USAGE) &&
-				    hidparser_find_unsigned_val(attribute)) {
-					/* Put in usage list */
-					if (rpt->no_of_usages >= USAGE_MAX) {
-
-						return (HIDPARSER_FAILURE);
-					}
-
-					hidparser_fill_usage_info(&ui,
-					    current->entity_item_attributes);
-
-					ui.collection_usage = collection_usage;
-
-					usage = hidparser_find_unsigned_val(
-					    attribute);
-					ui.usage_id = HID_USAGE_ID(usage);
-					if (attribute->
-					    entity_attribute_length == 3) {
-						if (HID_USAGE_PAGE(usage))
-							ui.usage_page =
-							    HID_USAGE_PAGE(
-							    usage);
-					}
-
-					i = rpt->no_of_usages++;
-					rpt->usage_descr[i] = ui;
-					rpt->report_id = report_id;
-					valid_usage = 1;
-					if (delim_pre == B_TRUE) {
-						/* skip over alternate usages */
-						while (attribute->
-						    entity_attribute_tag !=
-						    R_ITEM_SET_DELIMITER) {
-							attribute = attribute->
-							entity_attribute_next;
-						}
-						delim_pre = B_FALSE;
-					}
-				}
-
-				/*
-				 * If we have a usage min & max, and
-				 * we had a report id match(or report
-				 * ids are not present) put the usage
-				 * range into the list.
-				 */
-				if ((!foundreportid || (foundreportid &&
-				    right_report_id)) &&
-				    found_usage_min && found_usage_max) {
+				attribute = attribute->entity_attribute_next;
+			}
+
+			/*
+			 * If we have a report id match (or report ids
+			 * are not present), and have a usage item or
+			 * usage min&max, put the usage item into the
+			 * list. Don't put undefined usage items
+			 * (HID_USAGE_UNDEFINED, 0) into the list;
+			 * a 0 usage item is used to match padding
+			 * fields that don't have an attached usage.
+			 */
+			if (!foundreportid ||
+			    (foundreportid && right_report_id)) {
+
+				for (j = 0; j < found_usage; j++) {
 
 					/* Put in usage list */
 					if (rpt->no_of_usages >= USAGE_MAX) {
@@ -1019,30 +980,77 @@
 						return (HIDPARSER_FAILURE);
 					}
 
-					hidparser_fill_usage_info(&ui,
+					i = rpt->no_of_usages++;
+					ui = &(rpt->usage_descr[i]);
+
+					hidparser_fill_usage_info(ui,
 					    current->entity_item_attributes);
 
-					ui.collection_usage = collection_usage;
-
-					i = rpt->no_of_usages++;
-					rpt->usage_descr[i] = ui;
+					ui->rptcnt /= found_usage;
+					ui->collection_usage = collection_usage;
+					ui->usage_id = HID_USAGE_ID(
+					    usage_id[j]);
+
+					/*
+					 * This is an extended usage ie.
+					 * usage page in upper 16 bits
+					 * or-ed with usage in the lower
+					 * 16 bits.
+					 */
+					if (usage_id[j] >> 16) {
+						ui->usage_page =
+						    HID_USAGE_PAGE(usage_id[j]);
+					}
+
 					rpt->report_id = report_id;
 					valid_usage = 1;
-					if (delim_pre == B_TRUE) {
-						/* skip over alternate usages */
-						while (attribute->
-						    entity_attribute_tag !=
-						    R_ITEM_SET_DELIMITER) {
-							attribute = attribute->
-							entity_attribute_next;
-						}
-						delim_pre = B_FALSE;
+				}
+
+				if (found_usage_min && found_usage_max) {
+
+					/* Put in usage list */
+					if (rpt->no_of_usages >= USAGE_MAX) {
+
+						return (HIDPARSER_FAILURE);
 					}
 
-					found_usage_min = found_usage_max = 0;
+					if (found_usage) {
+
+						/* handle duplication */
+						ui->usage_min = HID_USAGE_ID(
+						    usage_min);
+						ui->usage_max = HID_USAGE_ID(
+						    usage_max);
+					} else {
+						i = rpt->no_of_usages++;
+						ui = &(rpt->usage_descr[i]);
+
+						hidparser_fill_usage_info(ui,
+						    current->
+						    entity_item_attributes);
+
+						ui->collection_usage =
+						    collection_usage;
+						ui->usage_min = HID_USAGE_ID(
+						    usage_min);
+						ui->usage_max = HID_USAGE_ID(
+						    usage_max);
+
+						rpt->report_id = report_id;
+						valid_usage = 1;
+					}
+
+					/*
+					 * This is an extended usage ie.
+					 * usage page in upper 16 bits
+					 * or-ed with usage_max in the lower
+					 * 16 bits.
+					 */
+					if (usage_max >> 16) {
+						ui->usage_page =
+						    HID_USAGE_PAGE(usage_max);
+					}
 				}
-
-				attribute = attribute->entity_attribute_next;
 			}
 
 			/*
@@ -1059,14 +1067,15 @@
 					return (HIDPARSER_FAILURE);
 				}
 
-				hidparser_fill_usage_info(&ui,
+				i = rpt->no_of_usages++;
+				ui = &(rpt->usage_descr[i]);
+
+				hidparser_fill_usage_info(ui,
 				    current->entity_item_attributes);
 
-				ui.collection_usage = collection_usage;
-				ui.usage_id = HID_USAGE_UNDEFINED;
-
-				i = rpt->no_of_usages++;
-				rpt->usage_descr[i] = ui;
+				ui->collection_usage = collection_usage;
+				ui->usage_id = HID_USAGE_UNDEFINED;
+
 				rpt->report_id = report_id;
 			}