Projeto-Pindorama / heirloom-ng

A collection of standard Unix utilities that is intended to provide maximum compatibility with traditional Unix while incorporating additional features necessary today.
http://heirloom-ng.pindorama.net.br
Other
28 stars 7 forks source link

write(1) implementation #47

Closed takusuman closed 1 month ago

takusuman commented 5 months ago

Another one bites the dust.

takusuman commented 5 months ago

There's a small problem with this: on the contrary of wall(1) (see #46), it can read the utmpx database perfectly, but it will not be writing to any terminal since it will always fail on not having the necessary permissions for it, failing here: https://github.com/Projeto-Pindorama/heirloom-ng/blob/ed2c5552b7f76b2813c135be28f3f60c244d7f6b/write/write.c#L121-L122 ... Or here: https://github.com/Projeto-Pindorama/heirloom-ng/blob/ed2c5552b7f76b2813c135be28f3f60c244d7f6b/write/write.c#L126-L127

Interesting at least.

takusuman commented 5 months ago

This code, with all the respect and acknowledgements to the AT&T crew, also looks like a spaghetti. I mean, it looks like that at least two people programmed this in parallel. Still, it looks legible enough.

takusuman commented 5 months ago

... Or here: https://github.com/Projeto-Pindorama/heirloom-ng/blob/ed2c5552b7f76b2813c135be28f3f60c244d7f6b/write/write.c#L126-L127

Funnily enough, when these are commented out, it writes as usual for normal users (at least from mine-to-mine), but not root, even though messages can be written for root on the util-linux implementation --- which is based on some BSD version and, of course, have almost completely different internals. In any case, I'm happy just per porting this from utmp to utmpx successfully.