日立洗濯機API
日立の洗濯機は WiFi で接続できるので、nmap をかけてみたが、反応なし。
でも何気なく「日立 洗濯機 API」でググると、下記の解析した人の情報を見つける。洗濯機の状況を把握できると面白いので色々試してみよう。
ひとまず記事の確認で、UDP ポートの全スキャンすると 50000 からの反応が確認できた。
$ sudo nmap -sU -p- washer-dryer Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-10-29 16:03 JST Nmap scan report for washer-dryer (192.168.11.37) Host is up (0.018s latency). rDNS record for 192.168.xx.xx: washer-dryer Not shown: 65534 closed udp ports (port-unreach) PORT STATE SERVICE 50000/udp open|filtered unknown MAC Address: 9C:2F:9D:xx:xx:xx (Liteon Technology) Nmap done: 1 IP address (1 host up) scanned in 88.22 seconds
PyCryptodomeのインストール
$ sudo apt install python3-pycryptodome
or pip3 install pycryptodome
$ sudo apt install build-essential python-dev-is-python3
$ pip install pycryptodomex
$ pip install pycryptodome-test-vectors
$ python3 -m Cryptodome.SelfTest
sshd のエラーメッセージ
sshd の設定をあまり見直していないが、下記のメッセージが出るようになっている。
2024-10-05T20:03:58.314494+09:00 xxxx sshd[176045]: rexec line 15: Deprecated option UsePrivilegeSeparation 2024-10-05T20:03:58.314710+09:00 xxxx sshd[176045]: rexec line 18: Deprecated option KeyRegenerationInterval 2024-10-05T20:03:58.314778+09:00 xxxx sshd[176045]: rexec line 19: Deprecated option ServerKeyBits 2024-10-05T20:03:58.314840+09:00 xxxx sshd[176045]: rexec line 31: Deprecated option RSAAuthentication 2024-10-05T20:03:58.314896+09:00 xxxx sshd[176045]: rexec line 38: Deprecated option RhostsRSAAuthentication 2024-10-05T20:20:31.361176+09:00 xxxx sshd[177351]: Unable to load host key: /etc/ssh/ssh_host_dsa_key
どれも、関連する行をコメントアウトで対応。
mariadb のエラー対策
別件で /var/log/syslog を確認したら、下記のエラーが大量に出力されている。
2024-10-05T19:53:54.546148+09:00 xxxx mariadbd[1076]: 2024-10-05 19:53:54 3785 [ERROR] Incorrect definition of table mysql.column_stats: expected column 'hist_type' at position 9 to have type enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB'), found type enum('SINGLE_PREC_HB','DOUBLE_PREC_HB').
2024-10-05T19:53:54.546217+09:00 xxxx mariadbd[1076]: 2024-10-05 19:53:54 3785 [ERROR] Incorrect definition of table mysql.column_stats: expected column 'histogram' at position 10 to have type longblob, found type varbinary(255).
エラーメッセージでググると、下記のコマンドで直るとのこと。
ALTER TABLE mysql.column_stats MODIFY histogram longblob;
ALTER TABLE mysql.column_stats MODIFY hist_type enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB');
ということで、実行してみる。
# mariadb -u root
:
MariaDB [(none)]> ALTER TABLE mysql.column_stats MODIFY histogram longblob;
Query OK, 0 rows affected (0.496 sec)
Records: 0 Duplicates: 0 Warnings: 0
MariaDB [(none)]> ALTER TABLE mysql.column_stats MODIFY hist_type enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB');
Query OK, 0 rows affected (0.176 sec)
Records: 0 Duplicates: 0 Warnings: 0
エラーメッセージは出なくなったようだ。
あづぃ…
エアコンのない室内、max37℃….

