OpenBCM V1.13 (Linux)

Packet Radio Mailbox

DB0FHN

[JN59NK Nuernberg]

 Login: GUEST





  
DG9EP  > UNIX     31.08.98 01:44l 509 Lines 13836 Bytes #999 (999) @ DL
BID : U88DB0IZ_02G
Read: GUEST
Subj: TNT-PATCH fuer PGP inkl. Versand (.patch)
Path: DB0MAK<DB0SON<DB0SIF<DB0HSK<DB0QS<DB0IZ
Sent: 980830/2131z @:DB0IZ.#NRW.DEU.EU [BCM West<>Link BOX SOLINGEN] BCM1.40
From: DG9EP @ DB0IZ.#NRW.DEU.EU  (Walter)
To:   UNIX @ DL
X-Info: No login password

-----BEGIN PGP SIGNED MESSAGE-----

diff -ub src.wrk.init/display.c src.wrk/display.c
- --- src.wrk.init/display.c	Sun Feb  2 20:48:16 1997
+++ src.wrk/display.c	Sun Aug 30 22:09:40 1998
@@ -544,6 +544,16 @@
   statlin_update();
 }
 
+void sel_connect_force(channel)
+int channel;
+{
+/* dg9ep 30.08.98 */
+  real_screen(layout[channel]);
+  act_mode = M_CONNECT;
+  act_channel = channel;
+  statlin_update();
+}
+
 void stat_display_org(channel)
 int channel;
 {
diff -ub src.wrk.init/file.c src.wrk/file.c
- --- src.wrk.init/file.c	Mon Feb 17 01:04:22 1997
+++ src.wrk/file.c	Sun Aug 30 17:31:59 1998
@@ -264,6 +264,9 @@
     case RX_AUTO7P:
       strcat(str," A7 ");
       break;
+    case RX_PGP:
+      strcat(str," PG ");
+      break;
     }
     cut_filename(str,rx_file[channel].name);
   }
@@ -626,6 +629,7 @@
       cmd_display(mode,channel,ok_text,1);
     }
     break;
+  case RX_PGP:
   case RX_AUTO7P:
     break;
   case RX_ABIN:
@@ -1065,6 +1069,7 @@
       break; /* ignore, handled in write_file_abin */
     case RX_YAPP:
       break; /* ignore, handled in write_file_yapp */
+    case RX_PGP:
     case RX_AUTO7P:
     case RX_PLAIN:
       memcpy(newstr,str,len);
@@ -1097,6 +1102,7 @@
     case RX_NORM:
     case RX_BIN:
     case RX_PLAIN:
+    case RX_PGP:
     case RX_AUTO7P:
       break; /* ignore, handled in write_file */
     case RX_YAPP:
diff -ub src.wrk.init/keyboard.c src.wrk/keyboard.c
- --- src.wrk.init/keyboard.c	Mon Dec  1 05:00:40 1997
+++ src.wrk/keyboard.c	Sun Aug 30 21:44:15 1998
@@ -15,6 +15,7 @@
 
 extern int queue_cmd_data(int channel,char code,int len,int flag,char *data);
 extern void sel_connect(int channel);
+extern void sel_connect_force(int channel);
 extern void statlin_update();
 extern void cmd_display(int flag,int channel,char *buffer,int cr);
 #ifndef DPBOXT
@@ -73,6 +74,12 @@
 extern void reinit_screen();
 
 
+/* i am confused about the many ifdef's and doubled lines
+ * so here is no ifdef around
+ */
+static char lastPGPEDITfilename[257];
+
+
 #ifdef DPBOXT
 
 extern int act_channel;
@@ -199,6 +206,7 @@
 extern void rem_ctext();
 extern void rem_name();
 static void cmd_chdir();
+static void cmd_pgpedit();  /* dg9ep 98 */
 static void cmd_cwdir();
 static void cmd_resync();
 extern void cmd_xconnect();
@@ -303,6 +311,8 @@
 #define F_AUTOYAPP 27
 #define F_AUTO7PL 28
 #define F_LOGBOOK 29
