82 points · by buserror · 6y ago · 60 comments
Otherwise, this becomes yet another thing to disable upon deployment, chances are people will forget they used this during development and production code will get deployed without the variable to disable telnet.
Demo is in C, but it shouldnt be too hard to add bindings for other languages.
This is very fresh paint, it had a demo of "one" in one of my other program, so I do expect the odd issue!
Someone should write a patch to fix that. There is no reason why the telnet protocol can't be used over UNIX domain sockets.
As you note, telnet has some advantages over socat/netcat/etc, e.g. the Negotiate About Window Size (NAWS) option can be used to notify terminal resize events (SIGWINCH).
One could also register and implement a telnet authentication type [1] to trigger authentication via SCM_CREDENTIALS. The server could use this to confirm the client has the expected UID/GID.
[1] https://www.iana.org/assignments/telnet-options/telnet-optio...
sudo busybox telnetd -b local:/telnetd.sock
busybox telnet local:/telnetd.sock
Then you can log in over telnet over Unix domain socket.
HOWEVER, this only works if busybox is built with CONFIG_FEATURE_UNIX_LOCAL=y. And normally, busybox isn't built with that enabled. It is one of the few features which "make defconfig" doesn't enable.
I wonder if busybox devs could be convinced to change defconfig to set CONFIG_FEATURE_UNIX_LOCAL=y? Their FAQ [1] says defconfig "enables all functionality except special purpose things like selinux or debugging support which would reduce the portability of the resulting binary". I don't think AF_UNIX/AF_LOCAL is really a "special purpose thing". (CONFIG_FEATURE_UNIX_LOCAL turns on AF_UNIX support for all relevant busybox networking commands, it isn't telnet specific.)
Of course, their telnet client doesn't support my SCM_CREDENTIALS as a telnet auth option idea either. The busybox code is reasonably clean so it wouldn't be hard to add it to their telnet client, even their telnetd just for testing (can't say the same for netkit-telnet, which is default telnet client/server on Debian/Ubuntu). Not sure if the busybox developers would be willing to accept such a random feature though.
PS: telnet/telnetd in Alpine Linux are compiled with CONFIG_FEATURE_UNIX_LOCAL=y. However, the default busybox in Alpine 3.7 and above doesn't include telnet/telnetd. You can install them though with "apk add busybox-extras"
PPS: on macOS, Homebrew's telnet also supports telnet to Unix domain sockets, e.g. telnet /tmp/telnetd.sock.
https://github.com/FRRouting/frr/blob/master/doc/developer/c...
https://github.com/FRRouting/frr/blob/master/lib/command.c (+ other files nearby)
looks like this:
DEFUN (show_version,
show_version_cmd,
"show version",
SHOW_STR
"Displays zebra version\n")
{ ... }
install_element(VIEW_NODE, &show_version_cmd);
self-registering commands (__attribute__((constructor))) are on the TODO list.On the other hand we have automatic parameter parsing into proper C types (look for "DEFPY" in the code/docs.)
disclaimer: I conceived and implemented DEFPY.
But that doesn't mean there isn't still value in someone writing a new library and sharing it with the community.
Time sharing systems also pre-date UNIX and Multics, which is why I exampled them as being operating systems that use the time sharing metaphor.
Adding a library such as this one, I could also enhance to alter queued up songs.
MISH_CMD_NAMES(set, "set");
MISH_CMD_HELP(set,
"set 'cnt' variable",
"test command for libmish!");
MISH_CMD_REGISTER(set, _test_set_cnt);
Should be MISH_CMD(set,
_test_set_cnt,
"set 'cnt' variable",
"test command for libmish!")
Which can expand as needed.This is very clever.. in my CLI I use a dedicated section to build a command table, but the linker script often has to be modified for this to work. The above avoids the need to change the linker script at all (but you do need an init function, which I don't..). It means you have to compile as C++, right?
(disclosure, I'm on the dev team)
Now just need a small wrapper around ptrace to inject the library and call mish_prepare(0), so can just dynamically add it as needed to running programs.
Or if it is more widely applicable then how would it work with non-C programs?
So we have COM, WCF, AppleScript/OSA, heck, we used to use two connections with FTP. One data, one control.
Nevertheless. it's nice if it's easily implementable.