1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
Description: Old patches as found in version 1:0.17.pre20000412-5
Last-Update: 2018-11-25
--- a/comsat/comsat.8
+++ b/comsat/comsat.8
@@ -54,7 +54,7 @@
.Xr inetd 8 ) .
The one line messages are of the form:
.Pp
-.Dl user@mailbox-offset
+.Dl user@mailbox-offset:/path/to/mailbox
.Pp
If the
.Em user
--- a/comsat/comsat.c
+++ b/comsat/comsat.c
@@ -62,6 +62,7 @@
#include <paths.h> /* used for _PATH_MAILDIR, _PATH_UTMP, etc. */
#include <unistd.h>
#include <stdlib.h>
+#include <time.h>
#include "../version.h"
@@ -76,8 +77,8 @@
static int nutmp;
static void mailfor(char *name);
-static void notify(struct utmp *utp, off_t offset);
-static void jkfprintf(FILE *, const char *name, off_t offset, const char *cr);
+static void notify(struct utmp *utp, off_t offset, const char *filename);
+static void jkfprintf(FILE *, const char *name, off_t offset, const char *cr, const char *filename);
static void onalrm(int);
int main(void) {
@@ -274,18 +275,26 @@
struct utmp *utp;
char *cp;
off_t offset;
+ char *filename;
+
+ dsyslog(LOG_DEBUG, "mailfor: %s\n", name);
/* Break off the file offset part and convert it to an integer. */
cp = strchr(name, '@');
if (!cp) return;
*cp = 0;
- offset = atol(cp + 1);
+ offset = strtol(cp + 1, &filename, 10);
+ /* if(*filename != '\0')
+ return; */
+
+ if(*filename == ':')
+ filename++;
/* Look through the utmp and call notify() for each matching login. */
utp = &utmp[nutmp];
while (--utp >= utmp) {
if (!strncmp(utp->ut_name, name, sizeof(utmp[0].ut_name)))
- notify(utp, offset);
+ notify(utp, offset, filename);
}
}
@@ -313,7 +322,7 @@
/*
* This actually writes to the user's terminal.
*/
-static void notify(struct utmp *utp, off_t offset)
+static void notify(struct utmp *utp, off_t offset, const char *filename)
{
FILE *tp; /* file open on tty */
struct stat stb;
@@ -426,7 +435,7 @@
/*
* Print the first few lines of the message.
*/
- jkfprintf(tp, name, offset, cr);
+ jkfprintf(tp, name, offset, cr, filename);
/*
* Close up and quit the child process.
@@ -439,7 +448,7 @@
* This prints a few lines from the mailbox of the user "name" at offset
* "offset", using "cr" as the line break string, to the file "tp".
*/
-static void jkfprintf(FILE *tp, const char *name, off_t offset, const char *cr)
+static void jkfprintf(FILE *tp, const char *name, off_t offset, const char *cr, const char * filename)
{
char *cp, ch;
FILE *fi;
@@ -469,8 +478,11 @@
/*
* Open the user's mailbox (recall we're already in the mail spool dir)
*/
- fi = fopen(name, "r");
- if (fi == NULL) return;
+ fi = fopen(filename, "r");
+ if (fi == NULL) {
+ dsyslog(LOG_DEBUG, "couldn't open mailbox %s\n", filename);
+ return;
+ }
/* Move to requested offset */
fseek(fi, offset, L_SET);
|