Re: read-write to stdin-stdout or to a file?
Quoting Pedro Zorzenon Neto (pzn@terra.com.br):
> On Fri, Jul 20, 2001 at 12:42:13PM +0100, David Wright wrote:
> > Do you mean this package?
> >
> > "Programmer for Atmel AVR microcontrolers that uses PC parallel port
>
> Yes.
>
> > If so, I'm not sure why you think it needs to be setuid. Just
> > chgrp somegroup /dev/lp0 (or whichever port) and put yourself
> > (and any others) into somegroup.
>
> I tried /dev/lp* and couldn't make the program work with it.
I should have looked back at what I had done. I didn't use /dev/lp*
but a device of my own making /dev/pp125 which is major 125, minor 0
(i.e. in the range reserved for users). But chgrp it just the same.
> This program uses a specific hardware connected to the printer port. It has to read some bits of the port and write other bits in patterns which has to change in some microseconds.
>
> That is why it uses lowlevel ioperm, inb, outb to IO 0x378 (or other IO, at user option[1]) and runs setuid root.
I used a kernel module, which saves using ioperm and setuid root.
The module loads automatically when anyone (allowed) opens the device.
> I think (not sure about all architectures) that because of this, it will run only in i386 machines. If I used /dev/lp* it would run in all machines. If someone knows how to use lp device for this specific purpose, please write me.
Are you sure you aren't writing /dev/lp* to mean a special device
with LP_MAJOR = 6, and hence the lp.o module. That won't work because
lp.o only drives printers - it doesn't do arbitrary bit-twiddling.
My module didn't use any architecture-specific headers, so I guess
it should work on any architecture. However, I had no hardware to
test that assertion.
> [1] root must edit a config file to say which ports the user can choose.
A module might look at /etc/modules.conf similarly.
Cheers,
--
Email: d.wright@open.ac.uk Tel: +44 1908 653 739 Fax: +44 1908 655 151
Snail: David Wright, Earth Science Dept., Milton Keynes, England, MK7 6AA
Disclaimer: These addresses are only for reaching me, and do not signify
official stationery. Views expressed here are either my own or plagiarised.
Reply to: