source: WorldVistAEHR/trunk/r/MAILMAN-XM/XMPSEC.m@ 1582

Last change on this file since 1582 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 4.2 KB
Line 
1XMPSEC ;ISC-SF/GMB-PackMan Security ;04/17/2002 11:13
2 ;;8.0;MailMan;;Jun 28, 2002
3 ; Code rewritten. Originally (ISC-WASH/GM/CAP)
4 ; Includes the former ^XMASEC (ISC-WASH/GM)
5 N I,XMTVAL,XMSTR
6 W !,"This message has been secured!"
7 S XMPASS=1
8 I '$D(XMSECURE),'$$KEYOK^XMJMCODE(XMZ,$P(XMA0,U,10)) S XMPASS=0 Q
9 W !,"Checking the package's integrity... (This may take some time.)",!
10 S I=$O(^XMB(3.9,XMZ,2,.999))
11 I $P(^(I,0),U,3,9999)'=$$ENCSTR^XMJMCODE("$SEC^3") S XMPASS=0 D FAIL Q
12 S I=1,XMTVAL=0
13P0 F S I=$O(^XMB(3.9,XMZ,2,I)) Q:'I D
14 . Q:'$D(^(I,0)) ; naked reference to line above
15 . S XMSTR=^(0) ; naked reference to line above
16 . I $E(XMSTR)="$" D CSCRAM(XMSTR) Q
17 . I 'XMB0 W:$X>75 ! W "." Q
18 . D VAL(XMSTR,.XMTVAL)
19 W !,"<<< DONE >>>",!
20 D:'XMPASS FAIL
21 Q
22VAL(XMSTR,XMTVAL) ;
23 N XMLVAL,I
24 S XMLVAL=0
25 F I=1:1:$L(XMSTR) S XMLVAL=$A(XMSTR,I)*I+XMLVAL
26 S XMTVAL=XMTVAL+XMLVAL+$L(XMSTR)
27 Q
28CSCRAM(XMSTR) ;
29 S XMB0=$S(XMSTR'["TXT":1,1:0)
30 I XMSTR["ROU",$P(XMSTR," ",2)?1"^".AN1"NTEG" D CNTEG Q
31 I XMSTR'["$END"!($E(XMSTR,1,8)="$END TXT"&'XMB0) S XMTVAL=0,XMA0=$P(XMSTR," ",2) Q
32 W "." I $P(XMSTR," ",2)="MESSAGE" Q
33 S XMA0=$S(XMSTR["$GLB":$P(XMSTR,U,2),XMSTR["$GLO":$P(XMSTR,U,2),1:$P($P(XMSTR,U)," ",3))
34 I XMSTR["ROU" W:$X>70 ! W $J($E(XMA0,1,9),10)
35 E W !,$P($E(XMSTR,5,99),U)
36 ;CHECK SUM EVALUTAION
37 Q:$P(XMSTR,U,2,999)=$$ENCSTR^XMJMCODE("$SEC"_U_(XMTVAL+XMPAKMAN("XMRW")))
38 W !!,"******** ",$J(XMA0,10)," has failed !!!!!!!!!!!",!!
39 S (XMTVAL,XMPASS)=0
40 Q
41FAIL ;
42 N XMTEXT,XMTO,XMFROM
43 S:'$D(XMPASS) XMPASS=0
44 S XMTEXT(1,0)="A package with the subject: "_$P(^XMB(3.9,XMZ,0),U)
45 S XMTEXT(2,0)="failed the security check during installation"_$S($D(XMPASS):".",1:", but was installed anyway.")
46 S XMFROM=$P(^XMB(3.9,XMZ,0),U,2)
47 I $G(XMFROM)["<" S XMTO(P($P(XMFROM,"<",2),">"))=""
48 S XMTO(XMDUZ)=""
49 D SENDMSG^XMXSEND(XMDUZ,"Failed Security","XMTEXT",.XMTO)
50 Q
51CHECK ;FROM XMP2
52 Q:XCF'=2
53 I "$DDD$RTN$DIE$DIB$DIP$ROU$GLB$GLO$OPT$HEL$BUL$KEY$PKG$FUN"[$E(X,1,4),X[U D Q
54 . D:'$D(XMPASS) FAIL
55 . S X=$P(X,U)_$P(X,U,2)
56 . S:$P(X," ",2)?.EU1"INIT"&($E(X,1,4)="$ROU") XMINIT=U_$P(X," ",2)
57 I $E(X,1,12)="$END MESSAGE",'$D(XMPASS) D FAIL
58 Q
59CNTEG ; Skip processing XXXINTEG program
60 S XMINTEG=$P(X," ",2)
61 F S I=$O(^XMB(3.9,XMZ,2,I)) Q:'I Q:"$END"[$E(^(I,0),1,4)
62 Q
63PSECURE(XMZ,XMABORT) ; Secure the PackMan message
64 N XMKEY,XMHINT,XMNO,XMSECURE
65 S XMABORT=0
66 D PQSEC(.XMNO,.XMABORT) Q:XMNO!XMABORT
67 D CRE8KEY^XMJMCODE(.XMKEY,.XMHINT,.XMABORT) Q:XMABORT
68 W !!,"Securing the message now. This may take a while.",!
69 D LOADCODE^XMJMCODE
70 D ADJUST^XMJMCODE(.XMKEY)
71 D PSTORE(XMZ,XMKEY,XMHINT)
72 D PSECIT(XMZ)
73 Q
74PQSEC(XMOK,XMABORT) ;
75 N DIR,Y,X
76 S DIR(0)="Y"
77 S DIR("A")="Do you wish to secure this message"
78 S DIR("B")="NO"
79 S DIR("?",1)="If you answer yes, this message will be secured"
80 S DIR("?")="to ensure that what you send is what is actually received."
81 D ^DIR
82 I $D(DIRUT) S XMABORT=1
83 S XMNO='Y
84 Q
85PSTORE(XMZ,XMKEY,XMHINT) ;
86 N XMFDA,XMIENS
87 S XMIENS=XMZ_","
88 S XMFDA(3.9,XMIENS,1.8)=$S($G(XMHINT)="":" ",1:XMHINT)
89 S XMFDA(3.9,XMIENS,1.85)="1"_$$ENCSTR^XMJMCODE(XMKEY)
90 D FILE^DIE("","XMFDA")
91 Q
92PSECIT(XMZ) ;
93 N XMSTR,I,XMTVAL
94 S I=$O(^XMB(3.9,XMZ,2,.999))
95 S XMSTR=^XMB(3.9,XMZ,2,I,0)
96 S XMSTR=$P(XMSTR,"on")_"at "_$P(XMSTR," at ",3)_" on"_$P($P(XMSTR,"on",2)," at",1)
97 S ^XMB(3.9,XMZ,2,I,0)=XMSTR_U_$$ENCSTR^XMJMCODE("$SEC^3")
98 S I=0
99 F S I=$O(^XMB(3.9,XMZ,2,I)) Q:'I D
100 . Q:'$D(^(I,0)) ; naked reference to line above
101 . S XMSTR=^(0) ; naked reference to line above
102 . I $E(XMSTR)="$" D PSCRAM(XMZ,.I,XMSTR,.XMTVAL) Q
103 . D VAL(XMSTR,.XMTVAL)
104 S XMSTR(1)="$END MESSAGE"
105 D MOVEBODY^XMXSEND(XMZ,"XMSTR","A")
106 Q
107PSCRAM(XMZ,I,XMSTR,XMTVAL) ;
108 I $E(XMSTR,1,4)="$END" S $P(^XMB(3.9,XMZ,2,I,0),U,2)=$$ENCSTR^XMJMCODE("$SEC"_U_(XMTVAL+XMPAKMAN("XMRW"))) Q
109 I $E(XMSTR,1,4)="$ROU" D I $P(XMSTR," ",2)?.AN1"NTEG" D PNTEG(XMZ,.I,XMSTR) Q
110 . W:$X>70 !
111 . W $J($P(XMSTR," ",2),10)
112 S XMTVAL=0
113 S $P(^XMB(3.9,XMZ,2,I,0)," ",2)=$S($E(XMSTR,1,4)'="$KID":U,1:"")_$P(XMSTR," ",2)
114 Q
115PNTEG(XMZ,I,XMSTR) ;
116 S $P(^XMB(3.9,XMZ,2,I,0)," ",2)=U_$P(XMSTR," ",2)
117 F S I=$O(^XMB(3.9,XMZ,2,I)) Q:'I S XMSTR=^(I,0) Q:"$END"[$E(XMSTR_" ",1,4) D
118 . S:XMSTR?.UN1" ;;".N $P(^XMB(3.9,XMZ,2,I,0),";",3)=$$ENCSTR^XMJMCODE($P(XMSTR,";",3)+XMPAKMAN("XMRW"))
119 Q
Note: See TracBrowser for help on using the repository browser.