*http 存取 Git Repository

  1. 本系統架設的 git repository python_pg.git 為 http 協定存取,所以其用戶及群組變更為 apache。
    root@ip123:/srv/git# chown -R apache:apache python_pg.git
    root@ip123:/srv/git# ll python_pg.git/
    total 16
    drwxr-xr-x. 2 apache apache    6 Feb  3 07:38 branches
    -rw-r--r--. 1 apache apache   66 Feb  3 07:38 config
    -rw-r--r--. 1 apache apache   73 Feb  3 07:38 description
    -rw-r--r--. 1 apache apache   23 Feb  3 07:38 HEAD
    drwxr-xr-x. 2 apache apache 4096 Feb  3 07:38 hooks
    drwxr-xr-x. 2 apache apache   21 Feb  3 07:38 info
    drwxr-xr-x. 4 apache apache   30 Feb  3 07:38 objects
    drwxr-xr-x. 4 apache apache   31 Feb  3 07:38 refs
    
  2. 為確保 SELinux enforcing 情況下,可以存取 git repository python_pg.git,所以其用戶及群組變更為 apache。
    root@ip123:/srv/git# semanage fcontext -a -t httpd_sys_rw_content_t "/srv/git/python_pg.git(/.*)?"
    root@ip123:/srv/git# restorecon -rv /srv/git/python_pg.git
    Relabeled /srv/git/python_pg.git from unconfined_u:object_r:var_t:s0 
    to unconfined_u:object_r:httpd_sys_rw_content_t:s0
    Relabeled /srv/git/python_pg.git/branches from unconfined_u:object_r:var_t:s0 
    to unconfined_u:object_r:httpd_sys_rw_content_t:s0
    ..........以下省略..............
    
  3. 查看 git repository python_pg.git 的 SELinux fcontext type,已變更為 httpd_sys_rw_content_t
    root@ip123:/srv/git# ls -Z python_pg.git/
    unconfined_u:object_r:httpd_sys_rw_content_t:s0 branches
    unconfined_u:object_r:httpd_sys_rw_content_t:s0 config
    unconfined_u:object_r:httpd_sys_rw_content_t:s0 description
    unconfined_u:object_r:httpd_sys_rw_content_t:s0 HEAD
    unconfined_u:object_r:httpd_sys_rw_content_t:s0 hooks
    unconfined_u:object_r:httpd_sys_rw_content_t:s0 info
    unconfined_u:object_r:httpd_sys_rw_content_t:s0 objects
    unconfined_u:object_r:httpd_sys_rw_content_t:s0 refs
    
  4. 重新啟動 httpd 服務。
    root@ip123:/srv/git# systemctl restart httpd