Skip to content

Commit f4d7928

Browse files
committedOct 5, 2014
initial import
1 parent 5cebfd4 commit f4d7928

18 files changed

+719
-0
lines changed
 

‎AUTHORS

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Martin Peres (martin.peres@free.fr)
2+
Steve Dodier-Lazaro (sidnioulz@gmail.com)

‎CMakeLists.txt

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
2+
3+
IF(NOT CMAKE_BUILD_TYPE)
4+
SET(CMAKE_BUILD_TYPE "Release" CACHE
5+
STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel."
6+
FORCE)
7+
ENDIF(NOT CMAKE_BUILD_TYPE)
8+
9+
SET(CMAKE_PROJECT_NAME "LibWSM")
10+
11+
INCLUDE(CheckIncludeFiles)
12+
INCLUDE(CheckLibraryExists)
13+
INCLUDE(CheckFunctionExists)
14+
INCLUDE(FindPkgConfig)
15+
INCLUDE(FeatureSummary)
16+
17+
INCLUDE_DIRECTORIES("include/" ${CMAKE_SOURCE_DIR}/src)
18+
LINK_DIRECTORIES(${CMAKE_BINARY_DIR})
19+
ADD_DEFINITIONS("-Wall")
20+
21+
OPTION(WSM_LIB "PPassKeeper library" ON)
22+
OPTION(WSM_BUILD_BACKENDS "Build the integrated WSM backends" ON)
23+
OPTION(WSM_BE_DEFAULT "Example backend" ON)
24+
25+
IF(NOT WSM_BUILD_BACKENDS)
26+
SET(WSM_BE_EXAMPLE OFF)
27+
ENDIF(NOT WSM_BUILD_BACKENDS)
28+
29+
#Tell libWSM where to find the backends
30+
IF(NOT WSM_DIRECTORY_PATH)
31+
SET(WSM_DIRECTORY_PATH ${CMAKE_INSTALL_PREFIX}/lib/wsm)
32+
ENDIF(NOT WSM_DIRECTORY_PATH)
33+
ADD_DEFINITIONS(-DDIRECTORY_PATH="${WSM_DIRECTORY_PATH}")
34+
35+
# libWSM library
36+
IF(WSM_LIB)
37+
ADD_LIBRARY(wsm SHARED "src/main.c" "src/module.c" "src/module.h" "include/libwsm.h")
38+
SET_PROPERTY(TARGET wsm PROPERTY VERSION 0.1.0)
39+
SET_PROPERTY(TARGET wsm PROPERTY SOVERSION 1)
40+
TARGET_LINK_LIBRARIES(wsm)
41+
INSTALL(TARGETS wsm DESTINATION lib)
42+
INSTALL(FILES "${CMAKE_SOURCE_DIR}/include/wsm.h" DESTINATION include)
43+
INSTALL(DIRECTORY "${CMAKE_SOURCE_DIR}/include/wsm" DESTINATION include)
44+
ENDIF(WSM_LIB)
45+
46+
# Example backend
47+
IF(WSM_BE_DEFAULT)
48+
FILE(GLOB wsm_be_default_SOURCES RELATIVE ${CMAKE_SOURCE_DIR} "backends/default/*.[ch]")
49+
ADD_LIBRARY(wsm_default MODULE ${wsm_be_default_SOURCES})
50+
TARGET_LINK_LIBRARIES(wsm_default wsm)
51+
INSTALL(TARGETS wsm_default DESTINATION lib/wsm/)
52+
ENDIF(WSM_BE_DEFAULT)
53+
54+
#PKG-CONFIG
55+
set(LIBWSM_VERSION "0.1")
56+
configure_file(libwsm.pc.in libwsm.pc @ONLY)
57+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libwsm.pc" DESTINATION lib/pkgconfig)
58+
59+
# Test
60+
add_executable(test_base "tests/base.c")
61+
target_link_libraries(test_base wsm "dl")
62+
63+
64+
#Final summary
65+
MESSAGE("")
66+
MESSAGE("")
67+
MESSAGE(" -------------------")
68+
MESSAGE("| Summary |")
69+
MESSAGE(" -------------------")
70+
MESSAGE("")
71+
72+
MESSAGE("Library : ${WSM_LIB} (-DWSM_LIB=OFF to deactivate)")
73+
MESSAGE("")
74+
75+
MESSAGE("Backends : ${WSM_BUILD_BACKENDS} (-DWSM_BUILD_BACKENDS=OFF to deactivate)")
76+
MESSAGE(" Default : ${WSM_BE_DEFAULT} (-DWSM_BE_DEFAULT=OFF to deactivate)")
77+
MESSAGE("")
78+
79+
MESSAGE("Options :")
80+
MESSAGE(" Build type: ${CMAKE_BUILD_TYPE} (-DCMAKE_BUILD_TYPE=Debug to debug)")
81+
MESSAGE(" Prefix: '${CMAKE_INSTALL_PREFIX}' (-DCMAKE_INSTALL_PREFIX=/your/prefix)")
82+
MESSAGE(" Backends directory: '${WSM_DIRECTORY_PATH}' (-DWSM_DIRECTORY_PATH=/your/prefix)")
83+
MESSAGE("")
84+
85+
MESSAGE("")
86+
MESSAGE("")

