Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Weblate
gajim
Commits
68550b73
Commit
68550b73
authored
16 years ago
by
Yann Leboulanger
Browse files
Options
Downloads
Patches
Plain Diff
[gjc] use correct API to get password from gnome-keyring. Fixes #3631
parent
cb1b0814
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/common/passwords.py
+19
-8
19 additions, 8 deletions
src/common/passwords.py
with
19 additions
and
8 deletions
src/common/passwords.py
+
19
−
8
View file @
68550b73
...
...
@@ -25,6 +25,7 @@
__all__
=
[
'
get_password
'
,
'
save_password
'
]
import
warnings
from
common
import
gajim
USER_HAS_GNOMEKEYRING
=
False
...
...
@@ -66,10 +67,7 @@ class GnomePasswordStorage(PasswordStorage):
conf
=
gajim
.
config
.
get_per
(
'
accounts
'
,
account_name
,
'
password
'
)
if
conf
is
None
:
return
None
try
:
auth_token
=
conf
.
split
(
'
gnomekeyring:
'
)[
1
]
auth_token
=
int
(
auth_token
)
except
(
IndexError
,
ValueError
):
if
not
conf
.
startswith
(
'
gnomekeyring:
'
):
password
=
conf
## migrate the password over to keyring
try
:
...
...
@@ -79,8 +77,21 @@ class GnomePasswordStorage(PasswordStorage):
set_storage
(
SimplePasswordStorage
())
return
password
try
:
return
gnomekeyring
.
item_get_info_sync
(
self
.
keyring
,
auth_token
).
get_secret
()
attributes
=
dict
(
account_name
=
str
(
account_name
),
gajim
=
1
)
try
:
items
=
gnomekeyring
.
find_items_sync
(
gnomekeyring
.
ITEM_GENERIC_SECRET
,
attributes
)
except
gnomekeyring
.
Error
:
items
=
[]
if
len
(
items
)
>
1
:
warnings
.
warn
(
"
multiple gnome keyring items found for account %s;
"
"
trying to use the first one...
"
%
account_name
)
if
items
:
return
items
[
0
].
secret
else
:
return
None
except
gnomekeyring
.
DeniedError
:
return
None
except
gnomekeyring
.
NoKeyringDaemonError
:
...
...
@@ -99,8 +110,8 @@ class GnomePasswordStorage(PasswordStorage):
set_storage
(
SimplePasswordStorage
())
storage
.
save_password
(
account_name
,
password
)
return
token
=
'
gnomekeyring:%i
'
%
auth_token
gajim
.
config
.
set_per
(
'
accounts
'
,
account_name
,
'
password
'
,
token
)
gajim
.
config
.
set_per
(
'
accounts
'
,
account_name
,
'
password
'
,
'
gnomekeyring:
'
)
if
account_name
in
gajim
.
connections
:
gajim
.
connections
[
account_name
].
password
=
password
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment