簡體   English   中英

提供對PHP服務器上svn簽出的HTTP只讀訪問權?

[英]Providing HTTP read-only access to svn checkout on a PHP server?

我在服務器上有一些Subversion存儲庫(最初是用svnadmin創建的)。 通過svn+ssh://有經過身份驗證的SSH讀寫訪問。 對於某些SVN存儲庫,我想允許通過http://進行匿名只讀訪問。 問題是我在該服務器上沒有管理屬性,因此我無法真正搞亂服務器設置或運行svnserve ,但是我可以擁有PHP腳本。 所以我想知道是否有某種解決方案(希望在PHP中)可以使我做到這一點(實現到Subversion存儲庫的“橋”, svn客戶端可以從中檢出)?

我想與git比較我想做什么。 如果我在目錄中執行git init.git得到.git子文件夾,其中包含與裸倉庫完全相同的內容。 我可以使用git clone --bare ...克隆此裸git clone --bare ... ,然后將其上傳到服務器-然后我可以使用git clone http://...和裸git clone --bare ...的位置直接進行克隆( 首先是, git會發出fatal: ... info/refs not found: did you run git update-server-info on the server? ;這意味着我應該啟用默認的更新后掛鈎[哪個]運行git update-server -info可以使啞傳輸(例如HTTP)所使用的信息保持最新 ;或在裸倉庫中運行git update-server-info ,這樣就會生成info/refs只有這樣,服務器上的裸倉庫才可以通過HTTP在客戶端上克隆 )。

因此,我認為svnadmin創建的存儲庫(具有內容dav db format hooks locks README.txt )等效於git裸存儲庫(因為它們都包含整個歷史記錄,沒有實際文件),所以我希望可以以相同的方式(即,僅通過復制服務器上的該文件夾內容)將svnadmin repo設置為只讀HTTP克隆。 不幸的是,事實並非如此-似乎即使使用HTTP訪問, svn實際上以服務器上的WebDAV形式通信( Subversion用戶:Re:dav目錄不存在SVN RedBook:WebDAV是什么? )。 因此,我嘗試了sabre / dav ,但是在成功的簡單設置(使用cadaver DAV命令行工具進行了測試)之后,我只能得到svn: OPTIONS of 'http://...': 200 OK (http://...)如果我指向svnadmin repo目錄(或它的dav/子目錄)。

我想當時我想要的可能無法實現:

回復:使用SabreDAV通過WebDav進行SVN或git-Google網上論壇

SVN協議需要對純webdav進行大量擴展才能起作用。 您在這里基本上不走運。

...但是我想肯定地確認這個問題...


感謝@Evert的回答; 但是不幸的是, svnsync似乎對我沒有幫助(由於“存儲庫永久移動”而失敗); 這是我在Apache服務器目錄上的bash運行的一組命令,其中一些命令響應以#開頭:

svn --version
# svn, version 1.6.6 (r40053)

cd /media/www
svnadmin create mytest.svnfs
svn co file:///media/www/mytest.svnfs mytest.svn

cd mytest.svn
echo aaa >> test.txt
svn add test.txt
svn commit -m "init commit"
echo bbb >> test.txt
svn add test.txt
svn commit -m "2nd com  mit"
wget -q --no-check-certificate http://localhost/mytest.svn -O - | head --bytes 120
# <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
# <html>
#  <head>
#   <title>Index of /mytest.svn</title>

cd ..
svnadmin create mytest.mirror
cat > mytest.mirror/hooks/pre-revprop-change <<'EOF'
#!/bin/sh
USER="$3"

if [ "$USER" = "syncuser" ]; then exit 0; fi

echo "Only the syncuser user can change revprops" >&2
exit 1
EOF
chmod +x mytest.mirror/hooks/pre-revprop-change
cat > mytest.mirror/hooks/start-commit <<'EOF'
#!/bin/sh

USER="$2"

if [ "$USER" = "syncuser" ]; then exit 0; fi

echo "Only the syncuser user may commit new revisions" >&2
exit 1
EOF
chmod +x mytest.mirror/hooks/start-commit
ls --ignore="*.tmpl" mytest.mirror/hooks/
# pre-revprop-change  start-commit

svnsync initialize file:///media/www/mytest.mirror http://localhost/mytest.svnfs/ --sync-username syncuser --sync-password syncpass
# svnsync: Repository moved permanently to 'http://localhost/mytest.svnfs/'; please relocate

# trying the working copy (even if it shouldn't work):
svnsync initialize file:///media/www/mytest.mirror http://localhost/mytest.svn/ --sync-username syncuser --sync-password syncpass
# svnsync: Repository moved permanently to 'http://localhost/mytest.svn/'; please relocate

我寫了這個答案,現在仍然成立。

簡而言之:

  1. SVN 服務器可以說webdav,Delta-V(webdav的版本擴展)
  2. SVN客戶端可以利用該服務器,但也需要 svn擴展。

幾年前確實如此,所以情況可能已經改變了……但我對此表示懷疑。

但是,對於您想做的事情,聽起來就像您只想使用svnsync

http://svnbook.red-bean.com/en/1.7/svn.reposadmin.maint.html#svn.reposadmin.maint.tk.svnsync

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM