Annotation of researchv10no/ipc/mgrs/authmgr/doconnect.c, revision 1.1.1.1

1.1       root        1: #include <stdio.h>
                      2: #include <signal.h>
                      3: #include <ipc.h>
                      4: #include <string.h>
                      5: 
                      6: #include "auth.h"
                      7: 
                      8: #define RLOGIN "/usr/bin/rlogin"
                      9: 
                     10: int callee = -1;
                     11: int cpid = -1;
                     12: 
                     13: int
                     14: doconnect(path, user)
                     15:        char *path;
                     16:        char *user;
                     17: {
                     18:        char *cp;
                     19:        int status;
                     20: 
                     21: 
                     22:        if (strncmp(path, "tcp!", 4) != 0) {
                     23:                char *svc;              /* this service stuff is a hack */ 
                     24:                if ((strchr(path, '/') == NULL) ||
                     25:                    (strncmp(path, "phone/", 6) == 0) ||
                     26:                    (strncmp(path, "homer/", 6) == 0) ||
                     27:                    (strncmp(path, "mercury/", 8) == 0))
                     28:                        svc = "dcon";   /* dcon requires no passwd on V10 unix */
                     29:                else
                     30:                        svc = "";
                     31:                restoretty();
                     32:                redial(path, user, svc);
                     33:                settty();
                     34:                return FALSE;
                     35:        }
                     36: 
                     37:        signal(SIGALRM, SIG_IGN);
                     38:        switch (cpid=fork()) {
                     39:        case -1:
                     40:                perror("Fork error");
                     41:                return FALSE;
                     42:        case 0:
                     43:                close(2);
                     44:                dup(1, 2);
                     45:                setlogname(user);
                     46:                execl(RLOGIN, RLOGIN, path, NULL);
                     47:                perror("exec failed");
                     48:                exit(100);
                     49:        default:
                     50:                /* do we need a timeout? */
                     51:                wait(&status);
                     52:                if (((status >> 8) & 0xFF) != 0) {
                     53:                        
                     54:                        return FALSE;
                     55:                }
                     56:                return TRUE;
                     57:        }
                     58: }
                     59: 
                     60: redial(path, user, svc)
                     61: char *path, *user, *svc;
                     62: {
                     63:        ipcinfo info;
                     64:        char buf[100];
                     65: 
                     66:        /* The options are U (for gnots) and - (for us) */
                     67: 
                     68:        strcpy(buf, "->");
                     69:        strcat(buf, path);
                     70: 
                     71:        strcpy(buf, "->");
                     72:        if (strncmp(path, "dk!", 3) == NULL)
                     73:                path += 3;
                     74:        strcat(buf, path);
                     75: 
                     76:        info.rfd = -1;
                     77:        info.cfd = 0;   /* pass back fd 0 */
                     78:        info.myname = NULL;
                     79:        info.user = user;
                     80:        info.machine = "";
                     81:        info.uid = info.gid = -1;
                     82:        info.name = ipcpath(buf, "/cs/dk", svc);
                     83:        info.param = "light";                           /* bogus */
                     84:        info.flags = 0;
                     85:        if(ipcredial(&info) != 0) {
                     86:                fprintf(stderr, "Redial failed, destination was %s\n", info.name);
                     87:        }
                     88: }
                     89: 
                     90: 
                     91: #ifdef notused
                     92: int
                     93: dkcall(path)
                     94: char *path;
                     95: {
                     96:        char *fullpath, *service;
                     97: 
                     98:        fullpath = ipcpath(path, "dk", "dcon");
                     99:        service = strrchr(fullpath, "!");
                    100:        service++;
                    101:        
                    102:        if (strcmp(service, "dcon") == 0) {     /* try a dcon */
                    103:                char answer[2];
                    104: 
                    105:                callee = ipcopen(fullpath, "light");
                    106:                if (callee >= 0) {
                    107:                        read(callee, answer, 2);
                    108:                        if (strcmp(answer, "OK") == 0)
                    109:                                return callee;          /* dcon likes us */
                    110:                }
                    111:        }
                    112: 
                    113:        fullpath = ipcpath(path, "dk", "");
                    114:        callee = ipcopen(fullpath, "light");
                    115:        return callee;
                    116: }
                    117: #endif

unix.superglobalmegacorp.com

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