systemd: 'Unit' セクションの不明なキー名 'ConditionEnvironment'

systemd: 'Unit' セクションの不明なキー名 'ConditionEnvironment'

私はsystemdバージョン246を使用しています。

$ systemctl --version                           
systemd 246 (246.2-1-arch)
+PAM +AUDIT -SELINUX -IMA -APPARMOR +SMACK -SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +ZSTD +SECCOMP +BLKID +ELFUTILS +KMOD +IDN2 -IDN +PCRE2 default-hierarchy=hybrid

そのドキュメントはConditionEnvironmentsystemd.unitのマンページにあります。ただし、次の単位ファイルで使用すると~/.config/systemd/user/i3-session-pre.target

[Unit]
Description=i3 session
Documentation=man:systemd.special(7)
BindsTo=graphical-session-pre.target
ConditionEnvironment=XDG_SESSION_DESKTOP=i3

マイユーザーログに次のエントリが表示されます。

systemd[599]: /home/****/.config/systemd/user/i3-session-pre.target:5: Unknown key name 'ConditionEnvironment' in section 'Unit', ignoring.

また、systemd-analyze conditionこの状況を処理できません。

$ systemd-analyze condition ConditionEnvironment=XDG_SESSION_DESKTOP=i3
Cannot parse "ConditionEnvironment=XDG_SESSION_DESKTOP=i3".

私は何が間違っていましたか?

ベストアンサー1

私はあなたが間違ったことがないと思います。 systemdにバグがあると思います。

Debianテスト(systemd 246およびアップグレード246.1以降)で、次のことを観察しました。

ConditionEnvironment=ただバージョン246としてリリース2020年7月30日(この記事を作成する2.5週間前)とフルリクエスト5月15日に統合されました。したがって、まだ成熟していないと見るのは妥当です。

これがバグだと思わせるテストは次のとおりです。

$ systemd-analyze condition \
    'ConditionKernelVersion='  \
    'ConditionKernelVersion='  \
    'ConditionACPower=' \
    'ConditionArchitecture=' \
    'AssertPathExists=' \
    'ConditionEnvironment='
Cannot parse "ConditionEnvironment=".

各条件を 1 つずつ実行すると、 を除くすべての条件が空の式として解釈されますConditionEnvironment=

あなたの目標をそのまま(i3環境でも)試したところ、目標が達成されたかどうかConditionEnvironment=には影響しないことがわかりました。正しい値と無効な値の両方を試しました。したがって、この質問はに限定されていませんsystemd-analyze

私がとても興味深かったのはコメントです。xdg-autostart-generator/xdg-autostart-condition.c:

 * This binary is intended to be run as an ExecCondition= in units generated
 * by the xdg-autostart-generator. It does the appropriate checks against
 * XDG_CURRENT_DESKTOP that are too advanced for simple ConditionEnvironment=
 * matches.

/lib/systemd/systemd-xdg-autostart-condition私はそのエラーが正しいと思いますが、作業中の正確な環境で問題を克服するためにジェネレータを作成(および配布)したことが興味深いと思います。

エラーレポートDebian と共に。私はDebian開発者がそれを見て、システム開発者に上流を伝えたいと思います。

おすすめ記事