Merge lp:~zorba-coders/zorba/sqlite-with-file-access into lp:zorba/sqlite-module

Proposed by Chris Hillery
Status: Merged
Approved by: Luis Rodriguez Gonzalez
Approved revision: 28
Merged at revision: 28
Proposed branch: lp:~zorba-coders/zorba/sqlite-with-file-access
Merge into: lp:zorba/sqlite-module
Diff against target: 120 lines (+56/-2)
5 files modified
CMakeLists.txt (+12/-0)
src/CMakeLists.txt (+3/-1)
src/config.h.cmake (+25/-0)
src/sqlite_module.xq (+3/-1)
src/sqlite_module.xq.src/sqlite_module.cpp (+13/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/sqlite-with-file-access
Reviewer Review Type Date Requested Status
Luis Rodriguez Gonzalez Approve
Chris Hillery Approve
Review via email: mp+144641@code.launchpad.net

Commit message

Add SQLITE_WITH_FILE_ACCESS to prevent filesystem access. Defaults to same value as ZORBA_WITH_FILE_ACCESS when built inside Zorba, or "ON" when built stand-alone.

To post a comment you must log in.
Revision history for this message
Chris Hillery (ceejatec) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job sqlite-with-file-access-2013-01-24T06-19-40.589Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 1 Approve, 1 Pending.

Revision history for this message
Luis Rodriguez Gonzalez (kuraru) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job sqlite-with-file-access-2013-01-24T16-06-45.722Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2012-11-20 16:41:36 +0000
3+++ CMakeLists.txt 2013-01-24 06:18:21 +0000
4@@ -42,6 +42,18 @@
5
6 IF (SQLITE_FOUND)
7 MESSAGE (STATUS "Found SQLite --" ${SQLITE_LIBRARIES})
8+
9+ # Set SQLITE_WITH_FILE_ACCESS - by default will be the same value as
10+ # ZORBA_WITH_FILE ACCESS when built inside Zorba, or "ON" if built
11+ # stand-alone.
12+ IF (DEFINED ZORBA_WITH_FILE_ACCESS)
13+ SET (_file_access ${ZORBA_WITH_FILE_ACCESS})
14+ ELSE (DEFINED ZORBA_WITH_FILE_ACCESS)
15+ SET (_file_access ON)
16+ ENDIF (DEFINED ZORBA_WITH_FILE_ACCESS)
17+ SET(SQLITE_WITH_FILE_ACCESS ${_file_access} CACHE BOOL
18+ "Allow filesystem-based SQLite databases")
19+
20 INCLUDE_DIRECTORIES (${SQLITE_INCLUDE_DIR})
21
22 ADD_SUBDIRECTORY("src")
23
24=== modified file 'src/CMakeLists.txt'
25--- src/CMakeLists.txt 2012-11-20 16:41:36 +0000
26+++ src/CMakeLists.txt 2013-01-24 06:18:21 +0000
27@@ -12,7 +12,9 @@
28 # See the License for the specific language governing permissions and
29 # limitations under the License.
30
31-INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}/sqlite_module.xq.src")
32+CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake"
33+ "${CMAKE_CURRENT_BINARY_DIR}/sqlite_module/config.h")
34+INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}")
35
36 DECLARE_ZORBA_MODULE (
37 URI "http://www.zorba-xquery.com/modules/sqlite"
38
39=== added file 'src/config.h.cmake'
40--- src/config.h.cmake 1970-01-01 00:00:00 +0000
41+++ src/config.h.cmake 2013-01-24 06:18:21 +0000
42@@ -0,0 +1,25 @@
43+/*
44+ * Copyright 2013 The FLWOR Foundation.
45+ *
46+ * Licensed under the Apache License, Version 2.0 (the "License");
47+ * you may not use this file except in compliance with the License.
48+ * You may obtain a copy of the License at
49+ *
50+ * http://www.apache.org/licenses/LICENSE-2.0
51+ *
52+ * Unless required by applicable law or agreed to in writing, software
53+ * distributed under the License is distributed on an "AS IS" BASIS,
54+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
55+ * See the License for the specific language governing permissions and
56+ * limitations under the License.
57+ */
58+
59+// This header is configured by the SQLite module's build process
60+// -- DO NOT EDIT!
61+
62+#ifndef ZORBA_SQLITE_CONFIG_H
63+#define ZORBA_SQLITE_CONFIG_H
64+
65+#cmakedefine SQLITE_WITH_FILE_ACCESS
66+
67+#endif /* ZORBA_SQLITE_CONFIG_H */
68
69=== modified file 'src/sqlite_module.xq'
70--- src/sqlite_module.xq 2013-01-09 15:07:19 +0000
71+++ src/sqlite_module.xq 2013-01-24 06:18:21 +0000
72@@ -37,7 +37,9 @@
73 :
74 : @return the SQLite database object as xs:anyURI.
75 :
76- : @error s:SQLI0001 if the databse name doesn't exist or it couldn't be opened.
77+ : @error s:SQLI0001 if the database name doesn't exist or it couldn't be opened.
78+ : @error s:SQLI0008 if a non-in-memory database is requested and the module
79+ : is built without filesystem access
80 : @error s:SQLI9999 if there was an internal error inside SQLite library.
81 :)
82 declare %an:sequential function s:connect(
83
84=== modified file 'src/sqlite_module.xq.src/sqlite_module.cpp'
85--- src/sqlite_module.xq.src/sqlite_module.cpp 2013-01-09 15:07:19 +0000
86+++ src/sqlite_module.xq.src/sqlite_module.cpp 2013-01-24 06:18:21 +0000
87@@ -31,6 +31,7 @@
88 #include <stdio.h>
89
90 #include "sqlite_module.h"
91+#include <sqlite_module/config.h>
92
93 namespace zorba { namespace sqlite {
94
95@@ -566,6 +567,12 @@
96 {
97 return "Parameter passed is not a valid value";
98 }
99+#ifndef SQLITE_WITH_FILE_ACCESS
100+ else if(error == "SQLI0008")
101+ {
102+ return "Only in-memory databases are allowed (Module built without filesystem access)";
103+ }
104+#endif /* not SQLITE_WITH_FILE_ACCESS */
105 else if(error == "SQLI9999")
106 {
107 return "Internal error ocurred";
108@@ -909,6 +916,12 @@
109 lDbName = lItemName.getStringValue().str();
110 if(lDbName == "")
111 lDbName = std::string(":memory:");
112+
113+#ifndef SQLITE_WITH_FILE_ACCESS
114+ if (lDbName != ":memory:") {
115+ throwError("SQLI0008", getErrorMessage("SQLI0008"));
116+ }
117+#endif /* not SQLITE_WITH_FILE_ACCESS */
118 lRc = sqlite3_open_v2(lDbName.c_str(), &lSqldb, lOptions.getOptionsAsInt(), NULL);
119 // Store the UUID for this connection and return it
120 lStrUUID = createUUID();

Subscribers

People subscribed via source and target branches

to all changes: