@@ -17,12 +17,13 @@ use jiff::tz::TimeZone;
1717use jiff:: { Timestamp , ToSpan , Zoned } ;
1818use std:: borrow:: Cow ;
1919use std:: ffi:: { OsStr , OsString } ;
20- use std:: fs:: { self , File } ;
20+ use std:: fs;
2121use std:: io:: { Error , ErrorKind } ;
2222use std:: path:: { Path , PathBuf } ;
2323use std:: time:: SystemTime ;
2424use uucore:: display:: Quotable ;
2525use uucore:: error:: { FromIo , UResult , USimpleError } ;
26+ use uucore:: fs:: create_file_restrictive_perm;
2627#[ cfg( target_os = "linux" ) ]
2728use uucore:: libc;
2829use uucore:: parser:: shortcut_value_parser:: ShortcutValueParser ;
@@ -476,9 +477,9 @@ fn touch_file(
476477 return Ok ( ( ) ) ;
477478 }
478479
479- if let Err ( e) = File :: create ( path) {
480+ if let Err ( e) = create_file_restrictive_perm ( path, true ) {
480481 // we need to check if the path is the path to a directory (ends with a separator)
481- // we can't use File::create to create a directory
482+ // we can't use create_file to create a directory
482483 // we cannot use path.is_dir() because it calls fs::metadata which we already called
483484 // when stable, we can change to use e.kind() == std::io::ErrorKind::IsADirectory
484485 let is_directory = if let Some ( last_char) = path. to_string_lossy ( ) . chars ( ) . last ( ) {
0 commit comments