+#define F_PGPAUTO 30 /* dg9ep 8-98 */
+#define F_PGPKEYADD 31 /* dg9ep 8-98 */
 
 /* variables for flag command */
 #ifdef DPBOXT
@@ -326,6 +336,8 @@
 int autobin_flag;
 int autoyapp_flag;
 int auto7pl_flag;
+int pgpauto_flag;
+int pgpkeyadd_flag;
 extern int xmon_flag;
 extern int mheard_flag;
 #ifdef USE_IFACE
@@ -491,7 +503,10 @@
   {"AUTOBIN" ,6,1,cmd_flag,"",F_AUTOBIN,0},
   {"AUTOYAPP",6,1,cmd_flag,"",F_AUTOYAPP,0},
   {"AUTO7PL" ,6,1,cmd_flag,"",F_AUTO7PL,0},
+  {"PGPAUTO" ,5,1,cmd_flag,"",F_PGPAUTO,0},
+  {"PGPKEYAD",6,1,cmd_flag,"",F_PGPKEYADD,0},
   {"LOGBOOK" ,7,1,cmd_flag,"",F_LOGBOOK,0},
+  {"PGPEDIT" ,7,1,cmd_pgpedit,"",0,0},
   {"XMON"    ,4,1,cmd_flag,"",F_XMON,0},
   {"HEARD"   ,3,1,cmd_flag,"",F_HEARD,0},
 #ifdef USE_IFACE
@@ -739,6 +754,7 @@
 #endif
   chan_flag = 0;
   exit_flag = 0;
+  lastPGPEDITfilename[0] = '\0';
 
   if (!tnt_daemon) {
     tcgetattr(0,&okbd_termios);
@@ -1606,6 +1622,12 @@
   case F_AUTO7PL:
     flag = &auto7pl_flag;
     break;
+  case F_PGPAUTO:
+    flag = &pgpauto_flag;
+    break;
+  case F_PGPKEYADD:
+    flag = &pgpkeyadd_flag;
+    break;
   case F_LOGBOOK:
     flag = &logbook_flag;
     break;
@@ -2065,4 +2087,159 @@
     return;
   }
   cmd_display(mode,channel,"Can't load keyboard-macro-file",1);
+}
+
+
+static void cmd_pgpedit(par1,par2,channel,len,mode,str)
+int par1;
+int par2;
+int channel;
+int len;
+int mode;
+char *str;
+{
+  int result;
+  char *sEditor;
+  char line[258];
+  char cmdline[230];
+  char tmpeditname[257];
+  char tmpstdoutname[257];
+  char ascfilename[257];
+  int file_end;
+  FILE *hdl_out;
+  FILE *hdl_test;
+  char *ptr;
+  
+  if( !str | (strlen(str) == 0) ) {
+    cmd_display(mode,channel,"Password missing",1);
+    return;
+  }
+
+  /* getting editorname */
+  sEditor = getenv("EDITOR");
+  if( !sEditor | (strlen(sEditor) == 0) )   /* default to ... */
+    sEditor = "vi";
+
+  if( *lastPGPEDITfilename != '\0' ) {  
+    /* there was en error during last pgpedit, so we'll try
+     * to reuse the file edited last */
+ 
+    strcpy(tmpeditname,lastPGPEDITfilename);
+  } else {
+    /* create a temp. file to edit */
+    strcpy(tmpeditname,"/tmp/tnt_pgpe.XXXXXX");
+    mktemp(tmpeditname);
+  }
+
+  strcpy(cmdline,sEditor);
+  strcat(cmdline," ");
+  strcat(cmdline,tmpeditname);
+  strcat(cmdline," 2>/dev/null");
+
+  result = system(cmdline);
+  
+  /*  Bildschirm wiederherstellen */
+  sel_connect_force(channel);
+
+  /* $TODO result abtesten */
+  /** sprintf(line,"*** %s --> res: %d\r ",cmdline,result);
+   ** rem_data_display(channel,line);
+   **/
+
+  /* existenz von tmpeditname testen */
+  if (!(hdl_test = fopen(tmpeditname,"r"))) {
+    /* Keine Arme, keine Kekse */
+    cmd_display(mode,channel,"No edited file -> no signing",1); 
+    return;
+  }
+  fclose(hdl_test);  
+
+  /* tmpeditname merken (see above) */
+  strcpy(lastPGPEDITfilename,tmpeditname);
+
+  /* PGP aufrufen */
+  /* 1. tempfile for stdout */
+  strcpy(tmpstdoutname,"/tmp/tnt_pgps.XXXXXX");
+  mktemp(tmpstdoutname);
+
+  /* 2. tempfile for outfile (.asc) */
+  strcpy(ascfilename,"/tmp/tnt_pgpo.XXXXXX");
+  mktemp(ascfilename);
+
+  /* 3. build cmdline for pgp */
+  sprintf(cmdline,
+     "pgp +batchmode +clearsig +verbose=0 -z""%s"" -o %s -sat %s > %s  2>/dev/null",
+      str,ascfilename,tmpeditname,tmpstdoutname
+  );
+  /***** rem_data_display(channel,cmdline); 
+ **/
+   
+  /* 4. Aufrufen */
+  sprintf(line ,"\r*** calling PGP *****\r");
+  rem_data_display(channel,line);
+ 
+  result = system(cmdline);
+
+  /* sprintf(cmdline,"res pgp=%d\r ",result);
+   * rem_data_display(channel,cmdline);
+   */
+
+  /* for security: */
+  memset(cmdline, 0, sizeof(cmdline) );
+  memset(str, 0, sizeof(str) );
+
+  /* Ausgabe von pgp anzeigen  $TODO: Subroutine hierfür verwenden */
+  {
+    if (!(hdl_out = fopen(tmpstdoutname,"r"))) {
+       return; /* Outfile nit da */
+    }
+
+    file_end = 0;
+    while (!file_end) {
+      if (fgets(line,257,hdl_out) == NULL) {
+        file_end = 1;
+      } else {
+        if (strlen(line) == 257) {
+          file_end = 1;
+        } else {
+          /* Killing some ctrl-char */
+          ptr = strchr(line,'\r');
+          if (ptr != NULL) *ptr = '\0';
+          ptr = strchr(line,'\n');
+          if (ptr != NULL) *ptr = '\0';
+          ptr = strchr(line,(char)0x07);
+          if (ptr != NULL) *ptr = ' ';
+
+          rem_data_display(channel,line);
+          rem_data_display(channel,"\r");
+        }
+      }
+    } /* while */
+    fclose(hdl_out);
+    unlink(tmpstdoutname);
+  }
+  sprintf(line ,"*********** end pgp output ******\r");
+  rem_data_display(channel,line);
+  
+
+  /* result des PGP Aufruf testen */
+  /* 127 -> bin/sh - Fehler; -1 anderer Aufruffehler
+   * sonst: Returncode des aufgerufenen
+   *   0 -> ok
+   *   512 -> Datei nicht gefunden
+   *  5120 -> Fehler beim unterschreiben
+   */
+  if( result ) {
+     return; /* Fehler -> nix machen */
+  }
+
+  /* everything OK */
+  cmd_display(mode,channel,ok_text,1);
+
+  lastPGPEDITfilename[0] = '\0'; /* not needed any more */
+  unlink(tmpeditname); /* dto. */
+
+  /* ascfilename $TODO nach up/ kopieren */
+  /* OK, send signed file */
+  open_sendfile(TX_NORM,1, channel, strlen(ascfilename), mode, ascfilename);
 }
diff -ub src.wrk.init/main.c src.wrk/main.c
- --- src.wrk.init/main.c	Sun Aug 30 17:10:10 1998
+++ src.wrk/main.c	Sun Aug 30 20:29:04 1998
@@ -181,7 +181,9 @@
 "-Version, Created: "TNT_DATE"\015"
 "Copyright (C) 1993-97 by Mark Wahl, DL4YBG\015"
 "For license details see documentation.\015"
