Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
Practical-Cryptdb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Zhaozhen
Practical-Cryptdb
Commits
21071ece
Commit
21071ece
authored
Apr 17, 2017
by
casualet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add wrapper.lua to the current directory
parent
a6c0a985
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
49 deletions
+20
-49
rewrite_util.cc
main/rewrite_util.cc
+1
-1
wrapper.lua
wrapper.lua
+19
-48
No files found.
main/rewrite_util.cc
View file @
21071ece
...
...
@@ -571,7 +571,7 @@ isUnique(const std::string &name,
const
auto
&
found
=
std
::
find
(
std
::
get
<
0
>
(
it
).
begin
(),
std
::
get
<
0
>
(
it
).
end
(),
name
);
if
(
found
!=
std
::
get
<
0
>
(
it
).
end
()
&&
(
std
::
get
<
1
>
(
it
)
==
Key
::
PRIMARY
||
std
::
get
<
1
>
(
it
)
==
Key
::
UNIQUE
))
{
&&
(
std
::
get
<
1
>
(
it
)
==
Key
::
PRIMARY
||
std
::
get
<
1
>
(
it
)
==
Key
::
UNIQUE
||
std
::
get
<
1
>
(
it
)
==
Key
::
FOREIGN_KEY
))
{
unique
=
true
;
break
;
}
...
...
mysqlproxy/
wrapper.lua
→
wrapper.lua
View file @
21071ece
assert
(
package.loadlib
(
"/t/cryt/obj/libexecute.so"
,
"lua_cryptdb_init"
))()
local
handle
=
io.popen
(
'pwd'
)
local
result
=
handle
:
read
(
"*a"
)
handle
:
close
()
prefix
=
result
:
gsub
(
"
\n
$"
,
""
)
libpath
=
prefix
..
"/obj/libexecute.so"
assert
(
package.loadlib
(
libpath
,
"lua_cryptdb_init"
))()
local
proto
=
assert
(
require
(
"mysql.proto"
))
local
g_want_interim
=
nil
...
...
@@ -20,7 +25,7 @@ function read_auth()
proxy
.
connection
.
server
.
dst
.
port
,
os.getenv
(
"CRYPTDB_USER"
)
or
"root"
,
os.getenv
(
"CRYPTDB_PASS"
)
or
"letmein"
,
os.getenv
(
"CRYPTDB_SHADOW"
)
or
"/t/cryt
/shadow"
)
os.getenv
(
"CRYPTDB_SHADOW"
)
or
prefix
..
"
/shadow"
)
-- EDBClient uses its own connection to the SQL server to set up UDFs
-- and to manipulate multi-principal state. (And, in the future, to
-- store its schema state for single- and multi-principal operation.)
...
...
@@ -32,17 +37,16 @@ function disconnect_client()
end
function
read_query
(
packet
)
printred
(
"read_query========================================================================================"
)
local
status
,
err
=
pcall
(
read_query_real
,
packet
)
if
status
then
return
err
else
print
(
"read_query: "
..
err
)
return
proxy
.
PROXY_SEND_QUERY
end
end
function
read_query_result
(
inj
)
printred
(
"read_query_result========================================================================================"
)
local
status
,
err
=
pcall
(
read_query_result_real
,
inj
)
if
status
then
return
err
...
...
@@ -53,28 +57,6 @@ function read_query_result(inj)
end
function
split
(
pString
,
pPattern
)
local
Table
=
{}
-- NOTE: use {n = 0} in Lua-5.0
local
fpat
=
"(.-)"
..
pPattern
local
last_end
=
1
local
s
,
e
,
cap
=
pString
:
find
(
fpat
,
1
)
while
s
do
if
s
~=
1
or
cap
~=
""
then
table.insert
(
Table
,
cap
)
end
last_end
=
e
+
1
s
,
e
,
cap
=
pString
:
find
(
fpat
,
last_end
)
end
if
last_end
<=
#
pString
then
cap
=
pString
:
sub
(
last_end
)
table.insert
(
Table
,
cap
)
end
return
Table
end
--
-- Pretty printing
--
...
...
@@ -100,8 +82,6 @@ function printred(x)
end
function
printline
(
n
)
print
(
"#######n=="
)
print
(
n
)
-- pretty printing
if
(
n
)
then
io.write
(
"+"
)
...
...
@@ -140,13 +120,7 @@ function prettyNewQuery(q)
end
end
list
=
split
(
q
,
','
)
for
i
=
1
,
#
list
do
io.write
(
string.sub
(
list
[
i
],
1
,
40
))
print
(
""
)
end
--print(greentext("NEW QUERY: ")..makePrintable(q))
print
(
greentext
(
"NEW QUERY: "
)
..
makePrintable
(
q
))
end
--
...
...
@@ -161,7 +135,8 @@ end
function
read_query_real
(
packet
)
local
query
=
string.sub
(
packet
,
2
)
--printred("QUERY: ".. query)
print
(
"================================================"
)
printred
(
"QUERY: "
..
query
)
if
string.byte
(
packet
)
==
proxy
.
COM_INIT_DB
then
query
=
"USE `"
..
query
..
"`"
...
...
@@ -186,12 +161,6 @@ function read_query_real(packet)
end
end
function
printRowsAndFields
(
inj
)
local
resultset
=
inj
.
resultset
end
function
read_query_result_real
(
inj
)
local
query
=
inj
.
query
:
sub
(
2
)
prettyNewQuery
(
query
)
...
...
@@ -228,9 +197,12 @@ function read_query_result_real(inj)
interim_fields
[
i
]
=
{
type
=
resfields
[
i
].
type
,
name
=
resfields
[
i
].
name
}
io.write
(
string.format
(
"%-
1
0s|"
,
rfi
.
name
))
io.write
(
string.format
(
"%-
2
0s|"
,
rfi
.
name
))
end
print
()
printline
(
#
resfields
)
local
resrows
=
resultset
.
rows
if
resrows
then
for
row
in
resrows
do
...
...
@@ -242,10 +214,9 @@ function read_query_result_real(inj)
print
()
end
end
--printline(#resfields)
end
print
(
greentext
(
"ENCRYPTED RESULTS END"
))
printline
(
#
resfields
)
end
return
next_handler
(
"results"
,
true
,
client
,
interim_fields
,
interim_rows
,
resultset
.
affected_rows
,
resultset
.
insert_id
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment