mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2026-07-29 15:55:47 -05: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:
@@ -17,19 +17,21 @@ Purpose of this replacement is to upload keys generated by OpenDNSSEC to LDAP.
|
|||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import dateutil.tz
|
|
||||||
import dns.dnssec
|
|
||||||
from gssapi.exceptions import GSSError
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
import select
|
import select
|
||||||
import sys
|
import sys
|
||||||
import systemd.daemon
|
|
||||||
import systemd.journal
|
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
|
import dateutil.tz
|
||||||
|
import dns.dnssec
|
||||||
|
from gssapi.exceptions import GSSError
|
||||||
|
import six
|
||||||
|
import systemd.daemon
|
||||||
|
import systemd.journal
|
||||||
|
|
||||||
import ipalib
|
import ipalib
|
||||||
from ipalib.constants import SOFTHSM_DNSSEC_TOKEN_LABEL
|
from ipalib.constants import SOFTHSM_DNSSEC_TOKEN_LABEL
|
||||||
from ipalib.install.kinit import kinit_keytab
|
from ipalib.install.kinit import kinit_keytab
|
||||||
@@ -470,8 +472,11 @@ def receive_systemd_command():
|
|||||||
|
|
||||||
# this implements cmdhandler_handle_cmd() logic
|
# this implements cmdhandler_handle_cmd() logic
|
||||||
cmd = conn.recv(ODS_SE_MAXLINE).strip()
|
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)
|
logger.debug('received command "%s" from systemd socket', cmd)
|
||||||
return (cmd, conn)
|
return cmd, conn
|
||||||
|
|
||||||
def parse_command(cmd):
|
def parse_command(cmd):
|
||||||
"""Parse command to (exit code, message, zone_name) tuple.
|
"""Parse command to (exit code, message, zone_name) tuple.
|
||||||
@@ -516,7 +521,9 @@ def parse_command(cmd):
|
|||||||
def send_systemd_reply(conn, reply):
|
def send_systemd_reply(conn, reply):
|
||||||
# Reply & close connection early.
|
# Reply & close connection early.
|
||||||
# This is necessary to let Enforcer to unlock the ODS DB.
|
# 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.shutdown(socket.SHUT_RDWR)
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user