07.06.2014 Views

2 - Raspberry PI Community Projects

2 - Raspberry PI Community Projects

2 - Raspberry PI Community Projects

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

GOING FURTHER<br />

The m4 macro language<br />

To properly structure the policy, the SELinux developers used a macrocommand<br />

processor. Instead of duplicating many similar allow directives,<br />

they created “macro functions” to use a higher-level logic, which also results<br />

in a much more readable policy.<br />

In practice, m4 is used to compile those rules. It does the opposite operation: it<br />

expands all those high-level directives into a huge database of allow directives.<br />

The SELinux “interfaces” are only macro functions which will be substituted<br />

by a set of rules at compilation time. Likewise, some rights are in fact sets of<br />

rights which are replaced by their values at compilation time.<br />

policy_module(myapp,1.0.0) 1 1<br />

########################################<br />

#<br />

# Declarations<br />

#<br />

type myapp_t;<br />

1 2<br />

type myapp_exec_t;<br />

domain_type(myapp_t)<br />

domain_entry_file(myapp_t, myapp_exec_t) 1 3<br />

type myapp_log_t;<br />

logging_log_file(myapp_log_t)<br />

1 4<br />

type myapp_tmp_t;<br />

files_tmp_file(myapp_tmp_t)<br />

########################################<br />

#<br />

# Myapp local policy<br />

#<br />

allow myapp_t myapp_log_t:file { read_file_perms append_file_perms }; 1 5<br />

allow myapp_t myapp_tmp_t:file manage_file_perms;<br />

files_tmp_filetrans(myapp_t,myapp_tmp_t,file)<br />

1 1<br />

The module must be identified by its name and version number. This directive is required.<br />

1 2<br />

If the module introduces new types, it must declare them with directives like this one. Do<br />

not hesitate to create as many types as required rather than granting too many useless<br />

rights.<br />

Chapter 14 — Security<br />

397

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!