Initial Git daemon domain. Modify git_selinux.8
PATCH 1/1 Initial Git daemon domain. Modify git_selinux.8
This is Fedoras' Git module revisited. Modified git_selinux.8 to reflect changes.
In my view unprivileged user domains, and admin domains should be able, from an SELinux perspective at least, to run Git session daemons in the Git session daemon domain by default. Git session domains should be allowed to bind tcp sockets to Git ports.
---
:100644 100644 e9c43b1... 3cc33d7... M man/man8/git_selinux.8
:100644 100644 2be17d2... addc3ad... M policy/modules/roles/staff.te
:100644 100644 0f96353... 58eb890... M policy/modules/roles/sysadm.te
:100644 100644 7e9da77... 46d24e3... M policy/modules/roles/unprivuser.te
:100644 100644 54f0737... e7a135c... M policy/modules/services/git.fc
:100644 100644 458aac6... 3a3db2b... M policy/modules/services/git.if
:100644 100644 7382f85... 2360634... M policy/modules/services/git.te
man/man8/git_selinux.8 | 48 ++-- policy/modules/roles/staff.te | 4 + policy/modules/roles/sysadm.te | 4 + policy/modules/roles/unprivuser.te | 4 + policy/modules/services/git.fc | 16 +- policy/modules/services/git.if | 534 +++++++++++++++++++++++++++++++++++- policy/modules/services/git.te | 186 +++++++++++++- 7 files changed, 767 insertions(+), 29 deletions(-)
man/man8/git_selinux.8 +24 -24
@@ -19,83 +19,83 @@ SELinux Git policy is very flexible allowing users to setup their web services i .PP The following file contexts types are by default defined for Git: .EX -git_system_content_t +git_sys_content_t .EE -- Set files with git_system_content_t if you want the Git system daemon to read the file, and if you want the file to be modifiable and executable by all "Git shell" users. +- Set files with git_sys_content_t if you want the Git system daemon to read the file, and if you want the file to be modifiable and executable by all Git system users. .EX git_session_content_t .EE -- Set files with git_session_content_t if you want the Git session and system daemon to read the file, and if you want the file to be modifiable and executable by all users. Note that "Git shell" users may not interact with this type. +- Set files with git_session_content_t if you want the Git session and system daemon to read the file, and if you want the file to be modifiable and executable by all Git session users. Note that Git system users may not interact with this type. .SH BOOLEANS SELinux policy is customizable based on least access required. Git policy is extremely flexible and has several booleans that allow you to manipulate the policy and run Git with the tightest access possible. .PP -Allow the Git system daemon to search user home directories so that it can find git session content. This is useful if you want the Git system daemon to host users personal repositories. +Determine whether Git system daemon can search user home directories so that it can find Git session repository content. This is useful if you want the Git system daemon to host personal Git repository content. .EX sudo setsebool -P git_system_enable_homedirs 1 .EE .PP -Allow the Git system daemon to read system shared repositories on NFS shares. +Determine whether Git system daemon can read any Git shared repository content on NFS shares. .EX sudo setsebool -P git_system_use_nfs 1 .EE .PP -Allow the Git system daemon to read system shared repositories on Samba shares. +Determine whether Git system daemon can read any shared repository content on Samba shares. .EX sudo setsebool -P git_system_use_cifs 1 .EE .PP -Allow the Git session daemon to read users personal repositories on NFS mounted home directories. +Determine whether Git session daemons can read personal repository content on NFS mounted home directories. .EX sudo setsebool -P use_nfs_home_dirs 1 .EE .PP -Allow the Git session daemon to read users personal repositories on Samba mounted home directories. +Determine whether Git session daemons can read personal repository content on Samba mounted home directories. .EX sudo setsebool -P use_samba_home_dirs 1 .EE .PP -To also allow Git system daemon to read users personal repositories on NFS and Samba mounted home directories you must also allow the Git system daemon to search home directories so that it can find the repositories. +To allow Git system daemon to read personal repository content on NFS and Samba mounted home directories you must also allow Git system daemon to search home directories so that it can find the personal repository content. .EX sudo setsebool -P git_system_enable_homedirs 1 .EE .PP -To allow the Git System daemon mass hosting of users personal repositories you can allow the Git daemon to listen to any unreserved ports. +Determine whether Git session daemons can listen on any unreserved TCP ports. This is useful for mass hosting of personal repository content. .EX sudo setsebool -P git_session_bind_all_unreserved_ports 1 .EE .SH GIT_SHELL -The Git policy by default provides a restricted user environment to be used with "Git shell". This default git_shell_u SELinux user can modify and execute generic Git system content (generic system shared respositories with type git_system_content_t). +The Git policy by default provides a restricted user environment to be used with "Git shell". The default git_shell_u Git system SELinux user can manage and execute generic Git shared repository content (shared repository content with type git_sys_content_t). .PP -To add a new Linux user and map him to this Git shell user domain automatically: +Add a new Unix user and map this user to the default Git system SELinux user automatically: .EX sudo useradd -Z git_shell_u joe .EE -.SH ADVANCED_SYSTEM_SHARED_REPOSITORY_AND GIT_SHELL_RESTRICTIONS -Alternatively Git SELinux policy can be used to restrict "Git shell" users to git system shared repositories. The policy allows for the creation of new types of Git system content and Git shell user environment. The policy allows for delegation of types of "Git shell" environments to types of Git system content. +.SH ADVANCED_SHARED_REPOSITORY_AND GIT_SHELL_RESTRICTIONS +Alternatively Git SELinux policy can be used to restrict Git system user types access to Git shared repository content types. The policy allows for the creation of new types of Git shared repository content and Git system users. The policy allows one to specify Git system user types access to Git shared repository content types. Note that any Git system user is allowed to manage and execute generic Git shared repository content. .PP -To add a new Git system repository type, for example "project1" create a file named project1.te and add to it: +Add a new Git shared repository content type, for example "project1". Create a file named project1.te and add to it: .EX policy_module(project1, 1.0.0) -git_content_template(project1) +git_sys_content_files_type(project1) .EE -Next create a file named project1.fc and add a file context specification for the new repository type to it: +Create a file named project1.fc, and add a file context specification for the new shared repository content type to it: .EX -/srv/git/project1\.git(/.*)? gen_context(system_u:object_r:git_project1_content_t,s0) +/var/lib/git/project1\.git(/.*)? gen_context(system_u:object_r:git_project1_content_t,s0) .EE -Build a binary representation of this source policy module, load it into the policy store and restore the context of the repository: +Build a binary representation of this source policy module, load it into the policy store and restore the context of the shared repository content: .EX make -f /usr/share/selinux/devel/Makefile project.pp sudo semodule -i project1.pp -sudo restorecon -R -v /srv/git/project1 +sudo restorecon -R -v /var/lib/git/project1.git .EE -To create a "Git shell" domain that can interact with this repository create a file named project1user.te in the same directory as where the source policy for the Git systemm content type is and add the following: +Create a Git system user domain that can interact with this shared repository content. Create a file named project1user.te in the same directory as where the source policy for the Git sys content file type is and add the following: .EX policy_module(project1user, 1.0.0) -git_role_template(project1user) -git_content_delegation(project1user_t, git_project1_content_t) +git_system_user_template(project1user) +git_rwx_spec_sys_content(project1user_t, git_project1_content_t) gen_user(project1user_u, user, project1user_r, s0, s0) .EE -Build a binary representation of this source policy module, load it into the policy store and map Linux users to the new project1user_u SELinux user: +Build a binary representation of this source policy module, load it into the policy store and map Unix users to the project1user_u SELinux user that was created: .EX make -f /usr/share/selinux/devel/Makefile project1user.pp sudo semodule -i project1user.pp
policy/modules/roles/staff.te +4 -0
@@ -27,6 +27,10 @@ optional_policy(` ') optional_policy(` + git_session_role_template(staff_r, staff_t) +') + +optional_policy(` postgresql_role(staff_r, staff_t) ')
policy/modules/roles/sysadm.te +4 -0
@@ -148,6 +148,10 @@ optional_policy(` ') optional_policy(` + git_session_role_template(sysadm_r, sysadm_t) +') + +optional_policy(` hostname_run(sysadm_t, sysadm_r) ')
policy/modules/roles/unprivuser.te +4 -0
@@ -17,6 +17,10 @@ optional_policy(` ') optional_policy(` + git_session_role_template(user_r, user_t) +') + +optional_policy(` screen_role_template(user, user_r, user_t) ')
policy/modules/services/git.fc +14 -2
@@ -1,3 +1,15 @@ -/var/cache/cgit(/.*)? gen_context(system_u:object_r:httpd_git_rw_content_t,s0) -/var/lib/git(/.*)? gen_context(system_u:object_r:httpd_git_content_t,s0) +HOME_DIR/public_git(/.*)? gen_context(system_u:object_r:git_session_content_t,s0) +HOME_DIR/\.gitaliases -- gen_context(system_u:object_r:git_session_content_t,s0) +HOME_DIR/\.gitconfig -- gen_context(system_u:object_r:git_session_content_t,s0) + +/srv/git(/.*)? gen_context(system_u:object_r:git_sys_content_t,s0) + +/usr/libexec/git-core/git-daemon -- gen_context(system_u:object_r:gitd_exec_t,s0) + +/var/cache/cgit(/.*)? gen_context(system_u:object_r:httpd_git_rw_content_t,s0) + +/var/lib/git(/.*)? gen_context(system_u:object_r:git_sys_content_t,s0) + /var/www/cgi-bin/cgit -- gen_context(system_u:object_r:httpd_git_script_exec_t,s0) +/var/www/git(/.*)? gen_context(system_u:object_r:httpd_git_content_t,s0) +/var/www/git/gitweb.cgi gen_context(system_u:object_r:httpd_git_script_exec_t,s0)
policy/modules/services/git.if +533 -1
534 lines not on this page · raw message
policy/modules/services/git.te +184 -2
192 lines not on this page · raw message
Signature · 9 lines
1.7.1 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: not available Url : http://oss.tresys.com/pipermail/refpolicy/attachments/20110822/a0d2149e/attachment-0001.bin