カテゴリー: 技術系

  • UbuntuでGitLab CEの更新でGPGキーのエラーが出た

    Ubuntu 20.04 LTSで、apt updateでgitlab-ceの更新で、GPGキーのエラーが出た。エラーの原因は、GPGキーの有効期限が2024年3月1日までで、切れたため。その対応メモ。

    出力されたエラーメッセージ

    以下の署名が無効です: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) <packages@gitlab.com>

    GPGキーの有効期限が2024年3月1日で切れているので、延長するために、下記のコマンドで更新を行った。

    curl -s "https://packages.gitlab.com/gpg.key" | sudo apt-key add -

    apt updateを実行してみると、同じようにエラーが表示された(前回と同じ方法では、うまくいかなかった)。公式の手順の内容を参考にして実行したところ、うまくいった。

    https://docs.gitlab.com/omnibus/update/package_signatures#update-keys-after-expiry-extension

    「signed-by」の機能を使用しているか、コマンドで確認する。

    grep 'deb \[signed-by=' /etc/apt/sources.list.d/gitlab_gitlab-?e.list

    Grepの結果が返される場合は、「signed-by」 を使用しているので、次のAWKコマンドを実行する。これで、GitLabリポジトリの公開鍵を更新する。要root権限。

     sudo awk '/deb \[signed-by=/{
           pubkey = $2;
           sub(/\[signed-by=/, "", pubkey);
           sub(/\]$/, "", pubkey);
           print pubkey
         }' /etc/apt/sources.list.d/gitlab_gitlab-?e.list | \
       while read line; do
         curl -s "https://packages.gitlab.com/gpg.key" | gpg --dearmor > $line
       done

    これで、あとはapt updateを行って、問題が解消しているか確認する。

    以下は、実行ログの抜粋。

    zen@LABO:~$ sudo apt update
    [sudo] zen のパスワード:
    ヒット:2 http://security.ubuntu.com/ubuntu focal-security InRelease
    ヒット:3 http://jp.archive.ubuntu.com/ubuntu focal InRelease
    取得:4 http://jp.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
    ヒット:5 http://jp.archive.ubuntu.com/ubuntu focal-backports InRelease
    取得:1 https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu focal InRelease [23.3 kB]
    エラー:1 https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu focal InRelease
      以下の署名が無効です: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) <packages@gitlab.com>
    137 kB を 2秒 で取得しました (59.7 kB/s)
    パッケージリストを読み込んでいます... 完了
    依存関係ツリーを作成しています
    状態情報を読み取っています... 完了
    パッケージはすべて最新です。
    W: 署名照合中にエラーが発生しました。リポジトリは更新されず、過去のインデックス ファイルが使われます。GPG エラー: https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu focal InRelease: 以下の署名が無効です: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) <packages@gitlab.com>
    W: https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/dists/focal/InRelease の 取得に失敗しました  以下の署名が無効です: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) <packages@gitlab.com>
    W: いくつかのインデックスファイルのダウンロードに失敗しました。これらは無視され るか、古いものが代わりに使われます。
    zen@LABO:~$
    zen@LABO:~$ curl -s "https://packages.gitlab.com/gpg.key" | sudo apt-key add -
    OK
    zen@LABO:~$
    zen@LABO:~$ sudo apt update
    [sudo] zen のパスワード:
    ヒット:2 http://jp.archive.ubuntu.com/ubuntu focal InRelease
    ヒット:3 http://security.ubuntu.com/ubuntu focal-security InRelease
    取得:4 http://jp.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
    ヒット:5 http://jp.archive.ubuntu.com/ubuntu focal-backports InRelease
    取得:1 https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu focal InRelease [23.3 kB]
    エラー:1 https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu focal InRelease
      以下の署名が無効です: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) <packages@gitlab.com>
    137 kB を 3秒 で取得しました (46.3 kB/s)
    パッケージリストを読み込んでいます... 完了
    依存関係ツリーを作成しています
    状態情報を読み取っています... 完了
    パッケージはすべて最新です。
    W: 署名照合中にエラーが発生しました。リポジトリは更新されず、過去のインデックス ファイルが使われます。GPG エラー: https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu focal InRelease: 以下の署名が無効です: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) <packages@gitlab.com>
    W: https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/dists/focal/InRelease の 取得に失敗しました  以下の署名が無効です: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) <packages@gitlab.com>
    W: いくつかのインデックスファイルのダウンロードに失敗しました。これらは無視され るか、古いものが代わりに使われます。
    zen@LABO:~$
    zen@LABO:~$  grep 'deb \[signed-by=' /etc/apt/sources.list.d/gitlab_gitlab-?e.list
    
    deb [signed-by=/usr/share/keyrings/gitlab_gitlab-ce-archive-keyring.gpg] https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/ focal main
    zen@LABO:~$
    zen@LABO:~$
    zen@LABO:~$
    zen@LABO:~$ sudo su
    root@LABO:/home/zen#
    root@LABO:/home/zen#
    root@LABO:/home/zen# awk '/deb \[signed-by=/{
    >        pubkey = $2;
    >        sub(/\[signed-by=/, "", pubkey);
    >        sub(/\]$/, "", pubkey);
    >        print pubkey
    >      }' /etc/apt/sources.list.d/gitlab_gitlab-?e.list | \
    >    while read line; do
    >      curl -s "https://packages.gitlab.com/gpg.key" | gpg --dearmor > $line
    >    done
    root@LABO:/home/zen#
    root@LABO:/home/zen# apt update
    ヒット:2 http://security.ubuntu.com/ubuntu focal-security InRelease
    ヒット:3 http://jp.archive.ubuntu.com/ubuntu focal InRelease
    ヒット:4 http://jp.archive.ubuntu.com/ubuntu focal-updates InRelease
    ヒット:5 http://jp.archive.ubuntu.com/ubuntu focal-backports InRelease
    取得:1 https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu focal InRelease [23.3 kB]
    取得:6 https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu focal/main amd64 Packages [54.6 kB]
    78.0 kB を 3秒 で取得しました (22.6 kB/s)
    パッケージリストを読み込んでいます... 完了
    依存関係ツリーを作成しています
    状態情報を読み取っています... 完了
    アップグレードできるパッケージが 1 個あります。表示するには 'apt list --upgradable' を実行してください。
    root@LABO:/home/zen#
  • 新種のCPU脆弱性「GhostRace」が発表された

    合わせ技かつ高度なので、よく発見したものだ、というくらい感想。サンプルコードをみると、シンプルなんだが、これでどうしてそうなるっていうのは、わからない。

    CPUへの命令のやりくり高度になっているから、実装が難しくて、セキュリティ問題がでるのだろうけれど、このレイヤーの話だと、実感もないしわからない。発見する人達もすごいが、修正する人達もすごい。攻撃側は・・・手法が確立されてしまえば、ツールが出て回るだろうから、内容を理解しなくても攻撃できてしまうのだろうけれど。

    新種のCPU脆弱性「GhostRace」をIBMが公表 ~Intel、AMD、ARMなどに影響
    https://forest.watch.impress.co.jp/docs/news/1575896.html

  • Windows Defenderが暗号化ZIPファイルをウィルス判定してしまう。

    ちょうど、3月(2024年3月)くらいから、ChromeでGmailの添付ファイルをダウンロードすると、暗号化されたZIPファイルがウィルス判定されて、ダウンロードできなくなった。

    チャンと調べたところ、Gmail側の添付ファイルはスキャンできないという表示だけなので、Gmail上はグレー判定。Chrome自体にウィルスチェック機能は付加していない。ウィルスチェックは、Windows11のWindows Defenderで行っている。ダウンロードされた直後に、Windows Defenderでのウィルスチェックが行われて、そのまま削除されていた。1つのZIPファイルだと、ウィルス混在の可能性があったので、気にしなかった。これが複数のまったく別の件の添付されたZIPファイルで同じ動作になった。

    Windows11で、一時的にWindows Defenderを無効化すれば、ダウンロードおよびZIPファイルの展開は可能。展開後に、Windows Defenderをオンにして、チェックを行うと、ZIPファイルはウィルス判定されて、削除される。展開されたファイルは、ウィルス判定されなかった。(どうしてもダウンロードが必要ならば、一時的にWindows Defenderを無効化する、自己責任で)

    このことから、Windows Defenderが暗号化ZIPファイルをウィルス判定してしまう状況という判断になった。

  • 古いWindowsのPowershellでメールを送ると文字化けする

    古いWindows(Windows Server 2008 R2) のPowershell(Ver 2.0)で、メールを送付すると、「-Encoding」でUTF8を指定していても文字化けする事象に遭遇した。

    Powershellのスクリプトは、Windows10で、VS Codeを使って書き、文字コードはUTF8にしている。そこで開発したスクリプトファイルを、古いWindowsに持って行って実行する。実行は問題なくできるのだが、そのスクリプトから送られてくるメールが文字化けしてしまう。

    Powershellのスクリプトファイル(.ps1)をみてみると、BOMなしで保存されている。これをBOMありで保存しなおして、古いWindows環境で実行してみると、文字化けが解消した。古いWindows環境のメモ帳では、文字化けせずに開けたが、Powershellの実行環境だと、BOMがないとSJISで開いているようで、ここで文字化けが発生している。

    Powershellのスクリプトを作成するときは、UTFの場合は、BOMありで保存する。

  • UbuntuでMariaDBのアップデートがエラーになった

    Ubuntu 20.04 でapt update , apt upgrade を実行したところ、MariaDBの更新でエラーになった。apt cleanや再実行では、解消せず。

    エラーの一部

    dpkg: error processing archive /var/cache/apt/archives/mariadb-server-core-10.3_1%3a10.3.38-0ubuntu0.20.04.1_amd64.deb (--unpack):

    エラーの全体

    $ sudo apt upgrade
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    Calculating upgrade... Done
    The following packages were automatically installed and are no longer required:
      libmariadb3 linux-image-4.15.0-202-generic linux-modules-4.15.0-202-generic
      linux-modules-extra-4.15.0-202-generic
    Use 'sudo apt autoremove' to remove them.
    Get more security updates through Ubuntu Pro with 'esm-apps' enabled:
      libmagickcore-6.q16-6-extra imagemagick libmagickwand-6.q16-6
      imagemagick-6.q16 libopenexr24 libmagickcore-6.q16-6 imagemagick-6-common
    Learn more about Ubuntu Pro at https://ubuntu.com/pro
    The following packages will be upgraded:
      mariadb-server-10.3 mariadb-server-core-10.3
    2 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    168 not fully installed or removed.
    2 standard LTS security updates
    Need to get 0 B/10.5 MB of archives.
    After this operation, 773 kB disk space will be freed.
    Do you want to continue? [Y/n] Y
    Preconfiguring packages ...
    (Reading database ... 132397 files and directories currently installed.)
    Preparing to unpack .../mariadb-server-core-10.3_1%3a10.3.38-0ubuntu0.20.04.1_amd64.deb ...
    Unpacking mariadb-server-core-10.3 (1:10.3.38-0ubuntu0.20.04.1) over (1:10.3.37+maria~ubu1804) ...
    dpkg: error processing archive /var/cache/apt/archives/mariadb-server-core-10.3_1%3a10.3.38-0ubuntu0.20.04.1_amd64.deb (--unpack):
     trying to overwrite '/usr/bin/my_print_defaults', which is also in package mariadb-server-10.3 1:10.3.37+maria~ubu1804
    dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
    dpkg: regarding .../mariadb-server-10.3_1%3a10.3.38-0ubuntu0.20.04.1_amd64.deb containing mariadb-server-10.3:
     mariadb-server-10.3 conflicts with mysql-server-core-5.5
      mariadb-server-core-10.3 provides mysql-server-core-5.5 and is present and installed.
    dpkg: error processing archive /var/cache/apt/archives/mariadb-server-10.3_1%3a10.3.38-0ubuntu0.20.04.1_amd64.deb (--unpack):
     conflicting packages - not installing mariadb-server-10.3
    Errors were encountered while processing:
     /var/cache/apt/archives/mariadb-server-core-10.3_1%3a10.3.38-0ubuntu0.20.04.1_amd64.deb
     /var/cache/apt/archives/mariadb-server-10.3_1%3a10.3.38-0ubuntu0.20.04.1_amd64.deb
    E: Sub-process /usr/bin/dpkg returned an error code (1)

    強制的に上書きした。パッケージのパスはエラーで表示されたものをそのまま指定して、実行した。

    $ sudo dpkg -i --force-overwrite /var/cache/apt/archives/mariadb-server-core-10.3_1%3a10.3.38-0ubuntu0.20.04.1_amd64.deb

    実行例。ワーニングやエラーが出ていた。

    $ sudo dpkg -i --force-overwrite /var/cache/apt/archives/mariadb-server-core-10.3_1%3a10.3.38-0ubuntu0.20.04.1_amd64.deb
    (Reading database ... 132397 files and directories currently installed.)
    Preparing to unpack .../mariadb-server-core-10.3_1%3a10.3.38-0ubuntu0.20.04.1_amd64.deb ...
    Unpacking mariadb-server-core-10.3 (1:10.3.38-0ubuntu0.20.04.1) over (1:10.3.37+maria~ubu1804) ...
    dpkg: warning: overriding problem because --force enabled:
    dpkg: warning: trying to overwrite '/usr/bin/my_print_defaults', which is also in package mariadb-server-10.3 1:10.3.37+maria~ubu1804
    dpkg: warning: overriding problem because --force enabled:
    dpkg: warning: trying to overwrite '/usr/bin/resolveip', which is also in package mariadb-server-10.3 1:10.3.37+maria~ubu1804
    dpkg: warning: overriding problem because --force enabled:
    dpkg: warning: trying to overwrite '/usr/share/man/man1/my_print_defaults.1.gz', which is also in package mariadb-server-10.3 1:10.3.37+maria~ubu1804
    dpkg: warning: overriding problem because --force enabled:
    dpkg: warning: trying to overwrite '/usr/share/man/man1/resolveip.1.gz', which is also in package mariadb-server-10.3 1:10.3.37+maria~ubu1804
    dpkg: warning: overriding problem because --force enabled:
    dpkg: warning: trying to overwrite '/usr/share/mysql/fill_help_tables.sql', which is also in package mariadb-server-10.3 1:10.3.37+maria~ubu1804
    dpkg: warning: overriding problem because --force enabled:
    dpkg: warning: trying to overwrite '/usr/share/mysql/maria_add_gis_sp_bootstrap.sql', which is also in package mariadb-server-10.3 1:10.3.37+maria~ubu1804
    dpkg: warning: overriding problem because --force enabled:
    dpkg: warning: trying to overwrite '/usr/share/mysql/mysql_performance_tables.sql', which is also in package mariadb-server-10.3 1:10.3.37+maria~ubu1804
    dpkg: warning: overriding problem because --force enabled:
    dpkg: warning: trying to overwrite '/usr/share/mysql/mysql_system_tables.sql', which is also in package mariadb-server-10.3 1:10.3.37+maria~ubu1804
    dpkg: warning: overriding problem because --force enabled:
    dpkg: warning: trying to overwrite '/usr/share/mysql/mysql_system_tables_data.sql', which is also in package mariadb-server-10.3 1:10.3.37+maria~ubu1804
    dpkg: warning: overriding problem because --force enabled:
    dpkg: warning: trying to overwrite '/usr/share/mysql/mysql_test_data_timezone.sql', which is also in package mariadb-server-10.3 1:10.3.37+maria~ubu1804
    dpkg: warning: overriding problem because --force enabled:
    dpkg: warning: trying to overwrite '/usr/share/mysql/mysql_test_db.sql', which is also in package mariadb-server-10.3 1:10.3.37+maria~ubu1804
    dpkg: dependency problems prevent configuration of mariadb-server-core-10.3:
     mariadb-server-core-10.3 depends on libsnappy1v5 (>= 1.1.8); however:
      Package libsnappy1v5:amd64 is not configured yet.
    dpkg: error processing package mariadb-server-core-10.3 (--install):
     dependency problems - leaving unconfigured
    Processing triggers for man-db (2.9.1-1) ...
    Errors were encountered while processing:
     mariadb-server-core-10.3
    $

    この後、もう1回、apt updateとapt upgradeを実施した。その他のパッケージもキレイにインストールされた。

    念のため、OS再起動も実施したが起動に問題なし。MariaDBもバージョンアップされていることを確認できた。

  • Powershellがコード: -1073741502で異常終了する

    Powershellがコード: -1073741502で異常終了することがある。一度、発生すると同じときに実行されているPowershellも立て続けに同じコードで落ちる。

    これを調べてみると、下記の内容が見つかる。

    “0xC0000142” or “-1073741502” Stop error when many PowerShell scripts call the Console.Write method or when you try to start many console applications on a PowerShell console in Windows 7 or in Windows Server 2008 R2
    https://support.microsoft.com/en-us/topic/-0xc0000142-or-1073741502-stop-error-when-many-powershell-scripts-call-the-console-write-method-or-when-you-try-to-start-many-console-applications-on-a-powershell-console-in-windows-7-or-in-windows-server-2008-r2-19f475a2-cbe9-c463-a2b4-b7fe7a1d236d

    Microsoft.powershell.consolehost.dllファイルのエラーが原因で発生しているようで、多くのコンソールがPowershellから開かれることによってリークが発生して、このエラーになる。時間がたつことで、一時的におさまるので、またPowershellの実行ができるようになる。(これも実際の挙動と一致するのでこれだろう)

    修正パッチもあるみたいないので、該当OSならば、パッチを当てるのもよさそうだ。

  • スナップショットがある仮想マシンをVeeam Backupでバックアップしたときの挙動

    負荷の高いVMのバックアップをとる場合は、Veeam Backupがバックアップ時に取得するスナップショット以外は、無い方がいい。すでにスナップショットがある場合は、下記のような挙動になることがあり、システム不安定につながる。

    • バックアップが長くなる、終わらない(まだ、いいほう)
    • バックアップ開始時のスナップショット取得時に、VMのOSの反応が悪くなったり、ネットワーク接続されているリソースが切断される(iSCSIディスクとか)。

    絶対になるわけではなく、Veeam BackupがvSphere上(ESXi上)でVMのスナップショットをとるときにOS側の挙動が不安定になったときに発生する。Veeam BackupでVMのバックアップを取得するときに不具合があるときは、対象VMのスナップショットの有無を確認したほうがいい。

  • メモ:GitLab 16.7.3-ceからGitLab 16.9.0-ceへはapt updateでアップデートできた。

    断すると、GitLab CEのアップデートがapt updateで失敗するので、メモ。

    GitLab 16.7.3-ceからGitLab 16.9.0-ceへはapt updateでアップデートできた。

  • Windows Server 2022のADにWindows 2000を参加させる

    通常のままでは、Windows Server 2022のActive Directory(機能レベル Windows Server 2016)にWindows 2000やWindows 2000 Serverを参加させることはできない。AD参加時のセキュリティの不一致によるため。

    無理やりWindows Server 2022のADにWindows 2000を参加させるためには、以下のことを行い、セキュリティレベルを下げる必要がある。

    1つめ。LAN Manager認証レベルを変更する

    1. 「secpol.msc」と入力して、ローカルセキュリティ設定を起動する。

    2. 「ローカルポリシー」>「セキュリティオプション」>「ネットワーク セキュリティ」>「LAN Manager 認証レベル」の順に選択開く。

    3. 「LMとNTML応答を送信する」を選択して、適用する。

    2つめ。SMBv1を許可する

    1. Powershellを管理者として実行する。

    2. `Enable-WindowsOptionalFeature -Online -FeatureName SMB1Protocol` を入力して、実行する。

    3. OSを再起動する。

    セキュリティは、かなり下がるので、Windows 2000はAD参加させないほうがいい。Windows Server 2003も同じ方法で参加できるはず。

  • Google Bardでイメージ生成ができるようになった

    Googleがイメージ生成のAIを公開して、それがBard経由で利用できるようになった。日本語での生成はできないけれど、英語で指定すると、Bardから画像を生成することができた。

    画像のダウンロードもできて、ダウンロードではフルサイズでみることができる。