Skip to content

Commit

Permalink
Rebase edge master (#2333)
Browse files Browse the repository at this point in the history
Co-authored-by: Giuseppe Lo Presti <[email protected]>
Co-authored-by: Gianmaria Del Monte <[email protected]>
Co-authored-by: David Christofas <[email protected]>
  • Loading branch information
4 people authored Dec 7, 2021
1 parent 7ac4043 commit ba8f2a6
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 20 deletions.
2 changes: 2 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ pkg/storage/fs/owncloudsql @cs3org/owncloud-team
pkg/storage/fs/owncloud @cs3org/owncloud-team
pkg/storage/fs/ocis @cs3org/owncloud-team
pkg/storage/utils/decomposedfs @cs3org/owncloud-team
pkg/storage/utils/eosfs @labkode @ishank011 @glpatcern
pkg/user/manager/owncloudsql @cs3org/owncloud-team
pkg/eosclient @labkode @ishank011 @glpatcern
pkg/app @labkode @ishank011 @wkloucek @glpatcern
3 changes: 3 additions & 0 deletions changelog/unreleased/fix-share-recyclebin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Bugfix: Remove share refs from trashbin

https://github.com/cs3org/reva/pull/2298
6 changes: 6 additions & 0 deletions changelog/unreleased/public-link-propfind.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enhancement: Add new attributes to public link propfinds

Added a new property "oc:signature-auth" to public link propfinds.
This is a necessary change to be able to support archive downloads in password protected public links.

https://github.com/cs3org/reva/pull/2315
18 changes: 18 additions & 0 deletions internal/http/services/owncloud/ocdav/propfind.go
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,24 @@ func (s *svc) mdToPropResponse(ctx context.Context, pf *propfindXML, md *provide
} else {
propstatNotFound.Prop = append(propstatNotFound.Prop, s.newProp("oc:"+pf.Prop[i].Local, ""))
}
case "signature-auth":
if isPublic {
// We only want to add the attribute to the root of the propfind.
if strings.HasSuffix(md.Path, ls.Token) && ls.Signature != nil {
expiration := time.Unix(int64(ls.Signature.SignatureExpiration.Seconds), int64(ls.Signature.SignatureExpiration.Nanos))
var sb strings.Builder
sb.WriteString("<oc:signature>")
sb.WriteString(ls.Signature.Signature)
sb.WriteString("</oc:signature>")
sb.WriteString("<oc:expiration>")
sb.WriteString(expiration.Format(time.RFC3339))
sb.WriteString("</oc:expiration>")

propstatOK.Prop = append(propstatOK.Prop, s.newPropRaw("oc:signature-auth", sb.String()))
} else {
propstatNotFound.Prop = append(propstatNotFound.Prop, s.newProp("oc:signature-auth", ""))
}
}
case "privatelink": // phoenix only
// <oc:privatelink>https://phoenix.owncloud.com/f/9</oc:privatelink>
fallthrough
Expand Down
3 changes: 0 additions & 3 deletions internal/http/services/owncloud/ocdav/publicfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,6 @@ func (s *svc) handlePropfindOnToken(w http.ResponseWriter, r *http.Request, ns s
w.WriteHeader(http.StatusNotFound)
return
}
// adjust path
tokenStatInfo.Path = path.Join("/", tokenStatInfo.Path, path.Base(pathRes.Path))

infos := s.getPublicFileInfos(onContainer, depth == "0", tokenStatInfo)

propRes, err := s.multistatusResponse(ctx, &pf, infos, ns, nil)
Expand Down
8 changes: 6 additions & 2 deletions pkg/eosclient/eosbinary/eosbinary.go
Original file line number Diff line number Diff line change
Expand Up @@ -632,8 +632,12 @@ func (c *Client) CreateDir(ctx context.Context, auth eosclient.Authorization, pa
}

// Remove removes the resource at the given path
func (c *Client) Remove(ctx context.Context, auth eosclient.Authorization, path string) error {
args := []string{"rm", "-r", path}
func (c *Client) Remove(ctx context.Context, auth eosclient.Authorization, path string, noRecycle bool) error {
args := []string{"rm", "-r"}
if noRecycle {
args = append(args, "--no-recycle-bin") // do not put the file in the recycle bin
}
args = append(args, path)
_, _, err := c.executeEOS(ctx, args, auth)
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/eosclient/eosclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type EOSClient interface {
Chown(ctx context.Context, auth, chownauth Authorization, path string) error
Chmod(ctx context.Context, auth Authorization, mode, path string) error
CreateDir(ctx context.Context, auth Authorization, path string) error
Remove(ctx context.Context, auth Authorization, path string) error
Remove(ctx context.Context, auth Authorization, path string, noRecycle bool) error
Rename(ctx context.Context, auth Authorization, oldPath, newPath string) error
List(ctx context.Context, auth Authorization, path string) ([]*FileInfo, error)
Read(ctx context.Context, auth Authorization, path string) (io.ReadCloser, error)
Expand Down
13 changes: 7 additions & 6 deletions pkg/eosclient/eosgrpc/eosgrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ func (c *Client) CreateDir(ctx context.Context, auth eosclient.Authorization, pa

}

func (c *Client) rm(ctx context.Context, auth eosclient.Authorization, path string) error {
func (c *Client) rm(ctx context.Context, auth eosclient.Authorization, path string, noRecycle bool) error {
log := appctx.GetLogger(ctx)
log.Info().Str("func", "rm").Str("uid,gid", auth.Role.UID+","+auth.Role.GID).Str("path", path).Msg("")

Expand All @@ -995,6 +995,7 @@ func (c *Client) rm(ctx context.Context, auth eosclient.Authorization, path stri

msg.Id = new(erpc.MDId)
msg.Id.Path = []byte(path)
msg.Norecycle = noRecycle

rq.Command = &erpc.NSRequest_Unlink{Unlink: msg}

Expand All @@ -1016,7 +1017,7 @@ func (c *Client) rm(ctx context.Context, auth eosclient.Authorization, path stri

}

func (c *Client) rmdir(ctx context.Context, auth eosclient.Authorization, path string) error {
func (c *Client) rmdir(ctx context.Context, auth eosclient.Authorization, path string, noRecycle bool) error {
log := appctx.GetLogger(ctx)
log.Info().Str("func", "rmdir").Str("uid,gid", auth.Role.UID+","+auth.Role.GID).Str("path", path).Msg("")

Expand All @@ -1031,7 +1032,7 @@ func (c *Client) rmdir(ctx context.Context, auth eosclient.Authorization, path s
msg.Id = new(erpc.MDId)
msg.Id.Path = []byte(path)
msg.Recursive = true
msg.Norecycle = false
msg.Norecycle = noRecycle

rq.Command = &erpc.NSRequest_Rm{Rm: msg}

Expand All @@ -1053,7 +1054,7 @@ func (c *Client) rmdir(ctx context.Context, auth eosclient.Authorization, path s
}

// Remove removes the resource at the given path
func (c *Client) Remove(ctx context.Context, auth eosclient.Authorization, path string) error {
func (c *Client) Remove(ctx context.Context, auth eosclient.Authorization, path string, noRecycle bool) error {
log := appctx.GetLogger(ctx)
log.Info().Str("func", "Remove").Str("uid,gid", auth.Role.UID+","+auth.Role.GID).Str("path", path).Msg("")

Expand All @@ -1064,10 +1065,10 @@ func (c *Client) Remove(ctx context.Context, auth eosclient.Authorization, path
}

if nfo.IsDir {
return c.rmdir(ctx, auth, path)
return c.rmdir(ctx, auth, path, noRecycle)
}

return c.rm(ctx, auth, path)
return c.rm(ctx, auth, path, noRecycle)
}

// Rename renames the resource referenced by oldPath to newPath
Expand Down
14 changes: 6 additions & 8 deletions pkg/storage/utils/eosfs/eosfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,7 @@ func (fs *eosfs) Delete(ctx context.Context, ref *provider.Reference) error {
return err
}

return fs.c.Remove(ctx, auth, fn)
return fs.c.Remove(ctx, auth, fn, false)
}

func (fs *eosfs) deleteShadow(ctx context.Context, p string) error {
Expand All @@ -1292,19 +1292,17 @@ func (fs *eosfs) deleteShadow(ctx context.Context, p string) error {
}

if fs.isShareFolderChild(ctx, p) {
u, err := getUser(ctx)
if err != nil {
return errors.Wrap(err, "eosfs: no user in ctx")
}

fn := fs.wrapShadow(ctx, p)

auth, err := fs.getUserAuth(ctx, u, "")
// in order to remove the folder or the file without
// moving it to the recycle bin, we should take
// the privileges of the root
auth, err := fs.getRootAuth(ctx)
if err != nil {
return err
}

return fs.c.Remove(ctx, auth, fn)
return fs.c.Remove(ctx, auth, fn, true)
}

return errors.New("eosfs: shadow delete of share folder that is neither root nor child. path=" + p)
Expand Down

0 comments on commit ba8f2a6

Please sign in to comment.