repos / pico

pico services - prose.sh, pastes.sh, imgs.sh, feeds.sh, pgs.sh
git clone https://github.com/picosh/pico.git

commit
9aaa466
parent
03e0845
author
Antonio Mika
date
2023-11-10 17:12:53 +0000 UTC
Properly close connection for unsupported flags
1 files changed,  +23, -2
M wish/send/rsync/rsync.go
+23, -2
 1@@ -23,6 +23,7 @@ type handler struct {
 2 	writeHandler utils.CopyFromClientHandler
 3 	root         string
 4 	recursive    bool
 5+	ignoreTimes  bool
 6 }
 7 
 8 func (h *handler) Skip(file *rsyncutils.ReceiverFile) bool {
 9@@ -164,9 +165,28 @@ func Middleware(writeHandler utils.CopyFromClientHandler) wish.Middleware {
10 			for _, arg := range cmd {
11 				if arg == "--sender" {
12 					opts, parser := rsyncsender.NewGetOpt()
13-					_, _ = parser.Parse(cmdFlags)
14+
15+					compress := parser.Bool("z", false)
16+
17+					_, _ = parser.Parse(cmdFlags[1:])
18 
19 					fileHandler.recursive = opts.Recurse
20+					fileHandler.ignoreTimes = opts.IgnoreTimes
21+
22+					if *compress {
23+						session.Stderr().Write([]byte("compression is currently unsupported\r\n"))
24+						return
25+					}
26+
27+					if opts.PreserveUid {
28+						session.Stderr().Write([]byte("uid preservation will not work as we don't retain user information\r\n"))
29+						return
30+					}
31+
32+					if opts.PreserveGid {
33+						session.Stderr().Write([]byte("gid preservation will not work as we don't retain user information\r\n"))
34+						return
35+					}
36 
37 					if err := rsyncsender.ClientRun(opts, session, fileHandler, fileHandler.root, true); err != nil {
38 						writeHandler.GetLogger().Error("error running rsync sender:", err)
39@@ -176,9 +196,10 @@ func Middleware(writeHandler utils.CopyFromClientHandler) wish.Middleware {
40 			}
41 
42 			opts, parser := rsyncreceiver.NewGetOpt()
43-			_, _ = parser.Parse(cmdFlags)
44+			_, _ = parser.Parse(cmdFlags[1:])
45 
46 			fileHandler.recursive = opts.Recurse
47+			fileHandler.ignoreTimes = opts.IgnoreTimes
48 
49 			if _, err := rsyncreceiver.ClientRun(opts, session, fileHandler, true); err != nil {
50 				writeHandler.GetLogger().Error("error running rsync receiver:", err)