Skip to content
This repository has been archived by the owner on Sep 18, 2022. It is now read-only.

Commit

Permalink
take into account that principals can be principals/<username> from l…
Browse files Browse the repository at this point in the history
…egacy installs

 Backport of commit 1c8fe29)
  • Loading branch information
BernieO committed Feb 14, 2019
1 parent a6d73c5 commit da7b815
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
14 changes: 9 additions & 5 deletions calcardbackup
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
set -euo pipefail

# calcardbackup version:
version="0.8.5-11_no-fd (14.02.2019), AGPL-3.0"
version="0.8.5-12_no-fd (14.02.2019), AGPL-3.0"

###
### BEGIN: FUNCTION DEFINITIONS
Expand Down Expand Up @@ -876,7 +876,9 @@ query_database() {
id+=("${line%%|*}") # store id (first field) in array
line="${line#*|}" # cut first field (id)
fi
line="${line/principals\/users\/}" # remove "principals/users/" from line, to get username
# for the next two lines see: https://github.com/nextcloud/server/pull/13573
line="${line/principals\/}" # at first only remove "principals/" from line to get username for legacy installs
line="${line/users\/}" # then also remove "users/" from line to get username for non-legacy installs
principal+=("${line%%|*}") # store principal (=username, is first field) in array
line="${line#*|}" # cut first field (principal)
if [[ "${item}" == "calendarsubscription" ]]; then
Expand Down Expand Up @@ -949,7 +951,9 @@ include_shares() {
share_type_group+=("${line%%|*}") # first field contains share-type_group
line="${line#*|}" # cut first field (share_type_group) from array
fi
line="${line/principals\/users\/}" # remove "principals/users/" to get username ("/principals/groups" stays there for groupcheck later)
# for the next two lines see: https://github.com/nextcloud/server/pull/13573
line="${line/principals\/}" # at first only remove "principals/" from line to get username for legacy installs
line="${line/users\/}" # then also remove "users/" from line to get username for non-legacy installs ("groups/" stays there for groupcheck later)
share_principal+=("${line%%|*}") # store share_principal (is now first field) in array
line="${line#*|}" # cut first field (share-principal)
share_type+=("${line%%|*}") # store share_type (is now first field) in array
Expand Down Expand Up @@ -1014,7 +1018,7 @@ include_shares() {
if [[ "${share_resourceid[$s]}" == "${id[$i]}" && "${share_type[$s]}" == "${item}" ]]; then
# make sure, principal of share is not a group (group will be treated below)
# first expression in next line is for ownCloud/Nextcloud >= 9.0, the second one (after &&) is for ownCloud < 9.0:
if [[ ! "${share_principal[$s]}" =~ principals/groups/ && ! "${share_type_group[$s]:-}" =~ ^1$ ]]; then
if [[ ! "${share_principal[$s]}" =~ groups/ && ! "${share_type_group[$s]:-}" =~ ^1$ ]]; then
# add identified dav-share (shared with a user!) to the temporary 'shares to be backed up'-arrays:
temp_principal+=("${share_principal[$s]}")
temp_uri+=("${uri[$i]}_shared_by_${principal[$i]}")
Expand All @@ -1027,7 +1031,7 @@ include_shares() {
# go through list with groups and their users and
# add item to the temporary 'shares to be backed up'-arrays for all users of that very group:
for g in "${!grouplist[@]}"; do
if [[ "${share_principal[$s]#*principals/groups/}" == "${grouplist[$g]%|*}" ]]; then
if [[ "${share_principal[$s]#*groups/}" == "${grouplist[$g]%|*}" ]]; then
# if item owner is member of group:
# do not add item to 'shares to be backed up'-arrays for owner, instead continue with next element
# (owner is excluded here, because owners item will be downloaded anyway: it is already in the array with items to be downloaded):
Expand Down
1 change: 1 addition & 0 deletions changelog
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
vX.X.X_no-fd (XX.XX.XXXX)
- improved: be more gentle and verbose, if no items found for users given in usersfile
- improved: rewrite of vendor detection
- fixed: take into account that principals can be principals/<username> from legacy installs
- fixed: don't request unset value instead of status.php, if overwrite.cli.url is unset
- fixed: if installed, prefer gpg2 over gpg to encrypt backup (fixes issue #18)
- fixed: minor typo in declaring local variables
Expand Down

1 comment on commit da7b815

@BernieO
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.