[英]Unlock gnome-keyring from a temp dbus session
I'm trying to write a python application that can unlock gnome-keyring
from a text-only system (headless machine) and retrieve the credentials.我正在尝试编写一个python应用程序,它可以从纯文本系统(无头机器)解锁gnome-keyring
并检索凭据。 I have the gnome-keyring
package installed in this machine.我在这台机器上安装了gnome-keyring
包。
Basically, my application will:基本上,我的应用程序将:
I'm trying to follow this tutorial: https://pypi.org/project/keyring/#using-keyring-on-headless-linux-systems我正在尝试按照本教程进行操作: https : //pypi.org/project/keyring/#using-keyring-on-headless-linux-systems
I tried reading: Python DBUS SESSION_BUS - X11 dependency but, the OP uses dbus-launch
instead of the dbus-run-session
.我尝试阅读: Python DBUS SESSION_BUS - X11 dependency但是,OP 使用dbus-launch
而不是dbus-run-session
。 The original man page for dbus-launch
says to use 'dbus-run-session` for text-only systems. dbus-launch
的原始手册页说对纯文本系统使用“dbus-run-session”。
If I start a new dbus session using python's subprocess, how can I run the step #2 in the same dbus-session?如果我使用 python 的子进程启动一个新的 dbus 会话,我如何在同一个 dbus 会话中运行第 2 步?
You will either need to spawn a second program in your project beneath dbus-run-session
, or you will need to use something other than dbus-run-session
to run your own session bus.您要么需要在项目中的dbus-run-session
下生成第二个程序,要么需要使用dbus-run-session
以外的其他程序来运行您自己的会话总线。 dbus-run-session
is designed to run a single program in its own bus; dbus-run-session
旨在在其自己的总线上运行单个程序; once that program terminates, the bus is shut down.一旦该程序终止,总线就会关闭。 So either you need to provide a second program which does steps 2 and 3 from your plan, or you need to more explicitly set up and tear down your own dbus-daemon
instance from your top-level program, replicating some of the behaviour of dbus-run-session
.因此,要么您需要提供第二个程序来执行您计划中的第 2 步和第 3 步,要么您需要从顶级dbus-daemon
更明确地设置和拆除您自己的dbus-daemon
实例,复制dbus-run-session
某些行为dbus-run-session
。
Typically this would involve:通常这将涉及:
dbus-daemon
configuration file to use.提供要使用的dbus-daemon
配置文件。dbus-daemon --config-file=path/to/config --address=path/to/socket --nofork
.运行dbus-daemon --config-file=path/to/config --address=path/to/socket --nofork
。DBUS_SESSION_BUS_ADDRESS=unix:path/to/socket
in your program's environment before doing anything with the keyring.在对密钥环执行任何操作之前,在程序环境中设置DBUS_SESSION_BUS_ADDRESS=unix:path/to/socket
。dbus-daemon
subprocess.终止dbus-daemon
子dbus-daemon
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.