mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Decode ODS commands
ODS commands are ASCII strings, but socket.recv() returns bytes and socket.send() expects bytes. Encode/decode values properly. Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
This commit is contained in:
parent
7670dcb853
commit
6a54146bc0
@ -17,19 +17,21 @@ Purpose of this replacement is to upload keys generated by OpenDNSSEC to LDAP.
|
||||
from __future__ import print_function
|
||||
|
||||
from datetime import datetime
|
||||
import dateutil.tz
|
||||
import dns.dnssec
|
||||
from gssapi.exceptions import GSSError
|
||||
import logging
|
||||
import os
|
||||
import socket
|
||||
import select
|
||||
import sys
|
||||
import systemd.daemon
|
||||
import systemd.journal
|
||||
import sqlite3
|
||||
import traceback
|
||||
|
||||
import dateutil.tz
|
||||
import dns.dnssec
|
||||
from gssapi.exceptions import GSSError
|
||||
import six
|
||||
import systemd.daemon
|
||||
import systemd.journal
|
||||
|
||||
import ipalib
|
||||
from ipalib.constants import SOFTHSM_DNSSEC_TOKEN_LABEL
|
||||
from ipalib.install.kinit import kinit_keytab
|
||||
@ -470,8 +472,11 @@ def receive_systemd_command():
|
||||
|
||||
# this implements cmdhandler_handle_cmd() logic
|
||||
cmd = conn.recv(ODS_SE_MAXLINE).strip()
|
||||
# ODS uses an ASCII protocol
|
||||
if not isinstance(cmd, six.text_type):
|
||||
cmd = cmd.decode('ascii')
|
||||
logger.debug('received command "%s" from systemd socket', cmd)
|
||||
return (cmd, conn)
|
||||
return cmd, conn
|
||||
|
||||
def parse_command(cmd):
|
||||
"""Parse command to (exit code, message, zone_name) tuple.
|
||||
@ -516,7 +521,9 @@ def parse_command(cmd):
|
||||
def send_systemd_reply(conn, reply):
|
||||
# Reply & close connection early.
|
||||
# This is necessary to let Enforcer to unlock the ODS DB.
|
||||
conn.send(reply + '\n')
|
||||
if isinstance(reply, six.text_type):
|
||||
reply = reply.encode('ascii')
|
||||
conn.send(reply + b'\n')
|
||||
conn.shutdown(socket.SHUT_RDWR)
|
||||
conn.close()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user