Skip to content

Commit

Permalink
feat(rcserver): allow for cat operation on /backup/schema files
Browse files Browse the repository at this point in the history
For Scylla 6.0, schema is backed up in a json file which needs to be opened and applied to cluster via cql session by SM during restore.
  • Loading branch information
Michal-Leszczynski authored and karol-kokoszka committed Jun 20, 2024
1 parent 4a6e089 commit 52948d3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/rclone/rcserver/rc.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ func init() {
rc.Add(rc.Call{
Path: "operations/cat",
AuthRequired: true,
Fn: wrap(rcCat, pathHasPrefix("backup/meta/")),
Fn: wrap(rcCat, pathHasPrefix("backup/meta/", "backup/schema/")),
Title: "Concatenate any files and send them in response",
Help: `This takes the following parameters
Expand Down
11 changes: 7 additions & 4 deletions pkg/rclone/rcserver/rchardening.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func wrap(fn rc.Func, v paramsValidator) rc.Func {

// pathHasPrefix reads "fs" and "remote" params, evaluates absolute path and
// ensures it has the required prefix.
func pathHasPrefix(prefix string) paramsValidator {
func pathHasPrefix(prefixes ...string) paramsValidator {
return func(ctx context.Context, in rc.Params) error {
_, p, err := joined(in, "fs", "remote")
if err != nil {
Expand All @@ -37,10 +37,13 @@ func pathHasPrefix(prefix string) paramsValidator {
i := strings.Index(p, "/")
p = p[i+1:]

if !strings.HasPrefix(p, prefix) {
return fs.ErrorPermissionDenied
for _, prefix := range prefixes {
if strings.HasPrefix(p, prefix) {
return nil
}
}
return nil

return fs.ErrorPermissionDenied
}
}

Expand Down

0 comments on commit 52948d3

Please sign in to comment.