File tree Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change 1111 but I no longer have a development environment set up for testing
1212 them, so I do not officially support them.
1313 - Shortcut initialization if it has run before.
14+ - Set hook log file permissions to be group-writable. (:bbissue: `62 `
15+ reported by :bbuser: `hedgeddown `)
1416
15172.10.1
1618
Original file line number Diff line number Diff line change @@ -17,6 +17,15 @@ test_set_by_user() {
1717 assertTrue " Log file was not created" " [ -f $WORKON_HOME /logs/hook.log ]"
1818}
1919
20+ test_file_permissions () {
21+ export VIRTUALENVWRAPPER_LOG_DIR=" $WORKON_HOME /logs"
22+ mkdir -p " $VIRTUALENVWRAPPER_LOG_DIR "
23+ source " $test_dir /../virtualenvwrapper.sh"
24+ perms=$( ls -l " $WORKON_HOME /logs/hook.log" | cut -f1 -d' ' )
25+ # echo $perms
26+ assertTrue " Log file permissions are wrong: $perms " " echo $perms | grep '^-rw-rw'"
27+ }
28+
2029test_not_set_by_user () {
2130 unset WORKON_HOME
2231 unset VIRTUALENVWRAPPER_LOG_DIR
Original file line number Diff line number Diff line change 1515
1616import pkg_resources
1717
18+ class GroupWriteRotatingFileHandler (logging .handlers .RotatingFileHandler ):
19+ """Taken from http://stackoverflow.com/questions/1407474/does-python-logging-handlers-rotatingfilehandler-allow-creation-of-a-group-writa
20+ """
21+ def _open (self ):
22+ prevumask = os .umask (0o002 )
23+ rtv = logging .handlers .RotatingFileHandler ._open (self )
24+ os .umask (prevumask )
25+ return rtv
26+
1827def main ():
1928 parser = optparse .OptionParser (
2029 usage = 'usage: %prog [options] <hook> [<arguments>]' ,
@@ -66,7 +75,7 @@ def main():
6675
6776 # Set up logging to a file
6877 root_logger .setLevel (logging .DEBUG )
69- file_handler = logging . handlers . RotatingFileHandler (
78+ file_handler = GroupWriteRotatingFileHandler (
7079 os .path .expandvars (os .path .join ('$VIRTUALENVWRAPPER_LOG_DIR' , 'hook.log' )),
7180 maxBytes = 10240 ,
7281 backupCount = 1 ,
You can’t perform that action at this time.
0 commit comments