Annotation of researchv10no/netfs/libnetb/setupmain.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * main program for server called by setup
                      3:  */
                      4: #include <stdio.h>
                      5: #include <signal.h>
                      6: #include "rf.h"
                      7: 
                      8: #define        CFD     0       /* filesystem connection */
                      9: 
                     10: int fserrno;
                     11: 
                     12: /*
                     13:  * setup handshake:
                     14:  * receive 16-byte message with initial parameters
                     15:  * send 1
                     16:  * receive maxsize bytes: uid map
                     17:  *     user : means list is incomplete;
                     18:  *     send 012 and read another maxsize bytes
                     19:  * send 2
                     20:  * receive maxsize bytes: gid map
                     21:  *     group : means list is incomplete;
                     22:  *     send 013 and read another maxsize bytes
                     23:  * send 3
                     24:  */
                     25: #define        MSG1LEN 16
                     26: 
                     27: extern char *_rfwhocalled();
                     28: char *malloc();
                     29: 
                     30: char *rfclient;
                     31: int rfdebug;
                     32: 
                     33: main(argc, argv)
                     34: int argc;
                     35: char **argv;
                     36: {
                     37:        char *inbuf;
                     38:        char msg[MSG1LEN];
                     39:        int n;
                     40:        int maxsize;
                     41: 
                     42:        umask(0);
                     43:        signal(SIGHUP, SIG_IGN);
                     44:        if ((rfclient = _rfwhocalled(CFD)) == NULL)
                     45:                rfclient = "";
                     46:        /*
                     47:         * setup message 1
                     48:         */
                     49:        if ((n = _rfgread(CFD, msg, MSG1LEN, MSG1LEN)) != MSG1LEN)
                     50:                rfpanic("setup 1: %d\n", n);
                     51:        maxsize = msg[0] * 1024;
                     52:        rfdebug = msg[3];
                     53:        if (_rfinit(argc, argv) == 0)
                     54:                rfpanic("can't init\n");
                     55:        if ((inbuf = malloc(maxsize)) == NULL)
                     56:                rfpanic("can't alloc %d bytes\n", maxsize);
                     57:        if (write(CFD, "\1", 1) != 1)
                     58:                rfpanic("setup 1: write error\n");
                     59:        /*
                     60:         * setup message 2
                     61:         */
                     62:        for (;;) {
                     63:                if ((n = _rfgread(CFD, inbuf, maxsize, maxsize)) != maxsize)
                     64:                        rfpanic("setup 2: %d\n", n);
                     65:                inbuf[n-1] = 0; /* safety */
                     66:                if (_rfmapuid(inbuf) != 0)
                     67:                        break;
                     68:                if (write(CFD, "\012", 1) != 1)
                     69:                        rfpanic("setup 2 (12): write error\n");
                     70:        }
                     71:        if (write(CFD, "\2", 1) != 1)
                     72:                rfpanic("setup 2: write error\n");
                     73:        /*
                     74:         * setup message 3
                     75:         */
                     76:        for (;;) {
                     77:                if ((n = _rfgread(CFD, inbuf, maxsize, maxsize)) != maxsize)
                     78:                        rfpanic("setup 3: %d\n", n);
                     79:                inbuf[n-1] = 0; /* safety */
                     80:                if (_rfmapgid(inbuf) != 0)
                     81:                        break;
                     82:                if (write(CFD, "\013", 1) != 1)
                     83:                        rfpanic("setup 3 (13): write error\n");
                     84:        }
                     85:        if (write(CFD, "\3", 1) != 1)
                     86:                rfpanic("setup 3: write error\n");
                     87:        rflog("ok; buf %d\n", maxsize);
                     88:        _rfscan(CFD, inbuf, maxsize);
                     89:        rflog("eof\n");
                     90:        exit(0);
                     91: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.