@@ -102,6 +102,7 @@ pub(crate) struct Tarball<'a> {
102
102
103
103
include_target_in_component_name : bool ,
104
104
is_preview : bool ,
105
+ permit_symlinks : bool ,
105
106
}
106
107
107
108
impl < ' a > Tarball < ' a > {
@@ -141,6 +142,7 @@ impl<'a> Tarball<'a> {
141
142
142
143
include_target_in_component_name : false ,
143
144
is_preview : false ,
145
+ permit_symlinks : false ,
144
146
}
145
147
}
146
148
@@ -160,6 +162,10 @@ impl<'a> Tarball<'a> {
160
162
self . is_preview = is;
161
163
}
162
164
165
+ pub ( crate ) fn permit_symlinks ( & mut self , flag : bool ) {
166
+ self . permit_symlinks = flag;
167
+ }
168
+
163
169
pub ( crate ) fn image_dir ( & self ) -> & Path {
164
170
t ! ( std:: fs:: create_dir_all( & self . image_dir) ) ;
165
171
& self . image_dir
@@ -316,6 +322,18 @@ impl<'a> Tarball<'a> {
316
322
}
317
323
self . builder . run ( & mut cmd) ;
318
324
325
+ // Ensure there are no symbolic links in the tarball. In particular,
326
+ // rustup-toolchain-install-master and most versions of Windows can't handle symbolic links.
327
+ let decompressed_output = self . temp_dir . join ( & package_name) ;
328
+ if !self . builder . config . dry_run && !self . permit_symlinks {
329
+ for entry in walkdir:: WalkDir :: new ( & decompressed_output) {
330
+ let entry = t ! ( entry) ;
331
+ if entry. path_is_symlink ( ) {
332
+ panic ! ( "generated a symlink in a tarball: {}" , entry. path( ) . display( ) ) ;
333
+ }
334
+ }
335
+ }
336
+
319
337
// Use either the first compression format defined, or "gz" as the default.
320
338
let ext = self
321
339
. builder
@@ -328,7 +346,7 @@ impl<'a> Tarball<'a> {
328
346
329
347
GeneratedTarball {
330
348
path : crate :: dist:: distdir ( self . builder ) . join ( format ! ( "{}.tar.{}" , package_name, ext) ) ,
331
- decompressed_output : self . temp_dir . join ( package_name ) ,
349
+ decompressed_output,
332
350
work : self . temp_dir ,
333
351
}
334
352
}
0 commit comments