Jon McKenzie
unread,Sep 9, 2012, 1:46:10 PM9/9/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to puppet...@googlegroups.com
Hi,
I'm just trying to get an idea about the best way to implement this:
I want a type that uses the 'semanage' binary to manage targeted policy (in this case for files).
So for example to create a targeted policy, I might do something like:
semanage fcontext -a -f -d -t some_domain_t "/path/to/files(/.*)?"
... which would add a target policy that sets 'some_domain_t' on all directories in "/path/to/files/"
The question I have is about the "-d", which is a parameter to "-f", that directs policy to only cover directories (e.g. "-d" is for directories, "--" is for regular files, "-s" is for sockets, etc. -- see the help for semanage for the rest).
I want a property called :filetype that can have a value of :file, :directory, :all, :socket, :character, :block, etc. Once I get valid input, I want to convert the value to the appropriate flag for the command. What's the best way to do this?
My current idea is to accept any input, and then have a case switch inside of a munge block, e.g.:
munge do |value|
case value
when "file"
value = "--"
when "directory"
value = "-d"
... etc..
end
end
Is this the "correct" way to implement this? Should this even be in the type definition (since these are details of the provider)?
Thanks for your help,
Jon