diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2006-11-28 20:29:33 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2006-11-28 20:29:33 +0000 |
commit | 70ce0341935fd116216e76d40ef65d969227e892 (patch) | |
tree | 6c3f151e6258cb75b0b1983e1e563d2b95ec457d /xserver | |
parent | df6b77dc03dec3df43fadeb2f3a4912966e93ea1 (diff) |
OpenBSD local modifications:
- privilege separation
- some snprintf/strlc{at,py} conversions
- support for more architectures
- signal handler fixes
- default mouse wheel support in config tools
- sunmouse protocol
Diffstat (limited to 'xserver')
63 files changed, 1849 insertions, 2287 deletions
diff --git a/xserver/Makefile.bsd-wrapper b/xserver/Makefile.bsd-wrapper index 43cdad043..95aa0568d 100644 --- a/xserver/Makefile.bsd-wrapper +++ b/xserver/Makefile.bsd-wrapper @@ -1,11 +1,11 @@ -# $OpenBSD: Makefile.bsd-wrapper,v 1.2 2006/11/27 19:34:41 matthieu Exp $ +# $OpenBSD: Makefile.bsd-wrapper,v 1.3 2006/11/28 20:29:31 matthieu Exp $ DIST= ${.CURDIR} CONFIGURE_ARGS= --localstatedir=/var --sysconfdir=/etc/X11 \ --with-module-dir=${LIBDIR}/modules \ --with-mesa-source=${XENOCARA_TOP}/dist/Mesa \ - --enable-install-setuid \ + --enable-install-setuid --enable-privsep \ --disable-dmx .include <bsd.xorg.mk> diff --git a/xserver/configure b/xserver/configure index 86f8bd66e..cf174cf3e 100644 --- a/xserver/configure +++ b/xserver/configure @@ -465,7 +465,7 @@ ac_includes_default="\ # include <unistd.h> #endif" -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CCAS CCASFLAGS LN_S build build_cpu build_vendor build_os host host_cpu host_vendor host_os EGREP ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB DLLTOOL ac_ct_DLLTOOL AS ac_ct_AS OBJDUMP ac_ct_OBJDUMP CPP CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL PKG_CONFIG ac_pt_PKG_CONFIG LEX LEXLIB LEX_OUTPUT_ROOT YACC RAWCPP RAWCPPFLAGS ALLOCA NEED_STRLCAT_TRUE NEED_STRLCAT_FALSE NEED_VSNPRINTF_TRUE NEED_VSNPRINTF_FALSE AGP_TRUE AGP_FALSE LNXAPM_TRUE LNXAPM_FALSE FBDEVHW_TRUE FBDEVHW_FALSE FREEBSD_KLDLOAD_TRUE FREEBSD_KLDLOAD_FALSE ALPHA_VIDEO_TRUE ALPHA_VIDEO_FALSE ARM_VIDEO_TRUE ARM_VIDEO_FALSE I386_VIDEO_TRUE I386_VIDEO_FALSE PPC_VIDEO_TRUE PPC_VIDEO_FALSE SPARC64_VIDEO_TRUE SPARC64_VIDEO_FALSE KDRIVE_HW_TRUE KDRIVE_HW_FALSE MMX_CAPABLE_TRUE MMX_CAPABLE_FALSE INSTALL_SETUID_TRUE INSTALL_SETUID_FALSE INT10_VM86_TRUE INT10_VM86_FALSE INT10_X86EMU_TRUE INT10_X86EMU_FALSE INT10_STUB_TRUE INT10_STUB_FALSE BUILDDOCS_TRUE BUILDDOCS_FALSE LINUXDOC PS2PDF BUILD_LINUXDOC_TRUE BUILD_LINUXDOC_FALSE BUILD_PDFDOC_TRUE BUILD_PDFDOC_FALSE MAKE_TEXT MAKE_PS MAKE_PDF MAKE_HTML INSTALL_LIBXF86CONFIG_TRUE INSTALL_LIBXF86CONFIG_FALSE XV_TRUE XV_FALSE XVMC_TRUE XVMC_FALSE DGA_TRUE DGA_FALSE COMPOSITE_TRUE COMPOSITE_FALSE MITSHM_TRUE MITSHM_FALSE XTRAP_TRUE XTRAP_FALSE RECORD_TRUE RECORD_FALSE SCREENSAVER_TRUE SCREENSAVER_FALSE RES_TRUE RES_FALSE XLIB_CFLAGS XLIB_LIBS GL_CFLAGS GL_LIBS GLX_TRUE GLX_FALSE MESA_SOURCE AIGLX_TRUE AIGLX_FALSE GLX_DEFINES DRI_TRUE DRI_FALSE DRIPROTO_CFLAGS DRIPROTO_LIBS LIBDRM_CFLAGS LIBDRM_LIBS XINERAMA_TRUE XINERAMA_FALSE XACE_TRUE XACE_FALSE XCSECURITY_TRUE XCSECURITY_FALSE XEVIE_TRUE XEVIE_FALSE APPGROUP_TRUE APPGROUP_FALSE CUP_TRUE CUP_FALSE EVI_TRUE EVI_FALSE MULTIBUFFER_TRUE MULTIBUFFER_FALSE FONTCACHE_TRUE FONTCACHE_FALSE DBE_TRUE DBE_FALSE XF86BIGFONT_TRUE XF86BIGFONT_FALSE DPMSExtension_TRUE DPMSExtension_FALSE XPRINTPROTO_CFLAGS XPRINTPROTO_LIBS XPRINT_TRUE XPRINT_FALSE XCALIBRATE_TRUE XCALIBRATE_FALSE XINPUT_TRUE XINPUT_FALSE XF86UTILS_TRUE XF86UTILS_FALSE XDMCP_CFLAGS XDMCP_LIBS XDMCP_TRUE XDMCP_FALSE XDMAUTH_TRUE XDMAUTH_FALSE USE_RGB_BUILTIN_TRUE USE_RGB_BUILTIN_FALSE COMPILEDDEFAULTFONTPATH RGB_DB BASE_FONT_PATH DRI_DRIVER_PATH VENDOR_STRING VENDOR_STRING_SHORT VENDOR_RELEASE VENDOR_MAN_VERSION DEBUG_TRUE DEBUG_FALSE XSERVERCFLAGS_CFLAGS XSERVERCFLAGS_LIBS XSERVERLIBS_CFLAGS XSERVERLIBS_LIBS SYS_LIBS XSERVER_LIBS DMXMODULES_CFLAGS DMXMODULES_LIBS DMX_TRUE DMX_FALSE XDMX_LIBS XDMXCONFIG_DEP_CFLAGS XDMXCONFIG_DEP_LIBS DMXEXAMPLES_DEP_CFLAGS DMXEXAMPLES_DEP_LIBS DMXXMUEXAMPLES_DEP_CFLAGS DMXXMUEXAMPLES_DEP_LIBS DMXXIEXAMPLES_DEP_CFLAGS DMXXIEXAMPLES_DEP_LIBS XTSTEXAMPLES_DEP_CFLAGS XTSTEXAMPLES_DEP_LIBS XRESEXAMPLES_DEP_CFLAGS XRESEXAMPLES_DEP_LIBS X11EXAMPLES_DEP_CFLAGS X11EXAMPLES_DEP_LIBS DMX_BUILD_LNX_TRUE DMX_BUILD_LNX_FALSE DMX_BUILD_USB_TRUE DMX_BUILD_USB_FALSE XVFB_TRUE XVFB_FALSE XVFB_LIBS XNESTMODULES_CFLAGS XNESTMODULES_LIBS XNEST_TRUE XNEST_FALSE XNEST_LIBS XGLMODULES_CFLAGS XGLMODULES_LIBS XGL_TRUE XGL_FALSE XGL_LIBS xglmoduledir XGL_MODULE_PATH XEGLMODULES_CFLAGS XEGLMODULES_LIBS XEGL_TRUE XEGL_FALSE XEGL_LIBS XGLXMODULES_CFLAGS XGLXMODULES_LIBS XGLX_TRUE XGLX_FALSE XGLX_LIBS XORG_CORE_LIBS SOLARIS_INOUT_ARCH SOLARIS_ASM_CFLAGS XORG_LIBS XORG_INCS XORG_OS XORG_OS_SUBDIR XORG_OS_KBD PERL XORG_CFLAGS LD_EXPORT_SYMBOLS_FLAG __XCONFIGFILE__ XF86CONFIGFILE DEFAULT_MODULE_PATH DEFAULT_LOGPREFIX moduledir driverdir sdkdir extdir logdir XORG_TRUE XORG_FALSE XORG_BUS_LINUXPCI_TRUE XORG_BUS_LINUXPCI_FALSE XORG_BUS_FREEBSDPCI_TRUE XORG_BUS_FREEBSDPCI_FALSE XORG_BUS_NETBSDPCI_TRUE XORG_BUS_NETBSDPCI_FALSE XORG_BUS_IX86PCI_TRUE XORG_BUS_IX86PCI_FALSE XORG_BUS_PPCPCI_TRUE XORG_BUS_PPCPCI_FALSE XORG_BUS_SPARCPCI_TRUE XORG_BUS_SPARCPCI_FALSE XORG_BUS_SPARC_TRUE XORG_BUS_SPARC_FALSE XORG_LOADER_SPARC_TRUE XORG_LOADER_SPARC_FALSE LINUX_IA64_TRUE LINUX_IA64_FALSE LINUX_ALPHA_TRUE LINUX_ALPHA_FALSE LNXACPI_TRUE LNXACPI_FALSE SOLARIS_USL_CONSOLE_TRUE SOLARIS_USL_CONSOLE_FALSE SOLARIS_ASM_INLINE_TRUE SOLARIS_ASM_INLINE_FALSE MFB_TRUE MFB_FALSE CFB_TRUE CFB_FALSE AFB_TRUE AFB_FALSE XPRINT_CFLAGS XPRINT_LIBS xpconfigdir MKFONTSCALE MKFONTDIR FREETYPE_CFLAGS FREETYPE_LIBS ft_config FREETYPE_REQUIRES XP_USE_FREETYPE_TRUE XP_USE_FREETYPE_FALSE XWIN_LIBS XWINMODULES_CFLAGS XWINMODULES_LIBS XWIN_SERVER_NAME XWIN_SYSTEM_LIBS XWIN_TRUE XWIN_FALSE XWIN_MULTIWINDOW_TRUE XWIN_MULTIWINDOW_FALSE XWIN_MULTIWINDOWEXTWM_TRUE XWIN_MULTIWINDOWEXTWM_FALSE XWIN_CLIPBOARD_TRUE XWIN_CLIPBOARD_FALSE XWIN_GLX_WINDOWS_TRUE XWIN_GLX_WINDOWS_FALSE XWIN_NATIVEGDI_TRUE XWIN_NATIVEGDI_FALSE XWIN_PRIMARYFB_TRUE XWIN_PRIMARYFB_FALSE XWIN_RANDR_TRUE XWIN_RANDR_FALSE XWIN_XV_TRUE XWIN_XV_FALSE KDRIVE_TRUE KDRIVE_FALSE TSLIB_CFLAGS TSLIB_LIBS XEPHYR_CFLAGS XEPHYR_LIBS KDRIVE_INCS KDRIVE_PURE_INCS KDRIVE_CFLAGS KDRIVE_PURE_LIBS KDRIVE_LIBS TSLIB_TRUE TSLIB_FALSE H3600_TS_TRUE H3600_TS_FALSE KDRIVEVESA_TRUE KDRIVEVESA_FALSE KDRIVEFBDEV_TRUE KDRIVEFBDEV_FALSE XEPHYR_TRUE XEPHYR_FALSE XEPHYR_INCS XSDLSERVER_TRUE XSDLSERVER_FALSE XSDL_LIBS XSDL_INCS XKB_BASE_DIRECTORY XKB_BIN_DIRECTORY XKM_OUTPUT_DIR XKB_COMPILED_DIR PROJECTROOT XORGCONFIG_DEP_CFLAGS XORGCONFIG_DEP_LIBS XORGCFG_DEP_CFLAGS XORGCFG_DEP_LIBS APPDEFAULTDIR BUILD_XORGCFG_TRUE BUILD_XORGCFG_FALSE USE_CURSES_TRUE USE_CURSES_FALSE BUILD_KBD_MODE_TRUE BUILD_KBD_MODE_FALSE BSD_KBD_MODE_TRUE BSD_KBD_MODE_FALSE SUN_KBD_MODE_TRUE SUN_KBD_MODE_FALSE BUILD_DATE DIX_CFLAGS libdir exec_prefix prefix APP_MAN_SUFFIX LIB_MAN_SUFFIX FILE_MAN_SUFFIX MISC_MAN_SUFFIX DRIVER_MAN_SUFFIX ADMIN_MAN_SUFFIX APP_MAN_DIR LIB_MAN_DIR FILE_MAN_DIR MISC_MAN_DIR DRIVER_MAN_DIR ADMIN_MAN_DIR LIBOBJS LTLIBOBJS' +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CCAS CCASFLAGS LN_S build build_cpu build_vendor build_os host host_cpu host_vendor host_os EGREP ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB DLLTOOL ac_ct_DLLTOOL AS ac_ct_AS OBJDUMP ac_ct_OBJDUMP CPP CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL PKG_CONFIG ac_pt_PKG_CONFIG LEX LEXLIB LEX_OUTPUT_ROOT YACC RAWCPP RAWCPPFLAGS ALLOCA NEED_STRLCAT_TRUE NEED_STRLCAT_FALSE NEED_VSNPRINTF_TRUE NEED_VSNPRINTF_FALSE AGP_TRUE AGP_FALSE LNXAPM_TRUE LNXAPM_FALSE FBDEVHW_TRUE FBDEVHW_FALSE FREEBSD_KLDLOAD_TRUE FREEBSD_KLDLOAD_FALSE ALPHA_VIDEO_TRUE ALPHA_VIDEO_FALSE ARM_VIDEO_TRUE ARM_VIDEO_FALSE HP300_VIDEO_TRUE HP300_VIDEO_FALSE HPPA_VIDEO_TRUE HPPA_VIDEO_FALSE I386_VIDEO_TRUE I386_VIDEO_FALSE PPC_VIDEO_TRUE PPC_VIDEO_FALSE SPARC64_VIDEO_TRUE SPARC64_VIDEO_FALSE KDRIVE_HW_TRUE KDRIVE_HW_FALSE MMX_CAPABLE_TRUE MMX_CAPABLE_FALSE X_PRIVSEP_TRUE X_PRIVSEP_FALSE INSTALL_SETUID_TRUE INSTALL_SETUID_FALSE INT10_VM86_TRUE INT10_VM86_FALSE INT10_X86EMU_TRUE INT10_X86EMU_FALSE INT10_STUB_TRUE INT10_STUB_FALSE BUILDDOCS_TRUE BUILDDOCS_FALSE LINUXDOC PS2PDF BUILD_LINUXDOC_TRUE BUILD_LINUXDOC_FALSE BUILD_PDFDOC_TRUE BUILD_PDFDOC_FALSE MAKE_TEXT MAKE_PS MAKE_PDF MAKE_HTML INSTALL_LIBXF86CONFIG_TRUE INSTALL_LIBXF86CONFIG_FALSE XV_TRUE XV_FALSE XVMC_TRUE XVMC_FALSE DGA_TRUE DGA_FALSE COMPOSITE_TRUE COMPOSITE_FALSE MITSHM_TRUE MITSHM_FALSE XTRAP_TRUE XTRAP_FALSE RECORD_TRUE RECORD_FALSE SCREENSAVER_TRUE SCREENSAVER_FALSE RES_TRUE RES_FALSE XLIB_CFLAGS XLIB_LIBS GL_CFLAGS GL_LIBS GLX_TRUE GLX_FALSE MESA_SOURCE AIGLX_TRUE AIGLX_FALSE GLX_DEFINES DRI_TRUE DRI_FALSE DRIPROTO_CFLAGS DRIPROTO_LIBS LIBDRM_CFLAGS LIBDRM_LIBS XINERAMA_TRUE XINERAMA_FALSE XACE_TRUE XACE_FALSE XCSECURITY_TRUE XCSECURITY_FALSE XEVIE_TRUE XEVIE_FALSE APPGROUP_TRUE APPGROUP_FALSE CUP_TRUE CUP_FALSE EVI_TRUE EVI_FALSE MULTIBUFFER_TRUE MULTIBUFFER_FALSE FONTCACHE_TRUE FONTCACHE_FALSE DBE_TRUE DBE_FALSE XF86BIGFONT_TRUE XF86BIGFONT_FALSE DPMSExtension_TRUE DPMSExtension_FALSE XPRINTPROTO_CFLAGS XPRINTPROTO_LIBS XPRINT_TRUE XPRINT_FALSE XCALIBRATE_TRUE XCALIBRATE_FALSE XINPUT_TRUE XINPUT_FALSE XF86UTILS_TRUE XF86UTILS_FALSE XDMCP_CFLAGS XDMCP_LIBS XDMCP_TRUE XDMCP_FALSE XDMAUTH_TRUE XDMAUTH_FALSE USE_RGB_BUILTIN_TRUE USE_RGB_BUILTIN_FALSE COMPILEDDEFAULTFONTPATH RGB_DB BASE_FONT_PATH DRI_DRIVER_PATH VENDOR_STRING VENDOR_STRING_SHORT VENDOR_RELEASE VENDOR_MAN_VERSION DEBUG_TRUE DEBUG_FALSE XSERVERCFLAGS_CFLAGS XSERVERCFLAGS_LIBS XSERVERLIBS_CFLAGS XSERVERLIBS_LIBS SYS_LIBS XSERVER_LIBS DMXMODULES_CFLAGS DMXMODULES_LIBS DMX_TRUE DMX_FALSE XDMX_LIBS XDMXCONFIG_DEP_CFLAGS XDMXCONFIG_DEP_LIBS DMXEXAMPLES_DEP_CFLAGS DMXEXAMPLES_DEP_LIBS DMXXMUEXAMPLES_DEP_CFLAGS DMXXMUEXAMPLES_DEP_LIBS DMXXIEXAMPLES_DEP_CFLAGS DMXXIEXAMPLES_DEP_LIBS XTSTEXAMPLES_DEP_CFLAGS XTSTEXAMPLES_DEP_LIBS XRESEXAMPLES_DEP_CFLAGS XRESEXAMPLES_DEP_LIBS X11EXAMPLES_DEP_CFLAGS X11EXAMPLES_DEP_LIBS DMX_BUILD_LNX_TRUE DMX_BUILD_LNX_FALSE DMX_BUILD_USB_TRUE DMX_BUILD_USB_FALSE XVFB_TRUE XVFB_FALSE XVFB_LIBS XNESTMODULES_CFLAGS XNESTMODULES_LIBS XNEST_TRUE XNEST_FALSE XNEST_LIBS XGLMODULES_CFLAGS XGLMODULES_LIBS XGL_TRUE XGL_FALSE XGL_LIBS xglmoduledir XGL_MODULE_PATH XEGLMODULES_CFLAGS XEGLMODULES_LIBS XEGL_TRUE XEGL_FALSE XEGL_LIBS XGLXMODULES_CFLAGS XGLXMODULES_LIBS XGLX_TRUE XGLX_FALSE XGLX_LIBS XORG_CORE_LIBS SOLARIS_INOUT_ARCH SOLARIS_ASM_CFLAGS XORG_LIBS XORG_INCS XORG_OS XORG_OS_SUBDIR XORG_OS_KBD PERL XORG_CFLAGS LD_EXPORT_SYMBOLS_FLAG __XCONFIGFILE__ XF86CONFIGFILE DEFAULT_MODULE_PATH DEFAULT_LOGPREFIX moduledir driverdir sdkdir extdir logdir XORG_TRUE XORG_FALSE XORG_BUS_LINUXPCI_TRUE XORG_BUS_LINUXPCI_FALSE XORG_BUS_FREEBSDPCI_TRUE XORG_BUS_FREEBSDPCI_FALSE XORG_BUS_NETBSDPCI_TRUE XORG_BUS_NETBSDPCI_FALSE XORG_BUS_IX86PCI_TRUE XORG_BUS_IX86PCI_FALSE XORG_BUS_PPCPCI_TRUE XORG_BUS_PPCPCI_FALSE XORG_BUS_SPARCPCI_TRUE XORG_BUS_SPARCPCI_FALSE XORG_BUS_SPARC_TRUE XORG_BUS_SPARC_FALSE XORG_LOADER_SPARC_TRUE XORG_LOADER_SPARC_FALSE LINUX_IA64_TRUE LINUX_IA64_FALSE LINUX_ALPHA_TRUE LINUX_ALPHA_FALSE LNXACPI_TRUE LNXACPI_FALSE SOLARIS_USL_CONSOLE_TRUE SOLARIS_USL_CONSOLE_FALSE SOLARIS_ASM_INLINE_TRUE SOLARIS_ASM_INLINE_FALSE MFB_TRUE MFB_FALSE CFB_TRUE CFB_FALSE AFB_TRUE AFB_FALSE XPRINT_CFLAGS XPRINT_LIBS xpconfigdir MKFONTSCALE MKFONTDIR FREETYPE_CFLAGS FREETYPE_LIBS ft_config FREETYPE_REQUIRES XP_USE_FREETYPE_TRUE XP_USE_FREETYPE_FALSE XWIN_LIBS XWINMODULES_CFLAGS XWINMODULES_LIBS XWIN_SERVER_NAME XWIN_SYSTEM_LIBS XWIN_TRUE XWIN_FALSE XWIN_MULTIWINDOW_TRUE XWIN_MULTIWINDOW_FALSE XWIN_MULTIWINDOWEXTWM_TRUE XWIN_MULTIWINDOWEXTWM_FALSE XWIN_CLIPBOARD_TRUE XWIN_CLIPBOARD_FALSE XWIN_GLX_WINDOWS_TRUE XWIN_GLX_WINDOWS_FALSE XWIN_NATIVEGDI_TRUE XWIN_NATIVEGDI_FALSE XWIN_PRIMARYFB_TRUE XWIN_PRIMARYFB_FALSE XWIN_RANDR_TRUE XWIN_RANDR_FALSE XWIN_XV_TRUE XWIN_XV_FALSE KDRIVE_TRUE KDRIVE_FALSE TSLIB_CFLAGS TSLIB_LIBS XEPHYR_CFLAGS XEPHYR_LIBS KDRIVE_INCS KDRIVE_PURE_INCS KDRIVE_CFLAGS KDRIVE_PURE_LIBS KDRIVE_LIBS TSLIB_TRUE TSLIB_FALSE H3600_TS_TRUE H3600_TS_FALSE KDRIVEVESA_TRUE KDRIVEVESA_FALSE KDRIVEFBDEV_TRUE KDRIVEFBDEV_FALSE XEPHYR_TRUE XEPHYR_FALSE XEPHYR_INCS XSDLSERVER_TRUE XSDLSERVER_FALSE XSDL_LIBS XSDL_INCS XKB_BASE_DIRECTORY XKB_BIN_DIRECTORY XKM_OUTPUT_DIR XKB_COMPILED_DIR PROJECTROOT XORGCONFIG_DEP_CFLAGS XORGCONFIG_DEP_LIBS XORGCFG_DEP_CFLAGS XORGCFG_DEP_LIBS APPDEFAULTDIR BUILD_XORGCFG_TRUE BUILD_XORGCFG_FALSE USE_CURSES_TRUE USE_CURSES_FALSE BUILD_KBD_MODE_TRUE BUILD_KBD_MODE_FALSE BSD_KBD_MODE_TRUE BSD_KBD_MODE_FALSE SUN_KBD_MODE_TRUE SUN_KBD_MODE_FALSE BUILD_DATE DIX_CFLAGS libdir exec_prefix prefix APP_MAN_SUFFIX LIB_MAN_SUFFIX FILE_MAN_SUFFIX MISC_MAN_SUFFIX DRIVER_MAN_SUFFIX ADMIN_MAN_SUFFIX APP_MAN_DIR LIB_MAN_DIR FILE_MAN_DIR MISC_MAN_DIR DRIVER_MAN_DIR ADMIN_MAN_DIR LIBOBJS LTLIBOBJS' ac_subst_files='' # Initialize some variables set by options. @@ -1263,6 +1263,8 @@ Optional Features: --enable-builddocs Build docs (default: disabled) --enable-install-libxf86config Install libxf86config (default: disabled) + --enable-privsep Build support for X server privilege separation + (default is NO) --disable-composite Build Composite extension (default: enabled) --disable-shm Build SHM extension (default: enabled) --disable-xres Build XRes extension (default: enabled) @@ -4226,7 +4228,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 4229 "configure"' > conftest.$ac_ext + echo '#line 4231 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -6067,7 +6069,7 @@ fi # Provide some information about the compiler. -echo "$as_me:6070:" \ +echo "$as_me:6072:" \ "checking for Fortran 77 compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5 @@ -7130,11 +7132,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7133: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7135: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7137: \$? = $ac_status" >&5 + echo "$as_me:7139: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7398,11 +7400,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7401: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7403: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7405: \$? = $ac_status" >&5 + echo "$as_me:7407: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7502,11 +7504,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7505: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7507: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7509: \$? = $ac_status" >&5 + echo "$as_me:7511: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -9847,7 +9849,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<EOF -#line 9850 "configure" +#line 9852 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -9947,7 +9949,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<EOF -#line 9950 "configure" +#line 9952 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12287,11 +12289,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:12290: $lt_compile\"" >&5) + (eval echo "\"\$as_me:12292: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:12294: \$? = $ac_status" >&5 + echo "$as_me:12296: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -12391,11 +12393,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:12394: $lt_compile\"" >&5) + (eval echo "\"\$as_me:12396: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:12398: \$? = $ac_status" >&5 + echo "$as_me:12400: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -13961,11 +13963,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:13964: $lt_compile\"" >&5) + (eval echo "\"\$as_me:13966: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:13968: \$? = $ac_status" >&5 + echo "$as_me:13970: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -14065,11 +14067,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14068: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14070: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:14072: \$? = $ac_status" >&5 + echo "$as_me:14074: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -16268,11 +16270,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16271: $lt_compile\"" >&5) + (eval echo "\"\$as_me:16273: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:16275: \$? = $ac_status" >&5 + echo "$as_me:16277: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -16536,11 +16538,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16539: $lt_compile\"" >&5) + (eval echo "\"\$as_me:16541: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:16543: \$? = $ac_status" >&5 + echo "$as_me:16545: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -16640,11 +16642,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16643: $lt_compile\"" >&5) + (eval echo "\"\$as_me:16645: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:16647: \$? = $ac_status" >&5 + echo "$as_me:16649: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -24274,6 +24276,26 @@ fi +if text "x$HP300_VIDEO" = xyes; then + HP300_VIDEO_TRUE= + HP300_VIDEO_FALSE='#' +else + HP300_VIDEO_TRUE='#' + HP300_VIDEO_FALSE= +fi + + + +if text "x$HPPA_VIDEO" = xyes; then + HPPA_VIDEO_TRUE= + HPPA_VIDEO_FALSE='#' +else + HPPA_VIDEO_TRUE='#' + HPPA_VIDEO_FALSE= +fi + + + if test "x$I386_VIDEO" = xyes; then I386_VIDEO_TRUE= I386_VIDEO_FALSE='#' @@ -24650,6 +24672,31 @@ else INSTALL_LIBXF86CONFIG=no fi; +# Check whether --enable-privsep or --disable-privsep was given. +if test "${enable_privsep+set}" = set; then + enableval="$enable_privsep" + ENABLE_PRIVSEP="$enableval" +else + ENABLE_PRIVSEP="no" +fi; +if test x$ENABLE_PRIVSEP = xyes ; then + +cat >>confdefs.h <<\_ACEOF +#define X_PRIVSEP 1 +_ACEOF + +fi + + +if test x$ENABLE_PRIVSEP = xyes; then + X_PRIVSEP_TRUE= + X_PRIVSEP_FALSE='#' +else + X_PRIVSEP_TRUE='#' + X_PRIVSEP_FALSE= +fi + + # Check whether --enable-composite or --disable-composite was given. if test "${enable_composite+set}" = set; then enableval="$enable_composite" @@ -30025,7 +30072,7 @@ _ACEOF XORG_OS_SUBDIR="bsd" XORG_OS_KBD="BSD" case $host_cpu in - i*86|amd64*|x86_64*|ia64*) + i*86|amd64*|x86_64*) ;; *) xorg_bus_freebsdpci="yes" @@ -30247,7 +30294,14 @@ echo "$as_me: error: Your OS is unknown. Xorg currently only supports Linux, \ ;; sparc*) xorg_bus_sparcpci="yes" - xorg_bus_sparc="yes" + case $host_os in + openbsd*) + xorg_bus_sparc="no" + ;; + *) + xorg_bus_sparc="yes" + ;; + esac ;; x86_64*|amd64*) case $host_os in @@ -33014,6 +33068,20 @@ echo "$as_me: error: conditional \"ARM_VIDEO\" was never defined. Usually this means the macro was only invoked conditionally." >&2;} { (exit 1); exit 1; }; } fi +if test -z "${HP300_VIDEO_TRUE}" && test -z "${HP300_VIDEO_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"HP300_VIDEO\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"HP300_VIDEO\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${HPPA_VIDEO_TRUE}" && test -z "${HPPA_VIDEO_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"HPPA_VIDEO\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"HPPA_VIDEO\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi if test -z "${I386_VIDEO_TRUE}" && test -z "${I386_VIDEO_FALSE}"; then { { echo "$as_me:$LINENO: error: conditional \"I386_VIDEO\" was never defined. Usually this means the macro was only invoked conditionally." >&5 @@ -33049,6 +33117,13 @@ echo "$as_me: error: conditional \"MMX_CAPABLE\" was never defined. Usually this means the macro was only invoked conditionally." >&2;} { (exit 1); exit 1; }; } fi +if test -z "${X_PRIVSEP_TRUE}" && test -z "${X_PRIVSEP_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"X_PRIVSEP\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"X_PRIVSEP\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi if test -z "${INSTALL_SETUID_TRUE}" && test -z "${INSTALL_SETUID_FALSE}"; then { { echo "$as_me:$LINENO: error: conditional \"INSTALL_SETUID\" was never defined. Usually this means the macro was only invoked conditionally." >&5 @@ -34466,6 +34541,10 @@ s,@ALPHA_VIDEO_TRUE@,$ALPHA_VIDEO_TRUE,;t t s,@ALPHA_VIDEO_FALSE@,$ALPHA_VIDEO_FALSE,;t t s,@ARM_VIDEO_TRUE@,$ARM_VIDEO_TRUE,;t t s,@ARM_VIDEO_FALSE@,$ARM_VIDEO_FALSE,;t t +s,@HP300_VIDEO_TRUE@,$HP300_VIDEO_TRUE,;t t +s,@HP300_VIDEO_FALSE@,$HP300_VIDEO_FALSE,;t t +s,@HPPA_VIDEO_TRUE@,$HPPA_VIDEO_TRUE,;t t +s,@HPPA_VIDEO_FALSE@,$HPPA_VIDEO_FALSE,;t t s,@I386_VIDEO_TRUE@,$I386_VIDEO_TRUE,;t t s,@I386_VIDEO_FALSE@,$I386_VIDEO_FALSE,;t t s,@PPC_VIDEO_TRUE@,$PPC_VIDEO_TRUE,;t t @@ -34476,6 +34555,8 @@ s,@KDRIVE_HW_TRUE@,$KDRIVE_HW_TRUE,;t t s,@KDRIVE_HW_FALSE@,$KDRIVE_HW_FALSE,;t t s,@MMX_CAPABLE_TRUE@,$MMX_CAPABLE_TRUE,;t t s,@MMX_CAPABLE_FALSE@,$MMX_CAPABLE_FALSE,;t t +s,@X_PRIVSEP_TRUE@,$X_PRIVSEP_TRUE,;t t +s,@X_PRIVSEP_FALSE@,$X_PRIVSEP_FALSE,;t t s,@INSTALL_SETUID_TRUE@,$INSTALL_SETUID_TRUE,;t t s,@INSTALL_SETUID_FALSE@,$INSTALL_SETUID_FALSE,;t t s,@INT10_VM86_TRUE@,$INT10_VM86_TRUE,;t t diff --git a/xserver/configure.ac b/xserver/configure.ac index 128130df5..134c4b50e 100644 --- a/xserver/configure.ac +++ b/xserver/configure.ac @@ -1,4 +1,4 @@ -dnl $Id: configure.ac,v 1.1 2006/11/26 18:13:43 matthieu Exp $ +dnl $Id: configure.ac,v 1.2 2006/11/28 20:29:31 matthieu Exp $ dnl dnl Copyright © 2003-2005 Keith Packard, Daniel Stone dnl @@ -241,6 +241,8 @@ esac dnl BSD *_video.c selection AM_CONDITIONAL(ALPHA_VIDEO, [test "x$ALPHA_VIDEO" = xyes]) AM_CONDITIONAL(ARM_VIDEO, [test "x$ARM_VIDEO" = xyes]) +AM_CONDITIONAL(HP300_VIDEO, [text "x$HP300_VIDEO" = xyes]) +AM_CONDITIONAL(HPPA_VIDEO, [text "x$HPPA_VIDEO" = xyes]) AM_CONDITIONAL(I386_VIDEO, [test "x$I386_VIDEO" = xyes]) AM_CONDITIONAL(PPC_VIDEO, [test "x$PPC_VIDEO" = xyes]) AM_CONDITIONAL(SPARC64_VIDEO, [test "x$SPARC64_VIDEO" = xyes]) @@ -395,6 +397,16 @@ AC_ARG_ENABLE(install-libxf86config, [INSTALL_LIBXF86CONFIG=$enableval], [INSTALL_LIBXF86CONFIG=no]) +dnl Privsep +AC_ARG_ENABLE(privsep, + AC_HELP_STRING([--enable-privsep], + [Build support for X server privilege separation (default is NO)]), + [ENABLE_PRIVSEP="$enableval"], [ENABLE_PRIVSEP="no"]) +if test x$ENABLE_PRIVSEP = xyes ; then + AC_DEFINE(X_PRIVSEP, 1, [Use X server privilege separation]) +fi +AM_CONDITIONAL(X_PRIVSEP, [test x$ENABLE_PRIVSEP = xyes]) + dnl Extensions. AC_ARG_ENABLE(composite, AS_HELP_STRING([--disable-composite], [Build Composite extension (default: enabled)]), [COMPOSITE=$enableval], [COMPOSITE=yes]) AC_ARG_ENABLE(mitshm, AS_HELP_STRING([--disable-shm], [Build SHM extension (default: enabled)]), [MITSHM=$enableval], [MITSHM=yes]) @@ -1173,7 +1185,7 @@ int main () { XORG_OS_SUBDIR="bsd" XORG_OS_KBD="BSD" case $host_cpu in - i*86|amd64*|x86_64*|ia64*) + i*86|amd64*|x86_64*) ;; *) xorg_bus_freebsdpci="yes" @@ -1257,7 +1269,14 @@ int main () { ;; sparc*) xorg_bus_sparcpci="yes" - xorg_bus_sparc="yes" + case $host_os in + openbsd*) + xorg_bus_sparc="no" + ;; + *) + xorg_bus_sparc="yes" + ;; + esac ;; x86_64*|amd64*) case $host_os in diff --git a/xserver/dix/devices.c b/xserver/dix/devices.c index 607510203..2205d8436 100644 --- a/xserver/dix/devices.c +++ b/xserver/dix/devices.c @@ -368,8 +368,10 @@ RegisterPointerDevice(DeviceIntPtr device) if (!device->name) { char *p = "pointer"; - device->name = (char *)xalloc(strlen(p) + 1); - strcpy(device->name, p); + size_t buflen = strlen(p) + 1; + + device->name = (char *)xalloc(buflen); + strlcpy(device->name, p, buflen); } } @@ -391,8 +393,9 @@ RegisterKeyboardDevice(DeviceIntPtr device) if (!device->name) { char *k = "keyboard"; - device->name = (char *)xalloc(strlen(k) + 1); - strcpy(device->name, k); + size_t buflen = strlen(k) + 1; + device->name = (char *)xalloc(buflen); + strlcpy(device->name, k, buflen); } } diff --git a/xserver/dix/extension.c b/xserver/dix/extension.c index f58c73138..068d84e0e 100644 --- a/xserver/dix/extension.c +++ b/xserver/dix/extension.c @@ -118,6 +118,7 @@ AddExtension(char *name, int NumEvents, int NumErrors, { int i; register ExtensionEntry *ext, **newexts; + size_t buflen; if (!MainProc || !SwappedMainProc || !CloseDownProc || !MinorOpcodeProc) return((ExtensionEntry *) NULL); @@ -130,7 +131,8 @@ AddExtension(char *name, int NumEvents, int NumErrors, return((ExtensionEntry *) NULL); bzero(ext, totalExtensionSize); InitExtensionPrivates(ext); - ext->name = (char *)xalloc(strlen(name) + 1); + buflen = strlen(name) + 1; + ext->name = (char *)xalloc(buflen); ext->num_aliases = 0; ext->aliases = (char **)NULL; if (!ext->name) @@ -138,7 +140,7 @@ AddExtension(char *name, int NumEvents, int NumErrors, xfree(ext); return((ExtensionEntry *) NULL); } - strcpy(ext->name, name); + strlcpy(ext->name, name, buflen); i = NumExtensions; newexts = (ExtensionEntry **) xrealloc(extensions, (i + 1) * sizeof(ExtensionEntry *)); @@ -187,16 +189,18 @@ _X_EXPORT Bool AddExtensionAlias(char *alias, ExtensionEntry *ext) { char *name; char **aliases; + size_t buflen; aliases = (char **)xrealloc(ext->aliases, (ext->num_aliases + 1) * sizeof(char *)); if (!aliases) return FALSE; ext->aliases = aliases; - name = (char *)xalloc(strlen(alias) + 1); + buflen = strlen(alias) + 1; + name = (char *)xalloc(buflen); if (!name) return FALSE; - strcpy(name, alias); + strlcpy(name, alias, buflen); ext->aliases[ext->num_aliases] = name; ext->num_aliases++; return TRUE; @@ -445,6 +449,7 @@ RegisterScreenProc(char *name, ScreenPtr pScreen, ExtensionLookupProc proc) register ScreenProcEntry *spentry; register ProcEntryPtr procEntry = (ProcEntryPtr)NULL; char *newname; + size_t buflen; int i; spentry = &AuxillaryScreenProcs[pScreen->myNum]; @@ -462,7 +467,8 @@ RegisterScreenProc(char *name, ScreenPtr pScreen, ExtensionLookupProc proc) procEntry->proc = proc; else { - newname = (char *)xalloc(strlen(name)+1); + buflen = strlen(name)+1; + newname = (char *)xalloc(buflen); if (!newname) return FALSE; procEntry = (ProcEntryPtr) @@ -476,7 +482,7 @@ RegisterScreenProc(char *name, ScreenPtr pScreen, ExtensionLookupProc proc) spentry->procList = procEntry; procEntry += spentry->num; procEntry->name = newname; - strcpy(newname, name); + strlcpy(newname, name, buflen); procEntry->proc = proc; spentry->num++; } diff --git a/xserver/hw/xfree86/common/compiler.h b/xserver/hw/xfree86/common/compiler.h index a330fadf4..e9472201b 100644 --- a/xserver/hw/xfree86/common/compiler.h +++ b/xserver/hw/xfree86/common/compiler.h @@ -387,7 +387,12 @@ static __inline__ void stw_u(unsigned long r5, unsigned short * r11) } /* to flush the I-cache before jumping to code which just got loaded */ +#ifdef __FreeBSD__ # define PAL_imb 134 +#endif +#ifdef __OpenBSD__ +#include <machine/pal.h> +#endif # define istream_mem_barrier() \ __asm__ __volatile__("call_pal %0 #imb" : : "i" (PAL_imb) : "memory") # define mem_barrier() __asm__ __volatile__("mb" : : : "memory") @@ -906,6 +911,13 @@ static __inline__ void stw_u(unsigned long val, unsigned short *p) # else # define PORT_SIZE short # endif +# if defined(__arm32__) && defined(__OpenBSD__) +/* +# include <machine/sysarch.h> +*/ + int arm_sync_icache(long addr, int len); +# define arm_flush_cache(addr) arm_sync_icache((long)(addr), 4); +# endif unsigned int IOPortBase; /* Memory mapped I/O port area */ @@ -1365,7 +1377,7 @@ do { \ # define write_mem_barrier() /* NOP */ # if !defined(__SUNPRO_C) -# if !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) +# if !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__vax__) # ifdef GCCUSESGAS /* @@ -1474,7 +1486,7 @@ inl(unsigned short port) # endif /* GCCUSESGAS */ -# else /* !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__)*/ +# else /* !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__vax__) */ static __inline__ void outb(unsigned short port, unsigned char val) diff --git a/xserver/hw/xfree86/common/xf86Config.c b/xserver/hw/xfree86/common/xf86Config.c index f1055928e..c050def4e 100644 --- a/xserver/hw/xfree86/common/xf86Config.c +++ b/xserver/hw/xfree86/common/xf86Config.c @@ -1220,7 +1220,11 @@ configInputKbd(IDevPtr inputp) " the \"wskbd\" keyboard protocol"); return FALSE; } +#ifndef X_PRIVSEP xf86Info.kbdFd = open(s, O_RDWR | O_NONBLOCK | O_EXCL); +#else + xf86Info.kbdFd = priv_open_device(s); +#endif if (xf86Info.kbdFd == -1) { xf86ConfigError("cannot open \"%s\"", s); xfree(s); @@ -1264,7 +1268,8 @@ configInputKbd(IDevPtr inputp) close(xf86Info.kbdFd); return FALSE; } -#endif + close (xf86Info.kbdFd); +#endif /* WSCONS_SUPPORT */ } else { xf86ConfigError("\"%s\" is not a valid keyboard protocol name", s); xfree(s); diff --git a/xserver/hw/xfree86/common/xf86Events.c b/xserver/hw/xfree86/common/xf86Events.c index b1ee1e93e..4769daeb8 100644 --- a/xserver/hw/xfree86/common/xf86Events.c +++ b/xserver/hw/xfree86/common/xf86Events.c @@ -511,6 +511,7 @@ xf86PostKbdEvent(unsigned key) } } else #endif /* i386 && SVR4 */ +#ifndef __OpenBSD__ { switch (scanCode) { case 0x59: scanCode = KEY_0x59; break; @@ -543,6 +544,7 @@ xf86PostKbdEvent(unsigned key) case 0x76: scanCode = KEY_0x76; break; } } +#endif } else if ( diff --git a/xserver/hw/xfree86/common/xf86Init.c b/xserver/hw/xfree86/common/xf86Init.c index 8f0a26dd7..6a9d2f38d 100644 --- a/xserver/hw/xfree86/common/xf86Init.c +++ b/xserver/hw/xfree86/common/xf86Init.c @@ -147,6 +147,10 @@ static InputDriverRec XF86KEYBOARD = { }; #endif +#ifdef X_PRIVSEP +static Bool xf86KeepPriv = FALSE; +#endif + static Bool xf86CreateRootWindow(WindowPtr pWin) { @@ -1139,9 +1143,14 @@ InitInput(argc, argv) * OS/Vendor-specific initialisations. Called from OsInit(), which * is called by dix before establishing the well known sockets. */ + +#ifdef X_PRIVSEP +extern void xf86DropPriv(char *); +extern void xf86PrivilegedInit(void); +#endif void -OsVendorInit() +OsVendorInit(void) { static Bool beenHere = FALSE; @@ -1182,6 +1191,12 @@ OsVendorInit() } #endif #endif +#if defined(X_PRIVSEP) + if (!beenHere && !xf86KeepPriv && geteuid() == 0) { + xf86PrivilegedInit(); + xf86DropPriv(display); + } +#endif beenHere = TRUE; } @@ -1349,8 +1364,9 @@ ddxProcessArgument(int argc, char **argv, int i) FatalError("Required argument to %s not specified\n", argv[i]); \ } - /* First the options that are only allowed for root */ - if (getuid() == 0 || geteuid() != 0) + /* First the options that are only allowed for root + or when the program is not privileged at all */ + if (getuid() == 0 || !issetugid()) { if (!strcmp(argv[i], "-modulepath")) { @@ -1390,6 +1406,11 @@ ddxProcessArgument(int argc, char **argv, int i) argv[i], argv[i]); } xf86ConfigFile = argv[i + 1]; +#ifdef X_PRIVSEP + /* Cannot drop privs when -xf86config is used with unsafe path */ + if (!xf86PathIsSafe(xf86ConfigFile)) + xf86KeepPriv = TRUE; +#endif return 2; } if (!strcmp(argv[i],"-showunresolved")) @@ -1646,18 +1667,35 @@ ddxProcessArgument(int argc, char **argv, int i) if (!strcmp(argv[i], "-probe")) { xf86DoProbe = TRUE; +#if 0 + DoProbe(argc, argv, i); +#endif return 1; } if (!strcmp(argv[i], "-configure")) { - if (getuid() != 0 && geteuid() == 0) { + if (getuid() != 0 && issetugid()) { ErrorF("The '-configure' option can only be used by root.\n"); exit(1); } xf86DoConfigure = TRUE; xf86AllowMouseOpenFail = TRUE; +#ifdef X_PRIVSEP + xf86KeepPriv = TRUE; +#endif return 1; } +#ifdef X_PRIVSEP + if (!strcmp(argv[i], "-keepPriv")) + { + if (getuid() != 0) { + ErrorF("The '-keepPriv' option can only be used by root.\n"); + exit(1); + } + xf86KeepPriv = TRUE; + return 1; + } +#endif if (!strcmp(argv[i], "-isolateDevice")) { int bus, device, func; @@ -1737,6 +1775,9 @@ ddxUseMsg() ErrorF("-ignoreABI make module ABI mismatches non-fatal\n"); ErrorF("-isolateDevice bus_id restrict device resets to bus_id (PCI only)\n"); ErrorF("-version show the server version\n"); +#ifdef X_PRIVSEP + ErrorF("-keepPriv don't revoque privs when running as root\n"); +#endif /* OS-specific usage */ xf86UseMsg(); ErrorF("\n"); diff --git a/xserver/hw/xfree86/common/xf86Xinput.c b/xserver/hw/xfree86/common/xf86Xinput.c index c56475b12..ad4fb8112 100644 --- a/xserver/hw/xfree86/common/xf86Xinput.c +++ b/xserver/hw/xfree86/common/xf86Xinput.c @@ -950,7 +950,7 @@ xf86PostMotionEvent(DeviceIntPtr device, } } else if (dx || dy) { - mult = pow((float)(dx*dx+dy*dy), + mult = pow((float)dx*(float)dx + (float)dy*(float)dy, ((float)(device->ptrfeed->ctrl.num) / (float)(device->ptrfeed->ctrl.den) - 1.0) / 2.0) / 2.0; diff --git a/xserver/hw/xfree86/doc/man/Xorg.man.pre b/xserver/hw/xfree86/doc/man/Xorg.man.pre index b7fa990bb..8178043b5 100644 --- a/xserver/hw/xfree86/doc/man/Xorg.man.pre +++ b/xserver/hw/xfree86/doc/man/Xorg.man.pre @@ -270,6 +270,14 @@ is ignored if .I bustype is anything other than \(oqPCI\(cq. .TP 8 +.B \-keepPriv +Prevent the server from revoking its privileges. If this option is +not specified, the X server will change its uid and gid either to +those of the user who started it or to the \fI_x11\fP user and group +if it was started by the super-user, after performing the +initialisations that require super-user privileges. Only root can use +this option. +.TP 8 .B \-keeptty Prevent the server from detaching its initial controlling terminal. This option is only useful when debugging the server. Not all platforms @@ -571,10 +579,10 @@ Libraries. .B __projectroot__/lib/X11/fonts/\(** Fonts. .TP 30 -.B __projectroot__/share/X11/rgb.txt +.B __projectroot__/lib/X11/rgb.txt Color names to RGB mapping. .TP 30 -.B __projectroot__/share/X11/XErrorDB +.B __projectroot__/lib/X11/XErrorDB Client error message database. .TP 30 .B __projectroot__/lib/X11/app-defaults/\(** diff --git a/xserver/hw/xfree86/dummylib/Makefile.am b/xserver/hw/xfree86/dummylib/Makefile.am index d89ee59a8..be48277a1 100644 --- a/xserver/hw/xfree86/dummylib/Makefile.am +++ b/xserver/hw/xfree86/dummylib/Makefile.am @@ -13,11 +13,16 @@ STRL_SRCS = $(top_srcdir)/os/strlcat.c $(top_srcdir)/os/strlcpy.c endif libdummy_nonserver_a_SOURCES = \ + chownlock.c \ + dispatchException.c \ fatalerror.c \ getvalidbios.c \ getemptypci.c \ logvwrite.c \ pcitestmulti.c \ + privsep.c \ + serverGeneration.c \ + useMsg.c \ $(STRL_SRCS) \ verrorf.c \ xalloc.c \ diff --git a/xserver/hw/xfree86/dummylib/chownlock.c b/xserver/hw/xfree86/dummylib/chownlock.c new file mode 100644 index 000000000..f4b01901f --- /dev/null +++ b/xserver/hw/xfree86/dummylib/chownlock.c @@ -0,0 +1,10 @@ +/* + * Public domain + */ +/* $OpenBSD: chownlock.c,v 1.1 2006/11/28 20:29:31 matthieu Exp $ */ +#include <sys/types.h> +int +ChownLock(uid_t uid, gid_t gid) +{ + return 0; +} diff --git a/xserver/hw/xfree86/dummylib/dispatchException.c b/xserver/hw/xfree86/dummylib/dispatchException.c new file mode 100644 index 000000000..6ceb91e84 --- /dev/null +++ b/xserver/hw/xfree86/dummylib/dispatchException.c @@ -0,0 +1,8 @@ +/** + ** Public domain + **/ +/* $OpenBSD: dispatchException.c,v 1.1 2006/11/28 20:29:31 matthieu Exp $ */ + +#include "opaque.h" + +volatile char dispatchException; diff --git a/xserver/hw/xfree86/dummylib/privsep.c b/xserver/hw/xfree86/dummylib/privsep.c new file mode 100644 index 000000000..bb25d6d08 --- /dev/null +++ b/xserver/hw/xfree86/dummylib/privsep.c @@ -0,0 +1,18 @@ +/** + ** Public domain + **/ +/* $OpenBSD: privsep.c,v 1.1 2006/11/28 20:29:31 matthieu Exp $ */ +#include <sys/types.h> +#include <fcntl.h> + +int +priv_init(uid_t uid, gid_t gid) +{ + return 0; +} + +int +priv_open_device(char *path) +{ + return open(path, O_RDWR); +} diff --git a/xserver/hw/xfree86/dummylib/serverGeneration.c b/xserver/hw/xfree86/dummylib/serverGeneration.c new file mode 100644 index 000000000..07982b7bc --- /dev/null +++ b/xserver/hw/xfree86/dummylib/serverGeneration.c @@ -0,0 +1,8 @@ +/** + ** Public domain + **/ +/* $OpenBSD: serverGeneration.c,v 1.1 2006/11/28 20:29:31 matthieu Exp $ */ + +#include "misc.h" + +unsigned long serverGeneration; diff --git a/xserver/hw/xfree86/dummylib/useMsg.c b/xserver/hw/xfree86/dummylib/useMsg.c new file mode 100644 index 000000000..a1ce12cc8 --- /dev/null +++ b/xserver/hw/xfree86/dummylib/useMsg.c @@ -0,0 +1,11 @@ +/** + ** Public Domain + **/ +/* $OpenBSD: useMsg.c,v 1.1 2006/11/28 20:29:31 matthieu Exp $ */ + +#include "os.h" + +void +UseMsg(void) +{ +} diff --git a/xserver/hw/xfree86/dummylib/xalloc.c b/xserver/hw/xfree86/dummylib/xalloc.c index b671d4dde..5a8d5b7d3 100644 --- a/xserver/hw/xfree86/dummylib/xalloc.c +++ b/xserver/hw/xfree86/dummylib/xalloc.c @@ -1,3 +1,4 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/dummylib/xalloc.c,v 1.1 2000/02/13 03:06:39 dawes Exp $ */ #ifdef HAVE_XORG_CONFIG_H #include <xorg-config.h> @@ -12,7 +13,7 @@ * Utility functions required by libxf86_os. */ -_X_EXPORT pointer +pointer Xalloc(unsigned long n) { if (!n) @@ -20,7 +21,7 @@ Xalloc(unsigned long n) return malloc(n); } -_X_EXPORT pointer +pointer Xrealloc(pointer p, unsigned long n) { if (!n) @@ -28,7 +29,7 @@ Xrealloc(pointer p, unsigned long n) return realloc(p, n); } -_X_EXPORT pointer +pointer Xcalloc(unsigned long n) { pointer r; @@ -38,7 +39,7 @@ Xcalloc(unsigned long n) return r; } -_X_EXPORT pointer +pointer XNFalloc(unsigned long n) { pointer r; @@ -50,7 +51,7 @@ XNFalloc(unsigned long n) } -_X_EXPORT pointer +pointer XNFrealloc(pointer p, unsigned long n) { pointer r; @@ -62,7 +63,7 @@ XNFrealloc(pointer p, unsigned long n) } -_X_EXPORT pointer +pointer XNFcalloc(unsigned long n) { pointer r; @@ -74,13 +75,13 @@ XNFcalloc(unsigned long n) } -_X_EXPORT void +void Xfree(pointer p) { free(p); } -_X_EXPORT char * +char * Xstrdup(const char *s) { char *sd; diff --git a/xserver/hw/xfree86/loader/dixsym.c b/xserver/hw/xfree86/loader/dixsym.c index 27a3093b1..efb4dff59 100644 --- a/xserver/hw/xfree86/loader/dixsym.c +++ b/xserver/hw/xfree86/loader/dixsym.c @@ -90,6 +90,10 @@ extern int XkbDfltRepeatDelay, XkbDfltRepeatInterval; #endif +#ifdef X_PRIVSEP +extern int priv_open_device(const char *); +#endif + extern Selection *CurrentSelections; extern int NumCurrentSelections; @@ -341,6 +345,10 @@ _X_HIDDEN void *dixLookupTab[] = { SYMFUNC(AdjustWaitForDelay) SYMVAR(noTestExtensions) SYMFUNC(GiveUp) +#ifdef X_PRIVSEP + /* privsep.c */ + SYMFUNC(priv_open_device) +#endif #ifdef BIGREQS SYMVAR(noBigReqExtension) diff --git a/xserver/hw/xfree86/os-support/bsd/Makefile.am b/xserver/hw/xfree86/os-support/bsd/Makefile.am index 20885e866..10ff44c4e 100644 --- a/xserver/hw/xfree86/os-support/bsd/Makefile.am +++ b/xserver/hw/xfree86/os-support/bsd/Makefile.am @@ -15,7 +15,7 @@ endif RES_SOURCES = $(srcdir)/../shared/stdResource.c if AGP -AGP_SOURCES = $(srcdir)/../linux/lnx_agp.c +AGP_SOURCES = bsd_agp.c else AGP_SOURCES = $(srcdir)/../shared/agp_noop.c endif @@ -33,6 +33,14 @@ if ARM_VIDEO ARCH_SOURCES = arm_video.c endif +if HP300_VIDEO +ARCH_SOURCES = hp300_video.c +endif + +if HPPA_VIDEO +ARCH_SOURCES = hppa_video.c +endif + if I386_VIDEO ARCH_SOURCES = i386_video.c endif diff --git a/xserver/hw/xfree86/os-support/bsd/alpha_video.c b/xserver/hw/xfree86/os-support/bsd/alpha_video.c index 5052b7862..6cb58fa4b 100644 --- a/xserver/hw/xfree86/os-support/bsd/alpha_video.c +++ b/xserver/hw/xfree86/os-support/bsd/alpha_video.c @@ -732,3 +732,15 @@ _X_EXPORT int (*xf86ReadMmio16)(pointer Base, unsigned long Offset) _X_EXPORT int (*xf86ReadMmio32)(pointer Base, unsigned long Offset) = readDense32; +/* + * Do all things that need root privileges early + * and revoke those priviledges + */ +_X_EXPORT void +xf86PrivilegedInit(void) +{ + xf86EnableIO(); + checkDevMem(TRUE); + pciInit(); + xf86OpenConsole(); +} diff --git a/xserver/hw/xfree86/os-support/bsd/arm_video.c b/xserver/hw/xfree86/os-support/bsd/arm_video.c index 4a3d5ca52..4c95b68aa 100644 --- a/xserver/hw/xfree86/os-support/bsd/arm_video.c +++ b/xserver/hw/xfree86/os-support/bsd/arm_video.c @@ -1,3 +1,5 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/ppc_video.c,v 1.6 2003/10/07 23:14:55 herrb Exp $ */ +/* $OpenBSD: arm_video.c,v 1.2 2006/11/28 20:29:31 matthieu Exp $ */ /* * Copyright 1992 by Rich Murphey <Rich@Rice.edu> * Copyright 1993 by David Wexelblat <dwex@goblin.org> @@ -23,39 +25,6 @@ * */ -/* - * The ARM32 code here carries the following copyright: - * - * Copyright 1997 - * Digital Equipment Corporation. All rights reserved. - * This software is furnished under license and may be used and copied only in - * accordance with the following terms and conditions. Subject to these - * conditions, you may download, copy, install, use, modify and distribute - * this software in source and/or binary form. No title or ownership is - * transferred hereby. - * - * 1) Any source code used, modified or distributed must reproduce and retain - * this copyright notice and list of conditions as they appear in the - * source file. - * - * 2) No right is granted to use any trade name, trademark, or logo of Digital - * Equipment Corporation. Neither the "Digital Equipment Corporation" - * name nor any trademark or logo of Digital Equipment Corporation may be - * used to endorse or promote products derived from this software without - * the prior written permission of Digital Equipment Corporation. - * - * 3) This software is provided "AS-IS" and any express or implied warranties, - * including but not limited to, any implied warranties of merchantability, - * fitness for a particular purpose, or non-infringement are disclaimed. - * In no event shall DIGITAL be liable for any damages whatsoever, and in - * particular, DIGITAL shall not be liable for special, indirect, - * consequential, or incidental damages or damages for lost profits, loss - * of revenue or loss of use, whether such damages arise in contract, - * negligence, tort, under statute, in equity, at law or otherwise, even - * if advised of the possibility of such damage. - * - */ - /* $XConsortium: bsd_video.c /main/10 1996/10/25 11:37:57 kaleb $ */ #ifdef HAVE_XORG_CONFIG_H @@ -65,625 +34,207 @@ #include <X11/X.h> #include "xf86.h" #include "xf86Priv.h" + #include "xf86_OSlib.h" #include "xf86OSpriv.h" -#ifdef __arm32__ -#include "machine/devmap.h" -struct memAccess -{ - int ioctl; - struct map_info memInfo; - pointer regionVirtBase; - Bool Checked; - Bool OK; -}; - -static pointer xf86MapInfoMap(); -static void xf86MapInfoUnmap(); -static struct memAccess *checkMapInfo(); -extern int vgaPhysLinearBase; - -/* A memAccess structure is needed for each possible region */ -struct memAccess vgaMemInfo = { CONSOLE_GET_MEM_INFO, NULL, NULL, - FALSE, FALSE }; -struct memAccess linearMemInfo = { CONSOLE_GET_LINEAR_INFO, NULL, NULL, - FALSE, FALSE }; -struct memAccess ioMemInfo = { CONSOLE_GET_IO_INFO, NULL, NULL, - FALSE, FALSE }; -#endif /* __arm32__ */ - -#if defined(__NetBSD__) && !defined(MAP_FILE) -#define MAP_FLAGS MAP_SHARED -#else -#define MAP_FLAGS (MAP_FILE | MAP_SHARED) -#endif +#include "bus/Pci.h" #ifndef MAP_FAILED #define MAP_FAILED ((caddr_t)-1) #endif - -#define BUS_BASE 0L -#define BUS_BASE_BWX 0L - +#include <sys/param.h> +#include <sys/sysctl.h> /***************************************************************************/ /* Video Memory Mapping section */ /***************************************************************************/ -static Bool useDevMem = FALSE; -static int devMemFd = -1; - -#define DEV_MEM "/dev/mem" - -static pointer mapVidMem(int, unsigned long, unsigned long, int); -static void unmapVidMem(int, pointer, unsigned long); - -/* - * Check if /dev/mem can be mmap'd. If it can't print a warning when - * "warn" is TRUE. - */ -static void -checkDevMem(Bool warn) -{ - static Bool devMemChecked = FALSE; - int fd; - pointer base; +#ifdef __OpenBSD__ +#undef DEV_MEM +#define DEV_MEM "/dev/xf86" +#endif - if (devMemChecked) - return; - devMemChecked = TRUE; - - if ((fd = open(DEV_MEM, O_RDWR)) >= 0) - { - /* Try to map a page at the VGA address */ - base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE, - MAP_FLAGS, fd, (off_t)0xA0000 + BUS_BASE); - - if (base != MAP_FAILED) - { - munmap((caddr_t)base, 4096); - devMemFd = fd; - useDevMem = TRUE; - return; - } else { - /* This should not happen */ - if (warn) - { - xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n", - DEV_MEM, strerror(errno)); - } - useDevMem = FALSE; - return; - } - } - if (warn) - { - xf86Msg(X_WARNING, "checkDevMem: failed to open %s (%s)\n", - DEV_MEM, strerror(errno)); - } - useDevMem = FALSE; - return; -} +static pointer ppcMapVidMem(int, unsigned long, unsigned long, int flags); +static void ppcUnmapVidMem(int, pointer, unsigned long); void xf86OSInitVidMem(VidMemInfoPtr pVidMem) { - - checkDevMem(TRUE); - pVidMem->linearSupported = useDevMem; - pVidMem->mapMem = armMapVidMem; - pVidMem->unmapVidMem = armUnmapVidMem; - + pVidMem->linearSupported = TRUE; + pVidMem->mapMem = ppcMapVidMem; + pVidMem->unmapMem = ppcUnmapVidMem; pVidMem->initialised = TRUE; } + +volatile unsigned char *ioBase = MAP_FAILED; + static pointer -mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) +ppcMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) { + int fd = xf86Info.screenFd; pointer base; +#ifdef DEBUG + xf86MsgVerb(X_INFO, 3, "mapVidMem %lx, %lx, fd = %d", + Base, Size, fd); +#endif - checkDevMem(FALSE); - - if (useDevMem) - { - if (devMemFd < 0) - { - FatalError("xf86MapVidMem: failed to open %s (%s)\n", - DEV_MEM, strerror(errno)); - } - base = mmap((caddr_t)0, Size, - (flags & VIDMEM_READONLY) ? - PROT_READ : (PROT_READ | PROT_WRITE), - MAP_FLAGS, devMemFd, (off_t)Base + BUS_BASE_BWX); - if (base == MAP_FAILED) - { - FatalError("%s: could not mmap %s [s=%x,a=%x] (%s)\n", - "xf86MapVidMem", DEV_MEM, Size, Base, - strerror(errno)); - } - return(base); - } - - /* else, mmap /dev/vga */ - if ((unsigned long)Base < 0xA0000 || (unsigned long)Base >= 0xC0000) - { - FatalError("%s: Address 0x%x outside allowable range\n", - "xf86MapVidMem", Base); - } base = mmap(0, Size, (flags & VIDMEM_READONLY) ? PROT_READ : (PROT_READ | PROT_WRITE), - MAP_FLAGS, xf86Info.screenFd, - (unsigned long)Base - 0xA0000); + MAP_SHARED, fd, Base); if (base == MAP_FAILED) - { - FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)\n", - strerror(errno)); - } - return(base); + FatalError("%s: could not mmap screen [s=%lx,a=%lx] (%s)", + "xf86MapVidMem", Size, Base, strerror(errno)); + + return base; } static void -unmapVidMem(int ScreenNum, pointer Base, unsigned long Size) +ppcUnmapVidMem(int ScreenNum, pointer Base, unsigned long Size) { - munmap((caddr_t)Base, Size); + munmap(Base, Size); } -/* - * Read BIOS via mmap()ing DEV_MEM - */ +static int kmem = -1; -_X_EXPORT int +int xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, int Len) { - unsigned char *ptr; - int psize; - int mlen; + int rv; - checkDevMem(TRUE); - if (devMemFd == -1) { - return(-1); + if (Base < 0x80000000) { + xf86Msg(X_WARNING, "No VGA Base=%#lx\n", Base); + return 0; } - psize = xf86getpagesize(); - Offset += Base & (psize - 1); - Base &= ~(psize - 1); - mlen = (Offset + Len + psize - 1) & ~(psize - 1); - ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ, - MAP_SHARED, devMemFd, (off_t)Base+BUS_BASE); - if ((long)ptr == -1) - { - xf86Msg(X_WARNING, - "xf86ReadBIOS: %s mmap[s=%x,a=%x,o=%x] failed (%s)\n", - DEV_MEM, Len, Base, Offset, strerror(errno)); - return(-1); - } -#ifdef DEBUG - ErrorF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n", - Base, ptr[0] | (ptr[1] << 8)); -#endif - (void)memcpy(Buf, (void *)(ptr + Offset), Len); - (void)munmap((caddr_t)ptr, mlen); -#ifdef DEBUG - xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)" - "-> %02x %02x %02x %02x...\n", - Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]); -#endif - return(Len); -} - - -/* XXX This needs to be updated for the ND */ - -/* -** Find out whether the console driver provides memory mapping information -** for the specified region and return the map_info pointer. Print a warning if required. -*/ -static struct memAccess * -checkMapInfo(Bool warn, int Region) -{ - struct memAccess *memAccP; - - switch (Region) - { - case VGA_REGION: - memAccP = &vgaMemInfo; - break; - - case LINEAR_REGION: - memAccP = &linearMemInfo; - break; - - case MMIO_REGION: - memAccP = &ioMemInfo; - break; - - default: - return NULL; - break; - } - - if(!memAccP->Checked) - { - if(ioctl(xf86Info.screenFd, memAccP->ioctl, &(memAccP->memInfo)) == -1) - { - if(warn) - { - xf86Msg(X_WARNING, - "checkMapInfo: failed to get map info for region %d\n\t(%s)\n", - Region, strerror(errno)); - } - } - else - { - if(memAccP->memInfo.u.map_info_mmap.map_offset - != MAP_INFO_UNKNOWN) - memAccP->OK = TRUE; - } - memAccP->Checked = TRUE; - } - if (memAccP->OK) - { - return memAccP; - } - else - { - return NULL; - } -} - -static pointer -xf86MapInfoMap(struct memAccess *memInfoP, pointer Base, unsigned long Size) -{ - struct map_info *mapInfoP = &(memInfoP->memInfo); - - if (mapInfoP->u.map_info_mmap.map_size == MAP_INFO_UNKNOWN) - { - Size = (unsigned long)Base + Size; - } - else - { - Size = mapInfoP->u.map_info_mmap.map_size; - } - - switch(mapInfoP->method) - { - case MAP_MMAP: - /* Need to remap if size is unknown because we may not have - mapped the whole region initially */ - if(memInfoP->regionVirtBase == NULL || - mapInfoP->u.map_info_mmap.map_size == MAP_INFO_UNKNOWN) - { - if((memInfoP->regionVirtBase = - mmap((caddr_t)0, - Size, - PROT_READ | PROT_WRITE, - MAP_SHARED, - xf86Info.screenFd, - (unsigned long)mapInfoP->u.map_info_mmap.map_offset)) - == (pointer)-1) - { - FatalError("xf86MapInfoMap: Failed to map memory at 0x%x\n\t%s\n", - mapInfoP->u.map_info_mmap.map_offset, strerror(errno)); + if (kmem == -1) { + kmem = open(DEV_MEM, 2); + if (kmem == -1) { + FatalError("xf86ReadBIOS: open %s", DEV_MEM); } - if(mapInfoP->u.map_info_mmap.internal_offset > 0) - memInfoP->regionVirtBase += - mapInfoP->u.map_info_mmap.internal_offset; - } - break; - - default: - FatalError("xf86MapInfoMap: Unsuported mapping method\n"); - break; - } - - return (pointer)((int)memInfoP->regionVirtBase + (int)Base); -} - -static void -xf86MapInfoUnmap(struct memAccess *memInfoP, unsigned long Size) -{ - struct map_info *mapInfoP = &(memInfoP->memInfo); - - switch(mapInfoP->method) - { - case MAP_MMAP: - if(memInfoP->regionVirtBase != NULL) - { - if(mapInfoP->u.map_info_mmap.map_size != MAP_INFO_UNKNOWN) - Size = mapInfoP->u.map_info_mmap.map_size; - munmap((caddr_t)memInfoP->regionVirtBase, Size); - memInfoP->regionVirtBase = NULL; - } - break; - default: - FatalError("xf86MapInfoMap: Unsuported mapping method\n"); - break; - } -} - -static pointer -armMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) -{ - struct memAccess *memInfoP; - - if((memInfoP = checkMapInfo(FALSE, Region)) != NULL) - { - /* - ** xf86 passes in a physical address offset from the start - ** of physical memory, but xf86MapInfoMap expects an - ** offset from the start of the specified region - it gets - ** the physical address of the region from the display driver. - */ - switch(Region) - { - case LINEAR_REGION: - if (vgaPhysLinearBase) - { - Base -= vgaPhysLinearBase; - } - break; - case VGA_REGION: - Base -= 0xA0000; - break; - } - - base = xf86MapInfoMap(memInfoP, Base, Size); - return (base); - } - return mapVidMem(ScreenNum, Base, Size, flags); -} - -static void -armUnmapVidMem(int ScreenNum, pointer Base, unsigned long Size) -{ - struct memAccess *memInfoP; - - if((memInfoP = checkMapInfo(FALSE, Region)) != NULL) - { - xf86MapInfoUnmap(memInfoP, Base, Size); } - unmapVidMem(ScreenNum, Base, Size); -} - -#ifdef USE_DEV_IO -static int IoFd = -1; - -_X_EXPORT Bool -xf86EnableIO() -{ - if (IoFd >= 0) - return TRUE; - - if ((IoFd = open("/dev/io", O_RDWR)) == -1) - { - xf86Msg(X_WARNING,"xf86EnableIO: " - "Failed to open /dev/io for extended I/O\n"); - return FALSE; - } - return TRUE; -} - -_X_EXPORT void -xf86DisableIO() -{ - if (IoFd < 0) - return; - - close(IoFd); - IoFd = -1; - return; -} +#ifdef DEBUG + xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS() %lx %lx, %x\n", + Base, Offset, Len); #endif -#if defined(USE_ARC_MMAP) || defined(__arm32__) - -Bool -xf86EnableIO() -{ - int fd; - pointer base; - - if (ExtendedEnabled) - return TRUE; - if ((fd = open("/dev/ttyC0", O_RDWR)) >= 0) { - /* Try to map a page at the pccons I/O space */ - base = (pointer)mmap((caddr_t)0, 65536, PROT_READ | PROT_WRITE, - MAP_FLAGS, fd, (off_t)0x0000); - - if (base != (pointer)-1) { - IOPortBase = base; - } - else { - xf86Msg(X_WARNING,"EnableIO: failed to mmap %s (%s)\n", - "/dev/ttyC0", strerror(errno)); - return FALSE; - } - } - else { - xf86Msg("EnableIO: failed to open %s (%s)\n", - "/dev/ttyC0", strerror(errno)); - return FALSE; - } - - ExtendedEnabled = TRUE; - - return TRUE; + lseek(kmem, Base + Offset, 0); + rv = read(kmem, Buf, Len); + return rv; } -void -xf86DisableIO() -{ - return; -} - -#endif /* USE_ARC_MMAP */ - - /***************************************************************************/ /* Interrupt Handling section */ /***************************************************************************/ -_X_EXPORT Bool +Bool xf86DisableInterrupts() { return(TRUE); } -_X_EXPORT void +void xf86EnableInterrupts() { return; } - - -#if 0 /* - * XXX This is here for reference. It needs to be handled differently for the - * ND. + * Do all initialisation that need root privileges */ -#if defined(USE_ARC_MMAP) || defined(__arm32__) - -#ifdef USE_ARM32_MMAP -#define DEV_MEM_IOBASE 0x43000000 -#endif - -static Bool ScreenEnabled[MAXSCREENS]; -static Bool ExtendedEnabled = FALSE; -static Bool InitDone = FALSE; - -Bool -xf86EnableIOPorts(ScreenNum) -int ScreenNum; -{ - int i; - int fd; - pointer base; - -#ifdef __arm32__ - struct memAccess *memInfoP; - int *Size; -#endif - - ScreenEnabled[ScreenNum] = TRUE; - - if (ExtendedEnabled) - return TRUE; - -#ifdef USE_ARC_MMAP - if ((fd = open("/dev/ttyC0", O_RDWR)) >= 0) { - /* Try to map a page at the pccons I/O space */ - base = (pointer)mmap((caddr_t)0, 65536, PROT_READ | PROT_WRITE, - MAP_FLAGS, fd, (off_t)0x0000); - - if (base != (pointer)-1) { - IOPortBase = base; - } - else { - xf86Msg(X_ERROR, - "EnableIOPorts: failed to mmap %s (%s)\n", - "/dev/ttyC0", strerror(errno)); - } - } - else { - xf86Msg(X_ERROR, "EnableIOPorts: failed to open %s (%s)\n", - "/dev/ttyC0", strerror(errno)); - } -#endif - -#ifdef __arm32__ - IOPortBase = (unsigned int)-1; - - if((memInfoP = checkMapInfo(TRUE, MMIO_REGION)) != NULL) - { - /* - * xf86MapInfoMap maps an offset from the start of video IO - * space (e.g. 0x3B0), but IOPortBase is expected to map to - * physical address 0x000, so subtract the start of video I/O - * space from the result. This is safe for now becase we - * actually mmap the start of the page, then the start of video - * I/O space is added as an internal offset. - */ - IOPortBase = (unsigned int)xf86MapInfoMap(memInfoP, - (caddr_t)0x0, 0L) - - memInfoP->memInfo.u.map_info_mmap.internal_offset; - ExtendedEnabled = TRUE; - return TRUE; - } -#ifdef USE_ARM32_MMAP - checkDevMem(TRUE); - - if (devMemFd >= 0 && useDevMem) - { - base = (pointer)mmap((caddr_t)0, 0x400, PROT_READ | PROT_WRITE, - MAP_FLAGS, devMemFd, (off_t)DEV_MEM_IOBASE); - - if (base != (pointer)-1) - IOPortBase = (unsigned int)base; - } - - if (IOPortBase == (unsigned int)-1) - { - xf86Msg(X_WARNING,"xf86EnableIOPorts: failed to open mem device or map IO base. \n\ -Make sure you have the Aperture Driver installed, or a kernel built with the INSECURE option\n"); - return FALSE; - } -#else - /* We don't have the IOBASE, so we can't map the address */ - xf86Msg(X_WARNING,"xf86EnableIOPorts: failed to open mem device or map IO base. \n\ -Try building the server with USE_ARM32_MMAP defined\n"); - return FALSE; -#endif -#endif - - ExtendedEnabled = TRUE; - - return TRUE; -} - void -xf86DisableIOPorts(ScreenNum) -int ScreenNum; -{ - int i; -#ifdef __arm32__ - struct memAccess *memInfoP; -#endif - - ScreenEnabled[ScreenNum] = FALSE; - -#ifdef __arm32__ - if((memInfoP = checkMapInfo(FALSE, MMIO_REGION)) != NULL) - { - xf86MapInfoUnmap(memInfoP, 0); +xf86PrivilegedInit(void) +{ + int mib[2]; + char buf[128]; + size_t len; + + mib[0] = CTL_HW; + mib[1] = HW_MACHINE; + len = sizeof(buf); + if (sysctl(mib, 2, buf, &len, NULL, 0) < 0) { + FatalError("Cannot get hw.machine"); + } + if (strcmp(buf, "zaurus") != 0) { + /* Not Zaurus */ + kmem = open(DEV_MEM, 2); + if (kmem == -1) { + ErrorF("errno: %d\n", errno); + FatalError("xf86PrivilegedInit: open %s", DEV_MEM); + } } -#endif - -#ifdef USE_ARM32_MMAP - if (!ExtendedEnabled) - return; - for (i = 0; i < MAXSCREENS; i++) - if (ScreenEnabled[i]) - return; - - munmap((caddr_t)IOPortBase, 0x400); - IOPortBase = (unsigned int)-1; - ExtendedEnabled = FALSE; -#endif - - return; + pciInit(); + xf86OpenConsole(); } -#endif /* USE_ARC_MMAP || USE_ARM32_MMAP */ -#endif - - +#ifdef __VFP_FP__ +/* + * force softfloat functions into binary, + * yes the protos/ret are all bogus. + */ +arm_softfloat() +{ +void __adddf3(); +void __addsf3(); +void __eqdf2(); +void __eqsf2(); +void __extendsfdf2(); +void __fixdfsi(); +void __fixsfsi(); +void __fixunsdfsi(); +void __fixunssfsi(); +void __floatsidf(); +void __floatsisf(); +void __gedf2(); +void __gesf2(); +void __gtdf2(); +void __gtsf2(); +void __ledf2(); +void __lesf2(); +void __ltdf2(); +void __ltsf2(); +void __nedf2(); +void __negdf2(); +void __negsf2(); +void __nesf2(); +void __subdf3(); +void __subsf3(); +void __truncdfsf2(); + +__adddf3(); +__addsf3(); +__eqdf2(); +__eqsf2(); +__extendsfdf2(); +__fixdfsi(); +__fixsfsi(); +__fixunsdfsi(); +__fixunssfsi(); +__floatsidf(); +__floatsisf(); +__gedf2(); +__gesf2(); +__gtdf2(); +__gtsf2(); +__ledf2(); +__lesf2(); +__ltdf2(); +__ltsf2(); +__nedf2(); +__negdf2(); +__negsf2(); +__nesf2(); +__subdf3(); +__subsf3(); +__truncdfsf2(); +} +#endif /* __VFP_FP__ */ diff --git a/xserver/hw/xfree86/os-support/bsd/bsdResource.c b/xserver/hw/xfree86/os-support/bsd/bsdResource.c index 37749c913..65aa9fde7 100644 --- a/xserver/hw/xfree86/os-support/bsd/bsdResource.c +++ b/xserver/hw/xfree86/os-support/bsd/bsdResource.c @@ -21,7 +21,8 @@ _X_EXPORT resRange PciAvoid[] = {_PCI_AVOID_PC_STYLE, _END}; #ifdef INCLUDE_XF86_NO_DOMAIN -#if defined(__alpha__) || defined(__sparc64__) || defined(__amd64__) +#if defined(__alpha__) || defined(__sparc__) || defined(__sparc64__) \ + || defined(__amd64__) || defined(__hppa__) resPtr xf86BusAccWindowsFromOS(void) @@ -115,7 +116,7 @@ xf86AccResFromOS(resPtr ret) return ret; } -#elif defined(__powerpc__) +#elif defined(__powerpc__) || defined(__arm__) || defined(__mc68020__) /* XXX hp300 */ || defined(__vax__) resPtr xf86BusAccWindowsFromOS(void) diff --git a/xserver/hw/xfree86/os-support/bsd/bsd_agp.c b/xserver/hw/xfree86/os-support/bsd/bsd_agp.c new file mode 100644 index 000000000..cc1231d9a --- /dev/null +++ b/xserver/hw/xfree86/os-support/bsd/bsd_agp.c @@ -0,0 +1,329 @@ +/* $OpenBSD: bsd_agp.c,v 1.1 2006/11/28 20:29:31 matthieu Exp $ */ +/* + * Abstraction of the AGP GART interface. + * + * This version is for OpenBSD + * + * Copyright © 2000 VA Linux Systems, Inc. + * Copyright © 2001 The XFree86 Project, Inc. + */ + +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_agp.c,v 3.11 2003/04/03 22:47:42 dawes Exp $ */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "xf86OSpriv.h" + +#include <sys/ioctl.h> +#include <sys/agpio.h> + +/* AGP page size is independent of the host page size. */ +#ifndef AGP_PAGE_SIZE +#define AGP_PAGE_SIZE 4096 +#endif + +static int gartFd = -1; +static int acquiredScreen = -1; +static Bool initDone = FALSE; + +/* + * Close /dev/agpgart. This frees all associated memory allocated during + * this server generation. + */ +Bool +xf86GARTCloseScreen(int screenNum) +{ + if(gartFd != -1) { + acquiredScreen = -1; + gartFd = -1; + initDone = FALSE; + } + return TRUE; +} + +/* + * Open /dev/agpgart. Keep it open until xf86GARTCloseScreen is called. + */ +static Bool +GARTInit(int screenNum) +{ + struct _agp_info agpinf; + + if (initDone) + return (gartFd != -1); + + initDone = TRUE; + + if (gartFd == -1) + gartFd = xf86Info.consoleFd; + else + return FALSE; + + xf86AcquireGART(-1); + /* Check the kernel driver version. */ + if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) { + xf86DrvMsg(screenNum, X_WARNING, + "GARTInit: AGPIOC_INFO failed (%s)\n", strerror(errno)); + gartFd = -1; + return FALSE; + } + xf86ReleaseGART(-1); + + return TRUE; +} + +Bool +xf86AgpGARTSupported() +{ + return GARTInit(-1); +} + +AgpInfoPtr +xf86GetAGPInfo(int screenNum) +{ + struct _agp_info agpinf; + AgpInfoPtr info; + + if (!GARTInit(screenNum)) + return NULL; + + + if ((info = xcalloc(sizeof(AgpInfo), 1)) == NULL) { + xf86DrvMsg(screenNum, X_ERROR, + "xf86GetAGPInfo: Failed to allocate AgpInfo\n"); + return NULL; + } + + memset((char*)&agpinf, 0, sizeof(agpinf)); + + if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) { + xf86DrvMsg(screenNum, X_ERROR, + "xf86GetAGPInfo: AGPIOC_INFO failed (%s)\n", + strerror(errno)); + return NULL; + } + + info->bridgeId = agpinf.bridge_id; + info->agpMode = agpinf.agp_mode; + info->base = agpinf.aper_base; + info->size = agpinf.aper_size; + info->totalPages = agpinf.pg_total; + info->systemPages = agpinf.pg_system; + info->usedPages = agpinf.pg_used; + + xf86DrvMsg(screenNum, X_INFO, "Kernel reported %lu total, %lu used\n", + (unsigned long)agpinf.pg_total, (unsigned long)agpinf.pg_used); + + return info; +} + +/* + * XXX If multiple screens can acquire the GART, should we have a reference + * count instead of using acquiredScreen? + */ + +Bool +xf86AcquireGART(int screenNum) +{ + if (screenNum != -1 && !GARTInit(screenNum)) + return FALSE; + + if (screenNum == -1 || acquiredScreen != screenNum) { + if (ioctl(gartFd, AGPIOC_ACQUIRE, 0) != 0) { + xf86DrvMsg(screenNum, X_WARNING, + "xf86AcquireGART: AGPIOC_ACQUIRE failed (%s)\n", + strerror(errno)); + return FALSE; + } + acquiredScreen = screenNum; + } + return TRUE; +} + +Bool +xf86ReleaseGART(int screenNum) +{ + if (screenNum != -1 && !GARTInit(screenNum)) + return FALSE; + + if (acquiredScreen == screenNum) { + /* + * The FreeBSD agp driver removes allocations on release. + * The Linux driver doesn't. xf86ReleaseGART() is expected + * to give up access to the GART, but not to remove any + * allocations. + */ + if (screenNum == -1) { + if (ioctl(gartFd, AGPIOC_RELEASE, 0) != 0) { + xf86DrvMsg(screenNum, X_WARNING, + "xf86ReleaseGART: AGPIOC_RELEASE failed (%s)\n", + strerror(errno)); + return FALSE; + } + acquiredScreen = -1; + } + return TRUE; + } + return FALSE; +} + +int +xf86AllocateGARTMemory(int screenNum, unsigned long size, int type, + unsigned long *physical) +{ + struct _agp_allocate alloc; + int pages; + + /* + * Allocates "size" bytes of GART memory (rounds up to the next + * page multiple) or type "type". A handle (key) for the allocated + * memory is returned. On error, the return value is -1. + */ + + if (!GARTInit(screenNum) || acquiredScreen != screenNum) + return -1; + + pages = (size / AGP_PAGE_SIZE); + if (size % AGP_PAGE_SIZE != 0) + pages++; + + /* XXX check for pages == 0? */ + + alloc.pg_count = pages; + alloc.type = type; + + if (ioctl(gartFd, AGPIOC_ALLOCATE, &alloc) != 0) { + xf86DrvMsg(screenNum, X_WARNING, "xf86AllocateGARTMemory: " + "allocation of %d pages failed\n\t(%s)\n", pages, + strerror(errno)); + return -1; + } + + if (physical) + *physical = alloc.physical; + + return alloc.key; +} + +Bool +xf86DeallocateGARTMemory(int screenNum, int key) +{ + if (!GARTInit(screenNum) || acquiredScreen != screenNum) + return FALSE; + + if (acquiredScreen != screenNum) { + xf86DrvMsg(screenNum, X_ERROR, + "xf86UnbindGARTMemory: AGP not acquired by this screen\n"); + return FALSE; + } + + if (ioctl(gartFd, AGPIOC_DEALLOCATE, (int *)key) != 0) { + xf86DrvMsg(screenNum, X_WARNING,"xf86DeAllocateGARTMemory: " + "deallocation gart memory with key %d failed\n\t(%s)\n", + key, strerror(errno)); + return FALSE; + } + + return TRUE; +} + +/* Bind GART memory with "key" at "offset" */ +Bool +xf86BindGARTMemory(int screenNum, int key, unsigned long offset) +{ + struct _agp_bind bind; + int pageOffset; + + if (!GARTInit(screenNum) || acquiredScreen != screenNum) + return FALSE; + + if (acquiredScreen != screenNum) { + xf86DrvMsg(screenNum, X_ERROR, + "xf86BindGARTMemory: AGP not acquired by this screen\n"); + return FALSE; + } + + if (offset % AGP_PAGE_SIZE != 0) { + xf86DrvMsg(screenNum, X_WARNING, "xf86BindGARTMemory: " + "offset (0x%lx) is not page-aligned (%d)\n", + offset, AGP_PAGE_SIZE); + return FALSE; + } + pageOffset = offset / AGP_PAGE_SIZE; + + xf86DrvMsgVerb(screenNum, X_INFO, 3, + "xf86BindGARTMemory: bind key %d at 0x%08lx " + "(pgoffset %d)\n", key, offset, pageOffset); + + bind.pg_start = pageOffset; + bind.key = key; + + if (ioctl(gartFd, AGPIOC_BIND, &bind) != 0) { + xf86DrvMsg(screenNum, X_WARNING, "xf86BindGARTMemory: " + "binding of gart memory with key %d\n" + "\tat offset 0x%lx failed (%s)\n", + key, offset, strerror(errno)); + return FALSE; + } + + return TRUE; +} + + +/* Unbind GART memory with "key" */ +Bool +xf86UnbindGARTMemory(int screenNum, int key) +{ + struct _agp_unbind unbind; + + if (!GARTInit(screenNum) || acquiredScreen != screenNum) + return FALSE; + + if (acquiredScreen != screenNum) { + xf86DrvMsg(screenNum, X_ERROR, + "xf86UnbindGARTMemory: AGP not acquired by this screen\n"); + return FALSE; + } + + unbind.priority = 0; + unbind.key = key; + + if (ioctl(gartFd, AGPIOC_UNBIND, &unbind) != 0) { + xf86DrvMsg(screenNum, X_WARNING, "xf86UnbindGARTMemory: " + "unbinding of gart memory with key %d " + "failed (%s)\n", key, strerror(errno)); + return FALSE; + } + + xf86DrvMsgVerb(screenNum, X_INFO, 3, + "xf86UnbindGARTMemory: unbind key %d\n", key); + + return TRUE; +} + + +/* XXX Interface may change. */ +Bool +xf86EnableAGP(int screenNum, CARD32 mode) +{ + agp_setup setup; + + if (!GARTInit(screenNum) || acquiredScreen != screenNum) + return FALSE; + + setup.agp_mode = mode; + if (ioctl(gartFd, AGPIOC_SETUP, &setup) != 0) { + xf86DrvMsg(screenNum, X_WARNING, "xf86EnableAGP: " + "AGPIOC_SETUP with mode %ld failed (%s)\n", + (unsigned long)mode, strerror(errno)); + return FALSE; + } + + return TRUE; +} diff --git a/xserver/hw/xfree86/os-support/bsd/bsd_init.c b/xserver/hw/xfree86/os-support/bsd/bsd_init.c index eb6d85053..782e3677b 100644 --- a/xserver/hw/xfree86/os-support/bsd/bsd_init.c +++ b/xserver/hw/xfree86/os-support/bsd/bsd_init.c @@ -38,6 +38,10 @@ #include <sys/utsname.h> #include <sys/ioctl.h> +#ifdef X_PRIVSEP +#include "os.h" +#include <pwd.h> +#endif #include <stdlib.h> #include <errno.h> @@ -164,12 +168,18 @@ xf86OpenConsole() vtmode_t vtmode; #endif +#ifdef X_PRIVSEP + if (xf86Info.consoleFd != -1) { + return; + } +#endif if (serverGeneration == 1) { /* check if we are run with euid==0 */ - if (geteuid() != 0) + if (geteuid() != 0 && issetugid()) { - FatalError("xf86OpenConsole: Server must be suid root"); + FatalError("xf86OpenConsole: Server must either be suid root" + " or without privileges at all"); } if (!KeepTty) @@ -283,17 +293,17 @@ acquire_vt: xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n"); } - signal(SIGUSR1, xf86VTRequest); + signal(SIGUSR2, xf86VTRequest); vtmode.mode = VT_PROCESS; - vtmode.relsig = SIGUSR1; - vtmode.acqsig = SIGUSR1; - vtmode.frsig = SIGUSR1; + vtmode.relsig = SIGUSR2; + vtmode.acqsig = SIGUSR2; + vtmode.frsig = SIGUSR2; if (ioctl(xf86Info.consoleFd, VT_SETMODE, &vtmode) < 0) { FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed"); } -#if !defined(USE_DEV_IO) && !defined(USE_I386_IOPL) +#if !defined(OpenBSD) && !defined(USE_DEV_IO) && !defined(USE_I386_IOPL) if (ioctl(xf86Info.consoleFd, KDENABIO, 0) < 0) { FatalError("xf86OpenConsole: KDENABIO failed (%s)", @@ -308,8 +318,7 @@ acquire_vt: #endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */ #ifdef WSCONS_SUPPORT case WSCONS: - fprintf(stderr, "xf86OpenConsole\n"); - /* xf86Info.consoleFd = open("/dev/wskbd0", 0); */ + /* Nothing to do */ break; #endif } @@ -510,7 +519,12 @@ xf86OpenPcvt() vtprefix = "/dev/ttyC"; #endif - fd = open(PCVT_CONSOLE_DEV, PCVT_CONSOLE_MODE, 0); + if (VTnum != -1) { + snprintf(vtname, sizeof(vtname), "%s%x", vtprefix, VTnum - 1); + fd = open(vtname, PCVT_CONSOLE_MODE, 0); + } else { + fd = open(PCVT_CONSOLE_DEV, PCVT_CONSOLE_MODE, 0); + } #ifdef WSCONS_PCVT_COMPAT_CONSOLE_DEV if (fd < 0) { @@ -573,8 +587,14 @@ xf86OpenPcvt() sprintf(vtname, "%s%01x", vtprefix, xf86Info.vtno - 1); if ((fd = open(vtname, PCVT_CONSOLE_MODE, 0)) < 0) { - FatalError("xf86OpenPcvt: Cannot open %s (%s)", + ErrorF("xf86OpenPcvt: Cannot open %s (%s)", vtname, strerror(errno)); + xf86Info.vtno = initialVT; + sprintf(vtname, "%s%01x", vtprefix, xf86Info.vtno - 1); + if ((fd = open(vtname, PCVT_CONSOLE_MODE, 0)) < 0) { + FatalError("xf86OpenPcvt: Cannot open %s (%s)", + vtname, strerror(errno)); + } } if (ioctl(fd, VT_GETMODE, &vtmode) < 0) { @@ -583,8 +603,8 @@ xf86OpenPcvt() xf86Info.consType = PCVT; #ifdef WSCONS_SUPPORT xf86Msg(X_PROBED, - "Using wscons driver in pcvt compatibility mode " - "(version %d.%d)\n", + "Using wscons driver on %s in pcvt compatibility mode " + "(version %d.%d)\n", vtname, pcvt_version.rmajor, pcvt_version.rminor); #else xf86Msg(X_PROBED, "Using pcvt driver (version %d.%d)\n", @@ -618,7 +638,7 @@ xf86OpenWScons() #if defined(__NetBSD__) sprintf(ttyname, "/dev/ttyE%d", i); #elif defined(__OpenBSD__) - sprintf(ttyname, "/dev/ttyC%d", i); + sprintf(ttyname, "/dev/ttyC%x", i); #endif if ((fd = open(ttyname, 2)) != -1) break; @@ -660,7 +680,7 @@ xf86CloseConsole() VT.mode = VT_AUTO; ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* dflt vt handling */ } -#if !defined(USE_DEV_IO) && !defined(USE_I386_IOPL) +#if !defined(OpenBSD) && !defined(USE_DEV_IO) && !defined(USE_I386_IOPL) if (ioctl(xf86Info.consoleFd, KDDISABIO, 0) < 0) { xf86FatalError("xf86CloseConsole: KDDISABIO failed (%s)", @@ -692,6 +712,9 @@ xf86CloseConsole() } } close(xf86Info.consoleFd); +#ifdef X_PRIVSEP + xf86Info.consoleFd = -1; +#endif if (devConsoleFd >= 0) close(devConsoleFd); return; @@ -735,3 +758,39 @@ xf86UseMsg() ErrorF("don't detach controlling tty (for debugging only)\n"); return; } + +#ifdef X_PRIVSEP +/* + * Revoke privileges after init. + * If the X server is started as root (xdm case), then switch to _x11 + * if it exists. + * Otherwise use the real uid. + */ +void +xf86DropPriv(char *disp) +{ + struct passwd *pw; + + /* revoke privileges */ + if (getuid() == 0) { + /* Running as root */ + pw = getpwnam("_x11"); + if (!pw) + return; + /* give away lock file to unpriviledged user */ + if (ChownLock(pw->pw_uid, pw->pw_gid) == -1) { + FatalError("Chown Lock"); + } + + /* Start privileged child */ + if (priv_init(pw->pw_uid, pw->pw_gid) == -1) { + FatalError("priv_init"); + } + } else { + /* Normal user */ + if (priv_init(getuid(), getgid()) == -1) { + FatalError("priv_init"); + } + } +} +#endif diff --git a/xserver/hw/xfree86/os-support/bsd/bsd_kbd.c b/xserver/hw/xfree86/os-support/bsd/bsd_kbd.c index 65d577eb8..481e1071b 100644 --- a/xserver/hw/xfree86/os-support/bsd/bsd_kbd.c +++ b/xserver/hw/xfree86/os-support/bsd/bsd_kbd.c @@ -27,6 +27,8 @@ #include "atKeynames.h" #include "bsd_kbd.h" +extern int priv_open_device(char *); + extern Bool VTSwitchEnabled; #ifdef USE_VT_SYSREQ extern Bool VTSysreqToggle; @@ -479,7 +481,11 @@ OpenKeyboard(InputInfoPtr pInfo) pKbd->consType = xf86Info.consType; } } else { +#ifndef X_PRIVSEP pInfo->fd = open(s, O_RDONLY | O_NONBLOCK | O_EXCL); +#else + pInfo->fd = priv_open_device(s); +#endif if (pInfo->fd == -1) { xf86Msg(X_ERROR, "%s: cannot open \"%s\"\n", pInfo->name, s); xfree(s); @@ -526,12 +532,18 @@ OpenKeyboard(InputInfoPtr pInfo) break; #endif #ifdef WSKBD_TYPE_SUN5 - case WSKBD_TYPE_SUN5: - xf86Msg(X_PROBED, "Keyboard type: Sun5\n"); - break; + case WSKBD_TYPE_SUN5: + printWsType("Sun5", pInfo->name); + break; #endif + case WSKBD_TYPE_LK201: + printWsType("LK-201", pInfo->name); + break; + case WSKBD_TYPE_LK401: + printWsType("LK-401", pInfo->name); + break; default: - xf86Msg(X_ERROR, "%s: Unsupported wskbd type \"%d\"", + xf86Msg(X_ERROR, "%s: Unsupported wskbd type \"%d\"\n", pInfo->name, pKbd->wsKbdType); close(pInfo->fd); return FALSE; diff --git a/xserver/hw/xfree86/os-support/bsd/bsd_mouse.c b/xserver/hw/xfree86/os-support/bsd/bsd_mouse.c index 21fe1ff18..e1708e62a 100644 --- a/xserver/hw/xfree86/os-support/bsd/bsd_mouse.c +++ b/xserver/hw/xfree86/os-support/bsd/bsd_mouse.c @@ -67,6 +67,10 @@ #define UMS_BUT(i) ((i) == 0 ? 2 : (i) == 1 ? 0 : (i) == 2 ? 1 : (i)) #endif /* USBMOUSE_SUPPORT */ +#ifdef X_PRIVSEP +extern int priv_open_device(const char *path); +#endif + #ifdef USBMOUSE_SUPPORT static void usbSigioReadInput (int fd, void *closure); #endif @@ -284,7 +288,11 @@ FindDevice(InputInfoPtr pInfo, const char *protocol, int flags) struct stat sb; for (pdev = mouseDevs; *pdev; pdev++) { +#ifndef X_PRIVSEP SYSCALL (fd = open(*pdev, O_RDWR | O_NONBLOCK)); +#else + fd = priv_open_device(*pdev); +#endif if (fd == -1) { #ifdef DEBUG ErrorF("Cannot open %s (%s)\n", *pdev, strerror(errno)); @@ -367,7 +375,11 @@ FindDevice(InputInfoPtr pInfo, const char *protocol, int flags) const char **pdev; for (pdev = mouseDevs; *pdev; pdev++) { +#ifndef X_PRIVSEP SYSCALL(fd = open(*pdev, O_RDWR | O_NONBLOCK)); +#else + fd = priv_open_device(*pdev); +#endif if (fd != -1) { /* Set the Device option. */ pInfo->conf_idev->commonOptions = diff --git a/xserver/hw/xfree86/os-support/bsd/hp300_video.c b/xserver/hw/xfree86/os-support/bsd/hp300_video.c new file mode 100644 index 000000000..251674bce --- /dev/null +++ b/xserver/hw/xfree86/os-support/bsd/hp300_video.c @@ -0,0 +1,120 @@ +/* $XFree86$ */ +/* $OpenBSD: hp300_video.c,v 1.1 2006/11/28 20:29:31 matthieu Exp $ */ +/* + * Copyright 1992 by Rich Murphey <Rich@Rice.edu> + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Rich Murphey and David Wexelblat + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Rich Murphey and + * David Wexelblat make no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +/* $XConsortium: bsd_video.c /main/10 1996/10/25 11:37:57 kaleb $ */ + +#include "X.h" +#include "xf86.h" +#include "xf86Priv.h" + +#include "xf86_OSlib.h" +#include "xf86OSpriv.h" + +#ifndef MAP_FAILED +#define MAP_FAILED ((caddr_t)-1) +#endif + +/***************************************************************************/ +/* Video Memory Mapping section */ +/***************************************************************************/ + +static pointer hp300MapVidMem(int, unsigned long, unsigned long, int); +static void hp300UnmapVidMem(int, pointer, unsigned long); + + +void +xf86OSInitVidMem(VidMemInfoPtr pVidMem) +{ + pVidMem->linearSupported = TRUE; + pVidMem->mapMem = hp300MapVidMem; + pVidMem->unmapMem = hp300UnmapVidMem; + pVidMem->initialised = TRUE; +} + + +volatile unsigned char *ioBase = MAP_FAILED; + +static pointer +hp300MapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) +{ + int fd = xf86Info.screenFd; + pointer base; + +#ifdef DEBUG + ErrorF("mapVidMem %lx, %lx, fd = %d\n", Base, Size, fd); +#endif + + base = mmap(0, Size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, Base); + if (base == MAP_FAILED) + FatalError("%s: could not mmap screen [s=%x,a=%x] (%s)", + "xf86MapVidMem", Size, Base, strerror(errno)); + + return base; +} + + +static void +hp300UnmapVidMem(int ScreenNum, pointer Base, unsigned long Size) +{ + + munmap(Base, Size); +} + +int +xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, + int Len) +{ + return 0; +} + +/***************************************************************************/ +/* Interrupt Handling section */ +/***************************************************************************/ + +Bool +xf86DisableInterrupts() +{ + + return(TRUE); +} + +void +xf86EnableInterrupts() +{ + + return; +} + +/* + * Do all initialisation that need root privileges + */ +void +xf86PrivilegedInit(void) +{ + /* pciInit(); */ + xf86OpenConsole(); +} diff --git a/xserver/hw/xfree86/os-support/bsd/hppa_video.c b/xserver/hw/xfree86/os-support/bsd/hppa_video.c new file mode 100644 index 000000000..ce5211e84 --- /dev/null +++ b/xserver/hw/xfree86/os-support/bsd/hppa_video.c @@ -0,0 +1,123 @@ +/* $XFree86$ */ +/* $OpenBSD: hppa_video.c,v 1.1 2006/11/28 20:29:31 matthieu Exp $ */ +/* + * Copyright 1992 by Rich Murphey <Rich@Rice.edu> + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Rich Murphey and David Wexelblat + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Rich Murphey and + * David Wexelblat make no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +/* $XConsortium: bsd_video.c /main/10 1996/10/25 11:37:57 kaleb $ */ + +#include "X.h" +#include "xf86.h" +#include "xf86Priv.h" + +#include "xf86_OSlib.h" +#include "xf86OSpriv.h" + +/* #include "bus/Pci.h" */ + +#ifndef MAP_FAILED +#define MAP_FAILED ((caddr_t)-1) +#endif + + +/***************************************************************************/ +/* Video Memory Mapping section */ +/***************************************************************************/ + +static pointer hppaMapVidMem(int, unsigned long, unsigned long, int); +static void hppaUnmapVidMem(int, pointer, unsigned long); + + +void +xf86OSInitVidMem(VidMemInfoPtr pVidMem) +{ + pVidMem->linearSupported = TRUE; + pVidMem->mapMem = hppaMapVidMem; + pVidMem->unmapMem = hppaUnmapVidMem; + pVidMem->initialised = TRUE; +} + + +volatile unsigned char *ioBase = MAP_FAILED; + +static pointer +hppaMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) +{ + int fd = xf86Info.screenFd; + pointer base; + +#ifdef DEBUG + ErrorF("mapVidMem %lx, %lx, fd = %d\n", Base, Size, fd); +#endif + + base = mmap(0, Size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, Base); + if (base == MAP_FAILED) + FatalError("%s: could not mmap screen [s=%x,a=%x] (%s)", + "xf86MapVidMem", Size, Base, strerror(errno)); + + return base; +} + + +static void +hppaUnmapVidMem(int ScreenNum, pointer Base, unsigned long Size) +{ + + munmap(Base, Size); +} + +int +xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, + int Len) +{ + return 0; +} + +/***************************************************************************/ +/* Interrupt Handling section */ +/***************************************************************************/ + +Bool +xf86DisableInterrupts() +{ + + return(TRUE); +} + +void +xf86EnableInterrupts() +{ + + return; +} + +/* + * Do all initialisation that need root privileges + */ +void +xf86PrivilegedInit(void) +{ + /* pciInit(); */ + xf86OpenConsole(); +} diff --git a/xserver/hw/xfree86/os-support/bsd/i386_video.c b/xserver/hw/xfree86/os-support/bsd/i386_video.c index f4ea3f5c9..f8409be18 100644 --- a/xserver/hw/xfree86/os-support/bsd/i386_video.c +++ b/xserver/hw/xfree86/os-support/bsd/i386_video.c @@ -38,7 +38,6 @@ #ifdef HAS_MTRR_SUPPORT #ifndef __NetBSD__ -#include <sys/types.h> #include <sys/memrange.h> #else #include "memrange.h" @@ -73,11 +72,11 @@ #ifdef __OpenBSD__ #define SYSCTL_MSG "\tCheck that you have set 'machdep.allowaperture=1'\n"\ "\tin /etc/sysctl.conf and reboot your machine\n" \ - "\trefer to xf86(4) for details" + "\trefer to xf86(4) for details\n" #define SYSCTL_MSG2 \ "Check that you have set 'machdep.allowaperture=2'\n" \ "\tin /etc/sysctl.conf and reboot your machine\n" \ - "\trefer to xf86(4) for details" + "\trefer to xf86(4) for details\n" #endif /***************************************************************************/ @@ -126,78 +125,64 @@ checkDevMem(Bool warn) return; devMemChecked = TRUE; - if ((fd = open(DEV_MEM, O_RDWR)) >= 0) - { +#ifdef HAS_APERTURE_DRV + /* Try the aperture driver first */ + if ((fd = open(DEV_APERTURE, O_RDWR)) >= 0) { /* Try to map a page at the VGA address */ base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE, - MAP_FLAGS, fd, (off_t)0xA0000); - - if (base != MAP_FAILED) - { + MAP_FLAGS, fd, (off_t)0xA0000); + + if (base != MAP_FAILED) { munmap((caddr_t)base, 4096); devMemFd = fd; useDevMem = TRUE; + xf86Msg(X_PROBED, "checkDevMem: using aperture driver %s\n", + DEV_APERTURE); return; } else { - /* This should not happen */ - if (warn) - { + if (warn) { xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n", - DEV_MEM, strerror(errno)); + DEV_APERTURE, strerror(errno)); } - useDevMem = FALSE; - return; } - } -#ifndef HAS_APERTURE_DRV - if (warn) - { - xf86Msg(X_WARNING, "checkDevMem: failed to open %s (%s)\n", - DEV_MEM, strerror(errno)); } - useDevMem = FALSE; - return; -#else - /* Failed to open /dev/mem, try the aperture driver */ - if ((fd = open(DEV_APERTURE, O_RDWR)) >= 0) - { +#endif + if ((fd = open(DEV_MEM, O_RDWR)) >= 0) { /* Try to map a page at the VGA address */ base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE, - MAP_FLAGS, fd, (off_t)0xA0000); + MAP_FLAGS, fd, (off_t)0xA0000); - if (base != MAP_FAILED) - { + if (base != MAP_FAILED) { munmap((caddr_t)base, 4096); devMemFd = fd; useDevMem = TRUE; - xf86Msg(X_INFO, "checkDevMem: using aperture driver %s\n", - DEV_APERTURE); return; } else { - - if (warn) - { + if (warn) { xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n", - DEV_APERTURE, strerror(errno)); + DEV_MEM, strerror(errno)); } } - } else { - if (warn) - { + } + if (warn) { +#ifndef HAS_APERTURE_DRV + xf86Msg(X_WARNING, "checkDevMem: failed to open/mmap %s (%s)\n", + DEV_MEM, strerror(errno)); + xf86ErrorF("\tlinear framebuffer access unavailable\n"); +#else #ifndef __OpenBSD__ - xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n" - "\t(%s)\n", DEV_MEM, DEV_APERTURE, strerror(errno)); + xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n" + "\t(%s)\n", DEV_APERTURE, DEV_MEM, strerror(errno)); #else /* __OpenBSD__ */ - xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n" - "\t(%s)\n%s", DEV_MEM, DEV_APERTURE, strerror(errno), - SYSCTL_MSG); + xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n" + "\t(%s)\n%s", DEV_APERTURE, DEV_MEM, strerror(errno), + SYSCTL_MSG); #endif /* __OpenBSD__ */ - } + + xf86ErrorF("\tlinear framebuffer access unavailable\n"); } - useDevMem = FALSE; return; - #endif } @@ -265,8 +250,7 @@ mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) (flags & VIDMEM_READONLY) ? PROT_READ : (PROT_READ | PROT_WRITE), MAP_FLAGS, xf86Info.screenFd, - (unsigned long)Base - 0xA0000 - ); + (unsigned long)Base - 0xA0000); if (base == MAP_FAILED) { FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)", @@ -365,9 +349,12 @@ xf86DisableIO() if (!ExtendedEnabled) return; - i386_iopl(FALSE); - ExtendedEnabled = FALSE; - + if (i386_iopl(FALSE) == 0) { + ExtendedEnabled = FALSE; + } + /* Otherwise, the X server has revoqued its root uid, + and thus cannot give up IO privileges any more */ + return; } @@ -996,3 +983,17 @@ amd64undoWC(int screenNum, pointer list) } #endif /* OpenBSD/amd64 */ +#ifdef X_PRIVSEP +/* + * Do all things that need root privileges early + * and revoke those privileges + */ +_X_EXPORT void +xf86PrivilegedInit(void) +{ + checkDevMem(TRUE); + xf86EnableIO(); + xf86OpenConsole(); + xf86AgpGARTSupported(); +} +#endif diff --git a/xserver/hw/xfree86/os-support/bsd/ppc_video.c b/xserver/hw/xfree86/os-support/bsd/ppc_video.c index ae65c8f15..04a8dc224 100644 --- a/xserver/hw/xfree86/os-support/bsd/ppc_video.c +++ b/xserver/hw/xfree86/os-support/bsd/ppc_video.c @@ -83,7 +83,7 @@ ppcMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) PROT_READ : (PROT_READ | PROT_WRITE), MAP_SHARED, fd, Base); if (base == MAP_FAILED) - FatalError("%s: could not mmap screen [s=%x,a=%x] (%s)", + FatalError("%s: could not mmap screen [s=%lx,a=%lx] (%s)", "xf86MapVidMem", Size, Base, strerror(errno)); return base; @@ -95,12 +95,18 @@ ppcUnmapVidMem(int ScreenNum, pointer Base, unsigned long Size) munmap(Base, Size); } +static int kmem = -1; + _X_EXPORT int xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, int Len) { int rv; - static int kmem = -1; + + if (Base < 0x80000000) { + xf86Msg(X_WARNING, "No VGA Base=%#lx\n", Base); + return 0; + } if (kmem == -1) { kmem = open(DEV_MEM, 2); @@ -138,3 +144,21 @@ xf86EnableInterrupts() return; } + +#ifdef X_PRIVSEP +/* + * Do all initialisation that need root privileges + */ +_X_EXPORT void +xf86PrivilegedInit(void) +{ + kmem = open(DEV_MEM, 2); + if (kmem == -1) { + xf86Msg(X_PROBED, + "no aperture driver access: only wsfb driver useable\n"); + } else { + pciInit(); + } + xf86OpenConsole(); +} +#endif diff --git a/xserver/hw/xfree86/os-support/bsd/sparc64_video.c b/xserver/hw/xfree86/os-support/bsd/sparc64_video.c index 0cb9d4d56..d2ba20e35 100644 --- a/xserver/hw/xfree86/os-support/bsd/sparc64_video.c +++ b/xserver/hw/xfree86/os-support/bsd/sparc64_video.c @@ -110,3 +110,16 @@ xf86EnableInterrupts() return; } + +#ifdef X_PRIVSEP +/* + * Do all things that need root privileges early + * and revoke those privileges + */ +_X_EXPORT void +xf86PrivilegedInit(void) +{ + pciInit(); + xf86OpenConsole(); +} +#endif diff --git a/xserver/hw/xfree86/os-support/bus/Pci.h b/xserver/hw/xfree86/os-support/bus/Pci.h index 7cc882d36..715ae5fda 100644 --- a/xserver/hw/xfree86/os-support/bus/Pci.h +++ b/xserver/hw/xfree86/os-support/bus/Pci.h @@ -250,11 +250,20 @@ # define INCLUDE_XF86_MAP_PCI_MEM # define INCLUDE_XF86_NO_DOMAIN # endif +# if defined(__OpenBSD__) +# define ARCH_PCI_INIT freebsdPciInit +# define INCLUDE_XF86_MAP_PCI_MEM +# define INCLUDE_XF86_NO_DOMAIN +# endif #elif defined(__hppa__) # if defined(linux) # define ARCH_PCI_INIT linuxPciInit # define INCLUDE_XF86_MAP_PCI_MEM # define INCLUDE_XF86_NO_DOMAIN +# elif defined(__OpenBSD__) +# define ARCH_PCI_INIT freebsdPciInit +# define INCLUDE_XF86_MAP_PCI_MEM +# define INCLUDE_XF86_NO_DOMAIN # endif #elif defined(__ia64__) # if defined(linux) @@ -267,7 +276,11 @@ # endif # define XF86SCANPCI_WRAPPER ia64ScanPCIWrapper #elif defined(__i386__) || defined(i386) -# define ARCH_PCI_INIT ix86PciInit +# if defined(__OpenBSD__) +# define ARCH_PCI_INIT freebsdPciInit +# else +# define ARCH_PCI_INIT ix86PciInit +# endif # define INCLUDE_XF86_MAP_PCI_MEM # define INCLUDE_XF86_NO_DOMAIN # if defined(linux) @@ -278,6 +291,16 @@ # define ARCH_PCI_INIT linuxPciInit # define INCLUDE_XF86_MAP_PCI_MEM # define INCLUDE_XF86_NO_DOMAIN +# elif defined(__OpenBSD__) +# define ARCH_PCI_INIT freebsdPciInit +# define INCLUDE_XF86_MAP_PCI_MEM +# define INCLUDE_XF86_NO_DOMAIN +# endif +#elif defined(__mc68020__) +# if defined(__OpenBSD__) +# define ARCH_PCI_INIT freebsdPciInit +# define INCLUDE_XF86_MAP_PCI_MEM +# define INCLUDE_XF86_NO_DOMAIN # endif #elif defined(__mips__) # if defined(linux) @@ -327,9 +350,21 @@ # define INCLUDE_XF86_MAP_PCI_MEM # define INCLUDE_XF86_NO_DOMAIN # endif -# if !defined(__FreeBSD__) +# if !defined(__FreeBSD__) && !defined(__OpenBSD__) # define ARCH_PCI_PCI_BRIDGE sparcPciPciBridge # endif +#elif defined(__sparc64__) +# if defined(__OpenBSD__) +# define ARCH_PCI_INIT freebsdPciInit +# define INCLUDE_XF86_MAP_PCI_MEM +# define INCLUDE_XF86_NO_DOMAIN +# endif +#elif defined(__vax__) +# if defined(__OpenBSD__) +# define ARCH_PCI_INIT freebsdPciInit +# define INCLUDE_XF86_MAP_PCI_MEM +# define INCLUDE_XF86_NO_DOMAIN +# endif #elif defined(__amd64__) || defined(__amd64) # if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) # define ARCH_PCI_INIT freebsdPciInit diff --git a/xserver/hw/xfree86/os-support/bus/freebsdPci.c b/xserver/hw/xfree86/os-support/bus/freebsdPci.c index 61cb405a8..97782f296 100644 --- a/xserver/hw/xfree86/os-support/bus/freebsdPci.c +++ b/xserver/hw/xfree86/os-support/bus/freebsdPci.c @@ -118,7 +118,11 @@ static int pciFd = -1; void freebsdPciInit() { +#ifndef X_PRIVSEP pciFd = open("/dev/pci", O_RDWR); +#else + pciFd = priv_open_device("/dev/pci"); +#endif if (pciFd < 0) return; diff --git a/xserver/hw/xfree86/os-support/shared/libc_wrapper.c b/xserver/hw/xfree86/os-support/shared/libc_wrapper.c index 4c4af4c24..6ebac9e4c 100644 --- a/xserver/hw/xfree86/os-support/shared/libc_wrapper.c +++ b/xserver/hw/xfree86/os-support/shared/libc_wrapper.c @@ -1870,7 +1870,7 @@ xf86getpagesize() if (pagesize == -1) pagesize = getpagesize(); #endif -#ifdef PAGE_SIZE +#if defined(PAGE_SIZE) && !defined(__OpenBSD__) /* XXX */ if (pagesize == -1) pagesize = PAGE_SIZE; #endif diff --git a/xserver/hw/xfree86/os-support/shared/posix_tty.c b/xserver/hw/xfree86/os-support/shared/posix_tty.c index 6e1b54331..6d9cafe42 100644 --- a/xserver/hw/xfree86/os-support/shared/posix_tty.c +++ b/xserver/hw/xfree86/os-support/shared/posix_tty.c @@ -63,6 +63,10 @@ #include "xf86Priv.h" #include "xf86_OSlib.h" +#ifdef X_PRIVSEP +extern int priv_open_device(const char *); +#endif + static int GetBaud (int baudrate) { @@ -129,8 +133,11 @@ xf86OpenSerial (pointer options) xf86Msg (X_ERROR, "xf86OpenSerial: No Device specified.\n"); return (-1); } - +#ifndef X_PRIVSEP SYSCALL (fd = open (dev, O_RDWR | O_NONBLOCK)); +#else + fd = priv_open_device (dev); +#endif if (fd == -1) { xf86Msg (X_ERROR, diff --git a/xserver/hw/xfree86/os-support/shared/sigio.c b/xserver/hw/xfree86/os-support/shared/sigio.c index f6c15c28f..c6fa6c752 100644 --- a/xserver/hw/xfree86/os-support/shared/sigio.c +++ b/xserver/hw/xfree86/os-support/shared/sigio.c @@ -101,6 +101,7 @@ xf86SIGIO (int sig) int i; fd_set ready; struct timeval to; + int save_errno = errno; /* do not clobber the global errno */ int r; ready = xf86SigIOMask; @@ -117,6 +118,8 @@ xf86SIGIO (int sig) if (r > 0) { xf86Msg(X_ERROR, "SIGIO %d descriptors not handled\n", r); } + /* restore global errno */ + errno = save_errno; } static int diff --git a/xserver/hw/xfree86/os-support/xf86OSmouse.h b/xserver/hw/xfree86/os-support/xf86OSmouse.h index 600683866..bb42bf907 100644 --- a/xserver/hw/xfree86/os-support/xf86OSmouse.h +++ b/xserver/hw/xfree86/os-support/xf86OSmouse.h @@ -70,6 +70,7 @@ typedef enum { PROT_BM, PROT_AUTO, PROT_SYSMOUSE, + PROT_SUNMOUSE, PROT_NUMPROTOS /* This must always be last. */ } MouseProtocolID; diff --git a/xserver/hw/xfree86/utils/xorgcfg/startx.c b/xserver/hw/xfree86/utils/xorgcfg/startx.c index 7b730c9aa..983406a6e 100644 --- a/xserver/hw/xfree86/utils/xorgcfg/startx.c +++ b/xserver/hw/xfree86/utils/xorgcfg/startx.c @@ -108,8 +108,15 @@ startx(void) XmuSnprintf(path, sizeof(path), "%s/"__XSERVERNAME__, XFree86_path); else XmuSnprintf(path, sizeof(path), "%s/bin/"__XSERVERNAME__, XFree86Dir); - execl(path, "X", ":8", /*"+xinerama",*/ "+accessx","-allowMouseOpenFail", +#ifndef X_PRIVSEP + execl(path, "X", ":8", /*"+xinerama",*/ "+accessx", + "-allowMouseOpenFail", "-nolisten", "tcp", "-xf86config", XF86Config_path, (void *)NULL); +#else + execl(path, "X", ":8", /*"+xinerama",*/ "+accessx", + "-allowMouseOpenFail", "-keepPriv", "-nolisten", "tcp", + "-xf86config", XF86Config_path, (void *)NULL); +#endif exit(-127); } break; case -1: diff --git a/xserver/hw/xfree86/utils/xorgcfg/stubs.c b/xserver/hw/xfree86/utils/xorgcfg/stubs.c index 47b2c2d5a..0250a8cc0 100644 --- a/xserver/hw/xfree86/utils/xorgcfg/stubs.c +++ b/xserver/hw/xfree86/utils/xorgcfg/stubs.c @@ -40,7 +40,7 @@ static char dummy; #endif -#if !defined(USE_MODULES) +#if 0 /* these are defined in libdummy.a */ int ErrorF(const char *fmt, ...) diff --git a/xserver/hw/xfree86/utils/xorgcfg/text-mode.c b/xserver/hw/xfree86/utils/xorgcfg/text-mode.c index 10f4b698f..c0de0ff89 100644 --- a/xserver/hw/xfree86/utils/xorgcfg/text-mode.c +++ b/xserver/hw/xfree86/utils/xorgcfg/text-mode.c @@ -50,12 +50,12 @@ (strcmp((X), "keyboard") == 0)) #ifndef PROJECT_ROOT -#define PROJECT_ROOT "/usr" +#define PROJECT_ROOT "/usr/X11R6" #endif #ifndef XKB_RULES_DIR #ifndef __UNIXOS2__ -#define XKB_RULES_DIR PROJECT_ROOT "/share/X11/xkb/rules" +#define XKB_RULES_DIR PROJECT_ROOT "/lib/X11/xkb/rules" #else #define XKB_RULES_DIR XF86CONFIGDIR "/xkb/rules" #endif @@ -396,7 +396,7 @@ static char *protocols[] = { static int MouseConfig(void) { - int i, nlist, def, proto, emul; + int i, nlist, def, proto, emul, wheel; char **list = NULL, *device, *str; XF86ConfInputPtr *inputs = NULL; XF86ConfInputPtr input = XF86Config->conf_input_lst; @@ -544,6 +544,17 @@ MouseConfig(void) return (i); emul = !i; + ClearScreen(); + refresh(); + i = Dialog("Mouse Wheel configuration", + "If your mouse has a wheel, you can enable it now.\n" + "\n" + "Do you want to enable the mouse wheel?", + 10, 60, " Yes ", " No ", def); + if (i < 0) + return (i); + wheel = !i; + str = NULL; option = xf86findOption(input->inp_option_lst, "Device"); if (option) @@ -592,6 +603,15 @@ MouseConfig(void) input->inp_option_lst = xf86addNewOption(input->inp_option_lst, XtNewString("Emulate3Buttons"), NULL); + if (wheel) { + option = xf86findOption(input->inp_option_lst, "ZAxisMapping"); + if (option) { + XtFree((XtPointer)option->opt_val); + option->opt_val = XtNewString("4 5"); + } else + input->inp_option_lst = xf86addNewOption(input->inp_option_lst, + XtNewString("ZAxisMapping"), XtNewString("4 5")); + } option = xf86findOption(input->inp_option_lst, "Device"); if (option) { XtFree((XtPointer)option->opt_val); diff --git a/xserver/hw/xfree86/utils/xorgconfig/xorgconfig.c b/xserver/hw/xfree86/utils/xorgconfig/xorgconfig.c index f00eea038..5806027ca 100644 --- a/xserver/hw/xfree86/utils/xorgconfig/xorgconfig.c +++ b/xserver/hw/xfree86/utils/xorgconfig/xorgconfig.c @@ -154,7 +154,7 @@ static int getuid() { return 0; } * may be more irritated than Unix users */ #ifndef PROJECTROOT -#define PROJECTROOT "/usr" +#define PROJECTROOT "/usr/X11R6" #endif #define TREEROOT PROJECTROOT #define TREEROOTLX TREEROOT "/lib/X11" @@ -203,11 +203,18 @@ static int getuid() { return 0; } #endif #endif +#if defined(__OpenBSD__) && defined(WSCONS_SUPPORT) && !defined(PCVT_SUPPORT) +/* OpenBSD/macppc now has support for Standard kbd protocol under wscons */ +# ifndef __powerpc__ +# define NEED_WSKBD +# endif +#endif int config_mousetype; /* Mouse. */ int config_emulate3buttons; int config_chordmiddle; int config_cleardtrrts; +int config_wheel; char *config_pointerdevice; int config_altmeta; /* Keyboard. */ int config_monitortype; /* Monitor. */ @@ -229,7 +236,7 @@ int config_virtualx24bpp, config_virtualy24bpp; char *config_ramdac; char *config_dacspeed; char *config_clockchip; -#if defined(__OpenBSD__) && defined(WSCONS_SUPPORT) && !defined(PCVT_SUPPORT) +#ifdef NEED_WSKBD char *config_keyboard_dev = "/dev/wskbd0"; #endif int config_xkbdisable = 0; @@ -642,7 +649,7 @@ mouse_configuration(void) { printf("\n"); - printf("Please answer the following question with either 'y' or 'n'.\n"); + printf("Please answer the following questions with either 'y' or 'n'.\n"); printf("Do you want to enable Emulate3Buttons? "); getstring(s); if (answerisyes(s)) @@ -651,6 +658,14 @@ mouse_configuration(void) { config_emulate3buttons = 0; printf("\n"); + printf("Do you want to configure a mouse wheel? "); + getstring(s); + if (answerisyes(s)) + config_wheel = 1; + else + config_wheel = 0; + printf("\n"); + #if (defined(sun) && (defined(__i386) || defined(__x86))) /* SPARC & USB mice (VUID or AUTO protocols) default to /dev/mouse, but PS/2 mice default to /dev/kdmouse */ @@ -709,7 +724,7 @@ static char *xkboptionstext = "Do you want to select additional XKB options (group switcher,\n" "group indicator, etc.)? "; -#if defined(__OpenBSD__) && defined(WSCONS_SUPPORT) && !defined(PCVT_SUPPORT) +#ifdef NEED_WSKBD static char *kbdevtext = "Please enter the device name for your keyboard or just press enter\n" "for the default of wskbd0\n\n"; @@ -724,7 +739,7 @@ keyboard_configuration(void) int number, options[MAX_XKBOPTIONS], num_options; XkbRF_RulesPtr rules; -#if defined(__OpenBSD__) && defined(WSCONS_SUPPORT) && !defined(PCVT_SUPPORT) +#ifdef NEED_WSKBD printf(kbdevtext); getstring(s); if (strlen(s) != 0) { @@ -2589,7 +2604,7 @@ write_XF86Config(char *filename) fprintf(f, "# Option \"LeftAlt\" \"Meta\"\n"); fprintf(f, "# Option \"RightAlt\" \"ModeShift\"\n"); } -#if defined(__OpenBSD__) && defined(WSCONS_SUPPORT) && !defined(PCVT_SUPPORT) +#ifdef NEED_WSKBD /* wscons keyoards need a protocol line */ fprintf(f, " Option \"Protocol\" \"wskbd\"\n"); fprintf(f, " Option \"Device\" \"%s\"\n", config_keyboard_dev); @@ -2641,6 +2656,11 @@ write_XF86Config(char *filename) fprintf(f, " Option \"ClearDTR\"\n"); fprintf(f, " Option \"ClearRTS\"\n\n"); } + fprintf(f, "# ZaxisMapping is an option for handling the wheel\n"); + if (!config_wheel) + fprintf(f, "#"); + fprintf(f, " Option \"ZAxisMapping\" \"4 5\"\n\n"); + fprintf(f, "EndSection\n\n\n"); /* diff --git a/xserver/include/dix-config.h b/xserver/include/dix-config.h deleted file mode 100644 index c70141e9e..000000000 --- a/xserver/include/dix-config.h +++ /dev/null @@ -1,452 +0,0 @@ -/* include/dix-config.h. Generated by configure. */ -/* dix-config.h.in: not at all generated. -*- c -*- */ - -#ifndef _DIX_CONFIG_H_ -#define _DIX_CONFIG_H_ - -/* Support BigRequests extension */ -#define BIGREQS 1 - -/* Builder address */ -#define BUILDERADDR "xorg@lists.freedesktop.org" - -/* Operating System Name */ -#define OSNAME "Linux 2.6.18-1.2708.fc6xen i686" - -/* Operating System Vendor */ -#define OSVENDOR "" - -/* Default font path */ -#define COMPILEDDEFAULTFONTPATH "/usr/local/lib/X11/fonts/misc/,/usr/local/lib/X11/fonts/TTF/,/usr/local/lib/X11/fonts/OTF,/usr/local/lib/X11/fonts/Type1/,/usr/local/lib/X11/fonts/CID/,/usr/local/lib/X11/fonts/100dpi/,/usr/local/lib/X11/fonts/75dpi/" - -/* Support Composite Extension */ -#define COMPOSITE 1 - -/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP - systems. This function is required for `alloca.c' support on those systems. - */ -/* #undef CRAY_STACKSEG_END */ - -/* Define to 1 if using `alloca.c'. */ -/* #undef C_ALLOCA */ - -/* Support Damage extension */ -#define DAMAGE 1 - -/* Use OsVendorInit */ -#define DDXOSINIT 1 - -/* Use GetTimeInMillis */ -/* #undef DDXTIME */ - -/* Use OsVendorFatalError */ -/* #undef DDXOSFATALERROR */ - -/* Use OsVendorVErrorF */ -/* #undef DDXOSVERRORF */ - -/* Use ddxBeforeReset */ -/* #undef DDXBEFORERESET */ - -/* Build DPMS extension */ -#define DPMSExtension 1 - -/* Build GLX extension */ -/* #undef GLXEXT */ - -/* Build GLX DRI loader */ -/* #undef GLX_DRI */ - -/* Path to DRI drivers */ -#define DRI_DRIVER_PATH "/usr/local/lib/dri" - -/* Include handhelds.org h3600 touchscreen driver */ -/* #undef H3600_TS */ - -/* Support XDM-AUTH*-1 */ -#define HASXDMAUTH 1 - -/* Define to 1 if you have the `getdtablesize' function. */ -#define HAS_GETDTABLESIZE 1 - -/* Define to 1 if you have the `getifaddrs' function. */ -#define HAS_GETIFADDRS 1 - -/* Define to 1 if you have the `getpeereid' function. */ -/* #undef HAS_GETPEEREID */ - -/* Define to 1 if you have the `getpeerucred' function. */ -/* #undef HAS_GETPEERUCRED */ - -/* Define to 1 if you have the `mmap' function. */ -#define HAS_MMAP 1 - -/* Support SHM */ -#define HAS_SHM 1 - -/* Define to 1 if you have `alloca', as a function or macro. */ -#define HAVE_ALLOCA 1 - -/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix). - */ -#define HAVE_ALLOCA_H 1 - -/* Define to 1 if you have the <asm/mtrr.h> header file. */ -#define HAVE_ASM_MTRR_H 1 - -/* Define to 1 if you have the <dbm.h> header file. */ -/* #undef HAVE_DBM_H */ - -/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'. - */ -#define HAVE_DIRENT_H 1 - -/* Define to 1 if you have the <dlfcn.h> header file. */ -#define HAVE_DLFCN_H 1 - -/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ -/* #undef HAVE_DOPRNT */ - -/* Define to 1 if you have the <fcntl.h> header file. */ -#define HAVE_FCNTL_H 1 - -/* Define to 1 if you have the `geteuid' function. */ -#define HAVE_GETEUID 1 - -/* Define to 1 if you have the `getisax' function. */ -/* #undef HAVE_GETISAX */ - -/* Define to 1 if you have the `getopt' function. */ -#define HAVE_GETOPT 1 - -/* Define to 1 if you have the `getopt_long' function. */ -#define HAVE_GETOPT_LONG 1 - -/* Define to 1 if you have the `getuid' function. */ -#define HAVE_GETUID 1 - -/* Define to 1 if you have the <inttypes.h> header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the `m' library (-lm). */ -#define HAVE_LIBM 1 - -/* Define to 1 if you have the `link' function. */ -#define HAVE_LINK 1 - -/* Define to 1 if you have the <linux/agpgart.h> header file. */ -#define HAVE_LINUX_AGPGART_H 1 - -/* Define to 1 if you have the <linux/apm_bios.h> header file. */ -#define HAVE_LINUX_APM_BIOS_H 1 - -/* Define to 1 if you have the <linux/fb.h> header file. */ -#define HAVE_LINUX_FB_H 1 - -/* Define to 1 if you have the <linux/h3600_ts.h> header file. */ -/* #undef HAVE_LINUX_H3600_TS_H */ - -/* Define to 1 if you have the `memmove' function. */ -#define HAVE_MEMMOVE 1 - -/* Define to 1 if you have the <memory.h> header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if you have the `memset' function. */ -#define HAVE_MEMSET 1 - -/* Define to 1 if you have the `mkstemp' function. */ -#define HAVE_MKSTEMP 1 - -/* Define to 1 if you have the <ndbm.h> header file. */ -/* #undef HAVE_NDBM_H */ - -/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */ -/* #undef HAVE_NDIR_H */ - -/* Define to 1 if you have the <rpcsvc/dbm.h> header file. */ -/* #undef HAVE_RPCSVC_DBM_H */ - -/* Define to 1 if you have the <stdint.h> header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the <stdlib.h> header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the `strchr' function. */ -#define HAVE_STRCHR 1 - -/* Define to 1 if you have the <strings.h> header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the <string.h> header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the `strrchr' function. */ -#define HAVE_STRRCHR 1 - -/* Define to 1 if you have the `strtol' function. */ -#define HAVE_STRTOL 1 - -/* Define to 1 if SYSV IPC is available */ -#define HAVE_SYSV_IPC 1 - -/* Define to 1 if you have the <sys/agpio.h> header file. */ -/* #undef HAVE_SYS_AGPIO_H */ - -/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'. - */ -/* #undef HAVE_SYS_DIR_H */ - -/* Define to 1 if you have the <sys/io.h> header file. */ -/* #undef HAVE_SYS_IO_H */ - -/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'. - */ -/* #undef HAVE_SYS_NDIR_H */ - -/* Define to 1 if you have the <sys/stat.h> header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the <sys/types.h> header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the <sys/vm86.h> header file. */ -/* #undef HAVE_SYS_VM86_H */ - -/* Define to 1 if you have the <tslib.h> header file. */ -/* #undef HAVE_TSLIB_H */ - -/* Define to 1 if you have the <unistd.h> header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to 1 if you have the `vprintf' function. */ -#define HAVE_VPRINTF 1 - -/* Support IPv6 for TCP connections */ -#define IPv6 1 - -/* Support os-specific local connections */ -/* #undef LOCALCONN */ - -/* Support MIT Misc extension */ -#define MITMISC 1 - -/* Support MIT-SHM Extension */ -#define MITSHM 1 - -/* Disable some debugging code */ -#define NDEBUG 1 - -/* Enable some debugging code */ -/* #undef DEBUG */ - -/* Name of package */ -#define PACKAGE "xorg-server" - -/* Internal define for Xinerama */ -#define PANORAMIX 1 - -/* Support pixmap privates */ -#define PIXPRIV 1 - -/* Overall prefix */ -#define PROJECTROOT "/usr/local" - -/* Support RANDR extension */ -#define RANDR 1 - -/* Support Record extension */ -#define XRECORD 1 - -/* Support RENDER extension */ -#define RENDER 1 - -/* Support X resource extension */ -#define RES 1 - -/* Support MIT-SCREEN-SAVER extension */ -#define SCREENSAVER 1 - -/* Use a lock to prevent multiple servers on a display */ -#define SERVER_LOCK 1 - -/* Support SHAPE extension */ -#define SHAPE 1 - -/* Include time-based scheduler */ -#define SMART_SCHEDULE 1 - -/* If using the C implementation of alloca, define if you know the - direction of stack growth for your system; otherwise it will be - automatically deduced at run-time. - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown */ -/* #undef STACK_DIRECTION */ - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define to 1 on systems derived from System V Release 4 */ -/* #undef SVR4 */ - -/* Support TCP socket connections */ -#define TCPCONN 1 - -/* Enable touchscreen support */ -/* #undef TOUCHSCREEN */ - -/* Support tslib touchscreen abstraction library */ -/* #undef TSLIB */ - -/* Support UNIX socket connections */ -#define UNIXCONN 1 - -/* Use builtin rgb color database */ -/* #undef USE_RGB_BUILTIN */ - -/* Use rgb.txt directly */ -#define USE_RGB_TXT 1 - -/* unaligned word accesses behave as expected */ -/* #undef WORKING_UNALIGNED_INT */ - -/* Build X-ACE extension */ -#define XACE 1 - -/* Support XCMisc extension */ -#define XCMISC 1 - -/* Build Security extension */ -#define XCSECURITY 1 - -/* Support Xdmcp */ -#define XDMCP 1 - -/* Build XEvIE extension */ -#define XEVIE 1 - -/* Build XFree86 BigFont extension */ -#define XF86BIGFONT 1 - -/* Support XFree86 miscellaneous extensions */ -#define XF86MISC 1 - -/* Support XFree86 Video Mode extension */ -#define XF86VIDMODE 1 - -/* Support XFixes extension */ -#define XFIXES 1 - -/* Build XDGA support */ -#define XFreeXDGA 1 - -/* Support Xinerama extension */ -#define XINERAMA 1 - -/* Support X Input extension */ -#define XINPUT 1 - -/* Build XKB */ -#define XKB 1 - -/* Enable XKB per default */ -#define XKB_DFLT_DISABLED 0 - -/* Build XKB server */ -#define XKB_IN_SERVER 1 - -/* Vendor release */ -#define XORG_RELEASE "Release 7.1.99.902" - -/* Current Xorg version */ -#define XORG_VERSION_CURRENT (((7) * 10000000) + ((1) * 100000) + ((99) * 1000) + 902) - -/* Xorg release date */ -#define XORG_DATE "13 November 2006" - -/* Build Xv Extension */ -#define XvExtension 1 - -/* Build XvMC Extension */ -#define XvMCExtension 1 - -/* Build XRes extension */ -#define XResExtension 1 - -/* Support XSync extension */ -#define XSYNC 1 - -/* Support XTest extension */ -#define XTEST 1 - -/* Support XTrap extension */ -#define XTRAP 1 - -/* Support Xv extension */ -#define XV 1 - -/* Build APPGROUP extension */ -#define XAPPGROUP 1 - -/* Build TOG-CUP extension */ -#define TOGCUP 1 - -/* Build Extended-Visual-Information extension */ -#define EVI 1 - -/* Build Multibuffer extension */ -/* #undef MULTIBUFFER */ - -/* Support DRI extension */ -#define XF86DRI 1 - -/* Build DBE support */ -#define DBE 1 - -/* Vendor name */ -#define XVENDORNAME "The X.Org Foundation" - -/* Endian order */ -#define X_BYTE_ORDER X_LITTLE_ENDIAN - -/* BSD-compliant source */ -#define _BSD_SOURCE 1 - -/* POSIX-compliant source */ -#define _POSIX_SOURCE 1 - -#ifndef _XOPEN_SOURCE -/* X/Open-compliant source */ -#define _XOPEN_SOURCE 500 -#endif - -/* Define to empty if `const' does not conform to ANSI C. */ -/* #undef const */ - -/* Define to `int' if <sys/types.h> does not define. */ -/* #undef pid_t */ - -/* Build Rootless code */ -/* #undef ROOTLESS */ - -/* Define to 1 if unsigned long is 64 bits. */ -/* #undef _XSERVER64 */ - -/* Define to location of RGB database */ -#define RGB_DB "/usr/local/share/X11/rgb" - -/* System is BSD-like */ -/* #undef CSRG_BASED */ - -/* Define to 1 if `struct sockaddr_in' has a `sin_len' member */ -/* #undef BSD44SOCKETS */ - -/* Define to 1 if modules should avoid the libcwrapper */ -#define NO_LIBCWRAPPER 1 - -/* Have a monotonic clock from clock_gettime() */ -#define MONOTONIC_CLOCK 1 - -#endif /* _DIX_CONFIG_H_ */ diff --git a/xserver/include/dix-config.h.in b/xserver/include/dix-config.h.in index 35700e460..e12329062 100644 --- a/xserver/include/dix-config.h.in +++ b/xserver/include/dix-config.h.in @@ -448,4 +448,7 @@ /* Have a monotonic clock from clock_gettime() */ #undef MONOTONIC_CLOCK +/* Use X server privilege separation */ +#undef X_PRIVSEP + #endif /* _DIX_CONFIG_H_ */ diff --git a/xserver/include/do-not-use-config.h b/xserver/include/do-not-use-config.h deleted file mode 100644 index 893e49fd9..000000000 --- a/xserver/include/do-not-use-config.h +++ /dev/null @@ -1,650 +0,0 @@ -/* include/do-not-use-config.h. Generated by configure. */ -/* include/do-not-use-config.h.in. Generated from configure.ac by autoheader. */ - -/* Build AIGLX loader */ -/* #undef AIGLX */ - -/* Default base font path */ -#define BASE_FONT_PATH "/usr/local/lib/X11/fonts" - -/* Support BigRequests extension */ -#define BIGREQS 1 - -/* Define to 1 if `struct sockaddr_in' has a `sin_len' member */ -/* #undef BSD44SOCKETS */ - -/* Builder address */ -#define BUILDERADDR "xorg@lists.freedesktop.org" - -/* Default font path */ -#define COMPILEDDEFAULTFONTPATH "/usr/local/lib/X11/fonts/misc/,/usr/local/lib/X11/fonts/TTF/,/usr/local/lib/X11/fonts/OTF,/usr/local/lib/X11/fonts/Type1/,/usr/local/lib/X11/fonts/CID/,/usr/local/lib/X11/fonts/100dpi/,/usr/local/lib/X11/fonts/75dpi/" - -/* Support Composite Extension */ -#define COMPOSITE 1 - -/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP - systems. This function is required for `alloca.c' support on those systems. - */ -/* #undef CRAY_STACKSEG_END */ - -/* System is BSD-like */ -/* #undef CSRG_BASED */ - -/* Simple debug messages */ -/* #undef CYGDEBUG */ - -/* Debug window manager */ -/* #undef CYGMULTIWINDOW_DEBUG */ - -/* Debug messages for window handling */ -/* #undef CYGWINDOWING_DEBUG */ - -/* Define to 1 if using `alloca.c'. */ -/* #undef C_ALLOCA */ - -/* Support Damage extension */ -#define DAMAGE 1 - -/* Support DBE extension */ -#define DBE 1 - -/* Use ddxBeforeReset */ -/* #undef DDXBEFORERESET */ - -/* Use OsVendorFatalError */ -/* #undef DDXOSFATALERROR */ - -/* Use OsVendorInit */ -#define DDXOSINIT 1 - -/* Use OsVendorVErrorF */ -/* #undef DDXOSVERRORF */ - -/* Use GetTimeInMillis */ -/* #undef DDXTIME */ - -/* Default log location */ -#define DEFAULT_LOGPREFIX "/usr/local/var/log/Xorg." - -/* Default module search path */ -#define DEFAULT_MODULE_PATH "/usr/local/lib/xorg/modules" - -/* Support DGA extension */ -#define DGA 1 - -/* Support DPMS extension */ -#define DPMSExtension 1 - -/* Built-in output drivers (none) */ -#define DRIVERS {} - -/* Default DRI driver path */ -#define DRI_DRIVER_PATH "/usr/local/lib/dri" - -/* Build Extended-Visual-Information extension */ -#define EVI 1 - -/* Build FontCache extension */ -/* #undef FONTCACHE */ - -/* Build GLX extension */ -/* #undef GLXEXT */ - -/* Support XDM-AUTH*-1 */ -#define HASXDMAUTH 1 - -/* System has /dev/xf86 aperture driver */ -/* #undef HAS_APERTURE_DRV */ - -/* Cygwin has /dev/windows for signaling new win32 messages */ -/* #undef HAS_DEVWINDOWS */ - -/* Have the `getdtablesize' function. */ -#define HAS_GETDTABLESIZE 1 - -/* Have the `getifaddrs' function. */ -#define HAS_GETIFADDRS 1 - -/* Have the `getpeereid' function. */ -/* #undef HAS_GETPEEREID */ - -/* Have the `getpeerucred' function. */ -/* #undef HAS_GETPEERUCRED */ - -/* Have the `mmap' function. */ -#define HAS_MMAP 1 - -/* Define to 1 if NetBSD built-in MTRR support is available */ -/* #undef HAS_MTRR_BUILTIN */ - -/* MTRR support available */ -#define HAS_MTRR_SUPPORT 1 - -/* Support SHM */ -#define HAS_SHM 1 - -/* Use Windows sockets */ -/* #undef HAS_WINSOCK */ - -/* Define to 1 if you have `alloca', as a function or macro. */ -#define HAVE_ALLOCA 1 - -/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix). - */ -#define HAVE_ALLOCA_H 1 - -/* Define to 1 if you have the <asm/mtrr.h> header file. */ -#define HAVE_ASM_MTRR_H 1 - -/* Define to 1 if you have the `authdes_create' function. */ -#define HAVE_AUTHDES_CREATE 1 - -/* Define to 1 if you have the `authdes_seccreate' function. */ -/* #undef HAVE_AUTHDES_SECCREATE */ - -/* Has backtrace support */ -#define HAVE_BACKTRACE 1 - -/* Define to 1 if you have the `clock_gettime' function. */ -/* #undef HAVE_CLOCK_GETTIME */ - -/* Define to 1 if you have the <dbm.h> header file. */ -/* #undef HAVE_DBM_H */ - -/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'. - */ -#define HAVE_DIRENT_H 1 - -/* Define to 1 if you have the <dlfcn.h> header file. */ -#define HAVE_DLFCN_H 1 - -/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ -/* #undef HAVE_DOPRNT */ - -/* Have execinfo.h */ -#define HAVE_EXECINFO_H 1 - -/* Define to 1 if you have the <fcntl.h> header file. */ -#define HAVE_FCNTL_H 1 - -/* Define to 1 if you have the `geteuid' function. */ -#define HAVE_GETEUID 1 - -/* Define to 1 if you have the `getisax' function. */ -/* #undef HAVE_GETISAX */ - -/* Define to 1 if you have the `getopt' function. */ -#define HAVE_GETOPT 1 - -/* Define to 1 if you have the `getopt_long' function. */ -#define HAVE_GETOPT_LONG 1 - -/* Define to 1 if you have the `getuid' function. */ -#define HAVE_GETUID 1 - -/* Define to 1 if you have the <inttypes.h> header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the `m' library (-lm). */ -#define HAVE_LIBM 1 - -/* Define to 1 if you have the `link' function. */ -#define HAVE_LINK 1 - -/* Define to 1 if you have the <linux/agpgart.h> header file. */ -#define HAVE_LINUX_AGPGART_H 1 - -/* Define to 1 if you have the <linux/apm_bios.h> header file. */ -#define HAVE_LINUX_APM_BIOS_H 1 - -/* Define to 1 if you have the <linux/fb.h> header file. */ -#define HAVE_LINUX_FB_H 1 - -/* Define to 1 if you have the <machine/mtrr.h> header file. */ -/* #undef HAVE_MACHINE_MTRR_H */ - -/* Define to 1 if you have the `memmove' function. */ -#define HAVE_MEMMOVE 1 - -/* Define to 1 if you have the <memory.h> header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if you have the `memset' function. */ -#define HAVE_MEMSET 1 - -/* Define to 1 if you have the `mkstemp' function. */ -#define HAVE_MKSTEMP 1 - -/* Define to 1 if you have the <ndbm.h> header file. */ -/* #undef HAVE_NDBM_H */ - -/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */ -/* #undef HAVE_NDIR_H */ - -/* Define to 1 if you have the <rpcsvc/dbm.h> header file. */ -/* #undef HAVE_RPCSVC_DBM_H */ - -/* Define to 1 if you have the <SDL/SDL.h> header file. */ -/* #undef HAVE_SDL_SDL_H */ - -/* Define to 1 if you have the <stdint.h> header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the <stdlib.h> header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the `strchr' function. */ -#define HAVE_STRCHR 1 - -/* Define to 1 if you have the <strings.h> header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the <string.h> header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the `strrchr' function. */ -#define HAVE_STRRCHR 1 - -/* Define to 1 if you have the `strtol' function. */ -#define HAVE_STRTOL 1 - -/* Define to 1 if SYSV IPC is available */ -#define HAVE_SYSV_IPC 1 - -/* Define to 1 if you have the <sys/agpio.h> header file. */ -/* #undef HAVE_SYS_AGPIO_H */ - -/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'. - */ -/* #undef HAVE_SYS_DIR_H */ - -/* Define to 1 if you have the <sys/io.h> header file. */ -/* #undef HAVE_SYS_IO_H */ - -/* Define to 1 if you have the <sys/linker.h> header file. */ -/* #undef HAVE_SYS_LINKER_H */ - -/* Define to 1 if you have the <sys/memrange.h> header file. */ -/* #undef HAVE_SYS_MEMRANGE_H */ - -/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'. - */ -/* #undef HAVE_SYS_NDIR_H */ - -/* Define to 1 if you have the <sys/stat.h> header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the <sys/types.h> header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the <sys/vm86.h> header file. */ -/* #undef HAVE_SYS_VM86_H */ - -/* Define to 1 if you have the <unistd.h> header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to 1 if you have the `vprintf' function. */ -#define HAVE_VPRINTF 1 - -/* Define to 1 if you have the `vsnprintf' function. */ -#define HAVE_VSNPRINTF 1 - -/* Define to 1 if you have the `walkcontext' function. */ -/* #undef HAVE_WALKCONTEXT */ - -/* Built-in input drivers (none) */ -#define IDRIVERS {} - -/* Support IPv6 for TCP connections */ -#define IPv6 1 - -/* Build kdrive ddx */ -/* #undef KDRIVEDDXACTIONS */ - -/* Build fbdev-based kdrive server */ -/* #undef KDRIVEFBDEV */ - -/* Build Kdrive X server */ -/* #undef KDRIVESERVER */ - -/* Build VESA-based kdrive servers */ -/* #undef KDRIVEVESA */ - -/* Name of the period field in struct kbd_repeat */ -#define LNX_KBD_PERIOD_NAME period - -/* Support MIT Misc extension */ -#define MITMISC 1 - -/* Support MIT-SHM extension */ -#define MITSHM 1 - -/* Have monotonic clock from clock_gettime() */ -#define MONOTONIC_CLOCK 1 - -/* Build Multibuffer extension */ -/* #undef MULTIBUFFER */ - -/* Disable some debugging code */ -#define NDEBUG 1 - -/* Do not have `strcasecmp'. */ -/* #undef NEED_STRCASECMP */ - -/* Need XFree86 helper functions */ -#define NEED_XF86_PROTOTYPES 1 - -/* Need XFree86 typedefs */ -#define NEED_XF86_TYPES 1 - -/* Define to 1 if modules should avoid the libcwrapper */ -#define NO_LIBCWRAPPER 1 - -/* Operating System Name */ -#define OSNAME "Linux 2.6.18-1.2708.fc6xen i686" - -/* Operating System Vendor */ -#define OSVENDOR "" - -/* Name of package */ -#define PACKAGE "xorg-server" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "https://bugs.freedesktop.org/enter_bug.cgi?product=xorg" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "xorg-server" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "xorg-server 1.1.99.902" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "xorg-server" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "1.1.99.902" - -/* Internal define for Xinerama */ -#define PANORAMIX 1 - -/* System has PC console */ -/* #undef PCCONS_SUPPORT */ - -/* System has PC console */ -/* #undef PCVT_SUPPORT */ - -/* Support pixmap privates */ -#define PIXPRIV 1 - -/* Overall prefix */ -#define PROJECTROOT "/usr/local" - -/* Support RANDR extension */ -#define RANDR 1 - -/* Make PROJECT_ROOT relative to the xserver location */ -/* #undef RELOCATE_PROJECTROOT */ - -/* Support RENDER extension */ -#define RENDER 1 - -/* Support X resource extension */ -#define RES 1 - -/* Define as the return type of signal handlers (`int' or `void'). */ -/* #undef RETSIGTYPE */ - -/* Default RGB path */ -#define RGB_DB "/usr/local/share/X11/rgb" - -/* Build Rootless code */ -/* #undef ROOTLESS */ - -/* Support MIT-SCREEN-SAVER extension */ -#define SCREENSAVER 1 - -/* Support Secure RPC ("SUN-DES-1") authentication for X11 clients */ -#define SECURE_RPC 1 - -/* Use a lock to prevent multiple servers on a display */ -#define SERVER_LOCK 1 - -/* Support SHAPE extension */ -#define SHAPE 1 - -/* The size of a `unsigned long', as computed by sizeof. */ -#define SIZEOF_UNSIGNED_LONG 4 - -/* Include time-based scheduler */ -#define SMART_SCHEDULE 1 - -/* If using the C implementation of alloca, define if you know the - direction of stack growth for your system; otherwise it will be - automatically deduced at run-time. - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown */ -/* #undef STACK_DIRECTION */ - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define to 1 on systems derived from System V Release 4 */ -/* #undef SVR4 */ - -/* System has syscons console */ -/* #undef SYSCONS_SUPPORT */ - -/* Support TCP socket connections */ -#define TCPCONN 1 - -/* Build TOG-CUP extension */ -#define TOGCUP 1 - -/* Have tslib support */ -/* #undef TSLIB */ - -/* Support UNIX socket connections */ -#define UNIXCONN 1 - -/* NetBSD PIO alpha IO */ -/* #undef USE_ALPHA_PIO */ - -/* BSD AMD64 iopl */ -/* #undef USE_AMD64_IOPL */ - -/* BSD /dev/io */ -/* #undef USE_DEV_IO */ - -/* BSD i386 iopl */ -/* #undef USE_I386_IOPL */ - -/* Use built-in RGB color database */ -/* #undef USE_RGB_BUILTIN */ - -/* Use rgb.txt directly */ -#define USE_RGB_TXT 1 - -/* Version number of package */ -#define VERSION "1.1.99.902" - -/* Building vgahw module */ -#define WITH_VGAHW 1 - -/* System has wscons console */ -/* #undef WSCONS_SUPPORT */ - -/* Build X-ACE extension */ -#define XACE 1 - -/* Build APPGROUP extension */ -#define XAPPGROUP 1 - -/* Build XCalibrate extension */ -/* #undef XCALIBRATE */ - -/* Support XCMisc extension */ -#define XCMISC 1 - -/* Build Security extension */ -#define XCSECURITY 1 - -/* Support XDM Control Protocol */ -#define XDMCP 1 - -/* Build XEvIE extension */ -#define XEVIE 1 - -/* Support XF86 Big font extension */ -#define XF86BIGFONT 1 - -/* Name of configuration file */ -#define XF86CONFIGFILE "xorg.conf" - -/* Build DRI extension */ -#define XF86DRI 1 - -/* Support XFree86 miscellaneous extensions */ -#define XF86MISC 1 - -/* Support XFree86 Video Mode extension */ -#define XF86VIDMODE 1 - -/* Support XFixes extension */ -#define XFIXES 1 - -/* Building loadable XFree86 server */ -#define XFree86LOADER 1 - -/* Building XFree86 server */ -#define XFree86Server 1 - -/* Build XDGA support */ -#define XFreeXDGA 1 - -/* Use loadable XGL modules */ -/* #undef XGL_MODULAR */ - -/* Default XGL module search path */ -/* #undef XGL_MODULE_PATH */ - -/* Support Xinerama extension */ -#define XINERAMA 1 - -/* Support X Input extension */ -#define XINPUT 1 - -/* Build XKB */ -#define XKB 1 - -/* Path to XKB data */ -#define XKB_BASE_DIRECTORY "/usr/local/share/X11/xkb" - -/* Path to XKB bin dir */ -#define XKB_BIN_DIRECTORY "/usr/local/bin" - -/* Disable XKB per default */ -#define XKB_DFLT_DISABLED 0 - -/* Build XKB server */ -#define XKB_IN_SERVER 1 - -/* Path to XKB output dir */ -#define XKM_OUTPUT_DIR "/usr/local/share/X11/xkb/compiled/" - -/* Building Xorg server */ -#define XORGSERVER 1 - -/* Vendor release */ -#define XORG_DATE "13 November 2006" - -/* Vendor man version */ -#define XORG_MAN_VERSION "Version 7.1.99.902" - -/* Vendor release */ -#define XORG_RELEASE "Release 7.1.99.902" - -/* Building Xorg server */ -#define XORG_SERVER 1 - -/* Current Xorg version */ -#define XORG_VERSION_CURRENT (((7) * 10000000) + ((1) * 100000) + ((99) * 1000) + 902) - -/* Build Print extension */ -/* #undef XPRINT */ - -/* Support FreeType rasterizer in Xprint for nearly all font file formats */ -/* #undef XP_USE_FREETYPE */ - -/* Support Record extension */ -#define XRECORD 1 - -/* Build XRes extension */ -#define XResExtension 1 - -/* Build Xsdl server */ -/* #undef XSDLSERVER */ - -/* Support XSync extension */ -#define XSYNC 1 - -/* Support XTest extension */ -#define XTEST 1 - -/* Support XTrap extension */ -#define XTRAP 1 - -/* Support Xv extension */ -#define XV 1 - -/* Vendor name */ -#define XVENDORNAME "The X.Org Foundation" - -/* Short vendor name */ -#define XVENDORNAMESHORT "X.Org" - -/* Endian order */ -#define X_BYTE_ORDER X_LITTLE_ENDIAN - -/* Build Xv extension */ -#define XvExtension 1 - -/* Build XvMC extension */ -#define XvMCExtension 1 - -/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a - `char[]'. */ -#define YYTEXT_POINTER 1 - -/* BSD-compliant source */ -#define _BSD_SOURCE 1 - -/* POSIX-compliant source */ -#define _POSIX_SOURCE 1 - -/* X/Open-compliant source */ -#define _XOPEN_SOURCE 500 - -/* Define to 1 if unsigned long is 64 bits. */ -/* #undef _XSERVER64 */ - -/* Solaris 8 or later */ -/* #undef __SOL8__ */ - -/* Vendor web address for support */ -#define __VENDORDWEBSUPPORT__ "http://wiki.x.org" - -/* Name of configuration file */ -#define __XCONFIGFILE__ "xorg.conf" - -/* Default XKB rules */ -#define __XKBDEFRULES__ "xorg" - -/* Name of X server */ -#define __XSERVERNAME__ "Xorg" - -/* Define to empty if `const' does not conform to ANSI C. */ -/* #undef const */ - -/* Define to `int' if <sys/types.h> does not define. */ -/* #undef pid_t */ diff --git a/xserver/include/do-not-use-config.h.in b/xserver/include/do-not-use-config.h.in index d172f6790..a58f50320 100644 --- a/xserver/include/do-not-use-config.h.in +++ b/xserver/include/do-not-use-config.h.in @@ -608,6 +608,9 @@ /* Endian order */ #undef X_BYTE_ORDER +/* Use X server privilege separation */ +#undef X_PRIVSEP + /* Build Xv extension */ #undef XvExtension diff --git a/xserver/include/os.h b/xserver/include/os.h index fbe1592a1..666477769 100644 --- a/xserver/include/os.h +++ b/xserver/include/os.h @@ -248,6 +248,9 @@ extern int auditTrailLevel; #ifdef SERVER_LOCK extern void LockServer(void); extern void UnlockServer(void); +#ifdef X_PRIVSEP +extern int ChownLock(uid_t, gid_t); +#endif #endif extern int OsLookupColor( diff --git a/xserver/include/servermd.h b/xserver/include/servermd.h index e6ca11ed2..8ae505c6f 100644 --- a/xserver/include/servermd.h +++ b/xserver/include/servermd.h @@ -120,12 +120,12 @@ SOFTWARE. * Currently defined for SPARC. */ -#ifdef vax +#if defined(vax) || defined(__vax__) #define IMAGE_BYTE_ORDER LSBFirst /* Values for the VAX only */ #define BITMAP_BIT_ORDER LSBFirst -#define GLYPHPADBYTES 1 -#define GETLEFTBITS_ALIGNMENT 4 +#define GLYPHPADBYTES 4 /* to make fb work */ +#define GETLEFTBITS_ALIGNMENT 1 #define FAST_UNALIGNED_READS #endif /* vax */ @@ -151,7 +151,7 @@ SOFTWARE. #endif /* __arm32__ */ -#if defined (hpux) || defined __hppa__ +#if defined(hpux) || defined(__hppa__) #define IMAGE_BYTE_ORDER MSBFirst #define BITMAP_BIT_ORDER MSBFirst @@ -495,6 +495,16 @@ SOFTWARE. #endif /* linux/m68k */ +#if defined (OpenBSD) && defined (__mc68020__) + +#define IMAGE_BYTE_ORDER MSBFirst +#define BITMAP_BIT_ORDER MSBFirst +#define FAST_UNALIGNED_READS +#define GLYPHPADBYTES 4 +#define GETLEFTBITS_ALIGNMENT 1 + +#endif /* OpenBSD/hp300 */ + #ifdef sgi #define IMAGE_BYTE_ORDER MSBFirst diff --git a/xserver/include/xorg-config.h b/xserver/include/xorg-config.h deleted file mode 100644 index 53cf9b08e..000000000 --- a/xserver/include/xorg-config.h +++ /dev/null @@ -1,116 +0,0 @@ -/* include/xorg-config.h. Generated by configure. */ -/* xorg-config.h.in: not at all generated. -*- c -*- - * - * This file differs from xorg-server.h.in in that -server is installed - * with the rest of the SDK for external drivers/modules to use, whereas - * -config is for internal use only (i.e. building the DDX). - * - */ - -#ifndef _XORG_CONFIG_H_ -#define _XORG_CONFIG_H_ - -#include <dix-config.h> -#include <xkb-config.h> - -/* Building Xorg server. */ -#define XORGSERVER 1 - -/* Current X.Org version. */ -#define XORG_VERSION_CURRENT (((7) * 10000000) + ((1) * 100000) + ((99) * 1000) + 902) - -/* Need XFree86 libc-replacement typedefs. */ -#define NEED_XF86_TYPES 1 - -/* Need XFree86 libc-replacement functions. */ -#define NEED_XF86_PROTOTYPES 1 - -/* Name of X server. */ -#define __XSERVERNAME__ "Xorg" - -/* URL to go to for support. */ -#define __VENDORDWEBSUPPORT__ "http://wiki.x.org" - -/* Built-in output drivers. */ -#define DRIVERS {} - -/* Built-in input drivers. */ -#define IDRIVERS {} - -/* Path to configuration file. */ -#define XF86CONFIGFILE "xorg.conf" - -/* Path to configuration file. */ -#define __XCONFIGFILE__ "xorg.conf" - -/* Path to loadable modules. */ -#define DEFAULT_MODULE_PATH "/usr/local/lib/xorg/modules" - -/* Path to server log file. */ -#define DEFAULT_LOGPREFIX "/usr/local/var/log/Xorg." - -/* Building DRI-capable DDX. */ -#define XF86DRI 1 - -/* Solaris 8 or later? */ -/* #undef __SOL8__ */ - -/* Whether to use pixmap privates */ -#define PIXPRIV 1 - -/* Define to 1 if you have the `walkcontext' function (used on Solaris for - xorg_backtrace in hw/xfree86/common/xf86Events.c */ -/* #undef HAVE_WALKCONTEXT */ - -/* Define to 1 if unsigned long is 64 bits. */ -/* #undef _XSERVER64 */ - -/* Building vgahw module */ -#define WITH_VGAHW 1 - -/* Define to 1 if NetBSD built-in MTRR support is available */ -/* #undef HAS_MTRR_BUILTIN */ - -/* Define to 1 if BSD MTRR support is available */ -#define HAS_MTRR_SUPPORT 1 - -/* NetBSD PIO alpha IO */ -/* #undef USE_ALPHA_PIO */ - -/* BSD AMD64 iopl */ -/* #undef USE_AMD64_IOPL */ - -/* BSD /dev/io */ -/* #undef USE_DEV_IO */ - -/* BSD i386 iopl */ -/* #undef USE_I386_IOPL */ - -/* System is BSD-like */ -/* #undef CSRG_BASED */ - -/* System has PC console */ -/* #undef PCCONS_SUPPORT */ - -/* System has PCVT console */ -/* #undef PCVT_SUPPORT */ - -/* System has syscons console */ -/* #undef SYSCONS_SUPPORT */ - -/* System has wscons console */ -/* #undef WSCONS_SUPPORT */ - -/* System has /dev/xf86 aperture driver */ -/* #undef HAS_APERTURE_DRV */ - -/* Has backtrace support */ -#define HAVE_BACKTRACE 1 - -/* Name of the period field in struct kbd_repeat */ -#define LNX_KBD_PERIOD_NAME period - -/* Have execinfo.h */ -#define HAVE_EXECINFO_H 1 - -#endif /* _XORG_CONFIG_H_ */ diff --git a/xserver/include/xorg-config.h.in b/xserver/include/xorg-config.h.in index 4a64522a7..e5ffb2590 100644 --- a/xserver/include/xorg-config.h.in +++ b/xserver/include/xorg-config.h.in @@ -112,4 +112,7 @@ /* Have execinfo.h */ #undef HAVE_EXECINFO_H +/* Use X server privilege separation */ +#undef X_PRIVSEP + #endif /* _XORG_CONFIG_H_ */ diff --git a/xserver/include/xorg-server.h b/xserver/include/xorg-server.h deleted file mode 100644 index c44faf95c..000000000 --- a/xserver/include/xorg-server.h +++ /dev/null @@ -1,242 +0,0 @@ -/* include/xorg-server.h. Generated by configure. */ -/* xorg-server.h.in -*- c -*- - * - * This file is the template file for the xorg-server.h file which gets - * installed as part of the SDK. The #defines in this file overlap - * with those from config.h, but only for those options that we want - * to export to external modules. Boilerplate autotool #defines such - * as HAVE_STUFF and PACKAGE_NAME is kept in config.h - * - * It is still possible to update config.h.in using autoheader, since - * autoheader only creates a .h.in file for the first - * AM_CONFIG_HEADER() line, and thus does not overwrite this file. - * - * However, it should be kept in sync with this file. - */ - -#ifndef _XORG_SERVER_H_ -#define _XORG_SERVER_H_ - -/* Support BigRequests extension */ -#define BIGREQS 1 - -/* Default font path */ -#define COMPILEDDEFAULTFONTPATH "/usr/local/lib/X11/fonts/misc/,/usr/local/lib/X11/fonts/TTF/,/usr/local/lib/X11/fonts/OTF,/usr/local/lib/X11/fonts/Type1/,/usr/local/lib/X11/fonts/CID/,/usr/local/lib/X11/fonts/100dpi/,/usr/local/lib/X11/fonts/75dpi/" - -/* Support Composite Extension */ -#define COMPOSITE 1 - -/* Use OsVendorInit */ -#define DDXOSINIT 1 - -/* Build DPMS extension */ -#define DPMSExtension 1 - -/* Built-in output drivers */ -#define DRIVERS {} - -/* Build GLX extension */ -/* #undef GLXEXT */ - -/* Include handhelds.org h3600 touchscreen driver */ -/* #undef H3600_TS */ - -/* Support XDM-AUTH*-1 */ -#define HASXDMAUTH 1 - -/* Support SHM */ -#define HAS_SHM 1 - -/* Built-in input drivers */ -#define IDRIVERS {} - -/* Support IPv6 for TCP connections */ -#define IPv6 1 - -/* Support MIT Misc extension */ -#define MITMISC 1 - -/* Support MIT-SHM Extension */ -#define MITSHM 1 - -/* Disable some debugging code */ -#define NDEBUG 1 - -/* Need XFree86 helper functions */ -#define NEED_XF86_PROTOTYPES 1 - -/* Need XFree86 typedefs */ -#define NEED_XF86_TYPES 1 - -/* Internal define for Xinerama */ -#define PANORAMIX 1 - -/* Support pixmap privates */ -#define PIXPRIV 1 - -/* Support RANDR extension */ -#define RANDR 1 - -/* Support RENDER extension */ -#define RENDER 1 - -/* Support X resource extension */ -#define RES 1 - -/* Support MIT-SCREEN-SAVER extension */ -#define SCREENSAVER 1 - -/* Use a lock to prevent multiple servers on a display */ -#define SERVER_LOCK 1 - -/* Support SHAPE extension */ -#define SHAPE 1 - -/* Include time-based scheduler */ -#define SMART_SCHEDULE 1 - -/* Define to 1 on systems derived from System V Release 4 */ -/* #undef SVR4 */ - -/* Support TCP socket connections */ -#define TCPCONN 1 - -/* Enable touchscreen support */ -/* #undef TOUCHSCREEN */ - -/* Support tslib touchscreen abstraction library */ -/* #undef TSLIB */ - -/* Support UNIX socket connections */ -#define UNIXCONN 1 - -/* Use builtin rgb color database */ -/* #undef USE_RGB_BUILTIN */ - -/* Use rgb.txt directly */ -#define USE_RGB_TXT 1 - -/* unaligned word accesses behave as expected */ -/* #undef WORKING_UNALIGNED_INT */ - -/* Support XCMisc extension */ -#define XCMISC 1 - -/* Support Xdmcp */ -#define XDMCP 1 - -/* Build XFree86 BigFont extension */ -#define XF86BIGFONT 1 - -/* Support XFree86 miscellaneous extensions */ -#define XF86MISC 1 - -/* Support XFree86 Video Mode extension */ -#define XF86VIDMODE 1 - -/* Build XDGA support */ -#define XFreeXDGA 1 - -/* Support Xinerama extension */ -#define XINERAMA 1 - -/* Support X Input extension */ -#define XINPUT 1 - -/* Build XKB */ -#define XKB 1 - -/* Enable XKB per default */ -#define XKB_DFLT_DISABLED 0 - -/* Build XKB server */ -#define XKB_IN_SERVER 1 - -/* Support loadable input and output drivers */ -/* #undef XLOADABLE */ - -/* Build DRI extension */ -#define XF86DRI 1 - -/* Build Xorg server */ -#define XORGSERVER 1 - -/* Vendor release */ -#define XORG_RELEASE "Release 7.1.99.902" - -/* Current Xorg version */ -#define XORG_VERSION_CURRENT (((7) * 10000000) + ((1) * 100000) + ((99) * 1000) + 902) - -/* Build Xv Extension */ -#define XvExtension 1 - -/* Build XvMC Extension */ -#define XvMCExtension 1 - -/* Build XRes extension */ -#define XResExtension 1 - -/* Support XSync extension */ -#define XSYNC 1 - -/* Support XTest extension */ -#define XTEST 1 - -/* Support XTrap extension */ -#define XTRAP 1 - -/* Support Xv Extension */ -#define XV 1 - -/* Vendor name */ -#define XVENDORNAME "The X.Org Foundation" - -/* Endian order */ -#define X_BYTE_ORDER X_LITTLE_ENDIAN - -/* BSD-compliant source */ -#define _BSD_SOURCE 1 - -/* POSIX-compliant source */ -#define _POSIX_SOURCE 1 - -/* X/Open-compliant source */ -#define _XOPEN_SOURCE 500 - -/* Vendor web address for support */ -#define __VENDORDWEBSUPPORT__ "http://wiki.x.org" - -/* Location of configuration file */ -#define __XCONFIGFILE__ "xorg.conf" - -/* XKB default rules */ -#define __XKBDEFRULES__ "xorg" - -/* Name of X server */ -#define __XSERVERNAME__ "Xorg" - -/* Define to 1 if unsigned long is 64 bits. */ -/* #undef _XSERVER64 */ - -/* Building vgahw module */ -#define WITH_VGAHW 1 - -/* System is BSD-like */ -/* #undef CSRG_BASED */ - -/* System has PC console */ -/* #undef PCCONS_SUPPORT */ - -/* System has PCVT console */ -/* #undef PCVT_SUPPORT */ - -/* System has syscons console */ -/* #undef SYSCONS_SUPPORT */ - -/* System has wscons console */ -/* #undef WSCONS_SUPPORT */ - -/* Loadable XFree86 server awesomeness */ -#define XFree86LOADER 1 - -#endif /* _XORG_SERVER_H_ */ diff --git a/xserver/include/xorg-server.h.in b/xserver/include/xorg-server.h.in index 48196d8b6..79fe8ced5 100644 --- a/xserver/include/xorg-server.h.in +++ b/xserver/include/xorg-server.h.in @@ -238,4 +238,7 @@ /* Loadable XFree86 server awesomeness */ #undef XFree86LOADER +/* Use X server privilege separation */ +#undef X_PRIVSEP + #endif /* _XORG_SERVER_H_ */ diff --git a/xserver/os/Makefile.am b/xserver/os/Makefile.am index 71e24c086..7d82e0c30 100644 --- a/xserver/os/Makefile.am +++ b/xserver/os/Makefile.am @@ -11,6 +11,7 @@ XCSECURITY_SOURCES = secauth.c XDMCP_SOURCES = xdmcp.c STRLCAT_SOURCES = strlcat.c strlcpy.c XORG_SOURCES = log.c +PRIVSEP_SOURCES = privsep.c libos_la_SOURCES = \ WaitFor.c \ @@ -41,6 +42,10 @@ if NEED_STRLCAT libos_la_SOURCES += $(STRLCAT_SOURCES) endif +if X_PRIVSEP +libos_la_SOURCES += $(PRIVSEP_SOURCES) +endif + libcwrapper_la_SOURCES = \ $(top_srcdir)/hw/xfree86/os-support/shared/libc_wrapper.c libcwrapper_la_CFLAGS = \ diff --git a/xserver/os/access.c b/xserver/os/access.c index cdb17589c..468ff2f64 100644 --- a/xserver/os/access.c +++ b/xserver/os/access.c @@ -1198,9 +1198,10 @@ ResetHosts (char *display) strlen(display) + 1; if (fnamelen > sizeof(fname)) FatalError("Display name `%s' is too long\n", display); - sprintf(fname, ETC_HOST_PREFIX "%s" ETC_HOST_SUFFIX, display); + snprintf(fname, sizeof(fname), ETC_HOST_PREFIX "%s" ETC_HOST_SUFFIX, + display); #ifdef __UNIXOS2__ - strcpy(fname, (char*)__XOS2RedirRoot(fname)); + strlcpy(fname, (char*)__XOS2RedirRoot(fname), sizeof(fname)); #endif /* __UNIXOS2__ */ if ((fd = fopen (fname, "r")) != 0) diff --git a/xserver/os/connection.c b/xserver/os/connection.c index 96ad11921..9588bfd0e 100644 --- a/xserver/os/connection.c +++ b/xserver/os/connection.c @@ -397,7 +397,7 @@ CreateWellKnownSockets(void) FD_ZERO (&WellKnownConnections); - sprintf (port, "%d", atoi (display)); + snprintf (port, sizeof(port), "%d", atoi (display)); if ((_XSERVTransMakeAllCOTSServerListeners (port, &partial, &ListenTransCount, &ListenTransConns) >= 0) && @@ -468,7 +468,11 @@ CreateWellKnownSockets(void) #endif /* __UNIXOS2__ */ if (RunFromSmartParent) { if (ParentProcess > 1) { +#ifdef X_PRIVSEP + priv_signal_parent(); +#else kill (ParentProcess, SIGUSR1); +#endif } } #endif @@ -563,7 +567,7 @@ AuthAudit (ClientPtr client, Bool letin, #endif if (!len) - strcpy(out, "local host"); + strlcpy(out, "local host", sizeof(addr)); else switch (saddr->sa_family) { @@ -571,11 +575,11 @@ AuthAudit (ClientPtr client, Bool letin, #if defined(UNIXCONN) || defined(LOCALCONN) || defined(OS2PIPECONN) case AF_UNIX: #endif - strcpy(out, "local host"); - break; + strlcpy(out, "local host", sizeof(addr)); + break; #if defined(TCPCONN) || defined(STREAMSCONN) || defined(MNX_TCPCONN) case AF_INET: - sprintf(out, "IP %s", + snprintf(out, sizeof(addr), "IP %s", inet_ntoa(((struct sockaddr_in *) saddr)->sin_addr)); break; #if defined(IPv6) && defined(AF_INET6) @@ -583,19 +587,19 @@ AuthAudit (ClientPtr client, Bool letin, char ipaddr[INET6_ADDRSTRLEN]; inet_ntop(AF_INET6, &((struct sockaddr_in6 *) saddr)->sin6_addr, ipaddr, sizeof(ipaddr)); - sprintf(out, "IP %s", ipaddr); + snprintf(out, sizeof(addr), "IP %s", ipaddr); } break; #endif #endif #ifdef DNETCONN case AF_DECnet: - sprintf(out, "DN %s", + snprintf(out, sizeof(addr), "DN %s", dnet_ntoa(&((struct sockaddr_dn *) saddr)->sdn_add)); break; #endif default: - strcpy(out, "unknown address"); + strlcpy(out, "unknown address", sizeof(addr)); } #ifdef HAS_GETPEERUCRED diff --git a/xserver/os/k5auth.c b/xserver/os/k5auth.c index 7bc0ce822..994b3fa3c 100644 --- a/xserver/os/k5auth.c +++ b/xserver/os/k5auth.c @@ -347,7 +347,8 @@ int k5_stage1(client) krb5_free_addresses(localaddrs); if (creds) krb5_free_creds(creds); - sprintf(kerror, "Krb5 stage1: unknown address family %d from getpeername", + snprintf(kerror, sizeof(kerror), + "Krb5 stage1: unknown address family %d from getpeername", cli_net_addr.sa_family); return(SendConnSetup(client, kerror)); } @@ -369,12 +370,12 @@ int k5_stage1(client) if (creds) krb5_free_creds(creds); free(rcache); - strcpy(kerror, "krb5_rc_resolve_type failed: "); - strncat(kerror, error_message(retval), 231); + strlcpy(kerror, "krb5_rc_resolve_type failed: ", sizeof(kerror)); + strlcat(kerror, error_message(retval), sizeof(kerror)); return(SendConnSetup(client, kerror)); } - if ((cachename = (char *)malloc(strlen(rc_base) + strlen(display) + 1)) - == NULL) + len = strlen(rc_base) + strlen(display) + 1; + if ((cachename = (char *)malloc(len)) == NULL) { if (localaddrs) krb5_free_addresses(localaddrs); @@ -383,8 +384,8 @@ int k5_stage1(client) free(rcache); return(SendConnSetup(client, "Krb5: malloc bombed for cachename")); } - strcpy(cachename, rc_base); - strcat(cachename, display); + strlcpy(cachename, rc_base, len); + strlcat(cachename, display, len); if (retval = krb5_rc_resolve(rcache, cachename)) { if (localaddrs) @@ -393,8 +394,8 @@ int k5_stage1(client) krb5_free_creds(creds); free(rcache); free(cachename); - strcpy(kerror, "krb5_rc_resolve failed: "); - strncat(kerror, error_message(retval), 236); + strlcpy(kerror, "krb5_rc_resolve failed: ", sizeof(kerror)); + strlcat(kerror, error_message(retval), sizeof(kerror)); return(SendConnSetup(client, kerror)); } free(cachename); @@ -409,13 +410,13 @@ int k5_stage1(client) krb5_free_creds(creds); if (retval2 = krb5_rc_close(rcache)) { - strcpy(kerror, "krb5_rc_close failed: "); - strncat(kerror, error_message(retval2), 238); + strlcpy(kerror, "krb5_rc_close failed: ", sizeof(kerror)); + strlcat(kerror, error_message(retval2), sizeof(kerror)); return(SendConnSetup(client, kerror)); } free(rcache); - strcpy(kerror, "krb5_rc_initialize failed: "); - strncat(kerror, error_message(retval), 233); + strlcpy(kerror, "krb5_rc_initialize failed: ", sizeof(kerror)); + strlcat(kerror, error_message(retval), sizeof(kerror)); return(SendConnSetup(client, kerror)); } } @@ -452,16 +453,16 @@ int k5_stage1(client) { if (retval2 = krb5_rc_close(rcache)) { - strcpy(kerror, "krb5_rc_close failed (2): "); - strncat(kerror, error_message(retval2), 230); + strlcpy(kerror, "krb5_rc_close failed (2): ", sizeof(kerror)); + strlcat(kerror, error_message(retval2), sizeof(kerror)); return(SendConnSetup(client, kerror)); } free(rcache); } if (retval) { - strcpy(kerror, "Krb5: Bad application request: "); - strncat(kerror, error_message(retval), 224); + strlcpy(kerror, "Krb5: Bad application request: ", sizeof(kerror)); + strlcat(kerror, error_message(retval), sizeof(kerror)); return(SendConnSetup(client, kerror)); } cprinc = authdat->ticket->enc_part2->client; @@ -490,8 +491,8 @@ int k5_stage1(client) if (retval = krb5_us_timeofday(&ctime, &cusec)) { krb5_free_tkt_authent(authdat); - strcpy(kerror, "error in krb5_us_timeofday: "); - strncat(kerror, error_message(retval), 234); + strlcpy(kerror, "error in krb5_us_timeofday: ", sizeof(kerror)); + strlcat(kerror, error_message(retval), sizeof(kerror)); return(SendConnSetup(client, kerror)); } rep.ctime = ctime; @@ -501,8 +502,8 @@ int k5_stage1(client) if (retval = krb5_mk_rep(&rep, skey, &buf)) { krb5_free_tkt_authent(authdat); - strcpy(kerror, "error in krb5_mk_rep: "); - strncat(kerror, error_message(retval), 238); + strlcpy(kerror, "error in krb5_mk_rep: ", sizeof(kerror)); + strlcat(kerror, error_message(retval), sizeof(kerror)); return(SendConnSetup(client, kerror)); } prefix.reqType = 2; /* opcode = authenticate */ @@ -535,8 +536,9 @@ int k5_stage1(client) retval = krb5_unparse_name(cprinc, &kname); if (retval == 0) { - sprintf(kerror, "Principal \"%s\" is not authorized to connect", - kname); + snprintf(kerror, sizeof(kerror), + "Principal \"%s\" is not authorized to connect", + kname); if (kname) free(kname); return(SendConnSetup(client, kerror)); @@ -576,9 +578,10 @@ k5_bad(client) { if (((OsCommPtr)client->osPrivate)->authstate.srvcreds) krb5_free_creds((krb5_creds *)((OsCommPtr)client->osPrivate)->authstate.srvcreds); - sprintf(kerror, "unrecognized Krb5 auth packet %d, expecting %d", - ((xReq *)client->requestBuffer)->reqType, - ((OsCommPtr)client->osPrivate)->authstate.stageno); + snprintf(kerror, sizeof(kerror), + "unrecognized Krb5 auth packet %d, expecting %d", + ((xReq *)client->requestBuffer)->reqType, + ((OsCommPtr)client->osPrivate)->authstate.stageno); return(SendConnSetup(client, kerror)); } @@ -675,7 +678,7 @@ int K5Add(data_length, data, id) free(nbuf); return 0; } - strcpy(ktname, cp + 1); + strlpy(ktname, cp + 1, ktlen + 1); retval = krb5_sname_to_principal(NULL, /* NULL for hostname uses local host name*/ nbuf, KRB5_NT_SRV_HST, diff --git a/xserver/os/log.c b/xserver/os/log.c index 05e542f08..fbf59724b 100644 --- a/xserver/os/log.c +++ b/xserver/os/log.c @@ -158,13 +158,15 @@ const char * LogInit(const char *fname, const char *backup) { char *logFileName = NULL; + size_t len1, len2; if (fname && *fname) { /* xalloc() can't be used yet. */ - logFileName = malloc(strlen(fname) + strlen(display) + 1); + len1 = strlen(fname) + strlen(display) + 1; + logFileName = malloc(len1); if (!logFileName) FatalError("Cannot allocate space for the log file name\n"); - sprintf(logFileName, fname, display); + snprintf(logFileName, len1, fname, display); if (backup && *backup) { struct stat buf; @@ -173,13 +175,15 @@ LogInit(const char *fname, const char *backup) char *suffix; char *oldLog; - oldLog = malloc(strlen(logFileName) + strlen(backup) + - strlen(display) + 1); - suffix = malloc(strlen(backup) + strlen(display) + 1); + len1 = strlen(logFileName) + strlen(backup) + + strlen(display) + 1; + len2 = strlen(backup) + strlen(display) + 1; + oldLog = malloc(len1); + suffix = malloc(len2); if (!oldLog || !suffix) FatalError("Cannot allocate space for the log file name\n"); - sprintf(suffix, backup, display); - sprintf(oldLog, "%s%s", logFileName, suffix); + snprintf(suffix, len2, backup, display); + snprintf(oldLog, len1, "%s%s", logFileName, suffix); free(suffix); #ifdef __UNIXOS2__ remove(oldLog); @@ -267,21 +271,19 @@ LogVWrite(int verb, const char *f, va_list args) len = strlen(tmpBuffer); } if ((verb < 0 || logVerbosity >= verb) && len > 0) - fwrite(tmpBuffer, len, 1, stderr); + write(2, tmpBuffer, len); if ((verb < 0 || logFileVerbosity >= verb) && len > 0) { if (logFile) { - fwrite(tmpBuffer, len, 1, logFile); - if (logFlush) { - fflush(logFile); + write(fileno(logFile), tmpBuffer, len); #ifndef WIN32 - if (logSync) - fsync(fileno(logFile)); + if (logFlush && logSync) + fsync(fileno(logFile)); #endif - } } else if (needBuffer) { /* * Note, this code is used before OsInit() has been called, so * xalloc() and friends can't be used. + * And it should not be called inside a signal handler. */ if (len > bufferUnused) { bufferSize += 1024; @@ -314,7 +316,6 @@ _X_EXPORT void LogVMessageVerb(MessageType type, int verb, const char *format, va_list args) { const char *s = X_UNKNOWN_STRING; - char *tmpBuf = NULL; /* Ignore verbosity for X_ERROR */ if (logVerbosity >= verb || logFileVerbosity >= verb || type == X_ERROR) { @@ -360,15 +361,29 @@ LogVMessageVerb(MessageType type, int verb, const char *format, va_list args) * Prefix the format string with the message type. We do it this way * so that LogVWrite() is only called once per message. */ - if (s) { - tmpBuf = malloc(strlen(format) + strlen(s) + 1 + 1); - /* Silently return if malloc fails here. */ - if (!tmpBuf) - return; - sprintf(tmpBuf, "%s ", s); - strcat(tmpBuf, format); + if (s != NULL) { + char stackBuf[BUFSIZ]; + char *tmpBuf = NULL; + size_t len; + + len = strlen(format) + strlen(s) + 1 + 1; + if (len <= sizeof(stackBuf)) { + /* + * avoid malloc() for short strings, since this may be called + * from a signal handler + */ + tmpBuf = stackBuf; + } else { + tmpBuf = malloc(len); + /* Silently return if malloc fails here. */ + if (tmpBuf == NULL) + return; + } + /* snprintf() is safe in signal handlers on OpenBSD */ + snprintf(tmpBuf, len, "%s %s", s, format); LogVWrite(verb, tmpBuf, args); - free(tmpBuf); + if (tmpBuf != stackBuf) + free(tmpBuf); } else LogVWrite(verb, format, args); } @@ -601,13 +616,15 @@ Error(char *str) { char *err = NULL; int saveErrno = errno; + size_t len; if (str) { - err = malloc(strlen(strerror(saveErrno)) + strlen(str) + 2 + 1); + len = strlen(strerror(saveErrno)) + strlen(str) + 2 + 1; + err = malloc(len); if (!err) return; - sprintf(err, "%s: ", str); - strcat(err, strerror(saveErrno)); + snprintf(err, len, "%s: ", str); + strlcat(err, strerror(saveErrno), len); LogWrite(-1, err); } else LogWrite(-1, strerror(saveErrno)); diff --git a/xserver/os/oscolor.c b/xserver/os/oscolor.c index a13a3a68c..db71237c4 100644 --- a/xserver/os/oscolor.c +++ b/xserver/os/oscolor.c @@ -203,7 +203,7 @@ lookup(char *name, int len, Bool create) { *prev = entry; entry->link = NULL; - strcpy( entry->name, name ); + strlcpy( entry->name, name, len + 1 ); } DEALLOCATE_LOCAL(name); @@ -220,20 +220,23 @@ OsInitColors(void) char name[BUFSIZ]; int red, green, blue, lineno = 0; dbEntryPtr entry; + size_t len; static Bool was_here = FALSE; if (!was_here) { #ifndef __UNIXOS2__ - path = (char*)ALLOCATE_LOCAL(strlen(rgbPath) +5); - strcpy(path, rgbPath); - strcat(path, ".txt"); + len = strlen(rgbPath) +5; + path = (char*)ALLOCATE_LOCAL(len); + strlcpy(path, rgbPath, len); + strlcat(path, ".txt", len); #else char *tmp = (char*)__XOS2RedirRoot(rgbPath); - path = (char*)ALLOCATE_LOCAL(strlen(tmp) +5); - strcpy(path, tmp); - strcat(path, ".txt"); + len = strlen(tmp) +5; + path = (char*)ALLOCATE_LOCAL(len); + strlcpy(path, tmp, len); + strlcat(path, ".txt", len); #endif if (!(rgb = fopen(path, "r"))) { diff --git a/xserver/os/osinit.c b/xserver/os/osinit.c index 9a1c1133a..eab53bc7b 100644 --- a/xserver/os/osinit.c +++ b/xserver/os/osinit.c @@ -119,9 +119,9 @@ OsInit(void) FILE *err; if (strlen (display) + strlen (admpath) + 1 < sizeof fname) - sprintf (fname, admpath, display); + snprintf (fname, sizeof(fname), admpath, display); else - strcpy (fname, devnull); + strlcpy (fname, devnull, sizeof(fname)); /* * uses stdio to avoid os dependencies here, * a real os would use diff --git a/xserver/os/privsep.c b/xserver/os/privsep.c new file mode 100644 index 000000000..ddcf12d92 --- /dev/null +++ b/xserver/os/privsep.c @@ -0,0 +1,335 @@ +/* $OpenBSD: privsep.c,v 1.1 2006/11/28 20:29:32 matthieu Exp $ */ +/* + * Copyright 2001 Niels Provos <provos@citi.umich.edu> + * All rights reserved. + * + * Copyright (c) 2002 Matthieu Herrb + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#include <sys/param.h> +#include <sys/uio.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <sys/stat.h> +#include <err.h> +#include <errno.h> +#include <fcntl.h> +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +enum cmd_types { + PRIV_OPEN_DEVICE, + PRIV_SIG_PARENT, +}; + +/* Command parameters */ +typedef struct priv_cmd { + int cmd; + int _pad; + union { + struct _open { + char path[MAXPATHLEN]; + } open; + } arg; +} priv_cmd_t; + + +static int priv_fd = -1; +static pid_t parent_pid = -1; +static const char * const allowed_devices[] = { + /* Serial devices */ + "/dev/wsmouse", + "/dev/wsmouse0", + "/dev/wsmouse1", + "/dev/wsmouse2", + "/dev/wsmouse3", + "/dev/uhid0", + "/dev/uhid1", + "/dev/uhid2", + "/dev/uhid3", + "/dev/tty00", + "/dev/tty01", + "/dev/tty02", + "/dev/tty03", + "/dev/ttya", + "/dev/ttyb", + "/dev/ttyc", + "/dev/ttyd", + "/dev/wskbd", + "/dev/wskbd0", + "/dev/wskbd1", + "/dev/wskbd2", + "/dev/wskbd3", + "/dev/ttyC0", + "/dev/ttyC1", + "/dev/ttyC2", + "/dev/ttyC3", + "/dev/ttyC4", + "/dev/ttyC5", + "/dev/ttyC6", + "/dev/ttyC7", + "/dev/ttyD0", + "/dev/ttyD1", + "/dev/ttyD2", + "/dev/ttyD3", + "/dev/ttyD4", + "/dev/ttyD5", + "/dev/ttyD6", + "/dev/ttyD7", + "/dev/pci", + NULL +}; + +/* return 1 if allowed to open said path */ +static int +open_ok(const char *path) +{ + const char * const *p; + struct stat sb; + + for (p = allowed_devices; *p != NULL; p++) { + if (strcmp(path, *p) == 0) { + if (stat(path, &sb) < 0) { + /* path is valid, but doesn't exist */ + return 0; + } + if (sb.st_mode & S_IFCHR) { + /* File is a character device */ + return 1; + } + } + } + /* path is not valid */ + return 0; +} + +static void +send_fd(int socket, int fd) +{ + struct msghdr msg; + char tmp[CMSG_SPACE(sizeof(int))]; + struct cmsghdr *cmsg; + struct iovec vec; + int result = 0; + ssize_t n; + + memset(&msg, 0, sizeof(msg)); + + if (fd >= 0) { + msg.msg_control = (caddr_t)tmp; + msg.msg_controllen = CMSG_LEN(sizeof(int)); + cmsg = CMSG_FIRSTHDR(&msg); + cmsg->cmsg_len = CMSG_LEN(sizeof(int)); + cmsg->cmsg_level = SOL_SOCKET; + cmsg->cmsg_type = SCM_RIGHTS; + *(int *)CMSG_DATA(cmsg) = fd; + } else { + result = errno; + } + + vec.iov_base = &result; + vec.iov_len = sizeof(int); + msg.msg_iov = &vec; + msg.msg_iovlen = 1; + + if ((n = sendmsg(socket, &msg, 0)) == -1) + warn("%s: sendmsg(%d)", __func__, socket); + if (n != sizeof(int)) + warnx("%s: sendmsg: expected sent 1 got %ld", + __func__, (long)n); +} + +static int +receive_fd(int socket) +{ + struct msghdr msg; + char tmp[CMSG_SPACE(sizeof(int))]; + struct cmsghdr *cmsg; + struct iovec vec; + ssize_t n; + int result; + int fd; + + memset(&msg, 0, sizeof(msg)); + vec.iov_base = &result; + vec.iov_len = sizeof(int); + msg.msg_iov = &vec; + msg.msg_iovlen = 1; + msg.msg_control = tmp; + msg.msg_controllen = sizeof(tmp); + + if ((n = recvmsg(socket, &msg, 0)) == -1) + warn("%s: recvmsg", __func__); + if (n != sizeof(int)) + warnx("%s: recvmsg: expected received 1 got %ld", + __func__, (long)n); + if (result == 0) { + cmsg = CMSG_FIRSTHDR(&msg); + if (cmsg == NULL) { + warnx("%s: no message header", __func__); + return -1; + } + if (cmsg->cmsg_type != SCM_RIGHTS) + warnx("%s: expected type %d got %d", __func__, + SCM_RIGHTS, cmsg->cmsg_type); + fd = (*(int *)CMSG_DATA(cmsg)); + return fd; + } else { + errno = result; + return -1; + } +} + +int +priv_init(uid_t uid, gid_t gid) +{ + int i, fd; + pid_t pid; + int socks[2]; + priv_cmd_t cmd; + + parent_pid = getppid(); + + /* Create sockets */ + if (socketpair(AF_LOCAL, SOCK_STREAM, PF_UNSPEC, socks) == -1) { + return -1; + } + pid = fork(); + if (pid < 0) { + /* can't fork */ + return -1; + } + if (pid != 0) { + /* Father - drop privileges and return */ + if (setgroups(1, &gid) == -1) + return -1; + if (setegid(gid) == -1) + return -1; + if (setgid(gid) == -1) + return -1; + if (seteuid(uid) == -1) + return -1; + if (setuid(uid) == -1) + return -1; + close(socks[0]); + priv_fd = socks[1]; + return 0; + } + /* son */ + for (i = 1; i <= _NSIG; i++) + signal(i, SIG_DFL); + setproctitle("[priv]"); + close(socks[1]); + + while (1) { + if (read(socks[0], &cmd, sizeof(cmd)) == 0) { + exit(0); + } + switch (cmd.cmd) { + + case PRIV_OPEN_DEVICE: + if (open_ok(cmd.arg.open.path)) { + fd = open(cmd.arg.open.path, + O_RDWR | O_NONBLOCK | O_EXCL); + if (fd < 0) { + warn("%s: open %s", __func__, + cmd.arg.open.path); + } + } else { + fd = -1; + errno = EPERM; + } + send_fd(socks[0], fd); + if (fd >= 0) + close(fd); + break; + case PRIV_SIG_PARENT: + kill(parent_pid, SIGUSR1); + break; + default: + errx(1, "%s: unknown command %d", __func__, cmd.cmd); + break; + } + } + _exit(1); +} + +/* Open file */ +int +priv_open_device(const char *path) +{ + priv_cmd_t cmd; + + if (priv_fd != -1) { + cmd.cmd = PRIV_OPEN_DEVICE; + strlcpy(cmd.arg.open.path, path, MAXPATHLEN); + write(priv_fd, &cmd, sizeof(cmd)); + return receive_fd(priv_fd); + } else + return open(path, O_RDWR | O_NONBLOCK | O_EXCL); +} + +/* send signal to parent process */ +int +priv_signal_parent(void) +{ + priv_cmd_t cmd; + + if (priv_fd != -1) { + if (parent_pid == -1) { + warnx("parent_pid == -1"); + return -1; + } + cmd.cmd = PRIV_SIG_PARENT; + write(priv_fd, &cmd, sizeof(cmd)); + return 0; + } else + return kill(getppid(), SIGUSR1); +} + +#ifdef TEST +/* This is not a complete regression test */ +int +main(int argc, char *argv[]) +{ + int fd; + + if (priv_init(getuid(), getgid()) < 0) { + err(1, "priv_init"); + } + fd = priv_open_device("/dev/wsmouse"); + if (fd < 0) { + err(1, "priv_open_device"); + } + write(fd, "test\n", 5); + close(fd); + exit(0); +} +#endif diff --git a/xserver/os/rpcauth.c b/xserver/os/rpcauth.c index 603844aee..b19a263d5 100644 --- a/xserver/os/rpcauth.c +++ b/xserver/os/rpcauth.c @@ -146,13 +146,15 @@ SecureRPCCheck (unsigned short data_length, char *data, } else { fullname = authdes_ezdecode(data, data_length); if (fullname == (char *)0) { - sprintf(rpc_error, "Unable to authenticate secure RPC client (why=%d)", why); + snprintf(rpc_error, sizeof(rpc_error), + "Unable to authenticate secure RPC client (why=%d)", why); *reason = rpc_error; } else { if (ForEachHostInFamily (FamilyNetname, CheckNetName, fullname)) return rpc_id; - sprintf(rpc_error, "Principal \"%s\" is not authorized to connect", - fullname); + snprintf(rpc_error, sizeof(rpc_error), + "Principal \"%s\" is not authorized to connect", + fullname); *reason = rpc_error; } } diff --git a/xserver/os/utils.c b/xserver/os/utils.c index 9824501e7..01537af6c 100644 --- a/xserver/os/utils.c +++ b/xserver/os/utils.c @@ -379,14 +379,16 @@ LockServer(void) FatalError("No TMP dir found\n"); #endif - sprintf(port, "%d", atoi(display)); + snprintf(port, sizeof(port), "%d", atoi(display)); len = strlen(LOCK_PREFIX) > strlen(LOCK_TMP_PREFIX) ? strlen(LOCK_PREFIX) : strlen(LOCK_TMP_PREFIX); len += strlen(tmppath) + strlen(port) + strlen(LOCK_SUFFIX) + 1; if (len > sizeof(LockFile)) FatalError("Display name `%s' is too long\n", port); - (void)sprintf(tmp, "%s" LOCK_TMP_PREFIX "%s" LOCK_SUFFIX, tmppath, port); - (void)sprintf(LockFile, "%s" LOCK_PREFIX "%s" LOCK_SUFFIX, tmppath, port); + (void)snprintf(tmp, sizeof(tmp), + "%s" LOCK_TMP_PREFIX "%s" LOCK_SUFFIX, tmppath, port); + (void)snprintf(LockFile, sizeof(LockFile), + "%s" LOCK_PREFIX "%s" LOCK_SUFFIX, tmppath, port); /* * Create a temporary file containing our PID. Attempt three times @@ -416,8 +418,12 @@ LockServer(void) } if (lfd < 0) FatalError("Could not create lock file in %s\n", tmp); - (void) sprintf(pid_str, "%10ld\n", (long)getpid()); + (void) snprintf(pid_str, sizeof(pid_str), "%10ld\n", (long)getpid()); (void) write(lfd, pid_str, 11); +#ifdef __OpenBSD__ + /* if possible give away the lock file to the real uid/gid */ + fchown(lfd, getuid(), getgid()); +#endif #ifndef __UNIXOS2__ #ifndef USE_CHMOD (void) fchmod(lfd, 0444); @@ -509,6 +515,14 @@ UnlockServer(void) (void) unlink(LockFile); } } + +#ifdef X_PRIVSEP +int +ChownLock(uid_t uid, gid_t gid) +{ + return chown(LockFile, uid, gid); +} +#endif #endif /* SERVER_LOCK */ /* Force connections to close on SIGHUP from init */ @@ -812,9 +826,10 @@ ProcessCommandLine(int argc, char *argv[]) } else if ( strcmp( argv[i], "-co") == 0) { - if(++i < argc) - rgbPath = argv[i]; - else + if(++i < argc) { + if (strlen(argv[i]) < MAXPATHLEN) + rgbPath = argv[i]; + } else UseMsg(); } else if ( strcmp( argv[i], "-core") == 0) @@ -1506,13 +1521,15 @@ char * Xstrdup(const char *s) { char *sd; + size_t len; if (s == NULL) return NULL; - - sd = (char *)Xalloc(strlen(s) + 1); + + len = strlen(s) + 1; + sd = (char *)Xalloc(len); if (sd != NULL) - strcpy(sd, s); + strlcpy(sd, s, len); return sd; } @@ -1521,12 +1538,14 @@ _X_EXPORT char * XNFstrdup(const char *s) { char *sd; + size_t len; if (s == NULL) return NULL; - - sd = (char *)XNFalloc(strlen(s) + 1); - strcpy(sd, s); + + len = strlen(s) + 1; + sd = (char *)XNFalloc(len); + strlcpy(sd, s, len); return sd; } diff --git a/xserver/os/xdmcp.c b/xserver/os/xdmcp.c index fd4be5e81..f09e9691e 100644 --- a/xserver/os/xdmcp.c +++ b/xserver/os/xdmcp.c @@ -1508,7 +1508,7 @@ get_addr_by_name( if (port == 0) { pport = NULL; } else if (port > 0 && port < 65535) { - sprintf(portstr, "%d", port); + snprintf(portstr, sizeof(portstr), "%d", port); } else { FatalError("Xserver: port out of range: %d\n", port); } @@ -1633,7 +1633,7 @@ get_mcast_options(argc, argv, i) } if (xdm_udp_port > 0 && xdm_udp_port < 65535) { - sprintf(portstr, "%d", xdm_udp_port); + snprintf(portstr, sizeof(portstr), "%d", xdm_udp_port); } else { FatalError("Xserver: port out of range: %d\n", xdm_udp_port); } |