diff options
| author | Joey Hess <joeyh@joeyh.name> | 2015-11-26 09:48:42 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2015-11-26 09:50:00 -0400 |
| commit | 1ae0ca973d5e3dace1dd7dc881e0266ced344978 (patch) | |
| tree | ab1327da55fc2acd5dc01a7d01facff3e44869e1 /src/Propellor/Property/Fail2Ban.hs | |
| parent | f736486013ba3d317cac808f490c1bfa956605f4 (diff) | |
Added Propellor.Property.Fail2Ban.
Diffstat (limited to 'src/Propellor/Property/Fail2Ban.hs')
| -rw-r--r-- | src/Propellor/Property/Fail2Ban.hs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/Propellor/Property/Fail2Ban.hs b/src/Propellor/Property/Fail2Ban.hs new file mode 100644 index 00000000..716d376f --- /dev/null +++ b/src/Propellor/Property/Fail2Ban.hs @@ -0,0 +1,30 @@ +module Propellor.Property.Fail2Ban where + +import Propellor.Base +import qualified Propellor.Property.Apt as Apt +import qualified Propellor.Property.Service as Service +import Propellor.Property.ConfFile + +installed :: Property NoInfo +installed = Apt.serviceInstalledRunning "fail2ban" + +reloaded :: Property NoInfo +reloaded = Service.reloaded "fail2ban" + +type Jail = String + +-- | By default, fail2ban only enables the ssh jail, but many others +-- are available to be enabled, for example "postfix-sasl" +jailEnabled :: Jail -> Property NoInfo +jailEnabled name = jailConfigured name "enabled" "true" + `onChange` reloaded + +-- | Configures a jail. For example: +-- +-- > jailConfigured "sshd" "port" "2222" +jailConfigured :: Jail -> IniKey -> String -> Property NoInfo +jailConfigured name key value = + jailConfFile name `containsIniSetting` (name, key, value) + +jailConfFile :: Jail -> FilePath +jailConfFile name = "/etc/fail2ban/jail.d/" ++ name ++ ".conf" |
