閉鎖環境内でアラートメールの送信ができるだけのためのメールサーバ設定(AlmaLinux8/RHEL8/Oracle Linux8)

閉鎖環境で機器初期セットアップを行う際に、アラートメールの送信先を指定する必要があったりする。

その時に、メール送信テストが行えるような簡易的なLinuxサーバを作るためのメモ書きです。

なお、メールの送信先は「root@adosakana.local」としておいて、Linuxユーザのroot宛にメールが届くような設定です。

メールを読むときは /var/mail/root に届くのを直接見るか、mail/mailx/muttコマンドなどで見る想定です。

(1) AlmaLinux / RHEL / Oracle Linux 8の最小インストールを実施

(2) アップデート

「dnf update -y」でパッケージを最新に

(3) SMTPで使用するポート開け

「firewall-cmd –add-service smtp –permanent」で追加

# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens192
  sources:
  services: cockpit dhcpv6-client ssh
  ports:
  protocols:
  forward: no
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:
# firewall-cmd --add-service smtp --permanent
success
# firewall-cmd --reload
success
# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens192
  sources:
  services: cockpit dhcpv6-client smtp ssh
  ports:
  protocols:
  forward: no
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:
#

(4) postfixのインストール

「dnf install postfix」でpostfixをインストール

(5) postfixの設定ファイルを編集

まず、テストに使うメールアドレスのドメイン名を「mydomain=~」で定義(myhostname 定義はそのまま使った)

# The mydomain parameter specifies the local internet domain name.
# The default is to use $myhostname minus the first component.
# $mydomain is used as a default value for many other configuration
# parameters.
#
#mydomain = domain.tld
mydomain = adosakana.local

メール送信者にドメイン名指定がない場合に、mydomainで設定した内容を適用するために「myorigin = $mydomain」

# SENDING MAIL
#
# The myorigin parameter specifies the domain that locally-posted
# mail appears to come from. The default is to append $myhostname,
# which is fine for small sites.  If you run a domain with multiple
# machines, you should (1) change this to $mydomain and (2) set up
# a domain-wide alias database that aliases each user to
# user@that.users.mailhost.
#
# For the sake of consistency between sender and recipient addresses,
# myorigin also specifies the default domain name that is appended
# to recipient addresses that have no @domain part.
#
#myorigin = $myhostname
myorigin = $mydomain

どのNICからきたSMTP要求でも受付させるための「inet_interfaces = all」を定義

# RECEIVING MAIL

# The inet_interfaces parameter specifies the network interface
# addresses that this mail system receives mail on.  By default,
# the software claims all active interfaces on the machine. The
# parameter also controls delivery of mail to user@[ip.address].
#
# See also the proxy_interfaces parameter, for network addresses that
# are forwarded to us via a proxy or network address translator.
#
# Note: you need to stop/start Postfix when this parameter changes.
#
inet_interfaces = all
#inet_interfaces = $myhostname
#inet_interfaces = $myhostname, localhost
#inet_interfaces = localhost

受信するメールを決めるために「mydestination =~」を指定。とりあえず全部受け取るような感じの設定にする

# Specify a list of host or domain names, /file/name or type:table
# patterns, separated by commas and/or whitespace. A /file/name
# pattern is replaced by its contents; a type:table is matched when
# a name matches a lookup key (the right-hand side is ignored).
# Continue long lines by starting the next line with whitespace.
#
# See also below, section "REJECTING MAIL FOR UNKNOWN LOCAL USERS".
#
#mydestination = $myhostname, localhost.$mydomain, localhost
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain,
#       mail.$mydomain, www.$mydomain, ftp.$mydomain

メール送信側のSSLプロトコル対応が古い場合を考慮して「smtpd_tls_security_level=none」と暗号化の要求レベルをなしにしておく

# Announce STARTTLS support to remote SMTP clients, but do not require that
# clients use TLS encryption (opportunistic TLS inbound).
#
#smtpd_tls_security_level = may
smtpd_tls_security_level = none

なお、「lost connection after STARTTLS from unknown」という形でSMTP接続を拒否される場合は、おそらく標準値の「smtpd_tls_security_level = may」で設定している場合。(TLS1.2以降を必須、とかそんな感じ)

(6) postfixを起動

「systemctl enable postfix」でOS起動時にpostfixも起動するように設定し、

「systemctl start postfix」でいますぐpostfixを起動させている

# systemctl status postfix
● postfix.service - Postfix Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/postfix.service; disabled; vendor pr>
   Active: inactive (dead)
# systemctl enable postfix
Created symlink /etc/systemd/system/multi-user.target.wants/postfix.service → /usr/lib/systemd/system/postfix.service.
# systemctl status postfix
● postfix.service - Postfix Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor pre>
   Active: inactive (dead)
# systemctl start postfix
#


おまけ: mutt コマンドでメールを送信しようとしたけど、送れない

とあるプロダクトのアラートメールの送信手法がmuttコマンドを利用していた。

「smtpd_tls_security_level = may」設定のpostfixにメールを送ると「lost connection after STARTTLS from unknown」で送れていなかった。

postfix側ではなく、mutt側で対策取れるかを確認したところ /etc/Muttrc.local などの muttの設定ファイル内で「set ssl_starttls = no」と設定して、STARTTLSの使用を取りやめることでメール送信に成功するようになった。

RHEL8.5サーバから mutt コマンドでメール送信する場合、SSL関連の設定を調べると以下の様なものがある

set ssl_verify_host = no
set ssl_verify_dates = no
set ssl_starttls = yes
set ssl_use_tlsv1_3 = yes
set ssl_use_tlsv1_2 = yes
set ssl_use_tlsv1_1 = yes
set ssl_use_tlsv1 = no
set ssl_use_sslv3 = no
set ssl_use_sslv2 = no

