[Pkg-wmaker-commits] [wmbiff] 18/38: space for detail in grab command output, use the detail to populate a message list in a getheaders function (eg. can see the list of thought to be updated packages if using hte security.debian script

Doug Torrance dtorrance-guest at moszumanska.debian.org
Thu Aug 20 03:03:39 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to tag wmbiff_0_4_16
in repository wmbiff.

commit 53fc2826ed1cd2b08fc3a8f35692b3b1a9ce0390
Author: bluehal <bluehal>
Date:   Thu Apr 17 01:56:00 2003 +0000

    space for detail in grab command output, use the detail to populate a message list in a getheaders function (eg. can see the list of thought to be updated packages if using hte security.debian script
---
 wmbiff/Client.h      | 10 +++++++---
 wmbiff/ShellClient.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++----
 wmbiff/passwordMgr.c |  2 +-
 3 files changed, 56 insertions(+), 8 deletions(-)

diff --git a/wmbiff/Client.h b/wmbiff/Client.h
index 062d2c5..87f6ddc 100644
--- a/wmbiff/Client.h
+++ b/wmbiff/Client.h
@@ -1,11 +1,11 @@
-/* $Id: Client.h,v 1.32 2003/04/16 08:18:32 bluehal Exp $ */
+/* $Id: Client.h,v 1.33 2003/04/17 01:56:00 bluehal Exp $ */
 /* Author : Scott Holden ( scotth at thezone.net )
    Modified : Yong-iL Joh ( tolkien at mizi.com )
    Modified : Jorge Garc�a ( Jorge.Garcia at uv.es )
  *
  * Email Checker Pop3/Imap4/Licq/Gicu/mbox/maildir/finger
  *
- * Last Updated : $Date: 2003/04/16 08:18:32 $
+ * Last Updated : $Date: 2003/04/17 01:56:00 $
  *
  */
 
@@ -53,6 +53,9 @@ typedef struct _mbox_t {
 			off_t size;
 		} mbox;
 		struct {
+			char *detail;
+		} shell;
+		struct {
 			time_t mtime_new;
 			off_t size_new;
 			time_t mtime_cur;
@@ -102,7 +105,8 @@ char *backtickExpand(Pop3 pc, const char *path);
 int fileHasChanged(const char *mbox_filename, time_t * atime,
 				   time_t * mtime, off_t * size);
 int grabCommandOutput(Pop3 pc, const char *command,
-					  /*@out@ */ char **output);
+					  /*@out@ */ char **output,
+					  /*@out@ *//*@null@ */ char **details);
 int exists(const char *filename);	/* test -f */
 
 /* _NONE is for silent operation.  _ERROR is for things that should
diff --git a/wmbiff/ShellClient.c b/wmbiff/ShellClient.c
index 19b646f..ebb31dd 100644
--- a/wmbiff/ShellClient.c
+++ b/wmbiff/ShellClient.c
@@ -21,6 +21,7 @@
 #include <assert.h>
 #include <strings.h>
 #include "charutil.h"
+#include "MessageList.h"
 #ifdef USE_DMALLOC
 #include <dmalloc.h>
 #endif
@@ -87,7 +88,7 @@ static int kind_pclose( /*@only@ */ FILE * F,
 }
 
 int grabCommandOutput(Pop3 pc, const char *command,	/*@out@ */
-					  char **output)
+					  char **output, /*@out@ *//*@null@ */ char **details)
 {
 	FILE *F;
 	char linebuf[512];
@@ -101,9 +102,20 @@ int grabCommandOutput(Pop3 pc, const char *command,	/*@out@ */
 			  "fgets: unable to read the output of '%s': %s\n", command,
 			  strerror(errno));
 	} else {
-		chomp(linebuf);
+		chomp(linebuf);			/* remove trailing newline */
 		*output = strdup_ordie(linebuf);
 	}
+	if (details) {
+		static char allbuf[4096];
+		allbuf[0] = '\0';
+		if (fread(allbuf, 1, 4095, F) == 0 && !feof(F)) {
+			SH_DM(pc, DEBUG_ERROR,
+				  "fread: unable to read the detailed output of '%s': %s\n",
+				  command, strerror(errno));
+		}
+		allbuf[4095] = '\0';
+		*details = strdup_ordie(allbuf);
+	}
 	return (kind_pclose(F, command, pc));
 }
 
@@ -126,7 +138,7 @@ char *backtickExpand(Pop3 pc, const char *path)
 		strncat(bigbuffer, path, tickstart - path);
 		command = strdup_ordie(tickstart + 1);
 		command[tickend - tickstart - 1] = '\0';
-		(void) grabCommandOutput(pc, command, &commandoutput);
+		(void) grabCommandOutput(pc, command, &commandoutput, NULL);
 		free(command);
 		if (commandoutput != NULL) {
 			strcat(bigbuffer, commandoutput);
@@ -151,7 +163,12 @@ int shellCmdCheck(Pop3 pc)
 
 	/* fetch the first line of input */
 	pc->TextStatus[0] = '\0';
-	(void) grabCommandOutput(pc, pc->path, &commandOutput);
+	if (pc->u.shell.detail != NULL) {
+		free(pc->u.shell.detail);
+		pc->u.shell.detail = NULL;
+	}
+	(void) grabCommandOutput(pc, pc->path, &commandOutput,
+							 &pc->u.shell.detail);
 	if (commandOutput == NULL) {
 		return -1;
 	}
@@ -201,6 +218,32 @@ int shellCmdCheck(Pop3 pc)
 	return (0);
 }
 
+struct msglst *shell_getHeaders( /*@notnull@ */ Pop3 pc)
+{
+	struct msglst *message_list = NULL;
+
+	char *ln = pc->u.shell.detail;
+	int i, j;
+	if (ln == NULL)
+		return NULL;
+
+	for (j = 0; ln[j] != '\0';) {
+		struct msglst *m = malloc(sizeof(struct msglst));
+		m->next = message_list;
+		m->subj[0] = '\0';
+		m->from[0] = '\0';
+
+		for (i = 0; i < SUBJ_LEN - 1 && ln[j + i] != '\n'; i++) {
+			m->subj[i] = ln[j + i];
+		}
+		m->subj[i] = '\0';
+		j += i + 1;
+
+		message_list = m;
+	}
+	return message_list;
+}
+
 int shellCreate( /*@notnull@ */ Pop3 pc, const char *str)
 {
 	/* SHELL format: shell:::/path/to/script */
@@ -211,6 +254,7 @@ int shellCreate( /*@notnull@ */ Pop3 pc, const char *str)
 	pc->OldMsgs = -1;
 	pc->OldUnreadMsgs = -1;
 	pc->checkMail = shellCmdCheck;
+	pc->getHeaders = shell_getHeaders;
 	reserved1 = str + 6;		/* shell:>:: */
 
 	assert(strncasecmp("shell:", str, 6) == 0);
diff --git a/wmbiff/passwordMgr.c b/wmbiff/passwordMgr.c
index 1e416d4..42ab405 100644
--- a/wmbiff/passwordMgr.c
+++ b/wmbiff/passwordMgr.c
@@ -130,7 +130,7 @@ char *passwordFor(const char *username,
 			snprintf(command, len, "%s 'password for wmbiff: %s@%s'",
 					 pc->askpass, username, servername);
 
-			(void) grabCommandOutput(pc, command, &password_ptr);
+			(void) grabCommandOutput(pc, command, &password_ptr, NULL);
 			/* it's not clear what to do with the exit
 			   status, though we can get it from
 			   grabCommandOutput if needed to deal with some

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmbiff.git



More information about the Pkg-wmaker-commits mailing list