X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=etc%2Fafpd%2Ffiledir.c;h=c6bcc34e19181b50f61c9dee6adc91072f79e7f1;hb=b362b6f7b22b6e4e9e74760989f389149677917b;hp=5f6e0f643e5987f101a2068123772eb8a50a21f8;hpb=4054f4b3c85ecab060dafd46c0d3632cadbb5803;p=netatalk.git diff --git a/etc/afpd/filedir.c b/etc/afpd/filedir.c index 5f6e0f64..c6bcc34e 100644 --- a/etc/afpd/filedir.c +++ b/etc/afpd/filedir.c @@ -40,6 +40,7 @@ char *strchr (), *strrchr (); #include #include #include +#include #include #include "directory.h" @@ -48,7 +49,6 @@ char *strchr (), *strrchr (); #include "volume.h" #include "fork.h" #include "file.h" -#include "globals.h" #include "filedir.h" #include "unix.h" @@ -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(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(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 @@ -624,18 +629,22 @@ int afp_delete(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size if (s_path->st_valid && s_path->st_errno == ENOENT) { rc = AFPERR_NOOBJ; } else { - if ((rc = deletefile(vol, -1, upath, 1)) == AFP_OK) + if ((rc = deletefile(vol, -1, upath, 1)) == AFP_OK) { fce_register_delete_file( s_path ); - + if (vol->v_tm_used < s_path->st.st_size) + vol->v_tm_used = 0; + else + vol->v_tm_used -= s_path->st.st_size; + } struct dir *cachedfile; - if ((cachedfile = dircache_search_by_name(vol, dir, upath, strlen(upath), s_path->st.st_ctime))) { + if ((cachedfile = dircache_search_by_name(vol, dir, upath, strlen(upath)))) { dircache_remove(vol, cachedfile, DIRCACHE | DIDNAME_INDEX | QUEUE_INDEX); dir_free(cachedfile); } } } if ( rc == AFP_OK ) { - curdir->offcnt--; + curdir->d_offcnt--; setvoltime(obj, vol ); } @@ -776,8 +785,8 @@ int afp_moveandrename(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U rc = AFPERR_PARAM; goto exit; } - curdir->offcnt++; - sdir->offcnt--; + curdir->d_offcnt++; + sdir->d_offcnt--; #ifdef DROPKLUDGE if (vol->v_flags & AFPVOL_DROPBOX) { /* FIXME did is not always the source id */ @@ -792,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 ); }