]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
--fix_client_id 1/default off toggles a fixed group for all clients and
authoranwleung <anwleung@29311d96-e01e-0410-9327-a35deaab8ce9>
Sat, 10 Mar 2007 02:01:06 +0000 (02:01 +0000)
committeranwleung <anwleung@29311d96-e01e-0410-9327-a35deaab8ce9>
Sat, 10 Mar 2007 02:01:06 +0000 (02:01 +0000)
uid based on clientid

git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1195 29311d96-e01e-0410-9327-a35deaab8ce9

branches/aleung/security1/ceph/.groups
branches/aleung/security1/ceph/client/Client.cc
branches/aleung/security1/ceph/config.cc
branches/aleung/security1/ceph/config.h

index 791840b5c2061ec0570f1cb268df00d19feed937..7a2adef402e18676f74a45efd3eba6c669e60982 100644 (file)
@@ -1,2 +1,3 @@
 1000 1000 3500 -1
-1500 384 555 -1
\ No newline at end of file
+1500 384 555 -1
+1020 340 3401 3402 3403 3404 3405 3406 -1
\ No newline at end of file
index 610595179b6039d9b4eb778046f1ad3d587e8a1d..547a6ca9191709dc19aab5729342f6abc19ce7d5 100644 (file)
@@ -1310,7 +1310,11 @@ int Client::link(const char *existing, const char *newname,
 
   // fix uid/gid if not supplied
   // get it from the system
-  if (uid == -1 || gid == -1) {
+  if (g_conf.fix_client_id == 1) {
+    uid = 340+whoami;
+    gid = 1020;
+  }
+  else if (uid == -1 || gid == -1) {
     uid = getuid();
     gid = getgid();
   }
@@ -1362,7 +1366,11 @@ int Client::unlink(const char *relpath, __int64_t uid, __int64_t gid)
 
   // fix uid/gid if not supplied                                                
   // get it from the system                                                     
-  if (uid == -1 || gid == -1) {
+  if (g_conf.fix_client_id == 1) {
+    uid = 340+whoami;
+    gid = 102+whoami;
+  }
+  else if (uid == -1 || gid == -1) {
     uid = getuid();
     gid = getgid();
   }
@@ -1420,8 +1428,12 @@ int Client::rename(const char *relfrom, const char *relto,
   client_lock.Lock();
 
   // fix uid/gid if not supplied                                              
-  // get it from the system                                               
-  if (uid == -1 || gid == -1) {
+  // get it from the system
+  if (g_conf.fix_client_id == 1) {
+    uid = 340+whoami;
+    gid = 1020;
+  }
+  else if (uid == -1 || gid == -1) {
     uid = getuid();
     gid = getgid();
   }
@@ -1477,7 +1489,11 @@ int Client::mkdir(const char *relpath, mode_t mode, __int64_t uid, __int64_t gid
 
   // fix uid/gid if not supplied
   // get it from the system
-  if (uid == -1 || gid == -1) {
+  if (g_conf.fix_client_id == 1) {
+    uid = 340+whoami;
+    gid = 1020;
+  }
+  else if (uid == -1 || gid == -1) {
     uid = getuid();
     gid = getgid();
   }
@@ -1527,7 +1543,11 @@ int Client::rmdir(const char *relpath, __int64_t uid, __int64_t gid)
   
   // fix uid/gid if not supplied                                               
   // get it from the system                                                    
-  if (uid == -1 || gid == -1) {
+  if (g_conf.fix_client_id == 1) {
+    uid = 340+whoami;
+    gid = 1020;
+  }
+  else if (uid == -1 || gid == -1) {
     uid = getuid();
     gid = getgid();
   }
@@ -1589,7 +1609,11 @@ int Client::symlink(const char *reltarget, const char *rellink,
 
   // fix uid/gid if not supplied                                               
   // get it from the system                                                    
-  if (uid == -1 || gid == -1) {
+  if (g_conf.fix_client_id == 1) {
+    uid = 340+whoami;
+    gid = 1020;
+  }
+  else if (uid == -1 || gid == -1) {
     uid = getuid();
     gid = getgid();
   }
@@ -1643,7 +1667,11 @@ int Client::readlink(const char *relpath, char *buf, off_t size,
 
   // fix uid/gid if not supplied                                               
   // get it from the system                                                    
-  if (uid == -1 || gid == -1) {
+  if (g_conf.fix_client_id == 1) {
+    uid = 340+whoami;
+    gid = 1020;
+  }
+  else if (uid == -1 || gid == -1) {
     uid = getuid();
     gid = getgid();
   }
@@ -1701,7 +1729,11 @@ int Client::_lstat(const char *path, int mask, Inode **in,
 
   // fix uid/gid if not supplied                                               
   // get it from the system                                                    
-  if (uid == -1 || gid == -1) {
+  if (g_conf.fix_client_id == 1) {
+    uid = 340+whoami;
+    gid = 1020;
+  }
+  else if (uid == -1 || gid == -1) {
     uid = getuid();
     gid = getgid();
   }
@@ -1807,7 +1839,11 @@ int Client::lstat(const char *relpath, struct stat *stbuf,
 
   // fix uid/gid if not supplied                                               
   // get it from the system                                                    
-  if (uid == -1 || gid == -1) {
+  if (g_conf.fix_client_id == 1) {
+    uid = 340+whoami;
+    gid = 1020;
+  }
+  else if (uid == -1 || gid == -1) {
     uid = getuid();
     gid = getgid();
   }
@@ -1850,7 +1886,11 @@ int Client::lstatlite(const char *relpath, struct statlite *stl,
    
   // fix uid/gid if not supplied                                               
   // get it from the system                                                    
-  if (uid == -1 || gid == -1) {
+  if (g_conf.fix_client_id == 1) {
+    uid = 340+whoami;
+    gid = 1020;
+  }
+  else if (uid == -1 || gid == -1) {
     uid = getuid();
     gid = getgid();
   }
@@ -1900,7 +1940,11 @@ int Client::chmod(const char *relpath, mode_t mode,
 
   // fix uid/gid if not supplied
   // get it from the system
-  if (uid == -1 || gid == -1) {
+  if (g_conf.fix_client_id == 1) {
+    uid = 340+whoami;
+    gid = 1020;
+  }
+  else if (uid == -1 || gid == -1) {
     uid = getuid();
     gid = getgid();
   }
@@ -1950,7 +1994,11 @@ int Client::chown(const char *relpath, __int64_t uid, __int64_t gid)
 
   // fix uid/gid if not supplied                                               
   // get it from the system                                                    
-  if (uid == -1 || gid == -1) {
+  if (g_conf.fix_client_id == 1) {
+    uid = 340+whoami;
+    gid = 1020;
+  }
+  else if (uid == -1 || gid == -1) {
     uid = getuid();
     gid = getgid();
   }
@@ -2003,7 +2051,11 @@ int Client::utime(const char *relpath, struct utimbuf *buf,
 
   // fix uid/gid if not supplied                                               
   // get it from the system                                                    
-  if (uid == -1 || gid == -1) {
+  if (g_conf.fix_client_id == 1) {
+    uid = 340+whoami;
+    gid = 1020;
+  }
+  else if (uid == -1 || gid == -1) {
     uid = getuid();
     gid = getgid();
   }
@@ -2060,7 +2112,11 @@ int Client::mknod(const char *relpath, mode_t mode,
 
   // fix uid/gid if not supplied                                               
   // get it from the system                                                    
-  if (uid == -1 || gid == -1) {
+  if (g_conf.fix_client_id == 1) {
+    uid = 340+whoami;
+    gid = 1020;
+  }
+  else if (uid == -1 || gid == -1) {
     uid = getuid();
     gid = getgid();
   }
@@ -2123,7 +2179,11 @@ int Client::getdir(const char *relpath, map<string,inode_t>& contents,
 
   // fix uid/gid if not supplied                                               
   // get it from the system                                                    
-  if (uid == -1 || gid == -1) {
+  if (g_conf.fix_client_id == 1) {
+    uid = 340+whoami;
+    gid = 1020;
+  }
+  else if (uid == -1 || gid == -1) {
     uid = getuid();
     gid = getgid();
   }
@@ -2408,7 +2468,11 @@ int Client::open(const char *relpath, int flags, __int64_t uid, __int64_t gid)
 
   // fix uid/gid if not supplied                                   
   // get it from the system                                                    
-  if (uid == -1 || gid == -1) {
+  if (g_conf.fix_client_id == 1) {
+    uid = 340+whoami;
+    gid = 1020;
+  }
+  else if (uid == -1 || gid == -1) {
     uid = getuid();
     gid = getgid();
   }
@@ -2581,7 +2645,11 @@ int Client::close(fh_t fh, __int64_t uid, __int64_t gid)
 
   // fix uid/gid if not supplied                                            
   // get it from the system                                                
-  if (uid == -1 || gid == -1) {
+  if (g_conf.fix_client_id == 1) {
+    uid = 340+whoami;
+    gid = 1020;
+  }
+  else if (uid == -1 || gid == -1) {
     uid = getuid();
     gid = getgid();
   }
@@ -2671,7 +2739,11 @@ int Client::read(fh_t fh, char *buf, off_t size, off_t offset,
 
   // fix uid/gid if not supplied                                               
   // get it from the system                                                    
-  if (uid == -1 || gid == -1) {
+  if (g_conf.fix_client_id == 1) {
+    uid = 340+whoami;
+    gid = 1020;
+  }
+  else if (uid == -1 || gid == -1) {
     uid = getuid();
     gid = getgid();
   }
@@ -2814,7 +2886,11 @@ int Client::write(fh_t fh, const char *buf, off_t size, off_t offset,
 
   // fix uid/gid if not supplied                                             
   // get it from the system                                               
-  if (uid == -1 || gid == -1) {
+  if (g_conf.fix_client_id == 1) {
+    uid = 340+whoami;
+    gid = 1020;
+  }
+  else if (uid == -1 || gid == -1) {
     uid = getuid();
     gid = getgid();
   }
@@ -2951,7 +3027,11 @@ int Client::truncate(const char *file, off_t size, __int64_t uid, __int64_t gid)
 
   // fix uid/gid if not supplied                                               
   // get it from the system                                                    
-  if (uid == -1 || gid == -1) {
+  if (g_conf.fix_client_id == 1) {
+    uid = 340+whoami;
+    gid = 1020;
+  }
+  else if (uid == -1 || gid == -1) {
     uid = getuid();
     gid = getgid();
   }
@@ -2996,7 +3076,11 @@ int Client::fsync(fh_t fh, bool syncdataonly, __int64_t uid, __int64_t gid)
 
   // fix uid/gid if not supplied                                               
   // get it from the system                                                    
-  if (uid == -1 || gid == -1) {
+  if (g_conf.fix_client_id == 1) {
+    uid = 340+whoami;
+    gid = 1020;
+  }
+  else if (uid == -1 || gid == -1) {
     uid = getuid();
     gid = getgid();
   }
@@ -3079,7 +3163,11 @@ int Client::lazyio_propogate(int fd, off_t offset, size_t count,
 
   // fix uid/gid if not supplied                                               
   // get it from the system                                                    
-  if (uid == -1 || gid == -1) {
+  if (g_conf.fix_client_id == 1) {
+    uid = 340+whoami;
+    gid = 1020;
+  }
+  else if (uid == -1 || gid == -1) {
     uid = getuid();
     gid = getgid();
   }
@@ -3132,7 +3220,11 @@ int Client::lazyio_synchronize(int fd, off_t offset, size_t count,
 
   // fix uid/gid if not supplied                                               
   // get it from the system                                                    
-  if (uid == -1 || gid == -1) {
+  if (g_conf.fix_client_id == 1) {
+    uid = 340+whoami;
+    gid = 1020;
+  }
+  else if (uid == -1 || gid == -1) {
     uid = getuid();
     gid = getgid();
   }
index e768439687f532dd940f9389d7fb7a26c1d1059c..dc941a13b42501d279dd5ca0f8ed83de6801bf26 100644 (file)
@@ -305,7 +305,8 @@ md_config_t g_conf = {
   secure_io:              1, /* 0=off, 1=on */
   mds_group:              0, /* 0=none, 1=unix, 2=batch, 3=def, 4=predict */
   mds_collection:         0, /* 0=none, 1=unix, 3=def */
-  unix_group_file:       0,
+  unix_group_file:        0, /* 0=no file, non-zero = filename ptr */
+  fix_client_id:          0, /* 0=off, 1=on */
   client_aux:             0, /* 0=off, 1=on */
   sign_scheme:            0, /* 0=esign, 1=RSA */
   hash_scheme:            0, /* 0=sha-1, 1=sha-256,
@@ -789,6 +790,8 @@ void parse_config_options(std::vector<char*>& args)
       g_conf.client_aux = atoi(args[++i]);
     else if (strcmp(args[i], "--unix_group_file") == 0)
       g_conf.unix_group_file = args[++i];
+    else if (strcmp(args[i], "--fix_client_id") == 0)
+      g_conf.fix_client_id = atoi(args[++i]);
 
     else if (strcmp(args[i], "--file_layout_ssize") == 0) 
       g_OSD_FileLayout.stripe_size = atoi(args[++i]);
index e17998180bab993a8d4361fae38f5381848f89df..3056590d889110225957f5dd095188fe0ca43c85 100644 (file)
@@ -296,6 +296,7 @@ struct md_config_t {
   int mds_group;
   int mds_collection;
   char *unix_group_file;
+  int fix_client_id;
   int client_aux;
   int sign_scheme;
   int hash_scheme;