rsh vs net/ipcad - problems on 5.5

2014-05-20 Thread viq
I encountered a strange problem when trying to communicate with net/ipcad:

rsh localhost stats
rsh: poll: Undefined error: 0

Same thing on 5.1:
rsh localhost stats
connect to address ::1: Connection refused
Trying 127.0.0.1...
Interface vlan123: received 585816944, 5 m average 313 bytes/sec, 4
pkts/sec, dropped 6078
Flow entries made: 583
Memory usage: 6% (65296 from 1048576)
Free slots for rsh clients: 9
IPCAD uptime is 159 days  7:04
fw.example.com uptime is 159 days  7:04

According to sthen@ this also works fine on 5.4 and he suspects
breakage due to time_t changes. He also provided simple sample config
http://pbot.rmdir.de/iFGRSOehzxnZ1flTJqum5Q because he's awesome like
that ;)

kern.version=OpenBSD 5.5 (GENERIC.MP) #0: Fri Apr 25 13:03:34 CEST 2014

r...@stable-55-amd64.mtier.org:/binpatchng/work-binpatch55-amd64/src/sys/arch/amd64/compile/GENERIC.MP
ipcad-3.7.3p1
-- 
viq



Re: rsh vs net/ipcad - problems on 5.5

2014-05-20 Thread Stuart Henderson
On 2014/05/20 16:41, viq wrote:
 I encountered a strange problem when trying to communicate with net/ipcad:
 
 rsh localhost stats
 rsh: poll: Undefined error: 0
 
 Same thing on 5.1:
 rsh localhost stats
 connect to address ::1: Connection refused
 Trying 127.0.0.1...
 Interface vlan123: received 585816944, 5 m average 313 bytes/sec, 4
 pkts/sec, dropped 6078
 Flow entries made: 583
 Memory usage: 6% (65296 from 1048576)
 Free slots for rsh clients: 9
 IPCAD uptime is 159 days  7:04
 fw.example.com uptime is 159 days  7:04
 
 According to sthen@ this also works fine on 5.4 and he suspects
 breakage due to time_t changes. He also provided simple sample config
 http://pbot.rmdir.de/iFGRSOehzxnZ1flTJqum5Q because he's awesome like
 that ;)
 
 kern.version=OpenBSD 5.5 (GENERIC.MP) #0: Fri Apr 25 13:03:34 CEST 2014
 
 r...@stable-55-amd64.mtier.org:/binpatchng/work-binpatch55-amd64/src/sys/arch/amd64/compile/GENERIC.MP
 ipcad-3.7.3p1
 -- 
 viq
 

Note that ipcad listens on port 514 and provides *its own* cisco-ish
rshell interface that you connect to, this isn't about openbsd rshd.

Sample config inline at the bottom of this mail. (the pastebin above
was just meant for when I was talking about this on irc - it will expire).

The error is coming from /usr/src/usr.bin/rsh/rsh.c:243 and since
nothing changed here in many years, I'm wondering if there's anything
up with poll(2). (If it's a direct bug with rsh, well, that's fixed
a different way in -current)..

230 sigprocmask(SIG_SETMASK, omask, NULL);
231 pfd[1].fd = rfd2;
232 pfd[1].events = POLLIN;
233 pfd[0].fd = rem;
234 pfd[0].events = POLLIN;
235 do {
236 if (poll(pfd, 2, INFTIM)  0) {
237 if (errno != EINTR)
238 err(1, poll);
239 continue;
240 }
241 if ((pfd[0].revents  (POLLERR|POLLHUP|POLLNVAL)) ||
242 (pfd[1].revents  (POLLERR|POLLHUP|POLLNVAL)))
 243  err(1, poll);
244 if (pfd[1].revents  POLLIN) {
245 errno = 0;
246 cc = read(rfd2, buf, sizeof buf);
247 if (cc = 0) {
248 if (errno != EWOULDBLOCK)
249 pfd[1].revents = 0;
250 } else
251 (void)write(STDERR_FILENO, buf, cc);
252 }
253 if (pfd[0].revents  POLLIN) {
254 errno = 0;
255 cc = read(rem, buf, sizeof buf);
256 if (cc = 0) {
257 if (errno != EWOULDBLOCK)
258 pfd[0].revents = 0;
259 } else
260 (void)write(STDOUT_FILENO, buf, cc);
261 }
262 } while ((pfd[0].revents  POLLIN) || (pfd[1].revents  POLLIN));

