Skip to contentSkip to conversation

TCP server howto

refpolicy Daniel J Walsh 2 participants 2 messages Mar 2, 2009 – Mar 5, 2009 3 messages not in the archive

lore
Share & tools
lore
#3 lore raw
In reply to a message not in the archive

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 40 lines · Jan Kasprzak

Dominick Grift wrote:
: I think corenet_reserved_port() is what you are looking for. :
Thanks for the hint. It is _almost_ exactly as you wrote,
except:

: # Declarations
:
: type my_port_t;
: corenet_reserved_port(my_port_t)
:
: # Policy
:
: corenet_all_recvfrom_unlabeled($1)
: corenet_all_recvfrom_netlabel($1)
: corenet_tcp_sendrecv_generic_if($1)
: corenet_tcp_sendrecv_generic_node($1)
: corenet_tcp_sendrecv_all_ports($1)
- corenet_tcp_bind_generic_node($1)
+ corenet_tcp_bind_inadrr_any_node($1)

: allow $1 my_port_t:tcp_socket name_bind;

+ allow $1 self:capability net_bind_service;
+ allow $1 self:tcp_socket create_stream_socket_perms;

: #EOF
:
: sudo semanage port -a -t my_port_t -p tcp 40

I would however like to have a really-high-level macro (or two)
to do the above - I guess this is what many users would like to do
- saying "this context belongs to my port", and "this domain can run a TCP server on this port". The similar way how the files_pid_file() and files_pid_filetrans() macros allow for the
"I want to have my own PID file in /var/run" case.

Would it be acceptable to submit this as a patch for inclusion
in the upstream policy?

Quoted 9 lines

I would like to have other things included upstream as well - for
example, now I have a policy bits for Perl: file contexts for /usr/bin/perl* and /usr/lib{,64}/perl5/*, and an interface macro for saying "this domain can run Perl scripts".

Thanks,

-Yenya

Yenya, take this discussion to the refpolicy list

<[email protected]>

Better to discuss it there. I think having a higher level template for creating a tcp or udp port would not be a bad idea. See what upstream thinks.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iEYEARECAAYFAkmsDzYACgkQrlYvE4MpobNJHwCfZ5YbOsiYpBATkbTZyCqkZWh+ wGUAn1qN1EySr3iW5Pn4TO8aDrhJKZRA
=+xoQ
-----END PGP SIGNATURE-----

#4 lore raw
Quoted 54 lines · Daniel J Walsh

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 40 lines · Jan Kasprzak

Dominick Grift wrote:
: I think corenet_reserved_port() is what you are looking for. :
Thanks for the hint. It is _almost_ exactly as you wrote,
except:

: # Declarations
:
: type my_port_t;
: corenet_reserved_port(my_port_t)
:
: # Policy
:
: corenet_all_recvfrom_unlabeled($1)
: corenet_all_recvfrom_netlabel($1)
: corenet_tcp_sendrecv_generic_if($1)
: corenet_tcp_sendrecv_generic_node($1)
: corenet_tcp_sendrecv_all_ports($1)
- corenet_tcp_bind_generic_node($1)
+ corenet_tcp_bind_inadrr_any_node($1)

: allow $1 my_port_t:tcp_socket name_bind;

+ allow $1 self:capability net_bind_service;
+ allow $1 self:tcp_socket create_stream_socket_perms;

: #EOF
:
: sudo semanage port -a -t my_port_t -p tcp 40

I would however like to have a really-high-level macro (or two)
to do the above - I guess this is what many users would like to do
- saying "this context belongs to my port", and "this domain can run a TCP server on this port". The similar way how the files_pid_file() and files_pid_filetrans() macros allow for the
"I want to have my own PID file in /var/run" case.

Would it be acceptable to submit this as a patch for inclusion
in the upstream policy?

Quoted 9 lines

I would like to have other things included upstream as well - for
example, now I have a policy bits for Perl: file contexts for /usr/bin/perl* and /usr/lib{,64}/perl5/*, and an interface macro for saying "this domain can run Perl scripts".

Thanks,

-Yenya

Quoted 7 lines

Yenya, take this discussion to the refpolicy list

<[email protected]>

Better to discuss it there. I think having a higher level template for creating a tcp or udp port would not be a bad idea. See what upstream thinks.

I'm willing to consider it, but it'll need a good name.

Signature · 3 lines
Chris PeBenito
Tresys Technology, LLC
(410) 290-1411 x150