Browse Source

all remaining auth-*.erb templates using variables also

Xabier de Zuazo 11 years ago
parent
commit
1e4e37a74d

+ 20 - 20
attributes/auth.rb

@@ -15,24 +15,24 @@ default['dovecot']['auth']['checkpassword'] = nil
 # }
 
 default['dovecot']['auth']['system'] = {}
-default['dovecot']['auth']['system'] = {
-  'passdb' => [
-  {
-    'driver' => 'pam',
-    'args' => 'dovecot',
-  },
-  {
-    'driver' => 'passwd',
-    'args' => '',
-  },
-  {
-    'driver' => 'shadow',
-    'args' => '',
-  },
-  {
-    'driver' => 'bsdauth',
-    'args' => '',
-  },
-]
-}
+# default['dovecot']['auth']['system'] = {
+#   'passdb' => [
+#   {
+#     'driver' => 'pam',
+#     'args' => 'dovecot',
+#   },
+#   {
+#     'driver' => 'passwd',
+#     'args' => '',
+#   },
+#   {
+#     'driver' => 'shadow',
+#     'args' => '',
+#   },
+#   {
+#     'driver' => 'bsdauth',
+#     'args' => '',
+#   },
+# ]
+# }
 

+ 4 - 0
templates/default/conf.d/auth-deny.conf.ext.erb

@@ -5,6 +5,9 @@
 # The deny passdb should always be specified before others, so it gets
 # checked first.
 
