Bug 2407

Summary: run Xserver with normal user permissions
Product: xorg Reporter: Egbert Eich <eich>
Component: Server/DDX/XorgAssignee: Xorg Project Team <xorg-team>
Status: RESOLVED FIXED QA Contact: Xorg Project Team <xorg-team>
Severity: normal    
Priority: high CC: roland.mainz, stuart.kreitman, wbrana
Version: git   
Hardware: x86 (IA32)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments:
Description Flags
See above. suzui: 6.8-branch-

Description Egbert Eich 2005-01-28 07:48:54 UTC
The patch below allows to run X with ordinary user permissions
privided the used driver doesn't require direct access to hardware.
Currently the fbdev and the dummy driver do.
The patch modifies a feature that has been added to the API with 6.8 slightly
while care has been taken to not change the ABI. Currently no open source
drivers should be affected but the Nvidia binary only driver might.
The API changes consist purely of name changes.

The API changes are:

1. enum xorgRRFuncFlags -> enum xorgDriverFuncOp
   The enum was extended with a flag GET_REQUIRED_HW_INTERFACES.
2. typedef Bool xorgRRFuncProc(ScrnInfoPtr, xorgRRFuncFlags, xorRRRotationPtr)
    -> typedef Bool xorgDriverFuncProc(ScrnInfoPtr, xorgDriverFuncOp, pointer)
   pointer is a generic (void) pointer that can be cast to any other pointer
   depending on the xorgDriverFuncOp value.
3. struct _ScrnInfoRec: xorgRRFuncProc *RRFunc -> xorgDriverFuncProc 
   DriverFunc.

4. A driverFunc can be added to the DriverRec of a driver to make some of
   its functionalitiy available before a screen has been initialized.
   It is also available in the ScrnInfoRec structure. If available in the 
   DriverRec xf86AllocateScreen() will copy it to ScrnInfoRec structure 
   automatically.
   If non of its functionality is required before a screen has been initialized
   the function may be added to the ScrnInfoRec structure in Probe().
Furthermore it is now required that xorgRRFuncProc() returns FALSE when it
doesn't handle the xorgRRFuncFlag as these functionalities may optional.

Applications like scanpci will no longer need root permissions either as long as
they don't have to access HW but can use interfaces like /proc/bus/pci.

Some OS specific changes are required. I have attempted to to add the changes to
xf86EnableIO() (it has been changed from void xf86EnableIO() to Bool
xf86EnableIO()).
The console init code may also need to be modified.
Comment 1 Egbert Eich 2005-01-28 07:49:31 UTC
Created attachment 1774 [details] [review]
See above.
Comment 2 Egbert Eich 2005-01-28 08:13:20 UTC
Committed.
This patch may break build for non-Linux OSes. I didn't have the opportunity to
test this code.
Leaving open for further discussion.

