diff --git a/lib/puppet/provider/s3ql_mount/s3ql_mount.rb b/lib/puppet/provider/s3ql_mount/s3ql_mount.rb index 1847866..1320a1b 100644 --- a/lib/puppet/provider/s3ql_mount/s3ql_mount.rb +++ b/lib/puppet/provider/s3ql_mount/s3ql_mount.rb @@ -50,8 +50,11 @@ def commands_wrapper(command, *arguments) Puppet::Util::Execution.execute([command, all_args], opts) end + # TODO: This *arguments paramether is kinda pointless def mount_s3ql(*arguments) - mount_args = ['--allow-other', '--metadata-upload-interval', + allow_other = '' + allow_other = '--allow-other' if @resource[:allow_other] + mount_args = [allow_other, '--metadata-upload-interval', @resource[:upload_inverval], arguments].flatten begin commands_wrapper('mount.s3ql', mount_args) @@ -86,10 +89,23 @@ def self.instances mounts.map do |mnt| storage_url, _, mountpoint, _, _, options = mnt.split - owner = options.sub(%r{.*user(_id)?=([^,)]+).*}, '\2') if options =~ %r{user(_id)?} + opts_hsh = options.split(',').map { |o| + k = o + v = true + if o.include?('=') + k, v = split('=') + end + [k, v] + }.to_h + + owner = opts_hsh['user'] + owner ||= opts_hsh['user_id'] owner ||= 0 - group = options.sub(%r{.*group(_id)?=([^,)]).*}, '\2') if options =~ %r{group(_id)?} + group = opts_hsh['group'] + group ||= opts_hsh['group_id'] group ||= 0 + allow_other = opts_hsh['allow_other'] + allow_other ||= false # and initialize @property_hash new(name: mountpoint, @@ -98,7 +114,8 @@ def self.instances storage_url: storage_url, owner: owner, group: group, - backend: storage_url.split(':')[0]) + backend: storage_url.split(':')[0], + allow_other: allow_other) end end diff --git a/lib/puppet/type/s3ql_mount.rb b/lib/puppet/type/s3ql_mount.rb index 530afdb..fcbbe1e 100644 --- a/lib/puppet/type/s3ql_mount.rb +++ b/lib/puppet/type/s3ql_mount.rb @@ -114,6 +114,19 @@ end end + newproperty(:allow_other) do + desc <<-EOS + Whether to allow "other" to access this mountpoint + + The default is `false`. To allow it, also make sure to set `allow_other` in `s3ql`. + EOS + defaultto :false + munge do |val| + :false if [false, 'false', :false].include? val + :true if [true, 'true', :true].include? val + end + end + newproperty(:backend) do desc <<-EOS The backend used. diff --git a/manifests/init.pp b/manifests/init.pp index 77a6212..66ffebe 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -7,6 +7,7 @@ $package_name = 's3ql', $package_ensure = 'present', $package_provider = undef, + $allow_other = false, ) { package { 's3ql': @@ -14,4 +15,12 @@ name => $package_name, provider => $package_provider, } + + if $allow_other { + file_line { "user_allow_other ${allow_other}": + path => '/etc/fuse.conf', + line => 'user_allow_other', + match => '^#user_allow_other' + } + } } diff --git a/spec/unit/provider/s3ql_mount/s3ql_mount.rb b/spec/unit/provider/s3ql_mount/s3ql_mount.rb index cd0fe6d..fb67964 100644 --- a/spec/unit/provider/s3ql_mount/s3ql_mount.rb +++ b/spec/unit/provider/s3ql_mount/s3ql_mount.rb @@ -11,6 +11,7 @@ storage_url: 'gs://bucket/prefix', owner: 'examplewww', group: 'examplewww', + allow_other: true, ) end diff --git a/spec/unit/type/s3ql_mount_spec.rb b/spec/unit/type/s3ql_mount_spec.rb index f476354..243406d 100644 --- a/spec/unit/type/s3ql_mount_spec.rb +++ b/spec/unit/type/s3ql_mount_spec.rb @@ -19,6 +19,7 @@ :owner, :group, :backend, + :allow_other, ] end let :parameters do