From 563a44ff2890d45f1ab04f75cf7f61f45ef2111c Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Sat, 16 Oct 2010 23:52:11 +0200 Subject: [PATCH] [remaster/mcs] some more MCS stuff --- remaster/mcs/mcs-functions.sh | 34 +- remaster/mcs/mmt_scripts/config.sh | 22 + remaster/mcs/mmt_scripts/deliver.sh | 65 ++ remaster/mcs/mmt_scripts/emailpush.pl | 56 ++ remaster/mcs/mmt_scripts/schedulebe.py | 379 +++++++++ remaster/mcs/mwsql.sql | 3 + .../postfix/ldapconf/ldap_internal_forward.cf | 7 + .../ldapconf/ldap_internal_mx_reject.cf | 8 + .../postfix/ldapconf/ldap_internaldomains.cf | 6 + .../postfix/ldapconf/ldap_internalmailbox.cf | 7 + .../mcs/postfix/ldapconf/ldap_policygroup.cf | 8 + .../postfix/ldapconf/ldap_sender_mismatch.cf | 8 + remaster/mcs/postfix/main.cf | 732 ++++++++++++++++++ remaster/mcs/postfix/master.cf | 111 +++ ...aster_generic_inner_chroot_script_after.sh | 5 + .../remaster_mcs_inner_chroot_script_after.sh | 56 +- 16 files changed, 1493 insertions(+), 14 deletions(-) create mode 100755 remaster/mcs/mmt_scripts/config.sh create mode 100755 remaster/mcs/mmt_scripts/deliver.sh create mode 100755 remaster/mcs/mmt_scripts/emailpush.pl create mode 100755 remaster/mcs/mmt_scripts/schedulebe.py create mode 100644 remaster/mcs/postfix/ldapconf/ldap_internal_forward.cf create mode 100644 remaster/mcs/postfix/ldapconf/ldap_internal_mx_reject.cf create mode 100644 remaster/mcs/postfix/ldapconf/ldap_internaldomains.cf create mode 100644 remaster/mcs/postfix/ldapconf/ldap_internalmailbox.cf create mode 100644 remaster/mcs/postfix/ldapconf/ldap_policygroup.cf create mode 100644 remaster/mcs/postfix/ldapconf/ldap_sender_mismatch.cf create mode 100644 remaster/mcs/postfix/main.cf create mode 100644 remaster/mcs/postfix/master.cf diff --git a/remaster/mcs/mcs-functions.sh b/remaster/mcs/mcs-functions.sh index f5eccbd..540ef96 100755 --- a/remaster/mcs/mcs-functions.sh +++ b/remaster/mcs/mcs-functions.sh @@ -1,6 +1,15 @@ #!/bin/bash -setup_fds() { +_is_live() { + cdroot=$(cat /proc/cmdline | grep cdroot) + if [ -n "${cdroot}" ]; then + return 0 + else + return 1 + fi +} + +_setup_fds_live() { # setup 389-ds tmp_config_file="$(mktemp)" echo "[General] @@ -27,7 +36,26 @@ ServerAdminPwd=mcsmanager # FIXME: calling the script directly, from init, won't work, WTF! su - -c "/usr/sbin/setup-ds-admin.pl -f ${tmp_config_file} --silent" || return 1 echo "389 Directory Server configured." - /etc/init.d/389-ds stop --nodeps &> /dev/null - /etc/init.d/389-admin stop --nodeps &> /dev/null return 0 } + +FDS_SETUP_FILE="/etc/.389-sabayon-configured" + +_setup_fds_installed() { + if [ -e "${FDS_SETUP_FILE}" ]; then + return + fi + # First, setup 389 + _setup_fds_live + # then make it autostart at the next boot + rc-update add 389-ds default + rc-update add 389-admin default + # do the whole thing once + touch "${FDS_SETUP_FILE}" +} + + +setup_fds() { + # setup 389 + ( _is_live && _setup_fds_live ) || _setup_fds_installed +} diff --git a/remaster/mcs/mmt_scripts/config.sh b/remaster/mcs/mmt_scripts/config.sh new file mode 100755 index 0000000..75ad61b --- /dev/null +++ b/remaster/mcs/mmt_scripts/config.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +EMAILPUSH_HOSTNAME="mmt-l-fl13-prv.mymessagingtop.it,mmt-l-fl14-prv.mymessagingtop.it" +EMAILPUSH_PORTNO="4242" +EMAILPUSH_PREFIX="PREFIX" + +INSPECT_DIR="/var/spool/filter" +DELIVER="/usr/libexec/dovecot/deliver" +#DELIVER="/opt/dovecot-1.2.8/libexec/dovecot/deliver" +EMAILPUSH="/usr/local/mmt_scripts/emailpush.pl" +SCHEDULEBE="/usr/local/mmt_scripts/schedulebe.py" +LOGGER_FACILITY="mail" +LOGGER_PRIORITY="info" +LOGGER_PROGRAM_NAME="deliver.sh" + +# Exit codes from +EX_TEMPFAIL=75 +EX_UNAVAILABLE=69 + +SCHEDULEBE_URL="http://localhost:8080/pubcaldav/rtsvc" +SCHEDULEBE_USERNAME="caladmin" +SCHEDULEBE_PASSWORD="caladmin" diff --git a/remaster/mcs/mmt_scripts/deliver.sh b/remaster/mcs/mmt_scripts/deliver.sh new file mode 100755 index 0000000..820e926 --- /dev/null +++ b/remaster/mcs/mmt_scripts/deliver.sh @@ -0,0 +1,65 @@ +#!/bin/sh + +# Simple shell-based filter. It is meant to be invoked as follows: +# /path/to/script -f sender recipients... + +#INSPECT_DIR="/var/spool/filter" +#DELIVER="/usr/libexec/dovecot/deliver" +#EMAILPUSH="/usr/local/mmt_scripts/emailpush.pl" +#SCHEDULEBE="/usr/local/mmt_scripts/schedulebe.py" +#LOGGER_FACILITY="mail" +#LOGGER_PRIORITY="info" +#LOGGER_PROGRAM_NAME="deliver.sh" + +# Exit codes from +#EX_TEMPFAIL=75 +#EX_UNAVAILABLE=69 + +source /usr/local/mmt_scripts/config.sh +if [ $? -ne 0 ]; then exit 75; fi + +COMMAND=$(which echo); if [ $? -ne 0 ] || [ ! -x $COMMAND ]; then echo "echo command doesn't exist"; exit $EX_TEMPFAIL;fi +COMMAND=$(which cut); if [ $? -ne 0 ] || [ ! -x $COMMAND ]; then echo "cut command doesn't exist"; exit $EX_TEMPFAIL;fi +COMMAND=$(which cat); if [ $? -ne 0 ] || [ ! -x $COMMAND ]; then echo "cat command doesn't exist"; exit $EX_TEMPFAIL;fi +COMMAND=$(which egrep); if [ $? -ne 0 ] || [ ! -x $COMMAND ]; then echo "egrep command doesn't exist"; exit $EX_TEMPFAIL;fi +COMMAND=$(which grep); if [ $? -ne 0 ] || [ ! -x $COMMAND ]; then echo "grep command doesn't exist"; exit $EX_TEMPFAIL;fi +COMMAND=$(which logger); if [ $? -ne 0 ] || [ ! -x $COMMAND ]; then echo "logger command doesn't exist"; exit $EX_TEMPFAIL;fi + +# Clean up when done or when aborting. +trap "rm -f in.$$" 0 1 2 3 15 + +# Start processing. +cd $INSPECT_DIR || { + echo $INSPECT_DIR does not exist; exit $EX_TEMPFAIL; } + +cat >in.$$ || { + echo Cannot save mail to file $UID; exit $EX_TEMPFAIL; } + +LINE=$(egrep -m 1 "by.+with.+[0-9A-Fa-f]+$" in.$$) +HEX=$(echo $LINE | egrep -o " id [0-9A-Fa-f]+$" | cut -d " " -f 3) +if [ -z $HEX ]; then + LINE=$(egrep -m 1 "id [0-9A-Fa-f]+;.+" in.$$) + HEX=$(echo $LINE | egrep -o "id [0-9A-Fa-f]+" | cut -d " " -f 2) +fi + +grep -P "^X-MW-Scheduler:\scalendar.myplace.edu$" in.$$ +if [ $? -ne 0 ]; then + #SCHEDULEBE_OUT=$(cat in.$$ | $SCHEDULEBE -U $SCHEDULEBE_URL -u $SCHEDULEBE_USERNAME -p $SCHEDULEBE_PASSWORD) + SCHEDULEBE_OUT=$(cat in.$$ | $SCHEDULEBE -U $SCHEDULEBE_URL) + logger -t $LOGGER_PROGRAM_NAME -p $LOGGER_FACILITY.$LOGGER_PRIORITY "mail-id $HEX - schedulebe.py: $SCHEDULEBE_OUT" +fi + +#EMAILPUSH_OUT=$($EMAILPUSH "$@" -h $EMAILPUSH_HOSTNAME -p $EMAILPUSH_PORTNO -P $EMAILPUSH_PREFIX) +#logger -t $LOGGER_PROGRAM_NAME -p $LOGGER_FACILITY.$LOGGER_PRIORITY "mail-id $HEX - emailpush.sh: $EMAILPUSH_OUT" + +DELIVER_OUT=$($DELIVER "$@" .*',re.IGNORECASE).sub(r'\1', mailaddress) + s = re.compile('mailto:',re.IGNORECASE).sub(r'', s) + return str(s.lower()) + +def getRecipientsFromMail(mail): + """get the TO Header from the email""" + recipients = ["one@example.com","two@exmaple.com"] + recipient = mail['To'] + return recipients + +def sendRequestToBedework(meeting): + """send a POST request to RTSVC url, setting """ + """ Header: originator: me@gmail.com """ + """ Header: recipient: one@example.com """ + """ Header: recipient: two@example.com """ + """ Header: Content-type: text/calendar """ + """ .ics as POST body """ + if not meeting.validate(): + return False + + rtsvcHeader = [ 'Content-Type:text/calendar; charset=UTF-8' ] + rtsvcHeader.append('originator: ' + meeting.sender) + + if conf_mail_enabled: + rcptList = [] + + if meeting.getMethod() == "REQUEST": + rcptList = set(meeting.getAttendees()).intersection(meeting.recipient) + elif meeting.getMethod() == "REPLY": + rcptList.append(meeting.getOrganizer()) + rcptList = set(rcptList).intersection(meeting.recipient) + + for a in rcptList: + rtsvcHeader.append('recipient: ' + a) + + c = pycurl.Curl() + + if _debug: + print "DEBUG:" + meeting.ics.serialize() + # c.setopt(c.VERBOSE, 1) + for a in rtsvcHeader: print "DEBUG:" + a + + output = StringIO.StringIO() + + c.setopt(c.HTTPHEADER, rtsvcHeader) + c.setopt(c.POSTFIELDS, meeting.ics.serialize()) + c.setopt(c.URL, rtsvcUrl) + c.setopt(c.HEADER, 1) + c.setopt(c.POST, 1) + c.setopt(pycurl.WRITEFUNCTION, output.write) + + res = c.perform() + if _debug: + # print output + print """DEBUG request %d """ % c.getinfo(pycurl.HTTP_CODE) + + + #response = output.read() + response = output.getvalue() + if _debug: + print "DEBUG: response: [%s]" % response + + parseResponse(response) + + return True + +def parseRecipientResponse(response): + """return True if the scheduling request to the recipient is successful + + + attendee@mysite.edu + + 2.0;Success + + """ + if response.localName != 'response': + return False + + for walk in response.childNodes: + if walk.localName == 'recipient': + attendees = walk.getElementsByTagName('href') + attendee = attendees[0].childNodes[0].data + + elif walk.localName == 'request-status': + if _debug: + print "REPORT: attendee: %s\t\tstatus: %s" % (attendee, walk.childNodes[0].data) + + v = {'2.0;Success' : True, + '1.0;Deferred' : True, + 'default' : False + } + + return v.get(walk.childNodes[0].data, 'default') + + + # false by default + return False + +def parseResponse(response): + """Parse the xml response of the RTSVC server + The response is like: + HttpHeaders + ... + + + + + attendee@mysite.edu + + 2.0;Success + + + """ + ret = False + + # strip http headers + try: + response = response[response.index('<'):] + except ValueError: + print "DEBUG: Can't find < in response" + return False + + #support multiple xml documents in response + for singleResponse in response.split('\nFirstname.Lastname mapping. + +# ADDRESS REDIRECTION (VIRTUAL DOMAIN) +# +# The VIRTUAL_README document gives information about the many forms +# of domain hosting that Postfix supports. + +# "USER HAS MOVED" BOUNCE MESSAGES +# +# See the discussion in the ADDRESS_REWRITING_README document. + +# TRANSPORT MAP +# +# See the discussion in the ADDRESS_REWRITING_README document. + +# ALIAS DATABASE +# +# The alias_maps parameter specifies the list of alias databases used +# by the local delivery agent. The default list is system dependent. +# +# On systems with NIS, the default is to search the local alias +# database, then the NIS alias database. See aliases(5) for syntax +# details. +# +# If you change the alias database, run "postalias /etc/aliases" (or +# wherever your system stores the mail alias file), or simply run +# "newaliases" to build the necessary DBM or DB file. +# +# It will take a minute or so before changes become visible. Use +# "postfix reload" to eliminate the delay. +# +#alias_maps = dbm:/etc/aliases +#alias_maps = hash:/etc/aliases +#alias_maps = hash:/etc/aliases, nis:mail.aliases +#alias_maps = netinfo:/aliases + +# The alias_database parameter specifies the alias database(s) that +# are built with "newaliases" or "sendmail -bi". This is a separate +# configuration parameter, because alias_maps (see above) may specify +# tables that are not necessarily all under control by Postfix. +# +#alias_database = dbm:/etc/aliases +#alias_database = dbm:/etc/mail/aliases +#alias_database = hash:/etc/aliases +#alias_database = hash:/etc/aliases, hash:/opt/majordomo/aliases + +# ADDRESS EXTENSIONS (e.g., user+foo) +# +# The recipient_delimiter parameter specifies the separator between +# user names and address extensions (user+foo). See canonical(5), +# local(8), relocated(5) and virtual(5) for the effects this has on +# aliases, canonical, virtual, relocated and .forward file lookups. +# Basically, the software tries user+foo and .forward+foo before +# trying user and .forward. +# +#recipient_delimiter = + + +# DELIVERY TO MAILBOX +# +# The home_mailbox parameter specifies the optional pathname of a +# mailbox file relative to a user's home directory. The default +# mailbox file is /var/spool/mail/user or /var/mail/user. Specify +# "Maildir/" for qmail-style delivery (the / is required). +# +#home_mailbox = Mailbox +#home_mailbox = Maildir/ + +# The mail_spool_directory parameter specifies the directory where +# UNIX-style mailboxes are kept. The default setting depends on the +# system type. +# +#mail_spool_directory = /var/mail +#mail_spool_directory = /var/spool/mail + +# The mailbox_command parameter specifies the optional external +# command to use instead of mailbox delivery. The command is run as +# the recipient with proper HOME, SHELL and LOGNAME environment settings. +# Exception: delivery for root is done as $default_user. +# +# Other environment variables of interest: USER (recipient username), +# EXTENSION (address extension), DOMAIN (domain part of address), +# and LOCAL (the address localpart). +# +# Unlike other Postfix configuration parameters, the mailbox_command +# parameter is not subjected to $parameter substitutions. This is to +# make it easier to specify shell syntax (see example below). +# +# Avoid shell meta characters because they will force Postfix to run +# an expensive shell process. Procmail alone is expensive enough. +# +# IF YOU USE THIS TO DELIVER MAIL SYSTEM-WIDE, YOU MUST SET UP AN +# ALIAS THAT FORWARDS MAIL FOR ROOT TO A REAL USER. +# +#mailbox_command = /some/where/procmail +#mailbox_command = /some/where/procmail -a "$EXTENSION" + +# The mailbox_transport specifies the optional transport in master.cf +# to use after processing aliases and .forward files. This parameter +# has precedence over the mailbox_command, fallback_transport and +# luser_relay parameters. +# +# Specify a string of the form transport:nexthop, where transport is +# the name of a mail delivery transport defined in master.cf. The +# :nexthop part is optional. For more details see the sample transport +# configuration file. +# +# NOTE: if you use this feature for accounts not in the UNIX password +# file, then you must update the "local_recipient_maps" setting in +# the main.cf file, otherwise the SMTP server will reject mail for +# non-UNIX accounts with "User unknown in local recipient table". +# +#mailbox_transport = lmtp:unix:/var/lib/imap/socket/lmtp + +# If using the cyrus-imapd IMAP server deliver local mail to the IMAP +# server using LMTP (Local Mail Transport Protocol), this is prefered +# over the older cyrus deliver program by setting the +# mailbox_transport as below: +# +# mailbox_transport = lmtp:unix:/var/lib/imap/socket/lmtp +# +# The efficiency of LMTP delivery for cyrus-imapd can be enhanced via +# these settings. +# +# local_destination_recipient_limit = 300 +# local_destination_concurrency_limit = 5 +# +# Of course you should adjust these settings as appropriate for the +# capacity of the hardware you are using. The recipient limit setting +# can be used to take advantage of the single instance message store +# capability of Cyrus. The concurrency limit can be used to control +# how many simultaneous LMTP sessions will be permitted to the Cyrus +# message store. +# +# To use the old cyrus deliver program you have to set: +#mailbox_transport = cyrus + +# The fallback_transport specifies the optional transport in master.cf +# to use for recipients that are not found in the UNIX passwd database. +# This parameter has precedence over the luser_relay parameter. +# +# Specify a string of the form transport:nexthop, where transport is +# the name of a mail delivery transport defined in master.cf. The +# :nexthop part is optional. For more details see the sample transport +# configuration file. +# +# NOTE: if you use this feature for accounts not in the UNIX password +# file, then you must update the "local_recipient_maps" setting in +# the main.cf file, otherwise the SMTP server will reject mail for +# non-UNIX accounts with "User unknown in local recipient table". +# +#fallback_transport = lmtp:unix:/var/lib/imap/socket/lmtp +#fallback_transport = + +# The luser_relay parameter specifies an optional destination address +# for unknown recipients. By default, mail for unknown@$mydestination, +# unknown@[$inet_interfaces] or unknown@[$proxy_interfaces] is returned +# as undeliverable. +# +# The following expansions are done on luser_relay: $user (recipient +# username), $shell (recipient shell), $home (recipient home directory), +# $recipient (full recipient address), $extension (recipient address +# extension), $domain (recipient domain), $local (entire recipient +# localpart), $recipient_delimiter. Specify ${name?value} or +# ${name:value} to expand value only when $name does (does not) exist. +# +# luser_relay works only for the default Postfix local delivery agent. +# +# NOTE: if you use this feature for accounts not in the UNIX password +# file, then you must specify "local_recipient_maps =" (i.e. empty) in +# the main.cf file, otherwise the SMTP server will reject mail for +# non-UNIX accounts with "User unknown in local recipient table". +# +#luser_relay = $user@other.host +#luser_relay = $local@other.host +#luser_relay = admin+$local + +# JUNK MAIL CONTROLS +# +# The controls listed here are only a very small subset. The file +# SMTPD_ACCESS_README provides an overview. + +# The header_checks parameter specifies an optional table with patterns +# that each logical message header is matched against, including +# headers that span multiple physical lines. +# +# By default, these patterns also apply to MIME headers and to the +# headers of attached messages. With older Postfix versions, MIME and +# attached message headers were treated as body text. +# +# For details, see "man header_checks". +# +#header_checks = regexp:/etc/postfix/header_checks + +# FAST ETRN SERVICE +# +# Postfix maintains per-destination logfiles with information about +# deferred mail, so that mail can be flushed quickly with the SMTP +# "ETRN domain.tld" command, or by executing "sendmail -qRdomain.tld". +# See the ETRN_README document for a detailed description. +# +# The fast_flush_domains parameter controls what destinations are +# eligible for this service. By default, they are all domains that +# this server is willing to relay mail to. +# +#fast_flush_domains = $relay_domains + +# SHOW SOFTWARE VERSION OR NOT +# +# The smtpd_banner parameter specifies the text that follows the 220 +# code in the SMTP server's greeting banner. Some people like to see +# the mail version advertised. By default, Postfix shows no version. +# +# You MUST specify $myhostname at the start of the text. That is an +# RFC requirement. Postfix itself does not care. +# +#smtpd_banner = $myhostname ESMTP $mail_name +#smtpd_banner = $myhostname ESMTP $mail_name ($mail_version) + +# PARALLEL DELIVERY TO THE SAME DESTINATION +# +# How many parallel deliveries to the same user or domain? With local +# delivery, it does not make sense to do massively parallel delivery +# to the same user, because mailbox updates must happen sequentially, +# and expensive pipelines in .forward files can cause disasters when +# too many are run at the same time. With SMTP deliveries, 10 +# simultaneous connections to the same domain could be sufficient to +# raise eyebrows. +# +# Each message delivery transport has its XXX_destination_concurrency_limit +# parameter. The default is $default_destination_concurrency_limit for +# most delivery transports. For the local delivery agent the default is 2. + +#local_destination_concurrency_limit = 2 +#default_destination_concurrency_limit = 20 + +# DEBUGGING CONTROL +# +# The debug_peer_level parameter specifies the increment in verbose +# logging level when an SMTP client or server host name or address +# matches a pattern in the debug_peer_list parameter. +# +debug_peer_level = 2 + +# The debug_peer_list parameter specifies an optional list of domain +# or network patterns, /file/name patterns or type:name tables. When +# an SMTP client or server host name or address matches a pattern, +# increase the verbose logging level by the amount specified in the +# debug_peer_level parameter. +# +#debug_peer_list = 127.0.0.1 +#debug_peer_list = some.domain + +# The debugger_command specifies the external command that is executed +# when a Postfix daemon program is run with the -D option. +# +# Use "command .. & sleep 5" so that the debugger can attach before +# the process marches on. If you use an X-based debugger, be sure to +# set up your XAUTHORITY environment variable before starting Postfix. +# +debugger_command = + PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin + ddd $daemon_directory/$process_name $process_id & sleep 5 + +# If you can't use X, use this to capture the call stack when a +# daemon crashes. The result is in a file in the configuration +# directory, and is named after the process name and the process ID. +# +# debugger_command = +# PATH=/bin:/usr/bin:/usr/local/bin; export PATH; (echo cont; +# echo where) | gdb $daemon_directory/$process_name $process_id 2>&1 +# >$config_directory/$process_name.$process_id.log & sleep 5 +# +# Another possibility is to run gdb under a detached screen session. +# To attach to the screen sesssion, su root and run "screen -r +# " where uniquely matches one of the detached +# sessions (from "screen -list"). +# +# debugger_command = +# PATH=/bin:/usr/bin:/sbin:/usr/sbin; export PATH; screen +# -dmS $process_name gdb $daemon_directory/$process_name +# $process_id & sleep 1 + +# INSTALL-TIME CONFIGURATION INFORMATION +# +# The following parameters are used when installing a new Postfix version. +# +# sendmail_path: The full pathname of the Postfix sendmail command. +# This is the Sendmail-compatible mail posting interface. +# +sendmail_path = /usr/sbin/sendmail + +# newaliases_path: The full pathname of the Postfix newaliases command. +# This is the Sendmail-compatible command to build alias databases. +# +newaliases_path = /usr/bin/newaliases + +# mailq_path: The full pathname of the Postfix mailq command. This +# is the Sendmail-compatible mail queue listing command. +# +mailq_path = /usr/bin/mailq + +# setgid_group: The group for mail submission and queue management +# commands. This must be a group name with a numerical group ID that +# is not shared with other accounts, not even with the Postfix account. +# +setgid_group = postdrop + +# html_directory: The location of the Postfix HTML documentation. +# +html_directory = /usr/share/doc/postfix-2.6.7/html + +# manpage_directory: The location of the Postfix on-line manual pages. +# +manpage_directory = /usr/share/man + +# sample_directory: The location of the Postfix sample configuration files. +# This parameter is obsolete as of Postfix 2.1. +# +sample_directory = /etc/postfix + +# readme_directory: The location of the Postfix README files. +# +readme_directory = /usr/share/doc/postfix-2.6.7/readme + +# mailware +virtual_mailbox_domains = ldap:/etc/postfix/ldapconf/ldap_internaldomains.cf +virtual_mailbox_base = / +virtual_mailbox_maps = ldap:/etc/postfix/ldapconf/ldap_internalmailbox.cf +virtual_alias_maps = ldap:/etc/postfix/ldapconf/ldap_internal_forward.cf ldap:/etc/postfix/ldapconf/ldap_internalmailbox.cf +virtual_alias_expansion_limit = 25000 +virtual_minimum_uid = 2 +virtual_uid_maps = static:8 +virtual_gid_maps = static:12 +transport_maps = hash:/etc/postfix/transport +##################################################################DECOMMENTARE PER ABILITARE DOVECOT +virtual_transport = dovecot +dovecot_destination_recipient_limit = 1 +#virtual_transport = maildrop +#maildrop_destination_recipient_limit = 1 + + +listcf_destination_recipient_limit = 1 + +smtpd_restriction_classes = sasl_interface, policy_0 +# policy_1, policy_2, policy_3, policy_lists + +# LAN +policy_0 = check_policy_service unix:private/lanpolicy + + +# QXN: destinatario in whitelist +#policy_1 = check_recipient_access ldap:/etc/postfix/ldapconf/ldap_policy_1.cf, check_recipient_access ldap:/etc/postfix/ldapconf/ldap_internal_reject_policy_1.cf, check_policy_service unix:private/qxnlistpolicy, reject +#policy_1 = check_recipient_access ldap:/etc/postfix/ldapconf/ldap_policy_1.cf, check_recipient_access ldap:/etc/postfix/ldapconf/ldap_internal_reject_policy_1.cf, check_recipient_access hash:/etc/postfix/qxnlist, reject + +# WWW destinatario in PD +#policy_2 = check_recipient_access ldap:/etc/postfix/ldapconf/ldap_policy_2.cf, check_recipient_access ldap:/etc/postfix/ldapconf/ldap_internal_reject_policy_2.cf, check_policy_service unix:private/internetpolicy, reject + +# WWW+QNX +#policy_3 = check_recipient_access ldap:/etc/postfix/ldapconf/ldap_policy_3.cf, check_recipient_access ldap:/etc/postfix/ldapconf/ldap_internal_reject_policy_3.cf, permit + +sasl_interface = reject_unknown_sender_domain, reject_authenticated_sender_login_mismatch, reject_unauthenticated_sender_login_mismatch + +# policy_lists = check_policy_service unix:private/listpolicy + +smtpd_sender_restrictions = sasl_interface, permit_sasl_authenticated, reject +smtpd_recipient_restrictions = check_recipient_access ldap:/etc/postfix/ldapconf/ldap_policygroup.cf, check_sender_access ldap:/etc/postfix/policy_domains.cf, reject_unauth_destination + +policy_time_limit = 3600 + +# Nega l'invio da domini gestiti sugli mx record +# check_mx_access=check_sender_access ldap:/etc/postfix/ldapconf/ldap_internal_mx_reject.cf, permit + +# controlla il MAIL FROM con le credenziali di autenticazione sasl +smtpd_sender_login_maps = ldap:/etc/postfix/ldapconf/ldap_sender_mismatch.cf + +# antirelay mx internet +# check_internet_access=check_recipient_access ldap:/etc/postfix/ldapconf/ldap_policygroup.cf, check_recipient_access ldap:/etc/postfix/ldapconf/ldap_internal_internet_mailboxes.cf, check_recipient_access ldap:/etc/postfix/ldapconf/ldap_internal_internet_aliases.cf + +####Far loggare il Subject su maillog +#header_checks = pcre:/etc/postfix/header_checks + +mynetworks = 127.0.0.1, 10.0.11.50, 10.0.8.4, 10.0.8.0/22, 10.0.10.10, 10.0.0.62, 10.0.0.0/24 +#always_bcc = gnarwl + +# always_bcc = schedulebe + +sms_destination_recipient_limit = 1 diff --git a/remaster/mcs/postfix/master.cf b/remaster/mcs/postfix/master.cf new file mode 100644 index 0000000..a89e73c --- /dev/null +++ b/remaster/mcs/postfix/master.cf @@ -0,0 +1,111 @@ +# +# Postfix master process configuration file. For details on the format +# of the file, see the master(5) manual page (command: "man 5 master"). +# +# ========================================================================== +# service type private unpriv chroot wakeup maxproc command + args +# (yes) (yes) (yes) (never) (100) +# ========================================================================== +smtp inet n - n - - smtpd +# -o receive_override_options=no_address_mappings + -o smtpd_sender_restrictions=permit_mynetworks,$check_mx_access + -o smtpd_recipient_restrictions=permit_mynetworks,$check_internet_access,reject_unauth_destination,reject +submission inet n - n - - smtpd + -o smtpd_sasl_auth_enable=yes + -o smtpd_sender_restrictions=permit_mynetworks,$check_mx_access + -o smtpd_recipient_restrictions=permit_mynetworks,$check_internet_access,reject_unauth_destination,reject +smtps inet n - n - - smtpd + -o smtpd_tls_wrappermode=yes + -o smtpd_sasl_auth_enable=yes + -o smtpd_sender_restrictions=permit_mynetworks,$check_mx_access + -o smtpd_recipient_restrictions=permit_mynetworks,$check_internet_access,reject_unauth_destination,reject + -o smtpd_tls_key_file=/etc/ssl/dovecot/server.key + -o smtpd_tls_cert_file=/etc/ssl/dovecot/server.cert + -o smtpd_tls_CAfile=/etc/ssl/dovecot/server.pem +#628 inet n - n - - qmqpd +pickup fifo n - n 60 1 pickup +cleanup unix n - n - 0 cleanup +qmgr fifo n - n 300 1 qmgr +#qmgr fifo n - n 300 1 oqmgr +tlsmgr unix - - n 1000? 1 tlsmgr +rewrite unix - - n - - trivial-rewrite +bounce unix - - n - 0 bounce +defer unix - - n - 0 bounce +trace unix - - n - 0 bounce +verify unix - - n - 1 verify +flush unix n - n 1000? 0 flush +proxymap unix - - n - - proxymap +smtp unix - - n - - smtp +# When relaying mail as backup MX, disable fallback_relay to avoid MX loops +relay unix - - n - - smtp + -o fallback_relay= +# -o smtp_helo_timeout=5 -o smtp_connect_timeout=5 +showq unix n - n - - showq +error unix - - n - - error +discard unix - - n - - discard +local unix - n n - - local +virtual unix - n n - - virtual +lmtp unix - - n - - lmtp +anvil unix - - n - 1 anvil +scache unix - - n - 1 scache +# +# ==================================================================== +# Interfaces to non-Postfix software. Be sure to examine the manual +# pages of the non-Postfix software to find out what options it wants. +# +# Many of the following services use the Postfix pipe(8) delivery +# agent. See the pipe(8) man page for information about ${recipient} +# and other message envelope options. +# ==================================================================== +# +# maildrop. See the Postfix MAILDROP_README file for details. +# Also specify in main.cf: maildrop_destination_recipient_limit=1 +# +#maildrop unix - n n - - pipe +# flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient} +# +# The Cyrus deliver program has changed incompatibly, multiple times. +# +old-cyrus unix - n n - - pipe + flags=R user=cyrus argv=/usr/lib/cyrus/deliver -e -m ${extension} ${user} +# Cyrus 2.1.5 (Amos Gouaux) +# Also specify in main.cf: cyrus_destination_recipient_limit=1 +cyrus unix - n n - - pipe + user=cyrus argv=/usr/lib/cyrus/deliver -e -r ${sender} -m ${extension} ${user} +# +# See the Postfix UUCP_README file for configuration details. +# +uucp unix - n n - - pipe + flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient) +# +# Other external delivery methods. +# +ifmail unix - n n - - pipe + flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient) +bsmtp unix - n n - - pipe + flags=Fq. user=foo argv=/usr/local/sbin/bsmtp -f $sender $nexthop $recipient +maildrop unix - n n - - pipe + flags=ODRhu user=mail argv=/usr/bin/maildrop -d ${recipient} +cos-cf unix - n n - 10 pipe + flags=Rq user=mail argv=/etc/postfix/filter.pl -f ${sender} ${recipient} + +dovecot unix - n n - - pipe + flags=ODRhu user=mail:mail argv=/usr/local/mmt_scripts/deliver.sh -f ${sender} -d ${recipient} + +#dovecot unix - n n - - pipe +# flags=ODRhu user=mail:mail argv=/usr/libexec/dovecot/deliver -f ${sender} -d ${recipient} + +#Deliver del sieve +#dovecot unix - n n - - pipe +# flags=ODRhu user=mail:mail argv=/opt/dovecot-1.2.8/libexec/dovecot/deliver -f ${sender} -d ${recipient} + + + +#always_bcc=gnarwl +gnarwl unix - n n - - pipe + flags=F user=gnarwl argv=/usr/bin/gnarwl -s ${sender} -a ${recipient} +schedulbe unix - n n - - pipe + flags=F user=schedulbe argv=/root/python/ScheduleBe/schedulebe.py -v +sms unix - n n - - smtp +retry unix - - n - - error +proxywrite unix - - n - 1 proxymap diff --git a/scripts/remaster_generic_inner_chroot_script_after.sh b/scripts/remaster_generic_inner_chroot_script_after.sh index 3cb19b4..45dead5 100755 --- a/scripts/remaster_generic_inner_chroot_script_after.sh +++ b/scripts/remaster_generic_inner_chroot_script_after.sh @@ -204,6 +204,11 @@ touch /var/log/clamav/freshclam.log chown clamav:clamav /var/log/clamav -R chown clamav:clamav /var/lib/clamav -R +# Fixup mysqld permissions, ebuild bug? +if [ -d "/var/run/mysqld" ]; then + chown mysql:mysql /var/run/mysqld -R +fi + # Setup SAMBA config file if [ -f /etc/samba/smb.conf.default ]; then cp -p /etc/samba/smb.conf.default /etc/samba/smb.conf diff --git a/scripts/remaster_mcs_inner_chroot_script_after.sh b/scripts/remaster_mcs_inner_chroot_script_after.sh index e3443c0..a85a199 100755 --- a/scripts/remaster_mcs_inner_chroot_script_after.sh +++ b/scripts/remaster_mcs_inner_chroot_script_after.sh @@ -1,5 +1,8 @@ #!/bin/sh +# merge config updates first +echo -5 | equo conf update + # setup Desktop icons rm /etc/skel/Desktop/*.desktop cp /usr/share/applications/keyboard.desktop /etc/skel/Desktop/ -p @@ -15,33 +18,36 @@ chmod 755 /etc/init.d/oemsystem-default chown root:root /etc/init.d/oemsystem-default rc-update add oemsystem-default default -# temp jboss-bin fixes -useradd jboss -chown jboss:jboss /opt/jboss-bin-4.2 -R - # setup fqdn sed -i 's/sabayon/localhost.localdomain sabayon/g' /etc/hosts # setup MySQL +# Fixup mysqld permissions, ebuild bug? +chown mysql:mysql /var/run/mysqld -R + mysql_ebuild="$(find /var/db/pkg/dev-db -name "mysql*.ebuild" | sort | head -n 1)" if [ -z "${mysql_ebuild}" ]; then echo "cannot find any mysql ebuild" exit 1 fi echo "password=mcsmanager" > /root/.my.cnf || exit 1 -mount -t tmpfs none /var/run/mysqld ebuild "${mysql_ebuild}" config if [ "${?}" != "0" ]; then - umount /var/run/mysqld exit 1 fi rm /root/.my.cnf -f -umount /var/run/mysqld # setup password sed -i '/^#password/ s/your_password/mcsmanager/g' /etc/mysql/my.cnf || exit 1 sed -i '/^#password/ s/#//g' /etc/mysql/my.cnf || exit 1 -# FIXME: enable mysql InnoDB? +# start and insert data +echo "Setting up mysql" +/etc/init.d/mysql start --nodeps || exit 1 +mysql -u root --password=mcsmanager -h localhost < /.mcs/mwsql.sql +mysql -u root --password=mcsmanager -h localhost < /.mcs/bedework.sql +# TODO setup user permissions? +# TODO do not ask password +/etc/init.d/mysql stop --nodeps # setup 389-console data mkdir /etc/skel/.389-console @@ -49,21 +55,49 @@ echo "UserID=admin HostURL=http\://localhost\:9830 " > /etc/skel/.389-console/Console.1.1.5.Login.preferences +# Setup Postfix +echo "Setting up Postfix" +cp /.mcs/postfix/main.cf /etc/postfix/main.cf || exit 1 +cp /.mcs/postfix/master.cf /etc/postfix/master.cf || exit 1 +cp /.mcs/postfix/ldapconf /etc/postfix/ldapconf -Rp || exit 1 +chown root:root /etc/postfix/{main,master}.cf || exit 1 +chmod 644 /etc/postfix/{main,master}.cf || exit 1 +chmod 755 /etc/postfix/ldapconf || exit 1 +chmod 644 /etc/postfix/ldapconf/*.cf || exit 1 +chown root:root /etc/postfix/ldapconf -R || exit 1 +# mmt_scripts +cp /.mcs/mmt_scripts /usr/local/ -Rp || exit 1 +chown root:root /usr/local/mmt_scripts -R || exit 1 +chmod 755 /usr/local/mmt_scripts/* -R || exit 1 + +# Build ejabberd +#tar xvzf /.mcs/ejabberd-patched.tar.bz2 -C /tmp || exit 1 +#cd /tmp/ejabberd-2.1.0_rc1 || exit 1 + +# Setup .war stuff +cp /.mcs/no_repo/jboss-deploy/* /opt/jboss-bin-4.2/server/default/deploy/ -Rap +chown jboss:jboss /opt/jboss-bin-4.2/server/default/deploy/ -R + # add services to init -rc-update add 389-ds default -rc-update add 389-admin default +# autostarted by the mcs setup script +## rc-update add 389-ds default +## rc-update add 389-admin default rc-update add 389-ds-snmp default rc-update add jboss-bin-4.2 default rc-update add mysql default +rc-update add dovecot default +rc-update add postfix default # remove unused services from init rc-update del sabayon-mce default rc-update del sabayon-mce boot rc-update del music default +# remove temp .mcs dir +rm /.mcs -rf + # Sabayon stuff -echo -5 | equo conf update mount -t proc proc /proc /lib/rc/bin/rc-depend -u