Arch Linux

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#37756 - [netctl] Profiles fail to start when encountering DOS line endings

Attached to Project: Arch Linux
Opened by Dennis Herbrich (gyroplast) - Wednesday, 13 November 2013, 12:08 GMT
Last edited by Jouke Witteveen (jouke) - Thursday, 14 November 2013, 13:21 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Jouke Witteveen (jouke)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Votes 0
Private No

Details

Description:
When netctl profiles or other sourced files contain DOS line endings, profiles
fail to be brought up, because netctl cannot read the file paths constructed
from the variables with a trailing carriage return.
This patch uses sed to transparently remove any \r at the end of lines in any
'source'd file without altering the original file, thus improving overall
robustness.

Without this fix, the most common failure users encounter will likely be:

Profile 'TEST' does not specify a valid connection

as the globals script attempts to source a file named 'ethernet\r' instead of 'ethernet', since \r is not whitespace by default and as such not trimmed automatically. One may also receive "invalid command '\r$'" on "empty" lines, too, though, and theoretically, hook scripts, interface definitions and basically all other sourced files are affected, too.

Additional info:
* netctl 1.3, also affects 1.4

Patch applies to 1.3, too. Feel free to pull from:
https://github.com/Gyroplast/netctl dos2unix
Patch is based on commit d378bb (1.4 release).

Steps to reproduce:
1. Create a working netctl profile, and verify it comes up properly.
2. Stop this profile.
3. Add DOS line endings to profile definition file: sed -i 's/$/\r/' FILE
4. Try to start profile again
5. Fail miserably and find confusing log message in journalctl

Example:
[root@devvm netctl]# pwd
/etc/netctl
[root@devvm netctl]# pacman -S netctl=1.3
warning: netctl-1.3-1 is up to date -- reinstalling
[SUCCESS]
[root@devvm netctl]# ip -d link show dev usb0
4: usb0: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT qlen 1000
link/ether 00:13:3b:00:75:ff brd ff:ff:ff:ff:ff:ff promiscuity 0
[root@devvm netctl]# cat TEST
Description='A basic static ethernet connection'
Interface=usb0
Connection=ethernet
IP=static
Address=('192.168.1.1/24')
SkipNoCarrier=yes
[root@devvm netctl]# netctl start TEST
[root@devvm netctl]# ip addr show dev usb0
4: usb0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
link/ether 00:13:3b:00:75:ff brd ff:ff:ff:ff:ff:ff
inet 192.168.1.1/24 brd 192.168.1.255 scope global usb0
valid_lft forever preferred_lft forever
[root@devvm netctl]# netctl stop TEST
[root@devvm netctl]# ip addr show dev usb0
4: usb0: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
link/ether 00:13:3b:00:75:ff brd ff:ff:ff:ff:ff:ff
[root@devvm netctl]# ip -d link show dev usb0
4: usb0: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT qlen 1000
link/ether 00:13:3b:00:75:ff brd ff:ff:ff:ff:ff:ff promiscuity 0
[root@devvm netctl]# sed -i 's/$/\r/' TEST
[root@devvm netctl]# od -c TEST
0000000 D e s c r i p t i o n = ' A b
0000020 a s i c s t a t i c e t h e
0000040 r n e t c o n n e c t i o n '
0000060 \r \n I n t e r f a c e = u s b 0
0000100 \r \n C o n n e c t i o n = e t h
0000120 e r n e t \r \n I P = s t a t i c
0000140 \r \n A d d r e s s = ( ' 1 9 2 .
0000160 1 6 8 . 1 . 1 / 2 4 ' ) \r \n S k
0000200 i p N o C a r r i e r = y e s \r
0000220 \n
0000221
[root@devvm netctl]# netctl start TEST
Job for netctl@TEST.service failed. See 'systemctl status netctl@TEST.service' and 'journalctl -xn' for details.
[root@devvm netctl]# journalctl -n 7 -u netctl@TEST
-- Logs begin at Mi 2013-03-06 13:48:04 CET, end at Mi 2013-11-13 13:00:36 CET. --
Nov 13 12:59:46 devvm network[3695]: Stopped network profile 'TEST'
Nov 13 12:59:46 devvm systemd[1]: Stopped Networking for netctl profile TEST.
Nov 13 13:00:36 devvm systemd[1]: Starting Networking for netctl profile TEST...
Nov 13 13:00:36 devvm network[3719]: Profile 'TEST' does not specify a valid connection
Nov 13 13:00:36 devvm systemd[1]: netctl@TEST.service: main process exited, code=exited, status=1/FAILURE
Nov 13 13:00:36 devvm systemd[1]: Failed to start Networking for netctl profile TEST.
Nov 13 13:00:36 devvm systemd[1]: Unit netctl@TEST.service entered failed state.
This task depends upon

Closed by  Jouke Witteveen (jouke)
Thursday, 14 November 2013, 13:21 GMT
Reason for closing:  Won't implement
Additional comments about closing:  Apparently, DOS line endings are syntactically incorrect for netctl configuration files. We just follow bash in this.

Loading...