libsemanage: Add support for DCCP and SCTP protocols

This is necessary for "semanage port" to be able to handle DCCP and SCTP
protocols.

Fixes:
    "port_parse" only handles TCP and UDP protocols

Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
This commit is contained in:
Vit Mojzis 2019-10-08 14:22:12 +02:00 committed by Stephen Smalley
parent 74c5e551ca
commit 991dd7402f
2 changed files with 6 additions and 0 deletions

View File

@ -16,6 +16,8 @@ typedef struct semanage_port_key semanage_port_key_t;
#define SEMANAGE_PROTO_UDP 0
#define SEMANAGE_PROTO_TCP 1
#define SEMANAGE_PROTO_DCCP 2
#define SEMANAGE_PROTO_SCTP 3
/* Key */
extern int semanage_port_compare(const semanage_port_t * port,

View File

@ -84,6 +84,10 @@ static int port_parse(semanage_handle_t * handle,
semanage_port_set_proto(port, SEMANAGE_PROTO_TCP);
else if (!strcasecmp(str, "udp"))
semanage_port_set_proto(port, SEMANAGE_PROTO_UDP);
else if (!strcasecmp(str, "dccp"))
semanage_port_set_proto(port, SEMANAGE_PROTO_DCCP);
else if (!strcasecmp(str, "sctp"))
semanage_port_set_proto(port, SEMANAGE_PROTO_SCTP);
else {
ERR(handle, "invalid protocol \"%s\" (%s: %u):\n%s", str,
info->filename, info->lineno, info->orig_line);