Skip to content

Commit 8812f26

Browse files
committed
[core] Make sure we set the setgid bit on created folders
1 parent bde64b0 commit 8812f26

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

meshroom/core/node.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import json
77
import logging
88
import os
9+
import stat
910
import platform
1011
import re
1112
import shutil
@@ -569,6 +570,7 @@ def saveStatusFile(self):
569570
statusFilepath = self.getStatusFile()
570571
folder = os.path.dirname(statusFilepath)
571572
os.makedirs(folder, exist_ok=True)
573+
os.chmod(folder, os.stat(folder).st_mode | stat.S_ISGID) # Add setgid on folder
572574

573575
statusFilepathWriting = getWritingFilepath(statusFilepath)
574576
with open(statusFilepathWriting, 'w') as jsonFile:
@@ -611,6 +613,7 @@ def saveStatistics(self):
611613
statisticsFilepath = self.getStatisticsFile()
612614
folder = os.path.dirname(statisticsFilepath)
613615
os.makedirs(folder, exist_ok=True)
616+
os.chmod(folder, os.stat(folder).st_mode | stat.S_ISGID) # Add setgid on folder
614617
statisticsFilepathWriting = getWritingFilepath(statisticsFilepath)
615618
with open(statisticsFilepathWriting, 'w') as jsonFile:
616619
json.dump(data, jsonFile, indent=4)
@@ -1650,6 +1653,7 @@ def upgradeStatusFile(self):
16501653
statusFilepath = self.nodeStatusFile
16511654
folder = os.path.dirname(statusFilepath)
16521655
os.makedirs(folder, exist_ok=True)
1656+
os.chmod(folder, os.stat(folder).st_mode | stat.S_ISGID) # Add setgid on folder
16531657
statusFilepathWriting = getWritingFilepath(statusFilepath)
16541658
with open(statusFilepathWriting, 'w') as jsonFile:
16551659
json.dump(data, jsonFile, indent=4)

meshroom/ui/graph.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import logging
44
import os
55
import re
6+
import stat
67
import json
78
from enum import Enum
89
from threading import Thread, Event, Lock
@@ -490,8 +491,10 @@ def loadGraph(self, filepath):
490491
g = Graph("")
491492
if filepath:
492493
g.load(filepath)
493-
if not os.path.exists(g.cacheDir):
494-
os.mkdir(g.cacheDir)
494+
cacheDir = g.cacheDir
495+
if not os.path.exists(cacheDir):
496+
os.mkdir(cacheDir)
497+
os.chmod(cacheDir, os.stat(cacheDir).st_mode | stat.S_ISGID) # Add setgid on folder
495498
self.setGraph(g)
496499

497500
@Slot(str)

0 commit comments

Comments
 (0)