Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!munnari!gwydir!gara!wtoomey From: wtoomey@gara.une.oz (Warren Toomey) Newsgroups: comp.os.minix Subject: Official Clam Patch #2 (Part 3 of 4) Message-ID: <781@gara.une.oz> Date: 1 Jun 89 10:35:30 GMT Organization: University of New England, Armidale, Australia Lines: 626 # This is a shell archive. Remove anything before this line, then # unpack it by saving it in a file and typing "sh file". (Files # unpacked will be owned by you and have default permissions.) # # This archive contains: # exec.cdif global.c hash.cdif header.hdif echo x - exec.cdif cat > "exec.cdif" << '//E*O*F exec.cdif//' *** ../Patch1/exec.c Thu Jun 1 17:02:51 1989 --- exec.c Thu Jun 1 16:54:59 1989 *************** *** 19,25 struct adefn *alias_defn; int stopflg,NoIoctl=0; ! void setexec() { #ifdef ATT struct termio tbuf; --- 19,26 ----- struct adefn *alias_defn; int stopflg,NoIoctl=0; ! void setexec(pid) ! int pid; { #ifdef ATT struct termio tbuf; *************** *** 46,51 fprintf(stderr,"set exec\n"); #endif termod=(struct sgttyb *) malloc ((unsigned)(sizeof(struct sgttyb))); if (ioctl(0,TIOCGETP,termod)) perror("ioctl in setexec"); termod->sg_flags &= (~CBREAK); /* cooked mode */ --- 47,53 ----- fprintf(stderr,"set exec\n"); #endif + /*** All this will be rewritten ***/ termod=(struct sgttyb *) malloc ((unsigned)(sizeof(struct sgttyb))); if (ioctl(0,TIOCGETP,termod)) perror("ioctl in setexec"); termod->sg_flags &= (~CBREAK); /* cooked mode */ *************** *** 51,56 termod->sg_flags &= (~CBREAK); /* cooked mode */ termod->sg_flags |= ECHO; /* with echo */ if (ioctl(0,TIOCSETN,termod)) perror("ioctl"); setsigc=(struct tchars *) malloc ((unsigned)(sizeof(struct tchars))); if (ioctl(0,TIOCGETC,setsigc)) perror("ioctl"); setsigc->t_intrc=03; /* interrupt ctrl c */ --- 53,59 ----- termod->sg_flags &= (~CBREAK); /* cooked mode */ termod->sg_flags |= ECHO; /* with echo */ if (ioctl(0,TIOCSETN,termod)) perror("ioctl"); + free(termod); setsigc=(struct tchars *) malloc ((unsigned)(sizeof(struct tchars))); if (ioctl(0,TIOCGETC,setsigc)) perror("ioctl"); setsigc->t_intrc=03; /* interrupt ctrl c */ *************** *** 57,62 setsigc->t_quitc=034; /* quit ctrl \ */ setsigc->t_eofc=04; /* eof ctrl d */ if (ioctl(0,TIOCSETC,setsigc)) perror("ioctl"); # ifndef MINIX moresigc.t_suspc=032; /* suspend ctrl z */ moresigc.t_dsuspc=031; /* delayed suspend ctrl y */ --- 60,66 ----- setsigc->t_quitc=034; /* quit ctrl \ */ setsigc->t_eofc=04; /* eof ctrl d */ if (ioctl(0,TIOCSETC,setsigc)) perror("ioctl"); + free(setsigc); # ifndef MINIX moresigc.t_suspc=032; /* suspend ctrl z */ moresigc.t_dsuspc=031; /* delayed suspend ctrl y */ *************** *** 65,70 moresigc.t_werasc=027; /* word erase ctrl w */ moresigc.t_lnextc=026; /* literal next char ctrl v */ if (ioctl(0,TIOCSLTC,&moresigc)) perror("ioctl"); # endif #endif --- 69,86 ----- moresigc.t_werasc=027; /* word erase ctrl w */ moresigc.t_lnextc=026; /* literal next char ctrl v */ if (ioctl(0,TIOCSLTC,&moresigc)) perror("ioctl"); + if (pid) /* this is so when setexec is called without pid just to set the + signal keys, it doesn't repeat this bit (if that ever happens). */ + { + if (ioctl(0,TIOCSPGRP,&pid)) perror("ioctl spg"); + #ifdef DEBUG + if (ioctl(0,TIOCGPGRP,&pid)) perror("Dioctl"); + fprintf(stderr,"terminal's pgrp is %d\n",pid); + fprintf(stderr,"Setting pgrp to %d\n",pid); + #endif + if (setpgrp(pid,pid)) perror("setpgrp"); + signal(SIGTTIN,SIG_DFL); + } # endif /*** end of rewrite ***/ *************** *** 66,71 moresigc.t_lnextc=026; /* literal next char ctrl v */ if (ioctl(0,TIOCSLTC,&moresigc)) perror("ioctl"); # endif #endif --- 82,88 ----- signal(SIGTTIN,SIG_DFL); } # endif + /*** end of rewrite ***/ #endif *************** *** 76,81 #ifndef MINIX int pid; pid=getpid(); setpgrp(pid,pid); signal(SIGTTIN,SIG_DFL); --- 93,101 ----- #ifndef MINIX int pid; + #ifdef DEBUG + fprintf(stderr,"setbgexec\n"); + #endif pid=getpid(); setpgrp(pid,pid); signal(SIGTTIN,SIG_DFL); *************** *** 176,185 { if (stopflg) break; retval=0; - #if 0 - /* WAS: same problem here as in main.c:fopen() */ - act=intercom(line,&pos,&pid,FALSE,NULL,fromfile); - #else act=intercom(line,&pos,&pid, &i, FALSE,fromfile); #endif --- 196,201 ----- { if (stopflg) break; retval=0; act=intercom(line,&pos,&pid, &i, FALSE,fromfile); #ifdef DEBUG *************** *** 181,187 act=intercom(line,&pos,&pid,FALSE,NULL,fromfile); #else act=intercom(line,&pos,&pid, &i, FALSE,fromfile); - #endif #ifdef DEBUG fprintf(stderr,"pid returned from intercom is %d for line %s\n",pid,line); --- 197,202 ----- if (stopflg) break; retval=0; act=intercom(line,&pos,&pid, &i, FALSE,fromfile); #ifdef DEBUG fprintf(stderr,"pid returned from intercom is %d for line %s\n",pid,line); *************** *** 187,195 fprintf(stderr,"pid returned from intercom is %d for line %s\n",pid,line); fprintf(stderr,"fileno(zin) is %d\n",fileno(zin)); #endif - #if 0 - for (i=3;i<=20;i++) if (i!=fileno(zin)) close(i); - #else for (i=3;i<=NFILES;i++) if (i!=fileno(zin)) close(i); #endif if (pid && act!=BCKGND) --- 202,207 ----- fprintf(stderr,"pid returned from intercom is %d for line %s\n",pid,line); fprintf(stderr,"fileno(zin) is %d\n",fileno(zin)); #endif for (i=3;i<=NFILES;i++) if (i!=fileno(zin)) close(i); if (pid && act!=BCKGND) retval=waitfor(pid); *************** *** 191,197 for (i=3;i<=20;i++) if (i!=fileno(zin)) close(i); #else for (i=3;i<=NFILES;i++) if (i!=fileno(zin)) close(i); - #endif if (pid && act!=BCKGND) retval=waitfor(pid); #ifndef MINIX --- 203,208 ----- fprintf(stderr,"fileno(zin) is %d\n",fileno(zin)); #endif for (i=3;i<=NFILES;i++) if (i!=fileno(zin)) close(i); if (pid && act!=BCKGND) retval=waitfor(pid); #ifndef MINIX *************** *** 552,560 #endif } } - #if 0 - for (fd=3;fd<20;fd++) - #else for (fd=3;fd "global.c" << '//E*O*F global.c//' /****************************************************************************** ** ** ** global.c ** ** Some global declarations for the entire program. ** ** ** ******************************************************************************/ #include "header.h" char termcapbuf[1024],bs[10],nd[10],cl[10],cd[10],up[10],so[10],se[10],beep[20],yankbuf[256],*invokename,**arguments,*current_alias,*newenv[MAXARG]; FILE *zin,*zout,*fopen(); int lenprompt,curr_hist,maxhist=0,wid,h_hits,h_misses,hits,misses,beeplength,fromfile,disable_auto,numargs,jobdone,globpid; int O_execstring=0,O_exiterror=0,O_faststart=0,O_interact,O_noexec=0,O_echoline=0,O_echoexp=0,O_echobefore=0,O_echoexpbefore=0; bool hashed,loginsh; /* Clam terminal driver characteristics which must always be set for Clam. */ struct sgttyb clam_sgttyb; struct tchars clam_tchars; #ifndef MINIX struct ltchars clam_ltchars; #endif //E*O*F global.c// echo x - hash.cdif cat > "hash.cdif" << '//E*O*F hash.cdif//' *** ../Patch1/hash.c Thu Jun 1 17:03:06 1989 --- hash.c Thu Jun 1 16:55:14 1989 *************** *** 31,37 char *dir,*entname; int nojoin; { ! struct stat *buf; char fpn[MAXWL]; buf=(struct stat *) malloc ((unsigned)(sizeof(struct stat))); --- 31,37 ----- char *dir,*entname; int nojoin; { ! struct stat buf; char fpn[MAXWL]; if (nojoin) *************** *** 34,40 struct stat *buf; char fpn[MAXWL]; - buf=(struct stat *) malloc ((unsigned)(sizeof(struct stat))); if (nojoin) stat(dir,buf); else --- 34,39 ----- struct stat buf; char fpn[MAXWL]; if (nojoin) stat(dir,&buf); else *************** *** 36,42 buf=(struct stat *) malloc ((unsigned)(sizeof(struct stat))); if (nojoin) ! stat(dir,buf); else { sprintf(fpn,"%s/%s",dir,entname); --- 35,41 ----- char fpn[MAXWL]; if (nojoin) ! stat(dir,&buf); else { sprintf(fpn,"%s/%s",dir,entname); *************** *** 40,46 else { sprintf(fpn,"%s/%s",dir,entname); ! stat(fpn,buf); } if (((buf->st_mode & S_IFMT)==S_IFREG) && (buf->st_mode & 0111)) return(TRUE); return(FALSE); --- 39,45 ----- else { sprintf(fpn,"%s/%s",dir,entname); ! stat(fpn,&buf); } if (((buf.st_mode & S_IFMT)==S_IFREG) && (buf.st_mode & 0111)) return(TRUE); *************** *** 42,48 sprintf(fpn,"%s/%s",dir,entname); stat(fpn,buf); } ! if (((buf->st_mode & S_IFMT)==S_IFREG) && (buf->st_mode & 0111)) return(TRUE); return(FALSE); } --- 41,48 ----- sprintf(fpn,"%s/%s",dir,entname); stat(fpn,&buf); } ! if (((buf.st_mode & S_IFMT)==S_IFREG) && (buf.st_mode & 0111)) ! return(TRUE); return(FALSE); } *************** *** 196,201 return; } strcpy(path,vget("PATH")); for (times=0;timesd_name[0]=='.' && (entry->d_name[1]==EOS || entry->d_name[1]=='.')) continue; + if (!executable(entry->d_name,"",1)) continue; + hashval=hash(entry->d_name); + for (times=0;hasharray[hashval].name!=NULL && timesd_name)); + #endif + h_misses++; + if (times==HSHSIZ) + { + write(2,"Hash table is full. Cannot complete hash.\n",42); + /* allow the partial hash and just return */ + return; + } + } + + /* Having found a blank position we now malloc some space and copy the values */ + hasharray[hashval].name=(char *) malloc ((unsigned)(strlen(entry->d_name)+1)); + strcpy(hasharray[hashval].name,entry->d_name); + hasharray[hashval].exec_ptr.dir=(char *) malloc ((unsigned)(strlen(dir)+1)); + strcpy(hasharray[hashval].exec_ptr.dir,dir); + hasharray[hashval].type=0; + } + closedir(dd); + } + else + fprintf(stderr,"Can't open directory: %s\n",dir); + } + + /* shouldn't have to malloc for entry since opendir does it, hopefully */ if ((dd=opendir(dir))!=NULL) { *************** *** 238,243 if (times==0) h_hits++; else { h_misses++; if (times==HSHSIZ) { --- 293,301 ----- if (times==0) h_hits++; else { + #ifdef DEBUG + fprintf(stderr,"Hash missed on %d\n",hash(entry->d_name)); + #endif h_misses++; if (times==HSHSIZ) { //E*O*F hash.cdif// echo x - header.hdif cat > "header.hdif" << '//E*O*F header.hdif//' *** ../Patch1/header.h Thu Jun 1 17:03:20 1989 --- header.h Thu Jun 1 16:55:28 1989 *************** *** 108,113 /* Some general defines */ #define EOS '\0' #define UNDEF -1 /* Identification for error codes for metacharacter expansion function */ #ifdef OK /* defined somewhere on minixST */ --- 108,114 ----- /* Some general defines */ #define EOS '\0' #define UNDEF -1 + #define NFILES 20 /* Identification for error codes for metacharacter expansion function */ #ifdef OK /* defined somewhere on minixST */ *************** *** 215,222 void insert(char *, int, int, int *); void show(char *, int *, bool); void goend(char *, int *, int *); ! void copyback(char *, int, int *); ! void delword(char *, int, int *); void backword(char *, int *, int *); void forword(char *, int *, int *); void yanknext(char *, int, char *); --- 216,224 ----- void insert(char *, int, int, int *); void show(char *, int *, bool); void goend(char *, int *, int *); ! void copyback(char *, int, int *, int); ! void delnextword(char *, int, int *); ! void delprevword(char *, int, int *); void backword(char *, int *, int *); void forword(char *, int *, int *); void yanknext(char *, int, char *); *************** *** 230,236 bool expand_tilde(char *, int *); void help(char *, int, int *); ! void setexec(void); void setbgexec(void); void resetsigdefaults(void); bool findslash(char *); --- 232,238 ----- bool expand_tilde(char *, int *); void help(char *, int, int *); ! void setexec(int); void setbgexec(void); void resetsigdefaults(void); bool findslash(char *); //E*O*F header.hdif// exit 0