In message <[EMAIL PROTECTED]> Warner Losh writes:
: Yes. The right answer isn't to kludge this through a sysctl, but
: instead it is to fix apm to that it is safe to make it world read
: only. Is there a way inside a ioctl to see if you have something open
: for write access?
OK. I found the answer. Here's my patch. Comments? This way we
don't have two, incompatible power interfaces.
Warner
Index: etc/MAKEDEV
===================================================================
RCS file: /home/imp/FreeBSD/CVS/src/etc/MAKEDEV,v
retrieving revision 1.260
diff -u -r1.260 MAKEDEV
--- etc/MAKEDEV 2000/06/26 15:42:48 1.260
+++ etc/MAKEDEV 2000/07/17 19:39:37
@@ -1364,7 +1364,7 @@
apm)
mknod apm c 39 0 root:operator
- chmod 660 apm
+ chmod 664 apm
;;
apmctl)
Index: usr.sbin/apm/apm.c
===================================================================
RCS file: /home/imp/FreeBSD/CVS/src/usr.sbin/apm/apm.c,v
retrieving revision 1.22
diff -u -r1.22 apm.c
--- usr.sbin/apm/apm.c 2000/01/22 18:11:58 1.22
+++ usr.sbin/apm/apm.c 2000/07/17 19:39:37
@@ -412,7 +412,10 @@
argv += optind;
}
finish_option:
- fd = open(APMDEV, O_RDWR);
+ if (haltcpu != -1 || enable != -1 || delta || sleep || standby)
+ fd = open(APMDEV, O_RDWR);
+ else
+ fd = open(APMDEV, O_RDONLY);
if (fd == -1)
err(1, "can't open %s", APMDEV);
if (enable != -1)
Index: sys/i386/apm/apm.c
===================================================================
RCS file: /home/imp/FreeBSD/CVS/src/sys/i386/apm/apm.c,v
retrieving revision 1.114
diff -u -r1.114 apm.c
--- sys/i386/apm/apm.c 2000/02/06 14:57:05 1.114
+++ sys/i386/apm/apm.c 2000/07/17 19:39:37
@@ -1169,6 +1169,8 @@
#endif
switch (cmd) {
case APMIO_SUSPEND:
+ if ((flag & FWRITE) != 0)
+ return (EPERM);
if (sc->active)
apm_suspend(PMST_SUSPEND);
else
@@ -1176,6 +1178,8 @@
break;
case APMIO_STANDBY:
+ if ((flag & FWRITE) != 0)
+ return (EPERM);
if (sc->active)
apm_suspend(PMST_STANDBY);
else
@@ -1203,23 +1207,35 @@
error = ENXIO;
break;
case APMIO_ENABLE:
+ if ((flag & FWRITE) != 0)
+ return (EPERM);
apm_event_enable();
break;
case APMIO_DISABLE:
+ if ((flag & FWRITE) != 0)
+ return (EPERM);
apm_event_disable();
break;
case APMIO_HALTCPU:
+ if ((flag & FWRITE) != 0)
+ return (EPERM);
apm_halt_cpu();
break;
case APMIO_NOTHALTCPU:
+ if ((flag & FWRITE) != 0)
+ return (EPERM);
apm_not_halt_cpu();
break;
case APMIO_DISPLAY:
+ if ((flag & FWRITE) != 0)
+ return (EPERM);
newstate = *(int *)addr;
if (apm_display(newstate))
error = ENXIO;
break;
case APMIO_BIOS:
+ if ((flag & FWRITE) != 0)
+ return (EPERM);
/* XXX compatibility with the old interface */
args = (struct apm_bios_arg *)addr;
sc->bios.r.eax = args->eax;
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message