Merge pull request #894 from gaul/default-mode

Default uid/gid/mode when object lacks permissions
This commit is contained in:
Takeshi Nakatani 2019-01-16 18:48:54 +09:00 committed by GitHub
commit 25b49e1a2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -802,11 +802,13 @@ mode_t get_mode(headers_t& meta, const char* path, bool checkdir, bool forcedir)
if(meta.end() != (iter = meta.find("x-amz-meta-mode"))){ if(meta.end() != (iter = meta.find("x-amz-meta-mode"))){
mode = get_mode((*iter).second.c_str()); mode = get_mode((*iter).second.c_str());
}else if(meta.end() != (iter = meta.find("x-amz-meta-permissions"))){ // for s3sync
mode = get_mode((*iter).second.c_str());
isS3sync = true;
}else{ }else{
if(meta.end() != (iter = meta.find("x-amz-meta-permissions"))){ // for s3sync // If another tool creates an object without permissions, default to owner
mode = get_mode((*iter).second.c_str()); // read-write and group readable.
isS3sync = true; mode = path[strlen(path) - 1] == '/' ? 0750 : 0640;
}
} }
// Checking the bitmask, if the last 3 bits are all zero then process as a regular // Checking the bitmask, if the last 3 bits are all zero then process as a regular
// file type (S_IFDIR or S_IFREG), otherwise return mode unmodified so that S_IFIFO, // file type (S_IFDIR or S_IFREG), otherwise return mode unmodified so that S_IFIFO,
@ -876,12 +878,13 @@ uid_t get_uid(const char *s)
uid_t get_uid(headers_t& meta) uid_t get_uid(headers_t& meta)
{ {
headers_t::const_iterator iter; headers_t::const_iterator iter;
if(meta.end() == (iter = meta.find("x-amz-meta-uid"))){ if(meta.end() != (iter = meta.find("x-amz-meta-uid"))){
if(meta.end() == (iter = meta.find("x-amz-meta-owner"))){ // for s3sync return get_uid((*iter).second.c_str());
return 0; }else if(meta.end() != (iter = meta.find("x-amz-meta-owner"))){ // for s3sync
} return get_uid((*iter).second.c_str());
}else{
return geteuid();
} }
return get_uid((*iter).second.c_str());
} }
gid_t get_gid(const char *s) gid_t get_gid(const char *s)
@ -892,12 +895,13 @@ gid_t get_gid(const char *s)
gid_t get_gid(headers_t& meta) gid_t get_gid(headers_t& meta)
{ {
headers_t::const_iterator iter; headers_t::const_iterator iter;
if(meta.end() == (iter = meta.find("x-amz-meta-gid"))){ if(meta.end() != (iter = meta.find("x-amz-meta-gid"))){
if(meta.end() == (iter = meta.find("x-amz-meta-group"))){ // for s3sync return get_gid((*iter).second.c_str());
return 0; }else if(meta.end() != (iter = meta.find("x-amz-meta-group"))){ // for s3sync
} return get_gid((*iter).second.c_str());
}else{
return getegid();
} }
return get_gid((*iter).second.c_str());
} }
blkcnt_t get_blocks(off_t size) blkcnt_t get_blocks(off_t size)