嘗試做一個 envchain 的仿品 (4)

剛剛試了一下 writePassword(),沒問題,可以用 key-value pair 的方式儲存想要保密的資料:

require 'dbus'
require 'pp'
 
session_bus = DBus.session_bus
 
kwalletd_service = session_bus["org.kde.kwalletd5"]
kwalletd_object = kwalletd_service.object "/modules/kwalletd5"
kwalletd_object.introspect
kwalletd_interface = kwalletd_object["org.kde.KWallet"]
handle = kwalletd_interface.open("kdewallet", 0, "Ruby D-Bus Client").first
pp kwalletd_interface
 
kwalletd_interface.createFolder(handle, "envpick", "Ruby D-Bus Client")
pp kwalletd_interface.folderList(handle, "Ruby D-Bus Client")
 
kwalletd_interface.writePassword(handle, "envpick", "key-0", "value-0", "Ruby D-Bus Client")
kwalletd_interface.writePassword(handle, "envpick", "key-1", "value-1", "Ruby D-Bus Client")
pp kwalletd_interface.entryList(handle, "envpick", "Ruby D-Bus Client")

完全符合我的需求。

CC BY-SA 4.0 This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Leave a Reply

Your email address will not be published. Required fields are marked *