@@ -54,6 +54,98 @@ func TestDaemonReceiverSync(t *testing.T) {
54
54
}
55
55
}
56
56
57
+ // like TestDaemonReceiverSync, but specifying a destination path that is a subdirectory
58
+ // within the module.
59
+ func TestDaemonReceiverSyncSubdir (t * testing.T ) {
60
+ t .Parallel ()
61
+
62
+ rsyncBin := rsynctest .TridgeOrGTFO (t , "TODO: reason" )
63
+
64
+ tmp := t .TempDir ()
65
+ source := filepath .Join (tmp , "source" )
66
+ dest := filepath .Join (tmp , "dest" )
67
+ destLarge := filepath .Join (dest , "destsubdir" , "large-data-file" )
68
+
69
+ headPattern := []byte {0x11 }
70
+ bodyPattern := []byte {0xbb }
71
+ endPattern := []byte {0xee }
72
+ rsynctest .WriteLargeDataFile (t , source , headPattern , bodyPattern , endPattern )
73
+
74
+ // start a server which receives data
75
+ srv := rsynctest .New (t , rsynctest .WritableInteropModule (dest ))
76
+
77
+ rsync := exec .Command (rsyncBin ,
78
+ // "--debug=all4",
79
+ "--archive" ,
80
+ // A verbosity level of 3 is enough, any higher than that and rsync
81
+ // will start listing individual chunk matches.
82
+ "-v" , "-v" , "-v" , // "-v",
83
+ "--port=" + srv .Port ,
84
+ source + "/" , // copy contents of source
85
+ "rsync://localhost/interop/destsubdir/" )
86
+ rsync .Env = append (os .Environ (),
87
+ // Ensure rsync does not localize decimal separators and fractional
88
+ // points based on the current locale:
89
+ "LANG=C.UTF-8" )
90
+ rsync .Stdout = testlogger .New (t )
91
+ rsync .Stderr = testlogger .New (t )
92
+ if err := rsync .Run (); err != nil {
93
+ t .Fatalf ("%v: %v" , rsync .Args , err )
94
+ }
95
+
96
+ if err := rsynctest .DataFileMatches (destLarge , headPattern , bodyPattern , endPattern ); err != nil {
97
+ t .Fatal (err )
98
+ }
99
+ }
100
+
101
+ // like TestDaemonReceiverSync, but specifying a destination path that is a subdirectory
102
+ // within the module.
103
+ func TestDaemonReceiverSyncSubdirTraversal (t * testing.T ) {
104
+ t .Parallel ()
105
+
106
+ rsyncBin := rsynctest .TridgeOrGTFO (t , "TODO: reason" )
107
+
108
+ tmp := t .TempDir ()
109
+ source := filepath .Join (tmp , "source" )
110
+ dest := filepath .Join (tmp , "dest" )
111
+ destLarge := filepath .Join (dest , "destsubdir" , "large-data-file" )
112
+
113
+ headPattern := []byte {0x11 }
114
+ bodyPattern := []byte {0xbb }
115
+ endPattern := []byte {0xee }
116
+ rsynctest .WriteLargeDataFile (t , source , headPattern , bodyPattern , endPattern )
117
+
118
+ // start a server which receives data
119
+ srv := rsynctest .New (t , rsynctest .WritableInteropModule (dest ))
120
+
121
+ rsync := exec .Command (rsyncBin ,
122
+ // "--debug=all4",
123
+ "--archive" ,
124
+ // A verbosity level of 3 is enough, any higher than that and rsync
125
+ // will start listing individual chunk matches.
126
+ "-v" , "-v" , "-v" , // "-v",
127
+ "--port=" + srv .Port ,
128
+ source + "/" , // copy contents of source
129
+ "rsync://localhost/interop/../" )
130
+ rsync .Env = append (os .Environ (),
131
+ // Ensure rsync does not localize decimal separators and fractional
132
+ // points based on the current locale:
133
+ "LANG=C.UTF-8" )
134
+ var buf bytes.Buffer
135
+ rsync .Stdout = & buf
136
+ rsync .Stderr = & buf
137
+ if err := rsync .Run (); err != nil {
138
+ if strings .Contains (buf .String (), "path escapes from parent" ) {
139
+ return
140
+ }
141
+ t .Fatalf ("%v: %v" , rsync .Args , err )
142
+ }
143
+
144
+ if err := rsynctest .DataFileMatches (destLarge , headPattern , bodyPattern , endPattern ); err != nil {
145
+ t .Fatal (err )
146
+ }
147
+ }
148
+
57
149
func TestDaemonReceiverDelete (t * testing.T ) {
58
150
t .Parallel ()
59
151
0 commit comments