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
2bfed31a
Commit
2bfed31a
authored
Oct 30, 2017
by
Casualet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add debug to this project
parent
1a5304df
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
187 additions
and
4 deletions
+187
-4
.gitignore
.gitignore
+1
-0
Makefile
Makefile
+9
-4
Makefrag
debug/Makefrag
+8
-0
hello.cc
debug/hello.cc
+4
-0
mcmd.cc
debug/mcmd.cc
+165
-0
No files found.
.gitignore
View file @
2bfed31a
...
...
@@ -20,3 +20,4 @@ writeFile
*back.sql
*load.sql
data
mtl
Makefile
View file @
2bfed31a
...
...
@@ -76,16 +76,21 @@ $(OBJDIR)/%.o: $(OBJDIR)/%.cc
@
mkdir
-p
$
(
@D
)
$(CXX)
-MD
$(CXXFLAGS)
-c
$<
-o
$@
mtl/%
:
$(OBJDIR)/debug/%.o
@
mkdir
-p
$
(
@D
)
$(CXX)
-g
-o
$@
$^
$(CXXFLAGS)
$(LDFLAGS)
-L
/
$(MYBUILD)
/libmysqld
-lmysqld
-laio
-lz
-ldl
-lm
-lcrypt
-lpthread
-lcryptdb
-ledbcrypto
-ledbutil
-ledbparser
-lntl
-lcrypto
include
crypto/Makefrag
include
parser/Makefrag
include
main/Makefrag
#include test/Makefrag
include
util/Makefrag
include
udf/Makefrag
include
mysqlproxy/Makefrag
#include tools/import/Makefrag
#include tools/learn/Makefrag
#include scripts/Makefrag
include
debug/Makefrag
$(OBJDIR)/.deps
:
$(foreach dir
,
$(OBJDIRS)
,
$(wildcard $(OBJDIR)/$(dir)/*.d))
@
mkdir
-p
$
(
@D
)
...
...
debug/Makefrag
0 → 100644
View file @
2bfed31a
OBJDIRS += debug
##note that xx=*.cc will not expand. wildcard *.cc will include files from other directories.
##%.o will include testall
TESTALL_OBJS := $(patsubst %.cc,$(OBJDIR)/%.o,$(wildcard debug/*.cc))
TESTALL_EXES := $(patsubst debug/%.cc,mtl/%,$(wildcard debug/*.cc))
all: $(TESTALL_OBJS) $(TESTALL_EXES)
debug/hello.cc
0 → 100644
View file @
2bfed31a
int
main
(){
return
0
;
}
debug/mcmd.cc
0 → 100644
View file @
2bfed31a
#include <cstdlib>
#include <cstdio>
#include <string>
#include <map>
#include <iostream>
#include <fstream>
#include <sstream>
#include <stdexcept>
#include <vector>
#include <set>
#include <list>
#include <algorithm>
#include <functional>
#include <cctype>
#include <locale>
#include <unistd.h>
#include <sys/types.h>
#include <dirent.h>
#include <main/Connect.hh>
#include <main/rewrite_main.hh>
#include <main/rewrite_util.hh>
#include <main/sql_handler.hh>
#include <main/dml_handler.hh>
#include <main/ddl_handler.hh>
#include <main/metadata_tables.hh>
#include <main/macro_util.hh>
#include <main/CryptoHandlers.hh>
#include <parser/embedmysql.hh>
#include <parser/stringify.hh>
#include <parser/lex_util.hh>
#include <readline/readline.h>
#include <readline/history.h>
#include <crypto/ecjoin.hh>
#include <util/errstream.hh>
#include <util/cryptdb_log.hh>
#include <util/enum_text.hh>
#include <util/yield.hpp>
#include <sstream>
#include <unistd.h>
static
std
::
string
embeddedDir
=
"/t/cryt/shadow"
;
//My WrapperState.
class
WrapperState
{
WrapperState
(
const
WrapperState
&
other
);
WrapperState
&
operator
=
(
const
WrapperState
&
rhs
);
KillZone
kill_zone
;
public
:
std
::
string
last_query
;
std
::
string
default_db
;
WrapperState
()
{}
~
WrapperState
()
{}
const
std
::
unique_ptr
<
QueryRewrite
>
&
getQueryRewrite
()
const
{
assert
(
this
->
qr
);
return
this
->
qr
;
}
void
setQueryRewrite
(
std
::
unique_ptr
<
QueryRewrite
>
&&
in_qr
)
{
this
->
qr
=
std
::
move
(
in_qr
);
}
void
selfKill
(
KillZone
::
Where
where
)
{
kill_zone
.
die
(
where
);
}
void
setKillZone
(
const
KillZone
&
kz
)
{
kill_zone
=
kz
;
}
std
::
unique_ptr
<
ProxyState
>
ps
;
std
::
vector
<
SchemaInfoRef
>
schema_info_refs
;
private
:
std
::
unique_ptr
<
QueryRewrite
>
qr
;
};
//global map, for each client, we have one WrapperState which contains ProxyState.
static
std
::
map
<
std
::
string
,
WrapperState
*>
clients
;
//This connection mimics the behaviour of MySQL-Proxy
Connect
*
globalConn
;
static
void
processFieldMeta
(
const
FieldMeta
&
field
){
std
::
cout
<<
GREEN_BEGIN
<<
"PRINT FieldMeta"
<<
COLOR_END
<<
std
::
endl
;
for
(
const
auto
&
onion
:
field
.
getChildren
()){
std
::
cout
<<
onion
.
second
->
getDatabaseID
()
<<
":"
<<
onion
.
first
.
getValue
()
<<
std
::
endl
;
}
std
::
cout
<<
GREEN_BEGIN
<<
"end FieldMeta"
<<
COLOR_END
<<
std
::
endl
;
}
static
void
processTableMeta
(
const
TableMeta
&
table
){
std
::
cout
<<
GREEN_BEGIN
<<
"PRINT TableMeta"
<<
COLOR_END
<<
std
::
endl
;
for
(
const
auto
&
field
:
table
.
getChildren
()){
std
::
cout
<<
field
.
second
->
getDatabaseID
()
<<
":"
<<
field
.
first
.
getValue
()
<<
std
::
endl
;
processFieldMeta
(
*
(
field
.
second
));
}
}
static
void
processDatabaseMeta
(
const
DatabaseMeta
&
db
)
{
std
::
cout
<<
GREEN_BEGIN
<<
"PRINT DatabaseMeta"
<<
COLOR_END
<<
std
::
endl
;
for
(
const
auto
&
table
:
db
.
getChildren
()){
processTableMeta
(
*
(
table
.
second
));
}
}
static
void
processSchemaInfo
(
SchemaInfo
&
schema
){
//we have a map here
std
::
cout
<<
GREEN_BEGIN
<<
"PRINT SchemaInfo"
<<
COLOR_END
<<
std
::
endl
;
//only const auto & is allowed, now copying. or we meet use of deleted function.
for
(
const
auto
&
child
:
schema
.
getChildren
())
{
std
::
cout
<<
child
.
second
->
getDatabaseID
()
<<
":"
<<
child
.
first
.
getValue
()
<<
std
::
endl
;
processDatabaseMeta
(
*
(
child
.
second
));
}
}
static
std
::
unique_ptr
<
SchemaInfo
>
myLoadSchemaInfo
()
{
std
::
unique_ptr
<
Connect
>
e_conn
(
Connect
::
getEmbedded
(
embeddedDir
));
std
::
unique_ptr
<
SchemaInfo
>
schema
(
new
SchemaInfo
());
std
::
function
<
DBMeta
*
(
DBMeta
*
const
)
>
loadChildren
=
[
&
loadChildren
,
&
e_conn
](
DBMeta
*
const
parent
)
{
auto
kids
=
parent
->
fetchChildren
(
e_conn
);
for
(
auto
it
:
kids
)
{
loadChildren
(
it
);
}
return
parent
;
};
//load all metadata and then store it in schema
loadChildren
(
schema
.
get
());
Analysis
analysis
(
std
::
string
(
"student"
),
*
schema
,
std
::
unique_ptr
<
AES_KEY
>
(
getKey
(
std
::
string
(
"113341234"
))),
SECURITY_RATING
::
SENSITIVE
);
return
schema
;
}
int
main
()
{
char
*
buffer
;
if
((
buffer
=
getcwd
(
NULL
,
0
))
==
NULL
){
perror
(
"getcwd error"
);
}
embeddedDir
=
std
::
string
(
buffer
)
+
"/shadow"
;
std
::
string
client
=
"192.168.1.1:1234"
;
//one Wrapper per user.
clients
[
client
]
=
new
WrapperState
();
//Connect phase
ConnectionInfo
ci
(
"localhost"
,
"root"
,
"letmein"
,
3306
);
const
std
::
string
master_key
=
"113341234"
;
SharedProxyState
*
shared_ps
=
new
SharedProxyState
(
ci
,
embeddedDir
,
master_key
,
determineSecurityRating
());
assert
(
0
==
mysql_thread_init
());
//we init embedded database here.
clients
[
client
]
->
ps
=
std
::
unique_ptr
<
ProxyState
>
(
new
ProxyState
(
*
shared_ps
));
clients
[
client
]
->
ps
->
safeCreateEmbeddedTHD
();
//Connect end!!
globalConn
=
new
Connect
(
ci
.
server
,
ci
.
user
,
ci
.
passwd
,
ci
.
port
);
std
::
unique_ptr
<
SchemaInfo
>
sm
=
myLoadSchemaInfo
();
processSchemaInfo
(
*
sm
);
return
0
;
}
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