CentOS Stream 9
Sponsored Link

Subversion : アクセス権を設定する2022/07/20

 
[svnserve] を起動している場合の、リポジトリに対するアクセス権の設定です。
([http://] や [file://] でアクセスする場合は無関係)
[1] 例として [/var/svn/repos/project] リポジトリに対するアクセス権を設定します。
[root@dlp ~]#
vi /var/svn/repos/project/conf/svnserve.conf
# 9行目 : 匿名アクセスを禁止する場合は追記

[general]
anon-access = none
# 28行目 : コメント解除

password-db = passwd
# 37行目 : コメント解除

authz-db = authz
[root@dlp ~]#
vi /var/svn/repos/project/conf/passwd
# ユーザー名とパスワードを設定

[users]
redhat = password
cent = password
fedora = password
[root@dlp ~]#
vi /var/svn/repos/project/conf/authz
# グループと所属ユーザーを定義

[groups]
developer = redhat,cent
# ドキュメントルートに対して [developer] グループに読み書き許可

[/]
@developer = rw
# [trunk] フォルダに対して [fedora] に読み取り許可

[/trunk]
fedora = r
[2] 任意のホストから SVN アクセスして設定を確認します。
[cent@node01 ~]$
svn --username cent list svn://dlp.srv.world/repos/project

Authentication realm: <svn://dlp.srv.world:3690> a346b3d1-11f2-4c5d-af1c-5962676b07e8
Password for 'cent': ********   # [1] で設定したパスワード

-----------------------------------------------------------------------
ATTENTION!  Your password for authentication realm:

   <svn://dlp.srv.world:3690> a346b3d1-11f2-4c5d-af1c-5962676b07e8

can only be stored to disk unencrypted!  You are advised to configure
your system so that Subversion can store passwords encrypted, if
possible.  See the documentation for details.

You can avoid future appearances of this warning by setting the value
of the 'store-plaintext-passwords' option to either 'yes' or 'no' in
'/home/cent/.subversion/servers'.
-----------------------------------------------------------------------
Store password unencrypted (yes/no)? no
branches/
tags/
trunk/

# 注意書きの通り設定

[cent@node01 ~]$
echo 'store-plaintext-passwords = no' >> ~/.subversion/servers
[cent@node01 ~]$
mkdir work3

[cent@node01 ~]$
cd work3

[cent@node01 work3]$
svn --username cent co svn://dlp.srv.world/repos/project

Authentication realm: <svn://dlp.srv.world:3690> a346b3d1-11f2-4c5d-af1c-5962676b07e8
Password for 'cent': ********

A    project/branches
A    project/tags
A    project/trunk
Checked out revision 3.

[cent@node01 work3]$
cd project/trunk
# 適当にバージョン管理下の任意のファイル作成/編集後に
# [fedora] ユーザーで [commit]

[cent@node01 trunk]$
echo "index.html" > index.html

[cent@node01 trunk]$
svn add index.html

[cent@node01 trunk]$
svn --username fedora ci index.html -m "add new index.html 2022072001"

Authentication realm: <svn://dlp.srv.world:3690> a346b3d1-11f2-4c5d-af1c-5962676b07e8
Password for 'fedora': ********

.....
.....

svn: E170001: Commit failed (details follow):
svn: E170001: Authorization failed
# 設定通り拒否された

# [redhat] ユーザーで [commit]

[cent@node01 trunk]$
svn --username redhat ci index.html -m "add new index.html 2022072001"

Authentication realm: <svn://dlp.srv.world:3690> a346b3d1-11f2-4c5d-af1c-5962676b07e8
Password for 'redhat': ********

Adding         index.html
Transmitting file data .done
Committing transaction...
Committed revision 6.
# 設定通り [commit] できた

[cent@node01 trunk]$
svn update

[cent@node01 trunk]$
svn list

index.html
test.txt
testfile.txt
関連コンテンツ