2005-01-28  Egbert Eich  <eich-at-freedesktop-dot-org>

        * programs/Xserver/hw/xfree86/common/xf86Bus.c:
        (xf86FindPrimaryDevice):
        * programs/Xserver/hw/xfree86/common/xf86Configure.c:
        (DoConfigure):
        * programs/Xserver/hw/xfree86/common/xf86DoProbe.c: (DoProbe):
        * programs/Xserver/hw/xfree86/common/xf86Events.c: (xf86VTSwitch):
        * programs/Xserver/hw/xfree86/common/xf86Globals.c:
        * programs/Xserver/hw/xfree86/common/xf86Helper.c: (xf86AddDriver),
        (xf86AllocateScreen):
        * programs/Xserver/hw/xfree86/common/xf86Init.c: (InitOutput),
        (ddxProcessArgument), (ddxUseMsg):
        * programs/Xserver/hw/xfree86/common/xf86Priv.h:
        * programs/Xserver/hw/xfree86/common/xf86RandR.c:
        (xf86RandRGetInfo), (xf86RandRSetConfig):
        * programs/Xserver/hw/xfree86/common/xf86str.h:
        * programs/Xserver/hw/xfree86/drivers/dummy/dummy_driver.c:
        (dummySetup), (dummyDriverFunc):
        * programs/Xserver/hw/xfree86/drivers/fbdev/fbdev.c: (FBDevSetup),
        (FBDevDriverFunc):
        * programs/Xserver/hw/xfree86/etc/scanpci.c: (main):
        * programs/Xserver/hw/xfree86/os-support/bsd/alpha_video.c:
        (xf86EnableIO):
        * programs/Xserver/hw/xfree86/os-support/bsd/arm_video.c:
        (xf86EnableIO):
        * programs/Xserver/hw/xfree86/os-support/bsd/i386_video.c:
        (xf86EnableIO):
        * programs/Xserver/hw/xfree86/os-support/bsdi/bsdi_video.c:
        (xf86EnableIO):
        * programs/Xserver/hw/xfree86/os-support/bus/Pci.c:
        * programs/Xserver/hw/xfree86/os-support/bus/ix86Pci.c:
        (ix86PciSelectCfgmech):
        * programs/Xserver/hw/xfree86/os-support/bus/linuxPci.c:
        (linuxPciOpenFile), (linuxPciCfgRead), (linuxPciCfgWrite),
        (linuxPciCfgSetBits), (xf86GetPciDomain), (linuxMapPci):
        * programs/Xserver/hw/xfree86/os-support/bus/ppcPci.c:
        (ppcPciInit), (motoppcPciInit), (buserr), (pciCfgMech1Read),
        (pciCfgMech1Write), (pciCfgMech1SetBits):
        * programs/Xserver/hw/xfree86/os-support/hurd/hurd_video.c:
        (xf86EnableIO):
        * programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c:
        (xf86OpenConsole), (xf86CloseConsole):
        * programs/Xserver/hw/xfree86/os-support/linux/lnx_kbd.c:
        (SetKbdRepeat):
        * programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c:
        (xf86EnableIO):
        * programs/Xserver/hw/xfree86/os-support/nto/nto_ioperm.c:
        (xf86EnableIO):
        * programs/Xserver/hw/xfree86/os-support/os2/os2_ioperm.c:
        (xf86EnableIO):
        * programs/Xserver/hw/xfree86/os-support/sco/sco_iop.c:
        (xf86EnableIO):
        * programs/Xserver/hw/xfree86/os-support/shared/ioperm_noop.c:
        (xf86EnableIO):
        * programs/Xserver/hw/xfree86/os-support/sunos/sun_vid.c:
        (xf86EnableIO):
        * programs/Xserver/hw/xfree86/os-support/sysv/sysv_video.c:
        (xf86EnableIO):
        * programs/Xserver/hw/xfree86/os-support/xf86_OSproc.h:
        Modifying X.Org Xserver DDX to allow to run X with ordinary
        user permissions when no access to HW registers is required.
        For API changes which mostly involve the modifications to
        make the RRFunc (introduced with 6.8) more flexible please
        check Bugzilla #2407.
        NOTE: This patch applies changes to OS specific files for
        other OSes which I cannot test.

Comment 3 Thomas Winischhofer 2005-01-28 09:14:26 UTC
How is this DriverFuncs stuff supposed to work in case of a static server? How
does the static server know whether the DriverRec has a DriverFunc field or not?
Comment 4 Adam Jackson 2005-06-28 14:03:16 UTC
*** Bug 1206 has been marked as a duplicate of this bug. ***
Comment 5 Eiichi Yagi 2006-05-21 15:06:52 UTC
Comment on attachment 1774 [details] [review]
See above.

xf86EnableIO error occur
Comment 6 Daniel Stone 2007-02-27 01:25:16 UTC
Sorry about the phenomenal bug spam, guys.  Adding xorg-team@ to the QA contact so bugs don't get lost in future.
Comment 7 wbrana 2012-07-05 13:34:08 UTC
Is this bug already fixed?

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.