.gear/audit.spec | 490 ++++++++++++++++++++++++++++++++++++++++++++++ .gear/rules | 4 + .gear/tags/list | 1 + .gear/upstream/remotes | 3 + audit.cron | 4 + audit.init | 106 ++++++++++ init.d/auditd.condrestart | 12 +- init.d/auditd.restart | 9 +- init.d/auditd.rotate | 1 - init.d/augenrules | 5 +- src/auditd-listen.c | 18 +- 11 files changed, 634 insertions(+), 19 deletions(-) diff --git a/.gear/audit.spec b/.gear/audit.spec new file mode 100644 index 00000000..5d1c12da --- /dev/null +++ b/.gear/audit.spec @@ -0,0 +1,490 @@ +%define _unpackaged_files_terminate_build 1 +%def_disable static +%def_without bootstrap +%def_with ldap +%def_without prelude + +Name: audit +Version: 3.1.2 +Release: alt2 +Summary: User space tools for Linux kernel 2.6+ auditing +License: GPL +Group: Monitoring +URL: https://people.redhat.com/sgrubb/audit/ +Source: %name-%version.tar +Patch0: %name-%version-alt.patch + +Requires: lib%{name}1 = %EVR +Requires: service >= 0.5.26-alt1 + +%if_without bootstrap +# Automatically added by buildreq on Wed Mar 04 2009 +BuildRequires(pre): rpm-build-python3 +BuildRequires: libkrb5-devel perl-XML-Parser python-devel swig intltool +BuildRequires: python3-devel +BuildRequires: libcap-ng-devel +%endif + +%{?_enable_static:BuildRequires: glibc-devel-static} +%{?_with_prelude:BuildRequires: libprelude-devel} +%{?_with_ldap:BuildRequires: libldap-devel} + +%description +The audit package contains the user space utilities for +storing and searching the audit records generate by +the audit subsystem in the Linux 2.6+ kernel. + +%package -n lib%{name}1 +Summary: Dynamic library for audit framework +License: LGPL +Group: System/Libraries +Provides: lib%name = %EVR +Obsoletes: libaudit = 2.0.4-alt1 + +%description -n lib%{name}1 +This package contains the dynamic libraries needed for +applications to use the audit framework. + +%package -n libauparse0 +Summary: Dynamic library for audit framework +License: LGPL +Group: System/Libraries +Conflicts: lib%name = 2.0.4-alt1 +Conflicts: lib%name < 1.7.16-alt2 + +%description -n libauparse0 +This package contains the dynamic libraries needed for +applications to use the audit framework. + +%package -n lib%name-devel +Summary: Header files and static library for libaudit +License: LGPL +Group: Development/C +Requires: lib%{name}1 = %EVR +Requires: libauparse0 = %EVR + +%description -n lib%name-devel +This package contains the static libraries and header +files needed for developing applications that need to use the audit +framework libraries. + +%package -n python-module-%name +Summary: Python bindings for libaudit +License: LGPL +Group: Development/Python +Requires: lib%{name}1 = %EVR + +%description -n python-module-%name +The python-module-%name package contains the bindings so that libaudit +and libauparse can be used by python. + +%package -n python3-module-%name +Summary: Python3 bindings for libaudit +License: LGPL +Group: Development/Python3 +Requires: lib%{name}1 = %EVR + +%description -n python3-module-%name +The python3-module-%name package contains the bindings so that libaudit +and libauparse can be used by python. + +%prep +%setup +%patch0 -p1 + +%build +%autoreconf + +%configure \ + --sbindir=/sbin \ + --libdir=%_libdir \ + --with-aarch64 \ + --with-arm \ + --with-libcap-ng=auto \ + --without-golang \ + --enable-experimental \ + --with-io_uring \ +%if_with bootstrap + --without-python \ + --without-python3 \ +%else + --enable-gssapi-krb5 \ +%endif + %{?!_with_ldap:--disable-zos-remote} \ + %{subst_enable static} \ + %{subst_with prelude} + +%make_build + +%check +%make check + +%install +%makeinstall_std + +install -d %buildroot%_logdir/%name +install -d %buildroot/%_libdir/%name + +#move shared library to %_lib +install -d %buildroot/%_lib +mv %buildroot/%_libdir/*.so.* %buildroot/%_lib/ +for i in libaudit libauparse;do +LIBNAME=$(readlink %buildroot/%_libdir/$i.so) +ln -sf ../../%_lib/${LIBNAME##*/} %buildroot/%_libdir/$i.so +done + +#replace init script +install -Dpm755 %name.init %buildroot/%_initdir/%{name}d + +#install rotate script +install -Dpm755 %name.cron %buildroot/%_sysconfdir/cron.weekly/%{name}d + +install -pD -m644 init.d/%{name}d.service %buildroot%_unitdir/%{name}d.service +install -pD -m755 init.d/%{name}d.condrestart %buildroot/usr/libexec/service/legacy-actions/%{name}d/condrestart +install -pD -m755 init.d/%{name}d.rotate %buildroot/usr/libexec/service/legacy-actions/%{name}d/rotate +install -pD -m755 init.d/%{name}d.stop %buildroot/usr/libexec/service/legacy-actions/%{name}d/stop +install -pD -m755 init.d/%{name}d.restart %buildroot/usr/libexec/service/legacy-actions/%{name}d/restart +install -pD -m644 rules/10-base-config.rules %buildroot%_sysconfdir/%name/rules.d/10-base-config.rules +install -pD -m755 init.d/%{name}-functions %buildroot/usr/libexec/audit-functions + +%post +%post_service %{name}d +if [ $1 -gt 1 ]; then + service %{name}d condrestart ||: +fi + +%preun +%preun_service %{name}d +if [ $1 -eq 0 ]; then + service %{name}d stop ||: +fi + +%files +%doc README ChangeLog contrib +%config(noreplace) %_sysconfdir/cron.weekly/%{name}d +%config(noreplace) %_sysconfdir/sysconfig/auditd +%_initdir/%{name}d +%attr(700,root,root) %_logdir/%name +%config %_unitdir/%{name}d.service + +/sbin/ausearch +/sbin/aureport +%_bindir/auvirt +%attr(750,root,root) /sbin/auditctl +%attr(750,root,root) /sbin/augenrules +%attr(750,root,root) /sbin/auditd +%attr(750,root,root) /sbin/autrace +%attr(750,root,root) /sbin/audisp-remote +%attr(750,root,root) /sbin/audisp-syslog +%attr(750,root,root) /sbin/audisp-af_unix +%attr(750,root,root) /sbin/audisp-ids +%attr(750,root,root) /sbin/audisp-statsd +%if_with prelude +%attr(750,root,root) /sbin/audisp-prelude +%endif +%if_with ldap +%attr(750,root,root) /sbin/audispd-zos-remote +%endif +%attr(750,root,root) %_bindir/aulastlog +%attr(750,root,root) %_bindir/aulast +%attr(750,root,root) %_bindir/ausyscall + + +%_man5dir/* +%_man8dir/* +%_man7dir/* + +%_datadir/%name/ + +%attr(700,root,root) %dir %_sysconfdir/%name +%config(noreplace) %attr(600,root,root) %_sysconfdir/%name/auditd.conf +%config(noreplace) %attr(600,root,root) %_sysconfdir/%name/audit-stop.rules +%attr(700,root,root) %dir %_sysconfdir/%name/rules.d +%config(noreplace) %attr(600,root,root) %_sysconfdir/%name/rules.d/*.rules + +%attr(700,root,root) %dir %_sysconfdir/audit/plugins.d +%config(noreplace) %attr(640,root,root) /etc/audit/plugins.d/*.conf + +%config(noreplace) %attr(640,root,root) /etc/audit/audisp-remote.conf +%config(noreplace) %attr(640,root,root) /etc/audit/zos-remote.conf +%config(noreplace) %attr(640,root,root) /etc/audit/ids.conf +%config(noreplace) %attr(640,root,root) /etc/audit/audisp-statsd.conf + +%attr(700,root,root) %dir %_libdir/audit +/usr/libexec/service/legacy-actions/%{name}d + +/usr/libexec/audit-functions + +%files -n lib%{name}1 +/%_lib/libaudit.so.* +%config(noreplace) %attr(600,root,root) /etc/libaudit.conf + +%files -n libauparse0 +/%_lib/libauparse.so.* + +%files -n lib%name-devel +%_libdir/*.so +%_includedir/* +%_pkgconfigdir/* +%_man3dir/* +%_aclocaldir/%name.m4 + +%if_without bootstrap +%files -n python-module-%name +%python_sitelibdir/* + +%files -n python3-module-%name +%python3_sitelibdir/* +%endif + +%changelog +* Wed Sep 20 2023 Michael Shigorin 3.1.2-alt2 +- add %%check + +* Fri Aug 11 2023 Egor Ignatov 3.1.2-alt1 +- new version 3.1.2 +- remove swig flexible array workaround (fixed by upstream) + +* Fri Apr 28 2023 Egor Ignatov 3.1.1-alt1 +- new version 3.1.1 + +* Wed Feb 15 2023 Egor Ignatov 3.1-alt1 +- new version 3.1 + +* Tue Aug 30 2022 Egor Ignatov 3.0.9-alt1 +- new version 3.0.9 + +* Fri Apr 01 2022 Egor Ignatov 3.0.8-alt2 +- Make swig flexible array workaround compatible with p10 + +* Wed Mar 30 2022 Egor Ignatov 3.0.8-alt1 +- new version 3.0.8 + +* Tue Mar 22 2022 Egor Ignatov 3.0.7-alt2 +- Fix FTBFS: add flex-array-workaround patch + +* Mon Jan 31 2022 Egor Ignatov 3.0.7-alt1 +- new version 3.0.7 +- Update scripts in init.d +- spec: Build with libcap-ng and krb5 + +* Mon Oct 04 2021 Egor Ignatov 3.0.6-alt1 +- new version 3.0.6 + +* Mon Sep 06 2021 Egor Ignatov 3.0.5-alt2 +- Fix bi-arch check (closes: #40852) +- Add armv8l support +- ausyscall: Add support for 'b32' and 'b64' aliases + +* Fri Aug 13 2021 Egor Ignatov 3.0.5-alt1 +- new version 3.0.5 + +* Sat Jul 17 2021 Egor Ignatov 3.0.3-alt1 +- new version 3.0.3 + +* Tue Jun 22 2021 Egor Ignatov 3.0.2-alt1 +- new version 3.0.2 + +* Fri Feb 19 2021 Egor Ignatov 3.0.1-alt1 +- Update to version 3.0.1 +- Exclude libpthread dependency from libaudit + +* Thu Feb 11 2021 Egor Ignatov 3.0-alt1 +- Update to version 3.0 + +* Tue Oct 06 2020 Anton Farygin 2.8.5-alt5.git.e4021a9 +- enabled ELF mapping for arm and aarch64 processors + +* Mon Jan 27 2020 Aleksei Nikiforov 2.8.5-alt4.git.e4021a9 +- Ported fix from different branch. + +* Fri Jan 24 2020 Aleksei Nikiforov 2.8.5-alt3.git.e4021a9 +- Pulled updates from upstream, including memory leak fixes. + +* Mon Mar 18 2019 Aleksei Nikiforov 2.8.5-alt2 +- Built python-3 bindings. + +* Tue Mar 12 2019 Anton Farygin 2.8.5-alt1 +- 2.8.5 + +* Thu Oct 04 2018 Stanislav Levin 2.8.4-alt2 +- Fixed log's server mode on IPV4 machines. + +* Mon Jun 25 2018 Anton Farygin 2.8.4-alt1 +- 2.8.4 + +* Fri Apr 20 2018 Stanislav Levin 2.8.3-alt3 +- Fix dependency to systemd in post script + +* Wed Apr 18 2018 Stanislav Levin 2.8.3-alt2 +- Make it possible not to limit the restart of a crashed plugin + +* Sat Mar 31 2018 Anton Farygin 2.8.3-alt1 +- new version + +* Fri Jan 26 2018 Anton Farygin 2.8.2-alt1 +- new version +- disabled prelude support (code is outdated and needs to be revised) + +* Sun Oct 15 2017 Anton Farygin 2.8.1-alt1 +- new version + +* Fri Sep 22 2017 Anton Farygin 2.7.8-alt1 +- new version + +* Thu Sep 07 2017 Michael Shigorin 2.7.7-alt2 +- BOOTSTRAP: + + make krb5/ldap/prelude/python support conditional + + make zos-remote plugin build depend on ldap support explicitly + - minor spec cleanup + +* Thu Jun 22 2017 Anton Farygin 2.7.7-alt1 +- new version + +* Mon Apr 24 2017 Anton Farygin 2.7.6-alt1 +- new version + +* Fri Apr 14 2017 Anton Farygin 2.7.5-alt1 +- new version + +* Fri Mar 10 2017 Anton Farygin 2.7.3-alt1 +- new version + +* Thu Feb 16 2017 Anton Farygin 2.7.2-alt1 +- new version + +* Wed Feb 08 2017 Anton Farygin 2.7.1-alt1 +- new version + +* Wed Feb 01 2017 Igor Vlasenko 2.6.7-alt1.1 +- rebuild with libprelude + +* Thu Sep 15 2016 Anton Farygin 2.6.7-alt1 +- new version + +* Tue Jul 19 2016 Anton Farygin 2.6.5-alt1 +- new version + +* Tue May 10 2016 Anton Farygin 2.5.2-alt1 +- new version + +* Thu Jan 14 2016 Anton Farygin 2.5-alt1 +- new version + +* Wed Oct 21 2015 Anton Farygin 2.4.4-alt1 +- new version + +* Tue May 26 2015 Anton Farygin 2.4.2-alt2 +- rebuild for new environment + +* Tue May 19 2015 Anton Farygin 2.4.2-alt1 +- new version + +* Thu Jan 22 2015 Anton Farygin 2.4.1-alt1 +- new version +- added legacy actions scripts (closes: #28931, #27843) + +* Wed Sep 24 2014 Eugeny A. Rostovtsev (REAL) 2.4-alt1.1 +- Rebuilt with new libprelude + +* Mon Sep 08 2014 Anton Farygin 2.4-alt1 +- new version + +* Thu Jun 05 2014 Anton Farygin 2.3.7-alt1 +- new version + +* Mon Apr 14 2014 Anton Farygin 2.3.6-alt1 +- new version + +* Fri Mar 21 2014 Anton Farygin 2.3.5-alt1 +- new version + +* Thu Feb 20 2014 Anton Farygin 2.3.3-alt1 +- new version + +* Mon Oct 07 2013 Anton Farygin 2.3.2-alt1 +- new version + +* Mon Jun 24 2013 Anton Farygin 2.3.1-alt1 +- new version + +* Fri Apr 19 2013 Anton Farygin 2.2.3-alt1 +- new version +- add systemd support + +* Wed Sep 19 2012 Anton Farygin 2.2.1-alt1 +- new version + +* Tue Sep 13 2011 Anton Farygin 2.1.3-alt1 +- new version + +* Fri Feb 25 2011 Anton Farygin 2.0.6-alt1 +- new version + +* Tue Sep 28 2010 Anton Farygin 2.0.5-alt1 +- new version + +* Tue Jul 20 2010 Mikhail Efremov 2.0.4-alt2 +- fix summaries and descriptions. +- package libauparse as separate subpackage libauparse0. +- rename libaudit -> libaudit1. + +* Thu Jul 01 2010 Mikhail Efremov 2.0.4-alt1 +- spec cleanup. +- drop depends on python-module-pygtk-libglade. +- new version + +* Mon Nov 23 2009 Eugeny A. Rostovtsev (REAL) 1.7.16-alt1.1 +- Rebuilt with python 2.6 + +* Mon Nov 16 2009 Anton Farygin 1.7.16-alt1 +- new version + +* Tue Sep 01 2009 Anton Farygin 1.7.13-alt3 +- rebuild with libldap2.4 + +* Sun Aug 09 2009 Anton Farygin 1.7.13-alt2 +- python-dev requires changed to python-devel +- menu entry fixed for system-config-audit + +* Mon Apr 27 2009 Anton Farygin 1.7.13-alt1 +- new version +- fixed build + +* Wed Apr 08 2009 Anton Farygin 1.7.12-alt6 +- added python-module-pygtk-libglade to requires for python-module-audit (#19431) + +* Wed Mar 11 2009 Anton Farygin 1.7.12-alt4 +- service auditd off by default + +* Tue Mar 10 2009 Slava Dubrovskiy 1.7.12-alt3 +- added support of libprelude + +* Wed Mar 04 2009 Anton Farygin 1.7.12-alt2 +- added system-config-audit subpackage with graphical utility for editing audit configuration + +* Wed Mar 04 2009 Anton Farygin 1.7.12-alt1 +- new version + +* Thu Jan 15 2009 Anton Farygin 1.7.11-alt1 +- new version +- subpackage python-module-audit added +- Packager changed + +* Wed Dec 17 2008 Anton Farygin 1.7.10-alt1 +- new version + +* Fri Dec 12 2008 Anton Farygin 1.7.9-alt1 +- new version + +* Tue Sep 23 2008 Stanislav Ievlev 1.7-alt2 +- silent rotate + +* Thu Apr 03 2008 Stanislav Ievlev 1.7-alt1 +- 1.7 + +* Fri Jul 06 2007 Stanislav Ievlev 1.5.4-alt1 +- 1.5.4 + +* Thu May 24 2007 Stanislav Ievlev 1.5.3-alt1 +- Initial release diff --git a/.gear/rules b/.gear/rules new file mode 100644 index 00000000..bfd969bf --- /dev/null +++ b/.gear/rules @@ -0,0 +1,4 @@ +tar: v@version@:. +diff: v@version@:. . name=@name@-@version@-alt.patch +spec: .gear/audit.spec +copy?: .gear/*.patch diff --git a/.gear/tags/list b/.gear/tags/list new file mode 100644 index 00000000..c23a4335 --- /dev/null +++ b/.gear/tags/list @@ -0,0 +1 @@ +572eb7d4fe926e7c1c52166d08e78af54877cbc5 v3.1.2 diff --git a/.gear/upstream/remotes b/.gear/upstream/remotes new file mode 100644 index 00000000..86ef95f3 --- /dev/null +++ b/.gear/upstream/remotes @@ -0,0 +1,3 @@ +[remote "upstream"] + url = https://github.com/linux-audit/audit-userspace.git + fetch = +refs/heads/*:refs/remotes/upstream/* diff --git a/audit.cron b/audit.cron new file mode 100644 index 00000000..91b615e1 --- /dev/null +++ b/audit.cron @@ -0,0 +1,4 @@ +#!/bin/sh + +/sbin/service auditd rotate >/dev/null + diff --git a/audit.init b/audit.init new file mode 100644 index 00000000..78a176ce --- /dev/null +++ b/audit.init @@ -0,0 +1,106 @@ +#!/bin/bash +# +# auditd This starts and stops auditd +# +# chkconfig: - 11 88 +# description: This starts the Linux Auditing System Daemon +# +# processname: /sbin/auditd +# config: /etc/sysconfig/auditd +# config: /etc/audit/auditd.conf +# pidfile: /var/run/auditd.pid + + +WITHOUT_RC_COMPAT=1 + +# Source function library. +. /etc/init.d/functions + +PIDFILE=/var/run/auditd.pid +LOCKFILE=/var/lock/subsys/auditd +RETVAL=0 + +start(){ + start_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user root -- auditd + RETVAL=$? + + #load default rules + [ $RETVAL -eq 0 -a -f /etc/audit/audit.rules ] && auditctl -R /etc/audit/audit.rules >/dev/null + + return $RETVAL +} + +stop(){ + stop_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user root -- auditd + RETVAL=$? + + [ $RETVAL -eq 0 ] && auditctl -D >/dev/null + + return $RETVAL +} + +rotate() +{ + printf "Rotating auditd logs\n" + stop_daemon --pidfile "$PIDFILE" --expect-user root -USR1 -- auditd + RETVAL=$? + return $RETVAL +} + +reload() +{ + msg_reloading auditd + stop_daemon --pidfile "$PIDFILE" --expect-user root -HUP -- auditd + RETVAL=$? + return $RETVAL +} + +restart() +{ + stop + start +} + + +# See how we were called. +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + restart + ;; + reload) + reload + ;; + rotate) + rotate + ;; + condstop) + if [ -e "$LOCKFILE" ]; then + stop + fi + ;; + condreload) + if [ -e "$LOCKFILE" ]; then + reload + fi + ;; + condrestart) + if [ -e "$LOCKFILE" ]; then + restart + fi + ;; + status) + status --pidfile "$PIDFILE" --expect-user root -- auditd + RETVAL=$? + ;; + *) + msg_usage "${0##*/} {rotate|start|stop|reload|restart|condstop|condrestart|condreload|status}" + RETVAL=1 +esac + +exit $RETVAL diff --git a/init.d/auditd.condrestart b/init.d/auditd.condrestart index d86e5e4c..d46f6d35 100644 --- a/init.d/auditd.condrestart +++ b/init.d/auditd.condrestart @@ -2,10 +2,8 @@ # Helper script to provide legacy auditd service options not # directly supported by systemd. -state=`service auditd status | awk '/^ Active/ { print $2 }'` -if [ $state = "active" ] ; then - /usr/libexec/initscripts/legacy-actions/auditd/restart - RETVAL="$?" - exit $RETVAL -fi -exit 0 +RETVAL=1 +start-stop-daemon -p "/var/run/auditd.pid" -u root -K -n auditd -t >/dev/null && \ + [ -x /usr/libexec/service/legacy-actions/auditd/restart ] && /usr/libexec/service/legacy-actions/auditd/restart +RETVAL="$?" +exit $RETVAL diff --git a/init.d/auditd.restart b/init.d/auditd.restart index 42669ff1..d65e7472 100644 --- a/init.d/auditd.restart +++ b/init.d/auditd.restart @@ -2,12 +2,11 @@ # Helper script to provide legacy auditd service options not # directly supported by systemd. -test -f /etc/audit/auditd.conf || exit 6 +test $(id -u) = 0 || exit 4 -/usr/libexec/initscripts/legacy-actions/auditd/stop -sleep 1 -echo "Redirecting start to /bin/systemctl start auditd.service" -/bin/systemctl start auditd.service +/usr/libexec/service/legacy-actions/auditd/stop +echo "Redirecting start to 'service auditd start'" +service auditd start RETVAL="$?" exit $RETVAL diff --git a/init.d/auditd.rotate b/init.d/auditd.rotate index 643b935c..8b1875ce 100644 --- a/init.d/auditd.rotate +++ b/init.d/auditd.rotate @@ -12,5 +12,4 @@ prog="auditd" printf "Rotating logs: " killproc $prog -USR1 RETVAL=$? -echo exit $RETVAL diff --git a/init.d/augenrules b/init.d/augenrules index ea96aa78..1311610c 100644 --- a/init.d/augenrules +++ b/init.d/augenrules @@ -33,6 +33,7 @@ OnlyCheck=0 LoadRules=0 RETVAL=0 usage="Usage: $0 [--check|--load]" +RESTORECON="/sbin/restorecon" # Delete the interim file on faults trap 'rm -f ${TmpRules}; exit 1' 1 2 3 13 15 @@ -128,8 +129,8 @@ fi cp "${TmpRules}" ${DestinationFile} chmod 0640 ${DestinationFile} # Restore context on MLS system. /tmp is SystemLow & audit.rules is SystemHigh -if [ -x /usr/sbin/restorecon ] ; then - /usr/sbin/restorecon -F ${DestinationFile} +if [ -x "${RESTORECON}" ] ; then + "${RESTORECON}" -F ${DestinationFile} fi rm -f "${TmpRules}" diff --git a/src/auditd-listen.c b/src/auditd-listen.c index 171974c0..385d6a38 100644 --- a/src/auditd-listen.c +++ b/src/auditd-listen.c @@ -988,7 +988,6 @@ int auditd_tcp_listen_init(struct ev_loop *loop, struct daemon_conf *config) return 1; } - { int ipv4 = 0, ipv6 = 0; nlsocks = 0; runp = ai; @@ -996,13 +995,24 @@ int auditd_tcp_listen_init(struct ev_loop *loop, struct daemon_conf *config) // Let's take a pass through and see what we got. if (runp->ai_family == AF_INET) ipv4++; - else if (runp->ai_family == AF_INET6) - ipv6++; + else if (runp->ai_family == AF_INET6) { + // check if ipv6 actually presents + int chsock = socket(runp->ai_family, + runp->ai_socktype, runp->ai_protocol); + if (chsock != -1) { + close(chsock); + } else if (errno == EAFNOSUPPORT) { + runp = runp->ai_next; + nlsocks++; + continue; + } + ipv6++; + } runp = runp->ai_next; nlsocks++; } - if (nlsocks == 2 && ipv4 && ipv6) + if (nlsocks == 2 && ipv4 && ipv6) { prefer_ipv6 = 1; }