diff options
author | Christian Heimes <cheimes@redhat.com> | 2017-12-15 14:02:34 +0100 |
---|---|---|
committer | Christian Heimes <cheimes@redhat.com> | 2018-02-07 17:27:11 +0100 |
commit | 6a54146bc0902e768a659e68394e454ba3993a0b (patch) | |
tree | 71b4a8a03935bb22c662bdba1db68e6f1b9830b2 | |
parent | 7670dcb8533e7c5b1a89f50af39d1128d344fb38 (diff) | |
download | freeipa-6a54146bc0902e768a659e68394e454ba3993a0b.tar.gz freeipa-6a54146bc0902e768a659e68394e454ba3993a0b.tar.xz freeipa-6a54146bc0902e768a659e68394e454ba3993a0b.zip |
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>
-rwxr-xr-x | daemons/dnssec/ipa-ods-exporter | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/daemons/dnssec/ipa-ods-exporter b/daemons/dnssec/ipa-ods-exporter index 748bce40d..d00dab9de 100755 --- a/daemons/dnssec/ipa-ods-exporter +++ b/daemons/dnssec/ipa-ods-exporter @@ -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() |