A class used to define a share, used by SMB_Server :param name: the share name :param path: the path the the folder hosted by the share :param type: (optional) share type per [MS-SRVS] sect 2.2.2.4 :param remark: (optional) a description of the share :param encryptdata: (op
| 151 | |
| 152 | |
| 153 | class SMBShare: |
| 154 | """ |
| 155 | A class used to define a share, used by SMB_Server |
| 156 | |
| 157 | :param name: the share name |
| 158 | :param path: the path the the folder hosted by the share |
| 159 | :param type: (optional) share type per [MS-SRVS] sect 2.2.2.4 |
| 160 | :param remark: (optional) a description of the share |
| 161 | :param encryptdata: (optional) whether encryption should be used for this |
| 162 | share. This only applies to SMB 3.1.1. |
| 163 | """ |
| 164 | |
| 165 | def __init__(self, name, path=".", type=None, remark="", encryptdata=False): |
| 166 | # Set the default type |
| 167 | if type is None: |
| 168 | type = 0 # DISKTREE |
| 169 | if name.endswith("$"): |
| 170 | type &= 0x80000000 # SPECIAL |
| 171 | # Lower case the name for resolution |
| 172 | self._name = name.lower() |
| 173 | # Resolve path |
| 174 | self.path = pathlib.Path(path).resolve() |
| 175 | # props |
| 176 | self.name = name |
| 177 | self.type = type |
| 178 | self.remark = remark |
| 179 | self.encryptdata = encryptdata |
| 180 | |
| 181 | def __repr__(self): |
| 182 | type = SRVSVC_SHARE_TYPES[self.type & 0x0FFFFFFF] |
| 183 | if self.type & 0x80000000: |
| 184 | type = "SPECIAL+" + type |
| 185 | if self.type & 0x40000000: |
| 186 | type = "TEMPORARY+" + type |
| 187 | return "<SMBShare %s [%s]%s = %s>" % ( |
| 188 | self.name, |
| 189 | type, |
| 190 | self.remark and (" '%s'" % self.remark) or "", |
| 191 | str(self.path), |
| 192 | ) |
| 193 | |
| 194 | |
| 195 | # The SMB Automaton |