FreeBSD tftpd и tftp-hpa

FreeBSD v13 9.1-RELEASE

Исправили параметры при запуске и перестартовали сервис inetd:

[[email protected] /]# cat /etc/inetd.conf | grep tftp
tftp    dgram   udp     wait    root    /usr/libexec/tftpd      tftpd -ldw -s /var/tftp

Пробуем от клиента 192.168.112.36 отправить файл 888.cfg:

[[email protected] /]# tail -f /var/log/xferlog
Oct  6 14:42:50 v13 tftpd[5533]: Filename: '888.cfg'
Oct  6 14:42:50 v13 tftpd[5533]: Mode: 'octet'
Oct  6 14:42:50 v13 tftpd[5533]: 192.168.112.36: write request for 888.cfg: error 102
Oct  6 14:42:55 v13 tftpd[5533]: Timeout #0 on DATA block 1

Не заработало! По сообщениям об ошибке ничего толкового найти не смог.

Ставлю /usr/ports/ftp/tftp-hpa
Далее конфигурим по инструкции из интернета.

[[email protected] /]# pw groupadd tftpd
[[email protected] /]# pw useradd tftpd -c tftp_manager -d /nonexistent -g tftpd -s /usr/sbin/nologin
[[email protected] /]# chown tftpd:tftpd /var/tftp
[[email protected] /]# chmod 750 /var/tftp
[[email protected] /]# touch /usr/local/etc/tftpd-remap.conf
[[email protected] /]# chmod 440 /usr/local/etc/tftpd-remap.conf
[[email protected] /]# chown tftpd:tftpd /usr/local/etc/tftpd-remap.conf

Скрипт запуска /usr/local/etc/rc.d/tftpd (.sh) после make install уже был. По инструкции его раньше делали с нуля:

 
[[email protected] /] touch /usr/local/etc/rc.d/tftpd
[[email protected] /] chmod +x /usr/local/etc/rc.d/tftpd
[[email protected] /]# cat /usr/local/etc/tftpd-remap.conf
# Rename all files
# If WRQ: filename -> IP-filename
# If RRQ: IP-filename -> filename

# Полученные файлы будут переименовываться в -<имя файла>
r .* \i-\0
[[email protected] /]# cat /usr/local/etc/rc.d/tftpd
#!/bin/sh
#
# tftp-hpa init script
# Copyright ╘ 2006 by Alexey Tsvetnov, [email protected]
#
# PROVIDE: tftpd
# REQUIRE: DAEMON
# BEFORE: LOGIN
# KEYWORD: shutdown
#
# Define these tftpd_* variables in one of these files:
#       /etc/rc.conf
#       /etc/rc.conf.local
#       /etc/rc.conf.d/tftpd
#
# tftpd_enable (bool):          Set it to "YES" to enable tftpd.
#                                           Default is "NO"
# tftpd_pidfile (path):           Set full path to tftpd.pid.
#                                           Default is /var/run/tftpd.pid
# tftpd_remapfile (path):      Set full path to remap file.
#                                           Default is /usr/local/etc/tftpd-remap.conf
# tftpd_datadir (path):         Set full path to directory with data.
#                                           Default is /var/tftp
# tftpd_flags (str):                Extra flags passed to start command.
#                                           Default is "-cps -u tftpd -U 037 -B 14682"
#

. /etc/rc.subr

name="tftpd"
rcvar=tftd_enable

load_rc_config $name

# DO NOT CHANGE THESE DEFAULT VALUES HERE

: ${tftpd_enable="NO"}
: ${tftpd_pidfile="/var/run/tftpd.pid"}
: ${tftpd_remapfile="/usr/local/etc/tftpd-remap.conf"}
: ${tftpd_datadir="/var/tftp"}
: ${tftpd_flags="-vcps -u tftpd -U 037 -B 1468"}

extra_commands="reload"
start_cmd="tftpd_start"
stop_postcmd="tftpd_poststop"
reload_cmd="tftpd_reload"
required_files="/usr/local/etc/tftpd-remap.conf"
pidfile=$tftpd_pidfile
procname="/usr/local/libexec/in.tftpd"

tftpd_start() {
      /bin/echo -n "Starting tftpd"
      /usr/local/libexec/in.tftpd $tftpd_flags -l -m $tftpd_remapfile $tftpd_datadir
      /bin/ps x | /usr/bin/grep in.tftpd | /usr/bin/grep -v grep | /usr/bin/awk '{print $1}' > $tftpd_pidfile
      /bin/echo "."
}

tftpd_poststop() {
    /bin/rm -f $tftpd_pidfile
}

tftpd_reload() {
    /bin/kill -1 `cat $tftpd_pidfile`
}

run_rc_command "$1"

[[email protected] /]# cat /etc/rc.conf | grep tftp
tftpd_enable="YES"
tftpd_flags="--ipv4 -vcps -u tftpd -U 037 -B 1468"

Стартуем:

[[email protected] /]# /usr/local/etc//rc.d/tftpd start
Starting tftpd.

Проверяем:

[[email protected] /]# ps -ax | grep tftpd
 8641 ??  Is       0:00.00 /usr/local/libexec/in.tftpd --ipv4 -vcps -u tftpd -U 037 -B 1468 -l -m /usr/local/etc/tftpd-remap.conf /var/tftp
 8649  0  S+       0:00.00 grep tftpd

[[email protected] /]# sockstat | grep 69
root     in.tftpd   8641  4  udp4   *:69                  *:*

Загрузаем файл 555.cfg c хоста 192.168.112.36:

[[email protected] /]# tail -f /var/log/xferlog
Oct  6 16:56:40 v13 in.tftpd[8676]: WRQ from 192.168.112.36 filename 555.cfg remapped to 192.168.112.36-555.cfg

После этого заккоментарил строку /usr/local/etc/tftpd-remap.conf
Загрузаем файл 555.cfg c хоста 192.168.112.36 повторно:

[[email protected] /]# tail -f /var/log/xferlog
Oct  6 17:22:38 v13 in.tftpd[8937]: WRQ from 192.168.112.36 filename 555.cfg

Теперь так как нужно. Вопрос закрыт.