ただ、RHEL8.5で試してみたところ「ssl_use_sslv2」というオプションは存在していなかった。

# echo "test mail"  | mutt -F ~/testmuttrc -s "test mail title" 受信者 -d 10
レベル 10 でデバッグ中。
/root/testmuttrc 中の 14 行目でエラー: ssl_use_sslv2 は不明な変数
source: /root/testmuttrc 中でエラー
#

また、opensslコマンドのs_clientでSSLv2 SSLv3の接続ができるかを試験してみたところ、オプション自体が廃止されていた。

# openssl s_client -connect 172.17.44.50:25 -servername 172.17.44.50 -ssl3
s_client: Option unknown option -ssl3
s_client: Use -help for summary.
# openssl s_client -connect 172.17.44.50:25 -servername 172.17.44.50 -ssl2
s_client: Option unknown option -ssl2
s_client: Use -help for summary.
#

Samba 4.16.x をOracle Linux 8環境でコンパイルする

Oracle Linux 8.6環境でSamba 4.16.3をコンパイルしようとしたら面倒だったのでメモ書き。

まず、「Package Dependencies Required to Build Samba」にあるVerified Package DependenciesのSamba master / CentOS 8 のリンクが使えない。

これは、CentOS8ではなく、CentOS8Streamにリンクが変わったためである。

ただ、Oracle Linux 8ではレポジトリ名が異なっているため、実行が失敗する。

Oracle Linux 8でのレポジトリ対応は下記となる。

RHEL 8CentOS 8Oracle Linux 8
BaseBaseol8_baseos_latest
AppStreamAppStreamol8_appstream
CodeReady Linux Builder*PowerToolsol8_codeready_builder
EPEL**EPEL**ol8_developer_EPEL

なので、Oracle Linux 8では下記を実行してレポジトリを有効化する

# yum config-manager --set-enabled ol8_codeready_builder
# yum config-manager --set-enabled ol8_developer_EPEL

次に、「Red Hat Enterprise Linux 8 / CentOS 8」に記載があるパッケージ群をインストール

# yum install docbook-style-xsl gcc gdb gnutls-devel gpgme-devel jansson-devel \
      keyutils-libs-devel krb5-workstation libacl-devel libaio-devel \
      libarchive-devel libattr-devel libblkid-devel libtasn1 libtasn1-tools \
      libxml2-devel libxslt lmdb-devel openldap-devel pam-devel perl \
      perl-ExtUtils-MakeMaker perl-Parse-Yapp popt-devel python3-cryptography \
      python3-dns python3-gpg python36-devel readline-devel rpcgen systemd-devel \
      tar zlib-devel

エラー対処1: dbus-devel

configure中にエラー発生

Checking for library nscd                                                                       : no
Checking for nscd_flush_cache                                                                   : not found
VFS_STATIC: vfs_default,vfs_not_implemented,vfs_posixacl,vfs_dfs_samba4
VFS_SHARED: vfs_recycle,vfs_audit,vfs_extd_audit,vfs_full_audit,vfs_fake_perms,vfs_default_quota,vfs_readonly,vfs_cap,vfs_expand_msdfs,vfs_shadow_copy,vfs_shadow_copy2,vfs_readahead,vfs_xattr_tdb,vfs_streams_xattr,vfs_streams_depot,vfs_acl_xattr,vfs_acl_tdb,vfs_preopen,vfs_catia,vfs_media_harmony,vfs_unityed_media,vfs_fruit,vfs_shell_snap,vfs_commit,vfs_worm,vfs_crossrename,vfs_linux_xfs_sgid,vfs_time_audit,vfs_offline,vfs_virusfilter,vfs_widelinks,vfs_snapper,vfs_posix_eadb,vfs_syncops,vfs_dirsort,vfs_fileid,vfs_aio_fork,vfs_aio_pthread,vfs_gpfs,vfs_btrfs,vfs_glusterfs_fuse
PDB_STATIC: pdb_smbpasswd,pdb_tdbsam,pdb_samba_dsdb,pdb_ldapsam
PDB_SHARED:
AUTH_STATIC: auth_builtin,auth_sam,auth_winbind,auth_unix,auth_samba4
AUTH_SHARED:
NSS_INFO_STATIC: nss_info_template
NSS_INFO_SHARED:
CHARSET_STATIC:
CHARSET_SHARED:
IDMAP_STATIC: idmap_tdb,idmap_passdb,idmap_nss,idmap_ldap
IDMAP_SHARED: idmap_ad,idmap_rfc2307,idmap_autorid,idmap_rid,idmap_hash,idmap_tdb2,idmap_script
GPEXT_STATIC:
GPEXT_SHARED:
PERFCOUNT_STATIC:
PERFCOUNT_SHARED:
Checking for dbus                                                                               : not found
vfs_snapper is enabled but prerequisite dbus-1 package not found. Use --with-shared-modules='!vfs_snapper' to disable vfs_snapper support.
(complete log in /root/samba-4.16.3/bin/config.log)
# 

これは「dnf install dbus-devel」のインストールで対応

# dnf install dbus-devel
メタデータの期限切れの最終確認: 0:08:21 時間前の 2022年07月19日 09時59分33秒 に 実施しました。
依存関係が解決しました。
================================================================================
 パッケージ      Arch        バージョン                リポジトリー       サイズ
================================================================================
インストール:
 dbus-devel      x86_64      1:1.12.8-18.0.1.el8       ol8_appstream       68 k

トランザクションの概要
================================================================================
インストール  1 パッケージ

