Skip to content

Commit 969ff24

Browse files
committed
Add CLI flag to opt in to world-readable log files (sigp#3747)
## Issue Addressed sigp#3732 ## Proposed Changes Add a CLI flag to allow users to opt out of the restrictive permissions of the log files. ## Additional Info This is not recommended for most users. The log files can contain sensitive information such as validator indices, public keys and API tokens (see sigp#2438). However some users using a multi-user setup may find this helpful if they understand the risks involved.
1 parent e9bf7f7 commit 969ff24

File tree

7 files changed

+36
-1
lines changed

7 files changed

+36
-1
lines changed

lcli/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,7 @@ fn run<T: EthSpec>(
789789
max_log_size: 0,
790790
max_log_number: 0,
791791
compression: false,
792+
is_restricted: true,
792793
})
793794
.map_err(|e| format!("should start logger: {:?}", e))?
794795
.build()

lighthouse/environment/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ pub struct LoggerConfig {
5555
pub max_log_size: u64,
5656
pub max_log_number: usize,
5757
pub compression: bool,
58+
pub is_restricted: bool,
5859
}
5960
impl Default for LoggerConfig {
6061
fn default() -> Self {
@@ -68,6 +69,7 @@ impl Default for LoggerConfig {
6869
max_log_size: 200,
6970
max_log_number: 5,
7071
compression: false,
72+
is_restricted: true,
7173
}
7274
}
7375
}
@@ -257,7 +259,7 @@ impl<E: EthSpec> EnvironmentBuilder<E> {
257259
.rotate_size(config.max_log_size)
258260
.rotate_keep(config.max_log_number)
259261
.rotate_compress(config.compression)
260-
.restrict_permissions(true)
262+
.restrict_permissions(config.is_restricted)
261263
.build()
262264
.map_err(|e| format!("Unable to build file logger: {}", e))?;
263265

lighthouse/src/main.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,15 @@ fn main() {
129129
to store old logs.")
130130
.global(true),
131131
)
132+
.arg(
133+
Arg::with_name("logfile-no-restricted-perms")
134+
.long("logfile-no-restricted-perms")
135+
.help(
136+
"If present, log files will be generated as world-readable meaning they can be read by \
137+
any user on the machine. Note that logs can often contain sensitive information \
138+
about your validator and so this flag should be used with caution.")
139+
.global(true),
140+
)
132141
.arg(
133142
Arg::with_name("log-format")
134143
.long("log-format")
@@ -407,6 +416,8 @@ fn run<E: EthSpec>(
407416

408417
let logfile_compress = matches.is_present("logfile-compress");
409418

419+
let logfile_restricted = !matches.is_present("logfile-no-restricted-perms");
420+
410421
// Construct the path to the log file.
411422
let mut log_path: Option<PathBuf> = clap_utils::parse_optional(matches, "logfile")?;
412423
if log_path.is_none() {
@@ -446,6 +457,7 @@ fn run<E: EthSpec>(
446457
max_log_size: logfile_max_size * 1_024 * 1_024,
447458
max_log_number: logfile_max_number,
448459
compression: logfile_compress,
460+
is_restricted: logfile_restricted,
449461
};
450462

451463
let builder = environment_builder.initialize_logger(logger_config.clone())?;

lighthouse/tests/beacon_node.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,6 +1548,23 @@ fn enabled_disable_log_timestamp_flag() {
15481548
assert!(config.logger_config.disable_log_timestamp);
15491549
});
15501550
}
1551+
#[test]
1552+
fn logfile_restricted_perms_default() {
1553+
CommandLineTest::new()
1554+
.run_with_zero_port()
1555+
.with_config(|config| {
1556+
assert!(config.logger_config.is_restricted);
1557+
});
1558+
}
1559+
#[test]
1560+
fn logfile_no_restricted_perms_flag() {
1561+
CommandLineTest::new()
1562+
.flag("logfile-no-restricted-perms", None)
1563+
.run_with_zero_port()
1564+
.with_config(|config| {
1565+
assert!(config.logger_config.is_restricted == false);
1566+
});
1567+
}
15511568

15521569
#[test]
15531570
fn sync_eth1_chain_default() {

testing/simulator/src/eth1_sim.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ pub fn run_eth1_sim(matches: &ArgMatches) -> Result<(), String> {
6767
max_log_size: 0,
6868
max_log_number: 0,
6969
compression: false,
70+
is_restricted: true,
7071
})?
7172
.multi_threaded_tokio_runtime()?
7273
.build()?;

testing/simulator/src/no_eth1_sim.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ pub fn run_no_eth1_sim(matches: &ArgMatches) -> Result<(), String> {
5252
max_log_size: 0,
5353
max_log_number: 0,
5454
compression: false,
55+
is_restricted: true,
5556
})?
5657
.multi_threaded_tokio_runtime()?
5758
.build()?;

testing/simulator/src/sync_sim.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ fn syncing_sim(
5656
max_log_size: 0,
5757
max_log_number: 0,
5858
compression: false,
59+
is_restricted: true,
5960
})?
6061
.multi_threaded_tokio_runtime()?
6162
.build()?;

0 commit comments

Comments
 (0)