‎CMakeLists.txt.user

+188
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE QtCreatorProject>
3+
<!-- Written by QtCreator 3.2.2, 2014-10-05T17:15:45. -->
4+
<qtcreator>
5+
<data>
6+
<variable>EnvironmentId</variable>
7+
<value type="QByteArray">{ba5a1285-61e0-4807-9d8d-7f5759ac8cca}</value>
8+
</data>
9+
<data>
10+
<variable>ProjectExplorer.Project.ActiveTarget</variable>
11+
<value type="int">0</value>
12+
</data>
13+
<data>
14+
<variable>ProjectExplorer.Project.EditorSettings</variable>
15+
<valuemap type="QVariantMap">
16+
<value type="bool" key="EditorConfiguration.AutoIndent">false</value>
17+
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
18+
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
19+
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
20+
<value type="QString" key="language">Cpp</value>
21+
<valuemap type="QVariantMap" key="value">
22+
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
23+
</valuemap>
24+
</valuemap>
25+
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
26+
<value type="QString" key="language">QmlJS</value>
27+
<valuemap type="QVariantMap" key="value">
28+
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
29+
</valuemap>
30+
</valuemap>
31+
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
32+
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
33+
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
34+
<value type="int" key="EditorConfiguration.IndentSize">4</value>
35+
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
36+
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
37+
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
38+
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
39+
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
40+
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
41+
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
42+
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
43+
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
44+
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
45+
<value type="int" key="EditorConfiguration.TabSize">8</value>
46+
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
47+
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
48+
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
49+
<value type="bool" key="EditorConfiguration.cleanIndentation">false</value>
50+
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
51+
<value type="bool" key="EditorConfiguration.inEntireDocument">true</value>
52+
</valuemap>
53+
</data>
54+
<data>
55+
<variable>ProjectExplorer.Project.PluginSettings</variable>
56+
<valuemap type="QVariantMap"/>
57+
</data>
58+
<data>
59+
<variable>ProjectExplorer.Project.Target.0</variable>
60+
<valuemap type="QVariantMap">
61+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
62+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
63+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{f0ef9a7d-b749-435d-9871-d86a9bb44a69}</value>
64+
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
65+
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
66+
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
67+
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
68+
<value type="bool" key="CMakeProjectManager.CMakeBuildConfiguration.UseNinja">false</value>
69+
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/mupuf/Programmation/libwsm/build</value>
70+
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
71+
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
72+
<value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments"></value>
73+
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets"/>
74+
<value type="bool" key="CMakeProjectManager.MakeStep.Clean">false</value>
75+
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
76+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
77+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
78+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
79+
</valuemap>
80+
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
81+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Compiler</value>
82+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
83+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
84+
</valuemap>
85+
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
86+
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
87+
<value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments">clean</value>
88+
<valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets"/>
89+
<value type="bool" key="CMakeProjectManager.MakeStep.Clean">true</value>
90+
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
91+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
92+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
93+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
94+
</valuemap>
95+
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
96+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Nettoyer</value>
97+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
98+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
99+
</valuemap>
100+
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
101+
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
102+
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
103+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">all</value>
104+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
105+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
106+
</valuemap>
107+
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
108+
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
109+
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
110+
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
111+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Déploiement</value>
112+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
113+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
114+
</valuemap>
115+
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
116+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Déployer localement</value>
117+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
118+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
119+
</valuemap>
120+
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
121+
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
122+
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
123+
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
124+
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
125+
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
126+
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
127+
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
128+
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
129+
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
130+
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
131+
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
132+
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
133+
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
134+
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
135+
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
136+
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
137+
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
138+
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
139+
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
140+
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
141+
<value type="int">0</value>
142+
<value type="int">1</value>
143+
<value type="int">2</value>
144+
<value type="int">3</value>
145+
<value type="int">4</value>
146+
<value type="int">5</value>
147+
<value type="int">6</value>
148+
<value type="int">7</value>
149+
<value type="int">8</value>
150+
<value type="int">9</value>
151+
<value type="int">10</value>
152+
<value type="int">11</value>
153+
<value type="int">12</value>
154+
<value type="int">13</value>
155+
<value type="int">14</value>
156+
</valuelist>
157+
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
158+
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
159+
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Arguments"></value>
160+
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable"></value>
161+
<value type="bool" key="ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal">false</value>
162+
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory">%{buildDir}</value>
163+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Exécutable personnalisé</value>
164+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
165+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
166+
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
167+
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
168+
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
169+
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
170+
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
171+
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
172+
</valuemap>
173+
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
174+
</valuemap>
175+
</data>
176+
<data>
177+
<variable>ProjectExplorer.Project.TargetCount</variable>
178+
<value type="int">1</value>
179+
</data>
180+
<data>
181+
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
182+
<value type="int">16</value>
183+
</data>
184+
<data>
185+
<variable>Version</variable>
186+
<value type="int">16</value>
187+
</data>
188+
</qtcreator>

