OpenWrt application lost permissions after ifup executed

I don't understand what is happened after "ifup" command executed. I try to logging to the remote host like this:

/sbin/logread -f -h client1 -r 514 -p /var/run/ -u

It works fine and I can see log messages on the remote host. But only till "ifup" command executed (or network service restarted). After that I get this behavior of a logread:

root@client1:~# /sbin/logread -f -h client1 -r 514 -p /var/run/ -u
failed to connect: Permission denied
failed to connect: Permission denied
failed to connect: Permission denied
failed to connect: Permission denied
failed to connect: Permission denied

It's not a firewall problem, I stop it by '/etc/init.d/firewall stop'. If I send log message manually by nc -u 514 it works.
What's the problem can be?

you cannot send ip traffic while an adapter is down

does a ping stream result in no lost packets / delays to the same ip with the same commands?
does nc work while running equivalent commands in another terminal ( ifup / restart )?

if so, then you might assume that logread ( to a remote destination ) has little or no error handling ( send fail -> buffer -> flush )

Yes, all adapters are needed have a state "up" after network changed. Remote host is "up" too and openwrt system has ip-connectivity to them (vie ping, ssh etc).
I can start "nc" anywere -- at the another terminal, at the same terminal -- all it work. I even do not stop "nc" before "ifup" command -- it works too.

It seems like logread use "something" (socket, device what ever) which permissions change after network state change. And this "something" changing is a reason of the problem.

How can I catch that "something"?

you can run strace before logread....

but... it's the socket/network... and it's normal behavior.... it "loses permissions" ( cannot write ) because the socket is not there.... ( or it is blocked from doing so by netifd/ubus )

"unable to send log message network is down"... simple

you may wish to use another logging program if you need more functionality....

Well I tested rsyslog instead of logread and it works as expected. I will use rsyslog.

1 Like

If your problem is solved, please consider marking this topic as [Solved]. See How to mark a topic as [Solved] for a short how-to.

I had the same problem:
"failed to connect: Permission denied"
when IPv6 was disabled on loopback interface (build 21.02.1)

Thank you! This was exactly the problem!

strace output:

connect(8, {sa_family=AF_INET6, sin6_port=htons(65535), sin6_flowinfo=htonl(0), inet_pton(AF_INET6, "::1", &sin6_addr), sin6_scope_id=0}, 28) = -1 EACCES (Permission denied)
close(8)                                = 0
writev(2, [{iov_base="failed to connect: Permission de"..., iov_len=37}, {iov_base=NULL, iov_len=0}], 2failed to connect: Permission denied
) = 37

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.