/*
- * $Id: unix.c,v 1.54 2009-10-13 22:55:37 didg Exp $
+ * $Id: unix.c,v 1.60 2010-01-20 13:22:13 franklahm Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
#endif /* STDC_HEADERS */
#include <errno.h>
-#include <dirent.h>
#include <limits.h>
#include <sys/param.h>
-#include <sys/stat.h>
#include <atalk/logger.h>
#include <atalk/adouble.h>
#include <atalk/vfs.h>
#include <atalk/afp.h>
#include <atalk/util.h>
+#include <atalk/unix.h>
#include "auth.h"
#include "directory.h"
if (setfilmode( path->u_name, mode, &path->st, vol->v_umask) < 0)
return -1;
/* we need to set write perm if read set for resource fork */
- return vol->vfs->rf_setfilmode(vol, path->u_name, mode, &path->st);
+ return vol->vfs->vfs_setfilmode(vol, path->u_name, mode, &path->st);
}
{
int dropbox = (vol->v_flags & AFPVOL_DROPBOX);
+
+ LOG(log_debug, logtype_afpd, "setdirunixmode('%s', mode:%04o) {v_dperm:%04o}",
+ fullpathname(name), mode, vol->v_dperm);
+
mode |= vol->v_dperm;
if (dir_rx_set(mode)) {
if ( stickydirmode(name, DIRBITS | mode, dropbox, vol->v_umask) < 0 )
return -1;
}
- if (vol->vfs->rf_setdirunixmode(vol, name, mode, NULL) < 0 && !vol_noadouble(vol)) {
+ if (vol->vfs->vfs_setdirunixmode(vol, name, mode, NULL) < 0 && !vol_noadouble(vol)) {
return -1 ;
}
if (!dir_rx_set(mode)) {
}
closedir( dir );
- if (vol->vfs->rf_setdirmode(vol, name, mode, NULL) < 0 && !vol_noadouble(vol)) {
+ if (vol->vfs->vfs_setdirmode(vol, name, mode, NULL) < 0 && !vol_noadouble(vol)) {
return -1 ;
}
return -1;
}
- if (vol->vfs->rf_chown(vol, path->u_name, uid, gid ) < 0 && errno != EPERM) {
+ if (vol->vfs->vfs_chown(vol, path->u_name, uid, gid ) < 0 && errno != EPERM) {
LOG(log_debug, logtype_afpd, "setfilowner: rf_chown %d/%d %s: %s",
uid, gid, path->u_name, strerror(errno) );
return -1;
}
closedir( dir );
- if (vol->vfs->rf_setdirowner(vol, name, uid, gid) < 0) {
+ if (vol->vfs->vfs_setdirowner(vol, name, uid, gid) < 0) {
return -1;
}
}
#endif
-/* This is equivalent of unix rename(). */
-int unix_rename(const char *oldpath, const char *newpath)
-{
-#if 0
- char pd_name[PATH_MAX+1];
- int i;
- struct stat pd_stat;
- uid_t uid;
-#endif
-
- if (rename(oldpath, newpath) < 0)
- return -1;
-#if 0
- for (i = 0; i <= PATH_MAX && newpath[i] != '\0'; i++)
- pd_name[i] = newpath[i];
- pd_name[i] = '\0';
-
- while (i > 0 && pd_name[i] != '/') i--;
- if (pd_name[i] == '/') i++;
-
- pd_name[i++] = '.'; pd_name[i++] = '\0';
-
- if (stat(pd_name, &pd_stat) < 0) {
- LOG(log_error, logtype_afpd, "stat() of parent dir failed: pd_name = %s, uid = %d: %s",
- pd_name, geteuid(), strerror(errno));
- return 0;
- }
-
- /* So we have SGID bit set... */
- if ((S_ISGID & pd_stat.st_mode) != 0) {
- uid = geteuid();
- if (seteuid(0) < 0)
- LOG(log_error, logtype_afpd, "seteuid() failed: %s", strerror(errno));
- if (recursive_chown(newpath, uid, pd_stat.st_gid) < 0)
- LOG(log_error, logtype_afpd, "chown() of parent dir failed: newpath=%s, uid=%d: %s",
- pd_name, geteuid(), strerror(errno));
- seteuid(uid);
- }
-#endif
- return 0;
-}
-