On Thu, Jun 26, 2003 at 03:35:21PM +0200, Robert Woerle wrote:
>Andrew C Aitchison schrieb:
>
>>On Thu, 26 Jun 2003, Cheshire Cat Fish wrote:
>>
>>
>>
>>>How do I go about reading a file from within my X driver. I want to read in
>>>a table of gamma correction values. If I use fopen() I get an unresolved
>>>symbol error.
>>>
>>>Do I need to link to libc somehow? Or use something other than fopen()?
>>>
>>>
>>
>>Drivers can't call libc functions, because drivers binaries are supposed
>>to run on any operating system. XFree86 provides wrappers for some libc
>>functions, but files are deliberately excluded (there is an exception
>>for input device drivers to talk to the device).
>>
>hmm.... strange ... i can do exaclty that !!!
>i am doing fopen() in an Input driver to reread my calibration data for
>the touchscreen
>so i can do calibration on the fly with it ...
>not doing a
>
>#include <stdio.h>
>
>did the trick , cause it seems that the X-source has his own fopen()
>
>( unfortunatly i am missing a good way to signal the change of that data ...
>does anyone know how to SIGNAL a Input driver from a X-application )
>
>my code looks like that : ( see also
>www.sourceforge.net/project/pacebook and browse the CVS for my
>touchscreen driver )
>
>xf86PaceBookMisc(void)
>{
>FILE *fp;
>fp = fopen ("/etc/X11/XF86Config","r");
> do {
> char *logs_old;
> char logstring[1025];
> logstring[0]='#';
> fgets(logstring,1024,fp);
> logstring[1025]=0; /* just to make extra sure */
> if(logstring[0]=='#') continue;
> if (strstr(logstring,"horizontalMax"))
>...
You shouldn't count on video/input drivers always being able to open
files directly. The only reason they can now is because of a limitation
of the current loader design where all module types can access all
exported functions. That's something I'm planning to change in the 5.0
time frame, if not sooner.
The "right" way to do this is either via the XInput extension (or an
enhancement to it), or by looking at the message passing addition that
Joe Moss recently added to the XFree86-Misc extension, and extending
that to work with input drivers. This, by its nature, also eliminates
the driver notification problem.
The input device calibration problem seems to be such a common one that
I'm surprised nobody has been able to make the XInput extension handle
it cleanly. I guess everyone just wants to take the quick and dirty
approach of communicating directly with the driver.
Grepping through the driver source, I do see that one or two video
drivers do use this approach too. The "mga" driver even writes to a
(fixed) temporary file name in a publicly-writable location, which looks
like an open invitation for any user to overwrite arbitary system files.
(I don't know who reviewed/committed that stuff.)
The sis driver goes one better and allows you to tell it which file to
to overwrite :-(
There may be other places where this is misused too. The above two
examples are from a quick grep, not a thorough audit.
This should give everyone an idea of how providing direct driver access
to functions like fopen() can be innocently misused. The X server
already provides an authenticated communication mechanism which should
make it harder to cause inadvertant problems like this. Why not use it
to implement a better method of doing these things?
David
--
David Dawes
Founder/committer/developer The XFree86 Project
www.XFree86.org/~dawes
_______________________________________________
Devel mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/devel