1
0
mirror of https://github.com/altlinux/gpupdate.git synced 2025-03-21 18:50:38 +03:00

util.kerberos: machine_kdestroy() introduced, used specific krb5 cache path

This commit is contained in:
Игорь Чудов 2020-06-25 13:38:30 +04:00
parent 004fc38962
commit 02e4da1758
Signed by untrusted user: nir
GPG Key ID: 0F3883600CAE7AAC

View File

@ -16,6 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from pathlib import Path
import logging
import subprocess
@ -23,15 +24,25 @@ from .util import get_machine_name
from .logging import slogm
def machine_kinit():
def machine_kinit(cache_name):
'''
Perform kinit with machine credentials
'''
host = get_machine_name()
subprocess.call(['kinit', '-k', host])
subprocess.call(['kinit', '-k', host, '-c', cache_name])
return check_krb_ticket()
def machine_kdestroy(cache_name):
'''
Perform kdestroy for machine credentials
'''
host = get_machine_name()
subprocess.call(['kdestroy', '-c', cache_name])
cache_file = Path(cache_name)
cache_file.unlink()
def check_krb_ticket():
'''
Check if Kerberos 5 ticket present