Ignore:
Timestamp:
Aug 5, 2009, 6:34:45 PM (16 years ago)
Author:
Herwig Bauernfeind
Message:

Update 3.0 to final 3.0.36 (source)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.0/source/modules/nfs4_acls.c

    r39 r312  
    588588
    589589        SMB_STRUCT_STAT sbuf;
    590         BOOL need_chown = False;
     590        BOOL set_acl_as_root = False;
    591591        uid_t newUID = (uid_t)-1;
    592592        gid_t newGID = (gid_t)-1;
     593        int saved_errno;
    593594
    594595        DEBUG(10, ("smb_set_nt_acl_nfs4 invoked for %s\n", fsp->fsp_name));
     
    618619                if (((newUID != (uid_t)-1) && (sbuf.st_uid != newUID)) ||
    619620                        ((newGID != (gid_t)-1) && (sbuf.st_gid != newGID))) {
    620                         need_chown = True;
    621                 }
    622                 if (need_chown) {
    623                         if ((newUID == (uid_t)-1 || newUID == current_user.ut.uid)) {
    624                                 if(try_chown(fsp->conn, fsp->fsp_name, newUID, newGID)) {
    625                                         DEBUG(3,("chown %s, %u, %u failed. Error = %s.\n",
    626                                                 fsp->fsp_name, (unsigned int)newUID, (unsigned int)newGID, strerror(errno) ));
    627                                         return False;
    628                                 }
    629                                 DEBUG(10,("chown %s, %u, %u succeeded.\n",
    630                                         fsp->fsp_name, (unsigned int)newUID, (unsigned int)newGID));
    631                                 if (smbacl4_GetFileOwner(fsp, &sbuf))
    632                                         return False;
    633                                 need_chown = False;
    634                         } else { /* chown is needed, but _after_ changing acl */
    635                                 sbuf.st_uid = newUID; /* OWNER@ in case of e_special */
    636                                 sbuf.st_gid = newGID; /* GROUP@ in case of e_special */
    637                         }
    638                 }
    639         }
    640 
    641         if ((security_info_sent & DACL_SECURITY_INFORMATION)!=0 && psd->dacl!=NULL)
    642         {
    643                 acl = smbacl4_win2nfs4(psd->dacl, &params, sbuf.st_uid, sbuf.st_gid);
    644                 if (!acl)
    645                         return False;
    646 
    647                 smbacl4_dump_nfs4acl(10, acl);
    648 
    649                 result = set_nfs4_native(fsp, acl);
    650                 if (result!=True)
    651                 {
    652                         DEBUG(10, ("set_nfs4_native failed with %s\n", strerror(errno)));
    653                         return False;
    654                 }
    655         } else
     621                        if(try_chown(fsp->conn, fsp->fsp_name, newUID, newGID)) {
     622                                DEBUG(3,("chown %s, %u, %u failed. Error = %s.\n",
     623                                        fsp->fsp_name, (unsigned int)newUID, (unsigned int)newGID, strerror(errno) ));
     624                                return False;
     625                        }
     626                        DEBUG(10,("chown %s, %u, %u succeeded.\n",
     627                                fsp->fsp_name, (unsigned int)newUID, (unsigned int)newGID));
     628                        if (smbacl4_GetFileOwner(fsp, &sbuf))
     629                                return False;
     630                        /* If we successfully chowned, we know we must
     631                         * be able to set the acl, so do it as root.
     632                         */
     633                        set_acl_as_root = True;
     634                }
     635        }
     636
     637        if (!(security_info_sent & DACL_SECURITY_INFORMATION) || psd->dacl ==NULL) {
    656638                DEBUG(10, ("no dacl found; security_info_sent = 0x%x\n", security_info_sent));
    657 
    658         /* Any chown pending? */
    659         if (need_chown) {
    660                 DEBUG(3,("chown#2 %s. uid = %u, gid = %u.\n",
    661                         fsp->fsp_name, (unsigned int)newUID, (unsigned int)newGID));
    662                 if (try_chown(fsp->conn, fsp->fsp_name, newUID, newGID)) {
    663                         DEBUG(2,("chown#2 %s, %u, %u failed. Error = %s.\n",
    664                                 fsp->fsp_name, (unsigned int)newUID, (unsigned int)newGID,
    665                                 strerror(errno)));
    666                         return False;
    667                 }
    668                 DEBUG(10,("chown#2 %s, %u, %u succeeded.\n",
    669                         fsp->fsp_name, (unsigned int)newUID, (unsigned int)newGID));
     639                return True;
     640        }
     641        acl = smbacl4_win2nfs4(psd->dacl, &params, sbuf.st_uid, sbuf.st_gid);
     642        if (!acl)
     643                return False;
     644
     645        smbacl4_dump_nfs4acl(10, acl);
     646
     647        if (set_acl_as_root) {
     648                become_root();
     649        }
     650        result = set_nfs4_native(fsp, acl);
     651        saved_errno = errno;
     652        if (set_acl_as_root) {
     653                unbecome_root();
     654        }
     655        if (result!=True) {
     656                errno = saved_errno;
     657                DEBUG(10, ("set_nfs4_native failed with %s\n", strerror(errno)));
     658                return False;
    670659        }
    671660
Note: See TracChangeset for help on using the changeset viewer.