ダウンロードサイズの合計: 68 k
インストール後のサイズ: 127 k
これでよろしいですか? [y/N]: y
パッケージのダウンロード:
dbus-devel-1.12.8-18.0.1.el8.x86_64.rpm          54 kB/s |  68 kB     00:01
--------------------------------------------------------------------------------
合計                                             54 kB/s |  68 kB     00:01
トランザクションの確認を実行中
トランザクションの確認に成功しました。
トランザクションのテストを実行中
トランザクションのテストに成功しました。
トランザクションを実行中
  準備             :                                                        1/1
  インストール中   : dbus-devel-1:1.12.8-18.0.1.el8.x86_64                  1/1
  scriptletの実行中: dbus-devel-1:1.12.8-18.0.1.el8.x86_64                  1/1
  検証             : dbus-devel-1:1.12.8-18.0.1.el8.x86_64                  1/1

インストール済み:
  dbus-devel-1:1.12.8-18.0.1.el8.x86_64

完了しました!
#

エラー対処2: python3-markdown

configure中にエラー発生

Checking for openpty                                                                            : not found
Checking for library util                                                                       : yes
Checking for openpty in util                                                                    : ok
Checking for system installation of Python module markdown                                      : not found
        Unable to find Python module 'markdown'. Please install the system package: python3-markdown'.
#

これは書かれている通りにpython3-markdownをインストール

# dnf install python3-markdown
メタデータの期限切れの最終確認: 0:09:33 時間前の 2022年07月19日 09時59分33秒 に 実施しました。
依存関係が解決しました。
================================================================================
 パッケージ          Arch      バージョン        リポジトリー             サイズ
================================================================================
インストール:
 python3-markdown    noarch    2.6.11-2.el8      ol8_codeready_builder    133 k

トランザクションの概要
================================================================================
インストール  1 パッケージ

ダウンロードサイズの合計: 133 k
インストール後のサイズ: 418 k
これでよろしいですか? [y/N]: y
パッケージのダウンロード:
python3-markdown-2.6.11-2.el8.noarch.rpm        108 kB/s | 133 kB     00:01
--------------------------------------------------------------------------------
合計                                            108 kB/s | 133 kB     00:01
トランザクションの確認を実行中
トランザクションの確認に成功しました。
トランザクションのテストを実行中
トランザクションのテストに成功しました。
トランザクションを実行中
  準備             :                                                        1/1
  インストール中   : python3-markdown-2.6.11-2.el8.noarch                   1/1
  scriptletの実行中: python3-markdown-2.6.11-2.el8.noarch                   1/1
  検証             : python3-markdown-2.6.11-2.el8.noarch                   1/1

インストール済み:
  python3-markdown-2.6.11-2.el8.noarch

完了しました!
#

エラー対処3: perl-JSON

make中にエラー発生

third_party/heimdal/lib/asn1/der_free.c third_party/heimdal/lib/asn1/der_format.c third_party/heimdal/lib/asn1/der_length.c third_party/heimdal/lib/asn1/der_copy.c third_party/heimdal/lib/asn1/der_cmp.c third_party/heimdal/lib/asn1/der_print.c third_party/heimdal/lib/asn1/extra.c third_party/heimdal/lib/asn1/timegm.c third_party/heimdal/lib/asn1/template.c third_party/heimdal/lib/asn1/oid_resolution.c -> bin/default/third_party/heimdal/lib/asn1/der-protos.h
Can't locate JSON.pm in @INC (you may need to install the JSON module) (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5) at /root/samba-4.16.3/third_party/heimdal/cf/make-proto.pl line 7.
BEGIN failed--compilation aborted at /root/samba-4.16.3/third_party/heimdal/cf/make-proto.pl line 7.

Waf: Leaving directory `/root/samba-4.16.3/bin/default'
Build failed
 -> task in '../heimdal/lib/asn1/der-protos.h' failed with exit status 2 (run with -v to display more information)
make: *** [Makefile:7: all] エラー 1
PYTHONHASHSEED=1 WAF_MAKE=1  ./buildtools/bin/waf install
Waf: Entering directory `/root/samba-4.16.3/bin/default'
        Selected embedded Heimdal build
