[Fakeroot-commits] [SCM] fakeroot branch, upstream, updated. debian/1.14.3-200-gb232f8a

Clint Adams schizo at debian.org
Tue Aug 23 13:06:01 UTC 2011


The following commit has been merged in the upstream branch:
commit 59e14cb91237f7aeb154ef83f1b6e354ea010c73
Author: Clint Adams <schizo at debian.org>
Date:   Tue Oct 30 16:45:23 2007 +0000

    Apply patch from Andrew Benham to add fake_get_owner() function as part of undocumented API.
    
    git-archimport-id: fakeroot at packages.debian.org--fakeroot/fakeroot--main--0.0--patch-137

diff --git a/communicate.c b/communicate.c
index cbccb23..d0766e5 100644
--- a/communicate.c
+++ b/communicate.c
@@ -381,7 +381,7 @@ void stat32from64(struct stat *s32, const struct stat64 *s64)
 void semaphore_up(){
   struct sembuf op;
   if(sem_id==-1)
-    sem_id=semget(get_ipc_key()+2,1,IPC_CREAT|0600);
+    sem_id=semget(get_ipc_key(0)+2,1,IPC_CREAT|0600);
   op.sem_num=0;
   op.sem_op=-1;
   op.sem_flg=SEM_UNDO;
@@ -401,7 +401,7 @@ void semaphore_up(){
 void semaphore_down(){
   struct sembuf op;
   if(sem_id==-1)
-    sem_id=semget(get_ipc_key()+2,1,IPC_CREAT|0600);
+    sem_id=semget(get_ipc_key(0)+2,1,IPC_CREAT|0600);
   op.sem_num=0;
   op.sem_op=1;
   op.sem_flg=SEM_UNDO;
@@ -766,13 +766,15 @@ void send_get_stat64(struct stat64 *st
 
 #ifndef FAKEROOT_FAKENET
 
-key_t get_ipc_key()
+key_t get_ipc_key(key_t new_key)
 {
   const char *s;
   static key_t key=-1;
 
   if(key==-1){
-    if((s=env_var_set(FAKEROOTKEY_ENV)))
+    if(new_key!=0)
+      key=new_key;
+    else if((s=env_var_set(FAKEROOTKEY_ENV)))
       key=atoi(s);
     else
       key=0;
@@ -791,10 +793,10 @@ int init_get_msg(){
   key_t key;
 
   if((!done)&&(msg_get==-1)){
-    key=get_ipc_key();
+    key=get_ipc_key(0);
     if(key){
-      msg_snd=msgget(get_ipc_key(),IPC_CREAT|00600);
-      msg_get=msgget(get_ipc_key()+1,IPC_CREAT|00600);
+      msg_snd=msgget(get_ipc_key(0),IPC_CREAT|00600);
+      msg_get=msgget(get_ipc_key(0)+1,IPC_CREAT|00600);
     }
     else{
       msg_get=-1;
@@ -805,4 +807,30 @@ int init_get_msg(){
   return msg_snd;
 }
 
+int fake_get_owner(int is_lstat, const char *key, const char *path,
+                  uid_t *uid, gid_t *gid){
+  struct stat st;
+  int i;
+
+  if (!key || !strlen(key))
+    return 0;
+
+  /* Do the stat or lstat */
+  i = (is_lstat ? lstat(path, &st) : stat(path, &st));
+  if (i < 0)
+    return i;
+
+  /* Now give pass it to faked */
+  get_ipc_key(atoi(key));
+  send_get_stat(&st);
+
+  /* Now return the values inside the pointers */
+  if (uid)
+    *uid = st.st_uid;
+  if (gid)
+    *gid = st.st_gid;
+
+  return 0;
+}
+
 #endif /* ! FAKEROOT_FAKENET */
diff --git a/communicate.h b/communicate.h
index 6583cc9..c21d295 100644
--- a/communicate.h
+++ b/communicate.h
@@ -138,7 +138,7 @@ extern void cpystatfakem(struct     stat *st, const struct fake_msg *buf, int ve
 
 #ifndef FAKEROOT_FAKENET
 extern int init_get_msg();
-extern key_t get_ipc_key();
+extern key_t get_ipc_key(key_t new_key);
 # ifndef STUPID_ALPHA_HACK
 extern void cpyfakemstat(struct fake_msg *b1, const struct stat *st);
 # else
diff --git a/debian/changelog b/debian/changelog
index 579f4b7..13b3660 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -4,6 +4,8 @@ fakeroot (1.8.3) unstable; urgency=low
     tr.  closes: #448631.
   * Apply patch from Andrew Benham to handle building with a C
     compiler other than GCC.  closes: #448631.
+  * Apply patch from Andrew Benham to add fake_get_owner() function
+    as part of undocumented API.
 
  -- Clint Adams <schizo at debian.org>  Tue, 30 Oct 2007 12:39:09 -0400
 

-- 
fakeroot



More information about the Fakeroot-commits mailing list