The code is in the zip above (Tellsv.9.zip) if you want to look at it; use something that syntax highlights perl - I use gedit, but there are a few others that work out there.
If you're on linux, geany and padre should also do.
Tellem seems to need no special privileges at all - it just needs to run on startup and sit in the background - all it does is grab the local host info and broadcast it on UDP every minute or so. I have it read the info every time, since various things might make it change - and the other end handles those changes should they occur.
Tellme, since it writes a root-owned file in the non-world-writeable /etc directory (hosts), needs to be run setuid or as root. I did copy them to usr/bin (writeable only by root itself) with the command line sudo cp tellme /usr/bin (which also makes them root-owned on the fly during the copy) I'm not sure if I needed to cd to /usr/bin and then do chmod 6711 for both, but I did anyway. Tellme is the one that's hard to get going at startup. If the privileges aren't right, it dies the first time it wants to write the hosts file. Which is the first thing it tries to do at this point, just to get one "clean" at first if it wasn't at the last shutdown.
For linux, an acceptable install script would simply be a script in any language you invoked like "sudo install", which would do those copies and chmods for you - could be part of a zip you give people just like the one above, but with another program to put the other 3 files where they belong. To get tellme to really run at startup, and as root, I had to put a .conf file in /etc/init for it, which is in that zip above - this is processed by init (or the newer upstart) at boot time. The same sort of thing with a name change would work for tellem, but isn't required - that one's easy, but it might be cleaner from the user's or sysadmin's pov.
A .deb would be great, but probably overkill in terms of the effort required to make it (dunno, haven't made one myself). At any rate, at some point you need to be root to do some of the required things.
This stuff would probably run on windows if it had perl (there is one available from active state, free) but I don't think windows supports all the posix stuff, though there's certainly a way to not need that there, you just need admin and to be a service (daemon) no matter how you do it, and that's all I use posix for. I do catch some signals to shutdown cleanly, but that's really not a requirement, just being polite. Tellme is set to re-build a raw hosts file on each new startup (via setting $changed to 1 at init), so it doesn't have to shut down clean.
The other possible issue is the format of the usual hosts file, which is hardcoded into the program tellme. That might have to change on some systems (windows, or non-ipv6 linuxes). I have what was the normal hosts format as data in the program as it sits - so I could put the new stuff after the loobacks and before the ipv6 junk, just as the system likes.
Here's what my default hosts file looks like either before installing any of this, or after running awhile with nothing else on the LAN:
- Code: Select all
127.0.0.1 localhost
127.0.1.1 main
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
I hardcode the first two lines, then add whatever between them and the hardcoded ipv6 lines when writing to the file - all kept in one scalar in perl (would be a string in C). That could probably be improved, but every hosts file I've seen on any version of linux here looks like this. Even though I also know the LAN IP of "main" in the tellme of "main" (this machine), I don't add that, since it's slower for main to get to itself that way than via 127.0.1.1 or 127.0.0.1. EG tellme is smart enough to know it's me hearing my own broadcast and not to include that in the hosts file.
Here's what that file looks like a few seconds after turning on two more machines on the LAN:
- Code: Select all
127.0.0.1 localhost
127.0.1.1 main
192.168.1.4 fusor2
192.168.1.12 server
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
Two minutes after turning them off (more or less), the file reverts to the original. That's a hardcoded number of seconds which seemed about right.
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.