‎COPYING

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2014 Martin Peres, Steve Dodier-Lazaro
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

‎ChangeLog

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
TODO

‎INSTALL

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Building instructions :
2+
3+
$ mkdir build
4+
$ cd build
5+
$ cmake -DCMAKE_INSTALL_PREFIX=/usr/ ../
6+
$ make
7+
# make install
8+

‎NEWS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Please visit http://libwsm.mupuf.org and http://www.mupuf.org

‎README

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
TODO

‎backends/default/wsm_default.c

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
Wayland Security Module
3+
Copyright (C) 2014 Martin Peres & Steve Dodier-Lazaro
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
#include <malloc.h>
21+
22+
struct wsm_default_t{
23+
/* */
24+
};
25+
26+
void *ctor(void)
27+
{
28+
void *user = malloc(sizeof(struct wsm_default_t));
29+
30+
/* init */
31+
32+
return user;
33+
}
34+
35+
36+
void dtor(void *user)
37+
{
38+
free(user);
39+
}
40+
41+
const char* getModuleName()
42+
{
43+
return "default";
44+
}
45+
46+
unsigned int getABIVersion()
47+
{
48+
return 1;
49+
}
50+

‎doc/capabilities

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
WSM_SCREENSHOT [allow/deny/unsure]
2+
Ability to take a still screenshot of the whole screen
3+
WSM_SCREENSHARING [allow/deny/unsure]
4+
Ability to record the screen continuously
5+
6+
WSM_VIRTUAL_KEYBOARD [allow/inject-only/filter-only/deny/unsure]
7+
Ability to inject or filter input on the keyboard
8+
9+
WSM_VIRTUAL_POINTING [allow/deny/unsure]
10+
Ability to modify the position of the pointer and simulate clicks
11+
12+
WSM_GLOBAL_KEYBOARD_SEQUENCE [allow/deny/unsure] [key sequence]
13+
Ability to receive global keyboard sequences when not on focus
14+
15+
WSM_FORWARD_RESERVED_KEYBOARD_SEQUENCE [allow/deny/unsure] [key sequence]
16+
Ability to receive reserved keyboard sequences instead of compositor when on focus
17+
18+
WSM_CLIPBOARD_COPY [allow/deny/unsure] [default-allow]
19+
Ability to copy to the clipboard
20+
21+
WSM_CLIPBOARD_PASTE [allow/deny/unsure]
22+
Ability to paste from the clipboard

