enum nss_status _nss_map_getgrnam_r( const char *name, struct group *g, char *buffer, size_t buflen, int *errnop) { map_conf_t *conf; if ((conf = read_conf()) == NULL) { return NSS_STATUS_NOTFOUND; } /* If out of memory */ if ((g->gr_name = get_static(&buffer, &buflen, strlen(name) + 1)) == NULL) { return NSS_STATUS_TRYAGAIN; } /* gr_name stay as the name given */ strcpy(g->gr_name, name); if ((g->gr_passwd = get_static(&buffer, &buflen, strlen("x") + 1)) == NULL) { return NSS_STATUS_TRYAGAIN; } strcpy(g->gr_passwd, "x"); g->gr_gid = conf->pw_gid; /* GID_NUMBER; */ free_conf(conf); return NSS_STATUS_SUCCESS; }
enum nss_status _nss_map_getgrgid_r( gid_t gid, struct group *g, char *buffer, size_t buflen, int *errnop) { char * name; /* XXX: The logname hack */ if ( (name = getenv("LOGNAME")) == NULL ) return NSS_STATUS_NOTFOUND; if ((g->gr_name = get_static(&buffer, &buflen, strlen(name) + 1)) == NULL) { return NSS_STATUS_TRYAGAIN; } strcpy(g->gr_name, name); if ((g->gr_passwd = get_static(&buffer, &buflen, strlen("x") + 1)) == NULL) { return NSS_STATUS_TRYAGAIN; } strcpy(g->gr_passwd, "x"); g->gr_gid = gid; g->gr_mem = NULL; return NSS_STATUS_SUCCESS; }
/* fun: _nss_map_getspnam_r * txt: get shadow struct by name mapped to users. */ enum nss_status _nss_map_getspnam_r( const char *name, struct spwd *s, char *buffer, size_t buflen, int *errnop) { /* If out of memory */ if ((s->sp_namp = get_static(&buffer, &buflen, strlen(name) + 1)) == NULL) { return NSS_STATUS_TRYAGAIN; } strcpy(s->sp_namp, name); if ((s->sp_pwdp = get_static(&buffer, &buflen, strlen("!") + 1)) == NULL) { return NSS_STATUS_TRYAGAIN; } strcpy(s->sp_pwdp, LOCKED_PASSWD); s->sp_lstchg = 13571; s->sp_min = 0; s->sp_max = 99999; s->sp_warn = 7; return NSS_STATUS_SUCCESS; }
/* fun: _nss_map_getpwuid * txt: get the passwd struct from uid, for mapped users, the value of user * name is taken from the environment, using the LOGNAME variable. */ enum nss_status _nss_map_getpwuid_r(uid_t uid, struct passwd *p, char *buffer, size_t buflen, int *errnop) { map_conf_t *conf; char * name; /* XXX: The logname hack */ if ( (name = getenv("LOGNAME")) == NULL ) return NSS_STATUS_NOTFOUND; if ((conf = read_conf()) == NULL) { return NSS_STATUS_NOTFOUND; } /* If out of memory */ if ((p->pw_name = get_static(&buffer, &buflen, strlen(name) + 1)) == NULL) { return NSS_STATUS_TRYAGAIN; } /* pw_name stay as the name given */ strcpy(p->pw_name, name); if ((p->pw_passwd = get_static(&buffer, &buflen, strlen("x") + 1)) == NULL) { return NSS_STATUS_TRYAGAIN; } strcpy(p->pw_passwd, "x"); p->pw_uid = conf->pw_uid; /* UID_NUMBER; */ p->pw_gid = conf->pw_gid; /* GID_NUMBER; */ if ((p->pw_gecos = get_static(&buffer, &buflen, strlen(conf->pw_gecos) + 1 )) == NULL) { return NSS_STATUS_TRYAGAIN; } strcpy(p->pw_gecos, conf->pw_gecos); if ((p->pw_dir = get_static(&buffer, &buflen, strlen(conf->pw_dir) + 1 + strlen(name) + 1 )) == NULL) { return NSS_STATUS_TRYAGAIN; } /* XXX: the dirname hack */ strcpy(p->pw_dir, conf->pw_dir); strcat(p->pw_dir,"/"); strcat(p->pw_dir,name); if ((p->pw_shell = get_static(&buffer, &buflen, strlen(conf->pw_shell) + 1 )) == NULL) { return NSS_STATUS_TRYAGAIN; } strcpy(p->pw_shell, conf->pw_shell); free_conf(conf); return NSS_STATUS_SUCCESS; }
static NSS_STATUS fill_grent(struct group *result, struct winbindd_gr *gr, char *gr_mem, char **buffer, size_t *buflen) { fstring name; int i; char *tst; /* Group name */ if ((result->gr_name = get_static(buffer, buflen, strlen(gr->gr_name) + 1)) == NULL) { /* Out of memory */ return NSS_STATUS_TRYAGAIN; } strcpy(result->gr_name, gr->gr_name); /* Password */ if ((result->gr_passwd = get_static(buffer, buflen, strlen(gr->gr_passwd) + 1)) == NULL) { /* Out of memory */ return NSS_STATUS_TRYAGAIN; } strcpy(result->gr_passwd, gr->gr_passwd); /* gid */ result->gr_gid = gr->gr_gid; /* Group membership */ if ((gr->num_gr_mem < 0) || !gr_mem) { gr->num_gr_mem = 0; } /* this next value is a pointer to a pointer so let's align it */ /* Calculate number of extra bytes needed to align on pointer size boundry */ if ((i = (unsigned long)(*buffer) % sizeof(char*)) != 0) i = sizeof(char*) - i; if ((tst = get_static(buffer, buflen, ((gr->num_gr_mem + 1) * sizeof(char *)+i))) == NULL) { /* Out of memory */ return NSS_STATUS_TRYAGAIN; } result->gr_mem = (char **)(tst + i); if (gr->num_gr_mem == 0) { /* Group is empty */ *(result->gr_mem) = NULL; return NSS_STATUS_SUCCESS; } /* Start looking at extra data */ i = 0; while(next_token((char **)&gr_mem, name, ",", sizeof(fstring))) { /* Allocate space for member */ if (((result->gr_mem)[i] = get_static(buffer, buflen, strlen(name) + 1)) == NULL) { /* Out of memory */ return NSS_STATUS_TRYAGAIN; } strcpy((result->gr_mem)[i], name); i++; } /* Terminate list */ (result->gr_mem)[i] = NULL; return NSS_STATUS_SUCCESS; }
static NSS_STATUS fill_pwent(struct passwd *result, struct winbindd_pw *pw, char **buffer, size_t *buflen) { /* User name */ if ((result->pw_name = get_static(buffer, buflen, strlen(pw->pw_name) + 1)) == NULL) { /* Out of memory */ return NSS_STATUS_TRYAGAIN; } strcpy(result->pw_name, pw->pw_name); /* Password */ if ((result->pw_passwd = get_static(buffer, buflen, strlen(pw->pw_passwd) + 1)) == NULL) { /* Out of memory */ return NSS_STATUS_TRYAGAIN; } strcpy(result->pw_passwd, pw->pw_passwd); /* [ug]id */ result->pw_uid = pw->pw_uid; result->pw_gid = pw->pw_gid; /* GECOS */ if ((result->pw_gecos = get_static(buffer, buflen, strlen(pw->pw_gecos) + 1)) == NULL) { /* Out of memory */ return NSS_STATUS_TRYAGAIN; } strcpy(result->pw_gecos, pw->pw_gecos); /* Home directory */ if ((result->pw_dir = get_static(buffer, buflen, strlen(pw->pw_dir) + 1)) == NULL) { /* Out of memory */ return NSS_STATUS_TRYAGAIN; } strcpy(result->pw_dir, pw->pw_dir); /* Logon shell */ if ((result->pw_shell = get_static(buffer, buflen, strlen(pw->pw_shell) + 1)) == NULL) { /* Out of memory */ return NSS_STATUS_TRYAGAIN; } strcpy(result->pw_shell, pw->pw_shell); /* The struct passwd for Solaris has some extra fields which must be initialised or nscd crashes. */ #if HAVE_PASSWD_PW_COMMENT result->pw_comment = ""; #endif #if HAVE_PASSWD_PW_AGE result->pw_age = ""; #endif return NSS_STATUS_SUCCESS; }
static int run_vm(ClipMachine * mp, ClipBlock * bp) { char *func = bp->func; char *modbeg = func - GETLONG(func); char *pp = modbeg + GETLONG(F_OFFS(func, 1, 0, 0)); char code; long len = GETLONG(F_OFFS(func, 2, 0, 0)); char *beg = pp, *end = pp + len; long staticsOffs = GETLONG(modbeg); ClipFile *file = bp->file; ClipVar *statics = file->statics + staticsOffs; int nlocals = GETSHORT(F_OFFS(func, 3, 0, 1)); int nreflocals = GETSHORT(F_OFFS(func, 3, 1, 1)); int ret = 0; int i; #if 0 ClipVar *locals /* = alloca(sizeof(ClipVar) * nlocals) */ ; #endif int maxdeep = GETSHORT(F_OFFS(func, 3, 2, 1)); ClipVar *stack = alloca(sizeof(ClipVar) * maxdeep); char *filename = F_OFFS(modbeg, 6, 6, 0); int nprivates = GETSHORT(F_OFFS(func, 3, 3, 1)); /*int nparams = GETSHORT( F_OFFS(func, 3, 4, 1)); */ /*long *privates = (long *) F_OFFS(func, 3, 5, 1); */ /*long *localDefHashs = (long *) F_OFFS(func, 3 + nprivates, 5, 1); */ int numlocals = nlocals + nreflocals; /*ClipVarDef *ldp, *localDefs = alloca(sizeof(ClipVarDef) * (numlocals+1)); */ /*short *localDefNums = (short *) F_OFFS(func, 3 + nprivates + numlocals, 5, 1); */ char *procname = F_OFFS(func, 3 + nprivates + numlocals, 5 + numlocals, 1 + 1); char *localnames = procname + *(unsigned char *) F_OFFS(func, 3 + nprivates + numlocals, 5 + numlocals, 1) + 1; /*ClipVar *params = alloca( nparams*sizeof(ClipVar)); */ ClipFrame frame = {stack, stack, filename, 0, 0, 0, 0 /*localDefs */ , file->staticDefs, 0, file->hash_names, procname, maxdeep, 0}; unsigned char c, c1; short s, s1; long l, l1; ClipVar *vp; ClipBlock bl; char *trap_pp = 0; int debuglevel = _clip_debuglevel; ClipVarFrame *localvars = 0, *reflocals = 0; int local_locals = 0; if (!nlocals && !nreflocals) { reflocals = frame.localvars = mp->fp->localvars; if (reflocals && reflocals->refcount) reflocals->refcount++; } else if (nreflocals) { localvars = calloc(1, sizeof(ClipVarFrame) + numlocals * sizeof(ClipVar)); localvars->vars = (ClipVar *) (localvars + 1); localvars->refcount = 1; reflocals = frame.localvars = localvars; localvars->size = numlocals; localvars->names = localnames; } else { #if 1 localvars = calloc(1, sizeof(ClipVarFrame) + numlocals * sizeof(ClipVar)); localvars->vars = (ClipVar *) (localvars + 1); localvars->size = numlocals; localvars->refcount = 1; localvars->names = localnames; reflocals = frame.localvars = localvars; #else locals = alloca(sizeof(ClipVar) * numlocals); memset(locals, 0, numlocals * sizeof(ClipVar)); localvars = alloca(sizeof(ClipVarFrame)); localvars->vars = locals; localvars->size = numlocals; localvars->refcount = 0; localvars->names = localnames; reflocals = frame.localvars = localvars; local_locals = 1; #endif } frame.up = mp->fp; mp->fp = &frame; #if 0 localDefs[0].name = numlocals; for (i = 0, ldp = localDefs + 1; i < numlocals; i++, ldp++, localDefHashs++, localDefNums++) { /*int no = *localDefNums; */ long hash = *localDefHashs; ldp->name = hash; /* if (no < 0) ldp->vp = reflocals - no; else */ /*ldp->vp = locals + no; */ ldp->vp = 0; } #endif if (_clip_profiler) _clip_start_profiler(mp); _clip_logg(4, "PCODE call: proc '%s' file '%s' line %d", frame.procname ? frame.procname : "unknown", frame.filename, frame.line); cont: while (pp >= beg && pp < end) { if (debuglevel) _clip_debug(mp); switch ((code = *pp++)) { case CLIP_NOP: break; case CLIP_POP: _clip_pop(mp); break; case CLIP_LINE: frame.line = GET_SHORT(pp); if (debuglevel) _clip_line(mp); break; case CLIP_PUSH_NUM: { int len, dec; double d; s = GET_SHORT(pp); frame.sp->t.memo = 0; frame.sp->t.type = NUMERIC_t; frame.sp->t.flags = F_NONE; get_num(modbeg, s, &d, &len, &dec); frame.sp->t.len = len; frame.sp->t.dec = dec; frame.sp->n.d = d; frame.sp->t.memo = 0; ++frame.sp; } break; case CLIP_PUSH_STR: #if 0 s = GET_SHORT(pp); frame.sp->t.type = CHARACTER_t; frame.sp->t.flags = F_MSTAT; frame.sp->t.memo = 0; get_str(modbeg, s, &(frame.sp->s.str.buf), &(frame.sp->s.str.len)); /* if ( !(mp->flags1 & NOEXPAND_MACRO_FLAG) ) { */ if (strchr(frame.sp->s.str.buf, '&')) _clip_expand_var(mp, frame.sp); /*}*/ ++frame.sp; break; #endif case CLIP_PUSH_STRDUP: s = GET_SHORT(pp); frame.sp->t.type = CHARACTER_t; frame.sp->t.flags = F_NONE; frame.sp->t.memo = 0; { char *str = ""; int len = 0; get_str(modbeg, s, &str, &len); frame.sp->s.str.buf = _clip_memdup(str, len); frame.sp->s.str.len = len; } /* if ( !(mp->flags1 & NOEXPAND_MACRO_FLAG) ) { */ if (strchr(frame.sp->s.str.buf, '&')) _clip_expand_var(mp, frame.sp); /*}*/ ++frame.sp; break; case CLIP_PUSH_NIL: frame.sp->t.type = UNDEF_t; frame.sp->t.flags = F_NONE; ++frame.sp; break; case CLIP_PUSH_TRUE: frame.sp->t.type = LOGICAL_t; frame.sp->t.flags = F_NONE; frame.sp->l.val = 1; ++frame.sp; break; case CLIP_PUSH_FALSE: frame.sp->t.type = LOGICAL_t; frame.sp->t.flags = F_NONE; frame.sp->l.val = 0; ++frame.sp; break; case CLIP_MEMVAR_PUBLIC: l = GET_LONG(pp); _clip_memvar_public(mp, l); break; case CLIP_MEMVAR_SPACE: l = GET_LONG(pp); l1 = GET_LONG(pp); _clip_memvar_space(mp, _clip_space(mp, l), l1, 1); break; case CLIP_MEMVAR_PRIVATE: l = GET_LONG(pp); _clip_memvar_private(mp, l); break; case CLIP_MEMVAR_PUBLIC_POP: l = _clip_pop_hash(mp); _clip_memvar_public(mp, l); break; case CLIP_MEMVAR_SPACE_POP: l = GET_LONG(pp); l1 = _clip_pop_hash(mp); _clip_memvar_space(mp, _clip_space(mp, l), l1, 1); break; case CLIP_MEMVAR_PRIVATE_POP: l = _clip_pop_hash(mp); /*_clip_memvar_private(mp, l);*/ _clip_add_private(mp, l); break; case CLIP_MEMVAR_PARAM: l = GET_LONG(pp); c = GET_BYTE(pp); _clip_memvar_param(mp, l, c); break; case CLIP_PUSH_PARAM: c = GET_BYTE(pp); s = GET_SHORT(pp); _clip_param(mp, c, s); break; case CLIP_PUSH_LOCAL: s = GET_SHORT(pp); if ((ret = _clip_push_local(mp, s))) goto _trap; break; case CLIP_PUSH_REF_LOCAL: s = GET_SHORT(pp); #if 0 frame.sp->p.vp = _clip_ref_local(mp, s); #else { ClipVar *vp1 = _clip_ref_local(mp, s); frame.sp->p.vp = vp1; } #endif break; case CLIP_PUSH_STATIC: s = GET_SHORT(pp); get_static(mp, file, statics, modbeg, s, &vp); if ((ret = _clip_push_static(mp, vp))) goto _trap; break; case CLIP_PUSH_REF_STATIC: s = GET_SHORT(pp); get_static(mp, file, statics, modbeg, s, &vp); frame.sp->p.vp = vp; break; case CLIP_PUSH_MEMVAR: l = GET_LONG(pp); if ((ret = _clip_memvar(mp, l))) goto _trap; break; case CLIP_PUSH_FMEMVAR: l = GET_LONG(pp); if ((ret = _clip_fmemvar(mp, l))) goto _trap; break; case CLIP_PUSH_MEMVARF: l = GET_LONG(pp); if ((ret = _clip_memvarf(mp, l))) goto _trap; break; case CLIP_REF_FMEMVAR: l = GET_LONG(pp); if ((ret = _clip_ref_fmemvar(mp, l))) goto _trap; break; case CLIP_PUSH_REF_MEMVAR: l = GET_LONG(pp); #if 0 frame.sp->p.vp = _clip_ref_memvar(mp, l); #else { ClipVar *vp1 = _clip_ref_memvar(mp, l); frame.sp->p.vp = vp1; } #endif break; case CLIP_PUSH_REF_MEMVAR_NOADD: l = GET_LONG(pp); { ClipVar *vp1 = _clip_ref_memvar_noadd(mp, l); frame.sp->p.vp = vp1; } break; case CLIP_PUSH_PUBLIC: l = GET_LONG(pp); if ((ret = _clip_public(mp, l))) goto _trap; break; case CLIP_PUSH_REF_PUBLIC: l = GET_LONG(pp); #if 0 frame.sp->p.vp = _clip_ref_public(mp, l); #else { ClipVar *vp1 = _clip_ref_public(mp, l); frame.sp->p.vp = vp1; } #endif break; case CLIP_REFMACRO: if ((ret = _clip_refmacro(mp))) goto _trap; break; case CLIP_MAKE_REF: c = GET_BYTE(pp); vp = frame.sp->p.vp; if ((ret = _clip_ref(mp, vp, c))) goto _trap; break; case CLIP_UNREF_ARR: _clip_unref_arr(mp); break; case CLIP_FIELD: l = GET_LONG(pp); l1 = GET_LONG(pp); if ((ret = _clip_field(mp, l, l1))) goto _trap; break; case CLIP_FIELD_POP: l = GET_LONG(pp); l1 = _clip_pop_hash(mp); if ((ret = _clip_field(mp, l, l1))) goto _trap; break; case CLIP_FIELD_POP_NAME: _clip_pop_fieldhash(mp, &l1, &l); if ((ret = _clip_field(mp, l, l1))) goto _trap; break; case CLIP_PUSH_AREA: l = GET_LONG(pp); if ((ret = _clip_push_area(mp, l))) goto _trap; break; case CLIP_PUSH_AREA_POP: l = _clip_pop_hash(mp); if ((ret = _clip_push_area(mp, l))) goto _trap; break; case CLIP_POP_AREA: if ((ret = _clip_pop_area(mp))) goto _trap; break; case CLIP_FUNC: c = GET_BYTE(pp); l = GET_LONG(pp); if ((ret = _clip_func_hash(mp, l, c, 0, reflocals))) goto _trap; break; case CLIP_FUNCR: c = GET_BYTE(pp); l = GET_LONG(pp); if ((ret = _clip_func_hash(mp, l, c, 1, reflocals))) goto _trap; break; case CLIP_PROC: c = GET_BYTE(pp); l = GET_LONG(pp); if ((ret = _clip_proc_hash(mp, l, c, 0, reflocals))) goto _trap; break; case CLIP_PROCR: c = GET_BYTE(pp); l = GET_LONG(pp); if ((ret = _clip_proc_hash(mp, l, c, 1, reflocals))) goto _trap; break; case CLIP_SFUNC: c = GET_BYTE(pp); s = GET_SHORT(pp); bl.file = file; get_func(modbeg, s, &bl.func); if ((ret = _clip_code_func(mp, &bl, c, 0, reflocals))) goto _trap; break; case CLIP_SFUNCR: c = GET_BYTE(pp); s = GET_SHORT(pp); bl.file = file; get_func(modbeg, s, &bl.func); if ((ret = _clip_code_func(mp, &bl, c, 1, reflocals))) goto _trap; break; case CLIP_SPROC: c = GET_BYTE(pp); s = GET_SHORT(pp); bl.file = file; get_func(modbeg, s, &bl.func); if ((ret = _clip_code_proc(mp, &bl, c, 0, reflocals))) goto _trap; break; case CLIP_SPROCR: c = GET_BYTE(pp); s = GET_SHORT(pp); bl.file = file; get_func(modbeg, s, &bl.func); if ((ret = _clip_code_proc(mp, &bl, c, 1, reflocals))) goto _trap; break; case CLIP_ASSIGN: vp = frame.sp->p.vp; if ((ret = _clip_assign(mp, vp))) goto _trap; break; case CLIP_REF_DESTROY: vp = frame.sp->p.vp; /*if (vp->t.flags != F_MREF)*/ _clip_destroy(mp, vp); /*_clip_destroy(mp, vp);*/ break; case CLIP_MACROASSIGN: c = GET_BYTE(pp); c1 = GET_BYTE(pp); if ((ret = _clip_macroassign(mp, c, c1 & 1, c1 & 2))) goto _trap; break; case CLIP_REFASSIGN: c = GET_BYTE(pp); vp = frame.sp->p.vp; if ((ret = _clip_refassign(mp, vp, c))) goto _trap; break; case CLIP_UNREF: vp = frame.sp->p.vp; _clip_destroy(mp, vp); break; case CLIP_IASSIGN: vp = frame.sp->p.vp; if ((ret = _clip_iassign(mp, vp))) goto _trap; break; case CLIP_OPASSIGN: c = GET_BYTE(pp); vp = frame.sp->p.vp; if ((ret = _clip_opassign(mp, vp, c))) goto _trap; break; case CLIP_OPIASSIGN: c = GET_BYTE(pp); vp = frame.sp->p.vp; if ((ret = _clip_opiassign(mp, vp, c))) goto _trap; break; case CLIP_ASSIGN_FIELD: l = GET_LONG(pp); l1 = GET_LONG(pp); if ((ret = _clip_assign_field(mp, l, l1))) goto _trap; break; case CLIP_IASSIGN_FIELD: l = GET_LONG(pp); l1 = GET_LONG(pp); if ((ret = _clip_iassign_field(mp, l, l1))) goto _trap; break; case CLIP_ASSIGN_FIELD_POP: l = GET_LONG(pp); l1 = _clip_pop_hash(mp); if ((ret = _clip_assign_field(mp, l, l1))) goto _trap; break; case CLIP_IASSIGN_FIELD_POP: l = GET_LONG(pp); l1 = _clip_pop_hash(mp); if ((ret = _clip_iassign_field(mp, l, l1))) goto _trap; break; case CLIP_ASSIGN_PFIELD: l = _clip_pop_hash(mp); l1 = GET_LONG(pp); if ((ret = _clip_assign_field(mp, l, l1))) goto _trap; break; case CLIP_IASSIGN_PFIELD: l = _clip_pop_hash(mp); l1 = GET_LONG(pp); if ((ret = _clip_iassign_field(mp, l, l1))) goto _trap; break; case CLIP_ASSIGN_PFIELD_POP: l = _clip_pop_hash(mp); l1 = _clip_pop_hash(mp); if ((ret = _clip_assign_field(mp, l, l1))) goto _trap; break; case CLIP_IASSIGN_PFIELD_POP: l = _clip_pop_hash(mp); l1 = _clip_pop_hash(mp); if ((ret = _clip_iassign_field(mp, l, l1))) goto _trap; break; case CLIP_FM_ASSIGN: l = GET_LONG(pp); if ((ret = _clip_fm_assign(mp, l))) goto _trap; break; case CLIP_FM_IASSIGN: l = GET_LONG(pp); if ((ret = _clip_fm_iassign(mp, l))) goto _trap; break; case CLIP_ARRAY: l = GET_LONG(pp); _clip_sarray(mp, l); break; case CLIP_DIMARRAY: l = GET_LONG(pp); _clip_dimarray(mp, l); break; case CLIP_NEWARRAY: l = GET_LONG(pp); _clip_vnewarray(mp, l, (long *) pp); pp += l * sizeof(long); break; case CLIP_GET: l = GET_LONG(pp); if ((ret = _clip_get(mp, l))) goto _trap; break; case CLIP_SET: l = GET_LONG(pp); if ((ret = _clip_set(mp, l))) goto _trap; break; case CLIP_RETURN_POP: _clip_return(mp); case CLIP_RETURN: goto _return; case CLIP_STORE: c1 = GET_BYTE(pp); c = GET_BYTE(pp); if ((ret = _clip_store(mp, c, c1))) goto _trap; break; case CLIP_ISTORE: c1 = GET_BYTE(pp); c = GET_BYTE(pp); if ((ret = _clip_istore(mp, c, c1))) goto _trap; break; case CLIP_OPSTORE: c = GET_BYTE(pp); c1 = GET_BYTE(pp); if ((ret = _clip_opstore(mp, c1, c))) goto _trap; break; case CLIP_OPISTORE: c = GET_BYTE(pp); c1 = GET_BYTE(pp); if ((ret = _clip_opistore(mp, c1, c))) goto _trap; break; case CLIP_FETCH: c = GET_BYTE(pp); if ((ret = _clip_fetch(mp, c))) goto _trap; break; case CLIP_FETCHREF: c = GET_BYTE(pp); #if 0 frame.sp->p.vp = _clip_fetchref(mp, c); #else { ClipVar *vp1 = _clip_fetchref(mp, c); /*printf("%p\n", vp1);*/ frame.sp->p.vp = vp1; } #endif if (!frame.sp->p.vp) goto _trap; break; case CLIP_IFETCH: c = GET_BYTE(pp); if ((ret = _clip_ifetch(mp, c))) goto _trap; break; case CLIP_CALL: c = GET_BYTE(pp); l = GET_LONG(pp); if ((ret = _clip_call(mp, c, l))) goto _trap; break; case CLIP_PUSH_CODE: s = GET_SHORT(pp); c = GET_BYTE(pp); c1 = GET_BYTE(pp); vp = NEW(ClipVar); vp->t.type = PCODE_t; vp->t.flags = F_NONE; vp->t.count = 1; vp->c.u.block = NEW(ClipBlock); get_func(modbeg, s, &(vp->c.u.block->func)); vp->c.u.block->file = file; if (c) { int nlocals = c; ClipVarFrame *localvars = calloc(1, sizeof(ClipVarFrame) + nlocals * sizeof(ClipVar)); localvars->vars = (ClipVar *) (localvars + 1); memcpy(localvars->vars, mp->fp->sp - nlocals, nlocals * sizeof(ClipVar)); localvars->refcount = 1; localvars->size = nlocals; vp->c.uplocals = localvars; mp->fp->sp -= nlocals; } else if (!c1 && reflocals && reflocals->refcount) { reflocals->refcount++; vp->c.uplocals = reflocals; } else vp->c.uplocals = 0; file->refCount++; CLEAR_CLIPVAR(frame.sp); frame.sp->t.type = PCODE_t; frame.sp->t.flags = F_MPTR; frame.sp->p.vp = vp; frame.sp++; CLIP_CHECK_STACK; break; case CLIP_MACRO: if ((ret = _clip_macro(mp))) goto _trap; break; case CLIP_PCOUNT: _clip_pcount(mp); break; case CLIP_PSHIFT: _clip_pshift(mp); break; case CLIP_PARN: if ((ret = _clip_parn(mp))) goto _trap; break; case CLIP_FUNC_NAME: c = GET_BYTE(pp); if ((ret = _clip_func_name(mp, c))) goto _trap; break; case CLIP_INCR: vp = frame.sp->p.vp; if ((ret = _clip_incr(mp, vp, 1, 0))) goto _trap; break; case CLIP_INCR_POST: vp = frame.sp->p.vp; if ((ret = _clip_incr(mp, vp, 1, 1))) goto _trap; break; case CLIP_DECR: vp = frame.sp->p.vp; if ((ret = _clip_incr(mp, vp, 0, 0))) goto _trap; break; case CLIP_DECR_POST: vp = frame.sp->p.vp; if ((ret = _clip_incr(mp, vp, 0, 1))) goto _trap; break; case CLIP_OP: c = GET_BYTE(pp); if ((ret = _clip_op(mp, c))) goto _trap; break; case CLIP_NOT: if ((ret = _clip_not(mp))) goto _trap; break; case CLIP_COND: s = GET_SHORT(pp); if ((ret = _clip_cond(mp, &i))) goto _trap; if (!i) pp += s; break; case CLIP_TCOND: s = GET_SHORT(pp); if ((ret = _clip_tcond(mp, &i))) goto _trap; if (!i) pp += s; break; case CLIP_ITCOND: s = GET_SHORT(pp); if ((ret = _clip_tcond(mp, &i))) goto _trap; if (i) pp += s; break; case CLIP_GOTO: s = GET_SHORT(pp); pp += s; break; case CLIP_FORSTEP: s = GET_SHORT(pp); if ((ret = _clip_forstep(mp, &i))) goto _trap; if (!i) pp += s; break; case CLIP_MAP_FIRST: c = GET_BYTE(pp); s = GET_SHORT(pp); if ((ret = _clip_map_first(mp, c, &i))) goto _trap; if (!i) pp += s; break; case CLIP_MAP_NEXT: c = GET_BYTE(pp); s = GET_SHORT(pp); if ((ret = _clip_map_next(mp, c, &i))) goto _trap; if (!i) pp += s; break; case CLIP_MINUS: if ((ret = _clip_minus(mp))) goto _trap; break; case CLIP_RESETTRAP: trap_pp = 0; break; case CLIP_SETTRAP: s = GET_SHORT(pp); trap_pp = pp + s; break; case CLIP_RECOVER: while (frame.sp > frame.stack) _clip_destroy(mp, --frame.sp); ret = 0; break; case CLIP_USING: if (mp->trapVar) { vp = frame.sp->p.vp; *frame.sp = *mp->trapVar; ++frame.sp; free(mp->trapVar); mp->trapVar = 0; if ((ret = _clip_assign(mp, vp))) goto _trap; } break; case CLIP_BREAK: #if 0 /*_clip_trap_str(mp, filename, frame.line, "BREAK");*/ #else vp = NEW(ClipVar); _clip_trap_var(mp, filename, frame.line, vp); #endif ret = -1; goto _trap; case CLIP_BREAK_EXPR: vp = NEW(ClipVar); --frame.sp; *vp = *frame.sp; _clip_trap_var(mp, filename, frame.line, vp); ret = -1; goto _trap; case CLIP_SWAP: c = GET_BYTE(pp); _clip_swap(mp, c); break; case CLIP_PUSH_HASH: l = GET_LONG(pp); frame.sp->t.memo = 0; frame.sp->t.type = NUMERIC_t; frame.sp->t.flags = F_NONE; frame.sp->t.len = 10; frame.sp->t.dec = 0; frame.sp->n.d = l; frame.sp++; CLIP_CHECK_STACK; break; case CLIP_CALC_HASH: _clip_calc_hash(mp); break; case CLIP_CALC_HASH2: _clip_calc_hash2(mp, 1); break; case CLIP_PUSH_LOCALE: _clip_push_locale(mp); break; case CLIP_RDDFIELD: s = GET_SHORT(pp); s1 = GET_SHORT(pp); _clip_rddfield(mp, s, s1); break; case CLIP_CATSTR: s = GET_SHORT(pp); _clip_catstr(mp, s); break; case CLIP_QUOT: _clip_quot(mp); break; case CLIP_SWITCH: s = GET_SHORT(pp); /* label num */ l = _clip_pop_shash(mp); /* hash */ { short other = GET_SHORT(pp); long *lp = (long *) pp; short *jmps = (short *) (pp + s * sizeof(long)); int n = search_long(lp, s, l); if (n < 0) pp += other; else pp += GETSHORT(jmps+n); } break; default: _clip_trap_printf(mp, filename, frame.line, "invalid bytecode %d", code); _clip_call_errblock(mp, 1); ret = 1; goto _trap; } } goto _return; _trap: if (trap_pp /*&& ret > 0 */ ) { pp = trap_pp; goto cont; } _clip_trap(mp, filename, frame.line); /*ret = 1; */ _return: if (_clip_profiler) _clip_stop_profiler(mp); if (local_locals) _clip_destroy_locals(mp); _clip_resume(mp, nlocals, nreflocals); #if 0 _clip_vresume(mp, nlocals, locals); #endif #if 0 _clip_vresume(mp, nparams, params); #endif #if 0 if (nreflocals) _clip_vresume(mp, nreflocals, reflocals); #endif /*_clip_vremove_privates(mp, nprivates, privates);*/ dealloca(stack); return ret; }
/**************************************************************************** gethostbyname() - we ignore any domain portion of the name and only handle names that are at most 15 characters long **************************************************************************/ NSS_STATUS _nss_wins_gethostbyname_r(const char *hostname, struct hostent *he, char *buffer, size_t buflen, int *errnop, int *h_errnop) { NSS_STATUS nss_status = NSS_STATUS_SUCCESS; char *ip; struct in_addr in; int i; fstring name; size_t namelen; int rc; #if HAVE_PTHREAD pthread_mutex_lock(&wins_nss_mutex); #endif memset(he, '\0', sizeof(*he)); fstrcpy(name, hostname); /* Do lookup */ ip = lookup_byname_backend(name); if (ip == NULL) { *h_errnop = HOST_NOT_FOUND; nss_status = NSS_STATUS_NOTFOUND; goto out; } rc = inet_pton(AF_INET, ip, &in); wbcFreeMemory(ip); if (rc == 0) { *errnop = errno; *h_errnop = NETDB_INTERNAL; nss_status = NSS_STATUS_TRYAGAIN; goto out; } /* Copy h_name */ namelen = strlen(name) + 1; if ((he->h_name = get_static(&buffer, &buflen, namelen)) == NULL) { *errnop = EAGAIN; *h_errnop = NETDB_INTERNAL; nss_status = NSS_STATUS_TRYAGAIN; goto out; } memcpy(he->h_name, name, namelen); /* Copy h_addr_list, align to pointer boundary first */ if ((i = (unsigned long)(buffer) % sizeof(char*)) != 0) i = sizeof(char*) - i; if (get_static(&buffer, &buflen, i) == NULL) { *errnop = EAGAIN; *h_errnop = NETDB_INTERNAL; nss_status = NSS_STATUS_TRYAGAIN; goto out; } if ((he->h_addr_list = (char **)get_static( &buffer, &buflen, 2 * sizeof(char *))) == NULL) { *errnop = EAGAIN; *h_errnop = NETDB_INTERNAL; nss_status = NSS_STATUS_TRYAGAIN; goto out; } if ((he->h_addr_list[0] = get_static(&buffer, &buflen, INADDRSZ)) == NULL) { *errnop = EAGAIN; *h_errnop = NETDB_INTERNAL; nss_status = NSS_STATUS_TRYAGAIN; goto out; } memcpy(he->h_addr_list[0], &in, INADDRSZ); he->h_addr_list[1] = NULL; /* Set h_addr_type and h_length */ he->h_addrtype = AF_INET; he->h_length = INADDRSZ; /* Set h_aliases */ if ((i = (unsigned long)(buffer) % sizeof(char*)) != 0) i = sizeof(char*) - i; if (get_static(&buffer, &buflen, i) == NULL) { *errnop = EAGAIN; *h_errnop = NETDB_INTERNAL; nss_status = NSS_STATUS_TRYAGAIN; goto out; } if ((he->h_aliases = (char **)get_static( &buffer, &buflen, sizeof(char *))) == NULL) { *errnop = EAGAIN; *h_errnop = NETDB_INTERNAL; nss_status = NSS_STATUS_TRYAGAIN; goto out; } he->h_aliases[0] = NULL; *h_errnop = NETDB_SUCCESS; nss_status = NSS_STATUS_SUCCESS; out: #if HAVE_PTHREAD pthread_mutex_unlock(&wins_nss_mutex); #endif return nss_status; }