脳みそ、熔ける…
muninの測定をnagios4で活用するには
switchbot の温湿度計を munin で読み取るための python スクリプトを活用していたけど、特定閾値を超えた際の処理は nagios4 の方が便利。munin の警告だと閾値を越えている間は何度も警告メールが飛んでくる。nagios であれば、こういった処理がうまい。
かといって、swichbot の python アプリを nagios の check_*** に書き換えてみたが、bluetooth のアクセス権限などの設定が煩雑だしうまくいかなかった。
でも、munin は、ネットワーク経由の監視の機能があるので、それを使うこととした。munin のリモート接続のポート番号4949に接続して、list で測定できるものの一覧が取れて、fetch すれば 値を読み取ってくれる。
((( telnet でプロトコルを確認 ))) $ telnet localhost 4949 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. # munin node at localhost list df load processes switchbotmeterbt . fetch switchbotmeterbt xxxxxxxxxxxx_Temperature.value 27.6 xxxxxxxxxxxx_Humidity.value 54 xxxxxxxxxxxx_Battery.value 87 xxxxxxxxxxxx_Discomfort.value 75.68896000000001 xxxxxxxxxxxx_WBGT.value 24.176256000000006 . QUIT Connection closed by foreign host. ((( 単純なので nc を使って読ませる ))) $ echo -e "fetch switchbotmeterbt\nQUIT\n" | nc localhost 4949 # munin node at localhost xxxxxxxxxxxx_Temperature.value 27.7 xxxxxxxxxxxx_Humidity.value 54 xxxxxxxxxxxx_Battery.value 87 xxxxxxxxxxxx_Discomfort.value 75.82342 xxxxxxxxxxxx_WBGT.value 24.268412 .
ということで、ちょっとだけ手抜きで nc とか使って perl を使って読み取らせる処理を書いてみた。
#!/usr/bin/perl
use strict ;
use warnings ;
my $SWBT_METER = "/usr/bin/echo -e 'fetch switchbotmeterbt\nQUIT\n' | /usr/bin/nc localhost 4949" ;
my %value = () ;
open( my $FH , "$SWBT_METER 2>/dev/null |" ) or die( "Can't open $SWBT_METER" ) ;
while ( my $line = <$FH> ) {
if ( $line =~ /^[0-9a-f]+_([^.]+)\.value\s+([\.0-9]+)\s*$/ ) {
$value{$1} = $2 ;
$flag = 1 ;
}
}
close( $FH ) ;
サーバのX11をWSLgに接続
ssh の ForwardX11 を使うのが簡単
((( サーバ側 /etc/ssh/sshd_config ))) X11Forwarding yes ((( wsl 側 /etc/ssh/ssh_config ))) ForwardX11 yes
((( wsl 側から ))) $ ssh -X ユーザ@サーバ
Debian/trixie 更新が頻繁
自宅サーバは、Debian/testing(trixie) で動かしているけど、この10日ほどは apt upgrade をかけると、大量の更新がかかる。しかもコアなパッケージに関連するのか、”aptitude safe-upgrade” だと未適用が若干残る。lib* がこぞって更新される。まぁ、Debian/testing なんてこれが普通ともいえるけど。”aptitude full-upgrade” だと、色々と動かなくなるソフトもでるから面倒なんだよなぁ…
xz-utils のバックドア問題
XZ形式の圧縮ファイル生成/解凍の xz-utils にバックドアが仕掛けられるというトラブルが報告されている。オープンソースで開発されているソフトで、誰かがソースコード中に悪意のあるコードを仕込んだらしい。このため、ソースでビルドされたパッケージにも影響する。xz-utils の 5.6.0, 5.6.1 が該当し、Debian でも testing / trixie などでインストールされる。
xz-utilsの確認とダウングレード Debian/trixie
確認すると、しっかりインストールされていた。
$ dpkg -l | grep xz-utils
ii xz-utils 5.6.1+really5.4.5-1 amd64
XZ-format compression utilities
さすがに怖いので、安全なバージョンが出るまでダウングレードだな。
$ sudo apt install xz-utils/stable $ sudo aptitude hold xz-utils
Ubuntu 2.2 LTSは大丈夫
dpkg -l | grep xz-utils
ii xz-utils 5.2.5-2ubuntu1 amd64
XZ-format compression utilities
$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.4 LTS"
:
具体的な情報を探すと 「vulnerableなxzがインストールされている状態で xz –version を実行するとバックドアが開いてしまうので実行するなという話だそう。」という情報があるし、インストールされているとはいえ自分自身で活用していないので “xz –version” は実行していない。というか、この記事を遡ると Debian の 5.6.1+really5.4.5-1 は、5.4.5 に戻されていて大丈夫みたいだな。ということで改めて、apt install xz-utils で、5.6.1+really5.4.5-1 が入った。5.6.1 の様に見えるけど、実は 5.4.5 。
saslauthd のトラブル
saslauthdが起動しない
メールの送信機能が動いていない。色々と調べたら、”systemctl start saslauthd” を実行しても起動しない。
正確に言うなら、systemctl が終わらない。1,2分ほど待つとタイムアウトが発生して強制終了となっている。
# systemctl start saslauthd # --- 1,2分で強制終了となる # journalctl -xeu saslauthd # journalctl で確認できるとのメッセージがあるので The job identifier is 21448. 3月 15 08:51:27 xxxx saslauthd[33874]: : master pid is: 33874 3月 15 08:51:27 xxxx saslauthd[33874]: : listening on socket: /var/spool/postfix/var/run/saslauthd/mux 3月 15 08:51:27 xxxx systemd[1]: saslauthd.service: Can't open PID file /run/saslauthd/saslauthd.pid (yet?) after start: No such file or directory 3月 15 08:52:57 xxxx systemd[1]: saslauthd.service: start operation timed out. Terminating. 3月 15 08:52:57 xxxx saslauthd[33874]: : master exited: 33874 3月 15 08:52:57 xxxx systemd[1]: saslauthd.service: Failed with result 'timeout'. ░░ Subject: Unit failed
postfix の smtp認証の設定の影響
色々調べると、こちらの記事を見つける。
postfix の中で、smtpd の起動はデフォルト(非chroot)では、/var/run/saslauthd の中にパイプなどを作る。しかし、postfix で SMTP認証を使えるように設定するための設定では、smtpd を chroot で起動するために、/etc/default/saslauthd の中の設定で、/var/spool/postfix/var/run/saslauthd を使うように指定しないといけない。
((( /etc/default/saslauthd ))) # See /usr/share/doc/sasl2-bin/README.Debian for Debian-specific information. # See the saslauthd man page and the output of 'saslauthd -h' for general # information about these options. # # Example for chroot Postfix users: "-c -m /var/spool/postfix/var/run/saslauthd" # Example for non-chroot Postfix users: "-c -m /var/run/saslauthd" # # To know if your Postfix is running chroot, check /etc/postfix/master.cf. # If it has the line "smtp inet n - y - - smtpd" or "smtp inet n - - - - smtpd" # then your Postfix is running in a chroot. # If it has the line "smtp inet n - n - - smtpd" then your Postfix is NOT # running in a chroot. OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd"
しかし、何らかの更新の中で 非chroot の /var/run/saslauthd を参照する設定となり、この中にパイプなどを作っても反応がないために、起動に失敗している様子。
ということで、元記事に書いてあるように、/var/spool/postfix/var/run/saslauthd を使わせるために、シンボリックリンクを設置する。saslauthd パッケージの更新で chroot 起動の判定が不十分なのではないかな。
# rm -rf /var/run/saslauthd # ln -sf /var/spool/postfix/var/run/saslauthd /var/run/saslauthd # systemctl start saslauthd
(追記) 次は Permission denied
無事に saslauthd は起動するようになったけど、次はパスワード認証が受け付けない。LOG を確認すると下記のエラーがでるようになった。
2024-03-15T11:59:10.543324+09:00 xxxxx postfix/smtpd[46317]: warning: xxxxxx[xxx.xxx.xx.xx]: SASL PLAIN authentication failed: generic failure, sasl_username=xxxx@xxxx.xxx 2024-03-15T11:59:10.560548+09:00 xxxxx postfix/smtpd[46317]: warning: SASL authentication failure: cannot connect to saslauthd server: Permission denied
これまた、調べてみたけど /var/spool/postfix/var/run/saslauthd 配下のファイルのパーミッションが原因っぽい。
配下のファイルに、下記の制限を設定して無事にメールが出せるようになった。
# chmod -R +x /var/spool/postfix/var/run/saslauthd/

