Changeset d564c3d


Ignore:
Timestamp:
Mar 17, 2010, 11:15:36 PM (14 years ago)
Author:
Nelson Elhage <nelhage@ksplice.com>
Branches:
master, release-1.10, release-1.6, release-1.7, release-1.8, release-1.9
Children:
2b7ef0a
Parents:
dfe94f9
git-author:
Nelson Elhage <nelhage@ksplice.com> (03/17/10 22:55:20)
git-committer:
Nelson Elhage <nelhage@ksplice.com> (03/17/10 23:15:36)
Message:
Replace the built-in zcrypt with shelling out to the zcrypt binary.
Files:
2 added
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • Makefile.am

    r10557e6 rd564c3d  
    99barnowl_bin_SOURCES = $(BASE_SRCS) \
    1010     owl.h owl_perl.h config.h \
    11      owl.c \
     11     owl.c filterproc.c \
    1212     $(GEN_C) $(GEN_H)
    1313
     
    3838     perlconfig.c keys.c functions.c zwrite.c viewwin.c help.c filter.c \
    3939     regex.c history.c view.c dict.c variable.c filterelement.c pair.c \
    40      keypress.c keymap.c keybinding.c cmd.c context.c zcrypt.c \
     40     keypress.c keymap.c keybinding.c cmd.c context.c \
    4141     aim.c buddy.c buddylist.c style.c errqueue.c \
    4242     zbuddylist.c popexec.c obarray.c select.c wcwidth.c \
  • commands.c

    rf449096 rd564c3d  
    19621962char *owl_command_zcrypt(int argc, const char *const *argv, const char *buff)
    19631963{
    1964 #ifdef OWL_ENABLE_ZCRYPT
    19651964  owl_zwrite z;
    19661965
     
    19841983  }
    19851984  return(NULL);
    1986 #else
    1987   owl_function_makemsg("This Owl does not support zcrypt");
    1988   return NULL;
    1989 #endif
    19901985}
    19911986
  • functions.c

    rdfe94f9 rd564c3d  
    1212#include <signal.h>
    1313#include "owl.h"
     14#include "filterproc.h"
    1415
    1516char *owl_function_command(const char *cmdbuff)
     
    402403  char *cryptmsg;
    403404  owl_message *m;
     405  const char *argv[7];
     406  int rv, status;
    404407
    405408  /* create the zwrite and send the message */
     
    411414
    412415  mymsg=owl_zwrite_get_message(&z);
    413 #ifdef OWL_ENABLE_ZCRYPT
    414   cryptmsg = owl_zcrypt_encrypt(mymsg, owl_zwrite_get_class(&z), owl_zwrite_get_instance(&z));
    415   if (!cryptmsg) {
     416
     417  argv[0] = "zcrypt";
     418  argv[1] = "-E";
     419  argv[2] = "-c"; argv[3] = owl_zwrite_get_class(&z);
     420  argv[4] = "-i"; argv[5] = owl_zwrite_get_instance(&z);
     421  argv[6] = NULL;
     422
     423  rv = call_filter("zcrypt", argv, mymsg, &cryptmsg, &status);
     424
     425  if (rv || status) {
     426    if(cryptmsg) owl_free(cryptmsg);
    416427    owl_function_error("Error in zcrypt, possibly no key found.  Message not sent.");
    417428    owl_function_beep();
     
    419430    return;
    420431  }
    421 #else
    422   cryptmsg=owl_strdup(mymsg);
    423 #endif
    424432
    425433  owl_zwrite_set_message(&z, cryptmsg);
  • message.c

    r66a8cd6 rd564c3d  
    1010#include <time.h>
    1111#include "owl.h"
     12#include "filterproc.h"
    1213
    1314static owl_fmtext_cache fmtext_cache[OWL_FMTEXT_CACHE_SIZE];
     
    838839  owl_free(tmp);
    839840
    840 #ifdef OWL_ENABLE_ZCRYPT
    841841  /* if zcrypt is enabled try to decrypt the message */
    842842  if (owl_global_is_zcrypt(&g) && !strcasecmp(n->z_opcode, "crypt")) {
    843     char *out = owl_zcrypt_decrypt(owl_message_get_body(m), owl_message_get_class(m), owl_message_get_instance(m));
    844     if (out) {
     843    const char *argv[] = {
     844      "zcrypt",
     845      "-D",
     846      "-c", owl_message_get_class(m),
     847      "-i", owl_message_get_instance(m),
     848      NULL
     849    };
     850    char *out;
     851    int rv;
     852    int status;
     853
     854    rv = call_filter("zcrypt", argv, owl_message_get_body(m), &out, &status);
     855
     856    if(!rv && !status) {
     857      int len = strlen(out);
     858      if(len >= 8 && !strcmp(out + len - 8, "**END**\n")) {
     859        out[len - 8] = 0;
     860      }
    845861      owl_message_set_body(m, out);
    846862      owl_free(out);
     863    } else if(out) {
     864      owl_free(out);
    847865    }
    848866  }
    849 #endif 
    850867}
    851868#else
  • tester.c

    r30bb10a rd564c3d  
    1313int owl_obarray_regtest(void);
    1414int owl_editwin_regtest(void);
    15 #ifdef OWL_ENABLE_ZCRYPT
    16 int owl_zcrypt_regtest(void);
    17 #endif
    1815
    1916int main(int argc, char **argv, char **env)
     
    3633  numfailures += owl_obarray_regtest();
    3734  numfailures += owl_editwin_regtest();
    38 #ifdef OWL_ENABLE_ZCRYPT
    39   numfailures += owl_zcrypt_regtest();
    40 #endif
    4135  if (numfailures) {
    4236      fprintf(stderr, "# *** WARNING: %d failures total\n", numfailures);
     
    367361  return numfailed;
    368362}
    369 
    370 #ifdef OWL_ENABLE_ZCRYPT
    371 int owl_zcrypt_regtest(void)
    372 {
    373   int numfailed = 0;
    374   char *encrypted, *decrypted;
    375 
    376   printf("# BEGIN testing owl_zcrypt\n");
    377 
    378   encrypted = owl_zcrypt_encrypt_with_key("Hello, world!", "seekritkey");
    379   FAIL_UNLESS("zcrypt encrypt", strcmp(encrypted, "TLJMKQSIGKSJRIJRSIIPIJFFULKRJSPK") == 0);
    380   decrypted = owl_zcrypt_decrypt_with_key(encrypted, "seekritkey");
    381   FAIL_UNLESS("zcrypt decrypt", strcmp(decrypted, "Hello, world!") == 0);
    382   owl_free(decrypted);
    383   owl_free(encrypted);
    384 
    385   printf("# END testing owl_zcrypt (%d failures)\n", numfailed);
    386 
    387   return numfailed;
    388 }
    389 #endif
Note: See TracChangeset for help on using the changeset viewer.