Checking project rules ...
Project rules pass
[1/1] Compiling VERSION
+ install /usr/local/samba/lib/pkgconfig/samba-hostconfig.pc (from bin/default/lib/param/samba-hostconfig.pc)
+ install /usr/local/samba/lib/pkgconfig/dcerpc_samr.pc (from bin/default/source4/librpc/dcerpc_samr.pc)
+ install /usr/local/samba/lib/pkgconfig/dcerpc.pc (from bin/default/source4/librpc/dcerpc.pc)
+ install /usr/local/samba/lib/pkgconfig/samdb.pc (from bin/default/source4/dsdb/samdb.pc)
+ install /usr/local/samba/lib/pkgconfig/samba-credentials.pc (from bin/default/auth/credentials/samba-credentials.pc)
+ install /usr/local/samba/lib/pkgconfig/wbclient.pc (from bin/default/nsswitch/libwbclient/wbclient.pc)
+ install /usr/local/samba/lib/pkgconfig/samba-util.pc (from bin/default/lib/util/samba-util.pc)
+ install /usr/local/samba/lib/pkgconfig/dcerpc_server.pc (from bin/default/source4/rpc_server/dcerpc_server.pc)
+ install /usr/local/samba/lib/pkgconfig/ndr_krb5pac.pc (from bin/default/librpc/ndr_krb5pac.pc)
+ install /usr/local/samba/lib/pkgconfig/ndr_standard.pc (from bin/default/librpc/ndr_standard.pc)
+ install /usr/local/samba/lib/pkgconfig/ndr_nbt.pc (from bin/default/librpc/ndr_nbt.pc)
+ install /usr/local/samba/lib/pkgconfig/ndr.pc (from bin/default/librpc/ndr.pc)
+ install /usr/local/samba/lib/pkgconfig/samba-policy.cpython-36m-x86_64-linux-gnu.pc (from bin/default/source4/lib/policy/samba-policy.cpython-36m-x86_64-linux-gnu.pc)
+ install /usr/local/samba/sbin/samba_downgrade_db (from bin/default/source4/scripting/bin/samba_downgrade_db.inst)
+ install /usr/local/samba/sbin/samba_dnsupdate (from bin/default/source4/scripting/bin/samba_dnsupdate.inst)
+ install /usr/local/samba/sbin/samba_spnupdate (from bin/default/source4/scripting/bin/samba_spnupdate.inst)
+ install /usr/local/samba/sbin/samba_upgradedns (from bin/default/source4/scripting/bin/samba_upgradedns.inst)
+ install /usr/local/samba/sbin/samba_kcc (from bin/default/source4/scripting/bin/samba_kcc.inst)
+ install /usr/local/samba/sbin/samba-gpupdate (from bin/default/source4/scripting/bin/samba-gpupdate.inst)
+ install /usr/local/samba/bin/samba-tool (from bin/default/source4/scripting/bin/samba-tool.inst)
+ install /usr/local/samba/lib/pkgconfig/netapi.pc (from bin/default/source3/libnet/netapi.pc)
+ install /usr/local/samba/lib/pkgconfig/smbclient.pc (from bin/default/source3/libsmb/smbclient.pc)
[306/306] Linking bin/default/third_party/heimdal_build/compile_et.inst
[317/322] Processing ../heimdal/lib/asn1/der-protos.h: third_party/heimdal/lib/asn1/der_get.c third_party/heimdal/lib/asn1/der_put.c third_party/heimdal/lib/asn1/der_free.c third_party/heimdal/lib/asn1/der_format.c third_party/heimdal/lib/asn1/der_length.c third_party/heimdal/lib/asn1/der_copy.c third_party/heimdal/lib/asn1/der_cmp.c third_party/heimdal/lib/asn1/der_print.c third_party/heimdal/lib/asn1/extra.c third_party/heimdal/lib/asn1/timegm.c third_party/heimdal/lib/asn1/template.c third_party/heimdal/lib/asn1/oid_resolution.c -> bin/default/third_party/heimdal/lib/asn1/der-protos.h
Can't locate JSON.pm in @INC (you may need to install the JSON module) (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5) at /root/samba-4.16.3/third_party/heimdal/cf/make-proto.pl line 7.
BEGIN failed--compilation aborted at /root/samba-4.16.3/third_party/heimdal/cf/make-proto.pl line 7.

