While attempting to make use of rc_need="net-online" in netmount (for cifs) and ntp-client an issue was identified. /etc/init.d/net-online: line 47: read: read error: 0: Invalid argument /etc/init.d/net-online: line 48: [: -eq: unary operator expected /sys/class/net/$dev/carrier is unreadable while an interface is down and the associated lines in /etc/init.d/net-online are not tolerant of this causing timeouts. Present code: for dev in ${interfaces}; do : $((ifcount += 1)) read x < /sys/class/net/$dev/carrier [ $x -eq 1 ] && : $((carriers += 1)) read x < /sys/class/net/$dev/operstate [ "$x" = up ] && : $((configured += 1)) Testing code to work around the issue: for dev in ${interfaces}; do : $((ifcount += 1)) #read x < /sys/class/net/$dev/carrier # jrb comment x=0 # jrb added read x < /sys/class/net/$dev/carrier 2> /dev/null # jrb added redirect [ $x -eq 1 ] && : $((carriers += 1)) read x < /sys/class/net/$dev/operstate [ "$x" = up ] && : $((configured += 1))
Hi, pasting changes like this directly into the comments makes it impossible for me to directly add them to the code. I will take a look at these, but In the future, please attach patches instead of inlining the changes.
Created attachment 504960 [details, diff] The solution suggested by jon R-B (converted from jon R-B comment)
Had the same issue and created a PR on the github repo: https://github.com/OpenRC/openrc/pull/189 Improved the fix from jon R-B a bit, as it is not fixing it fully. On the first failing try, the variable x would be assigned the value down from the second check. On a second failing try, the conditional [ $carrier -eq 1 ] will print an error: [: down: integer expression expected
Created attachment 509546 [details, diff] net-online.patch I merged the pull request. However, I would like to know if this works as well. If it does, I would rather test for existance than suppress the errors.
Created attachment 509552 [details, diff] net-online.patch This is the version of the patch you should test; I missed removing a redirection. Thanks, William
Unfortunately, checking for existence (or readability) will not be enough, as even though the file is there and readable from a permission standpoint, it can still return EINVAL. - https://bugzilla.redhat.com/show_bug.cgi?id=1253797 - https://unix.stackexchange.com/questions/252002/help-testing-special-file-in-sys-class-net Best regards
This is fixed upstream and will be included in OpenRC 0.35.