pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: pkg/47618



The following reply was made to PR pkg/47618; it has been noted by GNATS.

From: Aran Clauson <aran%100acres.us@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: pkg/47618
Date: Mon, 01 Jul 2013 09:15:06 -0700 (PDT)

 All,
 
 I am not proud of this patch, but it works for me on 6.99.22.  The kernel 
module
 does not get installed properly.  Instead of /stand/.../mppe/mppe.kmod it is
 installed in /usr/pkg/stand/.../mppe.kmod.  I had to copy it to the correct
 location and it worked.  Also, I included a full copy of the arc4 routines in
 the module.  I figured it was better than forcing everyone to include arc4 for
 just one module.  The patch follows:
 
 Aran
 
 
 ? work
 Index: Makefile
 ===================================================================
 RCS file: /cvsroot/pkgsrc/net/mppe-lkm/Makefile,v
 retrieving revision 1.7
 diff -u -r1.7 Makefile
 --- Makefile   1 Jun 2013 22:42:49 -0000       1.7
 +++ Makefile   1 Jul 2013 15:59:30 -0000
 @@ -1,8 +1,8 @@
 -# $NetBSD: Makefile,v 1.7 2013/06/01 22:42:49 dholland Exp $
 +#$NetBSD: Makefile,v 1.7 2013/06/01 22:42:49 dholland Exp $
  
  DISTNAME=     kernel_ppp_mppe-0.0.4-src
  PKGNAME=      mppe-lkm-0.0.4
 -PKGREVISION=  2
 +PKGREVISION=  3
  CATEGORIES=   net
  MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=poptop/}
  EXTRACT_SUFX= .tgz
 @@ -14,12 +14,12 @@
  
  NO_CONFIGURE= yes
  
 -ONLY_FOR_PLATFORM=    NetBSD-[12345]*-*
 -MAKE_ENV+=    KMODDIR=${PREFIX}/lkm
 +ONLY_FOR_PLATFORM=    NetBSD-[6]*-*
  WRKSRC=               ${WRKDIR}/mppe-lkm
  KPM_SRC=      ${WRKDIR}/${DISTNAME:C/-src$//}
  
 -INSTALLATION_DIRS=    lkm
 +INSTALLATION_DIRS=    stand
 +
  
  post-extract:
        @${CP} -R ${FILESDIR} ${WRKSRC}
 @@ -27,4 +27,8 @@
        @${CP} -p ${KPM_SRC}/ppp-comp-local.h ${KPM_SRC}/ppp_mppe_compress.c \
                ${WRKSRC}
  
 +post-install:
 +      @${CP} -R ${DESTDIR}/stand ${DESTDIR}/${PREFIX:Q}
 +
  .include "../../mk/bsd.pkg.mk"
 +
 Index: PLIST
 ===================================================================
 RCS file: /cvsroot/pkgsrc/net/mppe-lkm/PLIST,v
 retrieving revision 1.1.1.1
 diff -u -r1.1.1.1 PLIST
 --- PLIST      2 Jan 2005 02:52:56 -0000       1.1.1.1
 +++ PLIST      1 Jul 2013 15:59:30 -0000
 @@ -1,2 +1,2 @@
 -@comment $NetBSD: PLIST,v 1.1.1.1 2005/01/02 02:52:56 cube Exp $
 -lkm/mppe.o
 +@comment $NetBSD$
 +stand/amd64/6.99.22/modules/mppe/mppe.kmod
 Index: distinfo
 ===================================================================
 RCS file: /cvsroot/pkgsrc/net/mppe-lkm/distinfo,v
 retrieving revision 1.4
 diff -u -r1.4 distinfo
 --- distinfo   29 Apr 2005 11:41:29 -0000      1.4
 +++ distinfo   1 Jul 2013 15:59:30 -0000
 @@ -3,4 +3,6 @@
  SHA1 (kernel_ppp_mppe-0.0.4-src.tgz) = 
37dc2487c760a78eb02585690bd6a1708d8dbaa2
  RMD160 (kernel_ppp_mppe-0.0.4-src.tgz) = 
37ebac9263da2cc5e90844d7cc823d0fbcb3baf4
  Size (kernel_ppp_mppe-0.0.4-src.tgz) = 54194 bytes
 -SHA1 (patch-aa) = 9b1571fe86611f09b0eba290649fd6b91c6cb961
 +SHA1 (patch-Makefile) = c74335208b31809b8bf70f52dee0f1a1301c8d30
 +SHA1 (patch-aa) = fd578ca534afcf5f6415c9cd47397098cdb1f2d8
 +SHA1 (patch-lkm__mppe.c) = b4a911d347d529f5e27da83740fa620c3a71064e
 Index: patches/patch-Makefile
 ===================================================================
 RCS file: patches/patch-Makefile
 diff -N patches/patch-Makefile
 --- /dev/null  1 Jan 1970 00:00:00 -0000
 +++ patches/patch-Makefile     1 Jul 2013 15:59:30 -0000
 @@ -0,0 +1,10 @@
 +$NetBSD$
 +
 +--- Makefile.orig     2013-07-01 03:39:07.000000000 +0000
 ++++ Makefile
 +@@ -5,4 +5,4 @@ MKMAN=        no
 + # We set LDFLAGS because bsd.pkg.mk will put cc specific flags in it.
 + LDFLAGS=
 + 
 +-.include <bsd.kmod.mk>
 ++.include <bsd.kmodule.mk>
 Index: patches/patch-aa
 ===================================================================
 RCS file: /cvsroot/pkgsrc/net/mppe-lkm/patches/patch-aa,v
 retrieving revision 1.3
 diff -u -r1.3 patch-aa
 --- patches/patch-aa   29 Apr 2005 11:41:29 -0000      1.3
 +++ patches/patch-aa   1 Jul 2013 15:59:30 -0000
 @@ -1,6 +1,6 @@
  $NetBSD: patch-aa,v 1.3 2005/04/29 11:41:29 cube Exp $
  
 ---- ppp_mppe_compress.c.orig  2004-05-31 07:31:51.000000000 +0200
 +--- ppp_mppe_compress.c.orig  2004-05-31 05:31:51.000000000 +0000
  +++ ppp_mppe_compress.c
  @@ -5,6 +5,8 @@
    * By Frank Cusack <frank%google.com@localhost>.
 @@ -11,7 +11,7 @@
    *
    * Permission to use, copy, modify, and distribute this software and its
    * documentation is hereby granted, provided that the above copyright
 -@@ -18,19 +20,35 @@
 +@@ -18,19 +20,34 @@
    *                    deprecated in 2.6
    */
   
 @@ -35,7 +35,6 @@
  +#include <net/ppp-comp.h>
  +
  +#include <sys/sha1.h>
 -+#include <crypto/arc4/arc4.h>
  +
  +#if __NetBSD_Version__ < 299001600
  +/* MPPE definitions were included into the kernel source */
 @@ -58,7 +57,7 @@
   
   /*
    * State for an MPPE (de)compressor.
 -@@ -38,8 +56,8 @@
 +@@ -38,8 +55,8 @@
   typedef struct ppp_mppe_state {
       unsigned char    master_key[MPPE_MAX_KEY_LEN];
       unsigned char    session_key[MPPE_MAX_KEY_LEN];
 @@ -69,7 +68,7 @@
                                        /* NB: 128-bit == 16, 40-bit == 8! */
                                        /* If we want to support 56-bit,   */
                                        /* the unit has to change to bits  */
 -@@ -84,12 +102,12 @@ static int       mppe_comp_init __P((void *sta
 +@@ -84,16 +101,81 @@ static int       mppe_comp_init __P((void *sta
   static int   mppe_decomp_init __P((void *state, unsigned char *options,
                                      int optlen, int unit,
                                      int hdrlen, int mru, int debug));
 @@ -87,7 +86,76 @@
   static void  mppe_comp_reset __P((void *state));
   static void  mppe_decomp_reset __P((void *state));
   static void  mppe_comp_stats __P((void *state, struct compstat *stats));
 -@@ -104,7 +122,7 @@ GetNewKeyFromSHA(unsigned char *MasterKe
 + 
 ++struct arc4_ctx {
 ++        unsigned int    x;
 ++        unsigned int    y;
 ++        unsigned int    state[256];
 ++        /* was unsigned char, changed to int for performance -- onoe */
 ++};
 ++
 ++static int
 ++arc4_ctxlen(void)
 ++{
 ++        return sizeof(struct arc4_ctx);
 ++}
 ++static void
 ++arc4_setkey(void *ctxp, const u_char *key, u_int keylen)
 ++{
 ++        struct arc4_ctx *ctx = ctxp;
 ++        unsigned int i, t, u, ki, si;
 ++        unsigned int *state;
 ++
 ++        state = ctx->state;
 ++        ctx->x = 0;
 ++        ctx->y = 0;
 ++        for (i = 0; i < 256; i++)
 ++               state[i] = i;
 ++        ki = si = 0;
 ++        for (i = 0; i < 256; i++) {
 ++                t = state[i];
 ++                si = (si + key[ki] + t) & 0xff;
 ++                u = state[si];
 ++                state[si] = t;
 ++                state[i] = u;
 ++                if (++ki >= keylen)
 ++                        ki = 0;
 ++        }
 ++}
 ++
 ++static void
 ++arc4_encrypt(void *ctxp, u_char *dst, const u_char *src, int len)
 ++{
 ++        struct arc4_ctx *ctx = ctxp;
 ++        unsigned int x, y, sx, sy;
 ++        unsigned int *state;
 ++        const unsigned char *endsrc;
 ++
 ++        state = ctx->state;
 ++        x = ctx->x;
 ++        y = ctx->y;
 ++        for (endsrc = src + len; src != endsrc; src++, dst++) {
 ++                x = (x + 1) & 0xff;
 ++                sx = state[x];
 ++                y = (sx + y) & 0xff;
 ++                state[x] = sy = state[y];
 ++                state[y] = sx;
 ++                *dst = *src ^ state[(sx + sy) & 0xff];
 ++        }
 ++        ctx->x = x;
 ++        ctx->y = y;
 ++}
 ++
 ++static void
 ++arc4_decrypt(void *ctxp, u_char *dst, const u_char *src, int len)
 ++{
 ++
 ++        arc4_encrypt(ctxp, dst, src, len);
 ++}
 + 
 + /*
 +  * Key Derivation, from RFC 3078, RFC 3079.
 +@@ -104,7 +186,7 @@ GetNewKeyFromSHA(unsigned char *MasterKe
                 unsigned SessionKeyLength, unsigned char *InterimKey)
   {
       SHA1_CTX Context;
 @@ -96,7 +164,7 @@
   
       unsigned char SHApad1[40] =
       { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 -@@ -119,12 +137,12 @@ GetNewKeyFromSHA(unsigned char *MasterKe
 +@@ -119,12 +201,12 @@ GetNewKeyFromSHA(unsigned char *MasterKe
   
       /* assert(SessionKeyLength <= SHA1_SIGNATURE_SIZE); */
   
 @@ -115,7 +183,7 @@
   
       memcpy(InterimKey, Digest, SessionKeyLength);
   }
 -@@ -141,9 +159,9 @@ mppe_rekey(ppp_mppe_state *state, int in
 +@@ -141,9 +223,9 @@ mppe_rekey(ppp_mppe_state *state, int in
       GetNewKeyFromSHA(state->master_key, state->session_key,
                     state->keylen, InterimKey);
       if (!initial_key) {
 @@ -128,7 +196,7 @@
       } else {
        memcpy(state->session_key, InterimKey, state->keylen);
       }
 -@@ -153,7 +171,7 @@ mppe_rekey(ppp_mppe_state *state, int in
 +@@ -153,7 +235,7 @@ mppe_rekey(ppp_mppe_state *state, int in
        state->session_key[1] = 0x26;
        state->session_key[2] = 0x9e;
       }
 @@ -137,7 +205,7 @@
   }
   
   
 -@@ -170,15 +188,12 @@ mppe_alloc(unsigned char *options, int o
 +@@ -170,15 +252,12 @@ mppe_alloc(unsigned char *options, int o
        || options[1] != CILEN_MPPE)
        return NULL;
   
 @@ -155,7 +223,7 @@
       memset(state, 0, sizeof(*state));
   
       /* Save keys. */
 -@@ -201,12 +216,10 @@ mppe_free(void *arg)
 +@@ -201,12 +280,10 @@ mppe_free(void *arg)
       ppp_mppe_state *state = (ppp_mppe_state *) arg;
   
       if (state) {
 @@ -171,7 +239,7 @@
       }
   }
   
 -@@ -232,12 +245,16 @@ mppe_init(void *arg, unsigned char *opti
 +@@ -232,12 +309,16 @@ mppe_init(void *arg, unsigned char *opti
       else if (mppe_opts & MPPE_OPT_40)
        state->keylen = 8;
       else {
 @@ -189,7 +257,7 @@
       /* Generate the initial session key. */
       mppe_rekey(state, 1);
   
 -@@ -246,7 +263,7 @@ mppe_init(void *arg, unsigned char *opti
 +@@ -246,7 +327,7 @@ mppe_init(void *arg, unsigned char *opti
        char mkey[sizeof(state->master_key) * 2 + 1];
        char skey[sizeof(state->session_key) * 2 + 1];
   
 @@ -198,7 +266,7 @@
               unit, (state->keylen == 16)? 128: 40,
               (state->stateful)? "stateful": "stateless");
   
 -@@ -254,7 +271,7 @@ mppe_init(void *arg, unsigned char *opti
 +@@ -254,7 +335,7 @@ mppe_init(void *arg, unsigned char *opti
            sprintf(mkey + i * 2, "%.2x", state->master_key[i]);
        for (i = 0; i < sizeof(state->session_key); i++)
            sprintf(skey + i * 2, "%.2x", state->session_key[i]);
 @@ -207,7 +275,7 @@
               debugstr, unit, mkey, skey);
       }
   
 -@@ -311,30 +328,75 @@ mppe_comp_reset(void *arg)
 +@@ -311,30 +392,75 @@ mppe_comp_reset(void *arg)
    * MPPE_OVHD + 2 bytes larger than the input.
    */
   int
 @@ -289,7 +357,7 @@
       /*
        * Copy over the PPP header and set control bits.
        */
 -@@ -346,7 +408,7 @@ mppe_compress(void *arg, unsigned char *
 +@@ -346,7 +472,7 @@ mppe_compress(void *arg, unsigned char *
   
       state->ccount = (state->ccount + 1) % MPPE_CCOUNT_SPACE;
       if (state->debug >= 7)
 @@ -298,7 +366,7 @@
               state->ccount);
       obuf[0] = state->ccount >> 8;
       obuf[1] = state->ccount & 0xff;
 -@@ -356,19 +418,62 @@ mppe_compress(void *arg, unsigned char *
 +@@ -356,19 +482,62 @@ mppe_compress(void *arg, unsigned char *
        (state->bits & MPPE_BIT_FLUSHED)) {     /* CCP Reset-Request  */
        /* We must rekey */
        if (state->debug && state->stateful)
 @@ -365,7 +433,7 @@
   
       state->stats.unc_bytes += isize;
       state->stats.unc_packets++;
 -@@ -413,56 +518,50 @@ mppe_decomp_reset(void *arg)
 +@@ -413,56 +582,50 @@ mppe_decomp_reset(void *arg)
    * Decompress (decrypt) an MPPE packet.
    */
   int
 @@ -442,7 +510,7 @@
        state->sanity_errors += 100;
        sanity = 1;
       }
 -@@ -531,6 +630,46 @@ mppe_decompress(void *arg, unsigned char
 +@@ -531,6 +694,46 @@ mppe_decompress(void *arg, unsigned char
            mppe_rekey(state, 0);
       }
   
 @@ -489,7 +557,7 @@
       /*
        * Fill in the first part of the PPP header.  The protocol field
        * comes from the decrypted data.
 -@@ -538,15 +677,17 @@ mppe_decompress(void *arg, unsigned char
 +@@ -538,15 +741,17 @@ mppe_decompress(void *arg, unsigned char
       obuf[0] = PPP_ADDRESS(ibuf);     /* +1 */
       obuf[1] = PPP_CONTROL(ibuf);     /* +1 */
       obuf  += 2;
 @@ -508,7 +576,7 @@
   
       /*
        * Do PFC decompression.
 -@@ -557,13 +698,56 @@ mppe_decompress(void *arg, unsigned char
 +@@ -557,13 +762,56 @@ mppe_decompress(void *arg, unsigned char
        obuf[1] = obuf[0];
        obuf[0] = 0;
        obuf++;
 @@ -569,7 +637,7 @@
       state->stats.unc_packets++;
       state->stats.comp_bytes += isize;
       state->stats.comp_packets++;
 -@@ -571,7 +755,7 @@ mppe_decompress(void *arg, unsigned char
 +@@ -571,7 +819,7 @@ mppe_decompress(void *arg, unsigned char
       /* good packet credit */
       state->sanity_errors >>= 1;
   
 @@ -578,7 +646,7 @@
   }
   
   /*
 -@@ -581,29 +765,23 @@ mppe_decompress(void *arg, unsigned char
 +@@ -581,29 +829,23 @@ mppe_decompress(void *arg, unsigned char
    * packet.  (How to do this?)
    */
   static void
 @@ -616,7 +684,7 @@
   /*
    * Procedures exported to if_ppp.c.
    */
 -@@ -623,34 +801,3 @@ struct compressor ppp_mppe = {
 +@@ -623,34 +865,3 @@ struct compressor ppp_mppe = {
       mppe_incomp,     /* incomp */
       mppe_comp_stats, /* decomp_stat */
   };
 Index: patches/patch-lkm__mppe.c
 ===================================================================
 RCS file: patches/patch-lkm__mppe.c
 diff -N patches/patch-lkm__mppe.c
 --- /dev/null  1 Jan 1970 00:00:00 -0000
 +++ patches/patch-lkm__mppe.c  1 Jul 2013 15:59:30 -0000
 @@ -0,0 +1,105 @@
 +$NetBSD$
 +
 +--- lkm_mppe.c.orig   2013-07-01 03:39:07.000000000 +0000
 ++++ lkm_mppe.c
 +@@ -33,82 +33,33 @@
 + #include <sys/systm.h>
 + #include <sys/conf.h>
 + #include <sys/exec.h>
 +-#include <sys/lkm.h>
 ++#include <sys/module.h>
 ++#include <net/if.h>
 ++#include <net/ppp_defs.h>
 ++#include <net/if_ppp.h>
 + 
 + #include <sys/tty.h>
 + #include <sys/ttycom.h>
 + 
 +-MOD_MISC("mppe");
 +-
 + extern struct compressor ppp_mppe;
 + extern struct compressor *ppp_compressors[];
 + extern int mppe_in_use;
 + 
 +-int  mppe_lkmentry __P((struct lkm_table *, int, int));
 +-int  mppe_lkm_load __P((struct lkm_table *, int));
 +-
 +-int
 +-mppe_lkm_load(lkmtp, cmd)
 +-             struct lkm_table *lkmtp;
 +-             int cmd;
 +-{
 +-     int i;
 +-     for(i=0;i<7;i++) {
 +-             if (ppp_compressors[i] == NULL) {
 +-                     ppp_compressors[i] = &ppp_mppe;
 +-                     ppp_compressors[i+1] = NULL;
 +-                     break;
 +-             }
 +-     }
 +-     if (i==7) {
 +-             printf("MPPE: no free compressor slots\n");
 +-             return ENODEV;
 +-     }
 +-
 +-     printf("MPPE: loaded into ppp at slot %d\n",i);
 +-
 +-     return 0;
 +-}
 +-
 +-int
 +-mppe_lkm_unload(lkmtp, cmd)
 +-             struct lkm_table *lkmtp;
 +-             int cmd;
 +-{
 +-     int i;
 +-     if (mppe_in_use) {
 +-             printf("MPPE: cannot unload lkm while in use (count=%d)\n",
 +-                     mppe_in_use);
 +-             return EBUSY;
 +-     }
 +-     for(i=0;ppp_compressors[i];i++) {
 +-             if (ppp_compressors[i] == &ppp_mppe) break;
 +-     }
 +-     if (ppp_compressors[i] == NULL) {
 +-             printf("MPPE: cannot find mppe in ppp compressor slots\n");
 +-             return ENODEV;
 +-     }
 +-     printf("MPPE: unloaded from ppp at slot %d\n",i);
 +-     do {
 +-             ppp_compressors[i] = ppp_compressors[i+1];
 +-     } while(ppp_compressors[i++]);
 +-
 +-     return 0;
 +-}
 ++MODULE(MODULE_CLASS_MISC, mppe_lkm,NULL);
 + 
 +-int
 +-mppe_lkm_stat(lkmtp, cmd)
 +-             struct lkm_table *lkmtp;
 +-             int cmd;
 ++static int
 ++mppe_lkm_modcmd(modcmd_t cmd, void *arg)
 + {
 +-     printf("MPPE: use count %d\n",mppe_in_use);
 +-     return 0;
 ++     switch (cmd) {
 ++     case MODULE_CMD_INIT:
 ++             return ppp_register_compressor(&ppp_mppe, 1);
 ++     case MODULE_CMD_FINI:
 ++             return ppp_unregister_compressor(&ppp_mppe,1);
 ++        case MODULE_CMD_STAT:
 ++             return 0;
 ++     default:
 ++             return ENOTTY;
 ++        }
 ++     return ENOTTY;
 + }
 + 
 +-int
 +-mppe_lkmentry(lkmtp, cmd, ver)
 +-     struct lkm_table *lkmtp;
 +-     int cmd, ver;
 +-{
 +-     DISPATCH(lkmtp, cmd, ver, mppe_lkm_load,mppe_lkm_unload,mppe_lkm_stat);
 +-}
 


Home | Main Index | Thread Index | Old Index