Portál AbcLinuxu, 31. října 2025 21:13
conf.d/vhosts.conf
<VirtualHost *:80> ServerName git.domain.tld DocumentRoot /var/lib/git SetEnv GIT_PROJECT_ROOT /var/lib/git SetEnv GIT_HTTP_EXPORT_ALL SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER ScriptAlias / /usr/libexec/git-core/git-http-backend/ Include conf.d/git/*.conf </VirtualHost>
conf.d/git/user_repo.conf
RewriteEngine On
RewriteCond %{QUERY_STRING} service=git-receive-pack [OR]
RewriteCond %{REQUEST_URI} ^/user/repo.git/git-receive-pack$
RewriteRule ^/user/repo.git/ - [E=RW:yes]
<LocationMatch "^/user/repo.git/">
  Order Allow,Deny
  Allow from env=RW
  AuthType Basic
  AuthName "GIT Repository"
  AuthUserFile /etc/httpd/conf.d/git/user_repo.rw
  Require valid-user
  Satisfy All
</LocationMatch>
RewriteCond %{QUERY_STRING} !service=git-receive-pack
RewriteCond %{REQUEST_URI} !^/user/repo.git/git-receive-pack$
RewriteRule ^/user/repo.git/ - [E=RO:yes]
<LocationMatch "^/user/repo.git/">
  Order Allow,Deny
  Allow from env=RO
  AuthType Basic
  AuthName "GIT Repository"
  AuthUserFile /etc/httpd/conf.d/git/user_repo.ro
  Require valid-user
  Satisfy All
</LocationMatch>
conf.d/git/user_repo.rw
user1:XXXXXXXXXX
conf.d/git/user_repo.ro
user1:XXXXXXXXXX user2:XXXXXXXXXX user3:XXXXXXXXXXToto samozrejme nefunguje, lebo pri write používateľovi síce prvý locationmatch prístup povolí, ale druhý locationmatch ho hneď znovu zakáže (čiže potreboval by som niečo také, že ak je splnený prvý locationmatch, nech druhý ignoruje) Skúšal som aj takéto niečo:
<Location "/user/repo.git"> AuthType Basic AuthName "GIT Repository" AuthUserFile /etc/httpd/conf.d/git/user_repo.ro Require valid-user </Location> <LocationMatch "^/user/repo.git/git-receive-pack$"> AuthType Basic AuthName "GIT Repository" AuthUserFile /etc/httpd/conf.d/git/user_repo.rw Require valid-user </LocationMatch>ale to mi pre zmenu blblo úplne (toto bol používateľ len pre čítanie a predsa sa to pokúsilo zapísať):
git push origin master Counting objects: 6, done. Delta compression using up to 4 threads. Compressing objects: 100% (6/6), done. Writing objects: 100% (6/6), 607 bytes | 0 bytes/s, done. Total 6 (delta 3), reused 0 (delta 0) error: RPC failed; result=22, HTTP code = 401 fatal: The remote end hung up unexpectedly fatal: The remote end hung up unexpectedlyPredpokladám, že kvôly tomu, že "POST /user/repo.git/git-receive-pack" síce "išlo" do RW LocationMatch, ale "GET /user/repo.git/info/refs?service=git-receive-pack" už išlo do RO Location Už som z toho neštastný. Dúfam, že sa tu nájde niekto, kto pochopí o čo mi ide a bude vedieť pomôcť. Za každú pomoc vám vopred veľmi pekne ďakujem.
Na otázku zatím nikdo bohužel neodpověděl.
        Tiskni
            
                Sdílej:
                 
                 
                 
                 
                 
                 
            
    
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.