1 |
On 01/12/16 15:31, Jason Zaman wrote: |
2 |
> On Thu, Dec 01, 2016 at 10:24:21AM +0000, Robert Sharp wrote: |
3 |
>> Hi, |
4 |
>> |
5 |
>> |
6 |
>> I've looked at the Gentoo SELinux web pages etc, the SELinux Handbook |
7 |
>> and through the Reference Policy and I cannot find the answer to a |
8 |
>> simple question. |
9 |
>> |
10 |
>> I am writing a small policy for my backup system and I want to be able |
11 |
>> to a) access a MongoDB running on remote servers, and b) use rsync. I |
12 |
>> can see two AVCs relating to my port use and I know how I can fix the |
13 |
>> problem from the command line, but surely I should be able to address |
14 |
>> this in the policy? I think there is an rsync interface I need to call |
15 |
>> (rsync_entry_type(mytype_t)) and I assume this will run rsync in the |
16 |
>> right domain? |
17 |
>> |
18 |
>> Mongo has a policy but the only interface is admin. All I need to do |
19 |
>> locally is connect to the port. Can I use "portcon" in a policy to do |
20 |
>> this or do I need to do something else? |
21 |
>> |
22 |
>> Thanks, |
23 |
>> |
24 |
>> Robert Sharp |
25 |
> What port number is it using? does that port already have a label? if it |
26 |
> does then you use the corenet stuff, eg: |
27 |
> |
28 |
> corenet_tcp_connect_mysqld_port(foo_t) would allow foo_t to connect to |
29 |
> these ports: |
30 |
> |
31 |
> # semanage port -l | grep mysql |
32 |
> mysqld_port_t tcp 1186, 3306, 63132-63164 |
33 |
> |
34 |
> if there is no good label on the port currently, you can define your own |
35 |
> with semanage port. or it can be added to the base policy, because of |
36 |
> the way pp files work, you cannot do portcon in a module. If there is a |
37 |
> port that is missing a label, we can add it to the base in both refpol |
38 |
> and gentoos policy. |
39 |
> |
40 |
> Look at policy/modules/kernel/corenetwork.te.in in the policy for |
41 |
> adding a new one. |
42 |
> |
43 |
> As for rsync, if you want your script to be able to run it without |
44 |
> changing domain, you probably want rsync_exec(), if you want to transition |
45 |
> to rsync_t, then rsync_domtrans() |
46 |
> |
47 |
> -- Jason |
48 |
> |
49 |
Mongo uses tcp on port 27017 and there is nothing defined for this in |
50 |
the core policy. There is a mongodb policy in contrib but it uses |
51 |
corenet_all_recvfrom_unlabeled, corenet_tcp_sendrecv_generic_if and the |
52 |
likes. |
53 |
|
54 |
From what I can make out, semanage port will only allow me to assign a |
55 |
port to an existing label? Looks like I can only define a port label in |
56 |
the reference policy? What is the best way forward? If I was to add |
57 |
something to corenetwork.te it would look like this, I guess: |
58 |
|
59 |
type mongodb_port_t, port_type, defined_port_type; |
60 |
type mongodb_client_packet_t, packet_type, client_packet_type; |
61 |
type mongodb_server_packet_t, packet_type, server_packet_type; |
62 |
typeattribute mongodb_port_t unreserved_port_type; |
63 |
portcon tcp 27017 gen_context(system_u:object_r:mongodb_port_t,s0) |
64 |
|
65 |
Would that then create a "corenet_tcp_connect_mongodb_port" interface? |
66 |
|
67 |
Incidentally, if I have a little family of apps that use use a number of |
68 |
unreserved ports. Seems a little monolithic if the only way I can |
69 |
integrate them is to have them included in the base policy? Luckily they |
70 |
are not on the machine I am trying to get to strict atm, but they are on |
71 |
the next one. |
72 |
|
73 |
Thanks for your help, as always! |
74 |
|
75 |
Robert |