mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-24 07:46:42 +00:00
run/load/tftp: detect bad directory
If a user has e.g. /tftpboot/x86 as directory and configures base_dir=/tftboot and offset_dir=/x86, this leads to bad behavior as the load module creates a symlink /tftpboot/x86/<builddir> -> <absolut_builddir> in this case instead of the desired /tftpboot/x86 -> <absolut_builddir> Furthermore, the module works on /tftpboot/x86/config-00-00-00-00-00-00 and /tftpboot/x86/<builddir>/config-00-00-00-00-00-00 afterwards, which looks bad too. As there is no warning at all, this can be hard to debug. The commit adds an appropriate check with error message and exit -1 on an existing directory. Fixes #1630
This commit is contained in:
parent
4cf319a9d7
commit
b60f28bee9
@ -47,6 +47,14 @@ proc generate_tftp_config { } {
|
|||||||
set tftp_offset_dir [load_tftp_offset_dir]
|
set tftp_offset_dir [load_tftp_offset_dir]
|
||||||
|
|
||||||
if {[string length $tftp_base_dir] > 0 && [string length $tftp_offset_dir] > 0} {
|
if {[string length $tftp_base_dir] > 0 && [string length $tftp_offset_dir] > 0} {
|
||||||
|
|
||||||
|
# if the link target exists as directory this leads to bad behavior
|
||||||
|
if {[file exists $tftp_base_dir$tftp_offset_dir] &&
|
||||||
|
[string compare [file type $tftp_base_dir$tftp_offset_dir] "directory"] == 0} {
|
||||||
|
|
||||||
|
puts stderr "Error: TFTP symlink target $tftp_base_dir$tftp_offset_dir is a directory"
|
||||||
|
exit -1
|
||||||
|
}
|
||||||
exec ln -nfs "[pwd]" "$tftp_base_dir$tftp_offset_dir"
|
exec ln -nfs "[pwd]" "$tftp_base_dir$tftp_offset_dir"
|
||||||
|
|
||||||
set tftp_base ""
|
set tftp_base ""
|
||||||
|
Loading…
Reference in New Issue
Block a user