]> arthur.barton.de Git - netatalk.git/commitdiff
VFS EA: chown
authorfranklahm <franklahm>
Thu, 15 Oct 2009 15:00:55 +0000 (15:00 +0000)
committerfranklahm <franklahm>
Thu, 15 Oct 2009 15:00:55 +0000 (15:00 +0000)
include/atalk/ea.h
libatalk/vfs/ea.c
libatalk/vfs/vfs.c

index c2add23b7100cbf564cc65745896dca170e31542..c590a3d15fdac70175f2b8ec6954d7e3b9c869c7 100644 (file)
@@ -1,5 +1,5 @@
 /*
-   $Id: ea.h,v 1.3 2009-10-15 12:06:07 franklahm Exp $
+   $Id: ea.h,v 1.4 2009-10-15 15:00:55 franklahm Exp $
    Copyright (c) 2009 Frank Lahm <franklahm@gmail.com>
 
    This program is free software; you can redistribute it and/or modify
@@ -126,6 +126,7 @@ extern int remove_ea(VFS_FUNC_ARGS_EA_REMOVE);
 extern int ea_deletefile(VFS_FUNC_ARGS_DELETEFILE);
 extern int ea_renamefile(VFS_FUNC_ARGS_RENAMEFILE);
 extern int ea_copyfile(VFS_FUNC_ARGS_COPYFILE);
+extern int ea_chown(VFS_FUNC_ARGS_CHOWN);
 
 /* Solaris native EAs */
 #ifdef HAVE_SOLARIS_EAS
index 44188c0a8858dca4e88159e4234a696cd3ec8d35..304c794fd835938897c675b9148cdd85e1ed44ad 100644 (file)
@@ -1,5 +1,5 @@
 /*
-  $Id: ea.c,v 1.4 2009-10-15 12:06:07 franklahm Exp $
+  $Id: ea.c,v 1.5 2009-10-15 15:00:55 franklahm Exp $
   Copyright (c) 2009 Frank Lahm <franklahm@gmail.com>
 
   This program is free software; you can redistribute it and/or modify
@@ -1743,3 +1743,61 @@ exit:
     ea_close(&dstea);
        return ret;
 }
+
+int ea_chown(VFS_FUNC_ARGS_CHOWN)
+{
+    LOG(log_debug, logtype_afpd, "ea_chown('%s')", path);
+
+    int count = 0, ret = AFP_OK;
+    char *eaname;
+    struct ea ea;
+
+    /* Open EA stuff */
+    if ((ea_open(vol, path, EA_RDWR, &ea)) != 0) {
+        if (errno == ENOENT)
+            /* no EA files, nothing to do */
+            return AFP_OK;
+        else {
+            LOG(log_error, logtype_afpd, "ea_chown('%s'): error calling ea_open", path);
+            return AFPERR_MISC;
+        }
+    }
+
+    if ((chown(ea_path(&ea, NULL), uid, gid)) != 0) {
+        switch (errno) {
+        case EPERM:
+        case EACCES:
+            ret = AFPERR_ACCESS;
+            goto exit;
+        default:
+            ret = AFPERR_MISC;
+            goto exit;
+        }
+    }
+
+    while (count < ea.ea_count) {
+        eaname = ea_path(&ea, (*ea.ea_entries)[count].ea_name);
+        if ((chown(eaname, uid, gid)) != 0) {
+            switch (errno) {
+            case EPERM:
+            case EACCES:
+                ret = AFPERR_ACCESS;
+                goto exit;
+            default:
+                ret = AFPERR_MISC;
+                goto exit;
+            }
+            continue;
+        }
+
+        count++;
+    }
+
+exit:
+    if ((ea_close(&ea)) != 0) {
+        LOG(log_error, logtype_afpd, "ea_chown('%s'): error closing ea handle", path);
+        return AFPERR_MISC;
+    }
+
+    return ret;
+}
index 81ececd3dab38943021fcc1ece4da84e83c2461b..2f45b5c3ec8ff65e15844b0d85cb1e6d99197cb3 100644 (file)
@@ -908,25 +908,25 @@ static struct vfs_ops netatalk_adouble_sfm = {
  */
 
 struct vfs_ops netatalk_ea_adouble = {
-    /* ad_path:           */ NULL,
-    /* validupath:        */ NULL,
-    /* rf_chown:          */ NULL,
-    /* rf_renamedir:      */ NULL,
-    /* rf_deletecurdir:   */ NULL,
-    /* rf_setfilmode:     */ NULL,
-    /* rf_setdirmode:     */ NULL,
-    /* rf_setdirunixmode: */ NULL,
-    /* rf_setdirowner:    */ NULL,
-    /* rf_deletefile:     */ ea_deletefile,
-    /* rf_renamefile:     */ ea_renamefile,
+    /* vfs_path:          */ NULL,
+    /* vfs_validupath:    */ NULL,
+    /* vfs_chown:         */ ea_chown,
+    /* vfs_renamedir:     */ NULL, /* ok */
+    /* vfs_deletecurdir:  */ NULL, /* ok */
+    /* vfs_setfilmode:    */ NULL,
+    /* vfs_setdirmode:    */ NULL,
+    /* vfs_setdirunixmode:*/ NULL,
+    /* vfs_setdirowner:   */ NULL,
+    /* vfs_deletefile:    */ ea_deletefile,
+    /* vfs_renamefile:    */ ea_renamefile,
     /* vfs_copyfile       */ ea_copyfile,
-    /* rf_acl:            */ NULL,
-    /* rf_remove_acl      */ NULL,
-    /* ea_getsize         */ get_easize,
-    /* ea_getcontent      */ get_eacontent,
-    /* ea_list            */ list_eas,
-    /* ea_set             */ set_ea,
-    /* ea_remove          */ remove_ea
+    /* vfs_acl:           */ NULL,
+    /* vfs_remove_acl     */ NULL,
+    /* vfs_getsize        */ get_easize,
+    /* vfs_getcontent     */ get_eacontent,
+    /* vfs_list           */ list_eas,
+    /* vfs_set            */ set_ea,
+    /* vfs_remove         */ remove_ea
 };
 
 #ifdef HAVE_SOLARIS_EAS