Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
Root
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
为了安全,强烈建议开启2FA双因子认证:User Settings -> Account -> Enable two-factor authentication!!!
Show more breadcrumbs
cxwx
Root
Commits
01ccc3f1
Commit
01ccc3f1
authored
8 years ago
by
Georgios Bitzes
Committed by
Pere Mato
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add S3 Alternate support to TDavixFile
parent
502e6e04
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
config/rootrc.in
+7
-0
7 additions, 0 deletions
config/rootrc.in
net/davix/src/TDavixFile.cxx
+37
-0
37 additions, 0 deletions
net/davix/src/TDavixFile.cxx
net/davix/src/TDavixFileInternal.h
+1
-0
1 addition, 0 deletions
net/davix/src/TDavixFileInternal.h
with
45 additions
and
0 deletions
config/rootrc.in
+
7
−
0
View file @
01ccc3f1
...
...
@@ -723,10 +723,17 @@ Davix.UseOldClient: @useoldwebfile@
# Sets the Amazon S3 authentication parameters
# Region is optional - if provided, davix will use v4 signatures
# Token is optional, and enables the use of STS temporary credentials
#
# Alternate is optional and takes a boolean value. If set to true, davix
# will assume that the bucket name is in the path, not in the hostname.
# Necessary because davix has to know the bucket name to calculate
# the S3 signatures.
#
# Davix.S3.SecretKey: secret
# Davix.S3.AccessKey: access
# Davix.S3.Region: region
# Davix.S3.Token: token
# Davix.S3.Alternate: yes
# NOTE: The authentication of TDavixFile/TDavixSystem can be influenced
# through some well known environment variables:
...
...
This diff is collapsed.
Click to expand it.
net/davix/src/TDavixFile.cxx
+
37
−
0
View file @
01ccc3f1
...
...
@@ -71,6 +71,7 @@ const char* s3_seckey_opt = "s3seckey=";
const
char
*
s3_acckey_opt
=
"s3acckey="
;
const
char
*
s3_region_opt
=
"s3region="
;
const
char
*
s3_token_opt
=
"s3token="
;
const
char
*
s3_alternate_opt
=
"s3alternate="
;
const
char
*
open_mode_read
=
"READ"
;
const
char
*
open_mode_create
=
"CREATE"
;
const
char
*
open_mode_new
=
"NEW"
;
...
...
@@ -92,6 +93,15 @@ bool isno(const char *str)
}
bool
strToBool
(
const
char
*
str
,
bool
defvalue
)
{
if
(
!
str
)
return
defvalue
;
if
(
strcmp
(
str
,
"n"
)
==
0
||
strcmp
(
str
,
"no"
)
==
0
||
strcmp
(
str
,
"0"
)
==
0
||
strcmp
(
str
,
"false"
)
==
0
)
return
false
;
if
(
strcmp
(
str
,
"y"
)
==
0
||
strcmp
(
str
,
"yes"
)
==
0
||
strcmp
(
str
,
"1"
)
==
0
||
strcmp
(
str
,
"true"
)
==
0
)
return
true
;
return
defvalue
;
}
////////////////////////////////////////////////////////////////////////////////
int
configure_open_flag
(
const
std
::
string
&
str
,
int
old_flag
)
...
...
@@ -321,6 +331,20 @@ static void awsToken(...) {
Warning
(
"awsToken"
,
"Unable to set AWS token, not supported by this version of davix"
);
}
// Identical SFINAE trick as above for setAwsAlternate
template
<
typename
TRequestParams
=
Davix
::
RequestParams
>
static
auto
awsAlternate
(
TRequestParams
*
parameters
,
bool
option
)
->
decltype
(
parameters
->
setAwsAlternate
(
option
),
void
())
{
if
(
gDebug
>
1
)
Info
(
"awsAlternate"
,
"Setting S3 path-based bucket option (s3alternate)"
);
parameters
->
setAwsAlternate
(
option
);
}
template
<
typename
TRequestParams
=
Davix
::
RequestParams
>
static
void
awsAlternate
(...)
{
Warning
(
"awsAlternate"
,
"Unable to set AWS path-based bucket option (s3alternate), not supported by this version of davix"
);
}
void
TDavixFileInternal
::
setAwsRegion
(
const
std
::
string
&
region
)
{
if
(
!
region
.
empty
())
{
awsRegion
(
davixParam
,
region
.
c_str
());
...
...
@@ -333,6 +357,11 @@ void TDavixFileInternal::setAwsToken(const std::string & token) {
}
}
void
TDavixFileInternal
::
setAwsAlternate
(
const
bool
&
option
)
{
awsAlternate
(
davixParam
,
option
);
}
void
TDavixFileInternal
::
setS3Auth
(
const
std
::
string
&
secret
,
const
std
::
string
&
access
,
const
std
::
string
&
region
,
const
std
::
string
&
token
)
{
...
...
@@ -382,6 +411,10 @@ void TDavixFileInternal::parseConfig()
if
(
(
env_var
=
gEnv
->
GetValue
(
"Davix.S3.Token"
,
getenv
(
"S3_TOKEN"
)))
!=
NULL
)
{
setAwsToken
(
env_var
);
}
// need to set aws alternate?
if
(
(
env_var
=
gEnv
->
GetValue
(
"Davix.S3.Alternate"
,
getenv
(
"S3_ALTERNATE"
)))
!=
NULL
)
{
setAwsAlternate
(
strToBool
(
env_var
,
false
));
}
}
env_var
=
gEnv
->
GetValue
(
"Davix.GSI.GridMode"
,
(
const
char
*
)
"y"
);
...
...
@@ -429,6 +462,10 @@ void TDavixFileInternal::parseParams(Option_t *option)
if
(
strncasecmp
(
it
->
c_str
(),
s3_token_opt
,
strlen
(
s3_token_opt
))
==
0
)
{
s3token
=
std
::
string
(
it
->
c_str
()
+
strlen
(
s3_token_opt
));
}
// s3 alternate option
if
(
strncasecmp
(
it
->
c_str
(),
s3_alternate_opt
,
strlen
(
s3_alternate_opt
))
==
0
)
{
setAwsAlternate
(
strToBool
(
it
->
c_str
()
+
strlen
(
s3_alternate_opt
),
false
));
}
// open mods
oflags
=
configure_open_flag
(
*
it
,
oflags
);
}
...
...
This diff is collapsed.
Click to expand it.
net/davix/src/TDavixFileInternal.h
+
1
−
0
View file @
01ccc3f1
...
...
@@ -100,6 +100,7 @@ private:
void
setAwsRegion
(
const
std
::
string
&
region
);
void
setAwsToken
(
const
std
::
string
&
token
);
void
setAwsAlternate
(
const
bool
&
option
);
void
setS3Auth
(
const
std
::
string
&
secret
,
const
std
::
string
&
access
,
const
std
::
string
&
region
,
const
std
::
string
&
token
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment