zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #17399
[Merge] lp:~zorba-coders/zorba/sqlite-with-file-access into lp:zorba/sqlite-module
Chris Hillery has proposed merging lp:~zorba-coders/zorba/sqlite-with-file-access into lp:zorba/sqlite-module.
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.
Requested reviews:
Chris Hillery (ceejatec)
Luis Rodriguez Gonzalez (kuraru)
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/sqlite-with-file-access/+merge/144641
--
https://code.launchpad.net/~zorba-coders/zorba/sqlite-with-file-access/+merge/144641
Your team Zorba Coders is subscribed to branch lp:zorba/sqlite-module.
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2012-11-20 16:41:36 +0000
+++ CMakeLists.txt 2013-01-24 06:18:21 +0000
@@ -42,6 +42,18 @@
IF (SQLITE_FOUND)
MESSAGE (STATUS "Found SQLite --" ${SQLITE_LIBRARIES})
+
+ # Set SQLITE_WITH_FILE_ACCESS - by default will be the same value as
+ # ZORBA_WITH_FILE ACCESS when built inside Zorba, or "ON" if built
+ # stand-alone.
+ IF (DEFINED ZORBA_WITH_FILE_ACCESS)
+ SET (_file_access ${ZORBA_WITH_FILE_ACCESS})
+ ELSE (DEFINED ZORBA_WITH_FILE_ACCESS)
+ SET (_file_access ON)
+ ENDIF (DEFINED ZORBA_WITH_FILE_ACCESS)
+ SET(SQLITE_WITH_FILE_ACCESS ${_file_access} CACHE BOOL
+ "Allow filesystem-based SQLite databases")
+
INCLUDE_DIRECTORIES (${SQLITE_INCLUDE_DIR})
ADD_SUBDIRECTORY("src")
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2012-11-20 16:41:36 +0000
+++ src/CMakeLists.txt 2013-01-24 06:18:21 +0000
@@ -12,7 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}/sqlite_module.xq.src")
+CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake"
+ "${CMAKE_CURRENT_BINARY_DIR}/sqlite_module/config.h")
+INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}")
DECLARE_ZORBA_MODULE (
URI "http://www.zorba-xquery.com/modules/sqlite"
=== added file 'src/config.h.cmake'
--- src/config.h.cmake 1970-01-01 00:00:00 +0000
+++ src/config.h.cmake 2013-01-24 06:18:21 +0000
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2013 The FLWOR Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// This header is configured by the SQLite module's build process
+// -- DO NOT EDIT!
+
+#ifndef ZORBA_SQLITE_CONFIG_H
+#define ZORBA_SQLITE_CONFIG_H
+
+#cmakedefine SQLITE_WITH_FILE_ACCESS
+
+#endif /* ZORBA_SQLITE_CONFIG_H */
=== modified file 'src/sqlite_module.xq'
--- src/sqlite_module.xq 2013-01-09 15:07:19 +0000
+++ src/sqlite_module.xq 2013-01-24 06:18:21 +0000
@@ -37,7 +37,9 @@
:
: @return the SQLite database object as xs:anyURI.
:
- : @error s:SQLI0001 if the databse name doesn't exist or it couldn't be opened.
+ : @error s:SQLI0001 if the database name doesn't exist or it couldn't be opened.
+ : @error s:SQLI0008 if a non-in-memory database is requested and the module
+ : is built without filesystem access
: @error s:SQLI9999 if there was an internal error inside SQLite library.
:)
declare %an:sequential function s:connect(
=== modified file 'src/sqlite_module.xq.src/sqlite_module.cpp'
--- src/sqlite_module.xq.src/sqlite_module.cpp 2013-01-09 15:07:19 +0000
+++ src/sqlite_module.xq.src/sqlite_module.cpp 2013-01-24 06:18:21 +0000
@@ -31,6 +31,7 @@
#include <stdio.h>
#include "sqlite_module.h"
+#include <sqlite_module/config.h>
namespace zorba { namespace sqlite {
@@ -566,6 +567,12 @@
{
return "Parameter passed is not a valid value";
}
+#ifndef SQLITE_WITH_FILE_ACCESS
+ else if(error == "SQLI0008")
+ {
+ return "Only in-memory databases are allowed (Module built without filesystem access)";
+ }
+#endif /* not SQLITE_WITH_FILE_ACCESS */
else if(error == "SQLI9999")
{
return "Internal error ocurred";
@@ -909,6 +916,12 @@
lDbName = lItemName.getStringValue().str();
if(lDbName == "")
lDbName = std::string(":memory:");
+
+#ifndef SQLITE_WITH_FILE_ACCESS
+ if (lDbName != ":memory:") {
+ throwError("SQLI0008", getErrorMessage("SQLI0008"));
+ }
+#endif /* not SQLITE_WITH_FILE_ACCESS */
lRc = sqlite3_open_v2(lDbName.c_str(), &lSqldb, lOptions.getOptionsAsInt(), NULL);
// Store the UUID for this connection and return it
lStrUUID = createUUID();
Follow ups
-
[Merge] lp:~zorba-coders/zorba/sqlite-with-file-access into lp:zorba/sqlite-module
From: noreply, 2013-01-24
-
[Merge] lp:~zorba-coders/zorba/sqlite-with-file-access into lp:zorba/sqlite-module
From: Zorba Build Bot, 2013-01-24
-
[Merge] lp:~zorba-coders/zorba/sqlite-with-file-access into lp:zorba/sqlite-module
From: Zorba Build Bot, 2013-01-24
-
[Merge] lp:~zorba-coders/zorba/sqlite-with-file-access into lp:zorba/sqlite-module
From: Luis Rodriguez Gonzalez, 2013-01-24
-
Re: [Merge] lp:~zorba-coders/zorba/sqlite-with-file-access into lp:zorba/sqlite-module
From: Luis Rodriguez Gonzalez, 2013-01-24
-
[Merge] lp:~zorba-coders/zorba/sqlite-with-file-access into lp:zorba/sqlite-module
From: Zorba Build Bot, 2013-01-24
-
Re: [Merge] lp:~zorba-coders/zorba/sqlite-with-file-access into lp:zorba/sqlite-module
From: Zorba Build Bot, 2013-01-24
-
[Merge] lp:~zorba-coders/zorba/sqlite-with-file-access into lp:zorba/sqlite-module
From: Zorba Build Bot, 2013-01-24
-
[Merge] lp:~zorba-coders/zorba/sqlite-with-file-access into lp:zorba/sqlite-module
From: Chris Hillery, 2013-01-24
-
[Merge] lp:~zorba-coders/zorba/sqlite-with-file-access into lp:zorba/sqlite-module
From: Zorba Build Bot, 2013-01-24
-
Re: [Merge] lp:~zorba-coders/zorba/sqlite-with-file-access into lp:zorba/sqlite-module
From: Chris Hillery, 2013-01-24
-
[Merge] lp:~zorba-coders/zorba/sqlite-with-file-access into lp:zorba/sqlite-module
From: Chris Hillery, 2013-01-24