mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-12-23 09:18:55 +00:00
Merge pull request #608 from tlevi/chown_nocopy
Fix chown_nocopy losing existing uid/gid if unspecified
This commit is contained in:
commit
a08880ae15
25
src/s3fs.cpp
25
src/s3fs.cpp
@ -1705,15 +1705,6 @@ static int s3fs_chown(const char* path, uid_t uid, gid_t gid)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct passwd* pwdata= getpwuid(uid);
|
|
||||||
struct group* grdata = getgrgid(gid);
|
|
||||||
if(pwdata){
|
|
||||||
uid = pwdata->pw_uid;
|
|
||||||
}
|
|
||||||
if(grdata){
|
|
||||||
gid = grdata->gr_gid;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(S_ISDIR(stbuf.st_mode) && IS_REPLACEDIR(nDirType)){
|
if(S_ISDIR(stbuf.st_mode) && IS_REPLACEDIR(nDirType)){
|
||||||
// Should rebuild directory object(except new type)
|
// Should rebuild directory object(except new type)
|
||||||
// Need to remove old dir("dir" etc) and make new dir("dir/")
|
// Need to remove old dir("dir" etc) and make new dir("dir/")
|
||||||
@ -1769,6 +1760,13 @@ static int s3fs_chown_nocopy(const char* path, uid_t uid, gid_t gid)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if((uid_t)(-1) == uid){
|
||||||
|
uid = stbuf.st_uid;
|
||||||
|
}
|
||||||
|
if((gid_t)(-1) == gid){
|
||||||
|
gid = stbuf.st_gid;
|
||||||
|
}
|
||||||
|
|
||||||
// Get attributes
|
// Get attributes
|
||||||
if(S_ISDIR(stbuf.st_mode)){
|
if(S_ISDIR(stbuf.st_mode)){
|
||||||
result = chk_dir_object_type(path, newpath, strpath, nowcache, NULL, &nDirType);
|
result = chk_dir_object_type(path, newpath, strpath, nowcache, NULL, &nDirType);
|
||||||
@ -1781,15 +1779,6 @@ static int s3fs_chown_nocopy(const char* path, uid_t uid, gid_t gid)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct passwd* pwdata= getpwuid(uid);
|
|
||||||
struct group* grdata = getgrgid(gid);
|
|
||||||
if(pwdata){
|
|
||||||
uid = pwdata->pw_uid;
|
|
||||||
}
|
|
||||||
if(grdata){
|
|
||||||
gid = grdata->gr_gid;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(S_ISDIR(stbuf.st_mode)){
|
if(S_ISDIR(stbuf.st_mode)){
|
||||||
// Should rebuild all directory object
|
// Should rebuild all directory object
|
||||||
// Need to remove old dir("dir" etc) and make new dir("dir/")
|
// Need to remove old dir("dir" etc) and make new dir("dir/")
|
||||||
|
Loading…
Reference in New Issue
Block a user