- -"To get help: <ALT> H or <Esc> H\015";
+"To get help: <ALT> H or <Esc> H\015"
+"PGP extension, dg9ep, 30.Aug.98\015"
+;
 
 char add_signon[] =
 "No root permissions: SHELL command disabled\015";
diff -ub src.wrk.init/remote.c src.wrk/remote.c
- --- src.wrk.init/remote.c	Sun Feb 16 22:06:28 1997
+++ src.wrk/remote.c	Sun Aug 30 20:22:32 1998
@@ -49,6 +49,8 @@
 extern int autobin_flag;
 extern int autoyapp_flag;
 extern int auto7pl_flag;
+extern int pgpauto_flag;
+extern int pgpkeyadd_flag;
 extern char tnt_ctextfile[];
 extern char news_file_name[];
 extern char run_dir[];
@@ -832,6 +834,8 @@
   autobin_flag = 1;
   autoyapp_flag = 0;
   auto7pl_flag = 0;
+  pgpauto_flag = 0;
+  pgpkeyadd_flag = 1;
   strcpy(rem_tnt_str,"<TNT>: ");
   strcpy(rem_inv_str,"Invalid command !");
   strcpy(rem_len_str,"Line too long, ignored");
@@ -1039,6 +1043,122 @@
   return(0);
 }
 
+/* handle PGP strings/reception
+ * for now we are only looking for signed messages and keyblocks
+ * returns !0  if buffer handled
+ * dg9ep 7-98
+ */
+static int handle_pgp(channel,buffer,len)
+int channel;
+char *buffer;
+int len;
+{
+  int file_end;
+  char filename[257];
+  char tmpstdoutname[257];
+  char sres[257];
+  int i;
+  int typ;
+  int part;
+  int errflag;
+  int res;
+  char *ptr;
+  int ans_len;
+  char string[80];
+  char line[258];
+  int result;
+  FILE *hdl_out;
+
+
+  if (rx_file[channel].type == RX_PGP) {
+    /* already receiving file, just check for endstring */
+    typ = 0;
+    if        (!strncmp(buffer,"-----END PGP SIGNATURE-----",       27)) {
+       typ = PGP_SIGNED_MESSAGE;
+    } else if (!strncmp(buffer,"-----END PGP PUBLIC KEY BLOCK-----",34)) {
+       typ = PGP_PUBLIC_KEY_BLOCK;
+    }
+    if ( typ > 0 ) {
+      write_file(channel,len,RX_RCV,buffer);
+      strcpy(filename,rx_file[channel].name);
+      close_rxfile2(channel,0,0);
+
+      strcpy(tmpstdoutname,"/tmp/tnt_pgp_stdout.XXXXXX");
+      mktemp(tmpstdoutname);
+
+      /* build cmdline for pgp */
+      strcpy(string,"pgp +batchmode +verbose=0 ");
+      if(        typ == PGP_SIGNED_MESSAGE ) {
+          /* Nothing else to do to verify */
+      } else if( typ == PGP_PUBLIC_KEY_BLOCK ) {
+          if( pgpkeyadd_flag ) {
+             /* add keys to keyring */
+             strcat(string," +interactive=off +force -ka ");
+          } else {
+             /* show keys only */
+            rem_data_display(channel,"(keys will not be added to keyring)\r");
+          }
+      }
+      strcat(string,filename);
+      strcat(string," -o /dev/null > "); /* $TODO -> Outfile auch PGP vorwerfen */
+      strcat(string,tmpstdoutname);
+      strcat(string," 2>/dev/null");
+      result = system(string);
+      /* Ausgabe von pgp anzeigen */
+      if (!(hdl_out = fopen(tmpstdoutname,"r"))) {
+        sprintf(sres,"ERROR: %s not found",tmpstdoutname);
+        return(1);
+      }
+      file_end = 0;
+      while (!file_end) {
+        if (fgets(line,257,hdl_out) == NULL) {
+          file_end = 1;
+        } else {
+          if (strlen(line) == 257) {
+            file_end = 1;
+          } else {
+            ptr = strchr(line,'\r');
+            if (ptr != NULL) *ptr = '\0';
+            ptr = strchr(line,'\n');
+            if (ptr != NULL) *ptr = '\0';
+            ptr = strchr(line,(char)0x07);
+            if (ptr != NULL) *ptr = ' ';
+
+            rem_data_display(channel,line);
+            rem_data_display(channel,"\r");
+          }
+        }
+      }
+      fclose(hdl_out);
+      unlink(tmpstdoutname);
+      unlink(filename);
+    }
+    return(1);
+  }
+
+  typ = 0;
+  if        (!strncmp (buffer, "-----BEGIN PGP SIGNED MESSAGE-----",34)) {
+      /* It's a signed file */
+      typ = PGP_SIGNED_MESSAGE;
+  } else if (!strncmp (buffer, "-----BEGIN PGP PUBLIC KEY BLOCK-----",36)) {
+      typ = PGP_PUBLIC_KEY_BLOCK;
+  }
+  if( typ ) {
+      /* Get tmp. filename.  */
+      strcpy(filename,"/tmp/tnt_pgp.XXXXXX");
+      mktemp(filename);
+
+      open_logfile(RX_PGP,RX_RCV,channel,strlen(filename),
+                   M_CONNECT,filename);
+      errflag = (rx_file[channel].type != RX_PGP);
+      if (!errflag) return(1);
+  }
+  return(0);
+}
+
+
+
+
 /* check packet, if special strings are contained */
 static int check_spec_strings(channel,buffer,len)
 int channel;
