--- snoopy-1.8.0/snoopy.c 2011-03-06 03:52:18.000000000 +0100 +++ snoopy.c 2014-03-28 17:07:31.701494084 +0100 @@ -48,6 +48,7 @@ size_t logStringSize = 0; char cwd[PATH_MAX+1]; char *getCwdRet = NULL; + char * getIP = NULL; char *logMessage = NULL; int logMessageMaxSize = 0; @@ -124,9 +125,13 @@ /* Create logMessage */ + getCwdRet = getcwd(cwd, PATH_MAX+1); #if defined(SNOOPY_CWD_LOGGING) - getCwdRet = getcwd(cwd, PATH_MAX+1); - sprintf(logMessage, "[uid:%d sid:%d tty:%s cwd:%s filename:%s]: %s", getuid(), getsid(0), ttyPath, cwd, filename, logString); + getIP = getenv("SSH_CONNECTION"); + if (getIP == NULL) { + getIP = strdup("0.0.0.0"); // not elegeant but test when ssh env isn't existing.. + } + sprintf(logMessage, "[ip:%s uid:%d sid:%d tty:%s cwd:%s filename:%s]: %s", getIP, getuid(), getsid(0), ttyPath, cwd, filename, logString); #else sprintf(logMessage, "[uid:%d sid:%d tty:%s filename:%s]: %s", getuid(), getsid(0), ttyPath, filename, logString); #endif