a dropbox is a folder where w is set but not r eg:
rwx-wx-wx or rwx-wx--
rwx----wx (is not asked by a Mac with OS >= 8.0 ?)
+ using chmod_acl() instead of ochmod is ok here
*/
int stickydirmode(const char *name, const mode_t mode, const int dropbox, const mode_t v_umask)
{
if ( seteuid(0) < 0) {
LOG(log_error, logtype_afpd, "stickydirmode: unable to seteuid root: %s", strerror(errno));
}
- if ( (retval=chmod( name, ( (DIRBITS | mode | S_ISVTX) & ~v_umask) )) < 0) {
+ if ( (retval=chmod_acl( name, ( (DIRBITS | mode | S_ISVTX) & ~v_umask) )) < 0) {
LOG(log_error, logtype_afpd, "stickydirmode: chmod \"%s\": %s", fullpathname(name), strerror(errno) );
} else {
LOG(log_debug, logtype_afpd, "stickydirmode: chmod \"%s\": %s", fullpathname(name), strerror(retval) );
* Ignore EPERM errors: We may be dealing with a directory that is
* group writable, in which case chmod will fail.
*/
- if ( (chmod( name, (DIRBITS | mode) & ~v_umask ) < 0) && errno != EPERM &&
+ if ( (chmod_acl( name, (DIRBITS | mode) & ~v_umask ) < 0) && errno != EPERM &&
!(errno == ENOENT && (dropbox & AFPVOL_NOADOUBLE)) )
{
LOG(log_error, logtype_afpd, "stickydirmode: chmod \"%s\": %s", fullpathname(name), strerror(errno) );
}
/* --------------------- */
-int setfilmode(const char * name, mode_t mode, struct stat *st, mode_t v_umask)
+int setfilmode(const struct vol *vol, const char *name, mode_t mode, struct stat *st)
{
struct stat sb;
mode_t mask = S_IRWXU | S_IRWXG | S_IRWXO; /* rwx for owner group and other, by default */
st = &sb;
}
- if (S_ISLNK(st->st_mode))
- return 0; /* we don't want to change link permissions */
-
mode |= st->st_mode & ~mask; /* keep other bits from previous mode */
- if ( chmod( name, mode & ~v_umask ) < 0 && errno != EPERM ) {
+ if (ochmod(name, mode & ~vol->v_umask, st, vol_syml_opt(vol) | O_NETATALK_ACL) < 0 && errno != EPERM ) {
return -1;
}
return 0;
return AFP_OK;
}
-char *fullpathname(const char *name)
-{
- static char wd[ MAXPATHLEN + 1];
-
- if ( getcwd( wd , MAXPATHLEN) ) {
- strlcat(wd, "/", MAXPATHLEN);
- strlcat(wd, name, MAXPATHLEN);
- }
- else {
- strlcpy(wd, name, MAXPATHLEN);
- }
- return wd;
-}
-
-
/**************************************************************************
* *at semnatics support functions (like openat, renameat standard funcs)
**************************************************************************/
sfd = open(src, O_RDONLY);
#endif
if (sfd < 0) {
- LOG(log_error, logtype_afpd, "copy_file('%s'/'%s'): open '%s' error: %s",
+ LOG(log_info, logtype_afpd, "copy_file('%s'/'%s'): open '%s' error: %s",
src, dst, src, strerror(errno));
return -1;
}
if ((dfd = open(dst, O_WRONLY | O_CREAT | O_TRUNC, mode)) < 0) {
- LOG(log_error, logtype_afpd, "copy_file('%s'/'%s'): open '%s' error: %s",
+ LOG(log_info, logtype_afpd, "copy_file('%s'/'%s'): open '%s' error: %s",
src, dst, dst, strerror(errno));
ret = -1;
goto exit;
return -1;
}
-/*
- * @brief lstat/fsstatat multiplexer
- *
- * lstatat mulitplexes lstat and fstatat. If we dont HAVE_ATFUNCS, dirfd is ignored.
- *
- * @param dirfd (r) Only used if HAVE_ATFUNCS, ignored else, -1 gives AT_FDCWD
- * @param path (r) pathname
- * @param st (rw) pointer to struct stat
- */
-int lstatat(int dirfd, const char *path, struct stat *st)
-{
-#ifdef HAVE_ATFUNCS
- if (dirfd == -1)
- dirfd = AT_FDCWD;
- return (fstatat(dirfd, path, st, AT_SYMLINK_NOFOLLOW));
-#else
- return (lstat(path, st));
-#endif
-
- /* DEADC0DE */
- return -1;
-}
-
/*
* @brief opendir wrapper for *at semantics support
*