[Admin-discuss] Hey Changes
Hey, I've added some logging stuff to hey so we can have huh working again. Since I don't actually know any C i'd appreciate it if a few people could take a look and make sure I haven't done anything crazy. http://www.redbrick.dcu.ie/~receive/hey_main.html (changes are marked in red) andrew. -- Andrew Harford System Administrator, DCU Networking Society Equipment Officer, Societies & Publications Committee Tomorrow will be the most beautiful day of Raymond K. Hessel's life. His breakfast will taste better than any meal you and I have ever tasted. --Tyler Durden
As far as I can remember, the logging was done in swrite, so that we were able to log all terminal writes, not just ones sent from hey. It might be more helpful to send the output of diff -u, so we can see changes in a standard format we're more familiar with. :) Looks like you're on the right track, though. Charlie On 19 Dec 2008, at 00:08, Andrew Harford wrote:
Hey,
I've added some logging stuff to hey so we can have huh working again.
Since I don't actually know any C i'd appreciate it if a few people could take a look and make sure I haven't done anything crazy.
http://www.redbrick.dcu.ie/~receive/hey_main.html (changes are marked in red)
andrew.
-- Andrew Harford System Administrator, DCU Networking Society Equipment Officer, Societies & Publications Committee
Tomorrow will be the most beautiful day of Raymond K. Hessel's life. His breakfast will taste better than any meal you and I have ever tasted. --Tyler Durden
_______________________________________________ Admin-discuss mailing list Admin-discuss@lists.redbrick.dcu.ie http://lists.redbrick.dcu.ie/mailman/listinfo/admin-discuss
On Fri, Dec 19, 2008 at 12:18:04AM +0000, Charlie Von Metzradt wrote:
As far as I can remember, the logging was done in swrite, so that we were able to log all terminal writes, not just ones sent from hey.
Aye, twas. I'd rather avoid doing it that way though.
It might be more helpful to send the output of diff -u, so we can see changes in a standard format we're more familiar with. :)
I like red. Each to their own... --- hey_main.c 2008-12-18 23:51:20.784079601 +0000 +++ ../../twins-package/c-hey/hey_main.c 2004-02-19 21:50:34.000000000 +0000 @@ -15,11 +15,6 @@ #include "hey_edit.h" #include "aux.h" -/* added for logging */ -#include <syslog.h> -#include <pwd.h> -/* end logging additions */ - #define COMMANDLEN 64 /* the initial mesg status */ @@ -150,13 +145,10 @@ if (u->tty[0]) strncat(command, u->tty, COMMANDLEN - 1); if (!(pipe = popen(command, "w"))) printerr_exit("hey: couldn't open pipe to write.\n"); - - int linecount=-2; /* Print out the page to write */ do { fprintf(pipe, "%s\n", ptr); - linecount++; } while ((ptr = dyn_pageRead(NULL))); /* Close the pipe */ @@ -165,16 +157,6 @@ exit(1); } - - /* Log this */ - struct passwd *passwd; /* man getpwuid */ - passwd = getpwuid ( getuid()); - - syslog (LOG_MAKEPRI(LOG_USER, LOG_INFO), - "%s send %d line(s) to %s ", passwd->pw_name, linecount, u->name); - /* end new logging code */ - - /* Success message */ printf("hey: %s", u->name); if (u->tty[0]) printf(".%s", u->tty); -- Andrew Harford System Administrator, DCU Networking Society Equipment Officer, Societies & Publications Committee Never do today that which will become someone else's responsibility tomorrow. --David Brent
On Fri, Dec 19, 2008 at 12:08:27AM +0000, Andrew Harford wrote:
Hey,
Hey, sorry this took so long, I don't really read rb mail :-)
http://www.redbrick.dcu.ie/~receive/hey_main.html (changes are marked in red)
The log message should probably say "sent" instead of "send" , and I think the u->name and passwd->pw_name are the wrong way around. Using syslog also means that the messages can be trivially spoofed, so I'm not sure it's a good idea. We basically patched write to do the same thing before, and since it's an sgid app, it's less prone to spoofing (just write to a logfile as that group). The linecount won't be very accurate either, hey's concept of pages arent the same as unix lines. There's no easy way to fix that within hey. Prob fine to run it all the same, cool :-) -- colmmacc@redbrick.dcu.ie PubKey: colmmacc+pgp@redbrick.dcu.ie Web: http://devnull.redbrick.dcu.ie/
On Fri, Dec 26, 2008 at 01:15:26AM +0000, Colm MacCarthaigh wrote:
The log message should probably say "sent" instead of "send" , and I think the u->name and passwd->pw_name are the wrong way around.
Aye, that's what i'd have thought too, but the huh source is expecting it to say send. We realised they were the wrong way around just after I sent the mail out, I'd only been testing it by heying myself before that. It's been fixed.
Using syslog also means that the messages can be trivially spoofed, so I'm not sure it's a good idea. We basically patched write to do the same thing before, and since it's an sgid app, it's less prone to spoofing (just write to a logfile as that group).
I thought write was talking to syslog before, sending stuff into facility local3? I don't have source for any of that though. I originally tried to do the same thing, using local3, but syslog-ng seemed to hate that, so it's just filtering based on the program name. Since we're patching hey rather than write I never expected to be able to rely on the log file as being accurate for what was written to terminals, just to make huh work again. I hadn't really thought of someone spoofing it, it'd be relativly pointless though. Either way, will think more about this one. ta.
The linecount won't be very accurate either, hey's concept of pages arent the same as unix lines. There's no easy way to fix that within hey.
Yep, wasn't expecting it to be perfect. Hasn't been wrong for me yet though, so it's good enough. a. -- Andrew Harford System Administrator, DCU Networking Society Equipment Officer, Societies & Publications Committee This is a Renault Espace, probably the best of the people carriers. Not that that's much to shout about. That's like saying 'Oh good, I've got syphilis, the best of the sexually transmitted diseases!' --Jeremy Clarkson
participants (3)
-
Andrew Harford -
Charlie Von Metzradt -
Colm MacCarthaigh