From owner-acpi-jp@jp.FreeBSD.org Fri Feb 14 17:18:22 2003
Received: (from daemon@localhost)
	by castle.jp.FreeBSD.org (8.11.6+3.4W/8.11.3) id h1E8IMd25172;
	Fri, 14 Feb 2003 17:18:22 +0900 (JST)
	(envelope-from owner-acpi-jp@jp.FreeBSD.org)
Received: from axe-inc.co.jp (axegw.axe-inc.co.jp [61.199.217.66])
	by castle.jp.FreeBSD.org (8.11.6+3.4W/8.11.3) with ESMTP/inet id h1E8IMJ25167
	for <acpi-jp@jp.freebsd.org>; Fri, 14 Feb 2003 17:18:22 +0900 (JST)
	(envelope-from takawata@axe-inc.co.jp)
Received: from axe-inc.co.jp ([192.47.224.47])
	by axe-inc.co.jp (8.9.3+3.2W/3.7W) with ESMTP id RAA06555;
	Fri, 14 Feb 2003 17:18:19 +0900 (JST)
Message-Id: <200302140818.RAA06555@axe-inc.co.jp>
To: rwatson@freebsd.org
cc: acpi-jp@jp.FreeBSD.org
From: User Takawata <takawata@axe-inc.co.jp>
Reply-To: acpi-jp@jp.FreeBSD.org
Precedence: list
Date: Fri, 14 Feb 2003 17:19:29 +0900
X-Sequence: acpi-jp 2091
Subject: [acpi-jp 2091] /dev/acpi permission fix to permit unharmful ioctls.
Errors-To: owner-acpi-jp@jp.FreeBSD.org
Sender: owner-acpi-jp@jp.FreeBSD.org
X-Originator: takawata@axe-inc.co.jp
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+030107

Hi, I want to commit following patch.
This enables less previleged user program to 
use harmless ioctls, like getting battery information.

Comment?

Index: acpi.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/acpica/acpi.c,v
retrieving revision 1.83
diff -u -r1.83 acpi.c
--- acpi.c	28 Dec 2002 14:58:50 -0000	1.83
+++ acpi.c	14 Feb 2003 08:14:09 -0000
@@ -33,6 +33,7 @@
 #include <sys/param.h>
 #include <sys/kernel.h>
 #include <sys/proc.h>
+#include <sys/fcntl.h>
 #include <sys/malloc.h>
 #include <sys/bus.h>
 #include <sys/conf.h>
@@ -487,7 +488,7 @@
     /*
      * Create the control device
      */
-    sc->acpi_dev_t = make_dev(&acpi_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600,
+    sc->acpi_dev_t = make_dev(&acpi_cdevsw, 0, UID_ROOT, GID_WHEEL, 0644,
 	"acpi");
     sc->acpi_dev_t->si_drv1 = sc;
 
@@ -1841,6 +1842,15 @@
 		goto out;
 	    }
 	}
+    }
+
+    /*
+     * Core ioctl is not permitted for non-writable user.
+     * Currently, other ioctls just fetch information.
+     * Not changing system behavior.
+     */
+    if(!(flag & FWRITE)){
+	    return EPERM;
     }
 
     /*

