(self, pkt, tree_name)
| 851 | |
| 852 | @ATMT.action(receive_tree_connect) |
| 853 | def send_tree_connect_response(self, pkt, tree_name): |
| 854 | self.update_smbheader(pkt) |
| 855 | # Check the tree name against the shares we're serving |
| 856 | try: |
| 857 | share = next(x for x in self.shares if x._name == tree_name.lower()) |
| 858 | except StopIteration: |
| 859 | # Unknown tree |
| 860 | resp = self.smb_header.copy() / SMB2_Error_Response() |
| 861 | resp.Command = "SMB2_TREE_CONNECT" |
| 862 | resp.Status = "STATUS_BAD_NETWORK_NAME" |
| 863 | self.send(resp) |
| 864 | return |
| 865 | # Add tree to current trees |
| 866 | if tree_name not in self.current_trees: |
| 867 | self.tree_id += 1 |
| 868 | self.smb_header.TID = self.tree_id |
| 869 | self.current_trees[self.smb_header.TID] = tree_name |
| 870 | |
| 871 | # Construct ShareFlags |
| 872 | ShareFlags = ( |
| 873 | "AUTO_CACHING+NO_CACHING" |
| 874 | if self.current_tree() == "IPC$" |
| 875 | else self.TREE_SHARE_FLAGS |
| 876 | ) |
| 877 | # [MS-SMB2] sect 3.3.5.7 |
| 878 | if ( |
| 879 | self.session.Dialect >= 0x0311 |
| 880 | and not self.session.EncryptData |
| 881 | and share.encryptdata |
| 882 | ): |
| 883 | if not self.session.SupportsEncryption: |
| 884 | raise Exception("Peer asked for encryption but doesn't support it !") |
| 885 | ShareFlags += "+ENCRYPT_DATA" |
| 886 | |
| 887 | self.vprint("Tree Connect on: %s" % tree_name) |
| 888 | self.send( |
| 889 | self.smb_header.copy() |
| 890 | / SMB2_Tree_Connect_Response( |
| 891 | ShareType="PIPE" if self.current_tree() == "IPC$" else "DISK", |
| 892 | ShareFlags=ShareFlags, |
| 893 | Capabilities=( |
| 894 | 0 if self.current_tree() == "IPC$" else self.TREE_CAPABILITIES |
| 895 | ), |
| 896 | MaximalAccess=self.TREE_MAXIMAL_ACCESS, |
| 897 | ) |
| 898 | ) |
| 899 | |
| 900 | @ATMT.receive_condition(SERVING) |
| 901 | def receive_ioctl(self, pkt): |
nothing calls this directly
no test coverage detected