]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/filedir.c
Configurable symlink behaviour
[netatalk.git] / etc / afpd / filedir.c
index 6fe3c855b2d32d007432a9623ffa2cb2f0b6f8f8..c6bcc34e19181b50f61c9dee6adc91072f79e7f1 100644 (file)
@@ -94,28 +94,33 @@ int matchfile2dirperms(
         if ( uid != sb.st_uid )
         {
             seteuid(0);
-            if (lchown(upath, sb.st_uid, sb.st_gid) < 0)
+            if (ochown(upath, sb.st_uid, sb.st_gid, vol_syml_opt(vol)) < 0)
             {
                 LOG(log_error, logtype_afpd,
                     "matchfile2dirperms(%s): Error changing owner/gid: %s",
                     upath, strerror(errno));
                 ret = AFPERR_ACCESS;
             }
-            else if ((!S_ISLNK(st->st_mode)) && (chmod_acl(upath,(st.st_mode&~default_options.umask)| S_IRGRP| S_IROTH) < 0))
-            {
+            else if (ochmod(upath,
+                            (st.st_mode & ~default_options.umask) | S_IRGRP | S_IROTH,
+                            &sb,
+                            vol_syml_opt(vol) | O_NETATALK_ACL) < 0) {                         
                 LOG(log_error, logtype_afpd,
                     "matchfile2dirperms(%s): Error adding file read permissions: %s",
                     upath, strerror(errno));
                 ret = AFPERR_ACCESS;
             }
-            else if (lchown(adpath, sb.st_uid, sb.st_gid) < 0)
+            else if (ochown(adpath, sb.st_uid, sb.st_gid, vol_syml_opt(vol)) < 0)
             {
                 LOG(log_error, logtype_afpd,
                     "matchfile2dirperms(%s): Error changing AppleDouble owner/gid: %s",
                     adpath, strerror(errno));
                 ret = AFPERR_ACCESS;
             }
-            else if (chmod_acl(adpath, (st.st_mode&~default_options.umask)| S_IRGRP| S_IROTH) < 0)
+            else if (ochmod(adpath,
+                            (st.st_mode & ~default_options.umask) | S_IRGRP| S_IROTH,
+                            &st,
+                            vol_syml_opt(vol) | O_NETATALK_ACL) < 0)
             {
                 LOG(log_error, logtype_afpd,
                     "matchfile2dirperms(%s):  Error adding AD file read permissions: %s",
@@ -449,7 +454,7 @@ static int moveandrename(const struct vol *vol,
     if ( !isdir ) {
         path.st_valid = 1;
         path.st_errno = errno;
-        if (of_findname(&path)) {
+        if (of_findname(vol, &path)) {
             rc = AFPERR_EXIST; /* was AFPERR_BUSY; */
         } else {
             rc = renamefile(vol, sdir_fd, oldunixname, upath, newname, adp );
@@ -614,7 +619,7 @@ int afp_delete(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size
                 fce_register_delete_dir(cfrombstr(dname));
             bdestroy(dname);
         }
-    } else if (of_findname(s_path)) {
+    } else if (of_findname(vol, s_path)) {
         rc = AFPERR_BUSY;
     } else {
         /* it's a file st_valid should always be true
@@ -796,8 +801,8 @@ int afp_moveandrename(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U
             if (!isdir && !vol_unix_priv(vol)) {
                 int  admode = ad_mode("", 0777) | vol->v_fperm;
 
-                setfilmode(upath, admode, NULL, vol->v_umask);
-                vol->vfs->vfs_setfilmode(vol, upath, admode, NULL);
+                setfilmode(vol, upath, admode, path->st_valid ? &path->st : NULL);
+                vol->vfs->vfs_setfilmode(vol, upath, admode, path->st_valid ? &path->st : NULL);
             }
         setvoltime(obj, vol );
     }