1: # include "../ingres.h" 2: # include "../aux.h" 3: # include "../unix.h" 4: # include "../catalog.h" 5: # include "../pipes.h" 6: # include "qrymod.h" 7: 8: /* 9: ** FILLPROTUP -- fill the protection tuple from pipe. 10: ** 11: ** This routine is broken off from d_prot.c so that we 12: ** don't get symbol table overflows. 13: ** 14: ** Parameters: 15: ** protup -- pointer to the protection tuple to fill. 16: ** 17: ** Returns: 18: ** A bool telling whether we have PERMIT ALL TO ALL 19: ** permission. 20: ** 21: ** Side Effects: 22: ** The R_up pipe is flushed. 23: ** 24: ** History: 25: ** 4/16/80 (eric) -- broken off from d_prot for 6.2/10. 26: */ 27: 28: 29: extern struct pipfrmt Pipe; 30: 31: fillprotup(protup) 32: struct protect *protup; 33: { 34: register struct protect *pt; 35: register int i; 36: register char *p; 37: char buf[30]; 38: int all_pro; 39: auto int ix; 40: char ubuf[MAXLINE + 1]; 41: 42: /* 43: ** Fill in the protection tuple with the information 44: ** from the parser, validating as we go. 45: ** 46: ** Also, determine if we have a PERMIT xx to ALL 47: ** with no further qualification case. The variable 48: ** 'all_pro' is set to reflect this. 49: */ 50: 51: all_pro = TRUE; 52: pt = protup; 53: 54: /* read operation set */ 55: if (rdpipe(P_NORM, &Pipe, R_up, buf, 0) <= 0) 56: syserr("fillprotup: rdp#1"); 57: if (atoi(buf, &ix)) 58: syserr("fillprotup: atoi#1 %s", buf); 59: pt->proopset = ix; 60: if ((pt->proopset & PRO_RETR) != 0) 61: pt->proopset |= PRO_TEST | PRO_AGGR; 62: 63: /* read relation name */ 64: if (rdpipe(P_NORM, &Pipe, R_up, buf, 0) > MAXNAME + 1) 65: syserr("fillprotup: rdp#2"); 66: pmove(buf, pt->prorelid, MAXNAME, ' '); 67: 68: /* read relation owner */ 69: if (rdpipe(P_NORM, &Pipe, R_up, buf, 0) != 3) 70: syserr("fillprotup: rdp#3"); 71: bmove(buf, pt->prorelown, 2); 72: 73: /* read user name */ 74: rdpipe(P_NORM, &Pipe, R_up, buf, 0); 75: if (sequal(buf, "all")) 76: bmove(" ", pt->prouser, 2); 77: else 78: { 79: /* look up user in 'users' file */ 80: if (getnuser(buf, ubuf)) 81: ferror(3591, -1, Resultvar, buf, 0); 82: for (p = ubuf; *p != ':' && *p != 0; p++) 83: continue; 84: bmove(++p, pt->prouser, 2); 85: if (p[0] == ':' || p[1] == ':' || p[2] != ':') 86: syserr("fillprotup: users %s", ubuf); 87: all_pro = FALSE; 88: } 89: 90: /* read terminal id */ 91: rdpipe(P_NORM, &Pipe, R_up, buf, 0); 92: if (sequal(buf, "all")) 93: { 94: # ifndef xV7_UNIX 95: pt->proterm = ' '; 96: # endif 97: # ifdef xV7_UNIX 98: bmove(" ", pt->proterm, 2); 99: # endif 100: } 101: else 102: { 103: # ifndef xV7_UNIX 104: pt->proterm = buf[3]; 105: buf[3] = 'x'; 106: if (!sequal(buf, "ttyx")) 107: ferror(3590, -1, Resultvar, buf, 0); 108: # endif 109: # ifdef xV7_UNIX 110: if (bequal(buf, "/dev/tty", 8)) 111: pmove(&buf[8], pt->proterm, 2, ' '); 112: else if (bequal(buf, "/dev/", 5)) 113: pmove(&buf[5], pt->proterm, 2, ' '); 114: else if (bequal(buf, "tty", 3)) 115: pmove(&buf[3], pt->proterm, 2, ' '); 116: else 117: pmove(buf, pt->proterm, 2, ' '); 118: # endif 119: all_pro = FALSE; 120: } 121: 122: /* read starting time of day */ 123: rdpipe(P_NORM, &Pipe, R_up, buf, 0); 124: if (atoi(buf, &ix)) 125: syserr("fillprotup: atoi#5 %s", buf); 126: pt->protodbgn = ix; 127: if (ix > 0) 128: all_pro = FALSE; 129: 130: /* read ending time of day */ 131: rdpipe(P_NORM, &Pipe, R_up, buf, 0); 132: if (atoi(buf, &ix)) 133: syserr("fillprotup: atoi#6 %s", buf); 134: pt->protodend = ix; 135: if (ix < 24 * 60 - 1) 136: all_pro = FALSE; 137: 138: /* read beginning day of week */ 139: rdpipe(P_NORM, &Pipe, R_up, buf, 0); 140: i = cvt_dow(buf); 141: if (i < 0) 142: ferror(3594, -1, Resultvar, buf, 0); /* bad dow */ 143: pt->prodowbgn = i; 144: if (i > 0) 145: all_pro = FALSE; 146: 147: /* read ending day of week */ 148: rdpipe(P_NORM, &Pipe, R_up, buf, 0); 149: i = cvt_dow(buf); 150: if (i < 0) 151: ferror(3594, -1, Resultvar, buf, 0); /* bad dow */ 152: pt->prodowend = i; 153: if (i < 6) 154: all_pro = FALSE; 155: 156: /* finished with pipe... */ 157: rdpipe(P_SYNC, &Pipe, R_up); 158: 159: return (all_pro); 160: }