‎include/libwsm.h

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
Copyright (c) 2014 Martin Peres
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to deal
6+
in the Software without restriction, including without limitation the rights
7+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in
12+
all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
THE SOFTWARE.
21+
*/
22+
23+
#ifndef LIBWSM_H
24+
#define LIBWSM_H
25+
//
26+
27+
/**
28+
* \file libwsm.h
29+
* \author MùPùF - Martin Peres (martin dot peres at free dot fr)
30+
* \date 05-10-2014
31+
*/
32+
33+
typedef struct wsm_t
34+
{
35+
36+
} wsm_t;
37+
38+
wsm_t *wsm_init();
39+
void wsm_fini(wsm_t *wsm);
40+
41+
//
42+
#endif

‎include/wsm/backend.h

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
Wayland Security Module
3+
Copyright (C) 2014 Martin Peres
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
#ifndef WSM_BACKEND_H
21+
#define WSM_BACKEND_H
22+
23+
/**
24+
* \file backend.h
25+
* \author MùPùF - Martin Peres (martin dot peres at free.fr dot fr)
26+
* \date 5-10-2014
27+
*/
28+
29+
#ifdef __cplusplus
30+
extern "C"
31+
{
32+
#endif
33+
34+
/*! \brief Get the space that would be needed if we were to store the entry in a string.
35+
* \param entry The concerned entry.
36+
* \return Return the space that would be needed if we were to store the entry in a string.*/
37+
const char* getModuleName(const ppk_entry* entry);
38+
39+
/*! \brief Convert an entry to a string
40+
* \param entry The entry to be converted.
41+
* \param[out] returned_key The string will be copied in this buffer.
42+
* \param max_key_size How much character are we allowed to copy to returned_key ?
43+
* \return Returns PPK_TRUE if everything went fine and PPK_FALSE if there were not enough room in returned_key to fit the given entry.*/
44+
ppk_boolean ppk_get_key(const ppk_entry* entry, char* returned_key, size_t max_key_size);
45+
46+
/*! \brief Convert a string to a ppk_entry
47+
* \param key The key to be converted to a ppk_entry.
48+
* \return Returns a ppk_entry if everything went fine, NULL otherwise.*/
49+
ppk_entry* ppk_entry_new_from_key(const char* key);
50+
51+
#ifdef __cplusplus
52+
}
53+
#endif
54+
55+
#endif //WSM_BACKEND_H

‎libwsm.pc.in

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
prefix=@CMAKE_INSTALL_PREFIX@
2+
exec_prefix=${prefix}
3+
libdir=${prefix}/lib
4+
includedir=${prefix}/include
5+
plugindir=${libdir}/libwsm/
6+
7+
Name: libwsm
8+
Description: LibWSM is a library for Wayland compositors to delegate their security-decisions to a user-defined backend.
9+
Version: @LIBWSM_VERSION@
10+
URL: http://libwsm.mupuf.org
11+
Libs: -L${libdir} -lwsm
12+
Cflags: -I${includedir}

‎src/debug.h

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ifndef DEBUG_H
2+
#define DEBUG_H
3+
4+
#include <stdio.h>
5+
#include <stdlib.h>
6+
7+
#define DEBUG(format, args...) do { \
8+
if (getenv("LIBWSM_DEBUG") && strcmp(getenv("LIBWSM_DEBUG"), "1") == 0) \
9+
fprintf(stderr, "libWSN: "format, ##args); \
10+
} while(0);
11+
12+
#endif // DEBUG_H

‎src/main.c

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/* Copyright (c) 2014 Martin Peres
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.
20+
*/
21+
22+
#include <libwsm.h>
23+
#include <stddef.h>
24+
25+
#include "module.h"
26+
27+
wsm_t *wsm_init()
28+
{
29+
return wsm_load_module();
30+
}
31+
32+
void wsm_fini(wsm_t *wsm)
33+
{
34+
35+
}
36+

