Fix ticket #907: mknod fails due to path not found

ticket-769
Vadim vtroshchinskiy 2024-10-09 09:23:08 +02:00
parent a3874084b2
commit 360120b1f0
1 changed files with 7 additions and 4 deletions

View File

@ -1253,13 +1253,16 @@ class OpengnsysGitLibrary:
os.mknod(full_path, mode = file_mode, device = data['rdev'])
else:
self.logger.warning(f"Unknown file type for {filename}: {file_mode}")
# chown clears suid bit, so even though it's redundant in most cases and already
# done above, set the full perms on the file again anyway.
os.chown(full_path, data['uid'], data['gid'])
os.chmod(full_path, file_mode)
except FileExistsError as exists:
self.logger.debug(f"Exists: {full_path}")
except OSError as oserr:
self.logger.warning(f"Failed to create special file {full_path}: Error {oserr.errno}: {oserr.strerror}")
# chown clears suid bit, so even though it's redundant in most cases and already
# done above, set the full perms on the file again anyway.
os.chown(full_path, data['uid'], data['gid'])
os.chmod(full_path, file_mode)
self.logger.info("Metadata restoration completed.")