Re: Retrieving 'secret' setting




On 07 September 2017 at 16:37 Dan Williams <dcbw redhat com> wrote:

On Thu, 2017-09-07 at 09:31 +0100, Colin Helliwell wrote:

..
Thanks Dan, that gets it.
Now I'm struggling to *modify* the password.... :S I see that I can
do a
 settings.set_property(NM.SETTING_GSM_PASSWORD, "NewPw")
but unsure how to complete the updating. I found
NM.Connection.replace_settings(), and update_secrets(), but both of
those put me back into GVariant territory.
What would be the route to get the new password fed back through
(presumably prior to finishing with a
NM.RemoteConnection.save()/commit()?)

You're correct. Here's what I'd do:

client = NM.Client.new(None)
c =
client.get_connection_by_uuid(sys.argv[1])
secrets =
c.get_secrets(NM.SETTING_WIRELESS_SECURITY_SETTING_NAME)

# this merges
the secrets into the existing connection
c.update_secrets(NM.SETTING_WIR
ELESS_SECURITY_SETTING_NAME, secrets)



# write the full connection back to NM
c.save()

Yep, that's working (subject to save vs. commit_changes)  - many thanks for the guidance.

Btw, it seems the password can be extracted simply by: 
   password = secrets['gsm']['password']


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]