‎src/module.c

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/* Copyright (c) 2014 Martin Peres
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.
20+
*/
21+
22+
#include <sys/types.h>
23+
#include <stddef.h>
24+
#include <dirent.h>
25+
#include <string.h>
26+
#include <malloc.h>
27+
#include <dlfcn.h>
28+
#include <stdio.h>
29+
#include <errno.h>
30+
31+
#include "module.h"
32+
#include "debug.h"
33+
34+
wsm_t *load_backend(const char *dir_path, const char *filename)
35+
{
36+
char path[PATH_MAX];
37+
struct wsm_priv_t *w_p;
38+
39+
//if the filename doesn't have the right prefix then try to load it as a shared object
40+
if(strncmp(filename, "libwsm_", 7))
41+
return NULL;
42+
43+
DEBUG("try loading the backend '%s'\n", filename);
44+
45+
snprintf(path, PATH_MAX-1, "%s/%s", dir_path, filename);
46+
47+
/* load the shared object */
48+
void* dlhandle = dlopen(path, RTLD_NOW);
49+
if (dlhandle == NULL) {
50+
DEBUG("failed to dlopen the library '%s': %s\n", filename, dlerror());
51+
return NULL;
52+
}
53+
54+
/* load the symbols */
55+
w_p = (struct wsm_priv_t *)malloc(sizeof(struct wsm_priv_t));
56+
w_p->dlhandle = dlhandle;
57+
w_p->ctor = (_ctor)dlsym(dlhandle, "ctor");
58+
w_p->dtor = (_dtor)dlsym(dlhandle, "dtor");
59+
w_p->getModuleName = (_getModuleName)dlsym(dlhandle, "getModuleName");
60+
w_p->getABIVersion = (_getABIVersion)dlsym(dlhandle, "getABIVersion");
61+
62+
/* if minimal functions are here, add the lib to available modules */
63+
if(w_p->ctor == NULL || w_p->dtor == NULL ||
64+
w_p->getModuleName == NULL || w_p->getABIVersion == NULL) {
65+
DEBUG("not all symbols are present, check version numbers\n");
66+
goto error;
67+
}
68+
69+
/* check that the ABI version is no greater than the one from this lib */
70+
if (w_p->getABIVersion() > 1) {
71+
DEBUG("wrong ABI version (%i)\n", w_p->getABIVersion());
72+
goto error;
73+
}
74+
75+
w_p->user = w_p->ctor();
76+
77+
DEBUG("WSM module '%s' got loaded successfully\n", w_p->getModuleName());
78+
79+
return (wsm_t *)w_p;
80+
81+
error:
82+
dlclose(dlhandle);
83+
free(w_p);
84+
return NULL;
85+
86+
}
87+
88+
wsm_t *wsm_load_module(void)
89+
{
90+
DIR * backend_dir;
91+
struct dirent * mydirent;
92+
wsm_t *wsm = NULL;
93+
94+
/* TODO: load the module the user actually wants! */
95+
96+
backend_dir = opendir(DIRECTORY_PATH);
97+
if(backend_dir == NULL) {
98+
fprintf(stderr, "WSM: Could not open the backend "
99+
"directory '"DIRECTORY_PATH"': %s\n",
100+
strerror(errno));
101+
return NULL;
102+
}
103+
104+
while ((mydirent = readdir(backend_dir))!=NULL && wsm == NULL)
105+
wsm = load_backend(DIRECTORY_PATH, mydirent->d_name);
106+
closedir(backend_dir);
107+
108+
return wsm;
109+
}
110+

‎src/module.h

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/* Copyright (c) 2014 Martin Peres
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.
20+
*/
21+
22+
#ifndef MODULE_H
23+
#define MODULE_H
24+
25+
#include <libwsm.h>
26+
27+
/**
28+
* \file module.h
29+
* \author Martin Peres
30+
* \date 05-10-2014
31+
*/
32+
33+
/** Init the module */
34+
typedef void *(*_ctor)(void);
35+
36+
/** free the module */
37+
typedef void (*_dtor)(void *);
38+
39+
/** Returns the name of the module */
40+
typedef const char* (*_getModuleName)(void);
41+
42+
/** Returns the name of the module */
43+
typedef const char* (*_getModuleName)(void);
44+
45+
/** Version of libwsm's ABI used by the module */
46+
typedef unsigned int (*_getABIVersion)(void);
47+
48+
struct wsm_priv_t
49+
{
50+
wsm_t base;
51+
52+
/* priv */
53+
void *dlhandle;
54+
void *user;
55+
56+
_ctor ctor;
57+
_dtor dtor;
58+
_getModuleName getModuleName;
59+
_getABIVersion getABIVersion;
60+
};
61+
62+
wsm_t *wsm_load_module(void);
63+
64+
#endif

‎tests/base.c

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <libwsm.h>
2+
3+
int main(int argc, char **argv)
4+
{
5+
wsm_t *wsm = wsm_init();
6+
7+
wsm_fini(wsm);
8+
9+
return 0;
10+
}

0 commit comments

Comments
 (0)
Please sign in to comment.