Module: Temppath::SecurePermissionMethods
- Defined in:
- lib/temppath.rb
Overview
SecurePermissionMethods provides some Pathname methods with secure default permission.
Instance Method Summary collapse
-
#mkdir(*args) ⇒ Object
Make a directory with permission 0700 by defautl.
-
#mkpath(*args) ⇒ Object
Make paths with permission 0700 by defautl.
-
#open(*args, &b) ⇒ Object
Open file with permission 0600 by default.
-
#sysopen(*args) ⇒ Object
Open file with permission 0600 by default.
Instance Method Details
#mkdir(*args) ⇒ Object
Make a directory with permission 0700 by defautl. Otherwise, this is same as Pathname#mkdir.
61 62 63 64 |
# File 'lib/temppath.rb', line 61 def mkdir(*args) args[0] = 0700 unless args[0] orig_mkdir(*args) end |
#mkpath(*args) ⇒ Object
Make paths with permission 0700 by defautl. Otherwise, this is same as Pathname#mkpath.
68 69 70 71 72 |
# File 'lib/temppath.rb', line 68 def mkpath(*args) args[0] = {} unless args[0] args[0] = args[0].merge(mode: 0700) unless args[0][:mode] FileUtils.mkpath(self.to_s, *args) end |
#open(*args, &b) ⇒ Object
Open file with permission 0600 by default. Otherwise, this is same as Pathname#open.
54 55 56 57 |
# File 'lib/temppath.rb', line 54 def open(*args, &b) args[1] = 0600 unless args[1] orig_open(*args, &b) end |
#sysopen(*args) ⇒ Object
Open file with permission 0600 by default. Otherwise, this is same as Pathname#sysopen.
76 77 78 79 |
# File 'lib/temppath.rb', line 76 def sysopen(*args) args[1] = 0600 unless args[1] orig_sysopen(*args) end |