Waf: Leaving directory `/root/samba-4.16.3/bin/default'
Build failed
 -> task in '../heimdal/lib/asn1/der-protos.h' failed with exit status 2 (run with -v to display more information)
make: *** [Makefile:10: install] エラー 1
#

「dnf install perl-JSON」で対処

# dnf install perl-JSON
メタデータの期限切れの最終確認: 0:24:56 時間前の 2022年07月19日 09時59分33秒 に 実施しました。
依存関係が解決しました。
================================================================================
 パッケージ      Arch         バージョン              リポジトリー        サイズ
================================================================================
インストール:
 perl-JSON       noarch       2.97.001-2.el8          ol8_appstream        96 k

トランザクションの概要
================================================================================
インストール  1 パッケージ

ダウンロードサイズの合計: 96 k
インストール後のサイズ: 245 k
これでよろしいですか? [y/N]: y
パッケージのダウンロード:
perl-JSON-2.97.001-2.el8.noarch.rpm              70 kB/s |  96 kB     00:01
--------------------------------------------------------------------------------
合計                                             70 kB/s |  96 kB     00:01
トランザクションの確認を実行中
トランザクションの確認に成功しました。
トランザクションのテストを実行中
トランザクションのテストに成功しました。
トランザクションを実行中
  準備             :                                                        1/1
  インストール中   : perl-JSON-2.97.001-2.el8.noarch                        1/1
  scriptletの実行中: perl-JSON-2.97.001-2.el8.noarch                        1/1
  検証             : perl-JSON-2.97.001-2.el8.noarch                        1/1

インストール済み:
  perl-JSON-2.97.001-2.el8.noarch

完了しました!
#

以上でsamba-4.16.3のコンパイルが正常に終了した。

sambaのDNSでは委任(delegate)ができないようだ

PowerScaleシミュレータのSmartConnect動作を見てみようと、samba 4.15.5で作ったActive DirectoryのDNSサーバ機能で名前解決動作を試みて見た。

結果、samba 4.15.5ではWindowsのDNS管理ツールから行う「委任ウィザード」の「ネームサーバーレコード」の登録で「検証エラー」が発生するためうまく動作しなかった。

sa

samba-tool コマンドでNSレコードの登録を行ってみたところ登録ができるが、指定したDNSサーバに聞きに行くわけではない、という動作だった。

同じ操作をWindows Server 2019で作ったActive Directory環境で試すと何も問題が無く設定完了した

古いONTAPがActive Directoryに参加できない

2026/03/04追記

この記事を書いたのは2021年の話ですが、2023年7月ぐらいのCVE-2022-38023関連のActive Directoryの仕様変更に伴って、古いONTAPでActive Directoryに参加できない、という事例は増えていますので、2026年3月時点での状況についてまとめます

・ONTAP 8.3.2などの古すぎるもの はAES暗号化に対応していないので参加不可。ONTAPバージョンアップ必須
・ONTAP 9.10.1より前のONTAP はAES暗号化およびNetlogonでのAES暗号化利用が標準で有効になっていないのでそのままでは参加不可。設定を変更する
・ONTAP 9.10.1~9.12.1のONTAP はAES暗号化が標準で有効になっていないのでそのままでは参加不可。設定を変更する

なお、Active Directoryサーバ側のセキュリティ強化状態を緩和することで、対応していなくてもActive Directoryに参加させることは可能ではありますが、お勧めではありません。

2023年5月「Active Directoryサーバのセキュリティ強化アップデート(CVE-2022-38023)に伴うONTAPファイルサーバへの影響についてのメモ

2023年10月「CVE-2022-38023適用後 NetAppがActive Directoryに参加できない

2024年4月「CVE-2022-38023対応後のsamba ADサーバに古いONTAPを参加させる」(sambaの設定を意図的に脆弱なものにする)


以下、もとからの記事


古いONTAP、具体的にはONTAP 8.3.2環境の移行案件があったので、検証のためにONTAP simulatorのONTAP 8.3.2版を仮想環境上に作成して、Active Directoryに参加しようとしたところ下記のエラーとなった。(なお、接続先Active Direcrotyはsamba 4.14.5で構成している)

ontap832::> vserver cifs create -cifs-server share226 -domain adosakana.local -vserver share226

In order to create an Active Directory machine account for the CIFS server, you
must supply the name and password of a Windows account with sufficient
privileges to add computers to the "CN=Computers" container within the
ADOSAKANA.LOCAL domain.

Enter the user name: administrator

Enter the password:

Error: Machine account creation procedure failed
  [ 12154] Loaded the preliminary configuration.
  [ 12332] Created a machine account in the domain
  [ 12339] Successfully connected to 172.17.44.49:445 using TCP
  [ 12351] Unable to connect to LSA service on
           samba.adosakana.local (Error:
           RESULT_ERROR_GENERAL_FAILURE)
  [ 14357] TCP connection to 172.17.44.141:445 via interface
           172.17.44.236 failed: (Operation timed out).
  [ 14357] Could not open a socket to 'samba.adosakana.local'
  [ 14357] Unable to connect to LSA service on
           samba.adosakana.local (Error:
           RESULT_ERROR_SPINCLIENT_UNABLE_TO_RESOLVE_SERVER)
  [ 14357] No servers available for MS_LSA, vserver: 2, domain:
           adosakana.local.
**[ 14357] FAILURE: Unable to make a connection (LSA:adosakana.local),
**         result: 6940
  [ 14357] Could not find Windows SID
           'S-1-5-21-937304154-1581684492-536532533-512'
  [ 14381] Deleted existing account
           'CN=SHARE226,CN=Computers,DC=adosakana,DC=local'

Error: command failed: Failed to create the Active Directory machine account
       "SHARE226". Reason: SecD Error: no server available.

ontap832::>

これは暗号化の問題なので「vserver cifs security show」で設定項目を確認する。

ontap832::> vserver cifs security show -vserver share226

Vserver: share226

                    Kerberos Clock Skew:                   - minutes
                    Kerberos Ticket Age:                   - hours
                   Kerberos Renewal Age:                   - days
                   Kerberos KDC Timeout:                   - seconds
                    Is Signing Required:                   -
        Is Password Complexity Required:                   -
   Use start_tls For AD LDAP connection:               false
              Is AES Encryption Enabled:               false
                 LM Compatibility Level:  lm-ntlm-ntlmv2-krb
             Is SMB Encryption Required:                   -

ontap832::>

ONTAP 8.3.2無印では関連するオプション「SMB2 Enabled for DC Connections」を設定する項目が無い

ontap832::> version -node *

ontap832-01:
NetApp Release 8.3.2: Tue Feb 23 23:35:06 UTC 2016


ontap832::>

アップデータを探したところ、832P12_q_image.tgz(リンク先はNetAppサポートサイトにログインを済ませてからアクセス) があったので、「ONTAP 9.7シミュレータをアップデートする手法」と同じ手法でアップデートを行った。

ontap832::> version -node *

ontap832-01:
NetApp Release 8.3.2P12: Mon Aug 14 02:57:01 UTC 2017


ontap832::>

ONTAP 8.3.2P12であれば、「SMB2 Enabled for DC Connections」が存在していた。

ontap832::> vserver cifs security show -vserver share226

Vserver: share226

                    Kerberos Clock Skew:                   - minutes
                    Kerberos Ticket Age:                   - hours
                   Kerberos Renewal Age:                   - days
                   Kerberos KDC Timeout:                   - seconds
                    Is Signing Required:                   -
        Is Password Complexity Required:                   -
   Use start_tls For AD LDAP connection:               false
              Is AES Encryption Enabled:               false
                 LM Compatibility Level:  lm-ntlm-ntlmv2-krb
             Is SMB Encryption Required:                   -
        SMB1 Enabled for DC Connections:                   -
        SMB2 Enabled for DC Connections:                   -

ontap832::>

設定を変更

ontap832::> vserver cifs security modify -vserver share226 -smb1-enabled-for-dc-connections false -smb2-enabled-for-dc-connections true

ontap832::> vserver cifs security show -vserver share226

Vserver: share226

                    Kerberos Clock Skew:                   - minutes
                    Kerberos Ticket Age:                   - hours
                   Kerberos Renewal Age:                   - days
                   Kerberos KDC Timeout:                   - seconds
                    Is Signing Required:                   -
        Is Password Complexity Required:                   -
   Use start_tls For AD LDAP connection:               false
              Is AES Encryption Enabled:               false
                 LM Compatibility Level:  lm-ntlm-ntlmv2-krb
             Is SMB Encryption Required:                   -
        SMB1 Enabled for DC Connections:               false
        SMB2 Enabled for DC Connections:                true

ontap832::>

そして、Active Directoryへの参加

ontap832::> vserver cifs create -cifs-server share226 -domain adosakana.local -vserver share226

In order to create an Active Directory machine account for the CIFS server, you
must supply the name and password of a Windows account with sufficient
privileges to add computers to the "CN=Computers" container within the
ADOSAKANA.LOCAL domain.

Enter the user name: administrator

Enter the password:

Warning: An account by this name already exists in Active Directory at
         CN=SHARE226,CN=Computers,DC=adosakana,DC=local
         Ok to reuse this account? {y|n}: y

ontap832::>

今度は成功した。

MariaDB 5.5から10.6にアップデートして死にかけた件(utf8が無くなった)

CentOS7上で動いているMariaDB 5.5サーバをMariaDB 10.6にアップデートして死にかけた。


2022/10/28追記:この件に関するMariaDB公式のお知らせ的な物。どうやらold_mode を設定すると対処できるらしい


データベースのアップデート自体は問題なかったのだが、アプリケーション側で問題発生。

/var/log/messages に下記の様なメッセージが多発

Jul 13 10:50:11 ホスト名 kernel: dict[23339]: segfault at a8 ip 00007f99c6fa9fa1 sp 00007ffc4641fe50 error 4 in libmysqlclient.so.18.0.0[7f99c6f4b000+320000]
Jul 13 10:50:11 ホスト名 mariadbd: 2021-07-13 10:50:11 7 [Warning] Aborted connection 7 to db: 'unconnected' user: 'unauthenticated' host: 'localhost' (This connection closed normally without authentication)
Jul 13 10:50:11 ホスト名 kernel: dict[23340]: segfault at a8 ip 00007f3950ee4fa1 sp 00007ffe8bec4f70 error 4 in libmysqlclient.so.18.0.0[7f3950e86000+320000]
Jul 13 10:50:11 ホスト名 kernel: dict[23341]: segfault at a8 ip 00007f89b3d8efa1 sp 00007ffed464d830 error 4 in libmysqlclient.so.18.0.0[7f89b3d30000+320000]
Jul 13 10:50:11 ホスト名 mariadbd: 2021-07-13 10:50:11 8 [Warning] Aborted connection 8 to db: 'unconnected' user: 'unauthenticated' host: 'localhost' (This connection closed normally without authentication)
Jul 13 10:50:33 ホスト名 kernel: auth[23362]: segfault at a8 ip 00007f197609dfa1 sp 00007ffe82dc98a0 error 4 in libmysqlclient.so.18.0.0[7f197603f000+320000]

authとdictでlibmysqlclient.so.18.0.0 のsegmentation faultが発生しているという・・・

で・・このauthとdictというのはdovecot/authとdovecot/dictで、そこで何か起こっているようだ

/var/log/dovecot/dovecot.log を見てみる

Jul 13 10:50:05 ホスト名1 dovecot: dict(23024): Error: mysql(127.0.0.1): Connect failed to database (vmail): Can't connect to MySQL s
erver on '127.0.0.1' (111 "Connection refused") - waiting for 5 seconds before retry
Jul 13 10:50:05 ホスト名1 dovecot: dict(23024): Error: mysql(127.0.0.1): Connect failed to database (vmail): Can't connect to MySQL s
erver on '127.0.0.1' (111 "Connection refused") - waiting for 5 seconds before retry
Jul 13 10:50:10 ホスト名1 dovecot: dict: Error: #007Character set 'utf8' is not a compiled character set and is not specified in the '/usr/share/mysql/charsets/Index.xml' file
Jul 13 10:50:10 ホスト名1 dovecot: dict(23024): Error: mysql(127.0.0.1): Connect failed to database (vmail): Can't initialize character set utf8 (path: /usr/share/mysql/charsets/) - waiting for 25 seconds before retry
Jul 13 10:50:10 ホスト名1 dovecot: dict: Error: #007Character set 'utf8' is not a compiled character set and is not specified in the '/usr/share/mysql/charsets/Index.xml' file
Jul 13 10:50:10 ホスト名1 dovecot: dict(23024): Error: mysql(127.0.0.1): Connect failed to database (vmail): Can't initialize character set utf8 (path: /usr/share/mysql/charsets/) - waiting for 25 seconds before retry
Jul 13 10:50:11 ホスト名1 dovecot: dict: Error: #007Character set 'utf8' is not a compiled character set and is not specified in the '/usr/share/mysql/charsets/Index.xml' file
Jul 13 10:50:11 ホスト名1 dovecot: dict(23338): Error: mysql(127.0.0.1): Connect failed to database (vmail): Can't initialize character set utf8 (path: /usr/share/mysql/charsets/) - waiting for 1 seconds before retry

mariadb 10.6で文字コード utf8の指定ができないというエラーなようだ。

/usr/share/mysql/charsets/ に utf8の定義があるか確認してみる

# ls -l /usr/share/mysql/charsets/
合計 236
-rw-r--r-- 1 root root 23531  7月  5 19:47 Index.xml
-rw-r--r-- 1 root root  1749  7月  5 19:47 README
-rw-r--r-- 1 root root  5526  7月  5 19:47 armscii8.xml
-rw-r--r-- 1 root root  5512  7月  5 19:47 ascii.xml
-rw-r--r-- 1 root root  8241  7月  5 19:47 cp1250.xml
-rw-r--r-- 1 root root  8365  7月  5 19:47 cp1251.xml
-rw-r--r-- 1 root root  5569  7月  5 19:47 cp1256.xml
-rw-r--r-- 1 root root  8902  7月  5 19:47 cp1257.xml
-rw-r--r-- 1 root root  5506  7月  5 19:47 cp850.xml
-rw-r--r-- 1 root root  5528  7月  5 19:47 cp852.xml
-rw-r--r-- 1 root root  5613  7月  5 19:47 cp866.xml
-rw-r--r-- 1 root root  6529  7月  5 19:47 dec8.xml
-rw-r--r-- 1 root root  5516  7月  5 19:47 geostd8.xml
-rw-r--r-- 1 root root  5728  7月  5 19:47 greek.xml
-rw-r--r-- 1 root root  5517  7月  5 19:47 hebrew.xml
-rw-r--r-- 1 root root  5502  7月  5 19:47 hp8.xml
-rw-r--r-- 1 root root  5529  7月  5 19:47 keybcs2.xml
-rw-r--r-- 1 root root  5510  7月  5 19:47 koi8r.xml
-rw-r--r-- 1 root root  6532  7月  5 19:47 koi8u.xml
-rw-r--r-- 1 root root  9816  7月  5 19:47 latin1.xml
-rw-r--r-- 1 root root  7238  7月  5 19:47 latin2.xml
-rw-r--r-- 1 root root  5515  7月  5 19:47 latin5.xml
-rw-r--r-- 1 root root  7438  7月  5 19:47 latin7.xml
-rw-r--r-- 1 root root  8047  7月  5 19:47 macce.xml
-rw-r--r-- 1 root root  8058  7月  5 19:47 macroman.xml
-rw-r--r-- 1 root root  6530  7月  5 19:47 swe7.xml
# grep utf8 /usr/share/mysql/charsets/Index.xml
<charset name="utf8mb3">
  <collation name="utf8mb3_general_ci"  id="33">
  <collation name="utf8mb3_bin"         id="83">
#

なんと無い。

/usr/share/mysql/charsets/Index.xml のutf8関連記述を見てみる

<charset name="utf8mb3">
  <family>Unicode</family>
  <description>UTF-8 Unicode</description>
  <alias>utf-8</alias>
  <collation name="utf8mb3_general_ci"  id="33">
   <flag>primary</flag>
   <flag>compiled</flag>
  </collation>
  <collation name="utf8mb3_bin"         id="83">
    <flag>binary</flag>
    <flag>compiled</flag>
  </collation>
</charset>

おやぁ???

以前mariadb 10.5にアップデートしたサーバの/usr/share/mysql/charsets/Index.xmlの該当箇所と比較すると、いままでは utf8だったエントリが utf8mb3 に置き換わっているようだ。

<charset name="utf8">
  <family>Unicode</family>
  <description>UTF-8 Unicode</description>
  <alias>utf-8</alias>
  <collation name="utf8_general_ci"     id="33">
   <flag>primary</flag>
   <flag>compiled</flag>
  </collation>
  <collation name="utf8_bin"            id="83">
    <flag>binary</flag>
    <flag>compiled</flag>
  </collation>
</charset>

で・・・ /etc/my.cnf の設定で言語に関する設定は下記の様になっていた

[mysqld]
<略>
# character-set-server に関する値は未設定
<略>
[client]
default-character-set=utf8

クライアントからのアクセス時のデフォルトがutf8と設定されていた。

そこで/etc/my.cnf の文字コード指定を utf8mb3 に変更

[mysqld]
<略>
character-set-server=utf8mb3
<略>
[client]
default-character-set=utf8mb3

これで接続できない、という事象はなくなった。

なくなったが、/var/log/messages には下記のメッセージが出続けている。

Jul 13 13:10:01 ホスト名 mariadbd: 2021-07-13 13:10:01 925 [Warning] Aborted connection 925 to db: 'unconnected' user: 'unauthenticated' host: 'localhost' (This connection closed normally without authentication)
Jul 13 13:10:02 ホスト名 mariadbd: 2021-07-13 13:10:02 934 [Warning] Aborted connection 934 to db: 'unconnected' user: 'unauthenticated' host: 'localhost' (This connection closed normally without authentication)
Jul 13 13:10:06 ホスト名 mariadbd: 2021-07-13 13:10:06 935 [Warning] Aborted connection 935 to db: 'unconnected' user: 'unauthenticated' host: 'localhost' (This connection closed normally without authentication)
Jul 13 13:10:06 ホスト名 mariadbd: 2021-07-13 13:10:06 936 [Warning] Aborted connection 936 to db: 'unconnected' user: 'unauthenticated' host: 'localhost' (This connection closed normally without authentication)
Jul 13 13:10:22 ホスト名 mariadbd: 2021-07-13 13:10:22 811 [Warning] Aborted connection 811 to db: 'amavisd' user: 'amavisd' host: 'localhost' (Got timeout reading communication packets)
Jul 13 13:11:01 ホスト名 mariadbd: 2021-07-13 13:11:01 786 [Warning] Aborted connection 786 to db: 'amavisd' user: 'amavisd' host: 'localhost' (Got timeout reading communication packets)
Jul 13 13:12:26 ホスト名 mariadbd: 2021-07-13 13:12:26 839 [Warning] Aborted connection 839 to db: 'amavisd' user: 'amavisd' host: 'localhost' (Got timeout reading communication packets)
Jul 13 13:12:26 ホスト名 mariadbd: 2021-07-13 13:12:26 828 [Warning] Aborted connection 828 to db: 'amavisd' user: 'amavisd' host: 'localhost' (Got timeout reading communication packets)

iRedMailフォーラム「mysqld [Warning] Aborted connection」によると、ログレベル下げろ、とのこと

mysqlを起動しようとしたら問題が・・・

# mysql -u root
ERROR 2019 (00000): Can't initialize character set utf8mb3 (path: compiled_in)
#

とりあえず /etc/my.cnf の最後に下記を追加

[mysql]
default-character-set=utf8

警告はでるのもの操作は可能(なお、default-character-set=utf8mb3 だと起動できなかった)

# mysql -u root
mysql: Warning: Charset id '33' csname 'utf8mb3' trying to replace existing csname 'utf8'
mysql: Warning: Charset id '83' csname 'utf8mb3' trying to replace existing csname 'utf8'
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 1103
Server version: 10.6.3-MariaDB-log MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

起動したのでフォーラムにあった設定を入れる。

MariaDB [(none)]> show global variables like '%log_warnings%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_warnings  | 2     |
+---------------+-------+
1 row in set (0.002 sec)

MariaDB [(none)]> set global log_warnings=1;
Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]> show global variables like '%log_warnings%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_warnings  | 1     |
+---------------+-------+
1 row in set (0.002 sec)

MariaDB [(none)]> quit
Bye
#

しばらく放置・・・

Jul 13 13:40:01 ホスト名 mariadbd: 2021-07-13 13:40:01 313 [Warning] Aborted connection 313 to db: 'unconnected' user: 'unauthenticated' host: 'localhost' (This connection closed normally without authentication)
Jul 13 13:40:02 ホスト名 mariadbd: 2021-07-13 13:40:02 314 [Warning] Aborted connection 314 to db: 'unconnected' user: 'unauthenticated' host: 'localhost' (This connection closed normally without authentication)
Jul 13 13:40:04 ホスト名 mariadbd: 2021-07-13 13:40:04 315 [Warning] Aborted connection 315 to db: 'unconnected' user: 'unauthenticated' host: 'localhost' (This connection closed normally without authentication)
Jul 13 13:42:53 ホスト名 mariadbd: 2021-07-13 13:42:53 359 [Warning] Aborted connection 359 to db: 'vmail' user: 'vmail' host: 'localhost' (Got an error reading communication packets)
Jul 13 13:42:53 ホスト名 mariadbd: 2021-07-13 13:42:53 352 [Warning] Aborted connection 352 to db: 'vmail' user: 'vmail' host: 'localhost' (Got an error reading communication packets)
Jul 13 13:42:53 ホスト名 mariadbd: 2021-07-13 13:42:53 357 [Warning] Aborted connection 357 to db: 'vmail' user: 'vmail' host: 'localhost' (Got an error reading communication packets)
Jul 13 13:42:53 ホスト名 mariadbd: 2021-07-13 13:42:53 351 [Warning] Aborted connection 351 to db: 'vmail' user: 'vmail' host: 'localhost' (Got an error reading communication packets)

うーん?

あれ?反映されてない

# mysql -u root
mysql: Warning: Charset id '33' csname 'utf8mb3' trying to replace existing csname 'utf8'
mysql: Warning: Charset id '83' csname 'utf8mb3' trying to replace existing csname 'utf8'
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 474
Server version: 10.6.3-MariaDB-log MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show global variables like '%log_warnings%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_warnings  | 2     |
+---------------+-------+
1 row in set (0.002 sec)

MariaDB [(none)]> set global log_warnings=1;
Query OK, 0 rows aff
MariaDB [(none)]>

なんだろ?とりあえず再設定・・・

今度は大丈夫か?

…2時間経過

大丈夫そうだな


2021/07/15追記

注:下記はmariadbのserverとclientのバージョンが違っていたことによる問題でなので参考情報です

iredmailでは/usr/local/bin/fail2ban_banned_dbがcronにより毎分実行されているのだが、これがmysqlコマンドを使ってデータベース操作をしているようで、下記のメールが届くようになってしまった・・・

mysql: Warning: Charset id '33' csname 'utf8mb3' trying to replace existing csname 'utf8'
mysql: Warning: Charset id '83' csname 'utf8mb3' trying to replace existing csname 'utf8'

mysqlコマンドを実行した際のメッセージをなんとしてでも消さなければならないようだ。

utf8がutf8mb3になった変更について「MariaDB Server/MDEV-8334/Rename utf8 to utf8mb3

MariaDBの「OLD_MODE」という設定

# mysql -u root
mysql: Warning: Charset id '33' csname 'utf8mb3' trying to replace existing csname 'utf8'
mysql: Warning: Charset id '83' csname 'utf8mb3' trying to replace existing csname 'utf8'
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 38510
Server version: 10.6.3-MariaDB-log MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> SELECT REPLACE(@@OLD_MODE, ',', '\n');
+--------------------------------+
| REPLACE(@@OLD_MODE, ',', '\n') |
+--------------------------------+
| UTF8_IS_UTF8MB3                |
+--------------------------------+
1 row in set (0.023 sec)

MariaDB [(none)]>

現状は「UTF8_IS_UTF8MB3」が設定されているので、UTF8=UTF8MB3扱いになるらしいが、設定されていない場合は「UTF8=UTF8MB4」となるそうな。

だったら、「utf8」でアクセスした場合でも勝手に読み替えて欲しいもんなんだけど、どうなっているのか???

MariaDB [(none)]> show variables like 'char%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8mb3                    |
| character_set_connection | utf8mb3                    |
| character_set_database   | utf8mb3                    |
| character_set_filesystem | binary                     |
| character_set_results    | utf8mb3                    |
| character_set_server     | utf8mb3                    |
| character_set_system     | utf8mb3                    |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.002 sec)

MariaDB [(none)]>
MariaDB [(none)]> show global variables like '%character_set%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8mb3                    |
| character_set_connection | utf8mb3                    |
| character_set_database   | utf8mb3                    |
| character_set_filesystem | binary                     |
| character_set_results    | utf8mb3                    |
| character_set_server     | utf8mb3                    |
| character_set_system     | utf8mb3                    |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.002 sec)

MariaDB [(none)]> show global variables like 'collation%';
+----------------------+--------------------+
| Variable_name        | Value              |
+----------------------+--------------------+
| collation_connection | utf8mb3_general_ci |
| collation_database   | utf8mb3_general_ci |
| collation_server     | utf8mb3_general_ci |
+----------------------+--------------------+
3 rows in set (0.002 sec)

MariaDB [(none)]>

ん?????

トラブル生じた時に、MariaDB10.5にしなかったっけ?と

# rpm -qa | grep MariaDB
MariaDB-client-10.5.11-1.el7.centos.x86_64
MariaDB-compat-10.6.3-1.el7.centos.x86_64
MariaDB-common-10.6.3-1.el7.centos.x86_64
MariaDB-server-10.6.3-1.el7.centos.x86_64
#

あー・・・MariaDB-clientとMariaDB-serverのバージョンがずれていました。

そんなわけで、MariaDB-clientの方も 10.6.3に揃えて再実行

# mysql -u root
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 405
Server version: 10.6.3-MariaDB-log MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> exit
Bye
#

というわけで、解決しました。