From 849dbf3ead4bb133639e5b36aa6f6a10d41c13b3 Mon Sep 17 00:00:00 2001 From: Mario Fetka Date: Wed, 31 Jul 2024 07:59:25 +0200 Subject: [PATCH] apply patch from https://github.com/davidrg/mars_nwe/issues/1#issuecomment-2259477604 --- CMakeLists.txt | 2 +- opt/comm.c | 2 ++ opt/sendm.c | 2 ++ opt/unxcomm.c | 1 + opt/unxsendm.c | 3 ++- src/connect.c | 2 +- src/tools.c | 37 ++++++++++++++++++++++++++++++------- src/unxlog.c | 6 +++++- 8 files changed, 44 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e9d2632..bd0102c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ enable_language(C) SET (VERSION_MAJOR "0") SET (VERSION_MINOR "99") -SET (VERSION_PATCH "24") +SET (VERSION_PATCH "25") SET (VERSION_SUB "0") SET (VERSION_DEVEL "0") SET (VERSION_SUFFIX ".0") diff --git a/opt/comm.c b/opt/comm.c index 0bd01e4..0db2f1d 100644 --- a/opt/comm.c +++ b/opt/comm.c @@ -21,6 +21,8 @@ #define ENV_UNXCOMM "UNXCOMM" #ifdef LINUX +# include +# include # define DEFAULT_COMM "/pipes/unxcomm" #else # ifdef DEFAULT_UNC diff --git a/opt/sendm.c b/opt/sendm.c index 663b763..332701c 100644 --- a/opt/sendm.c +++ b/opt/sendm.c @@ -12,6 +12,8 @@ #define ENV_UNXCOMM "UNXSENDM" #ifdef LINUX +# include +# include # define DEFAULT_COMM "/pipes/unxsendm" # else # define DEFAULT_COMM "p:/unxsendm" diff --git a/opt/unxcomm.c b/opt/unxcomm.c index c191eea..c5aa1bd 100644 --- a/opt/unxcomm.c +++ b/opt/unxcomm.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include diff --git a/opt/unxsendm.c b/opt/unxsendm.c index 3eb8d73..e884893 100644 --- a/opt/unxsendm.c +++ b/opt/unxsendm.c @@ -5,6 +5,7 @@ */ #include +#include #include #include #include @@ -36,7 +37,7 @@ int main(int argc, char *argv[]) FILE *f; char path[MAXARGLEN+200]; buf[size]='\0'; - sprintf(path, "/usr/sbin/sendmail %s", buf); + sprintf(path, "/usr/bin/sendmail %s", buf); f=popen(path, "w"); if (NULL != f) { write(1, "+++++\n", 6); diff --git a/src/connect.c b/src/connect.c index 6adb5ce..60af2ce 100644 --- a/src/connect.c +++ b/src/connect.c @@ -882,7 +882,7 @@ static int build_path( NW_PATH *path, if (len > 255) len = 255; conn_build_path_fn(vol, path->path, - (only_dir) ? (uint8)NULL + (only_dir) ? NULL : path->fn, &(path->has_wild), data, len, sizeof(path->fn)); diff --git a/src/tools.c b/src/tools.c index ea9c634..dbd35d1 100644 --- a/src/tools.c +++ b/src/tools.c @@ -21,6 +21,27 @@ #include #include +#if 0 +#ifndef LINUX + extern int _sys_nerr; + extern char *_sys_errlist[]; +#else +# ifndef __USE_GNU +# define _sys_nerr sys_nerr +# define _sys_errlist sys_errlist +# endif +#endif +#else +# ifndef __USE_GNU +# ifdef FREEBSD +# define _sys_nerr sys_nerr +# define _sys_errlist sys_errlist +# else +extern int _sys_nerr; +extern char *_sys_errlist[]; +# endif +# endif +#endif int nw_debug=0; uint32 debug_mask=0; /* special debug masks */ @@ -161,7 +182,8 @@ static char *buffered=NULL; if (mode & 0x10) { int l=sprintf(pb, ", errno=%d", errnum); pb+=l; - l=sprintf(pb, " (%s)", strerror(errnum)); + if (errnum > 0) + l=sprintf(pb, " (%s)", strerror(errnum)); } if (!(mode & 2)) { char identstr[200]; @@ -186,7 +208,8 @@ static char *buffered=NULL; va_end(ap); } if (mode & 0x10) { - fprintf(logfile, ", errno=%d", strerror(errnum)); + fprintf(logfile, ", errno=%d", errnum); + if (errnum > 0) fprintf(logfile, " (%s)", strerror(errnum)); } if (!(mode & 2)) @@ -213,11 +236,11 @@ void errorp(int mode, char *what, char *p, ...) errnum = -1; mode -= 10; } -// if (errnum >= 0 && errnum < _sys_nerr) errstr = _sys_errlist[errnum]; -// else if (errnum > -1) - sprintf(errbuf, "errno=%d", strerror(errnum)); -// else -// errbuf[0] = '\0'; + if (errnum >= 0) errstr = strerror(errnum); + else if (errnum > -1) + sprintf(errbuf, "errno=%d", errnum); + else + errbuf[0] = '\0'; if (use_syslog) { int prio=(mode) ? LOG_CRIT : LOG_ERR; diff --git a/src/unxlog.c b/src/unxlog.c index ea037dc..ac15263 100644 --- a/src/unxlog.c +++ b/src/unxlog.c @@ -24,6 +24,7 @@ void write_utmp(int dologin, int connection, int pid, #ifndef FREEBSD struct utmp loc_ut; struct utmp *ut; + struct timeval tv; int fd; char buff[200]; int found = 0; @@ -67,7 +68,10 @@ void write_utmp(int dologin, int connection, int pid, memset(ut->ut_user, 0, sizeof(ut->ut_user)); ut->ut_pid = 0; } - (void)time(&(ut->ut_time)); + gettimeofday(&tv, NULL); + ut->ut_tv.tv_sec=tv.tv_sec; + ut->ut_tv.tv_usec=tv.tv_usec; + pututline(ut); endutent(); if (NULL == fn_wtmp) return;