def fixSetGroupID(childPath):
 if ((os.name == u'nt') or (os.name == u'ce')):
  return
 parentPath = os.path.dirname(childPath)
 parentStat = os.stat(parentPath)
 parentMode = stat.S_IMODE(parentStat[stat.ST_MODE])
 childPath = os.path.join(parentPath, os.path.basename(childPath))
 if (parentMode & stat.S_ISGID):
  parentGID = parentStat[stat.ST_GID]
  childStat = os.stat(childPath)
  childGID = childStat[stat.ST_GID]
  if (childGID == parentGID):
   return
  childPath_owner = childStat.st_uid
  user_id = os.geteuid()
  if ((user_id != 0) and (user_id != childPath_owner)):
   sickrage.srCore.srLogger.debug(((u'Not running as root or owner of ' + childPath) + u', not trying to set the set-group-ID'))
   return
  try:
   os.chown(childPath, (-1), parentGID)
   sickrage.srCore.srLogger.debug((u'Respecting the set-group-ID bit on the parent directory for %s' % childPath))
  except OSError:
   sickrage.srCore.srLogger.error((u'Failed to respect the set-group-ID bit on the parent directory for %s (setting group ID %i)' % (childPath, parentGID)))

def fixSetGroupID ( childPath ) : if ( ( os . name == u'nt' ) or ( os . name == u'ce' ) ) : return parentPath = os . path . dirname ( childPath ) parentStat = os . stat ( parentPath ) parentMode = stat . S_IMODE ( parentStat [ stat . ST_MODE ] ) childPath = os . path . join ( parentPath , os . path . basename ( childPath ) ) if ( parentMode & stat . S_ISGID ) : parentGID = parentStat [ stat . ST_GID ] childStat = os . stat ( childPath ) childGID = childStat [ stat . ST_GID ] if ( childGID == parentGID ) : return childPath_owner = childStat . st_uid user_id = os . geteuid ( ) if ( ( user_id != 0 ) and ( user_id != childPath_owner ) ) : sickrage . srCore . srLogger . debug ( ( ( u'Not running as root or owner of ' + childPath ) + u', not trying to set the set-group-ID' ) ) return try : os . chown ( childPath , ( - 1 ) , parentGID ) sickrage . srCore . srLogger . debug ( ( u'Respecting the set-group-ID bit on the parent directory for %s' % childPath ) ) except OSError : sickrage . srCore . srLogger . error ( ( u'Failed to respect the set-group-ID bit on the parent directory for %s (setting group ID %i)' % ( childPath , parentGID ) ) )
inherid sgid from parent .