-#ifdef FORCE_UIDGID
- uidgidset *uidgid;
-
- memset(&uidgid, 0, sizeof(uidgid));
-#endif /* FORCE_UIDGID */
-
- upath = mtoupath(vol, path);
- memset(&ad, 0, sizeof(ad));
-#ifdef FORCE_UIDGID
- save_uidgid ( &uidgid );
-#endif /* FORCE_UIDGID */
- if (ad_open( upath, vol_noadouble(vol)|ADFLAGS_HF|ADFLAGS_DIR,
- O_RDWR|O_CREAT, 0666, &ad) < 0) {
- /*
- * Check to see what we're trying to set. If it's anything
- * but ACCESS, UID, or GID, give an error. If it's any of those
- * three, we don't need the ad to be open, so just continue.
- *
- * note: we also don't need to worry about mdate. also, be quiet
- * if we're using the noadouble option.
- */
- if (!vol_noadouble(vol) && (bitmap &
- ~((1<<DIRPBIT_ACCESS)|(1<<DIRPBIT_UID)|(1<<DIRPBIT_GID)|
- (1<<DIRPBIT_MDATE)|(1<<DIRPBIT_PDINFO)))) {
-#ifdef FORCE_UIDGID
- restore_uidgid ( &uidgid );
-#endif /* FORCE_UIDGID */
- return AFPERR_ACCESS;
- }
-
- isad = 0;
+ int change_mdate = 0;
+ int change_parent_mdate = 0;
+ int newdate = 0;
+ u_int16_t bitmap = d_bitmap;
+ u_char finder_buf[32];
+ u_int32_t upriv;
+ mode_t mpriv = 0;
+ u_int16_t upriv_bit = 0;
+
+ bit = 0;
+ upath = path->u_name;
+ dir = path->d_dir;
+ while ( bitmap != 0 ) {
+ while (( bitmap & 1 ) == 0 ) {
+ bitmap = bitmap>>1;
+ bit++;
+ }
+
+ switch( bit ) {
+ case DIRPBIT_ATTR :
+ change_mdate = 1;
+ memcpy( &ashort, buf, sizeof( ashort ));
+ buf += sizeof( ashort );
+ break;
+ case DIRPBIT_CDATE :
+ change_mdate = 1;
+ memcpy(&cdate, buf, sizeof(cdate));
+ buf += sizeof( cdate );
+ break;
+ case DIRPBIT_MDATE :
+ memcpy(&newdate, buf, sizeof(newdate));
+ buf += sizeof( newdate );
+ break;
+ case DIRPBIT_BDATE :
+ change_mdate = 1;
+ memcpy(&bdate, buf, sizeof(bdate));
+ buf += sizeof( bdate );
+ break;
+ case DIRPBIT_FINFO :
+ change_mdate = 1;
+ memcpy( finder_buf, buf, 32 );
+ buf += 32;
+ break;
+ case DIRPBIT_UID : /* What kind of loser mounts as root? */
+ change_parent_mdate = 1;
+ memcpy( &owner, buf, sizeof(owner));
+ buf += sizeof( owner );
+ break;
+ case DIRPBIT_GID :
+ change_parent_mdate = 1;
+ memcpy( &group, buf, sizeof( group ));
+ buf += sizeof( group );
+ break;
+ case DIRPBIT_ACCESS :
+ change_mdate = 1;
+ change_parent_mdate = 1;
+ ma.ma_user = *buf++;
+ ma.ma_world = *buf++;
+ ma.ma_group = *buf++;
+ ma.ma_owner = *buf++;
+ mpriv = mtoumode( &ma ) | vol->v_perm;
+ if (dir_rx_set(mpriv) && setdirmode( vol, upath, mpriv) < 0 ) {
+ err = set_dir_errors(path, "setdirmode", errno);
+ bitmap = 0;
+ }
+ break;
+ /* Ignore what the client thinks we should do to the
+ ProDOS information block. Skip over the data and
+ report nothing amiss. <shirsch@ibm.net> */
+ case DIRPBIT_PDINFO :
+ if (afp_version < 30) {
+ buf += 6;
+ }
+ else {
+ err = AFPERR_BITMAP;
+ bitmap = 0;
+ }
+ break;
+ case DIRPBIT_UNIXPR :
+ if (vol_unix_priv(vol)) {
+ memcpy( &owner, buf, sizeof(owner)); /* FIXME need to change owner too? */
+ buf += sizeof( owner );
+ memcpy( &group, buf, sizeof( group ));
+ buf += sizeof( group );
+
+ change_mdate = 1;
+ change_parent_mdate = 1;
+ memcpy( &upriv, buf, sizeof( upriv ));
+ buf += sizeof( upriv );
+ upriv = ntohl (upriv) | vol->v_perm;
+ if (dir_rx_set(upriv)) {
+ /* maybe we are trying to set perms back */
+ if ( setdirunixmode(vol, upath, upriv) < 0 ) {
+ bitmap = 0;
+ err = set_dir_errors(path, "setdirunixmode", errno);
+ }
+ }
+ else {
+ /* do it later */
+ upriv_bit = 1;
+ }
+ break;
+ }
+ /* fall through */
+ default :
+ err = AFPERR_BITMAP;
+ bitmap = 0;
+ break;
+ }
+
+ bitmap = bitmap>>1;
+ bit++;
+ }
+ ad_init(&ad, vol->v_adouble, vol->v_ad_options);
+
+ if (ad_open( upath, vol_noadouble(vol)|ADFLAGS_HF|ADFLAGS_DIR,
+ O_RDWR|O_CREAT, 0666, &ad) < 0) {
+ /*
+ * Check to see what we're trying to set. If it's anything
+ * but ACCESS, UID, or GID, give an error. If it's any of those
+ * three, we don't need the ad to be open, so just continue.
+ *
+ * note: we also don't need to worry about mdate. also, be quiet
+ * if we're using the noadouble option.
+ */
+ if (!vol_noadouble(vol) && (d_bitmap &
+ ~((1<<DIRPBIT_ACCESS)|(1<<DIRPBIT_UNIXPR)|
+ (1<<DIRPBIT_UID)|(1<<DIRPBIT_GID)|
+ (1<<DIRPBIT_MDATE)|(1<<DIRPBIT_PDINFO)))) {
+ return AFPERR_ACCESS;
+ }
+
+ isad = 0;