lib/ezmlm/list.rb
changeset 28 99fdbf4a5f37
parent 26 a89d91d4b157
equal deleted inserted replaced
27:a629597fd647 28:99fdbf4a5f37
     1 #!/usr/bin/ruby
     1 #!/usr/bin/ruby
     2 # vim: set nosta noet ts=4 sw=4:
     2 # vim: set nosta noet ts=4 sw=4:
     3 
       
     4 
     3 
     5 require 'pathname'
     4 require 'pathname'
     6 require 'time'
     5 require 'time'
     7 require 'etc'
     6 require 'etc'
     8 require 'ezmlm' unless defined?( Ezmlm )
     7 require 'ezmlm' unless defined?( Ezmlm )
    12 #
    11 #
    13 #    list = Ezmlm::List.new( '/path/to/listdir' )
    12 #    list = Ezmlm::List.new( '/path/to/listdir' )
    14 #
    13 #
    15 #---
    14 #---
    16 class Ezmlm::List
    15 class Ezmlm::List
    17 	#  $Id$
    16 	#  $Id: list.rb,v a89d91d4b157 2017/06/23 17:54:26 mahlon $
    18 
    17 
    19 	# Valid subdirectories/sections for subscriptions.
    18 	# Valid subdirectories/sections for subscriptions.
    20 	SUBSCRIPTION_DIRS = %w[ deny mod digest allow ]
    19 	SUBSCRIPTION_DIRS = %w[ deny mod digest allow ]
    21 
    20 
    22 
    21 
   822 	###
   821 	###
   823 	### All writes should be wrapped in this method.
   822 	### All writes should be wrapped in this method.
   824 	###
   823 	###
   825 	def with_safety( &block )
   824 	def with_safety( &block )
   826 		home = self.homedir
   825 		home = self.homedir
   827 		mode = home.stat.mode
   826 		home.chmod( home.stat.mode | 01000 ) # enable sticky
   828 
       
   829 		home.chmod( mode | 01000 ) # enable sticky
       
   830 		yield
   827 		yield
   831 
   828 
   832 	ensure
   829 	ensure
   833 		home.chmod( mode )
   830 		home.chmod( home.stat.mode & ~01000 ) # disable sticky
   834 	end
   831 	end
   835 
   832 
   836 end # class Ezmlm::List
   833 end # class Ezmlm::List
   837 
   834