Michal Sojka [Fri, 22 Oct 2021 12:47:54 +0000 (14:47 +0200)]
Make <<>> fail if it cannot open a file
By default, only a warning is printed and the script continues.
Example of this situation:
% novaboot non-existent --gen-only
novaboot: Read /home/wsh/.config/novaboot
novaboot: Effective options: non-existent --gen-only
Can't open non-existent: No such file or directory at /home/wsh/src/novaboot/novaboot line 362.
We do not add a test for this, because we make all warnings fatal when
running tests.
Michal Sojka [Fri, 22 Oct 2021 12:19:30 +0000 (14:19 +0200)]
Replace <> with <<>>
The reason is that <> can be dangerous. From Perl documentation:
Since the null filehandle uses the two argument form of "open" in
perlfunc it interprets special characters, so if you have a script like
this:
while (<>) {
print;
}
and call it with "perl dangerous.pl 'rm -rfv *|'", it actually opens a
pipe, executes the "rm" command and reads "rm"'s output from that pipe.
If you want all items in @ARGV to be interpreted as file names, you can
use the module "ARGV::readonly" from CPAN, or use the double diamond
bracket:
while (<<>>) {
print;
}
Using double angle brackets inside of a while causes the open to use
the three argument form (with the second argument being "<"), so all
arguments in "ARGV" are treated as literal filenames (including "-").
(Note that for convenience, if you use "<<>>" and if @ARGV is empty, it
will still read from the standard input.)
Michal Sojka [Mon, 28 Jun 2021 06:19:34 +0000 (08:19 +0200)]
shell.nix: Add grub2 and dhcp
This is to allow manual testing of --dhcp-tftp --grub2 functionality.
Currently, I don't have time to fully automate the tests, but this is
how I tested it manually:
1. Create testboot script with the following content:
alberand [Wed, 31 Mar 2021 20:51:58 +0000 (22:51 +0200)]
Create tftpd.pid in default location
This way we restrict the user in commands which he can run under sudo.
It's better to use * wildcard in the pkill command as it doesn't write
anything to the filesystem.
alberand [Wed, 24 Feb 2021 17:16:06 +0000 (18:16 +0100)]
tftpd: Run with mapfile
This mapfile is needed as some pxeclient add zero byte \x00 to the end
of the filename. This is a known bug. The mapfile contains rule to
remove that byte.
Michal Sojka [Mon, 12 Apr 2021 06:26:00 +0000 (08:26 +0200)]
Copy files to TFTP server with default permissions
Previously, we used rsync's --perm option to mirror source permissions
at target. This could have caused the files to be inaccessible by the
TFTP server, because source permissions were to tight. To overcome
this problem, we now always set the target permissions to the default
value by using --chmod. From rsync manual:
To give new files the destination-default permissions (while
leaving existing files unchanged), make sure that the --perms
option is off and use --chmod=ugo=rwX.
Note that this change does not require changes on the server
side (novaboot-shell).
Michal Sojka [Tue, 26 Jan 2021 11:08:46 +0000 (12:08 +0100)]
Add README.md
It is shorter than the current README.pod (man page), to which it
links. In addition to the man page, it contains installation
instructions and links to server-side documentation.
Michal Sojka [Mon, 25 Jan 2021 00:12:08 +0000 (01:12 +0100)]
server: Refactor console setup to a separate function
Also drop exec before the command, because it only causes troubles.
Thanks to dropping exec, we had to change the testsuite, because
without exec it starts a new process, which is not killed by "kill
$COPROC_PID" and since it holds a lock (via flock), we could not run
the following tests.
Michal Sojka [Wed, 20 Nov 2019 22:10:07 +0000 (23:10 +0100)]
tests: Get rid of asynchronous process substitution
Under bash, processes substitution is run asynchronously. This means
that the messages printed by the process can be mixed with other
messages, which causes random tests to fail, because the wvtest
protocol lines are corrupted.
Now we run all processes synchronously and the test no longer fail
randomly.
Jan Kaisrlik [Mon, 4 Nov 2019 16:28:01 +0000 (17:28 +0100)]
Disable echo in default stty arguments
From time to time I observe that the novaboot hangs in the uboot menu
with weird characters on the line like this
=> MC: mmc@7000: 0^M^JLoading Environment from MMC... OK^M^JIn: serial@3000^M^JNet: eth0: ethernet@ff3f0000^M^JHit any key to stop autoboot: 2 ^H^H^H 0^M^J=> MC: mmc@7000: 0^M^JLoading Environment from MMC... OK^M^JIn: serial@3000^M^JNet:
Unknown command 'MC:' - try 'help'
When I tried to play with stty options I realized that the echo option
breaks the communication. The reason is that when echo is
enabled (which is by default), all characters sent by the target are
echoed back to the target, which may interpret them.
It turns out that the problem appears only during the first initial
novaboot conversation with the bootloader after. After switching to
interactive mode, echo is automatically disabled by Expect.pm and for
subsequent boots, echo remains disabled.
[Note: Commit message updated by Michal Sojka based on GitHub
discussion https://github.com/wentasah/novaboot/pull/5 and his
investigation of the issue.]
Michal Sojka [Thu, 31 Oct 2019 22:27:44 +0000 (23:27 +0100)]
server: Always use flock with --no-fork
Without this my test suite fails. The reason for not using --no-fork
was that it didn't work well on some systems. Since I'm annoyed by not
working test suite, I'm willing to investigate --no-fork problems if
they still exist on current Linux systems.