===
capture-ports disable;
interface em0;
rsh enable at 127.0.0.1;
rsh root@127.0.0.1 admin;
rsh 127.0.0.1;
rsh ttl = 3;
rsh timeout = 30;
dumpfile = ipcad.dump;
chroot = /var/ipcad;
pidfile = ipcad.pid;
memory_limit = 1m;



Re: rsh vs net/ipcad - problems on 5.5

2014-05-20 Thread Philip Guenther
On Tue, May 20, 2014 at 8:29 AM, Stuart Henderson st...@openbsd.org wrote:

 On 2014/05/20 16:41, viq wrote:
  I encountered a strange problem when trying to communicate with
 net/ipcad:
 
  rsh localhost stats
  rsh: poll: Undefined error: 0

...

 Note that ipcad listens on port 514 and provides *its own* cisco-ish
 rshell interface that you connect to, this isn't about openbsd rshd.

 The error is coming from /usr/src/usr.bin/rsh/rsh.c:243 and since
 nothing changed here in many years, I'm wondering if there's anything
 up with poll(2). (If it's a direct bug with rsh, well, that's fixed
 a different way in -current)..

...

 241 if ((pfd[0].revents  (POLLERR|POLLHUP|POLLNVAL)) ||
 242 (pfd[1].revents  (POLLERR|POLLHUP|POLLNVAL)))
  243  err(1, poll);


It's reporting that the second fd, the stderr fd, has been closed by the
other side (POLLHUP).  Does ipcad implement the expected ordering in the
rsh protocol?


Philip Guenther


Re: rsh vs net/ipcad - problems on 5.5

2014-05-20 Thread Stuart Henderson
On 2014/05/20 12:36, Philip Guenther wrote:
 On Tue, May 20, 2014 at 8:29 AM, Stuart Henderson st...@openbsd.org wrote:
 
  On 2014/05/20 16:41, viq wrote:
   I encountered a strange problem when trying to communicate with
  net/ipcad:
  
   rsh localhost stats
   rsh: poll: Undefined error: 0
 
 ...
 
  Note that ipcad listens on port 514 and provides *its own* cisco-ish
  rshell interface that you connect to, this isn't about openbsd rshd.
 
  The error is coming from /usr/src/usr.bin/rsh/rsh.c:243 and since
  nothing changed here in many years, I'm wondering if there's anything
  up with poll(2). (If it's a direct bug with rsh, well, that's fixed
  a different way in -current)..
 
 ...
 
  241 if ((pfd[0].revents  (POLLERR|POLLHUP|POLLNVAL)) ||
  242 (pfd[1].revents  (POLLERR|POLLHUP|POLLNVAL)))
   243  err(1, poll);
 
 
 It's reporting that the second fd, the stderr fd, has been closed by the
 other side (POLLHUP).  Does ipcad implement the expected ordering in the
 rsh protocol?
 
 
 Philip Guenther

Thanks for the cluebat / lesson in rsh :)

Seems it's actually racey, sometimes closing the stderr first, sometimes
closing port 514 first. So no it doesn't ... And rshd works fine,
reinforcing this i.e. seems like an ipcad bug. Still it seems odd
that it stopped working in 5.5 (though not enough for me to spend
longer looking!).

rsh ipcad
54  55  ok
55  54  ok
55  55  fail

Anyway Viq, since rsh has gone away in -current, I suggest looking for
an alternative; there are various things which might be suitable depending
on what you're actually using it for ..

Now to remove my test rshd configs before I forget :-)