Show HN: A library to add a command promp (and telnet) to your programs
github.com
github.com
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.
The reason I keep hammering on about time sharing is because they largely came hand in hand, time sharing systems needed to support multi-tasking whereas single user systems didn't (you still see echoes of this in the 80s with CP/M, DOS and 8-bit micros running BASIC). In fact if you look at the history of multi-tasking it roughly follows the same time line and lineage as the uptake of time sharing systems (around mid '60s IIRC). Before then you'd have to stop the execution of one program before you could start execution on another.
I know some "LISPians" like to think everything in computing eventually leads back to LISP but that's not always the case (and I say that as a big fan of the language myself).
Lisp also has the idea of break loops, which halt the current execution (for example triggered by some kind of interrupt), allow interaction with the program state and then let one continue the program in some way. Thus one would not need to attach a debugger I/O loop from another process, but the debugger repl would be a part of the running program and could be called on demand.
That you 'know some "LISPians" like to think everything in computing eventually leads back to LISP but that's not always the case' doesn't invalidate the fact that Lisp systems were running on many of the early computers & operating systems from 1960 onwards and followed their evolution. Thus at least some interesting stuff has been done very early in Lisp, too.
Pre-time sharing systems weren't multi-terminal. Hence why I keep coming back to time sharing.
Also your main loop example could be done in assembly, FORTRAN, BASIC, Pascal and C, two of which also pre-date LISP. There's nothing uniquely LISP about writing a polling loop.
Job control et al and multi-terminal mainframes are something very much born out of time sharing. You could use LISP to write your application that would run atop of that time sharing system if you wanted but you could also write that same application in a bunch of other languages too (assuming you had a compiler for that machine). And bare in mind around this time you could still physically inspect the state of paused program on a fair amount of single process systems (and those you couldn't would often punch out verbose log of its running state to tape).
> An early (mid 60s) application domain
By the mid 60s you had time sharing systems. Your argument was that LISP was doing this before then.
> That you 'know some "LISPians" like to think everything in computing eventually leads back to LISP but that's not always the case' doesn't invalidate the fact that Lisp systems were running on many of the early computers & operating systems from 1960 onwards and followed their evolution. Thus at least some interesting stuff has been done very early in Lisp, too.
I completely agree but you're attributing credit to LISP for something that isn't a language-specific feature. At least the OP was referencing a computing platform.
Anyway, this whole conversation was ridiculous from the outset and a massive distraction to the submission that sparked it. It doesn't really matter what came first; the only reason I even commented was to illustrate that we're all standing on the shoulders of giants so it's pointless mocking a submission for being similar in design to tech that pre-dates it. It's ironic that post lead to an argument about what came first.
'Could' is the word. My example was that it was actually done to have built-in command loops and the building blocks for those (so that they could be used in programs), which could be invoked on demand while a program was running.
> it's pointless mocking a submission for being similar in design
I'm not mocking the submission. The feature is quite valuable and interacting with running software via command loops is great.
Ok, "was" then. Operating systems were originally written in assembly and you can't write an operating system without some kind of hardware polling and command loops (even in the days before multi-tasking systems).
Even earlier computers in the days before operating systems would have command loops written in giant rings of punched sheets that would slowly spin round on reels like a cambelt. So this isn't even an innovation that was born from assembly, let alone any high level language.
I honestly do get what you're saying and I'm not trying to dismiss your point that people did this kind of stuff in LISP but what you need to understand is that people did this in a great number of different ways, in different languages and even mechanically too.
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.