Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: file task uid gid #3359

Merged
merged 2 commits into from
Jul 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions client/daemon/rpcserver/rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,16 @@ func (s *server) download(ctx context.Context, req *dfdaemonv1.DownRequest, stre
log.Errorf("task %s/%s failed: %d/%s", p.PeerID, p.TaskID, p.State.Code, p.State.Msg)
return dferrors.New(p.State.Code, p.State.Msg)
}
if p.PeerTaskDone {
// update permission before send last result
if req.Uid != 0 && req.Gid != 0 {
log.Infof("change owner to uid %d gid %d", req.Uid, req.Gid)
if err = os.Chown(req.Output, int(req.Uid), int(req.Gid)); err != nil {
log.Errorf("change owner failed: %s", err)
return err
}
}
}
err = stream.Send(&dfdaemonv1.DownResult{
TaskId: p.TaskID,
PeerId: p.PeerID,
Expand All @@ -813,13 +823,6 @@ func (s *server) download(ctx context.Context, req *dfdaemonv1.DownRequest, stre
if p.PeerTaskDone {
p.DoneCallback()
log.Infof("task %s/%s done", p.PeerID, p.TaskID)
if req.Uid != 0 && req.Gid != 0 {
log.Infof("change own to uid %d gid %d", req.Uid, req.Gid)
if err = os.Chown(req.Output, int(req.Uid), int(req.Gid)); err != nil {
log.Errorf("change own failed: %s", err)
return err
}
}
return nil
}
case <-ctx.Done():
Expand Down
Loading