initial commit of file from CVS for smeserver-tftp-server on Sat Sep 7 21:08:06 AEST 2024

This commit is contained in:
Trevor Batley
2024-09-07 21:08:06 +10:00
parent 2e9f176f5e
commit dd2326f8b1
27 changed files with 522 additions and 2 deletions

View File

@@ -0,0 +1 @@
69

View File

@@ -0,0 +1 @@
private

View File

@@ -0,0 +1 @@
/tftpboot

View File

@@ -0,0 +1 @@
normal

View File

@@ -0,0 +1 @@
ro

View File

@@ -0,0 +1 @@
disabled

View File

@@ -0,0 +1 @@
default

View File

@@ -0,0 +1 @@
service

View File

@@ -0,0 +1 @@
nobody

View File

@@ -0,0 +1,7 @@
{
my $tftpd = $DB->get('tftpd') or return;
if ( $tftpd->prop('privilege') eq "r" )
{
$tftpd->set_prop('privilege' => "ro");
}
}

View File

@@ -0,0 +1,7 @@
{
my $tftpd = $DB->get('tftpd') or return;
if ( $tftpd->prop('timeout') eq "normal" )
{
$tftpd->set_prop('timeout' => "default");
}
}

View File

@@ -0,0 +1,7 @@
{
my $tftpd = $DB->get('tftpd') or return;
if ( $tftpd->prop('user') eq "root" )
{
$tftpd->set_prop('user' => "nobody");
}
}

View File

@@ -0,0 +1,10 @@
{
my $tftpd = $DB->get("tftpd") or return;
my $tftp = $DB->get("tftp") ||
$DB->new_record("tftp", { type => "service" });
$tftp->merge_props($tftpd->props);
$tftpd->delete;
}

View File

@@ -0,0 +1,3 @@
{
$DB->hosts_allow_spec('tftp', 'in.tftpd');
}

View File

@@ -0,0 +1,7 @@
[Unit]
Description=Tftp Server
Requires=tftp.socket
Documentation=man:in.tftpd
After=network-online.target
Wants=network-online.target

View File

@@ -0,0 +1,50 @@
{
my $blocksize = $tftp{blocksize} || "1468";
my $verbosity = "-v";
my $log = $tftp{log};
my $refuse = $tftp{refuse};
my $privilege = $tftp{privilege} || "";
my $user = $tftp{user} || "";
# Now only relevant if you run under xinetd
my $timeout = $tftp{timeout} || "";
if ( $log eq "verbose" ) {
$verbosity = "-vv";
}
elsif ( $log eq "disabled" ) {
$verbosity = "";
}
if ( $refuse ne "" ) {
$refuse = "-r $refuse";
}
if ( $blocksize <= "512" ) {
$blocksize = "512";
}
elsif ( $blocksize >= "65464" ) {
$blocksize = "65464";
}
if ( $privilege eq "rw" ) {
$privilege = "-c";
} elsif ($privilege = "ro" ) {
$privilege = "";
}
if ( $user ne "" ) {
$user = "-u $user";
}
$OUT .= "\n";
$OUT .= "[Service]\n";
$OUT .= "# Options: man in.tftpd\n";
$OUT .= "# ExecStartPre=/bin/sleep 10\n";
$OUT .= " \n";
$OUT .= "ExecStart=\n";
$OUT .= "ExecStart=/usr/sbin/in.tftpd -s /tftpboot $verbosity -B $blocksize $user $refuse $privilege\n";
$OUT .= " \n";
$OUT .= "StandardInput=socket\n";
}

View File

@@ -0,0 +1,4 @@
[Install]
WantedBy=sme-server.target
Also=tftp.socket

View File

@@ -0,0 +1,21 @@
{
my $interfaceIP = "127.0.0.1";
my $localIP = ${LocalIP};
my $port = $tftp{UDPPort};
my $access = $tftp{access};
if ( $access eq "public" ) {
$interfaceIP = "0.0.0.0";
}
elsif ( $access eq "private" ) {
$interfaceIP = $localIP;
}
$OUT .= "[Socket]\n";
$OUT .= "ListenDatagram=\n";
$OUT .= "ListenDatagram=$interfaceIP:$port\n";
$OUT .= "FreeBind=True\n";
}