|
Packit Service |
30b792 |
#!/usr/bin/env python3
|
|
Packit Service |
30b792 |
# -*- coding: utf-8 -*-
|
|
Packit Service |
30b792 |
|
|
Packit Service |
30b792 |
from __future__ import absolute_import, division, unicode_literals
|
|
Packit Service |
30b792 |
|
|
Packit Service |
30b792 |
# Copyright (C) 2018 Ben McGinnes <ben@gnupg.org>
|
|
Packit Service |
30b792 |
#
|
|
Packit Service |
30b792 |
# This program is free software; you can redistribute it and/or modify it under
|
|
Packit Service |
30b792 |
# the terms of the GNU General Public License as published by the Free Software
|
|
Packit Service |
30b792 |
# Foundation; either version 2 of the License, or (at your option) any later
|
|
Packit Service |
30b792 |
# version.
|
|
Packit Service |
30b792 |
#
|
|
Packit Service |
30b792 |
# This program is free software; you can redistribute it and/or modify it under
|
|
Packit Service |
30b792 |
# the terms of the GNU Lesser General Public License as published by the Free
|
|
Packit Service |
30b792 |
# Software Foundation; either version 2.1 of the License, or (at your option)
|
|
Packit Service |
30b792 |
# any later version.
|
|
Packit Service |
30b792 |
#
|
|
Packit Service |
30b792 |
# This program is distributed in the hope that it will be useful, but WITHOUT
|
|
Packit Service |
30b792 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
Packit Service |
30b792 |
# FOR A PARTICULAR PURPOSE. See the GNU General Public License and the GNU
|
|
Packit Service |
30b792 |
# Lesser General Public License for more details.
|
|
Packit Service |
30b792 |
#
|
|
Packit Service |
30b792 |
# You should have received a copy of the GNU General Public License and the GNU
|
|
Packit Service |
30b792 |
# Lesser General Public along with this program; if not, see
|
|
Packit Service |
30b792 |
# <https://www.gnu.org/licenses/>.
|
|
Packit Service |
30b792 |
|
|
Packit Service |
30b792 |
import gpg
|
|
Packit Service |
30b792 |
import os.path
|
|
Packit Service |
30b792 |
|
|
Packit Service |
30b792 |
print("""
|
|
Packit Service |
30b792 |
This script revokes a user ID on an existing key.
|
|
Packit Service |
30b792 |
|
|
Packit Service |
30b792 |
The gpg-agent and pinentry are invoked to enter the passphrase.
|
|
Packit Service |
30b792 |
""")
|
|
Packit Service |
30b792 |
|
|
Packit Service |
30b792 |
c = gpg.Context()
|
|
Packit Service |
30b792 |
|
|
Packit Service |
30b792 |
homedir = input("Enter the GPG configuration directory path (optional): ")
|
|
Packit Service |
30b792 |
fpr0 = input("Enter the fingerprint of the key to modify: ")
|
|
Packit Service |
30b792 |
uid_name = input("Enter the name of the user ID: ")
|
|
Packit Service |
30b792 |
uid_email = input("Enter the email address of the user ID: ")
|
|
Packit Service |
30b792 |
uid_cmnt = input("Enter a comment to include (optional): ")
|
|
Packit Service |
30b792 |
|
|
Packit Service |
30b792 |
if homedir.startswith("~"):
|
|
Packit Service |
30b792 |
if os.path.exists(os.path.expanduser(homedir)) is True:
|
|
Packit Service |
30b792 |
c.home_dir = os.path.expanduser(homedir)
|
|
Packit Service |
30b792 |
else:
|
|
Packit Service |
30b792 |
pass
|
|
Packit Service |
30b792 |
elif os.path.exists(homedir) is True:
|
|
Packit Service |
30b792 |
c.home_dir = homedir
|
|
Packit Service |
30b792 |
else:
|
|
Packit Service |
30b792 |
pass
|
|
Packit Service |
30b792 |
|
|
Packit Service |
30b792 |
fpr = "".join(fpr0.split())
|
|
Packit Service |
30b792 |
|
|
Packit Service |
30b792 |
if uid_cmnt:
|
|
Packit Service |
30b792 |
userid = "{0} ({1}) <{2}>".format(uid_name, uid_cmnt, uid_email)
|
|
Packit Service |
30b792 |
else:
|
|
Packit Service |
30b792 |
userid = "{0} <{2}>".format(uid_name, uid_email)
|
|
Packit Service |
30b792 |
|
|
Packit Service |
30b792 |
key = c.get_key(fpr, secret=True)
|
|
Packit Service |
30b792 |
c.key_revoke_uid(key, userid)
|