Skip to content

Commit 8f17fb9

Browse files
committed
修复:“reference undefined to xxx”等错误;
1 parent a43206d commit 8f17fb9

File tree

9 files changed

+44
-14
lines changed

9 files changed

+44
-14
lines changed

devapi/abe/abe_crypto.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "mysqlx/abe/base64.h"
1414

1515
namespace mysqlx{
16+
MYSQLX_ABI_BEGIN(2,0)
1617
namespace abe{
1718

1819
bool abe_crypto::encrypt(std::string pt, std::string policy, std::string &ct){
@@ -27,7 +28,7 @@ bool abe_crypto::encrypt(std::string pt, std::string policy, std::string &ct){
2728
return true;
2829
}
2930

30-
bool abe_crypto::decrypt(std::string ct, std::string &pt){
31+
bool abe_crypto::decrypt(const std::string ct, std::string &pt){
3132

3233
if(!check_abe_key()){
3334
return false;
@@ -321,4 +322,6 @@ bool abe_crypto::rsa_decrypt(const std::string ct, std::string &pt){
321322
}
322323

323324
}//namespace mysqlx::abe
325+
326+
MYSQLX_ABI_END(2,0)
324327
}//namespace mysqlx

devapi/abe/base64.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <iostream>
44

55
namespace mysqlx{
6+
MYSQLX_ABI_BEGIN(2,0)
67
namespace abe{
78
namespace base64_utils {
89

@@ -110,4 +111,6 @@ unsigned b64_dec_len(unsigned srclen)
110111

111112
}
112113
}//namespace mysqlx::abe
114+
115+
MYSQLX_ABI_END(2,0)
113116
}//namespace mysqlx

devapi/abe/rewrite.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* 解密函数格式:abe_dec(<field name>)
1616
*/
1717
namespace mysqlx{
18+
MYSQLX_ABI_BEGIN(2,0)
1819
namespace abe{
1920

2021
CommandType simple_parse(const std::string sql){
@@ -120,4 +121,5 @@ std::vector<std::string> rewrite_plan::get_field_name_list() const {
120121
}
121122

122123
}//namespace mysqlx::abe
124+
MYSQLX_ABI_END(2,0)
123125
}//namespace mysqlx

devapi/abe_extern.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88

99
namespace mysqlx{
10+
MYSQLX_ABI_BEGIN(2,0)
11+
1012
using rewrite_plan = mysqlx::abe::rewrite_plan;
1113
using abe_crypto = mysqlx::abe::abe_crypto;
1214

@@ -39,9 +41,9 @@ RowResult abe_query::execute(){
3941
std::string abe_query::recover(const std::string &ct){
4042
std::string pt;
4143
if(!crypto->decrypt(ct, pt)){
42-
return pt;
44+
return "";
4345
}
44-
return "";
46+
return pt;
4547
}
4648

4749

@@ -87,7 +89,7 @@ std::string abe_env::get_current_user(){
8789
if(row_num != 1 || field_num != 1) return "";
8890

8991
auto it = res.begin();
90-
auto str = (*it).get(1).get<string>();
92+
auto str = (*it).get(0).get<string>();
9193
std::string namehost(str);
9294
return namehost;
9395
}
@@ -101,7 +103,7 @@ std::string abe_env::get_current_user_abe_attribute(){
101103
if(row_num != 1 || field_num != 1) return "";
102104

103105
auto it = res.begin();
104-
auto str = (*it).get(1).get<string>();
106+
auto str = (*it).get(0).get<string>();
105107
std::string att(str);
106108
return att;
107109
}
@@ -157,4 +159,5 @@ bool abe_decrypt(abe_crypto &abe, std::string ct, std::string &pt){
157159
return true;
158160
}
159161

162+
MYSQLX_ABI_END(2,0)
160163
}//namespace mysqlx

include/mysqlx/abe/abe_crypto.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
#include <openssl/err.h>
88
#include <openssl/pem.h>
99
#include "openssl/crypto.h"
10+
#include "../common/api.h"
1011

1112
namespace mysqlx{
13+
MYSQLX_ABI_BEGIN(2,0)
1214
namespace abe{
1315

1416
#define ABE_ERROR(msg) std::cerr << "error: " << (msg) << std::endl;
@@ -24,7 +26,7 @@ struct abe_user{
2426
std::string user_attr;
2527
};
2628

27-
class abe_crypto{
29+
class PUBLIC_API abe_crypto{
2830
public:
2931

3032
abe_crypto(){}
@@ -39,7 +41,7 @@ class abe_crypto{
3941
bool check_abe_key(); //true: abe_key已存在
4042

4143
bool encrypt(std::string pt, std::string policy, std::string &ct);
42-
bool decrypt(std::string ct, std::string &pt);
44+
bool decrypt(const std::string ct, std::string &pt);
4345

4446
bool import_db_cert(std::string db_cert_path);
4547
bool import_kms_cert(std::string kms_cert_path);
@@ -61,6 +63,7 @@ class abe_crypto{
6163
};
6264

6365
}//namespace mysqlx::abe
66+
MYSQLX_ABI_END(2,0)
6467
}//namespace mysqlx
6568

6669
#endif

include/mysqlx/abe/base64.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#ifndef SQL_ABE_BASE64_H
22
#define SQL_ABE_BASE64_H
3+
#include "../common/api.h"
34
namespace mysqlx{
5+
MYSQLX_ABI_BEGIN(2,0)
6+
47
namespace abe{
58
namespace base64_utils {
69
static const char _base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
@@ -143,5 +146,7 @@ namespace base64_utils {
143146
}
144147

145148
}//namespace mysqlx::abe
149+
150+
MYSQLX_ABI_END(2,0)
146151
}//namespace mysqlx
147152
#endif // SEC_ABE_UTILS_H

include/mysqlx/abe/rewrite.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@
88
#include <unordered_map>
99
#include <regex>
1010
#include "abe_crypto.h"
11+
#include "../common/api.h"
1112

1213

1314
namespace mysqlx{
15+
MYSQLX_ABI_BEGIN(2,0)
16+
1417
namespace abe{
1518
enum CommandType{
1619
BEGIN,
@@ -142,5 +145,6 @@ class rewrite_plan{
142145
};
143146

144147
}//namespace mysqlx::abe
148+
MYSQLX_ABI_END(2,0)
145149
}//namespace mysqlx
146150
#endif

include/mysqlx/abe_extern.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@
77
#include "xdevapi.h"
88
// #include "devapi/detail/result.h"
99
namespace mysqlx {
10+
MYSQLX_ABI_BEGIN(2,0)
1011

1112
struct abe_parameters{
12-
string rsa_sk_path; //rsa私钥路径,用于解密
13-
string db_cert_path; //db证书,用于验签
14-
string kms_cert_path; //kms证书,用于验签
13+
std::string rsa_sk_path; //rsa私钥路径,用于解密
14+
std::string db_cert_path; //db证书,用于验签
15+
std::string kms_cert_path; //kms证书,用于验签
1516

16-
string abe_key_path; //abe密钥路径
17-
string abe_pp_path; //abe公共参数路径,也可称mpk
17+
std::string abe_key_path; //abe密钥路径
18+
std::string abe_pp_path; //abe公共参数路径,也可称mpk
1819
};
1920

20-
class abe_query : public abe::rewrite_plan{
21+
class PUBLIC_API abe_query : public abe::rewrite_plan{
2122
public:
2223
abe_query(Session * sess, abe::abe_crypto * abe, std::string sql): rewrite_plan(sql){
2324
this->sess = sess;
@@ -38,7 +39,7 @@ class abe_query : public abe::rewrite_plan{
3839
Session * sess;
3940
};
4041

41-
class abe_env{
42+
class PUBLIC_API abe_env{
4243
public:
4344
abe_env(Session &sess){
4445
this->sess = &sess;
@@ -74,6 +75,8 @@ class abe_env{
7475

7576
bool abe_encrypt(abe::abe_crypto &abe, std::string pt, std::string policy, std::string &ct );
7677
bool abe_decrypt(abe::abe_crypto &abe, std::string ct, std::string &pt);
78+
79+
MYSQLX_ABI_END(2,0)
7780
}
7881
// const std::string abe_rewrite(const std::string &query, const abe_crypto &abe);
7982
#endif //ABE_EXTERN_H

include/mysqlx/common/api.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ MYSQLX_ABI_BEGIN(2,0)
9292
namespace common {
9393
}
9494

95+
namespace abe {
96+
97+
}
98+
9599
MYSQLX_ABI_END(2,0)
96100

97101
/*

0 commit comments

Comments
 (0)