diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2010-09-02 14:50:04 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2010-09-02 14:50:04 +0200 |
commit | 3b903c5c46287cc6f453b3138842715a467c57fb (patch) | |
tree | 7bab364cf5908a77960f4c2370bf65f0c7278ff2 | |
parent | df78f6e877325ddfd9569e9704612ee2509791b1 (diff) | |
download | dbscripts-3b903c5c46287cc6f453b3138842715a467c57fb.tar.gz dbscripts-3b903c5c46287cc6f453b3138842715a467c57fb.tar.xz |
Set correct group after touching the db file
* When writing the db file ensure that it has write permission of the group which owns the parent directory.
* This should make the adjust-permissions cron job obsolete.
-rw-r--r-- | db-functions | 14 | ||||
-rwxr-xr-x | db-move | 3 | ||||
-rwxr-xr-x | db-remove | 1 | ||||
-rwxr-xr-x | db-update | 1 |
4 files changed, 19 insertions, 0 deletions
diff --git a/db-functions b/db-functions index 28928da..7a751bf 100644 --- a/db-functions +++ b/db-functions @@ -387,3 +387,17 @@ check_repo_permission() { return 0 } + +set_repo_permission() { + local repo=$1 + local arch=$2 + local dbfile="${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT}" + + if [ -w "${dbfile}" ]; then + local group=$(/usr/bin/stat --printf='%G' "$(dirname "${dbfile}")") + chgrp $group "${dbfile}" || error "Could not change group of ${dbfile} to $group" + chmod g+w "${dbfile}" || error "Could not set write permission for group $group to ${dbfile}" + else + error "You don't have permission to change ${dbfile}" + fi +} @@ -108,8 +108,11 @@ for tarch in ${ARCHES[@]}; do if [ -n "${add_pkgs[${tarch}]}" ]; then /usr/bin/repo-add -q "${ftppath_to}/${tarch}/${repo_to}${DBEXT}" ${add_pkgs[${tarch}]} >/dev/null \ || error "repo-add ${tarch}/${repo_to}${DBEXT} ${add_pkgs[${tarch}]}" + set_repo_permission "${repo_to}" "${tarch}" + /usr/bin/repo-remove -q "${ftppath_from}/${tarch}/${repo_from}${DBEXT}" ${remove_pkgs[${tarch}]} >/dev/null \ || error "repo-remove ${tarch}/${repo_from}${DBEXT} ${remove_pkgs[${tarch}]}" + set_repo_permission "${repo_from}" "${tarch}" fi done @@ -48,5 +48,6 @@ for tarch in ${tarches[@]}; do fi /usr/bin/repo-remove -q "$ftppath/$tarch/$repo$DBEXT" ${pkgnames[@]} >/dev/null + set_repo_permission "${repo}" "${tarch}" repo_unlock $repo $tarch done @@ -68,6 +68,7 @@ for repo in ${repos[@]}; do /usr/bin/repo-add -q "$repo$DBEXT" ${add_pkgs[@]} >/dev/null \ || die "repo-add $repo$DBEXT ${add_pkgs[@]}" popd >/dev/null + set_repo_permission "${repo}" "${pkgarch}" fi done done |