diff options
Diffstat (limited to 'debian/local/update_db.in')
-rw-r--r-- | debian/local/update_db.in | 81 |
1 files changed, 63 insertions, 18 deletions
diff --git a/debian/local/update_db.in b/debian/local/update_db.in index 72ee337..d61016f 100644 --- a/debian/local/update_db.in +++ b/debian/local/update_db.in @@ -32,9 +32,21 @@ if [ -x ./update_sendmail ]; then sm_path='.'; elif [ -x $(dirname $0)/update_sendmail ]; then sm_path=$(dirname $0); -else +else sm_path=@datadir@/sendmail; fi; +# Bring in sendmail.conf for the network definitions +if [ ! -f @sysconfdir@/mail/sendmail.conf ]; then + if [ -x $sm_path/update_conf ]; then + $sm_path/update_conf; + fi; + fi; +if [ -f @sysconfdir@/mail/sendmail.conf ]; then + . @sysconfdir@/mail/sendmail.conf; + fi; +if [ "$HANDS_OFF" != 'No' ]; then + exit 0; + fi; # control amount of output verbosity=0; @@ -74,7 +86,7 @@ is_found () { case "$dbfeat" in ALIAS_FILE) - if [ -f @sysconfdir@/mail/aliases -a ! -f /etc/aliases ]; then + if [ -f @sysconfdir@/mail/aliases ] & [ ! -f /etc/aliases ]; then echo "Moving @sysconfdir@/mail/aliases to /etc/aliases"; mv @sysconfdir@/mail/aliases /etc/aliases; ln -sf ../aliases @sysconfdir@/mail/aliases; @@ -262,6 +274,16 @@ is_not_found () { $sm_path/update_conf; fi; ;; + access_db) + missing_cre=`expr $missing_cre + 1`; + echo "Warning: $dbfeat source" \ + "file not found: $dbname"; + echo " it was created"; + cp @datadir@/sendmail/examples/db/access \ + @sysconfdir@/mail/; + chown root:root $dbname; + chmod 0644 $dbname; + ;; *) if move_file /etc/$dbsname; then :; @@ -297,6 +319,12 @@ is_empty () { databases|Makefile) :; ;; + access_db) + cp @datadir@/sendmail/examples/db/access \ + @sysconfdir@/mail/; + chown root:root $dbname; + chmod 0644 $dbname; + ;; *) echo "Informational: $dbfeat file empty: $dbname"; if [ "$dbopts" = "-o" ]; then @@ -314,7 +342,7 @@ is_comments () { if [ $verbosity -gt 1 ]; then echo "is_comments: $dbfeat - $dbname"; fi; - if [ $process -eq 1 -a -s "$dbname" ]; then + if [ $process -eq 1 ] && [ -s "$dbname" ]; then if [ "$dbtype" != "-" ]; then rm -f $dbname.db; rm -f $dbname.pag; @@ -343,12 +371,12 @@ is_normal () { fi; # Make sure sensitive databases are *not* generally readable - if [ "$dbsname" = "authinfo" \ - -o "$dbsname" = "access" ]; then + if [ "$dbsname" = "authinfo" ] \ + || [ "$dbsname" = "access" ]; then chmod go-rwx $dbname; fi; - if [ $process -eq 1 -a $max_rc -eq 0 ]; then + if [ $process -eq 1 ] && [ $max_rc -eq 0 ]; then case "$dbtype" in '-'|text|ldap) :; @@ -372,12 +400,13 @@ is_normal () { dbm | btree | hash) echo "Updating $dbname..."; @sbindir@/makemap $dbtype $dbname.new.db < $dbname; - chown root:smmsp $dbname.new.db; - if [ "$dbsname" = "authinfo" \ - -o "$dbsname" = "access" ]; then + if [ "$dbsname" = "authinfo" ] \ + || [ "$dbsname" = "access" ]; then + chown smmta:smmsp $dbname.new.db; chmod 0640 $dbname.new.db; else - chmod 0644 $dbname.new.db; + chown root:smmsp $dbname.new.db; + chmod 0640 $dbname.new.db; fi; mv -f $dbname.new.db $dbname.db; ;; @@ -385,11 +414,11 @@ is_normal () { echo "Updating $dbname..."; if [ $newaliases_run -eq 0 ]; then newaliases_run=1; - @sbindir@/sendmail -bi || true; + @libexecdir@/newaliases || true; fi; if [ -f $dbname.db ]; then - chown root:smmsp $dbname.db; - chmod 0644 $dbname.db; + chown smmta:smmsp $dbname.db; + chmod 0640 $dbname.db; fi; ;; m4) @@ -399,6 +428,10 @@ is_normal () { m4 @sysconfdir@/mail/${mcfile}.mc \ > @sysconfdir@/mail/${mcfile}.cf.new \ 2> @sysconfdir@/mail/${mcfile}.cf.errors || true; + echo "### @sysconfdir@/mail/${mcfile}.mc ###" \ + >> @sysconfdir@/mail/${mcfile}.cf.new; + sed -e 's/^/# /' @sysconfdir@/mail/${mcfile}.mc \ + >> @sysconfdir@/mail/${mcfile}.cf.new; chown root:smmsp @sysconfdir@/mail/${mcfile}.cf.new; chmod 0644 @sysconfdir@/mail/${mcfile}.cf.new; if [ ! -s @sysconfdir@/mail/${mcfile}.cf.errors ]; then @@ -470,9 +503,9 @@ for file in $db_files; do \ # Check to see if we're doing one, or all if [ ! -z "$1" ]; then - if [ "$1" = "$dbfeat" -o \ - "$1" = "$dbname" -o \ - "$1" = "$dbsname" ]; then + if [ "$1" = "$dbfeat" ] \ + || [ "$1" = "$dbname" ] \ + || [ "$1" = "$dbsname" ]; then :; else continue; @@ -487,6 +520,18 @@ for file in $db_files; do \ fi; continue ;; + dbm | btree | hash) + if [ ! -x @libexecdir@/makemap ]; then + echo "Delaying $dbname..."; + continue; + fi; + ;; + newaliases) + if [ ! -x @libexecdir@/newaliases ]; then + echo "Delaying $dbname..."; + continue; + fi; + ;; *) ;; esac; @@ -502,7 +547,7 @@ for file in $db_files; do \ fi; # Check for database existance - if [ -f "$dbname" -o -d "$dbname" ]; then + if [ -f "$dbname" ] || [ -d "$dbname" ]; then is_found; else is_not_found; @@ -560,7 +605,7 @@ if [ $missing_rqd -ne 0 ]; then max_rc=2; fi; fi; -if [ $missing_opt -ne 0 -o $missing_rqd -ne 0 ]; then +if [ $missing_opt -ne 0 ] || [ $missing_rqd -ne 0 ]; then echo " "; echo "$0 assumes that databases, and their source datasets"; echo "have the same base name (not counting the .db). If this is not"; |