Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Debian New Member Process
nm.debian.org
Commits
8821800f
Commit
8821800f
authored
May 16, 2016
by
Enrico Zini
Browse files
Removed unused keyring.models.UserKey
parent
93716ca4
Changes
1
Hide whitespace changes
Inline
Side-by-side
keyring/models.py
View file @
8821800f
...
...
@@ -523,71 +523,6 @@ class KeycheckUidResult(object):
self
.
sigs_bad
.
append
(
sig
)
class
UserKey
(
object
):
"""
Manage a temporary keyring use to work with the key of a user that is not
in any of the main keyrings.
"""
def
__init__
(
self
,
fpr
):
"""
Create/access a temporary keyring dir for the given fingerprint.
IMPORTANT: make sure that fpr is validated to a sequence of A-Fa-f0-9, as
it will be passed to os.path.join unchecked
"""
self
.
fpr
=
fpr
self
.
pathname
=
os
.
path
.
join
(
KEYRINGS_TMPDIR
,
fpr
)
require_dir
(
self
.
pathname
,
mode
=
0o770
)
self
.
gpg
=
GPG
(
homedir
=
self
.
pathname
)
self
.
keyring
=
os
.
path
.
join
(
self
.
pathname
,
"user.gpg"
)
def
has_key
(
self
):
"""
Check if we already have the key
"""
return
self
.
gpg
.
has_key
(
self
.
keyring
,
self
.
fpr
)
def
refresh
(
self
):
"""
Fetch/refresh the key
"""
self
.
gpg
.
fetch_key
(
self
.
fpr
,
self
.
keyring
)
def
want_key
(
self
):
"""
Make sure that we have the key, no matter how old
"""
if
not
self
.
has_key
():
self
.
refresh
()
def
getmtime
(
self
):
"""
Return the modification time of the keyring. This can be used to check
how fresh is the key.
Returns 0 if the file is not there.
"""
try
:
return
os
.
path
.
getmtime
(
self
.
keyring
)
except
OSError
as
e
:
import
errno
if
e
.
errno
==
errno
.
ENOENT
:
return
0
raise
def
encrypt
(
self
,
data
):
"""
Encrypt the given data with this key, returning the ascii-armored
encrypted result.
"""
cmd
=
self
.
gpg
.
keyring_cmd
(
self
.
keyring
,
"--encrypt"
,
"--armor"
,
"--no-default-recipient"
,
"--trust-model=always"
,
"--recipient"
,
self
.
fpr
)
stdout
,
stderr
,
result
=
self
.
gpg
.
run_cmd
(
cmd
,
input
=
data
)
if
result
!=
0
:
raise
RuntimeError
(
"gpg exited with status %d: %s"
%
(
result
,
stderr
.
strip
()))
return
stdout
class
Changelog
(
object
):
re_date
=
re
.
compile
(
"^\d+-\d+-\d+$"
)
re_datetime
=
re
.
compile
(
"^\d+-\d+-\d+ \d+:\d+:\d+$"
)
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment