Private GIT

Skip to content
Snippets Groups Projects
Commit b8937d80 authored by Patrick Vos's avatar Patrick Vos
Browse files

Add check if allowed to change permissions before changing permissions

On linux when download user and sickbeard user are not the same,
moving files will result in download user still owning the files.
When SickBeard tries to chmod permissions it results in error,
because only root or owner are allowed to do this.
Check if user is allowed to change permissions.
parent 2104a1b4
No related branches found
No related tags found
No related merge requests found
...@@ -446,6 +446,13 @@ def chmodAsParent(childPath): ...@@ -446,6 +446,13 @@ def chmodAsParent(childPath):
if childPath_mode == childMode: if childPath_mode == childMode:
return return
childPath_owner = os.stat(childPath).st_uid
user_id = os.geteuid()
if user_id !=0 and user_id != childPath_owner:
logger.log(u"Not running as root or owner of "+childPath+", not trying to set permissions", logger.DEBUG)
return
try: try:
ek.ek(os.chmod, childPath, childMode) ek.ek(os.chmod, childPath, childMode)
logger.log(u"Setting permissions for %s to %o as parent directory has %o" % (childPath, childMode, parentMode), logger.DEBUG) logger.log(u"Setting permissions for %s to %o as parent directory has %o" % (childPath, childMode, parentMode), logger.DEBUG)
...@@ -474,6 +481,13 @@ def fixSetGroupID(childPath): ...@@ -474,6 +481,13 @@ def fixSetGroupID(childPath):
if childGID == parentGID: if childGID == parentGID:
return return
childPath_owner = os.stat(childPath).st_uid
user_id = os.geteuid()
if user_id !=0 and user_id != childPath_owner:
logger.log(u"Not running as root or owner of "+childPath+", not trying to set the set-group-ID", logger.DEBUG)
return
try: try:
ek.ek(os.chown, childPath, -1, parentGID) #@UndefinedVariable - only available on UNIX ek.ek(os.chown, childPath, -1, parentGID) #@UndefinedVariable - only available on UNIX
logger.log(u"Respecting the set-group-ID bit on the parent directory for %s" % (childPath), logger.DEBUG) logger.log(u"Respecting the set-group-ID bit on the parent directory for %s" % (childPath), logger.DEBUG)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment