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 rclunk(void) { Xfile *f; if(!waserror()){ f = xfile(req->fid, Asis); (*f->xf->s->clunk)(f); poperror(); } xfile(req->fid, Clunk); }
static void ropen(Req *r) { Xfile *f; chat("open(fid=%d,mode=%d)...", thdr.fid, thdr.mode); errno = 0; f = xfile(r->fid, Asis); if( !f ){ errno = Eio; goto error; } if(thdr.mode & OTRUNC){ if( !S_ISREG(getmode(f)) ){ errno = Eperm; goto error; } if(truncfile(f) < 0){ goto error; } } chat("f->qid=0x%8.8lux...", r->fid->qid.path); rhdr.qid = r->fid->qid; error: response(r); }
static void destroyfid(Fid *fid) { chat("destroy(fid=%d)\n", fid->fid); xfile(fid, Clunk); /*syncbuf(xf);*/ }
static void rwrite(Req *r) { Xfile *f; int nr; chat("write(fid=%d,offset=%lld,count=%d)...", thdr.fid, thdr.offset, thdr.count); errno = 0; if (!(f=xfile(r->fid, Asis)) ){ errno = Eio; goto error; } if( !S_ISREG(getmode(f)) ){ errno = Elink; goto error; } nr = writefile(f, thdr.data, thdr.offset, thdr.count); if(nr >= 0){ rhdr.count = nr; chat("rcnt=%d...OK\n", nr); respond(r, nil); return; } errno = Eio; error: response(r); }
static void rread(Req *r) { Xfile *f; int nr; chat("read(fid=%d,offset=%lld,count=%d)...", thdr.fid, thdr.offset, thdr.count); errno = 0; if ( !(f=xfile(r->fid, Asis)) ) goto error; if( r->fid->qid.type & QTDIR ){ nr = readdir(f, r->rbuf, thdr.offset, thdr.count); }else nr = readfile(f, r->rbuf, thdr.offset, thdr.count); if(nr >= 0){ rhdr.count = nr; chat("rcnt=%d...OK\n", nr); respond(r, nil); return; } error: errno = Eio; response(r); }
Tracter::MLP::MLP(Component<float>* iInput, const char* iObjectName) { mObjectName = iObjectName; mInput = iInput; mInputs = iInput->Frame().size; assert(mInputs > 0); mTheta = GetEnv("Theta", 9); assert(mTheta > 0); const char *fname = GetEnv("Weights", ""); assert(strlen(fname) > 0); Torch::DiskXFile xfile(fname,"rb"); mMLP.loadXFile(&xfile); //mMLP.build(); if (mMLP.machine_infos[mMLP.n_layers-1][0]->desc == Torch::LOGSOFTMAX){ Torch::SoftMax *sm = new Torch::SoftMax(mMLP.n_outputs); mMLP.removeFCL(); mMLP.addFCL(sm); } mMLP.build(); mMLP.setPartialBackprop(); mWindow = mTheta*2 + 1; mFeature.resize(mMLP.n_inputs); if (mMLP.n_inputs != mWindow*mInputs) throw Exception("MLP: Dimension mismatch: %d != %d", mMLP.n_inputs, mWindow*mInputs); Connect(mInput, mWindow, mTheta); mFrame.size = mMLP.n_outputs; assert(mFrame.size > 0); }
static void rattach(Req *r) { Xfs *xf; Xfile *root; chat("attach(fid=%d,uname=\"%s\",aname=\"%s\",afid=\"%d\")...", thdr.fid, thdr.uname, thdr.aname, thdr.afid); errno = 0; root = xfile(r->fid, Clean); if(!root){ errno = Enomem; goto error; } root->xf = xf = getxfs(thdr.aname); if(!xf) goto error; /* now attach root inode */ if( get_inode(root, EXT2_ROOT_INODE) < 0 ) goto error; r->fid->qid.type = QTDIR; r->fid->qid.vers = 0; root->xf->rootqid = r->fid->qid; root->pinbr = EXT2_ROOT_INODE; root->root = 1; rhdr.qid = r->fid->qid; error: response(r); }
static char * rwalk1(Fid *fid, char *name, Qid *qid) { Xfile *f=xfile(fid, Asis); int nr, sinbr = 0; chat("walk1(fid=%d,name=\"%s\")...", fid->fid, name); errno = 0; if( !f ){ chat("no xfile..."); goto error; } if( !(fid->qid.type & QTDIR) ){ chat("qid.type=0x%x...", fid->qid.type); goto error; } sinbr = f->pinbr; if( name == 0 || name[0] == 0 || !strcmp(name, ".") ){ *qid = fid->qid; goto ok; }else if( !strcmp(name, "..") ){ if( fid->qid.path == f->xf->rootqid.path ){ chat("walkup from root..."); *qid = fid->qid; goto ok; } if( get_inode(f, f->pinbr) < 0 ) goto error; if( f->pinbr == EXT2_ROOT_INODE ){ *qid = f->xf->rootqid; f->pinbr = EXT2_ROOT_INODE; } else { *qid = (Qid){f->pinbr,0,QTDIR}; f->inbr = f->pinbr; if( (nr = get_file(f, "..")) < 0 ) goto error; f->pinbr = nr; } }else{ f->pinbr = f->inbr; if( (nr = get_file(f, name)) < 0 ) goto error; if( get_inode(f, nr) < 0 ) goto error; *qid = (Qid){nr,0,0}; if( nr == EXT2_ROOT_INODE ) *qid = f->xf->rootqid; else if( S_ISDIR(getmode(f)) ) qid->type = QTDIR; /*strcpy(f->name, thdr.name);*/ } ok: chat("OK\n"); return 0; error: f->pinbr = sinbr; chat("%s\n", xerrstr(Enonexist)); return xerrstr(Enonexist); }
static void rcreate(Req *r) { Xfile *f; int inr, perm; chat("create(fid=%d,name=\"%s\",perm=%uo,mode=%d)...", thdr.fid, thdr.name, thdr.perm, thdr.mode); errno = 0; if(strcmp(thdr.name, ".") == 0 || strcmp(thdr.name, "..") == 0){ errno = Eperm; goto error; } f = xfile(r->fid, Asis); if( !f ){ errno = Eio; goto error; } if( strlen(thdr.name) > EXT2_NAME_LEN ){ chat("name too long ..."); errno = Elongname; goto error; } /* create */ errno = 0; if( thdr.perm & DMDIR ){ perm = (thdr.perm & ~0777) | (getmode(f) & thdr.perm & 0777); perm |= S_IFDIR; inr = create_dir(f, thdr.name, perm); }else{ perm = (thdr.perm & (~0777|0111)) | (getmode(f) & thdr.perm & 0666); perm |= S_IFREG; inr = create_file(f, thdr.name, perm); } if( inr < 0 ) goto error; /* fill with new inode */ f->pinbr = f->inbr; if( get_inode(f, inr) < 0 ){ errno = Eio; goto error; } r->fid->qid = (Qid){inr, 0, 0}; if( S_ISDIR(getmode(f)) ) r->fid->qid.type |= QTDIR; chat("f->qid=0x%8.8lux...", r->fid->qid.path); rhdr.qid = r->fid->qid; error: response(r); }
void rwrite(void) { Xfile *f; f=xfile(req->fid, Asis); if(!(f->flags&Owrite)) error("file not opened for writing"); rep->count = (*f->xf->s->write)(f, req->data, req->offset, req->count); }
static char * rclone(Fid *fid, Fid *newfid) { Xfile *of = xfile(fid, Asis); Xfile *nf = xfile(newfid, Clean); chat("clone(fid=%d,newfid=%d)...", fid->fid, newfid->fid); errno = 0; if(!of) errno = Eio; else if(!nf) errno = Enomem; else{ Xfile *next = nf->next; *nf = *of; nf->next = next; nf->fid = newfid->fid; nf->root = 0; } chat("%s\n", errno? xerrstr(errno) : "OK"); return errno ? xerrstr(errno) : 0; }
static void rwstat(Req *r) { Xfile *f=xfile(r->fid, Asis); chat("wstat(fid=%d)...", thdr.fid); errno = 0; if( !f ) errno = Eio; else dowstat(f, &r->d); response(r); }
void rread(void) { Xfile *f; f=xfile(req->fid, Asis); if (!(f->flags&Oread)) error("file not opened for reading"); if(f->qid.type & QTDIR) rep->count = (*f->xf->s->readdir)(f, (uchar*)fdata, req->offset, req->count); else rep->count = (*f->xf->s->read)(f, fdata, req->offset, req->count); rep->data = fdata; }
static void rstat(Req *r) { Xfile *f=xfile(r->fid, Asis); chat("stat(fid=%d)...", thdr.fid); errno = 0; if( !f ) errno = Eio; else{ dostat(r->fid->qid, f, &r->d); } response(r); }
void ropen(void) { Xfile *f; f = xfile(req->fid, Asis); if(f->flags&Omodes) error("open on open file"); if(req->mode&ORCLOSE) error("no removes"); (*f->xf->s->open)(f, req->mode); f->flags = openflags(req->mode); rep->qid = f->qid; rep->iounit = 0; }
Xfile* doclone(Xfile *of, int newfid) { Xfile *nf, *next; nf = xfile(newfid, Clean); if(waserror()){ xfile(newfid, Clunk); nexterror(); } next = nf->next; *nf = *of; nf->next = next; nf->fid = newfid; refxfs(nf->xf, 1); if(nf->len){ nf->ptr = ealloc(nf->len); memmove(nf->ptr, of->ptr, nf->len); }else nf->ptr = of->ptr; (*of->xf->s->clone)(of, nf); poperror(); return nf; }
void rstat(void) { Xfile *f; Dir dir; chat("stat(fid=%d)...", req->fid); f=xfile(req->fid, Asis); setnames(&dir, fdata); (*f->xf->s->stat)(f, &dir); if(chatty) showdir(2, &dir); rep->nstat = convD2M(&dir, statbuf, sizeof statbuf); rep->stat = statbuf; }
static void rremove(Req *r) { Xfile *f=xfile(r->fid, Asis); chat("remove(fid=%d) ...", thdr.fid); errno = 0; if(!f){ errno = Eio; goto error; } /* check permission here !!!!*/ unlink(f); error: response(r); }
void rwalk(void) { Xfile *f, *nf; Isofile *oldptr; int oldlen; Qid oldqid; rep->nwqid = 0; nf = nil; f = xfile(req->fid, Asis); if(req->fid != req->newfid) f = nf = doclone(f, req->newfid); /* save old state in case of error */ oldqid = f->qid; oldlen = f->len; oldptr = f->ptr; if(oldlen){ oldptr = ealloc(oldlen); memmove(oldptr, f->ptr, oldlen); } if(waserror()){ if(nf != nil) xfile(req->newfid, Clunk); if(rep->nwqid == req->nwname){ if(oldlen) free(oldptr); }else{ /* restore previous state */ f->qid = oldqid; if(f->len) free(f->ptr); f->ptr = oldptr; f->len = oldlen; } if(rep->nwqid==req->nwname || rep->nwqid > 0){ err_msg[0] = '\0'; return; } nexterror(); } for(rep->nwqid=0; rep->nwqid < req->nwname && rep->nwqid < MAXWELEM; rep->nwqid++){ chat("\twalking %s\n", req->wname[rep->nwqid]); if(!(f->qid.type & QTDIR)){ chat("\tnot dir: type=%#x\n", f->qid.type); error("walk in non-directory"); } if(strcmp(req->wname[rep->nwqid], "..")==0){ if(f->qid.path != f->xf->rootqid.path) (*f->xf->s->walkup)(f); }else (*f->xf->s->walk)(f, req->wname[rep->nwqid]); rep->wqid[rep->nwqid] = f->qid; } poperror(); if(oldlen) free(oldptr); }
bool opDriver::DialectModeFile(const opParameters& p, const path& filename) { double totaltimestart = opTimer::GetTimeSeconds(); opError::Clear(); // output compiling -file- to std out if (!p.Silent) { Log(opString("Reading dialect ") + filename.string() + " ..."); } // load the oh file, it will be tracked elsewhere DialectFileNode* filenode = FileNode::Load<DialectFileNode>( filename.string(), opScanner::SM_DialectMode); // filenode should be non-null even if there were errors assert(filenode); if (opError::HasErrors()) { if (p.PrintTree) filenode->PrintTree(filename.string()); opError::Print(); return false; } // check for file not found error // if (filenode->FileNotFoundError()) // { // opError::Print(); // // //this is ambiguous doh! // //TODO: fix this to be specific // Log(opString("Cannot open input file \"") + filename.string() + // "\"!"); return false; // } // // //check for scanner error // if(filenode->ScanError()) // { // opError::Print(); // // if (p.Verbose) // { // Log("Compilation failed!"); // Log(""); // } // // return false; // } // // //check for parser errors // if(filenode->AnyErrors()) // { // //print the tree (failure) // if (p.PrintTree) // filenode->PrintTree(filename.string()); // // opError::Print(); // // if (p.Verbose) // { // Log("Compilation failed!"); // Log(""); // } // // return false; // } opString spath = GetOutputPath(p, filename); path oohpath = (spath + ".ooh").GetString(); path ocpppath = (spath + ".ocpp").GetString(); path outputpath = oohpath.branch_path(); if (!exists(outputpath)) create_directories(outputpath); // handle dialect writing // we always want to read dialects though. bool bwrite = true; if (!p.Force) { // we want to rebuild upon upgrades / new builds if (exists(oohpath) && exists(filename)) { time_t oohtime = last_write_time(oohpath); time_t opcpptime = opPlatform::GetOpCppTimeStamp(); time_t dohtime = GetDialectTimestamp(p); filenode->LoadDependencies(spath + ".depend"); bool bNewDepend = filenode->IsDependencyNewer(oohtime); if (bNewDepend) { if (p.Verbose) { Log("Included dialect newer than generated dialect file, " "forcing recompile ..."); Log(""); } } else if (oohtime < opcpptime) { if (p.Verbose) { Log(opPlatform::GetOpCppExecutableName() + " newer than generated dialect file, forcing recompile " "..."); Log(""); } } else if (oohtime <= dohtime) { if (p.Verbose) { Log("Dialect newer than generated dialect file, forcing " "recompile ..."); Log(""); } } else if (oohtime > dohtime) { if (p.Verbose) Log(filename.string() + " is up to date"); bwrite = false; } } } if (bwrite) { try { // Save dependencies file. opString dependpath = spath + ".depend"; filenode->SaveDependencies(dependpath); // open the output files for the generated code... FileWriteStream hfile(oohpath.string()); FileWriteStream sfile(ocpppath.string()); if (hfile.is_open() && sfile.is_open()) { filenode->SetFiles(oohpath.string(), ocpppath.string()); opDialectStream filestream(hfile, sfile); // add the pre-pend path (for relative #lines) filestream.SetDepths(oohpath.string()); // files are open, now print to them filenode->PrintDialectNode(filestream); filestream.Output(); } else { Log("Could not open output file(s)!"); return false; } } catch (opException::opCPP_Exception&) { } // print xml! if (p.PrintXml) { try { path xmlpath = (spath + ".xml").GetString(); // open the output files for the generated code... boost::filesystem::ofstream xfile(xmlpath); if (xfile.is_open()) { opXmlStream filestream(xfile); // files are open, now print to them filenode->PrintXml(filestream); } else { Log("Could not open output xml file!"); return false; } } catch (opException::opCPP_Exception&) { //??? ever } } } double totaltimeend = opTimer::GetTimeSeconds(); double totaltimeMs = (totaltimeend - totaltimestart) * 1000.0; // print the tree (success) if (p.PrintTree) filenode->PrintTree(filename.string()); // write the verbose compilation notice if (p.Verbose) { Log(""); Log(opString("Dialect reading successful ... took ") + totaltimeMs + " ms (" + filenode->GetScanMs() + " scan ms, " + filenode->GetParseMs() + " parse ms)"); Log(""); } return true; }
// compiles a file in normal mode bool opDriver::NormalModeFile(const opParameters& p, const path& filename) { double totaltimestart = opTimer::GetTimeSeconds(); // build the output filename strings... // fix this for ../ case (convert to string and find & replace...) opString sfile = GetOutputPath(p, filename); path oohpath = (sfile + ".ooh").GetString(); path ocpppath = (sfile + ".ocpp").GetString(); path outputpath = oohpath.branch_path(); if (!exists(outputpath)) create_directories(outputpath); // lets check the timestamp... if (!p.Force) { time_t ohtime = last_write_time(filename); // we want to rebuild upon upgrades / new builds time_t opcpptime = opPlatform::GetOpCppTimeStamp(); if (exists(oohpath) && exists(ocpppath)) { time_t oohtime = last_write_time(oohpath); time_t ocpptime = last_write_time(ocpppath); time_t dohtime = GetGeneratedDialectTimestamp(p); FileNode tempfile; tempfile.LoadDependencies(sfile + ".depend"); bool bNewDepend = tempfile.IsDependencyNewer(oohtime); if (bNewDepend) { if (p.Verbose) { Log("Included file newer than generated file, forcing " "recompile ..."); Log(""); } } // up to date if ooh newer than oh, and ooh newer than opcpp build else if (oohtime < opcpptime || ocpptime < opcpptime) { if (p.Verbose) { Log(opPlatform::GetOpCppExecutableName() + " newer than generated file, forcing recompile ..."); Log(""); } } else if (oohtime <= dohtime || ocpptime <= dohtime) { if (p.Verbose) { Log("Dialect newer than generated file, forcing recompile " "..."); Log(""); } } else if (oohtime > ohtime && ocpptime > ohtime) { if (p.Verbose) Log(filename.string() + " is up to date"); return true; } } } opError::Clear(); // output compiling -file- to std out if (!p.Silent) { Log(opString("Compiling ") + filename.string() + " ..."); } // load the oh file, it will be tracked elsewhere OPFileNode* filenode = FileNode::Load<OPFileNode>(filename.string(), opScanner::SM_NormalMode); // filenode should be non-null even if there were errors assert(filenode); if (opError::HasErrors()) { if (p.PrintTree) filenode->PrintTree(filename.string()); opError::Print(); return false; } // no errors, let's print the output files try { // Save dependencies file. opString dependpath = sfile + ".depend"; filenode->SaveDependencies(dependpath); // open the output files for the generated code... FileWriteStream hfile(oohpath.string()); FileWriteStream sfile(ocpppath.string()); if (hfile.is_open() && sfile.is_open()) { filenode->SetFiles(oohpath.string(), ocpppath.string()); opFileStream filestream(hfile, sfile); // add the pre-pend path (for relative #lines) filestream.SetDepths(oohpath.string()); // files are open, now print to them filenode->PrintNode(filestream); filestream.Output(); } else { Log("Could not open output file(s)!"); return false; } } catch (opException::opCPP_Exception&) { //??? ever } // print xml! if (p.PrintXml) { try { path xmlpath = (sfile + ".xml").GetString(); // open the output files for the generated code... boost::filesystem::ofstream xfile(xmlpath); if (xfile.is_open()) { opXmlStream filestream(xfile); // files are open, now print to them filenode->PrintXml(filestream); } else { Log("Could not open output xml file!"); return false; } } catch (opException::opCPP_Exception&) { //??? ever } } // any errors left? // shouldn't be really opError::Print(); double totaltimeend = opTimer::GetTimeSeconds(); double totaltimeMs = (totaltimeend - totaltimestart) * 1000.0; // TODO: allow PrintTree to any stream // and add support for PrintTree to file // print the AST to stdout if (p.PrintTree) filenode->PrintTree(filename.string()); // write the verbose compilation notice if (p.Verbose) { Log(""); Log(opString("Compilation successful ... took ") + totaltimeMs + " ms (" + filenode->GetScanMs() + " scan ms, " + filenode->GetParseMs() + " parse ms)"); } return true; }
void srvinit(int fd, char *file, char *addr) { char fdservice[16], *naddr; Session *s; Xfile *xp; Xfid *xf; Fid *f; s = calloc(1, sizeof(Session)); s->spec = ""; s->fd = -1; if(fd >= 0){ s->fd = fd; sprint(fdservice, "/fd/%d", s->fd); s->service = strstore(fdservice); chat("fd = %d\n", s->fd); }else if(file){ chat("file = \"%s\"\n", file); s->service = file; s->fd = open(file, ORDWR); if(s->fd < 0){ clog("can't open %s: %r\n", file); goto error; } }else if(addr){ chat("addr = \"%s\"\n", addr); naddr = netmkaddr(addr, 0, "9fs"); s->service = addr; s->fd = dial(naddr, 0, 0, 0); if(s->fd < 0){ clog("can't dial %s: %r\n", naddr); goto error; } } chat("version..."); s->tag = NOTAG-1; s->f.msize = Maxfdata+IOHDRSZ; s->f.version = "9P2000"; xmesg(s, Tversion); messagesize = IOHDRSZ+s->f.msize; chat("version spec %s size %d\n", s->f.version, s->f.msize); s->tag = 0; chat("authenticate..."); if(authhostowner(s) < 0){ clog("auth failed %r\n"); goto error; } chat("attach as none..."); f = newfid(s); s->f.fid = f - s->fids; s->f.afid = ~0x0UL; s->f.uname = "none"; s->f.aname = s->spec; if(xmesg(s, Tattach)){ clog("attach failed\n"); goto error; } xp = xfile(&s->f.qid, s, 1); s->root = xp; xp->parent = xp; xp->name = "/"; xf = xfid("none", xp, 1); xf->urfid = f; clog("service=%s uid=%s fid=%ld\n", s->service, xf->uid, xf->urfid - s->fids); if(tail) tail->next = s; else head = s; tail = s; return; error: if(s->fd >= 0) close(s->fd); free(s); }
int main (int argc, char *argv[]) { args_t args; struct stat st; #ifdef WIN // PVOID OldValue=NULL; WSADATA wsa; Wow64DisableWow64FsRedirection (&OldValue); WSAStartup(MAKEWORD(2,0), &wsa); #endif setbuf(stdout, NULL); setbuf(stderr, NULL); memset (&args, 0, sizeof(args)); // set default parameters args.address = NULL; args.file = NULL; args.ai_family = AF_INET; args.port = DEFAULT_PORT; args.port_nbr = atoi(args.port); args.mode = -1; args.tx_mode = -1; args.sim = 0; args.dbg = 0; printf ("\n[ run shellcode v0.1\n"); parse_args(&args, argc, argv); // check if we have file parameter and it accessible if (args.file!=NULL) { if (stat (args.file, &st)) { printf ("[ unable to access %s\n", args.file); return 0; } else { if (st.st_size > MAX_BUFSIZ) { printf ("[ %s exceeds MAX_BUFSIZ of %i bytes\n", args.file, MAX_BUFSIZ); return 0; } } } // if mode is executing if (args.mode==RSC_EXEC) { if (args.file!=NULL) { xfile(&args); return 0; } else { printf ("\n[ you've used -x without supplying file with -f"); return 0; } } if (init_network(&args)) { // if no file specified, we receive and execute data args.tx_mode = (args.file==NULL) ? RSC_RECV : RSC_SEND; // if mode is -1, we listen for incoming connections if (args.mode == -1) { args.mode=RSC_SERVER; } // if no file specified, set to receive one if (args.tx_mode == -1) { args.tx_mode=RSC_RECV; } if (args.mode==RSC_SERVER) { ssr (&args); } else { csr (&args); } } return 0; }
Xfid * rpc2xfid(Rpccall *cmd, Dir *dp) { char *argptr = cmd->args; Xfile *xp; Xfid *xf; Session *s; char *service; Authunix au; Qid qid; char client[256], *user; Unixidmap *m; int i; uvlong x1, x2; chat("rpc2xfid %.8lux %.8lux %p %p\n", *((ulong*)argptr), *((ulong*)argptr+1), buf, argptr); if(argptr[0] == 0 && argptr[1] == 0){ /* root */ chat("root..."); xp = xfroot(&argptr[2], 0); s = xp ? xp->s : 0; }else{ ulong ul; chat("noroot %.8lux...", *((ulong*)argptr)); if((ul=GLONG()) != starttime){ chat("bad tag %lux %lux...", ul, starttime); return 0; } s = (Session *)GLONG(); x1 = GLONG(); x2 = GLONG(); qid.path = x1 | (x2<<32); qid.vers = 0; qid.type = GBYTE(); xp = xfile(&qid, s, 0); } if(xp == 0){ chat("no xfile..."); return 0; } if(auth2unix(&cmd->cred, &au) != 0){ chat("auth flavor=%ld, count=%ld\n", cmd->cred.flavor, cmd->cred.count); for(i=0; i<cmd->cred.count; i++) chat(" %.2ux", ((uchar *)cmd->cred.data)[i]); chat("..."); return 0; }else{ /* chat("auth: %d %.*s u=%d g=%d", * au.stamp, utfnlen(au.mach.s, au.mach.n), au.mach.s, au.uid, au.gid); * for(i=0; i<au.gidlen; i++) * chat(", %d", au.gids[i]); * chat("..."); */ char *p = memchr(au.mach.s, '.', au.mach.n); chat("%ld@%.*s...", au.uid, utfnlen(au.mach.s, (p ? p-au.mach.s : au.mach.n)), au.mach.s); } if(au.mach.n >= sizeof client){ chat("client name too long..."); return 0; } memcpy(client, au.mach.s, au.mach.n); client[au.mach.n] = 0; service = xp->parent->s->service; cmd->up = m = pair2idmap(service, cmd->host); if(m == 0){ chat("no map for pair (%s,%s)...", service, client); /*chat("getdom %d.%d.%d.%d", cmd->host&0xFF, (cmd->host>>8)&0xFF, (cmd->host>>16)&0xFF, (cmd->host>>24)&0xFF);/**/ /*if(getdom(cmd->host, client, sizeof(client))<0) return 0;/**/ return 0; } /*chat("map=(%s,%s)...", m->server, m->client);/**/ cmd->user = user = id2name(&m->u.ids, au.uid); if(user == 0){ chat("no user for id %ld...", au.uid); return 0; } chat("user=%s...", user);/**/ xf = 0; if(s == xp->parent->s){ if(!s->noauth) xf = setuser(xp, user); if(xf == 0) xf = setuser(xp, "none"); if(xf == 0) chat("can't set user none..."); }else xf = xp->users; if(xf) chat("uid=%s...", xf->uid); if(xf && dp && xfstat(xf, dp) < 0){ chat("can't stat %s...", xp->name); return 0; } return xf; }