X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=blobdiff_plain;f=etc%2Fafpd%2Funix.c;h=d068c0b3c2711caa45d579df36180a53fc12802a;hp=cc10d97ba02dbf39e58118eed7b6a4bba75503ec;hb=b362b6f7b22b6e4e9e74760989f389149677917b;hpb=c267400f7b0ea332a2e8656205cf6e90fee22a6f diff --git a/etc/afpd/unix.c b/etc/afpd/unix.c index cc10d97b..d068c0b3 100644 --- a/etc/afpd/unix.c +++ b/etc/afpd/unix.c @@ -175,7 +175,7 @@ void accessmode(const struct vol *vol, char *path, struct maccess *ma, struct di ma->ma_user = ma->ma_owner = ma->ma_world = ma->ma_group = 0; if (!st) { - if (lstat(path, &sb) != 0) + if (ostat(path, &sb, vol_syml_opt(vol)) != 0) return; st = &sb; } @@ -234,6 +234,7 @@ mode_t mtoumode(struct maccess *ma) #define EXEC_MODE (S_IXGRP | S_IXUSR | S_IXOTH) +/* Using chmod_acl() instead of ochmod is ok here */ int setdeskmode(const mode_t mode) { char wd[ MAXPATHLEN + 1]; @@ -277,7 +278,7 @@ int setdeskmode(const mode_t mode) *m = '\0'; strcat( modbuf, subp->d_name ); /* XXX: need to preserve special modes */ - if (lstat(modbuf, &st) < 0) { + if (stat(modbuf, &st) < 0) { LOG(log_error, logtype_afpd, "setdeskmode: stat %s: %s",fullpathname(modbuf), strerror(errno) ); continue; } @@ -313,7 +314,7 @@ int setdeskmode(const mode_t mode) int setfilunixmode (const struct vol *vol, struct path* path, mode_t mode) { if (!path->st_valid) { - of_stat(path); + of_stat(vol, path); } if (path->st_errno) { @@ -322,7 +323,7 @@ int setfilunixmode (const struct vol *vol, struct path* path, mode_t mode) mode |= vol->v_fperm; - if (setfilmode( path->u_name, mode, &path->st, vol->v_umask) < 0) + if (setfilmode(vol, path->u_name, mode, &path->st) < 0) return -1; /* we need to set write perm if read set for resource fork */ return vol->vfs->vfs_setfilmode(vol, path->u_name, mode, &path->st); @@ -384,7 +385,7 @@ int setdirmode(const struct vol *vol, const char *name, mode_t mode) if ( *dirp->d_name == '.' && (!osx || dirp->d_name[1] != '_')) { continue; } - if ( lstat( dirp->d_name, &st ) < 0 ) { + if (ostat(dirp->d_name, &st, vol_syml_opt(vol)) < 0 ) { LOG(log_error, logtype_afpd, "setdirmode: stat %s: %s",dirp->d_name, strerror(errno) ); continue; } @@ -392,7 +393,7 @@ int setdirmode(const struct vol *vol, const char *name, mode_t mode) if (!S_ISDIR(st.st_mode)) { int setmode = (osx && *dirp->d_name == '.')?hf_mode:mode; - if (setfilmode(dirp->d_name, setmode, &st, vol->v_umask) < 0) { + if (setfilmode(vol, dirp->d_name, setmode, &st) < 0) { closedir( dir ); LOG(log_error, logtype_afpd, "setdirmode: chmod %s: %s",dirp->d_name, strerror(errno) ); return -1; @@ -479,14 +480,14 @@ int setfilowner(const struct vol *vol, const uid_t uid, const gid_t gid, struct { if (!path->st_valid) { - of_stat(path); + of_stat(vol, path); } if (path->st_errno) { return -1; } - if ( lchown( path->u_name, uid, gid ) < 0 && errno != EPERM ) { + if (ochown( path->u_name, uid, gid, vol_syml_opt(vol)) < 0 && errno != EPERM ) { LOG(log_debug, logtype_afpd, "setfilowner: chown %d/%d %s: %s", uid, gid, path->u_name, strerror(errno) ); return -1; @@ -520,13 +521,13 @@ int setdirowner(const struct vol *vol, const char *name, const uid_t uid, const if ( *dirp->d_name == '.' && (!osx || dirp->d_name[1] != '_')) { continue; } - if ( lstat( dirp->d_name, &st ) < 0 ) { + if (ostat(dirp->d_name, &st, vol_syml_opt(vol)) < 0 ) { LOG(log_error, logtype_afpd, "setdirowner: stat %s: %s", fullpathname(dirp->d_name), strerror(errno) ); continue; } if (( st.st_mode & S_IFMT ) == S_IFREG ) { - if ( lchown( dirp->d_name, uid, gid ) < 0 && errno != EPERM ) { + if (ochown(dirp->d_name, uid, gid, vol_syml_opt(vol)) < 0 && errno != EPERM ) { LOG(log_debug, logtype_afpd, "setdirowner: chown %s: %s", fullpathname(dirp->d_name), strerror(errno) ); /* return ( -1 ); Sometimes this is okay */ @@ -539,10 +540,10 @@ int setdirowner(const struct vol *vol, const char *name, const uid_t uid, const return -1; } - if ( lstat( ".", &st ) < 0 ) { + if (ostat(".", &st, vol_syml_opt(vol)) < 0 ) { return( -1 ); } - if ( gid && gid != st.st_gid && lchown( ".", uid, gid ) < 0 && errno != EPERM ) { + if ( gid && gid != st.st_gid && ochown(".", uid, gid, vol_syml_opt(vol)) < 0 && errno != EPERM ) { LOG(log_debug, logtype_afpd, "setdirowner: chown %d/%d %s: %s", uid, gid, fullpathname("."), strerror(errno) ); } @@ -566,7 +567,7 @@ static int recursive_chown(const char *path, uid_t uid, gid_t gid) { return -1; } - if (lstat(path, &sbuf) < 0) { + if (stat(path, &sbuf) < 0) { LOG(log_error, logtype_afpd, "cannot chown() file [%s] (uid = %d): %s", path, uid, strerror(errno)); return -1; }