@@ -1066,6 +1186,12 @@
   if (((rx_file[channel].type == -1) && auto7pl_flag) ||
       (rx_file[channel].type == RX_AUTO7P)) {
     if (handle_7pl(channel,buffer,len)) return(0);
+  }
+
+  /* PGP handling  dg9ep */
+  if (((rx_file[channel].type == -1) && pgpauto_flag) ||
+       (rx_file[channel].type == RX_PGP)) {
+    if (handle_pgp(channel,buffer,len)) return(0);
   }
 
   wait_bin = ((rx_file[channel].type == RX_ABIN) ||
diff -ub src.wrk.init/tnt.h src.wrk/tnt.h
- --- src.wrk.init/tnt.h	Sun Aug 30 17:08:11 1998
+++ src.wrk/tnt.h	Sun Aug 30 17:32:00 1998
@@ -292,6 +292,7 @@
 #define RX_ABIN_E 5     /* RX_ABIN_Q only for box and boxcut */
 #define RX_YAPP 6       /* receive using YAPP */
 #define RX_AUTO7P 7     /* auto 7PLUS reception */
+#define RX_PGP 8        /* auto PGP rx & check, dg9ep 7-98 */
 
 /* transmit file types */
 #define TX_NORM 0	/* ASCII-file */
@@ -305,6 +306,10 @@
 /* flag for logging data */
 #define RX_RCV 0x01	/* received data */
 #define RX_SND 0x02	/* sent data */
+
+/* types of PGP-Files */
+#define PGP_SIGNED_MESSAGE 1
+#define PGP_PUBLIC_KEY_BLOCK 2
 
 /* types of send_queue */
 #define SQ_NORMAL 0     /* normal queue */

-----BEGIN PGP SIGNATURE-----
Version: 2.6.3ia
Charset: latin1

iQCVAwUBNenGojD37IMYqFzBAQGeTQP+P7tpF3NncemLSUnTmPgkcdPyVnGPRZNg
6rSjt/Se2zwjnGGS25N1M0/LMrc/Ibv7Ghn0tQsctWeRg5rubMxXj+1YIu3Nyr4v
x06GIQYIbNy7xtcfrWd+lMPxBu4qXci0TSiAVevSVgBaPIbp0dA3PNd15S6t/htZ
UHWioDijLuI=
=0z3B
-----END PGP SIGNATURE-----


Read previous mail | Read next mail


 11.07.2026 00:42:45lGo back Go up