name. Björn Fernhomberg and me.
# limitsize -> limit disk size reporting to 2GB. this is
# here for older macintoshes using newer
# appleshare clients. yucko.
+# nofileid -> don't advertise createfileid, resolveid, deleteid
+# calls
+# upriv -> use unix privilege.
#
# codepage:filename -> load filename from nls directory.
# dbpath:path -> store the database stuff in the following path.
# password:password -> set a volume password (8 characters max)
-# nofileid -> don't advertise createfileid, resolveid, deleteid
-# calls
#
# The "~" below indicates that Home directories are visible by default.
# If you do not wish to have people accessing their Home directories,
/*
- * $Id: desktop.c,v 1.28 2003-05-07 13:23:53 didg Exp $
+ * $Id: desktop.c,v 1.29 2003-06-05 09:17:10 didg Exp $
*
* See COPYRIGHT.
*
clen = min( clen, 199 );
upath = path->u_name;
- if (check_access(upath, OPENACC_WR ) < 0) {
+ if (!vol_unix_priv(vol) && check_access(upath, OPENACC_WR ) < 0) {
return AFPERR_ACCESS;
}
}
upath = s_path->u_name;
- if (check_access(upath, OPENACC_WR ) < 0) {
+ if (!vol_unix_priv(vol) && check_access(upath, OPENACC_WR ) < 0) {
return AFPERR_ACCESS;
}
/*
- * $Id: directory.c,v 1.74 2003-05-20 14:46:50 didg Exp $
+ * $Id: directory.c,v 1.75 2003-06-05 09:17:11 didg Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
/* -----------------------------------------
* if did is not in the cache resolve it with cnid
*
+ * FIXME
+ * OSX call it with bogus id, ie file ID not folder ID,
+ * and we are really bad in this case.
*/
struct dir *
dirlookup( vol, did )
return 0;
}
+/* --------------------- */
+int file_access(struct path *path, int mode)
+{
+struct maccess ma;
+
+ accessmode(path->u_name, &ma, curdir, &path->st);
+ if ((mode & OPENACC_WR) && !(ma.ma_user & AR_UWRITE))
+ return -1;
+ if ((mode & OPENACC_RD) && !(ma.ma_user & AR_UREAD))
+ return -1;
+ return 0;
+
+}
+
/* ------------------------------
(".", curdir)
(name, dir) with curdir:name == dir, from afp_enumerate
}
break;
+ case DIRPBIT_UNIXPR :
+ aint = htonl(st->st_uid);
+ memcpy( data, &aint, sizeof( aint ));
+ data += sizeof( aint );
+ aint = htonl(st->st_gid);
+ memcpy( data, &aint, sizeof( aint ));
+ data += sizeof( aint );
+
+ aint = st->st_mode;
+ aint = htonl ( aint & ~S_ISGID ); /* Remove SGID, OSX doesn't like it ... */
+ memcpy( data, &aint, sizeof( aint ));
+ data += sizeof( aint );
+
+ accessmode( upath, &ma, dir , st);
+
+ *data++ = ma.ma_user;
+ *data++ = ma.ma_world;
+ *data++ = ma.ma_group;
+ *data++ = ma.ma_owner;
+ break;
+
+
default :
if ( isad ) {
ad_close( &ad, ADFLAGS_HF );
buf += 6;
break;
}
+
+ case DIRPBIT_UNIXPR :
+ /* Skip UID and GID for now, there seems to be now way to set them from an OSX client anyway */
+ buf += sizeof( aint );
+ buf += sizeof( aint );
+
+ change_mdate = 1;
+ change_parent_mdate = 1;
+ memcpy( &aint, buf, sizeof( aint ));
+ buf += sizeof( aint );
+ aint = ntohl (aint);
+ if (curdir->d_did == DIRDID_ROOT)
+ setdeskmode( aint );
+#if 0 /* don't error if we can't set the desktop mode */
+ switch ( errno ) {
+ case EPERM :
+ case EACCES :
+ err = AFPERR_ACCESS;
+ goto setdirparam_done;
+ case EROFS :
+ err = AFPERR_VLOCK;
+ goto setdirparam_done;
+ default :
+ LOG(log_error, logtype_afpd, "setdirparam: setdeskmode: %s",
+ strerror(errno) );
+ break;
+ err = AFPERR_PARAM;
+ goto setdirparam_done;
+ }
+#endif /* 0 */
+
+ if ( setdirunixmode( aint, vol_noadouble(vol),
+ (vol->v_flags & AFPVOL_DROPBOX)) < 0 ) {
+ switch ( errno ) {
+ case EPERM :
+ case EACCES :
+ err = AFPERR_ACCESS;
+ goto setdirparam_done;
+ case EROFS :
+ err = AFPERR_VLOCK;
+ goto setdirparam_done;
+ default :
+ LOG(log_error, logtype_afpd, "setdirparam: setdirmode: %s",
+ strerror(errno) );
+ err = AFPERR_PARAM;
+ goto setdirparam_done;
+ }
+ }
+ break;
+
default :
err = AFPERR_BITMAP;
goto setdirparam_done;
/*
- * $Id: directory.h,v 1.15 2003-05-20 14:46:50 didg Exp $
+ * $Id: directory.h,v 1.16 2003-06-05 09:17:11 didg Exp $
*
* Copyright (c) 1990,1991 Regents of The University of Michigan.
* All Rights Reserved.
#define DIRPBIT_GID 11
#define DIRPBIT_ACCESS 12
#define DIRPBIT_PDINFO 13 /* ProDOS Info */
+#define DIRPBIT_UNIXPR 15
/* directory attribute bits (see file.h for other bits) */
#define ATTRBIT_EXPFOLDER (1 << 1) /* shared point */
extern int for_each_dirent __P((const struct vol *, char *, dir_loop , void *));
extern int check_access __P((char *name , int mode));
+extern int file_access __P((struct path *path, int mode));
extern int netatalk_unlink __P((const char *name));
/*
- * $Id: file.c,v 1.93 2003-06-02 06:54:22 didg Exp $
+ * $Id: file.c,v 1.94 2003-06-05 09:17:11 didg Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
if (aint > 255) /* FIXME safeguard, anyway if no ascii char it's game over*/
aint = 255;
- utf8 = htonl(utf8);
+ utf8 = 0; /* htonl(utf8) */
memcpy(data, &utf8, sizeof(utf8));
data += sizeof(utf8);
u_char achar, fdType[4];
u_int32_t utf8 = 0;
struct stat *st;
+ struct maccess ma;
#ifdef DEBUG
LOG(log_info, logtype_afpd, "begin getmetadata:");
#endif /* DEBUG */
memcpy(data, &aint, sizeof( aint ));
data += sizeof( aint );
break;
+ case FILPBIT_UNIXPR :
+ aint = htonl(st->st_uid);
+ memcpy( data, &aint, sizeof( aint ));
+ data += sizeof( aint );
+ aint = htonl(st->st_gid);
+ memcpy( data, &aint, sizeof( aint ));
+ data += sizeof( aint );
+
+ aint = htonl(st->st_mode);
+ memcpy( data, &aint, sizeof( aint ));
+ data += sizeof( aint );
+
+ accessmode( upath, &ma, dir , st);
+
+ *data++ = ma.ma_user;
+ *data++ = ma.ma_world;
+ *data++ = ma.ma_group;
+ *data++ = ma.ma_owner;
+ break;
+
default :
return( AFPERR_BITMAP );
}
adp = &ad;
}
- if (check_access(upath, OPENACC_WR ) < 0) {
+ if (!vol_unix_priv(vol) && check_access(upath, OPENACC_WR ) < 0) {
return AFPERR_ACCESS;
}
break;
}
/* fallthrough */
+ case FILPBIT_UNIXPR :
+ /* Skip the UIG/GID, no way to set them from OSX clients */
+ buf += sizeof( aint );
+ buf += sizeof( aint );
+
+ change_mdate = 1;
+ change_parent_mdate = 1;
+ memcpy( &aint, buf, sizeof( aint ));
+ buf += sizeof( aint );
+ aint = ntohl (aint);
+
+ setfilemode(path, aint);
+ break;
default :
err = AFPERR_BITMAP;
goto setfilparam_done;
/*
- * $Id: file.h,v 1.16 2003-03-09 19:55:34 didg Exp $
+ * $Id: file.h,v 1.17 2003-06-05 09:17:11 didg Exp $
*
* Copyright (c) 1990,1991 Regents of The University of Michigan.
* All Rights Reserved.
#define FILPBIT_EXTDFLEN 11
#define FILPBIT_PDINFO 13 /* ProDOS Info/ UTF8 name */
#define FILPBIT_EXTRFLEN 14
+#define FILPBIT_UNIXPR 15
/* attribute bits. (d) = directory attribute bit as well. */
#define ATTRBIT_INVISIBLE (1<<0) /* invisible (d) */
/*
- * $Id: filedir.c,v 1.46 2003-05-03 20:03:13 didg Exp $
+ * $Id: filedir.c,v 1.47 2003-06-05 09:17:11 didg Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
}
else
#endif /* DROPKLUDGE */
- if (!isdir) {
+ /* if unix priv don't try to match perm with dest folder */
+ if (!isdir && !vol_unix_priv(vol)) {
int admode = ad_mode("", 0777);
setfilmode(upath, admode, NULL);
/*
- * $Id: fork.c,v 1.51 2003-03-15 01:34:35 didg Exp $
+ * $Id: fork.c,v 1.52 2003-06-05 09:17:11 didg Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
}
/* FIXME should we check it first ? */
upath = s_path->u_name;
- if (check_access(upath, access ) < 0) {
- return AFPERR_ACCESS;
+ if (!vol_unix_priv(vol)) {
+ if (check_access(upath, access ) < 0) {
+ return AFPERR_ACCESS;
+ }
+ }
+ else {
+ if (file_access(s_path, access ) < 0) {
+ return AFPERR_ACCESS;
+ }
}
st = &s_path->st;
/*
- * $Id: unix.c,v 1.43 2003-03-09 19:55:35 didg Exp $
+ * $Id: unix.c,v 1.44 2003-06-05 09:17:12 didg Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
#include <limits.h>
#include <atalk/adouble.h>
#include <atalk/afp.h>
-
/* STDC check */
#if STDC_HEADERS
#include <string.h>
#include "directory.h"
#include "volume.h"
#include "unix.h"
+#include "fork.h"
/*
* Get the free space on a partition.
mbits = 0;
- mbits |= ( bits & ( S_IREAD >> 6 )) ? (AR_UREAD | AR_USEARCH) : 0;
+ mbits |= ( bits & ( S_IREAD >> 6 )) ? AR_UREAD : 0;
mbits |= ( bits & ( S_IWRITE >> 6 )) ? AR_UWRITE : 0;
- /* Do we really need this?
- mbits |= ( bits & ( S_IEXEC >> 6) ) ? AR_USEARCH : 0; */
+ /* Do we really need this? */
+ mbits |= ( bits & ( S_IEXEC >> 6) ) ? AR_USEARCH : 0;
return( mbits );
}
return( 0 );
}
+/* --------------------- */
+int setfilemode (path, mode)
+struct path* path;
+mode_t mode;
+{
+ if (!path->st_valid) {
+ of_stat(path);
+ }
+
+ if (path->st_errno) {
+ return -1;
+ }
+
+ if (setfilmode( path->u_name, mode, &path->st) < 0)
+ return -1;
+ /* we need to set write perm if read set for resource fork */
+ return setfilmode(ad_path( path->u_name, ADFLAGS_HF ), ad_hf_mode(mode), &path->st);
+}
+
+/* --------------------- */
int setfilmode(name, mode, st)
char * name;
mode_t mode;
return 0;
}
+/* --------------------- */
+int setdirunixmode( mode, noadouble, dropbox )
+const mode_t mode;
+const int noadouble;
+const int dropbox;
+{
+ if ( stickydirmode(".AppleDouble", DIRBITS | mode, dropbox) < 0 && !noadouble)
+ return -1 ;
+
+ if ( stickydirmode(".", DIRBITS | mode, dropbox) < 0 )
+ return -1;
+ return 0;
+}
+
+/* --------------------- */
int setdirmode( mode, noadouble, dropbox )
const mode_t mode;
const int noadouble;
/*
- * $Id: unix.h,v 1.12 2003-01-07 15:55:22 rlewczuk Exp $
+ * $Id: unix.h,v 1.13 2003-06-05 09:17:12 didg Exp $
*/
#ifndef AFPD_UNIX_H
extern struct afp_options default_options;
-extern int gmem __P((const gid_t));
-extern int setdeskmode __P((const mode_t));
-extern int setdirmode __P((const mode_t, const int, const int));
-extern int setdeskowner __P((const uid_t, const gid_t));
-extern int setdirowner __P((const uid_t, const gid_t, const int));
-extern int setfilmode __P((char *, mode_t , struct stat *));
-extern int unix_rename __P((const char *oldpath, const char *newpath));
-
-extern void accessmode __P((char *, struct maccess *, struct dir *, struct stat *));
+extern int gmem __P((const gid_t));
+extern int setdeskmode __P((const mode_t));
+extern int setdirunixmode __P((const mode_t, const int, const int));
+extern int setdirmode __P((const mode_t, const int, const int));
+extern int setdeskowner __P((const uid_t, const gid_t));
+extern int setdirowner __P((const uid_t, const gid_t, const int));
+extern int setfilmode __P((char *, mode_t , struct stat *));
+extern int setfilemode __P((struct path*, const mode_t));
+extern int unix_rename __P((const char *oldpath, const char *newpath));
+
+extern void accessmode __P((char *, struct maccess *, struct dir *, struct stat *));
#ifdef AFS
#define accessmode afsmode
/*
- * $Id: volume.c,v 1.52 2003-05-21 01:32:47 didg Exp $
+ * $Id: volume.c,v 1.53 2003-06-05 09:17:12 didg Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
options[VOLOPT_FLAGS].i_value |= AFPVOL_NOFILEID;
else if (strcasecmp(p, "utf8") == 0)
options[VOLOPT_FLAGS].i_value |= AFPVOL_UTF8;
+ else if (strcasecmp(p, "upriv") == 0)
+ options[VOLOPT_FLAGS].i_value |= AFPVOL_UNIX_PRIV;
p = strtok(NULL, ",");
}
ashort |= VOLPBIT_ATTR_CATSEARCH;
if (afp_version >= 30) {
ashort |= VOLPBIT_ATTR_UTF8;
+ if (vol->v_flags & AFPVOL_UNIX_PRIV)
+ ashort |= VOLPBIT_ATTR_UNIXPRIV;
}
ashort = htons(ashort);
memcpy(data, &ashort, sizeof( ashort ));
completely worked this out, but it's related to booting
from the server. Support for that function is a ways
off.. <shirsch@ibm.net> */
- *data++ |= (volume->v_flags & AFPVOL_A2VOL) ? AFPSRVR_CONFIGINFO : 0;
+ *data |= (volume->v_flags & AFPVOL_A2VOL) ? AFPSRVR_CONFIGINFO : 0;
+ *data++ |= 0; /* UNIX PRIVS BIT ..., OSX doesn't seem to use it, so we don't either */
len = strlen( volume->v_name );
*data++ = len;
memcpy(data, volume->v_name, len );
/*
- * $Id: volume.h,v 1.19 2003-03-09 20:37:27 didg Exp $
+ * $Id: volume.h,v 1.20 2003-06-05 09:17:12 didg Exp $
*
* Copyright (c) 1990,1994 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
#define AFPVOL_DROPBOX (1 << 14) /* dropkludge dropbox support */
#define AFPVOL_NOFILEID (1 << 15) /* don't advertise createid resolveid and deleteid calls */
#define AFPVOL_UTF8 (1 << 16) /* unix name are in UTF8 */
+#define AFPVOL_UNIX_PRIV (1 << 17) /* support unix privileges */
/* FPGetSrvrParms options */
#define AFPSRVR_CONFIGINFO (1 << 0)
#define vol_utf8(vol) (0)
#define utf8_encoding() (0)
#endif
+#define vol_unix_priv(vol) (afp_version >= 30 && ((vol)->v_flags & AFPVOL_UNIX_PRIV))
extern struct vol *getvolbyvid __P((const u_int16_t));
extern int ustatfs_getvolspace __P((const struct vol *,