Commits

George Notaras committed c132981

Modified function that sets filesystem permissions on a path

1. Function renamed from 'chown_chmod_path' to 'set_fs_permissions'
2. chmod occurs before chown

Comments (0)

Files changed (2)

src/TinyIDS/main.py

     
         # Set permissions and ownership on the logfile, if running as root
         if user:
-            process.chown_chmod_path(logfile, user, group, 0600)
+            process.set_fs_permissions(logfile, user, group, 0600)
         
         logger.info('tinyidsd normal startup')
         logger.debug('Logging to file: %s' % logfile)

src/TinyIDS/process.py

         raise UserError('User not found: %s' % user)
 
 
-def chown_chmod_path(path, user, group, mode):
+def set_fs_permissions(path, user, group, mode):
     """Sets permissions and ownership on path.
     
     This can only work only if the process has been started with root
     uid = pwd.getpwnam(user)[2]
     gid = grp.getgrnam(group)[2]
     
+    os.chmod(path, mode)
     os.chown(path, uid, gid)
-    os.chmod(path, mode)
+    
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.