u_int16_t ashort;
u_char achar, fdType[4];
+#ifdef DEBUG
+ syslog(LOG_INFO, "begin getfilparams:");
+#endif DEBUG
+
upath = mtoupath(vol, path);
if ((of = of_findname(vol, curdir, path))) {
adp = of->of_ad;
ad_close( adp, ADFLAGS_HF );
}
*buflen = data - buf;
+
+#ifdef DEBUG
+ syslog(LOG_INFO, "end getfilparams:");
+#endif DEBUG
+
return( AFP_OK );
}
int ibuflen, *rbuflen;
{
struct stat st;
-#ifdef DROPKLUDGE
- struct stat sb;
- char adpath[50];
- int uid;
-#endif DROPKLUDGE
struct adouble ad, *adp;
struct vol *vol;
struct dir *dir;
struct ofork *of;
char *path, *upath;
- int creatf, did, openf;
+ int creatf, did, openf, retvalue = AFP_OK;
u_int16_t vid;
+#ifdef DEBUG
+ syslog(LOG_INFO, "begin afp_createfile:");
+#endif DEBUG
+
*rbuflen = 0;
ibuf++;
creatf = (unsigned char) *ibuf++;
createfile_done:
#ifdef DROPKLUDGE
-
-/* The below code changes the way file ownership is determined in the name of
-fixing dropboxes. It has known security problem. See the netatalk FAQ for
-more information */
- if (stat(".", &sb) < 0) {
- syslog (LOG_ERR, "afp_createfile: Error checking directory \"%s\": %m", dir->d_name);
- return(-1);
- }
- else {
- uid=geteuid();
- if ( uid != sb.st_uid )
- {
- strcpy (adpath, "./.AppleDouble/");
- strcat (adpath, upath);
- seteuid(0); /* Become root to change the owner of the file */
- if (lchown(upath, sb.st_uid, sb.st_gid) < 0)
- {
- syslog (LOG_ERR, "afp_createfile: Error changing owner/gid: %m");
- return (-1);
- }
- /* In order to write information to the file, the Mac client needs
- to be able to read from it too, so read bits have to be turned on.
- Directory permissions remain unchanged */
- stat(upath, &st);
- if (chmod(upath,(st.st_mode&0x0FFFF)| S_IRGRP| S_IROTH) < 0)
- {
- syslog (LOG_ERR, "afp_createfile: Error adding file read permissions: %m");
- return (-1);
- }
- else syslog (LOG_DEBUG, "afp_createfile: Added S_IRGRP and S_IROTH: %m");
- if (lchown(adpath, sb.st_uid, sb.st_gid) < 0)
- {
- syslog (LOG_ERR, "afp_createfile: Error changing AppleDouble owner/gid: %m");
- return (-1);
- }
- if (chmod(adpath, (st.st_mode&0x0FFFF)| S_IRGRP| S_IROTH) < 0)
- {
- syslog (LOG_ERR, "afp_createfile: Error adding AD file read permissions: %m");
- return (-1);
- }
- else syslog (LOG_DEBUG, "afp_createfile: Added S_IRGRP and S_IROTH to AD: %m");
- syslog (LOG_DEBUG, "afp_createfile: Changing afpd owner back to %d", uid);
- seteuid(uid); /* Restore process ownership to normal */
- }
- }
-
+ retvalue=matchfile2dirperms(upath, vol, did);
#endif DROPKLUDGE
setvoltime(obj, vol );
- return AFP_OK;
+
+#ifdef DEBUG
+ syslog(LOG_INFO, "end afp_createfile");
+#endif DEBUG
+
+ return (retvalue);
}
int afp_setfilparams(obj, ibuf, ibuflen, rbuf, rbuflen )
int did, rc;
u_int16_t vid, bitmap;
+#ifdef DEBUG
+ syslog(LOG_INFO, "begin afp_setfilparams:");
+#endif DEBUG
+
*rbuflen = 0;
ibuf += 2;
setvoltime(obj, vol );
}
+#ifdef DEBUG
+ syslog(LOG_INFO, "end afp_setfilparams:");
+#endif DEBUG
+
return( rc );
}
u_int32_t aint;
struct utimbuf ut;
+#ifdef DEBUG
+ syslog(LOG_INFO, "begin setfilparams:");
+#endif DEBUG
+
upath = mtoupath(vol, path);
if ((of = of_findname(vol, curdir, path))) {
adp = of->of_ad;
ad_flush( adp, ADFLAGS_HF );
ad_close( adp, ADFLAGS_HF );
}
+
+#ifdef DEBUG
+ syslog(LOG_INFO, "end setfilparams:");
+#endif DEBUG
+
return err;
}
/* existence check moved to afp_moveandrename */
+#ifdef DEBUG
+ syslog (LOG_INFO, "begin renamefile:");
+#endif DEBUG
+
if ( rename( src, dst ) < 0 ) {
switch ( errno ) {
case ENOENT :
ad_flush( &ad, ADFLAGS_HF );
ad_close( &ad, ADFLAGS_HF );
+#ifdef DEBUG
+ syslog (LOG_INFO, "end renamefile:");
+#endif DEBUG
+
return( AFP_OK );
}
struct dir *dir;
char *newname, *path, *p;
u_int32_t sdid, ddid;
- int plen, err;
+ int plen, err, did, retvalue = AFP_OK;
u_int16_t svid, dvid;
+#ifdef DEBUG
+ syslog (LOG_INFO, "begin afp_copyfile:");
+#endif DEBUG
+
*rbuflen = 0;
ibuf += 2;
}
setvoltime(obj, vol );
- return( AFP_OK );
+
+#ifdef DROPKLUDGE
+ retvalue=matchfile2dirperms(newname, vol, sdid);
+#endif DROPKLUDGE
+
+#ifdef DEBUG
+ syslog (LOG_INFO, "end afp_copyfile:");
+#endif DEBUG
+
+ return( retvalue );
}
{
ssize_t cc;
+#ifdef DEBUG
+ syslog(LOG_INFO, "begin copy_all:");
+#endif DEBUG
+
while (buflen > 0) {
if ((cc = write(dfd, buf, buflen)) < 0) {
switch (errno) {
buflen -= cc;
}
- return 0;
+#ifdef DEBUG
+ syslog(LOG_INFO, "end copy_all:");
+#endif DEBUG
+
+ return AFP_OK;
}
/* XXX: this needs to use ad_open and ad_lock. so, we need to
int sfd, dfd, len, err = AFP_OK;
ssize_t cc;
+#ifdef DEBUG
+ syslog(LOG_INFO, "begin copyfile:");
+#endif DEBUG
if (newname) {
if ((sfd = open( ad_path( src, ADFLAGS_HF ), O_RDONLY, 0 )) < 0 ) {
ad_close( &ad, ADFLAGS_HF );
}
+#ifdef DEBUG
+ syslog(LOG_INFO, "end copyfile:");
+#endif DEBUG
+
return( AFP_OK );
}
struct adouble ad;
int adflags, err = AFP_OK;
+#ifdef DEBUG
+ syslog(LOG_INFO, "begin deletefile:");
+#endif DEBUG
+
/* try to open both at once */
adflags = ADFLAGS_DF|ADFLAGS_HF;
memset(&ad, 0, sizeof(ad));
ad_tmplock(&ad, ADEID_RFORK, ADLOCK_CLR, 0, 0);
ad_tmplock(&ad, ADEID_DFORK, ADLOCK_CLR, 0, 0);
ad_close( &ad, adflags );
+
+#ifdef DEBUG
+ syslog(LOG_INFO, "end deletefile:");
+#endif DEBUG
+
return err;
}
int len;
cnid_t did, id;
u_short vid;
+
+#ifdef DEBUG
+ syslog(LOG_INFO, "begin afp_createid:");
+#endif DEBUG
*rbuflen = 0;
ibuf += 2;
return AFP_OK;
}
+#ifdef DEBUG
+ syslog(LOG_INFO, "ending afp_createid...:");
+#endif DEBUG
+
switch (errno) {
case EROFS:
return AFPERR_VLOCK;
int err, buflen;
cnid_t id;
u_int16_t vid, bitmap;
+
+#ifdef DEBUG
+ syslog(LOG_INFO, "begin afp_resolveid:");
+#endif DEBUG
*rbuflen = 0;
ibuf += 2;
*rbuflen = buflen + sizeof(bitmap);
memcpy(rbuf, ibuf, sizeof(bitmap));
+
+#ifdef DEBUG
+ syslog(LOG_INFO, "end afp_resolveid:");
+#endif DEBUG
+
return AFP_OK;
}
int err;
cnid_t id;
u_short vid;
-
+
+#ifdef DEBUG
+ syslog(LOG_INFO, "begin afp_deleteid:");
+#endif DEBUG
+
*rbuflen = 0;
ibuf += 2;
}
}
+#ifdef DEBUG
+ syslog(LOG_INFO, "end afp_deleteid:");
+#endif DEBUG
+
return err;
}
#endif
#endif
cnid_t sid, did;
u_int16_t vid;
-
+
+#ifdef DEBUG
+ syslog(LOG_INFO, "begin afp_exchangefiles:");
+#endif DEBUG
+
*rbuflen = 0;
ibuf += 2;
goto err_temp_to_dest;
}
#endif
+
+#ifdef DEBUG
+ syslog(LOG_INFO, "ending afp_exchangefiles:");
+#endif DEBUG
+
return AFP_OK;