6
7

More than 5 years have passed since last update.

yumで入れたパッケージのコンフィグの差分を確認したい話

Last updated at Posted at 2016-04-25

背景

RHELやらCentosやら、yumなどのパッケージ管理ツールでソフトウェアを入れた時、だいたいの場合コンフィグも一緒に入ってくれる。
ゼロからコンフィグを書くのはしんどいので凄く便利、なんだけど、デフォルトのコンフィグがいつでもそのまま使えるワケではなくて、何かしらの修正を加えることになる。

ものによっては .d ディレクトリに新規ファイルを作るとか、 .local みたいな拡張子で設定を上書きするとか、パッケージ管理ツールで入るコンフィグに直接手を加えずに設定できるものもあるけど、直接パッケージ管理ツールで入るコンフィグを修正しないといけない場合も結構ある。

で、パッケージのアップデートしたい、とか、サーバーを移行したいなんて時に、デフォルトのコンフィグからどんな修正を加えたかなぁ、と調べたいことが結構多々ある(ありますよね?)

調べてみると rpmdevtools パッケージに入っている rpmpeek というコマンドで、パッケージと現在の状況との差分を作ってくれる、らしい……
のだけど、どうにもこうにも手元の環境では rpmpeek なんてコマンドは無い。

あと、 rpm -V で手元の環境に差分があるかどうかの確認はできる。
のだけど実際どんな修正をいれたのかまではワカラナイ。

仕方が無いので自作してみた。

概要

ソース: https://github.com/takei-yuya/rpmdiff

コマンド一発で、例えばこんなdiffが作れます (openssh-serverの例)

--- /etc/ssh/sshd_config
+++ /etc/ssh/sshd_config    2016-02-20 12:37:50.866572704 +0900
@@ -14,13 +14,13 @@
 # SELinux about this change.
 # semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
 #
-#Port 22
+Port 10022
 #AddressFamily any
 #ListenAddress 0.0.0.0
 #ListenAddress ::

 # The default requires explicit activation of protocol 1
-#Protocol 2
+Protocol 2

 # HostKey for protocol version 1
 #HostKey /etc/ssh/ssh_host_key
@@ -46,13 +46,13 @@
 # Authentication:

 #LoginGraceTime 2m
-#PermitRootLogin yes
+PermitRootLogin no
 #StrictModes yes
 #MaxAuthTries 6
 #MaxSessions 10

-#RSAAuthentication yes
-#PubkeyAuthentication yes
+RSAAuthentication yes
+PubkeyAuthentication yes

 # The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
 # but this is overridden so installations will only check .ssh/authorized_keys
@@ -76,7 +76,7 @@
 # To disable tunneled clear text passwords, change to no here!
 #PasswordAuthentication yes
 #PermitEmptyPasswords no
-PasswordAuthentication yes
+PasswordAuthentication no

 # Change to no to disable s/key passwords
 #ChallengeResponseAuthentication yes
@@ -109,8 +109,8 @@
 # problems.
 UsePAM yes

-#AllowAgentForwarding yes
-#AllowTcpForwarding yes
+AllowAgentForwarding yes
+AllowTcpForwarding yes
 #GatewayPorts no
 X11Forwarding yes
 #X11DisplayOffset 10
@@ -123,8 +123,8 @@
 UsePrivilegeSeparation sandbox     # Default for new installations.
 #PermitUserEnvironment no
 #Compression delayed
-#ClientAliveInterval 0
-#ClientAliveCountMax 3
+ClientAliveInterval 30
+ClientAliveCountMax 3
 #ShowPatchLevel no
 #UseDNS yes
 #PidFile /var/run/sshd.pid

やっていることは凄く単純で、 yum reinstall--downloadonly オプションを付けて、オリジナルの .rpm ファイルを取得。
その後、 rpm2cpio + cpio でファイルを抽出して、現在のファイル状況とdiffを取るだけ。
おまけで、ファイルに出力しつつも、画面への出力は pygmentize があったら色を付ける、なんてことをしています。

そんな説明することがなかった。

まぁ、あると地味に便利系ツールということで。 EoQ

// 編集する前に .orig とかバックアップを取っておけという話ですが……。

6
7
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
6
7