]> arthur.barton.de Git - netatalk.git/blobdiff - libatalk/vfs/ea.c
Force conversion of EA names
[netatalk.git] / libatalk / vfs / ea.c
index d6e7d87e08aefe8c624bc35ea4fbc52b56820ee4..7b9cb9a7fa46171d4de0ce9ed82e1f6f1a68efeb 100644 (file)
@@ -1,5 +1,5 @@
 /*
-  $Id: ea.c,v 1.10 2009-10-23 14:09:51 franklahm Exp $
+  $Id: ea.c,v 1.14 2009-10-29 19:20:28 franklahm Exp $
   Copyright (c) 2009 Frank Lahm <franklahm@gmail.com>
 
   This program is free software; you can redistribute it and/or modify
@@ -78,7 +78,7 @@ static char *mtoupath(const struct vol *vol, const char *mpath)
     char         *u;
     size_t       inplen;
     size_t       outlen;
-    uint16_t     flags = CONV_ESCAPEHEX;
+    uint16_t     flags = CONV_ESCAPEHEX | CONV_FORCE;
 
     if (!mpath)
         return NULL;
@@ -300,7 +300,7 @@ static char * ea_path(const struct ea * restrict ea,
     static char pathbuf[MAXPATHLEN + 1];
 
     /* get name of a adouble file from uname */
-    adname = ea->vol->vfs->ad_path(ea->filename, (ea->ea_flags & EA_DIR) ? ADFLAGS_DIR : 0);
+    adname = ea->vol->ad_path(ea->filename, (ea->ea_flags & EA_DIR) ? ADFLAGS_DIR : 0);
     /* copy it so we can work with it */
     strlcpy(pathbuf, adname, MAXPATHLEN + 1);
     /* append "::EA" */
@@ -654,9 +654,8 @@ static int ea_open(const struct vol * restrict vol,
 
     ea->vol = vol;              /* ea_close needs it */
     ea->ea_flags = eaflags;
-    /* Dont check for errors, eg when removing the file is already gone */
-    stat(uname, &st);
-    if (S_ISDIR(st.st_mode))
+    /* Dont care for errors, eg when removing the file is already gone */
+    if (!stat(uname, &st) && S_ISDIR(st.st_mode))
         ea->ea_flags |=  EA_DIR;
 
     if ( ! (ea->filename = strdup(uname))) {
@@ -1572,17 +1571,19 @@ int ea_chmod_dir(VFS_FUNC_ARGS_SETDIRUNIXMODE)
     uid = geteuid();
     if (seteuid(0)) {
         LOG(log_error, logtype_afpd, "ea_chmod_dir('%s'): seteuid: %s", name, strerror(errno));
-        ret = AFPERR_MISC;
-        goto exit;
+        return AFPERR_MISC;
     }
 
     /* Open EA stuff */
     if ((ea_open(vol, name, EA_RDWR, &ea)) != 0) {
-        if (errno == ENOENT)
-            /* no EA files, nothing to do */
-            return AFP_OK;
-        else
-            return AFPERR_MISC;
+        /* ENOENT --> no EA files, nothing to do */
+        if (errno != ENOENT)
+            ret = AFPERR_MISC;
+        if (seteuid(uid) < 0) {
+            LOG(log_error, logtype_afpd, "can't seteuid back: %s", strerror(errno));
+            exit(EXITERR_SYS);
+        }
+        return ret;
     }
 
     /* Set mode on EA header */