Skip to content

Commit 3de1184

Browse files
committed
set permissions to 744 for all zipped files
1 parent 54bf64c commit 3de1184

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

tmc-langs-plugins/src/tmc_zip.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,17 @@ pub fn zip_student_files<P: StudentFilePolicy>(
3535
.unwrap_or_else(|| entry.path());
3636
if entry.path().is_dir() {
3737
log::trace!("adding directory {}", path.display());
38-
writer
39-
.add_directory(path_to_zip_compatible_string(path), FileOptions::default())?;
38+
writer.add_directory(
39+
path_to_zip_compatible_string(path),
40+
FileOptions::default().unix_permissions(0o744),
41+
)?;
4042
} else {
4143
let bytes = file_util::read_file(entry.path())?;
4244
log::trace!("writing file {}", path.display());
43-
writer.start_file(path_to_zip_compatible_string(path), FileOptions::default())?;
45+
writer.start_file(
46+
path_to_zip_compatible_string(path),
47+
FileOptions::default().unix_permissions(0o744),
48+
)?;
4449
writer
4550
.write_all(&bytes)
4651
.map_err(|e| TmcError::ZipWrite(path.to_path_buf(), e))?;

tmc-langs/src/course_refresher.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,15 +399,15 @@ fn execute_zip(
399399
if entry.path().is_file() {
400400
writer.start_file(
401401
relative_path.to_string_lossy(),
402-
zip::write::FileOptions::default(),
402+
zip::write::FileOptions::default().unix_permissions(0o744),
403403
)?;
404404
let bytes = file_util::read_file(entry.path())?;
405405
writer.write_all(&bytes).map_err(LangsError::ZipWrite)?;
406406
} else {
407407
// java-langs expects directories to have their own entries
408408
writer.start_file(
409409
relative_path.join("").to_string_lossy(), // java-langs expects directory entries to have a trailing slash
410-
zip::write::FileOptions::default(),
410+
zip::write::FileOptions::default().unix_permissions(0o744),
411411
)?;
412412
}
413413
}

tmc-langs/src/submission_packaging.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,15 @@ pub fn prepare_submission(
294294
stripped.display()
295295
);
296296
if entry_path.is_dir() {
297-
archive.add_directory(stripped.to_string_lossy(), FileOptions::default())?;
297+
archive.add_directory(
298+
stripped.to_string_lossy(),
299+
FileOptions::default().unix_permissions(0o744),
300+
)?;
298301
} else {
299-
archive.start_file(stripped.to_string_lossy(), FileOptions::default())?;
302+
archive.start_file(
303+
stripped.to_string_lossy(),
304+
FileOptions::default().unix_permissions(0o744),
305+
)?;
300306
let mut file = file_util::open_file(entry_path)?;
301307
std::io::copy(&mut file, &mut archive)
302308
.map_err(|e| LangsError::TarAppend(entry_path.to_path_buf(), e))?;

0 commit comments

Comments
 (0)