Ubuntu(WSL)の git をアップデートする

7月 1, 2023Ubuntu(WSL)

概要

  • 少し前にGit にも深刻な脆弱性が報告されましたので、Ubuntu(WSL)にインストールしている git をアップデートしました。備忘録として記載します。今回は、オーバーフローの脆弱性が対策されたバージョンに更新します。

 

Ubuntu(WSL)の git アップデート方法

  • 先ず、git のversion を確認します。
niikawa@niikawa1:~$ git --version
git version 2.17.1
  • 念のため、git を brew でインストールしていたかbrew list コマンドで確認します。以下の通り、brew は使っていませんでした。apt で管理していた様です。
niikawa@niikawa1:~$ brew list | grep git
  • Git の公式サイトに記載の手順でアップデートを行います。 最新のGit はPPA (Personal Package Archiveの略)から提供されます。
  • add-apt-repository コマンドでPPA を追加します。PPA を追加後は、通常のapt コマンドでインストールが可能です。
niikawa@niikawa1:~$ sudo add-apt-repository ppa:git-core/ppa
 The most current stable version of Git for Ubuntu.

For release candidates, go to https://launchpad.net/~git-core/+archive/candidate .
 More info: https://launchpad.net/~git-core/+archive/ubuntu/ppa
Press [ENTER] to continue or Ctrl-c to cancel adding it.

Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease
Get:2 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Hit:4 http://ppa.launchpad.net/ansible/ansible/ubuntu bionic InRelease
Get:5 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [1300 kB]
Get:6 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [83.3 kB]
Get:7 http://ppa.launchpad.net/git-core/ppa/ubuntu bionic InRelease [20.8 kB]
Get:8 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [3032 kB]
Get:9 http://ppa.launchpad.net/git-core/ppa/ubuntu bionic/main amd64 Packages [3024 B]
Get:10 http://security.ubuntu.com/ubuntu bionic-security/universe Translation-en [307 kB]
Get:11 http://ppa.launchpad.net/git-core/ppa/ubuntu bionic/main Translation-en [2252 B]
Get:12 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [1910 kB]
Get:13 https://download.docker.com/linux/ubuntu bionic InRelease [64.4 kB]
Get:14 http://archive.ubuntu.com/ubuntu bionic-updates/universe Translation-en [420 kB]
Fetched 7320 kB in 5s (1539 kB/s)
Reading package lists... Done
  • apt updateでパッケージリストを更新します。
niikawa@niikawa1:~$ sudo apt update
  • apt installで gitのアップデートを行います。
niikawa@niikawa1:~$ sudo apt install git
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
  libfreetype6
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  git-man libpcre2-8-0
Suggested packages:
  git-daemon-run | git-daemon-sysvinit git-doc git-email git-gui gitk gitweb git-cvs git-mediawiki git-svn
The following NEW packages will be installed:
  libpcre2-8-0
The following packages will be upgraded:
  git git-man
2 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 9635 kB of archives.
After this operation, 14.9 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://ppa.launchpad.net/git-core/ppa/ubuntu bionic/main amd64 git amd64 1:2.41.0-0ppa1~ubuntu18.04.1 [7343 kB]
Get:2 http://archive.ubuntu.com/ubuntu bionic/universe amd64 libpcre2-8-0 amd64 10.31-2 [179 kB]
Get:3 http://ppa.launchpad.net/git-core/ppa/ubuntu bionic/main amd64 git-man all 1:2.41.0-0ppa1~ubuntu18.04.1 [2113 kB]
Fetched 9635 kB in 13s (749 kB/s)
(Reading database ... 45202 files and directories currently installed.)
Preparing to unpack .../git_1%3a2.41.0-0ppa1~ubuntu18.04.1_amd64.deb ...
Unpacking git (1:2.41.0-0ppa1~ubuntu18.04.1) over (1:2.17.1-1ubuntu0.18) ...
Preparing to unpack .../git-man_1%3a2.41.0-0ppa1~ubuntu18.04.1_all.deb ...
Unpacking git-man (1:2.41.0-0ppa1~ubuntu18.04.1) over (1:2.17.1-1ubuntu0.18) ...
Selecting previously unselected package libpcre2-8-0:amd64.
Preparing to unpack .../libpcre2-8-0_10.31-2_amd64.deb ...
Unpacking libpcre2-8-0:amd64 (10.31-2) ...
Setting up git-man (1:2.41.0-0ppa1~ubuntu18.04.1) ...
Setting up libpcre2-8-0:amd64 (10.31-2) ...
Setting up git (1:2.41.0-0ppa1~ubuntu18.04.1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for libc-bin (2.27-3ubuntu1.6) ...
  • git のversion を確認します。脆弱性が対策されたバージョンに更新されました。
niikawa@niikawa1:~$ git version
git version 2.41.0

 

Ubuntu(WSL)

Posted by takaaki