dbus
「アプリケーションが互いに対話する簡単な方法」を提供する必要があります。
しかし、私はそれが実際に何をしているのかまだ確信していません。私はそれが役に立ったとは見たことがなく、コマンドラインからターミネータを起動したときなど、特定のコンポーネントdbus
にエラーが発生したという警告だけを見ましたdbus
(エラーを見ることができるように)。
Error retrieving accessibility bus address: org.freedesktop.DBus.Error.ServiceUnknown: The name org.a11y.Bus was not provided by any .service files
NO_AT_BRIDGE=1
に追加して上記のエラーを削除しました/etc/environment
。私はそれが何をしているのかわかりません。
ほとんどすべてのGUIアプリケーションはで動作しているようですdbus
。一部はdbus
、つまり次のように実行を許可します。
terminator --no-dbus
行動も変わらないようです。何が動作を停止し、いつterminator
動作しなくなり始めるべきですかdbus
?
また、どれが動作を停止しているかを確認するために、さまざまなdbusコンポーネントを無効にしてみました。
私は/etc/X11/Xsession.d/95dbus_update-activation-env
何が起こるのかを見るために削除しました。これには次のコードが含まれています。
if [ -n "$DBUS_SESSION_BUS_ADDRESS" ] && [ -x "/usr/bin/dbus-update-activation-environment" ]; then
# subshell so we can unset environment variables
(
# unset login-session-specifics
unset XDG_SEAT
unset XDG_SESSION_ID
unset XDG_VTNR
# tell dbus-daemon --session to put the Xsession's environment in activated services' environments
dbus-update-activation-environment --verbose --all
)
fi
私が知る限り、すべてが同じです。上記のスクリプトの目的は何ですか?
どのような状況で私のアプリケーションが互いに通信するのが便利ですかdbus
?
それがなければ実行できないアプリはありますかdbus
?
私のシステムはDebian Busterで、一般的なオープンボックス環境を使用しています(GnomeやKDEなどのデスクトップ環境はありません)。
ベストアンサー1
dbus
おっしゃるとおり、アプリケーション間の双方向通信が可能です。
あなたが言及した具体的な例の場合terminator
。 ~からターミネーターのマニュアルページ、私達は次を見ます:
--new-tab If this is specified and Terminator is already running, DBus will be used to spawn a new tab in the first Terminator window.
したがって、他の端末(konsole、xterm、gnome-terminal)でこれを行う場合:
$ terminator &
$ terminator --new-tab &
最初のコマンドが新しいウィンドウを開くことがわかります。 2番目のコマンドは、最初のウィンドウで新しいタブを開きます。これは、dbusを使用して最初のプロセスを見つけ、新しいタブを開くように要求し、終了する2番目のプロセスによって行われます。
他の端末でこれを行う場合:
$ terminator --no-dbus &
$ terminator --new-tab &
最初のコマンドが新しいウィンドウを開くことがわかります。 2番目のコマンドは、最初のウィンドウのdbusが見つからないため、新しいウィンドウを起動します。これをテストするためにターミネーターをインストールしたのは本当です。
また、ポルキットも影響を受けると考えられます。 Polkitはdbusを使用してGUIアプリケーションの権限を向上させます。これはsudo
GUIの世界と同じです。 gnomeで管理者パスワードの入力を求められたときに全画面が隠れる場合、これはPolkitの機能です。 .努力から。これは高い権限で実行されます。このオプションがある場合とない場合に違いがあるかどうかを確認してください。私のウィンドウマネージャ(i3)にpolkitエージェントがないため、このエージェントをテストできません。terminator
--no-dbus
terminator
pkexec ls
ls
--no-dbus
私はほとんどdbusのシステムの側面を知っているので、残りの答えはここから来ます。
それがなければ実行できないアプリはありますか
dbus
?
はい。取るsystemctl
。 systemctl status
質問は"org.freedesktop.systemd1"
あなたに発行され提示されます。 systemctl start
dbusメソッドが呼び出され、単位がパラメータとしてメソッドに渡されます。 systemd
電話に応答して対処してください。
システムユニット(foo.serviceなど)の状態変更に応答してアクションを実行するには、org.freedesktop.DBus.Properties
path/org/freedesktop/systemd1/unit/foo_2eservice
とmemberを使用してインターフェイスのファイル記述子を取得できますPropertiesChanged
。そのFDに1つを設定するinotify
と、突然サービスの開始、停止、失敗などに反応する方法ができます。
ssh.service
systemd dbusの特定のデバイス(たとえば)で利用可能なエントリを表示するには、次の手順を試します。
busctl introspect \
org.freedesktop.systemd1 \
/org/freedesktop/systemd1/unit/ssh_2eservice
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
org.freedesktop.DBus.Introspectable interface - - -
.Introspect method - s -
org.freedesktop.DBus.Peer interface - - -
.GetMachineId method - s -
.Ping method - - -
org.freedesktop.DBus.Properties interface - - -
.Get method ss v -
.GetAll method s a{sv} -
.Set method ssv - -
.PropertiesChanged signal sa{sv}as - -
org.freedesktop.systemd1.Service interface - - -
.AttachProcesses method sau - -
.GetProcesses method - a(sus) -
.AllowedCPUs property ay 0 -
.AllowedMemoryNodes property ay 0 -
.AmbientCapabilities property t 0 const
.AppArmorProfile property (bs) false "" const
.BindPaths property a(ssbt) 0 const
.BindReadOnlyPaths property a(ssbt) 0 const
.BlockIOAccounting property b false -
.BlockIODeviceWeight property a(st) 0 -
.BlockIOReadBandwidth property a(st) 0 -
.BlockIOWeight property t 18446744073709551615 -
.BlockIOWriteBandwidth property a(st) 0 -
.BusName property s "" const
.CPUAccounting property b false -
.CPUAffinity property ay 0 const
.CPUAffinityFromNUMA property b false const
.CPUQuotaPerSecUSec property t 18446744073709551615 -
.CPUQuotaPeriodUSec property t 18446744073709551615 -
.CPUSchedulingPolicy property i 0 const
.CPUSchedulingPriority property i 0 const
.CPUSchedulingResetOnFork property b false const
.CPUShares property t 18446744073709551615 -
.CPUUsageNSec property t 18446744073709551615 -
.CPUWeight property t 18446744073709551615 -
.CacheDirectory property as 0 const
.CacheDirectoryMode property u 493 const
.CapabilityBoundingSet property t 18446744073709551615 const
.CleanResult property s "success" emits-change
.ConfigurationDirectory property as 0 const
.ConfigurationDirectoryMode property u 493 const
.ControlGroup property s "/system.slice/ssh.service" -
.ControlPID property u 0 emits-change
.CoredumpFilter property t 51 const
.DefaultMemoryLow property t 0 -
.DefaultMemoryMin property t 0 -
.Delegate property b false -
.DelegateControllers property as 0 -
.DeviceAllow property a(ss) 0 -
.DevicePolicy property s "auto" -
.DisableControllers property as 0 -
.DynamicUser property b false const
.EffectiveCPUs property ay 0 -
.EffectiveMemoryNodes property ay 0 -
.Environment property as 0 const
.EnvironmentFiles property a(sb) 1 "/etc/default/ssh" true const
.ExecCondition property a(sasbttttuii) 0 emits-invalidation
.ExecConditionEx property a(sasasttttuii) 0 emits-invalidation
.ExecMainCode property i 0 emits-change
.ExecMainExitTimestamp property t 0 emits-change
.ExecMainExitTimestampMonotonic property t 0 emits-change
.ExecMainPID property u 835 emits-change
.ExecMainStartTimestamp property t 1597235861087584 emits-change
.ExecMainStartTimestampMonotonic property t 5386565 emits-change
.ExecMainStatus property i 0 emits-change
.ExecReload property a(sasbttttuii) 2 "/usr/sbin/sshd" 2 "/usr/sbin/sshd" "… emits-invalidation
.ExecReloadEx property a(sasasttttuii) 2 "/usr/sbin/sshd" 2 "/usr/sbin/sshd" "… emits-invalidation
.ExecStart property a(sasbttttuii) 1 "/usr/sbin/sshd" 3 "/usr/sbin/sshd" "… emits-invalidation
.ExecStartEx property a(sasasttttuii) 1 "/usr/sbin/sshd" 3 "/usr/sbin/sshd" "… emits-invalidation
.ExecStartPost property a(sasbttttuii) 0 emits-invalidation
.ExecStartPostEx property a(sasasttttuii) 0 emits-invalidation
.ExecStartPre property a(sasbttttuii) 1 "/usr/sbin/sshd" 2 "/usr/sbin/sshd" "… emits-invalidation
.ExecStartPreEx property a(sasasttttuii) 1 "/usr/sbin/sshd" 2 "/usr/sbin/sshd" "… emits-invalidation
.ExecStop property a(sasbttttuii) 0 emits-invalidation
.ExecStopEx property a(sasasttttuii) 0 emits-invalidation
.ExecStopPost property a(sasbttttuii) 0 emits-invalidation
.ExecStopPostEx property a(sasasttttuii) 0 emits-invalidation
.FileDescriptorStoreMax property u 0 const
.FinalKillSignal property i 9 const
.GID property u 4294967295 emits-change
.Group property s "" const
.GuessMainPID property b true const
.IOAccounting property b false -
.IODeviceLatencyTargetUSec property a(st) 0 -
.IODeviceWeight property a(st) 0 -
.IOReadBandwidthMax property a(st) 0 -
.IOReadBytes property t 18446744073709551615 -
.IOReadIOPSMax property a(st) 0 -
.IOReadOperations property t 18446744073709551615 -
.IOSchedulingClass property i 0 const
.IOSchedulingPriority property i 0 const
.IOWeight property t 18446744073709551615 -
.IOWriteBandwidthMax property a(st) 0 -
.IOWriteBytes property t 18446744073709551615 -
.IOWriteIOPSMax property a(st) 0 -
.IOWriteOperations property t 18446744073709551615 -
.IPAccounting property b false -
.IPAddressAllow property a(iayu) 0 -
.IPAddressDeny property a(iayu) 0 -
.IPEgressBytes property t 18446744073709551615 -
.IPEgressFilterPath property as 0 -
.IPEgressPackets property t 18446744073709551615 -
.IPIngressBytes property t 18446744073709551615 -
.IPIngressFilterPath property as 0 -
.IPIngressPackets property t 18446744073709551615 -
.IgnoreSIGPIPE property b true const
.InaccessiblePaths property as 0 const
...skipping...
.CollectMode property s "inactive" const
.ConditionResult property b true emits-change
.ConditionTimestamp property t 1597235861034899 emits-change
.ConditionTimestampMonotonic property t 5333881 emits-change
.Conditions property a(sbbsi) 1 "ConditionPathExists" false true "/et… emits-invalidation
.ConflictedBy property as 0 const
.Conflicts property as 1 "shutdown.target" const
.ConsistsOf property as 0 const
.DefaultDependencies property b true const
.Description property s "OpenBSD Secure Shell server" const
.Documentation property as 2 "man:sshd(8)" "man:sshd_config(5)" const
.DropInPaths property as 0 const
.FailureAction property s "none" const
.FailureActionExitStatus property i -1 const
.Following property s "" -
.FragmentPath property s "/lib/systemd/system/ssh.service" const
.FreezerState property s "running" emits-change
.Id property s "ssh.service" const
.IgnoreOnIsolate property b false const
.InactiveEnterTimestamp property t 0 emits-change
.InactiveEnterTimestampMonotonic property t 0 emits-change
.InactiveExitTimestamp property t 1597235861039525 emits-change
.InactiveExitTimestampMonotonic property t 5338505 emits-change
.InvocationID property ay 16 90 215 118 165 228 162 72 57 179 144… emits-change
.Job property (uo) 0 "/" emits-change
.JobRunningTimeoutUSec property t 18446744073709551615 const
.JobTimeoutAction property s "none" const
.JobTimeoutRebootArgument property s "" const
.JobTimeoutUSec property t 18446744073709551615 const
.JoinsNamespaceOf property as 0 const
.LoadError property (ss) "" "" const
.LoadState property s "loaded" const
.Names property as 2 "ssh.service" "sshd.service" const
.NeedDaemonReload property b false const
.OnFailure property as 0 const
.OnFailureJobMode property s "replace" const
.PartOf property as 0 const
.Perpetual property b false const
.PropagatesReloadTo property as 0 const
.RebootArgument property s "" const
.Refs property as 0 -
.RefuseManualStart property b false const
.RefuseManualStop property b false const
.ReloadPropagatedFrom property as 0 const
.RequiredBy property as 0 const
.Requires property as 3 "system.slice" "-.mount" "sysinit.tar… const
.RequiresMountsFor property as 1 "/run/sshd" const
.Requisite property as 0 const
.RequisiteOf property as 0 const
.SourcePath property s "" const
.StartLimitAction property s "none" const
.StartLimitBurst property u 5 const
.StartLimitIntervalUSec property t 10000000 const
.StateChangeTimestamp property t 1597235861208937 emits-change
.StateChangeTimestampMonotonic property t 5507917 emits-change
.StopWhenUnneeded property b false const
.SubState property s "running" emits-change
.SuccessAction property s "none" const
.SuccessActionExitStatus property i -1 const
.Transient property b false const
.TriggeredBy property as 0 const
.Triggers property as 0 const
.UnitFilePreset property s "enabled" -
.UnitFileState property s "enabled" -
.WantedBy property as 1 "multi-user.target" const
.Wants property as 0 const
dbusインターフェイスの機能が非常に強力であることがわかります。
あなたは次のように尋ねることができます。なぜこれらのアプリケーションはソケットやファイルを介して通信しないのですか?
DBusは共通のインターフェースを提供します。会話中のアプリケーションに応じて、メソッドを呼び出すかプロパティを検証するために他のロジックを使用する必要はありません。パス名だけがわかります。
systemd
これは私が最もよく理解しているので、これを例として使用していますが、ほとんどのデスクトップにはdbusが多用されています。認証からディスプレイ設定まで、すべてがdbusで動作します。