-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
find_media_errors.py: ini file match ownership and permissions of med…
…ia file
- Loading branch information
Showing
8 changed files
with
46 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import logging | ||
import os | ||
import stat | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def match_owner_and_perm(target_path: str, source_path: str) -> bool: | ||
result = True | ||
source_stat = os.stat(source_path) | ||
try: | ||
os.chown(target_path, source_stat.st_uid, source_stat.st_gid) | ||
except OSError: | ||
logger.warning(f"Changing ownership of {target_path} failed, continuing") | ||
result = False | ||
|
||
try: | ||
st_mode = source_stat.st_mode | ||
# if source is dir and has suid or guid and target is a file, mask suid/guid | ||
if os.path.isfile(target_path): | ||
st_mode &= ~(stat.S_ISUID | stat.S_ISGID | 0o111) | ||
os.chmod(target_path, st_mode) | ||
except OSError: | ||
logger.warning(f"Changing permission of {target_path} failed, continuing") | ||
result = False | ||
|
||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters