1 /*
2 * Copyright © 2011 Daniel Stone
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 *
23 * Author: Daniel Stone <daniel@fooishbar.org>
24 */
25
26 #ifdef HAVE_XORG_CONFIG_H
27 #include <xorg-config.h>
28 #endif
29
30 #include "extension.h"
31 #include "extinit.h"
32 #include "globals.h"
33
34 #include "xf86.h"
35 #include "xf86Config.h"
36 #include "xf86Module.h"
37 #include "xf86Extensions.h"
38 #include "xf86Opt.h"
39 #include "optionstr.h"
40
41 #ifdef XSELINUX
42 #include "xselinux.h"
43 #endif
44
45 #ifdef XFreeXDGA
46 #include <X11/extensions/xf86dgaproto.h>
47 #endif
48
49 #ifdef XF86VIDMODE
50 #include <X11/extensions/xf86vmproto.h>
51 #include "vidmodestr.h"
52 #endif
53
54 /*
55 * DDX-specific extensions.
56 */
57 static const ExtensionModule extensionModules[] = {
58 #ifdef XF86VIDMODE
59 {
60 XFree86VidModeExtensionInit,
61 XF86VIDMODENAME,
62 &noXFree86VidModeExtension
63 },
64 #endif
65 #ifdef XFreeXDGA
66 {
67 XFree86DGAExtensionInit,
68 XF86DGANAME,
69 &noXFree86DGAExtension
70 },
71 #endif
72 #ifdef XF86DRI
73 {
74 XFree86DRIExtensionInit,
75 "XFree86-DRI",
76 &noXFree86DRIExtension
77 },
78 #endif
79 #ifdef DRI2
80 {
81 DRI2ExtensionInit,
82 DRI2_NAME,
83 &noDRI2Extension
84 }
85 #endif
86 };
87
88 static void
load_extension_config(void)89 load_extension_config(void)
90 {
91 XF86ConfModulePtr mod_con = xf86configptr->conf_modules;
92 XF86LoadPtr modp;
93
94 /* Only the best. */
95 if (!mod_con)
96 return;
97
98 nt_list_for_each_entry(modp, mod_con->mod_load_lst, list.next) {
99 InputOption *opt;
100
101 if (strcasecmp(modp->load_name, "extmod") != 0)
102 continue;
103
104 /* extmod options are of the form "omit <extension-name>" */
105 nt_list_for_each_entry(opt, modp->load_opt, list.next) {
106 const char *key = input_option_get_key(opt);
107 if (strncasecmp(key, "omit", 4) != 0 || strlen(key) < 5)
108 continue;
109 if (EnableDisableExtension(key + 4, FALSE))
110 xf86MarkOptionUsed(opt);
111 }
112
113 #ifdef XSELINUX
114 if ((opt = xf86FindOption(modp->load_opt,
115 "SELinux mode disabled"))) {
116 xf86MarkOptionUsed(opt);
117 selinuxEnforcingState = SELINUX_MODE_DISABLED;
118 }
119 if ((opt = xf86FindOption(modp->load_opt,
120 "SELinux mode permissive"))) {
121 xf86MarkOptionUsed(opt);
122 selinuxEnforcingState = SELINUX_MODE_PERMISSIVE;
123 }
124 if ((opt = xf86FindOption(modp->load_opt,
125 "SELinux mode enforcing"))) {
126 xf86MarkOptionUsed(opt);
127 selinuxEnforcingState = SELINUX_MODE_ENFORCING;
128 }
129 #endif
130 }
131 }
132
133 void
xf86ExtensionInit(void)134 xf86ExtensionInit(void)
135 {
136 load_extension_config();
137
138 LoadExtensionList(extensionModules, ARRAY_SIZE(extensionModules), TRUE);
139 }
140