chutz/chroot-wrapper

EXTRA_MOUNTS in default config file not returned from source_config_file()

lucius-martius opened this issue · 2 comments

If I define EXTRA_MOUNTS by simply uncommenting it in config.bash, where it's declared using declare -A, the filesystems do not get mounted by the script.

The issue is that the scope of EXTRA_MOUNTS ends on return from the source_config_file() function.

I can see multiple solutions:

  1. Change the variable to a global variable in the template (i.e. remove declare -A) like with TMPFS_MOUNTS
  2. Replace the call to source_config_file() with directly sourcing it in main()

For simplicity's sake I'd suggest actually doing both. Point 2 has the added benefit that the program would terminate with an error if the specified config file is not accessible/readable, which currently fails silently. (also, the -C command is currently not documented in the --help message)

If you want I can create a pull-request fixing all of these small problems.

chutz commented

Sure, go ahead and create a pull-request to fix the problems. Appreciate the feedback.

There is still one problem remaining, namely that setting DEFAULT_MOUNTS from the config file can not overwrite the definition from the script, since it's declared read-only.

But I am not sure what the desired result should be.

Either it shouldn't be declared read-only or it shouldn't be in the config-file.