Bug 1904301 - Following deprecation of tcp_wrappers (libwrap) in services, tcpd needs to be manually configured in systemd... it doesn't work
Summary: Following deprecation of tcp_wrappers (libwrap) in services, tcpd needs to be...
Keywords:
Status: CLOSED WORKSFORME
Alias: None
Product: Fedora
Classification: Fedora
Component: tcp_wrappers
Version: 35
Hardware: x86_64
OS: All
low
low
Target Milestone: ---
Assignee: Jakub Jelen
QA Contact: Fedora Extras Quality Assurance
URL: https://fedoraproject.org/wiki/Change...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-12-04 03:04 UTC by David Hill
Modified: 2023-09-18 00:23 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-12-05 06:37:46 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description David Hill 2020-12-04 03:04:02 UTC
Description of problem:
Following deprecation of tcp_wrappers (libwrap) in services, tcpd needs to be manually configured in systemd... it doesn't work.

Well the following doesn't work:

https://fedoraproject.org/wiki/Changes/Deprecate_TCP_wrappers#:~:text=Fedora%2028%20removes%20support%20for,rules%20for%20more%20complex%20filtering.

We get a bunch of errors like this:
Dec  3 21:53:08 zappa tcpd[6580]: getpeername: Socket operation on non-socket
Dec  3 21:53:16 zappa tcpd[6597]: warning: can't get client address: Socket operation on non-socket
Dec  3 21:53:16 zappa tcpd[6597]: getpeername: Socket operation on non-socket
Dec  3 21:54:03 zappa tcpd[6670]: warning: can't get client address: Socket operation on non-socket
Dec  3 21:54:03 zappa tcpd[6670]: getpeername: Socket operation on non-socket
Dec  3 21:54:50 zappa tcpd[6743]: warning: can't get client address: Socket operation on non-socket
Dec  3 21:54:50 zappa tcpd[6743]: getpeername: Socket operation on non-socket
Dec  3 21:55:38 zappa tcpd[6992]: warning: can't get client address: Socket operation on non-socket
Dec  3 21:55:38 zappa tcpd[6992]: getpeername: Socket operation on non-socket


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 3 Peter Bieringer 2020-12-04 06:45:04 UTC
I'm also very unhappy dropping libwrap support (hit me on EL8), especially because there is no real simple-to-use replacement mechanism for some features, which offers at least some basic protection like:
- ACL based on DNS reverse lookup (usually, attackers don't know which domains are whitelisted...)
- Script-based accept/deny like "ipfilter.sh"

My current "ugly" workaround is using xinetd as relay and reconnect to local running SSH deaemon.

This has btw. the advantage that ssh daemon is reachable on 2 ports:
- base port, protected by firewalld
- add-on-port, protected by libwrap

service PB-sshd-tcpd
{
	id = PB-sshd-tcpd
	socket_type = stream
	port = ****
	type = unlisted
	flags = NAMEINARGS
	server = /usr/sbin/tcpd
	server_args = /bin/nc 127.0.0.1 ****
	protocol = tcp
	user = nobody
	group = nobody
	wait = no
	instances = ***
	per_source = **
	cps = ***
	disable = no
}

Comment 4 David Hill 2020-12-04 13:28:25 UTC
I guess the "*" needs to be replaced by the values we need right ?

Comment 5 Peter Bieringer 2020-12-05 05:53:23 UTC
(In reply to David Hill from comment #4)
> I guess the "*" needs to be replaced by the values we need right ?

Yes, instances, per_source, cps can be overtaken from onther examples
port = 2222 (example)
server_args port usually 22 (in case one has not shifted the default ssh port to something else)

Comment 6 Ben Cotton 2021-02-09 16:21:07 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 34 development cycle.
Changing version to 34.

Comment 7 Ben Cotton 2022-05-12 15:33:27 UTC
This message is a reminder that Fedora Linux 34 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora Linux 34 on 2022-06-07.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
'version' of '34'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, change the 'version' 
to a later Fedora Linux version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora Linux 34 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora Linux, you are encouraged to change the 'version' to a later version
prior to this bug being closed.

Comment 8 Peter Bieringer 2022-05-13 19:39:03 UTC
Documentation in
https://fedoraproject.org/wiki/Changes/Deprecate_TCP_wrappers#:~:text=Fedora%2028%20removes%20support%20for,rules%20for%20more%20complex%20filtering

is slightly incorrect.

Looks like working on F35 using following adjustments:

# create directory for override file
mkdir /etc/systemd/system/sshd@.service.d/

# create overrride file
cat <<'END' >/etc/systemd/system/sshd@.service.d/override.conf
[Service]
ExecStart=
ExecStart=@-/usr/sbin/tcpd /usr/sbin/sshd -i $OPTIONS
END

# Toggle SELinux to allow tcpd to use SSH port
setsebool -p ssh_use_tcpd=1

# systemd reload
systemctl daemon-reload

# restart of SSH socket
systemctl restart sshd.socket


# Test
cat <<END >>/etc/hosts.deny
sshd: 127.0.0.1 [::1]
END

=> ssh localhost should no longer work and logged to /var/log/secure:

grep sshd /var/log/secure | grep refused
May 13 21:31:02 *** sshd[70569]: refused connect from ::1 (::1)
May 13 21:36:31 *** sshd[71326]: refused connect from ::1 (::1)


Can one confirm? If yes, I would try to get the Wiki updated.

Comment 9 Peter Bieringer 2022-05-13 19:45:49 UTC
Even better, checks also whether /usr/sbin/tcpd is installed at all

cat <<'END' >/etc/systemd/system/sshd@.service.d/override.conf
[Unit]
ConditionFileIsExecutable=/usr/sbin/tcpd

[Service]
ExecStart=
ExecStart=@-/usr/sbin/tcpd /usr/sbin/sshd -i $OPTIONS
END

Comment 10 Peter Bieringer 2022-05-14 07:52:43 UTC
Looks like F35 and EL8 using different SSH start options, here a flexible generated:


cat <<'END' >/etc/systemd/system/sshd@.service.d/override.conf
[Unit]
ConditionFileIsExecutable=/usr/sbin/tcpd

[Service]
ExecStart=
END

grep '^ExecStart=' /usr/lib/systemd/system/sshd@.service | sed 's#[^\/]*\(.*\)#ExecStart=@-/usr/sbin/tcpd \1#' >>/etc/systemd/system/sshd@.service.d/override.conf


also a typo needs to be fixed:

setsebool -P ssh_use_tcpd=1

Comment 11 Peter Bieringer 2022-05-14 08:44:00 UTC
Wiki updated: https://fedoraproject.org/wiki/Changes/Deprecate_TCP_wrappers

Comment 12 Ben Cotton 2022-11-29 16:50:52 UTC
This message is a reminder that Fedora Linux 35 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora Linux 35 on 2022-12-13.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
'version' of '35'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, change the 'version' 
to a later Fedora Linux version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora Linux 35 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora Linux, you are encouraged to change the 'version' to a later version
prior to this bug being closed.

Comment 13 Peter Bieringer 2022-12-05 06:37:46 UTC
close now this bug as documentation was updated some time ago.

Comment 15 Red Hat Bugzilla 2023-09-18 00:23:43 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 120 days


Note You need to log in before you can comment on or make changes to this bug.