def get_id(self, entry): checksum = crc32(dn_to_domain(self.parameters['base_dn'])) if 'entryUUID' in entry: return get(entry, 'entryUUID') if 'uidNumber' in entry: return str(uuid2(checksum, int(get(entry, 'uidNumber')))) if 'gidNumber' in entry: return str(uuid2(checksum, int(get(entry, 'gidNumber')))) return str(uuid.uuid4())
def get_id(self, entry): checksum = crc32(dn_to_domain(self.parameters['base_dn'])) if 'entryUUID' in entry: return get(entry, 'entryUUID.0') if 'uidNumber' in entry: return str(uuid2(checksum, int(get(entry, 'uidNumber.0')))) if 'gidNumber' in entry: return str(uuid2(checksum, int(get(entry, 'gidNumber.0')))) return str(uuid.uuid4())
def getgruuid(self, id): logger.debug('getgruuid(uuid={0})'.format(id)) try: checksum, gid = parse_uuid2(id) if crc32(dn_to_domain(self.base_dn)) != checksum: return None q = '(gidNumber={0})'.format(gid) except ValueError: q = '(entryUUID={0})'.format(id) group = self.search_one(self.group_dn, q) return self.convert_group(group)
def getpwuuid(self, id): logger.debug('getpwuuid(uuid={0})'.format(id)) try: checksum, uid = parse_uuid2(id) if crc32(dn_to_domain(self.base_dn)) != checksum: return None q = '(uidNumber={0})'.format(uid) except ValueError: q = '(entryUUID={0})'.format(id) user = self.search_one(self.user_dn, q) return self.convert_user(user)
utils.appendFile(outputChunk, binPart) header.write('\n'.encode()) header.write('# Header suffix'.encode()) header.write(headerScriptSuffix.encode()) header.write('\n'.encode()) header.write('% <- this is end of file symbol\n'.encode()) header.flush() print('[i] Fill header script to 16KB') header.write(('\xff' * (HEADER_SIZE - os.path.getsize(headerPart))).encode( encoding='iso-8859-1')) print('[i] Generating footer ...') headerCRC = utils.crc32(headerPart) binCRC = utils.crc32(binPart) header16bytes = utils.loadPart(headerPart, 0, 16) with open(footerPart, 'wb') as footer: print('[i] Magic: {}'.format(MAGIC_FOOTER)) footer.write(MAGIC_FOOTER.encode()) print('[i] Header CRC: 0x{:02X}'.format(headerCRC)) footer.write(struct.pack( 'L', headerCRC)) # struct.pack('L', data) <- returns byte swapped data print('[i] Bin CRC: 0x{:02X}'.format(binCRC)) footer.write(struct.pack('L', binCRC)) print('[i] First 16 bytes of header: {}'.format(header16bytes)) footer.write(header16bytes) print('[i] Merging header, bin, footer ...') open(firmwareFileName, 'w').close()
header.write('\n'.encode()) header.write('# File Partition: set_config'.encode()) header.write(headerScriptSuffix.encode()) header.write('\n'.encode()) header.write('% <- this is end of file symbol\n'.encode()) header.flush() print ('[i] Fill header script to 16KB') header.write( ('\xff' * (HEADER_SIZE - os.path.getsize(headerPart))).encode(encoding='iso-8859-1') ) print ('[i] Generating footer ...') if (XGIMI_CRC): # NB XGIMI uses HEADER+BIN+MAGIC+HEADER_CRC to calculate crc2 headerCRC = utils.crc32(headerPart) header16bytes = utils.loadPart(headerPart, 0, 16) binCRC = utils.crc32(binPart) # Step #1. Merge HEADER+BIN+MAGIC+HEADER_CRC to one file mergedPart = os.path.join(tmpDir, '~merged') open(mergedPart, 'w').close() utils.appendFile(headerPart, mergedPart) utils.appendFile(binPart, mergedPart) with open(mergedPart, 'ab') as part: # If PB803 CRC type selected then adding BIN_CRC to the merged file if (PB803_CRC): print ('[i] Bin CRC : 0x{:02X}'.format(binCRC)) part.write(struct.pack('L', binCRC)) print ('[i] Magic : {}'.format(MAGIC_FOOTER)) part.write(MAGIC_FOOTER.encode())