Using the recently stabilized app-alternatives/awk package with USE=mawk causes errors for me when running `/etc/init.d/net.* stop`. I assume this script uses GNU-isms in its awk scripts that don't work with mawk. Ideally, this usage of awk would be changed to be more portable with all of the available awk alternatives. Or, at minimum and less ideally, be changed to use and depend on gawk specifically. Reproducible: Always Steps to Reproduce: 1. Install app-alternatives/awk with USE=mawk 2. Stop a network interface with /etc/init.d/net.IF stop Actual Results: doas /etc/init.d/net.wlp3s0 stop doas (njd@skinny) password: * Bringing down interface wlp3s0 * Stopping wpa_cli on wlp3s0 ... [ ok ] * Stopping wpa_supplicant on wlp3s0 ... [ ok ] awk: line 1: syntax error at or near , Excerpt of the above with debugging enabled: + awk match($0, /^Session ([0-9]+) in tunnel ([0-9]+)$/, ret) {sid=ret[1]; tid=ret[2]} match($0, /^[ ]*interface name: wlp3s0$/) {print "session_id="sid";tunnel_id="tid; exit} awk: line 1: syntax error at or near , Expected Results: No awk syntax error when using /etc/init.d/net.* Portage 3.0.41 (python 3.10.9-final-0, default/linux/amd64/17.0/musl, gcc-11, musl-1.2.3, 5.15.75-gentoo-x86_64 x86_64) ================================================================= System uname: Linux-5.15.75-gentoo-x86_64-x86_64-Intel-R-_Core-TM-_i5-4250U_CPU_@_1.30GHz-with-libc KiB Mem: 3962708 total, 1162168 free KiB Swap: 4194300 total, 3892540 free Timestamp of repository gentoo: Sat, 07 Jan 2023 19:00:01 +0000 Head commit of repository gentoo: 9f99545b58408a567eb46121d78691a6bc9012bb Timestamp of repository musl: Sat, 07 Jan 2023 15:02:27 +0000 Head commit of repository musl: 42a5e42b14ae5bfab8e2729b6e1f6948f3379dfd sh dash 0.5.11.5 ld GNU ld (Gentoo 2.39 p5) 2.39.0 app-misc/pax-utils: 1.3.5::gentoo app-shells/bash: 5.1_p16-r2::gentoo dev-lang/perl: 5.36.0-r1::gentoo dev-lang/python: 3.10.9::gentoo, 3.11.1::gentoo dev-lang/rust: 1.65.0::gentoo dev-util/cmake: 3.24.3::gentoo dev-util/meson: 0.64.1::gentoo sys-apps/baselayout: 2.9::gentoo sys-apps/openrc: 0.45.2-r2::gentoo sys-apps/sandbox: 2.29::gentoo sys-devel/autoconf: 2.13-r7::gentoo, 2.71-r5::gentoo sys-devel/automake: 1.16.5::gentoo sys-devel/binutils: 2.39-r4::gentoo sys-devel/binutils-config: 5.4.1::gentoo sys-devel/clang: 15.0.6-r1::gentoo sys-devel/gcc: 11.3.1_p20221209::gentoo sys-devel/gcc-config: 2.8::gentoo sys-devel/libtool: 2.4.7::gentoo sys-devel/lld: 15.0.6::gentoo sys-devel/llvm: 15.0.6-r1::gentoo sys-devel/make: 4.3::gentoo sys-kernel/linux-headers: 5.15-r3::gentoo (virtual/os-headers) sys-libs/musl: 1.2.3::gentoo Repositories: gentoo location: /var/db/repos/gentoo sync-type: rsync sync-uri: rsync://rsync.gentoo.org/gentoo-portage priority: -1000 sync-rsync-verify-max-age: 24 sync-rsync-verify-jobs: 1 sync-rsync-verify-metamanifest: yes sync-rsync-extra-opts: --new-compress musl location: /var/db/repos/musl sync-type: git sync-uri: https://github.com/gentoo-mirror/musl.git masters: gentoo njd location: /var/db/repos/njd masters: gentoo ACCEPT_KEYWORDS="amd64" ACCEPT_LICENSE="*" AR="llvm-ar" CBUILD="x86_64-gentoo-linux-musl" CC="clang" CFLAGS="-march=haswell -O2 -pipe -fomit-frame-pointer" CHOST="x86_64-gentoo-linux-musl" CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt" CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo" CXX="clang++" CXXFLAGS="-march=haswell -O2 -pipe -fomit-frame-pointer" DISTDIR="/var/cache/distfiles" ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GDK_PIXBUF_MODULE_FILE GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME" FCFLAGS="-march=haswell -O2 -pipe -fomit-frame-pointer" FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs buildpkg-live config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr" FFLAGS="-march=haswell -O2 -pipe -fomit-frame-pointer" GENTOO_MIRRORS="http://distfiles.gentoo.org" INSTALL_MASK="charset.alias /usr/share/locale/locale.alias" LANG="en_CA.UTF-8" LDFLAGS="-Wl,--as-needed" LEX="reflex" MAKEOPTS="-j2" NM="llvm-nm" PKGDIR="/var/cache/binpkgs" PORTAGE_CONFIGROOT="/" PORTAGE_RSYNC_EXTRA_OPTS="--new-compress" PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git" PORTAGE_TMPDIR="/var/tmp" RANLIB="llvm-ranlib" RUSTFLAGS="-C target-cpu=haswell" SHELL="/bin/zsh" USE="acl alsa amd64 bluetooth brotli bzip2 clang cli colord crypt cxx dbus dri elogind exif fdk ffmpeg flac fortran gif gles2 gles2-only gles3 gstreamer heif iconv icu idn ipv6 jpeg jpeg2k lcms libaom libedit libglvnd libsamplerate libtirpc lvm lz4 lzma lzo magic mp3 ncurses nls nptl ogg openmp opus pam pcre png pulseaudio readline seccomp sndfile speex split-usr ssl svg test-rust theora tiff truetype udev unicode v4l vaapi vim-syntax vorbis vpx vulkan wayland webp x264 x265 xattr xvid xxhash zip zlib zstd" ABI_X86="64" ADA_TARGET="gnat_2021" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="abm acpi aes aperfmperf apic arat arch_perfmon avx avx2 bmi1 bmi2 bts clflush cmov constant_tsc cpuid cpuid_fault cx16 cx8 de ds_cpl dtes64 dtherm dts epb ept ept_ad erms est f16c flexpriority flush_l1d fma fma3 fpu fsgsbase fxsr ht ibpb ibrs ida invpcid invpcid_single lahf_lm lm mca mce md_clear mmx mmxext monitor movbe msr mtrr nonstop_tsc nopl nx pae pat pbe pcid pclmulqdq pdcm pdpe1gb pebs pge pln pni popcnt pse pse36 pti pts rdrand rdtscp rep_good sdbg sep smep ss ssbd sse sse2 sse3 sse4_1 sse4_2 ssse3 stibp syscall tm tm2 tpr_shadow tsc tsc_adjust tsc_deadline_timer vme vmx vnmi vpid x2apic xsave xsaveopt xtopology xtpr" ELIBC="musl" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput" KERNEL="linux" L10N="en-CA en" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LLVM_TARGETS="AArch64 BPF WebAssembly X86" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-4 php8-0" POSTGRES_TARGETS="postgres12 postgres13" PYTHON_SINGLE_TARGET="python3_10" PYTHON_TARGETS="python3_10" RUBY_TARGETS="ruby27" USERLAND="GNU" VIDEO_CARDS="intel i965" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq proto steal rawnat logmark ipmark dhcpmac delude chaos account" YACC="byacc" Unset: ADDR2LINE, ARFLAGS, AS, ASFLAGS, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXXFILT, ELFEDIT, EMERGE_DEFAULT_OPTS, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, LC_ALL, LD, LFLAGS, LIBTOOL, LINGUAS, MAKE, MAKEFLAGS, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, READELF, SIZE, STRINGS, STRIP, YFLAGS
Note it's not only about GNU'ism when mawk is involved, app-alternatives/awk has this warning for mawk: # Show the warning on new installs if using mawk, or older installs # if upgrading from < app-alternatives/awk-4[mawk]. if [[ -z ${REPLACING_VERSIONS} || ${SHOW_MAWK_WARNING} -eq 1 || ${HAD_MAWK} -eq 0 ]] && use mawk; then ewarn "mawk (incompletely) implements awk, as it was defined by the now-obsolete" ewarn "POSIX 1003.2 (draft 11.3) specification. It does not fully implement the standard" ewarn "extended regular expression syntax and there are other known issues pertaining to POSIX conformance." fi i.e. does USE=nawk or USE=busybox work fine? Or does only gawk work?
USE=busybox reports no errors. USE=nawk has a similar error to mawk: awk: syntax error at source line 1 context is match($0, /^Session ([0-9]+) in tunnel >>> ([0-9]+)$/, <<< awk: bailing out at source line 1
jkroon, if you use l2tp (I think you do), is there any chance you could share the output of `ip l2tp show session` we know what it's supposed to look like? Thank you!
(In reply to Sam James from comment #3) > jkroon, if you use l2tp (I think you do), is there any chance you could > share the output of `ip l2tp show session` we know what it's supposed to > look like? Also, "show tunnel", if it's not too much trouble. The script will need to refrain from using the three-arg form of match(), at the very least.
Hi, kerberos [10:34:48] ~ # ip l2tp show session RTNETLINK answers: No such file or directory Error talking to the kernel kerberos [10:34:56] ~ # ip l2tp show tunnel RTNETLINK answers: No such file or directory Error talking to the kernel So that's ... interesting to say the least. Perhaps xl2tpd runs all of these from userspace? If someone can provide me a sample config for l2tp from /etc/conf.d/net I can definitely give it a spin for you. This may relate to the errors above: tauri [10:39:51] ~ # gunzip < /proc/config.gz | grep L2TP CONFIG_NETFILTER_XT_MATCH_L2TP=m CONFIG_L2TP=y CONFIG_L2TP_DEBUGFS=y # CONFIG_L2TP_V3 is not set <------ CONFIG_PPPOL2TP=m Sorry for not being much help here.
(In reply to Jaco Kroon from comment #5) ing to the kernel > > So that's ... interesting to say the least. Perhaps xl2tpd runs all of > these from userspace? If someone can provide me a sample config for l2tp > from /etc/conf.d/net I can definitely give it a spin for you. Thanks for trying. I think you're right; iproute2 is to be used to manage the L2TPv3 implementation in the kernel. I'll try to set up some tunnels in that way.
Created attachment 848493 [details, diff] 0001-net-l2tp.sh-Rewrite-to-address-issues-of-POSIX-confo.patch
Created attachment 848495 [details, diff] 0002-net-l2tp.sh-Re-order-function-declarations-and-use-a.patch
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=b6c67a56b566b0a178fc8eb7cac761e0f6521356 commit b6c67a56b566b0a178fc8eb7cac761e0f6521356 Author: Kerin Millar <kfm@plushkava.net> AuthorDate: 2023-01-14 23:04:46 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2023-01-15 01:51:26 +0000 net/l2tp.sh: Re-order function declarations and use a consistent brace style This is how I would initially have submitted it, only I wanted for the initial set of changes to be legible as a unified diff. Signed-off-by: Kerin Millar <kfm@plushkava.net> Bug: https://bugs.gentoo.org/890238 Signed-off-by: Sam James <sam@gentoo.org> net/l2tp.sh | 168 +++++++++++++++++++++++++++++------------------------------- 1 file changed, 82 insertions(+), 86 deletions(-) https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=1601d0dbed5d0373f0e19f90f07612bf60c59184 commit 1601d0dbed5d0373f0e19f90f07612bf60c59184 Author: Kerin Millar <kfm@plushkava.net> AuthorDate: 2023-01-14 22:58:41 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2023-01-15 01:51:20 +0000 net/l2tp.sh: Rewrite to address issues of POSIX conformance (and more besides) Ensure that awk(1) is used portably throughout. Eliminate the use of ${parameter^^} expansion syntax, which is a bashism. Delegate netfirc parameter parsing to xargs(1) and awk(1). The potential for code injection is thus eliminated, to the extent that is currently possible in netifrc. It also eliminates potential issues pertaining to word splitting and unintentional pathname expansion. Add additional sanity checks and increase the rigour of those that exist. For instance, blank values are no longer permitted and the tunnel_id parameter must match that of l2tpsession_*, in the case that l2tptunnel_* is defined. Add additional diagnostic messages while improving the clarity of those that already existed. This is achieved in some instances by being more precise and, in others, through the use of English that exhibits greater formality and consistency. At least one grammatical error was rectified. Simplify and refine the code in terms of both structure and syntax, and greatly reduce the number of (local) variables. As a byproduct, all complaints previously raised by shellcheck have been eliminated, save for the use of local, whose behaviour is not defined by POSIX. I have not attempted to eliminate the use of local because, for now, it continues to be used extensively throughout the netifrc codebase. Honour the exit status value of ip(8) for the "add" and "del" verbs, rather than parse STDERR. Optimise l2tp_post_stop() by refraining from executing ip(8) and awk(8) in the case that the interface cannot be identifed as a virtual one. Further, do not attempt to destroy the tunnels associated with an identified session in the case that the attempt to destroy the session has failed. Signed-off-by: Kerin Millar <kfm@plushkava.net> Bug: https://bugs.gentoo.org/890238 Signed-off-by: Sam James <sam@gentoo.org> net/l2tp.sh | 349 +++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 206 insertions(+), 143 deletions(-)
I do have a tinderbox here where gawk was re-emerged after mawk was emerged, yielding into broken awk symlink: # grep awk task.20230304-140722._world.log [ebuild R ] sys-apps/gawk-5.2.1::gentoo USE="nls readline verify-sig* -mpfr -pma" 0 KiB [nomerge ] app-alternatives/awk-4::gentoo USE="mawk* (split-usr) -busybox -gawk* -nawk" [ebuild N ] sys-apps/mawk-1.3.4_p20230203::gentoo USE="verify-sig" 0 KiB [ebuild R ] app-alternatives/awk-4::gentoo USE="mawk* (split-usr) -busybox -gawk* -nawk" 0 KiB [nomerge ] sys-apps/gawk-5.2.1::gentoo USE="nls readline verify-sig* -mpfr -pma" [ebuild N ] sec-keys/openpgp-keys-gawk-20220407::gentoo 0 KiB >>> Emerging (37 of 179) sec-keys/openpgp-keys-gawk-20220407::gentoo >>> Installing (37 of 179) sec-keys/openpgp-keys-gawk-20220407::gentoo >>> Completed (37 of 179) sec-keys/openpgp-keys-gawk-20220407::gentoo >>> Emerging (101 of 179) app-alternatives/awk-4::gentoo >>> Installing (101 of 179) app-alternatives/awk-4::gentoo >>> Completed (101 of 179) app-alternatives/awk-4::gentoo ./config.status: line 1069: awk: command not found # grep awk /var/log/emerge.log 1677939588: >>> emerge (37 of 179) sec-keys/openpgp-keys-gawk-20220407 to / 1677939588: === (37 of 179) Cleaning (sec-keys/openpgp-keys-gawk-20220407::/var/db/repos/gentoo/sec-keys/openpgp-keys-gawk/openpgp-keys-gawk-20220407.ebuild) 1677939589: === (37 of 179) Compiling/Merging (sec-keys/openpgp-keys-gawk-20220407::/var/db/repos/gentoo/sec-keys/openpgp-keys-gawk/openpgp-keys-gawk-20220407.ebuild) 1677939591: === (37 of 179) Merging (sec-keys/openpgp-keys-gawk-20220407::/var/db/repos/gentoo/sec-keys/openpgp-keys-gawk/openpgp-keys-gawk-20220407.ebuild) 1677939592: >>> AUTOCLEAN: sec-keys/openpgp-keys-gawk:0 1677939593: === (37 of 179) Post-Build Cleaning (sec-keys/openpgp-keys-gawk-20220407::/var/db/repos/gentoo/sec-keys/openpgp-keys-gawk/openpgp-keys-gawk-20220407.ebuild) 1677939593: ::: completed emerge (37 of 179) sec-keys/openpgp-keys-gawk-20220407 to / 1677940719: >>> emerge (101 of 179) app-alternatives/awk-4 to / 1677940719: === (101 of 179) Cleaning (app-alternatives/awk-4::/var/db/repos/gentoo/app-alternatives/awk/awk-4.ebuild) 1677940719: === (101 of 179) Compiling/Merging (app-alternatives/awk-4::/var/db/repos/gentoo/app-alternatives/awk/awk-4.ebuild) 1677940722: === (101 of 179) Merging (app-alternatives/awk-4::/var/db/repos/gentoo/app-alternatives/awk/awk-4.ebuild) 1677940723: >>> AUTOCLEAN: app-alternatives/awk:0 1677940723: === Unmerging... (app-alternatives/awk-4) 1677940724: >>> unmerge success: app-alternatives/awk-4 1677940727: === (101 of 179) Post-Build Cleaning (app-alternatives/awk-4::/var/db/repos/gentoo/app-alternatives/awk/awk-4.ebuild) 1677940727: ::: completed emerge (101 of 179) app-alternatives/awk-4 to / # ls -l /usr/bin/*awk* lrwxrwxrwx 1 root root 4 Mar 4 14:38 /usr/bin/awk -> mawk -rwxr-xr-x 1 root root 671304 Jan 1 17:32 /usr/bin/gawk -rwxr-xr-x 1 root root 6613 Jan 1 17:32 /usr/bin/gawkbug (image 17.1_systemd-j5-20230304-130004)
toralf: could you file another bug for that? Thanks!
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=04e95bd55dcb4d638c5b8814c994904308926598 commit 04e95bd55dcb4d638c5b8814c994904308926598 Author: Sam James <sam@gentoo.org> AuthorDate: 2023-04-17 04:39:50 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2023-04-17 04:41:25 +0000 net-misc/netifrc: add 0.7.4 Closes: https://bugs.gentoo.org/904422 Closes: https://bugs.gentoo.org/893290 Closes: https://bugs.gentoo.org/890238 Closes: https://bugs.gentoo.org/889922 Signed-off-by: Sam James <sam@gentoo.org> net-misc/netifrc/Manifest | 1 + net-misc/netifrc/netifrc-0.7.4.ebuild | 74 +++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+)