SecurityDescriptor querySecurity ( SmbTreeHandleImpl th, int types ) throws CIFSException { if ( th.isSMB2() ) { Smb2QueryInfoRequest req = new Smb2QueryInfoRequest(th.getConfig()); req.setInfoType(Smb2Constants.SMB2_0_INFO_SECURITY); req.setAdditionalInformation(types); Smb2QueryInfoResponse resp = withOpen(th, req); return resp.getInfo(SecurityDescriptor.class); } if ( !th.hasCapability(SmbConstants.CAP_NT_SMBS) ) { throw new SmbUnsupportedOperationException("Not supported without CAP_NT_SMBS/SMB2"); } NtTransQuerySecurityDescResponse response = new NtTransQuerySecurityDescResponse(getContext().getConfig()); try ( SmbFileHandleImpl f = openUnshared(O_RDONLY, READ_CONTROL, DEFAULT_SHARING, 0, isDirectory() ? 1 : 0) ) { /* * NtTrans Query Security Desc Request / Response */ NtTransQuerySecurityDesc request = new NtTransQuerySecurityDesc(getContext().getConfig(), f.getFid(), types); response = th.send(request, response, RequestParam.NO_RETRY); return response.getSecurityDescriptor(); } }
SecurityDescriptor querySecurity ( SmbTreeHandleImpl th, int types ) throws CIFSException { if ( th.isSMB2() ) { Smb2QueryInfoRequest req = new Smb2QueryInfoRequest(th.getConfig()); req.setInfoType(Smb2Constants.SMB2_0_INFO_SECURITY); req.setAdditionalInformation(types); Smb2QueryInfoResponse resp = withOpen(th, req); return resp.getInfo(SecurityDescriptor.class); } if ( !th.hasCapability(SmbConstants.CAP_NT_SMBS) ) { throw new SmbUnsupportedOperationException("Not supported without CAP_NT_SMBS/SMB2"); } NtTransQuerySecurityDescResponse response = new NtTransQuerySecurityDescResponse(getContext().getConfig()); try ( SmbFileHandleImpl f = openUnshared(O_RDONLY, READ_CONTROL, DEFAULT_SHARING, 0, isDirectory() ? 1 : 0) ) { /* * NtTrans Query Security Desc Request / Response */ NtTransQuerySecurityDesc request = new NtTransQuerySecurityDesc(getContext().getConfig(), f.getFid(), types); response = th.send(request, response, RequestParam.NO_RETRY); return response.getSecurityDescriptor(); } }