bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Syslog output from bash


From: Richard Lohman
Subject: Syslog output from bash
Date: Mon, 22 Aug 2016 15:10:32 -0500

Hey all:

In my attempts to log commands from bash via syslog, I've come upon a snag. The output is of the form:
    Mmm dd HH:MM:SS hostname -bash: command
This was obtained by uncommenting the define in config-top.h and changing the call to syslog in bashhist.c as such:
    syslog(SYSLOG_FACILITY|SYSLOG_LEVEL, "%s", line);

Problem is, I'd like the output to resemble other syslog messages:
  Mmm dd HH:MM:SS hostname bash[pid]: command
And ultimately drop the username in as well. Since only bash is logging in this format, I'm guessing there is something in the bash source tree impacting the format, but I can't seem to find it.

As far as the user name, I cobbled a bit of code that will get this for me:

register structure password *pw;
register uid_t uid;
uid=geteuid();
pw=getpwuid(uid);
If(pw) {
    return(pw->pw_name); }
else {
    //handle the error... }

This works to obtain the username, but seems a little heavy-handed. Is there something more expedient, by chance?

Thanks in advance,
Rich


reply via email to

[Prev in Thread] Current Thread [Next in Thread]