void ktest_make_sample_etype_info2(krb5_etype_info_entry ***p) { krb5_etype_info_entry **info; int i, len; char *str; info = ealloc(4 * sizeof(krb5_etype_info_entry *)); for (i = 0; i < 3; i++) { info[i] = ealloc(sizeof(krb5_etype_info_entry)); info[i]->etype = i; len = asprintf(&str, "Morton's #%d", i); if (len < 0) abort(); info[i]->salt = (krb5_octet *)str; info[i]->length = (unsigned int)len; len = asprintf(&info[i]->s2kparams.data, "s2k: %d", i); if (len < 0) abort(); info[i]->s2kparams.length = (unsigned int) len; info[i]->magic = KV5M_ETYPE_INFO_ENTRY; } free(info[1]->salt); info[1]->length = KRB5_ETYPE_NO_SALT; info[1]->salt = 0; *p = info; }
void add_edge (int a, int b) { edge* e1 = ealloc (); e1->a = a, e1->b = b, e1->next = ve[a], ve[a] = e1; edge* e2 = ealloc (); e2->a = b, e2->b = a, e2->next = ve[b], ve[b] = e2; e1->back = e2, e2->back = e1; }
edge* add_edge (int a, int b, int i) { edge* e = ealloc (); e->a = a, e->b = b, e->ok = true, e->next = ve[a], ve[a] = e, e->i = i; edge* e2 = ealloc (); e2->a = b, e2->b = a, e2->ok = true, e2->next = ve[b], ve[b] = e2, e2->i = i; e->back = e2, e2->back = e; }
edge* add_edge (int a, int b, int p) { edge* e = ealloc (); e->b = b, e->p = p, e->f = 0, e->next = ve[a], ve[a] = e; edge* e2 = ealloc (); b, e2->b = a, e2->p = 0, e2->f = 0, e2->next = ve[b], ve[b] = e2; e->back = e2, e2->back = e; }
edge* add_edge (int a, int b, int c) { edge* e = ealloc (); e->a = a, e->b = b, e->c = c, e->next = ve[a], ve[a] = e; edge* e2 = ealloc (); e2->a = b, e2->b = a, e2->c = c, e2->next = ve[b], ve[b] = e2; e->back = e2, e2->back = e; }
void ktest_make_sample_fast_response(krb5_fast_response *p) { ktest_make_sample_pa_data_array(&p->padata); p->strengthen_key = ealloc(sizeof(krb5_keyblock)); ktest_make_sample_keyblock(p->strengthen_key); p->finished = ealloc(sizeof(krb5_fast_finished)); ktest_make_sample_fast_finished(p->finished); p->nonce = SAMPLE_NONCE; }
void ktest_make_minimal_pa_otp_challenge(krb5_pa_otp_challenge *p) { memset(p, 0, sizeof(*p)); krb5_data_parse(&p->nonce, "minnonce"); p->tokeninfo = ealloc(2 * sizeof(*p->tokeninfo)); p->tokeninfo[0] = ealloc(sizeof(*p->tokeninfo[0])); ktest_make_minimal_otp_tokeninfo(p->tokeninfo[0]); p->tokeninfo[1] = NULL; }
extern char *which(char *name, bool verbose) { static char *test = NULL; static size_t testlen = 0; List *path; int len; if (name == NULL) /* no filename? can happen with "> foo" as a command */ return NULL; if (!initialized) { initialized = TRUE; uid = geteuid(); gid = getegid(); #if HAVE_GETGROUPS #if HAVE_POSIX_GETGROUPS ngroups = getgroups(0, (GETGROUPS_T *)0); if (ngroups < 0) { uerror("getgroups"); rc_exit(1); } #else ngroups = NGROUPS; #endif if (ngroups) { gidset = ealloc(ngroups * sizeof(GETGROUPS_T)); getgroups(ngroups, gidset); } #endif } if (isabsolute(name)) /* absolute pathname? */ return rc_access(name, verbose) ? name : NULL; len = strlen(name); for (path = varlookup("path"); path != NULL; path = path->n) { size_t need = strlen(path->w) + len + 2; /* one for null terminator, one for the '/' */ if (testlen < need) { efree(test); test = ealloc(testlen = need); } if (*path->w == '\0') { strcpy(test, name); } else { strcpy(test, path->w); if (!streq(test, "/")) /* "//" is special to POSIX */ strcat(test, "/"); strcat(test, name); } if (rc_access(test, FALSE)) return test; } if (verbose) { char *n = protect(name); fprint(2, RC "cannot find `%s'\n", n); efree(n); } return NULL; }
void ktest_make_sample_sam_challenge_2(krb5_sam_challenge_2 *p) { /* Need a valid DER sequence encoding here; this one contains the OCTET * STRING "challenge". */ krb5_data_parse(&p->sam_challenge_2_body, "\x30\x0B\x04\x09" "challenge"); p->sam_cksum = ealloc(2 * sizeof(krb5_checksum *)); p->sam_cksum[0] = ealloc(sizeof(krb5_checksum)); ktest_make_sample_checksum(p->sam_cksum[0]); p->sam_cksum[1] = NULL; }
void ktest_make_sample_pa_data_array(krb5_pa_data ***pad) { int i; *pad = ealloc(3 * sizeof(krb5_pa_data *)); for (i = 0; i <= 1; i++) { (*pad)[i] = ealloc(sizeof(krb5_pa_data)); ktest_make_sample_pa_data((*pad)[i]); } (*pad)[2] = NULL; }
void ktest_make_sample_authorization_data(krb5_authdata ***ad) { int i; *ad = ealloc(3 * sizeof(krb5_authdata *)); for (i = 0; i <= 1; i++) { (*ad)[i] = ealloc(sizeof(krb5_authdata)); ktest_make_sample_authdata((*ad)[i]); } (*ad)[2] = NULL; }
void ktest_make_sample_addresses(krb5_address ***caddrs) { int i; *caddrs = ealloc(3 * sizeof(krb5_address *)); for (i = 0; i < 2; i++) { (*caddrs)[i] = ealloc(sizeof(krb5_address)); ktest_make_sample_address((*caddrs)[i]); } (*caddrs)[2] = NULL; }
extern void inityy() { newline = FALSE; w = NW; hq = NULL; /* return memory to the system if the buffer got too large */ if (bufsize > BUFMAX && realbuf != NULL) { efree(realbuf); bufsize = BUFSIZE; realbuf = ealloc(bufsize); } else if (realbuf == NULL) realbuf = ealloc(bufsize); }
void ktest_make_sample_priv_enc_part(krb5_priv_enc_part *pep) { ktest_make_sample_data(&(pep->user_data)); pep->timestamp = SAMPLE_TIME; pep->usec = SAMPLE_USEC; pep->seq_number = SAMPLE_SEQ_NUMBER; pep->s_address = ealloc(sizeof(krb5_address)); ktest_make_sample_address(pep->s_address); pep->r_address = ealloc(sizeof(krb5_address)); ktest_make_sample_address(pep->r_address); }
void ktest_make_sample_sequence_of_ticket(krb5_ticket ***sot) { int i; *sot = ealloc(3 * sizeof(krb5_ticket *)); for (i = 0; i < 2; i++) { (*sot)[i] = ealloc(sizeof(krb5_ticket)); ktest_make_sample_ticket((*sot)[i]); } (*sot)[2] = NULL; }
void ktest_make_sequence_of_cred_info(krb5_cred_info ***soci) { int i; *soci = ealloc(3 * sizeof(krb5_cred_info *)); for (i = 0; i < 2; i++) { (*soci)[i] = ealloc(sizeof(krb5_cred_info)); ktest_make_sample_cred_info((*soci)[i]); } (*soci)[2] = NULL; }
void ktest_make_sample_pa_pk_as_req(krb5_pa_pk_as_req *p) { ktest_make_sample_data(&p->signedAuthPack); p->trustedCertifiers = ealloc(2 * sizeof(krb5_external_principal_identifier *)); p->trustedCertifiers[0] = ealloc(sizeof(krb5_external_principal_identifier)); ktest_make_sample_external_principal_identifier(p->trustedCertifiers[0]); p->trustedCertifiers[1] = NULL; ktest_make_sample_data(&p->kdcPkId); }
void ktest_make_sample_cred_enc_part(krb5_cred_enc_part *cep) { cep->nonce = SAMPLE_NONCE; cep->timestamp = SAMPLE_TIME; cep->usec = SAMPLE_USEC; cep->s_address = ealloc(sizeof(krb5_address)); ktest_make_sample_address(cep->s_address); cep->r_address = ealloc(sizeof(krb5_address)); ktest_make_sample_address(cep->r_address); ktest_make_sequence_of_cred_info(&cep->ticket_info); }
void ktest_make_sample_authenticator(krb5_authenticator *a) { ktest_make_sample_principal(&a->client); a->checksum = ealloc(sizeof(krb5_checksum)); ktest_make_sample_checksum(a->checksum); a->cusec = SAMPLE_USEC; a->ctime = SAMPLE_TIME; a->subkey = ealloc(sizeof(krb5_keyblock)); ktest_make_sample_keyblock(a->subkey); a->seq_number = SAMPLE_SEQ_NUMBER; ktest_make_sample_authorization_data(&a->authorization_data); }
void ktest_make_maximal_pa_otp_challenge(krb5_pa_otp_challenge *p) { krb5_data_parse(&p->nonce, "maxnonce"); krb5_data_parse(&p->service, "testservice"); p->tokeninfo = ealloc(3 * sizeof(*p->tokeninfo)); p->tokeninfo[0] = ealloc(sizeof(*p->tokeninfo[0])); ktest_make_minimal_otp_tokeninfo(p->tokeninfo[0]); p->tokeninfo[1] = ealloc(sizeof(*p->tokeninfo[1])); ktest_make_maximal_otp_tokeninfo(p->tokeninfo[1]); p->tokeninfo[2] = NULL; krb5_data_parse(&p->salt, "keysalt"); krb5_data_parse(&p->s2kparams, "1234"); }
void ktest_make_sample_safe(krb5_safe *s) { ktest_make_sample_data(&s->user_data); s->timestamp = SAMPLE_TIME; s->usec = SAMPLE_USEC; s->seq_number = SAMPLE_SEQ_NUMBER; s->s_address = ealloc(sizeof(krb5_address)); ktest_make_sample_address(s->s_address); s->r_address = ealloc(sizeof(krb5_address)); ktest_make_sample_address(s->r_address); s->checksum = ealloc(sizeof(krb5_checksum)); ktest_make_sample_checksum(s->checksum); }
static List *lglob(List *s, char *p, char *m, size_t slashcount) { List *q, *r, *top, foo; static List slash; static size_t slashsize = 0; if (slashcount + 1 > slashsize) { slash.w = ealloc(slashcount + 1); slashsize = slashcount; } slash.w[slashcount] = '\0'; while (slashcount > 0) slash.w[--slashcount] = '/'; for (top = r = NULL; s != NULL; s = s->n) { q = dmatch(s->w, p, m); if (q != NULL) { foo.w = s->w; foo.m = NULL; foo.n = NULL; if (!(s->w[0] == '/' && s->w[1] == '\0')) /* need to separate */ q = concat(&slash, q); /* dir/name with slash */ q = concat(&foo, q); if (r == NULL) top = r = q; else r->n = q; while (r->n != NULL) r = r->n; } } return top; }
void rattach(void) { Xfs *xf; Xfile *root; Xfsub **xs; chat("attach(fid=%d,uname=\"%s\",aname=\"%s\")...", req->fid, req->uname, req->aname); if(waserror()){ xfile(req->fid, Clunk); nexterror(); } root = xfile(req->fid, Clean); root->qid = (Qid){0, 0, QTDIR}; root->xf = xf = ealloc(sizeof(Xfs)); memset(xf, 0, sizeof(Xfs)); xf->ref = 1; xf->d = getxdata(req->aname); for(xs=xsublist; *xs; xs++) if((*(*xs)->attach)(root) >= 0){ poperror(); xf->s = *xs; xf->rootqid = root->qid; rep->qid = root->qid; return; } error("unknown format"); }
void ktest_make_sample_auth_pack_draft9(krb5_auth_pack_draft9 *p) { ktest_make_sample_pk_authenticator_draft9(&p->pkAuthenticator); p->clientPublicValue = ealloc(sizeof(krb5_subject_pk_info)); ktest_make_sample_subject_pk_info(p->clientPublicValue); }
void ktest_make_sample_last_req_entry(krb5_last_req_entry **lre) { *lre = ealloc(sizeof(krb5_last_req_entry)); (*lre)->lr_type = -5; (*lre)->value = SAMPLE_TIME; }
void ktest_make_sample_iakerb_header(krb5_iakerb_header *ih) { ktest_make_sample_data(&(ih->target_realm)); ih->cookie = ealloc(sizeof(krb5_data)); ktest_make_sample_data(ih->cookie); }
static void ktest_make_sample_dh_rep_info(krb5_dh_rep_info *p) { ktest_make_sample_data(&p->dhSignedData); ktest_make_sample_data(&p->serverDHNonce); p->kdfID = ealloc(sizeof(krb5_data)); ktest_make_sample_data(p->kdfID); }
void ktest_make_sample_pa_data(krb5_pa_data *pad) { pad->pa_type = 13; pad->length = 7; pad->contents = ealloc(7); memcpy(pad->contents, "pa-data", 7); }
void ktest_make_sample_checksum(krb5_checksum *cs) { cs->checksum_type = 1; cs->length = 4; cs->contents = ealloc(4); memcpy(cs->contents,"1234",4); }
void ktest_make_sample_ap_req(krb5_ap_req *ar) { ar->ap_options = SAMPLE_FLAGS; ar->ticket = ealloc(sizeof(krb5_ticket)); ktest_make_sample_ticket(ar->ticket); ktest_make_sample_enc_data(&(ar->authenticator)); }