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 11
11
but I no longer have a development environment set up for testing
12
12
them, so I do not officially support them.
13
13
- Shortcut initialization if it has run before.
14
+ - Set hook log file permissions to be group-writable. (:bbissue: `62 `
15
+ reported by :bbuser: `hedgeddown `)
14
16
15
17
2.10.1
16
18
Original file line number Diff line number Diff line change @@ -17,6 +17,15 @@ test_set_by_user() {
17
17
assertTrue " Log file was not created" " [ -f $WORKON_HOME /logs/hook.log ]"
18
18
}
19
19
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
+
20
29
test_not_set_by_user () {
21
30
unset WORKON_HOME
22
31
unset VIRTUALENVWRAPPER_LOG_DIR
Original file line number Diff line number Diff line change 15
15
16
16
import pkg_resources
17
17
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
+
18
27
def main ():
19
28
parser = optparse .OptionParser (
20
29
usage = 'usage: %prog [options] <hook> [<arguments>]' ,
@@ -66,7 +75,7 @@ def main():
66
75
67
76
# Set up logging to a file
68
77
root_logger .setLevel (logging .DEBUG )
69
- file_handler = logging . handlers . RotatingFileHandler (
78
+ file_handler = GroupWriteRotatingFileHandler (
70
79
os .path .expandvars (os .path .join ('$VIRTUALENVWRAPPER_LOG_DIR' , 'hook.log' )),
71
80
maxBytes = 10240 ,
72
81
backupCount = 1 ,
You can’t perform that action at this time.
0 commit comments