+<% if Dovecot::Auth.has_passdb?(@auth['deny']) -%>
+<%=  Dovecot::Conf.authdb('passdb', @auth['deny']['passdb']) %>
+<% else -%>
 # Example deny passdb using passwd-file. You can use any passdb though.
 passdb {
   driver = passwd-file
@@ -13,3 +16,4 @@ passdb {
   # File contains a list of usernames, one per line
   args = /etc/dovecot/deny-users
 }
+<% end -%>

+ 8 - 0
templates/default/conf.d/auth-ldap.conf.ext.erb

@@ -2,13 +2,20 @@
 #
 # <doc/wiki/AuthDatabase.LDAP.txt>
 
+<% if Dovecot::Auth.has_passdb?(@auth['ldap']) -%>
+<%=  Dovecot::Conf.authdb('passdb', @auth['ldap']['passdb']) %>
+<% else -%>
 passdb {
   driver = ldap
 
   # Path for LDAP configuration file, see example-config/dovecot-ldap.conf.ext
   args = /etc/dovecot/dovecot-ldap.conf.ext
 }
+<% end -%>
 
+<% if Dovecot::Auth.has_userdb?(@auth['ldap']) -%>
+<%=  Dovecot::Conf.authdb('userdb', @auth['ldap']['userdb']) %>
+<% else -%>
 # "prefetch" user database means that the passdb already provided the
 # needed information and there's no need to do a separate userdb lookup.
 # <doc/wiki/UserDatabase.Prefetch.txt>
@@ -28,3 +35,4 @@ userdb {
   #driver = static
   #args = uid=vmail gid=vmail home=/var/vmail/%u
 #}
+<% end -%>

+ 4 - 0
templates/default/conf.d/auth-master.conf.ext.erb

@@ -4,6 +4,9 @@
 # of "master users", who can log in as anyone else.
 # <doc/wiki/Authentication.MasterUsers.txt>
 
+<% if Dovecot::Auth.has_passdb?(@auth['master']) -%>
+<%=  Dovecot::Conf.authdb('passdb', @auth['master']['passdb']) %>
+<% else -%>
 # Example master user passdb using passwd-file. You can use any passdb though.
 passdb {
   driver = passwd-file
@@ -14,3 +17,4 @@ passdb {
   # be looked up from passdb that it really exists. pass=yes does that.
   pass = yes
 }
+<% end -%>

+ 8 - 0
templates/default/conf.d/auth-passwdfile.conf.ext.erb

@@ -3,12 +3,20 @@
 # passwd-like file with specified location.
 # <doc/wiki/AuthDatabase.PasswdFile.txt>
 
+<% if Dovecot::Auth.has_passdb?(@auth['passwdfile']) -%>
+<%=  Dovecot::Conf.authdb('passdb', @auth['passwdfile']['passdb']) %>
+<% else -%>
 passdb {
   driver = passwd-file
   args = scheme=CRYPT username_format=%u /etc/dovecot/users
 }
+<% end -%>
 
+<% if Dovecot::Auth.has_userdb?(@auth['userwdfile']) -%>
+<%=  Dovecot::Conf.authdb('userdb', @auth['passwdfile']['userdb']) %>
+<% else -%>
 userdb {
   driver = passwd-file
   args = username_format=%u /etc/dovecot/users
 }
+<% end -%>

+ 8 - 0
templates/default/conf.d/auth-sql.conf.ext.erb

@@ -2,13 +2,20 @@
 #
 # <doc/wiki/AuthDatabase.SQL.txt>
 
+<% if Dovecot::Auth.has_passdb?(@auth['sql']) -%>
+<%=  Dovecot::Conf.authdb('passdb', @auth['sql']['passdb']) %>
+<% else -%>
 passdb {
   driver = sql
 
   # Path for SQL configuration file, see example-config/dovecot-sql.conf.ext
   args = /etc/dovecot/dovecot-sql.conf.ext
 }
+<% end -%>
 
+<% if Dovecot::Auth.has_userdb?(@auth['sql']) -%>
+<%=  Dovecot::Conf.authdb('userdb', @auth['sql']['userdb']) %>
+<% else -%>
 # "prefetch" user database means that the passdb already provided the
 # needed information and there's no need to do a separate userdb lookup.
 # <doc/wiki/UserDatabase.Prefetch.txt>
@@ -28,3 +35,4 @@ userdb {
   #driver = static
   #args = uid=vmail gid=vmail home=/var/vmail/%u
 #}
+<% end -%>

+ 8 - 0
templates/default/conf.d/auth-static.conf.ext.erb

@@ -8,6 +8,9 @@
 #  - authentication with SSL certificates
 #  - simple testing
 
+<% if Dovecot::Auth.has_passdb?(@auth['static']) -%>
+<%=  Dovecot::Conf.authdb('passdb', @auth['static']['passdb']) %>
+<% else -%>
 #passdb {
 #  driver = static
 #  args = proxy=y host=%1Mu.example.com nopassword=y
@@ -17,8 +20,13 @@
 #  driver = static
 #  args = password=test
 #}
+<% end -%>
 
+<% if Dovecot::Auth.has_userdb?(@auth['static']) -%>
+<%=  Dovecot::Conf.authdb('userdb', @auth['static']['userdb']) %>
+<% else -%>
 #userdb {
 #  driver = static
 #  args = uid=vmail gid=vmail home=/home/%u
 #}
+<% end -%>

+ 8 - 0
templates/default/conf.d/auth-system.conf.ext.erb

@@ -7,6 +7,9 @@
 # PAM is typically used with either userdb passwd or userdb static.
 # REMEMBER: You'll need /etc/pam.d/dovecot file created for PAM
 # authentication to actually work. <doc/wiki/PasswordDatabase.PAM.txt>
+<% if Dovecot::Auth.has_passdb?(@auth['system']) -%>
+<%=  Dovecot::Conf.authdb('passdb', @auth['system']['passdb']) %>
+<% else -%>
 passdb {
   driver = pam
   # [session=yes] [setcred=yes] [failure_show_msg=yes] [max_requests=<n>]
@@ -39,6 +42,7 @@ passdb {
   # [blocking=no] [cache_key=<key>]
   #args =
 #}
+<% end -%>
 
 ##
 ## User databases
@@ -46,6 +50,9 @@ passdb {
 
 # System users (NSS, /etc/passwd, or similiar). In many systems nowadays this
 # uses Name Service Switch, which is configured in /etc/nsswitch.conf.
+<% if Dovecot::Auth.has_userdb?(@auth['system']) -%>
+<%=  Dovecot::Conf.authdb('userdb', @auth['system']['userdb']) %>
+<% else -%>
 userdb {
   # <doc/wiki/AuthDatabase.Passwd.txt>
   driver = passwd
@@ -69,3 +76,4 @@ userdb {
   #
   #args =
 #}
+<% end -%>

+ 8 - 0
templates/default/conf.d/auth-vpopmail.conf.ext.erb

@@ -2,16 +2,24 @@
 #
 # <doc/wiki/AuthDatabase.VPopMail.txt>
 
+<% if Dovecot::Auth.has_passdb?(@auth['vpopmail']) -%>
+<%=  Dovecot::Conf.authdb('passdb', @auth['vpopmail']['passdb']) %>
+<% else -%>
 passdb {
   driver = vpopmail
 
   # [cache_key=<key>] [webmail=<ip>]
   args =
 }
+<% end -%>
 
+<% if Dovecot::Auth.has_userdb?(@auth['vpopmail']) -%>
+<%=  Dovecot::Conf.authdb('userdb', @auth['vpopmail']['userdb']) %>
+<% else -%>
 userdb {
   driver = vpopmail
 
   # [quota_template=<template>] - %q expands to Maildir++ quota
   args = quota_template=quota_rule=*:backend=%q
 }
+<% end -%>