|
|
1.1 ! root 1: /* ssapexec.c - SPM: exec */ ! 2: ! 3: #ifndef lint ! 4: static char *rcsid = "$Header: /f/osi/ssap/RCS/ssapexec.c,v 7.0 89/11/23 22:25:26 mrose Rel $"; ! 5: #endif ! 6: ! 7: /* ! 8: * $Header: /f/osi/ssap/RCS/ssapexec.c,v 7.0 89/11/23 22:25:26 mrose Rel $ ! 9: * ! 10: * ! 11: * $Log: ssapexec.c,v $ ! 12: * Revision 7.0 89/11/23 22:25:26 mrose ! 13: * Release 6.0 ! 14: * ! 15: */ ! 16: ! 17: /* ! 18: * NOTICE ! 19: * ! 20: * Acquisition, use, and distribution of this module and related ! 21: * materials are subject to the restrictions of a license agreement. ! 22: * Consult the Preface in the User's Manual for the full terms of ! 23: * this agreement. ! 24: * ! 25: */ ! 26: ! 27: ! 28: /* LINTLIBRARY */ ! 29: ! 30: #include <stdio.h> ! 31: #include "spkt.h" ! 32: #include "isoservent.h" ! 33: #include "tailor.h" ! 34: ! 35: /* SERVER only */ ! 36: ! 37: int SExec (ts, si, hook, setperms) ! 38: struct TSAPstart *ts; ! 39: struct SSAPindication *si; ! 40: IFP hook, ! 41: setperms; ! 42: { ! 43: int sd; ! 44: char *cp; ! 45: register struct isoservent *is; ! 46: register struct ssapkt *s; ! 47: struct TSAPdata txs; ! 48: register struct TSAPdata *tx = &txs; ! 49: struct TSAPdisconnect tds; ! 50: register struct TSAPdisconnect *td = &tds; ! 51: ! 52: if (TReadRequest (sd = ts -> ts_sd, tx, NOTOK, td) == NOTOK) ! 53: return ts2sslose (si, "TReadRequest", td); ! 54: ! 55: s = tsdu2spkt (&tx -> tx_qbuf, tx -> tx_cc, NULLIP); ! 56: TXFREE (tx); ! 57: ! 58: if (s == NULL || s -> s_errno != SC_ACCEPT) { ! 59: (void) spktlose (sd, si, (s ? s -> s_errno : SC_CONGEST) | SC_REFUSE, ! 60: NULLCP, NULLCP); ! 61: goto out1; ! 62: } ! 63: ! 64: switch (s -> s_code) { ! 65: case SPDU_CN: ! 66: if ((s -> s_mask & SMASK_CN_VRSN) ! 67: && !(s -> s_cn_version & SB_ALLVRSNS)) { ! 68: (void) spktlose (sd, si, SC_VERSION | SC_REFUSE, NULLCP, ! 69: "version mismatch: expecting 0x%x, got 0x%x", ! 70: SB_ALLVRSNS, s -> s_cn_version); ! 71: break; ! 72: } ! 73: ! 74: if ((s -> s_mask & SMASK_CN_CALLED) && s -> s_calledlen > 0) { ! 75: if ((is = getisoserventbyselector ("ssap", s -> s_called, ! 76: s -> s_calledlen)) == NULL) { ! 77: char buffer[BUFSIZ]; ! 78: ! 79: buffer[explode (buffer, (u_char *) s -> s_called, ! 80: s -> s_calledlen)] = NULL; ! 81: (void) spktlose (sd, si, SC_SSAPID | SC_REFUSE, NULLCP, ! 82: "ISO service ssap/%s not found", buffer); ! 83: break; ! 84: } ! 85: } ! 86: else ! 87: if ((is = getisoserventbyname ("presentation", "ssap")) ! 88: == NULL) { ! 89: (void) spktlose (sd, si, SC_SSUSER | SC_REFUSE, NULLCP, ! 90: "default presentation service not found"); ! 91: break; ! 92: } ! 93: ! 94: if (TSaveState (sd, is -> is_tail, td) == NOTOK) { ! 95: (void) spktlose (sd, si, SC_CONGEST | SC_REFUSE, NULLCP, ! 96: NULLCP); ! 97: break; ! 98: } ! 99: cp = *is -> is_tail++; ! 100: if ((*is -> is_tail++ = spkt2str (s)) == NULL) { ! 101: (void) spktlose (sd, si, SC_CONGEST | SC_REFUSE, NULLCP, ! 102: NULLCP); ! 103: break; ! 104: } ! 105: *is -> is_tail = NULL; ! 106: ! 107: switch (hook ? (*hook) (is, si) : OK) { ! 108: case NOTOK: ! 109: return NOTOK; ! 110: ! 111: case DONE: ! 112: return OK; ! 113: ! 114: case OK: ! 115: default: ! 116: if (setperms) ! 117: (void) (*setperms) (is); ! 118: (void) execv (*is -> is_vec, is -> is_vec); ! 119: SLOG (ssap_log, LLOG_FATAL, *is -> is_vec, ! 120: ("unable to exec")); ! 121: (void) TRestoreState (cp, ts, td); ! 122: (void) spktlose (ts -> ts_sd, si, SC_CONGEST | SC_REFUSE, ! 123: *is -> is_vec, "unable to exec"); ! 124: break; ! 125: } ! 126: break; ! 127: ! 128: default: ! 129: (void) spktlose (sd, si, SC_PROTOCOL | SC_REFUSE, NULLCP, ! 130: "session protocol mangled: expecting 0x%x, got 0x%x", ! 131: SPDU_CN, s -> s_code); ! 132: break; ! 133: } ! 134: ! 135: out1: ; ! 136: freespkt (s); ! 137: ! 138: return NOTOK; ! 139: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.