[filesystem] add code to check group id using setgroups() 37/75937/1
authorHyunjin Park <hj.na.park@samsung.com>
Wed, 22 Jun 2016 07:21:32 +0000 (16:21 +0900)
committerHyunjin Park <hj.na.park@samsung.com>
Wed, 22 Jun 2016 07:21:32 +0000 (16:21 +0900)
problem : 216 fail issues on Web TCT
cause : permission of content directory is set by setgroups() to priv_mediastorage

TCT result : 100% pass rate

Change-Id: I0d8fbea0ac90fe9e259f2703ff7f63cebf9f8a3c

src/filesystem/filesystem_stat.cc

index 41d0693..f90b37d 100755 (executable)
@@ -77,6 +77,11 @@ FilesystemStat FilesystemStat::getStat(const std::string& path) {
 
   _result.path = path;
   _result.readOnly = true;
+
+  const int GROUPBUF_SIZE = 100;
+  gid_t groupbuf[GROUPBUF_SIZE];
+  int n_groups = getgroups(GROUPBUF_SIZE, groupbuf);
+
   if (getuid() == aStatObj.st_uid && (aStatObj.st_mode & S_IWUSR) == S_IWUSR) {
     _result.readOnly = false;
   } else if (getgid() == aStatObj.st_gid &&
@@ -84,6 +89,13 @@ FilesystemStat FilesystemStat::getStat(const std::string& path) {
     _result.readOnly = false;
   } else if ((aStatObj.st_mode & S_IWOTH) == S_IWOTH) {
     _result.readOnly = false;
+  } else if (n_groups > 0) {
+    for(int i=0; i<n_groups; i++)
+    {
+      if(groupbuf[i] == aStatObj.st_gid && (aStatObj.st_mode & S_IWGRP) == S_IWGRP) {
+        _result.readOnly = false;
+      }
+    }
   }
 
   _result.isDirectory = S_ISDIR(aStatObj.st_mode);