return chunks
+#------------------------------------------------------------------------
+
+def email_valid(address):
+ '''
+ Simple Check for E-Mail addresses
+
+ @param address: the mail address to check
+ @type address: str
+
+ @return: Validity of the given mil address
+ @rtype: bool
+ '''
+
+ if address is None:
+ return False
+
+ adr = str(address)
+ if adr is None or adr == '':
+ return False
+
+ pattern = r'^[a-z0-9._%-+]+@[a-z0-9._%-]+.[a-z]{2,6}$'
+ if re.search(pattern, adr, re.IGNORECASE) is None:
+ return False
+
+ return True
+
#========================================================================
if __name__ == "__main__":
import os
import os.path
-from LogRotateCommon import split_parts
+from LogRotateCommon import split_parts, email_valid
revision = '$Revision$'
revision = re.sub( r'\$', '', revision )
match = re.search(r'^(not?)?mail$', option, re.IGNORECASE)
if match:
negated = match.group(1)
+ if negated:
+ directive['mailaddress'] = None
+ if val is not None and val != '':
+ self.logger.warning(
+ ( _("Senseless option value »%s« after »%s«.")
+ % (val, option.lower())
+ )
+ )
+ return False
+ return True
+ if not email_valid(val):
+ directive['mailaddress'] = None
+ self.logger.warning( ( _("Invalid Mail address »%s«.") % (val)))
+ return False
+ directive['mailaddress'] = val
+ if self.verbose > 4:
+ self.logger.debug(
+ ( _("Setting mail address to »%s«. (file »%s«, line %s)")
+ % (val, filename, linenr)
+ )
+ )
+ return True
+
+ # Check for mailfirst/maillast
+ match = re.search(r'^mail(first|last)$', option, re.IGNORECASE)
+ if match:
+ when = match.group(1).lower()
+ option_value = False
+ if when == 'first':
+ option_value = True
+ directive['mailfirst'] = option_value
+ if self.verbose > 4:
+ self.logger.debug(
+ ( _("Setting mailfirst to »%s«. (file »%s«, line %s)")
+ % (str(option_value), filename, linenr)
+ )
+ )
+ if val is not None and val != '':
+ self.logger.warning(
+ ( _("Senseless option value »%s« after »%s«.")
+ % (val, option.lower())
+ )
+ )
+ return False
+ return True
+
return True
--- /dev/null
+# Apache2 logrotate snipet for Gentoo Linux
+# Contributes by Chuck Short
+#
+
+/var/log/apache2/access_log
+/var/log/apache2/*.log
+{
+ missingok
+ notifempty
+ sharedscripts
+ rotate 10
+ error bla
+ weekly
+ size 1m
+ mail test@uhu-banane.de
+ olddir /var/log/apache2/%Y-%m
+ postrotate
+ /etc/init.d/apache2 reload > /dev/null 2>&1 || true
+ endscript
+}
+