0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

FreeBSDを13.x→14.xにアップグレードした際に発生するPAMモジュールエラーの対処法

Posted at

概要

FreeBSDを14系にアップグレードした際、PAMモジュール周りのエラーが出るようになってしまいました。
/etc/pam.d/system の設定を修正することで対応できるのですが、認証モジュールまわりのエラーであるためログインできない状態になってしまいます。この問題の対処方法を備忘録的にまとめました。

PAMまわりのエラー

FreeBSDを13.xから14.xにアップグレードしたところ、 sudosu コマンドで以下のエラーが発生するようになってしまいました。

$ sudo id
sudo: PAM を初期化できません: 無効な実行形式です
$ LANG=C sudo id
sudo: unable to initialize PAM: Exec format error
$
$ su -
su: pam_start: System error

この問題自体の対処は簡単で、 /etc/pam.d/system から pam_opie*.so の設定をコメントアウトするだけで良さそうです。

$ diff -u /etc/pam.d/system.ORIG /etc/pam.d/system
--- /etc/pam.d/system.ORIG      2024-10-25 18:54:32.196400000 +0900
+++ /etc/pam.d/system   2024-10-25 18:54:38.856547000 +0900
@@ -5,8 +5,8 @@
 #

 # auth
-auth           sufficient      pam_opie.so             no_warn no_fake_prompts
-auth           requisite       pam_opieaccess.so       no_warn allow_local
+#auth          sufficient      pam_opie.so             no_warn no_fake_prompts
+#auth          requisite       pam_opieaccess.so       no_warn allow_local
 #auth          sufficient      pam_krb5.so             no_warn try_first_pass
 #auth          sufficient      pam_ssh.so              no_warn try_first_pass
 auth           required        pam_unix.so             no_warn try_first_pass nullok

しかし、sshログインはできるものの、 root ユーザに切り替え出来ない状態であり、加えてコンソールからログインしようにも同じようなエラーが発生するため、実質的に /etc/pam.d/system の編集が行えません…🥺

シングルユーザモードでの起動で対応する

このような場合、FreeBSDをシングルユーザモードで起動して対処します。私の環境ではさくらのVPSを利用しており、以降はVPS環境での手順になります。

コンソールを開き、右上の Ctrl + Alt + Del ボタンを押します。確認ダイアログが出たのちにインスタンスが再起動します。

fbsd01.PNG

以下の画面でスペースキーを押して起動オプションの入力待ち状態にし、"2 Boot Single User"を選択します(「2」キーを押す)。

fbsd02.PNG

シングルユーザモードで /bin/sh が実行されるので、以下の手順でルートパーティションを書き込み可能で再マウントすることで /etc/pam.d/system が編集可能になります。

fbsd03.PNG

先述した修正内容を /etc/pam.d/system に適用します。

$ diff -u /etc/pam.d/system.ORIG /etc/pam.d/system
--- /etc/pam.d/system.ORIG      2024-10-25 18:54:32.196400000 +0900
+++ /etc/pam.d/system   2024-10-25 18:54:38.856547000 +0900
@@ -5,8 +5,8 @@
 #

 # auth
-auth           sufficient      pam_opie.so             no_warn no_fake_prompts
-auth           requisite       pam_opieaccess.so       no_warn allow_local
+#auth          sufficient      pam_opie.so             no_warn no_fake_prompts
+#auth          requisite       pam_opieaccess.so       no_warn allow_local
 #auth          sufficient      pam_krb5.so             no_warn try_first_pass
 #auth          sufficient      pam_ssh.so              no_warn try_first_pass
 auth           required        pam_unix.so             no_warn try_first_pass nullok

最後にマシンを再起動することで問題が解消された状態になります。

まとめ

FreeBSDのアップグレードによるPAMモジュールエラーの対処方法をまとめました。FreeBSDのアップグレードはちょいちょいトラブルが発生しがちな感じで(※個人の感想です)、このような対応手順をこまめにまとめておきたいところです。
(今回みたいに解消方法はあるけど、そこに至るまでの手順などの解説は丁寧に行いたい感じです)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?