home *** CD-ROM | disk | FTP | other *** search
- From: purdon@athena.mit.edu (James R. Purdon III)
- Newsgroups: alt.sources
- Subject: slugnet - Multiple user conferencing system: Part 4 of 6
- Message-ID: <1990Dec20.164646.25441@athena.mit.edu>
- Date: 20 Dec 90 16:46:46 GMT
-
- The slugnet program is a multiple-user, interactive conferencing
- facility. It currently runs under a variety of System V-based and
- BSD-based operating systems (although certain functions may not be
- possible under some of these operating systems).
-
- Cut here-------------------------------------------------------------------
-
- #!/bin/sh
- # to extract, remove the header and type "sh filename"
- if `test ! -s ./slugnet.c`
- then
- echo "writing ./slugnet.c"
- cat > ./slugnet.c << '\End\Of\Shar\'
- /* @(#)slugnet.c 1.16 */
- #include "slugnet.h"
- #include <pwd.h>
-
- #ifdef NETWORK
- #ifdef INTERLAN
- #include <interlan/socket.h>
- #include <interlan/netdb.h>
- #include <interlan/in.h>
- #else
- #include <sys/socket.h>
- #include <netdb.h>
- #include <netinet/in.h>
- #endif
- #endif NETWORK
-
- #ifdef INTERLAN
- #include <interlan/il_ioctl.h>
- #else
- #include <sys/ioctl.h>
- #endif
-
- #ifdef NETWORK
- int slugnet( socket, rhost )
- int socket;
- char *rhost;
- #endif NETWORK
- #ifdef LOCAL
- main()
- #endif LOCAL
- {
-
- /* pointers */
-
- char *p[LINLEN];
-
- /* strings */
-
- static char access[FLNMLN]="\0";
- static char billing[4]="\0";
- static char broad[24]=" < broadcast message >";
- static char confer[CFRLEN]="\0"; /* conference name */
- static char crrct[52]="\nIs the above information correct ( yes or no )? : ";
- static char dprivs[FLNMLN]="\0"; /* default privileges */
- static char host[HOSTLEN]="\0"; /* host name */
- static char idfrmt[28]="\nFrom %s ( %s@%s / %s ):%s";
- static char idstr[LINLEN]="\0"; /* user id string */
- static char jsn[JSNLEN]="aaaa"; /* user jsn - incremented per job */
- static char last[UNLEN]="\0"; /* last valid un */
- static char line[LINLEN+80]="\0";
- static char logset[4]="\0";
- static char mode[MODELN]="U"; /* mode u = user, s = server */
- static char modem[LINLEN]="\0";
- static char msgbuf[MSGLEN]="\0";
- static char name[NAMLEN]="New user";
- static char newcfr[CFRLEN]="\0"; /* conference to join */
- static char normal[2]=BLANKS;
- static char notallow[34]=" Error: Insufficent privileges.\n";
- static char offstr[6]="off.\n";
- static char onstr[5]="on.\n";
- static char offtst[5]=" off";
- static char ontst[4]=" on";
- static char pid[PIDLEN]="\0"; /* pid in string form */
- static char portstr[4]="\0";
- static char prompt[PRMLEN]="\0";
- static char repeat[32]="Please answer 'yes' or 'no'. : ";
- static char scratch[ MSGLEN ]; /* scratch buffer */
- static char server[LINLEN]="\0"; /* server string */
- static char slugid[UNLEN]="\0";
- static char sndbuf[MSGLEN+80]="\0"; /* send buffer */
- static char srvnam[8]="Server";
- static char srvhst[HOSTLEN]; /* server host name */
- static char thost[HOSTLEN]; /* target host name for private messages */
- char *thstp; /* pointer for thost */
- static char tjsn[JSNLEN]; /* target jsn for private messages */
- static char un[UNLEN];
- static char uprivs[FLNMLN]="\0"; /* user privileges */
- static char usrerr[36];
- static char waitstr[LINLEN]; /* string for wait mode */
-
- /* files */
-
- static char actfil[FLNMLN]; /* system accounting file name */
- static char bgnfil[FLNMLN]; /* prelogin file name */
- static char bilfil[FLNMLN]; /* billing options file */
- static char confil[FLNMLN]; /* user configuration file name */
- static char deffil[FLNMLN]; /* user definition file name */
- static char dirfil[FLNMLN]; /* user directory file name */
- static char hlpfil[FLNMLN]; /* help file name */
- static char jsnfil[FLNMLN]; /* jsn file name */
- static char newfil[FLNMLN]; /* news file name */
- static char profil[FLNMLN]; /* user prologue file name */
- static char rcvfil[FLNMLN]; /* receiver file name */
- static char sysfil[FLNMLN]; /* system configuration file */
- static char tmpfil[FLNMLN]; /* user scratch file */
- static char usrfil[FLNMLN]; /* user directory file name */
- static char valfil[FLNMLN]; /* validated user list file name */
-
- /* slugdir record structure */
-
- struct slugdir inpstr; /* for usrfil */
-
- /* paths */
-
- static char homedir[DIRLEN];
- static char slugdir[DIRLEN];
-
- /* char functions */
-
- char *ctime(),*getcwd(),*getlogin();
-
- /* file descriptors */
-
- FILE *act,*con,*def,*hlp,*inp,*rcv,*snd,*tmp;
- #ifdef SYSV2
- FILE *fopen();
- #endif SYSV2
-
- /* ints */
-
- int atend,bci,bco,bill,brdcst,change,count[MSGLEN],cntns_flg,dtime,echo,
- echoplex,found,hlpon,hlp_found,i,ipid,j,join,k,l,login,msgpos,
- msgflg,novice,nwlnln,prvflg,prmpt_flg,reclen,remote,ringok,
- scroll,serial_number,soff,space,stop,timer,usr,wait;
- int allon,memon,conon,logon,hoson; /* flags for some show commands */
- unsigned int port; /* com port number */
- int in,out; /* file / socket descriptor */
- int fromlen; /* length of struct sockaddr */
-
- #ifdef NETWORK
- struct sockaddr_in from;
- struct sockaddr_in *fromp;
- #endif NETWORK
-
- /* stuff for ioctl */
-
- int off, on;
-
- struct hostent *hp;
-
- int admin,brods,dirct,files,joinc,names,network,privt,ringr,systm; /* privileges */
- #ifndef ULTRIX
- int euid, uid;
- #endif ULTRIX
-
- long time0,time1,time();
-
- #ifdef ULTRIX
- unsigned short uid, euid;
- #endif ULTRIX
- #ifdef SYSV2
- unsigned sleep(),u;
- void exit();
- #endif SYSV2
- #ifdef SYSV3
- unsigned sleep(),u;
- void exit();
- #endif SYSV3
- #ifdef ULTRIX
- void sleep();
- void exit();
- #endif ULTRIX
- #ifdef SYSV2
- void sigquit(),sigstop(),sighang(),sigterm();
- #endif SYSV2
- #ifdef SYSV3
- void sigquit(),sigstop(),sighang(),sigterm();
- #endif SYSV3
- #ifdef BSD4
- int sigurg(),sigtstp(),sigquit(),sigstop(),sighang(),sigterm();
- #endif BSD4
- #ifdef ULTRIX
- int sigurg(),sigtstp(),sigquit(),sigstop(),sighang(),sigterm();
- #endif ULTRIX
-
- /* password entry field */
-
- struct passwd *upasswd;
- struct passwd *getpwuid();
-
- /* these are used by ioctl */
-
- on = ON;
- off = OFF;
-
- /* initialize signal variables */
-
- hungup = OFF;
- stopscroll = OFF;
-
- /* get process id and host name */
-
- sprintf( pid, "%d", getpid());
- gethostname( host, HOSTLEN );
- strcpy( srvhst, host );
- #ifdef DBG
- fprintf( stderr, "pid: %s at 1\n", pid );
- #endif DBG
-
- /* set real and effective uids */
-
- uid = getuid();
- euid = geteuid();
-
- /* handle interrupts and hangups */
-
- #ifdef LOCAL
- signal(SIGHUP, sighang);
- signal(SIGQUIT, sigquit);
- #ifdef ULTRIX
- signal( SIGINT, sigstop);
- signal( SIGTSTP, sigtstp);
- #endif ULTRIX
- #ifdef BSD4
- signal( SIGINT, sigstop);
- signal( SIGTSTP, sigtstp);
- #endif BSD4
- #ifdef SYSV2
- signal(SIGINT , sigstop);
- #endif SYSV2
- #ifdef SYSV3
- signal(SIGINT , sigstop);
- #endif SYSV3
- #endif LOCAL
- #ifdef NETWORK
- signal(SIGHUP, sighang);
- signal(SIGQUIT, sigquit);
- #ifdef ULTRIX
- signal( SIGURG, sigurg);
- signal( SIGINT, sigstop);
- signal( SIGTSTP, sigtstp);
- #endif ULTRIX
- #ifdef BSD4
- signal( SIGURG, sigurg);
- signal( SIGINT, sigstop);
- signal( SIGTSTP, sigtstp);
- #endif BSD4
- #ifdef SYSV2
- signal(SIGINT ,sigstop);
- #endif SYSV2
- #ifdef SYSV3
- signal(SIGINT ,sigstop);
- #endif SYSV3
- #endif NETWORK
- signal(SIGTERM,sigterm);
-
-
- strcpy(tjsn," \0"); /* target jsn for private messages */
- strcpy(un,"\0");
- strcpy(usrerr," Error: chgusr return code is %d.\n");
- strcpy(waitstr,"\0"); /* string for wait mode */
-
- /* files */
-
- strcpy( actfil,"\0"); /* system accounting file name */
- strcpy( bgnfil,"\0"); /* prelogin file name */
- strcpy( bilfil,"\0"); /* billing options file */
- strcpy( confil,"\0"); /* user configuration file name */
- strcpy( deffil,"\0"); /* user definition file name */
- strcpy( dirfil,"\0"); /* user directory file name */
- strcpy( hlpfil,"\0"); /* help file name */
- strcpy( jsnfil,"\0"); /* jsn file name */
- strcpy( newfil,"\0"); /* news file name */
- strcpy( profil,"\0"); /* user prologue file name */
- strcpy( rcvfil,"\0"); /* receiver file name */
- strcpy( sysfil,"\0"); /* system configuration file */
- strcpy( tmpfil,"\0"); /* user scratch file */
- strcpy( usrfil,"\0"); /* user directory file name */
- strcpy( valfil,"\0"); /* validated user list file name */
-
- /* directories */
-
- strcpy( slugdir, SLUGDIR );
- #ifdef SYSV2
- i=setuid(uid);
- #endif SYSV2
- #ifdef SYSV3
- i=setuid(uid);
- #endif SYSV3
- getcwd( homedir, DIRLEN );
- #ifdef SYSV2
- i=setuid(euid);
- #endif SYSV2
- #ifdef SYSV3
- i=setuid(euid);
- #endif SYSV3
-
- bci=0;
- bco=0;
- nwlnln=strlen("\n");
- #ifdef NETWORK
- in=socket;
- out=socket;
- if( rhost != (char *)NULL ){
- on = ON;
- ioctl( in, FIONBIO, (char *)&on );
- }
- #endif NETWORK
- #ifdef LOCAL
- in=fileno(stdin);
- out=fileno( stdout );
- #endif LOCAL
- #ifdef DBG
- fprintf( stderr, "pid: %s at 2\n", pid );
- #endif DBG
- reclen = sizeof( struct slugdir );
- serial_number=NULL;
- /* sprintf(slugid,"SLUGNET%4x0000",serial_number); */
- /* get server name */
- upasswd = getpwuid( euid );
- strcpy(slugid,upasswd->pw_name );
- repchar(slugid,' ','0');
- strcpy(un,slugid);
- strcpy(last,un);
-
- sprintf(server,idfrmt,srvnam,slugid,srvhst,jsn,normal);
-
- /* set directory to slugnet */
-
- i = chdir( slugdir );
-
- if( i != NULL )
- {
- bco=bco+transmit(out,"\nUnable to change to directory 'slugnet'.",NOCRLF);
- return(1);
- }
- /* set up system configuration */
-
- strcpy(line,"\0");
- if(DEBUG==ON && euid==uid)
- {
- bco=bco+transmit(out,"\nEnter name of system configuration file. : ",NOCRLF);
- bci=bci+receive( in,line,FLNMLN,OFF);
- }
- if(strlen(line)<=12)
- sscanf(line,"%s",sysfil);
- else
- sscanf(line,"%15s",sysfil);
- if(strlen(sysfil)==0)
- strcpy(sysfil,"slugsys.dat");
-
- if((i=getcfg(sysfil,access,actfil,bgnfil,billing,bilfil,deffil,dirfil,
- hlpfil,jsnfil,logset,modem,newfil,portstr,dprivs,profil,usrfil,valfil))!=NULL)
- {
- bco=bco+transmit(out,server,CRLF);
- sprintf(line," Error: getcfg return code is %d.\n",i);
- bco=bco+transmit(out,line,NOCRLF);
- return(2);
- }
-
- /* set billing flag */
-
- if(strncmp(billing,onstr,2)==NULL)
- bill=ON;
- else
- bill=OFF;
-
- /* set login flag */
-
- if(strncmp(logset,onstr,2)==NULL)
- login=ON;
- else
- login=OFF;
-
- if(DEBUG==ON && euid==uid)
- {
- sprintf(line,"\nSystem Configuration\n");
- sprintf(line," acc: %s",access);
- i=transmit(out,line,CRLF);
- sprintf(line," act: %s",actfil);
- i=transmit(out,line,CRLF);
- sprintf(line," bgn: %s",bgnfil);
- i=transmit(out,line,CRLF);
- sprintf(line," bil: %s",billing);
- i=transmit(out,line,CRLF);
- sprintf(line," blf: %s",bilfil);
- i=transmit(out,line,CRLF);
- sprintf(line," def: %s",deffil);
- i=transmit(out,line,CRLF);
- sprintf(line," dir: %s",dirfil);
- i=transmit(out,line,CRLF);
- sprintf(line," hlp: %s",hlpfil);
- i=transmit(out,line,CRLF);
- sprintf(line," jsn: %s",jsnfil);
- i=transmit(out,line,CRLF);
- sprintf(line," log: %s",logset);
- i=transmit(out,line,CRLF);
- sprintf(line," mod: %s",modem);
- i=transmit(out,line,CRLF);
- sprintf(line," new: %s",newfil);
- i=transmit(out,line,CRLF);
- sscanf(portstr,"%u",&port);
- sprintf(line," por: %u",port);
- i=transmit(out,line,CRLF);
- sprintf(line," pri: %s",dprivs);
- i=transmit(out,line,CRLF);
- sprintf(line," pro: %s",profil);
- i=transmit(out,line,CRLF);
- sprintf(line," sys: %s",sysfil);
- i=transmit(out,line,CRLF);
- sprintf(line," usr: %s",usrfil);
- i=transmit(out,line,CRLF);
- sprintf(line," val: %s",valfil);
- i=transmit(out,line,CRLF);
- sprintf(line,"%s",crrct);
- i=transmit(out,line,NOCRLF);
- yno:
- i=receive( in,line,LINLEN,OFF);
- if(strncmp(line,"n",1)==NULL) return(3);
- if(strncmp(line,"y",1)!=NULL)
- {
- printf("%s\n",line);
- sprintf(line,"%s",repeat);
- i=transmit(out,line,NOCRLF);
- goto yno;
- }
- }
-
- /* wait for calls */
-
- wait_for_call:
-
- /* initialize variables */
-
- bci=0;
- bco=0;
- cntns_flg=OFF;
- echo=ON;
- echoplex=OFF;
- found=OFF;
- #ifdef LOCAL
- prmpt_flg=ON;
- #endif LOCAL
- #ifdef NETWORK
- if( rhost != (char *)NULL )
- prmpt_flg = OFF;
- else
- prmpt_flg=ON;
- #endif NETWORK
- strcpy(uprivs,dprivs);
-
- /* see if access allowed */
-
- soff=open("slugnet.off",O_RDONLY);
- if( soff >= NULL )
- {
- bco=bco+transmit(out,"Slugnet is currently unavailable.\n",CRLF );
- return(4);
- }
- j=close(soff);
-
- /* get start time */
-
- time(&time0);
- #ifdef LOCAL
- /* send prelogin news */
-
- bco=bco+transmit(out,"Slugnet on line.\n",CRLF);
- bco=bco+send_file(out,bgnfil);
- #endif LOCAL
- #ifdef NETWORK
-
- /* if internodal client, send server command */
-
- if( rhost != (char *)NULL ){
- strcpy( name, "Server" );
- bco = bco + transmit(out,"set server on\n",CRLF);
- } else {
-
- /* send prelogin news */
-
- bco=bco+transmit(out,"Slugnet on line.\n",CRLF);
- bco=bco+send_file(out,bgnfil);
- }
- #endif NETWORK
- #ifdef DBG
- fprintf( stderr, "pid: %s at 3\n", pid );
- #endif DBG
-
- #ifdef NETWORK
- if( rhost == (char *)NULL ){
- fromlen = sizeof( from );
- if(getpeername( out, &from, &fromlen ) == 0 ) {
- #ifdef DBG
- fprintf( stderr, "pid: %s at 4a\n", pid );
- #endif DBG
- fromp = &from;
- fromp->sin_port = ntohs((u_short)fromp->sin_port);
- if((hp = gethostbyaddr( &fromp->sin_addr, sizeof( struct in_addr ), fromp->sin_family )) != (struct hostent *)NULL) {
- #ifdef DBG
- fprintf( stderr, "pid: %s at 5a\n", pid );
- #endif DBG
- strcpy( host, hp->h_name );
- } else {
- #ifdef DBG
- fprintf( stderr, "pid: %s at 5b\n", pid );
- #endif DBG
- strcpy( host, inet_ntoa( from.sin_addr ));
- }
- }
- strcpy( un, "unknown" );
- } else {
- hp = gethostent();
- strcpy( host, hp->h_name );
- upasswd = getpwuid( uid );
- strcpy(un,upasswd->pw_name );
- }
- #ifdef DBG
- fprintf( stderr, "pid: %s at 5c\n", pid );
- #endif DBG
- #endif NETWORK
- #ifdef LOCAL
- upasswd = getpwuid( uid );
- strcpy(un,upasswd->pw_name );
- #endif LOCAL
- #ifdef DBG
- fprintf( stderr, "pid: %s at 6\n", pid );
- #endif DBG
-
- /* initialize session variables */
-
- /* if uid equals euid, set all privileges */
-
- #ifdef LOCAL
- if( uid == euid )
- strcpy(uprivs,"_abdfjnprs");
- #endif LOCAL
-
- /* assign privileges */
-
- if(find(uprivs,'a',15)>NULL)
- admin=ON; /* administrator */
- else
- admin=OFF;
- if(find(uprivs,'b',15)>NULL)
- brods=ON; /* broadcast allowed */
- else
- brods=OFF;
- if(find(uprivs,'d',15)>NULL)
- dirct=ON; /* redirection allowed */
- else
- dirct=OFF;
- if(find(uprivs,'f',15)>NULL)
- files=ON; /* access to files allowed */
- else
- files=OFF;
- if(find(uprivs,'j',15)>NULL)
- joinc=ON; /* join command allowed */
- else
- joinc=OFF;
- if(find(uprivs,'n',15)>NULL)
- names=ON; /* set name command allowed */
- else
- names=OFF;
- if(find(uprivs,'p',15)>NULL)
- privt=ON; /* private messages allowed */
- else
- privt=OFF;
- if(find(uprivs,'r',15)>NULL)
- ringr=ON; /* ring command allowed */
- else
- ringr=OFF;
- if(find(uprivs,'s',15)>NULL)
- systm=ON; /* Shell access allowed */
- else
- systm=OFF;
- #ifdef NETWORK
- network = ON;
- #endif NETWORK
- #ifdef LOCAL
- network = OFF;
- #endif LOCAL
- #ifdef DBG
- fprintf( stderr, "pid: %s at 7\n", pid );
- #endif DBG
- atend=OFF;
- brdcst=OFF;
- strcpy(confer,"Root");
- if(login==OFF)
- strcpy(confil,"slugcon.dat");
- else
- sprintf(confil,"slug%s.dat",un[11]);
- dtime=15;
- #ifdef NETWORK
- in=socket;
- #endif NETWORK
- #ifdef LOCAL
- in = fileno( stdin );
- #endif LOCAL
- inp=(FILE *)NULL;
- join=OFF;
- strcpy(mode,"U");
- #ifdef NETWORK
- if( rhost != (char *)NULL ){
- strcpy(mode,"S");
- dtime = 1;
- }
- #endif NETWORK
- msgflg=ON;
- msgpos=0;
- msgbuf[msgpos]=(char)NULL;
- #ifdef NETWORK
- out=socket;
- #endif NETWORK
- #ifdef LOCAL
- out = fileno( stdout );
- novice=ON;
- echo=ON;
- #endif LOCAL
- #ifdef NETWORK
- if( rhost != (char *)NULL ){
- novice=OFF;
- echo=OFF;
- } else {
- novice=ON;
- echo=ON;
- }
- #endif NETWORK
- prvflg=OFF;
- remote=OFF;
- ringok=ON;
- scroll=OFF;
- sprintf(server,idfrmt,srvnam,slugid,srvhst,jsn,normal);
- stop=OFF;
- timer=ON;
- wait=OFF;
- strcpy(waitstr,"From");
-
- /* read user's configuration file, if it exists */
-
- #ifdef SYSV2
- i=setuid(uid);
- #endif SYSV2
- #ifdef SYSV3
- i=setuid(uid);
- #endif SYSV3
- i=chdir(homedir);
- con=fopen(confil,"r");
- if(con!=NULL)
- {
- fscanf(con,"%s ",deffil);
- i=repchar(deffil,'_',' ');
- fscanf(con,"%u ",&dtime);
- fscanf(con,"%d ",&echo);
- fscanf(con,"%d ",&echoplex);
- fscanf(con,"%s ",name);
- i=repchar(name,'_',' ');
- fscanf(con,"%d ",&novice);
- fscanf(con,"%s ",profil);
- i=repchar(profil,'_',' ');
- fscanf(con,"%d ",&prmpt_flg);
- fscanf(con,"%d ",&ringok);
- fscanf(con,"%d ",&timer);
- fscanf(con,"%s ",waitstr);
- i=repchar(waitstr,'_',' ');
- j=fclose(con);
- }
- #ifdef SYSV2
- i=setuid(euid);
- #endif SYSV2
- #ifdef SYSV3
- i=setuid(euid);
- #endif SYSV3
- i=chdir(slugdir);
-
- /* setup jsn */
-
- if((i=getjsn(jsn,jsnfil,rcvfil))!=NULL)
- {
- bco=bco+transmit(out,server,CRLF);
- sprintf(line," Error: getjsn return code is %d.\n",i);
- bco=bco+transmit(out,line,NOCRLF);
- return(5);
- }
-
- /* send postlogin news */
-
- sprintf(server,idfrmt,srvnam,slugid,srvhst,jsn,normal);
- #ifdef LOCAL
- bco=bco+transmit(out,BLANKS,CRLF);
- bco=bco+transmit(out,server,CRLF);
- bco=bco+transmit(out," Welcome to Slugnet!",CRLF);
- bco=bco+send_file(out,newfil);
- #endif LOCAL
- #ifdef NETWORK
- if( rhost == (char *)NULL ){
- bco=bco+transmit(out,BLANKS,CRLF);
- bco=bco+transmit(out,server,CRLF);
- bco=bco+transmit(out," Welcome to Slugnet!",CRLF);
- bco=bco+send_file(out,newfil);
- }
- #endif NETWORK
-
- /* put user in user directory */
-
- if((i=chgusr(name,un,jsn,confer,rcvfil,usrfil,OFF,host,pid,mode))!=NULL)
- {
- bco=bco+transmit(out,server,CRLF);
- sprintf(line,usrerr,i);
- bco=bco+transmit(out,line,CRLF);
- return(6);
- }
-
- /* build logon message */
-
- sprintf(sndbuf,"$server:a:%s:%s:%s:%s:%s:%s:\n %s\n %s ( %s@%s / %s ) logged on %s.\n$server:m:%s:\n",name,un,host,jsn,confer,mode,server,name,un,host,jsn,confer,confer);
-
- /* do prologue file, if present */
-
- #ifdef SYSV2
- i=setuid(uid);
- #endif SYSV2
- #ifdef SYSV3
- i=setuid(uid);
- #endif SYSV3
- i=chdir(homedir);
- inp=fopen(profil,"r");
- #ifdef SYSV2
- i=setuid(euid);
- #endif SYSV2
- #ifdef SYSV3
- i=setuid(euid);
- #endif SYSV3
- i=chdir(slugdir);
-
- /* main loop */
-
- while(strncmp(line,"exit",4)!=NULL)
- {
- /* send message */
-
- sndmsg:
- if(msgflg==ON||brdcst==ON||prvflg==ON)
- {
- #ifdef DBGC
- if( mode[ 0 ] == 'S' )
- fprintf( stderr, "s:%s",sndbuf );
- #endif DBGC
- lock(usrfil);
- #ifdef SYSV2
- usr=open(usrfil,O_RDWR|O_SYNC);
- #endif SYSV2
- #ifdef SYSV3
- usr=open(usrfil,O_RDWR|O_SYNC);
- #endif SYSV3
- #ifdef BSD4
- usr=open(usrfil,O_RDWR|O_FSYNC);
- #endif BSD4
- #ifdef ULTRIX
- usr=open(usrfil,O_RDWR|O_FSYNC);
- #endif ULTRIX
- scratch[ 0 ] = ( char )NULL;
- for(;;)
- {
- #ifdef SYSV2
- j=read(usr,&inpstr,(unsigned)reclen);
- #endif SYSV2
- #ifdef SYSV3
- j=read(usr,&inpstr,(unsigned)reclen);
- #endif SYSV3
- #ifdef BSD4
- j=read(usr,&inpstr,reclen);
- #endif BSD4
- #ifdef ULTRIX
- j=read(usr,&inpstr,reclen);
- #endif ULTRIX
- if( j == NULL )
- break;
-
- /* see if the jsn is valid */
-
- if(strncmp(inpstr.jsn," ",JSNLEN-1)!=NULL){
-
- /* make sure the process is alive */
-
- sscanf( inpstr.pid, "%d", &ipid );
-
- if(kill(ipid,NULL)<NULL && strcmp( inpstr.confer, confer ) == NULL ) {
-
- sprintf(msgbuf,"\n$server:d:%s:%s:%s:%s:%s:%s:\n %s\n %s ( %s@%s / %s ) disconnected.\n$server:m:%s:\n",inpstr.name,inpstr.un,inpstr.host,inpstr.jsn,inpstr.confer,inpstr.mode,server,inpstr.name,inpstr.un,inpstr.host,inpstr.jsn,inpstr.confer);
- strcat( scratch, msgbuf );
- msgbuf[ 0 ] = (char)NULL;
- strcpy( inpstr.jsn, " " );
-
-
- #ifndef SYSV2
- j=lseek(usr,-(long)reclen,SEEK_CUR);
- #endif SYSV2
- #ifdef SYSV2
- j=lseek(usr,-(long)reclen,CURRENT);
- #endif SYSV2
- #ifdef SYSV2
- j=write(usr,&inpstr,(unsigned)reclen);
- #endif SYSV2
- #ifdef SYSV3
- j=write(usr,&inpstr,(unsigned)reclen);
- #endif SYSV3
- #ifdef BSD4
- j=write(usr,&inpstr,reclen);
- #endif BSD4
- #ifdef ULTRIX
- j=write(usr,&inpstr,reclen);
- #endif ULTRIX
-
- /* unlink rcvfil */
-
- if( strncmp( inpstr.rcvfil, "*", 1 ) != NULL )
- unlink( inpstr.rcvfil );
-
-
-
-
- } else if( strncmp(inpstr.confer,confer,strlen(confer))==NULL
- && strncmp(inpstr.jsn,jsn,JSNLEN-1)!=NULL
- && strncmp(inpstr.rcvfil,"*",1)!=NULL
- && msgflg==ON ){
- lock(inpstr.rcvfil);
- snd=fopen(inpstr.rcvfil,"a");
- fprintf(snd,"%s\n",sndbuf);
- j=fclose(snd);
- unlock(inpstr.rcvfil);
- } else if( strncmp(inpstr.jsn,jsn,JSNLEN-1)!=NULL
- && strncmp(inpstr.rcvfil,"*",1)!=NULL
- && brdcst==ON ){
- lock(inpstr.rcvfil);
- snd=fopen(inpstr.rcvfil,"a");
- fprintf(snd,"%s\n",sndbuf);
- j=fclose(snd);
- unlock(inpstr.rcvfil);
- } else if( strncmp(inpstr.jsn,jsn,JSNLEN-1)!=NULL
- && strncmp(inpstr.rcvfil,"*",1)!=NULL
- && strncmp( inpstr.mode,"S",1)==NULL
- && ( brdcst==ON || msgflg == ON || prvflg == ON )){
- lock(inpstr.rcvfil);
- snd=fopen(inpstr.rcvfil,"a");
- fprintf(snd,"%s\n",sndbuf);
- j=fclose(snd);
- unlock(inpstr.rcvfil);
- } else if( strncmp(inpstr.confer,confer,strlen(confer))==NULL
- && strncmp(inpstr.jsn,tjsn,JSNLEN-1)==NULL
- && strncmp(inpstr.jsn,jsn,JSNLEN-1)!=NULL
- && strncmp(inpstr.rcvfil,"*",1)!=NULL
- && ( thost[ 0 ] == NULL || strnicmp( inpstr.host, thost, strlen( thost )) == NULL )
- && prvflg==ON ){
- lock(inpstr.rcvfil);
- snd=fopen(inpstr.rcvfil,"a");
- fprintf(snd,"%s\n",sndbuf);
- j=fclose(snd);
- unlock(inpstr.rcvfil);
- } else if( strncmp(inpstr.jsn,jsn,JSNLEN-1)==NULL
- && echo==ON && join==OFF ){
- lock(inpstr.rcvfil);
- snd=fopen(inpstr.rcvfil,"a");
- fprintf(snd,"%s\n",sndbuf);
- j=fclose(snd);
- unlock(inpstr.rcvfil);
- }
- }
- }
-
- j=close(usr);
- unlock(usrfil);
-
- /* clean up disconnects */
-
- if( scratch[ 0 ] != (char )NULL ){
- strcpy( sndbuf, scratch );
- goto sndmsg;
- }
-
- /* do join */
-
- if(join==ON)
- {
- join=OFF;
- strcpy(confer,newcfr);
- sprintf(sndbuf,"$server:c:%s:%s:%s:%s:%s:%s:\n %s\n %s ( %s@%s / %s ) logged on %s.\n$server:m:%s:\n",name,un,host,jsn,confer,mode,server,name,un,host,jsn,confer,confer);
- if((i=chgusr(name,un,jsn,confer,rcvfil,usrfil,OFF,host,pid,mode))!=NULL)
- {
- bco=bco+transmit(out,server,CRLF);
- sprintf(line,usrerr,i);
- bco=bco+transmit(out,line,CRLF);
- return(7);
- }
- goto sndmsg;
- }
-
- /* do exit or bye */
-
- if(atend==ON)
- {
- /* update accounting file */
-
- lock(actfil);
- act=fopen(actfil,"a");
- chmod(actfil,00600);
- time(&time1);
- i = (int)(time1 - time0);
- fprintf(act,"%s@%s:%s:%d:%d:%d:%d:%d:%s",un,host,jsn,bci,bco,time0,time1,i,(char *)ctime(&time0));
- i=fclose(act);
- unlock(actfil);
-
- /* remove user from directory */
-
- if((i=chgusr(name,un,jsn,confer,rcvfil,usrfil,ON,host,pid,mode))!=NULL)
- {
- bco=bco+transmit(out,server,NOCRLF);
- sprintf(line,usrerr,i);
- bco=bco+transmit(out,line,CRLF);
- return(8);
- }
- goto cleanup;
- }
- }
-
- /* print and reset user's receive file */
-
- if(remote==OFF)
- {
- lock(rcvfil);
- rcv=fopen(rcvfil,"r");
- }
-
- /* bco=bco+send_file(out,rcvfil); */
-
- space = OFF;
- while(feof(rcv)==NULL)
- {
- i=rdline(rcv,line,LINLEN);
- #ifdef DBGC
- if( mode[ 0 ] == 'S' )
- fprintf( stderr, "rf: %s\n", line );
- #endif DBGC
- if( i > 0 && wait == OFF ) space = ON;
- if(mode[0] == 'S' && line[ 0 ] == '$' ){
- bco=bco+transmit(out,line,CRLF);
- }
- else if(line[ 0 ] == '$' && strncmp(line+1,jsn,JSNLEN-1)==NULL ){
- for(i=5;i<LINLEN;++i) line[i-5]=line[i];
- remote=ON;
- unlock(rcvfil);
- goto parser;
- }
- if(line[ 0 ] != '$' && (i = strlen( line )) > 0 )
- bco=bco+transmit(out,line,CRLF);
- if(wait==ON)
- {
- j=strlen(waitstr);
- for(i=0;(i+j-1)<strlen(line);++i)
- {
- if(strncmp(line+i,waitstr,j)==NULL){
- wait=OFF;
- #ifdef NETWORK
- off = OFF;
- if( ioctl( in, FIONBIO, (char *)&off ) < NULL )
- perror( "ioctl2" );
- #endif NETWORK
- }
- }
- }
- }
- if( space == ON && mode[ 0 ] != 'S' ) bco = bco + transmit( out, "\n", NOCRLF );
- i=fclose(rcv);
- i=unlink(rcvfil);
- rcv=fopen(rcvfil,"a");
- i=fclose(rcv);
- unlock(rcvfil);
-
- /* reset message flags */
-
- brdcst=OFF;
- msgflg=OFF;
- prvflg=OFF;
- remote=OFF;
-
- /* display prompt */
-
- prompter:
-
- /* see if SIGINT has been sent ( stops scroll and wait mode ) */
-
- if(stopscroll==ON)
- {
- scroll=OFF;
- wait=OFF;
- stopscroll=OFF;
- #ifdef LOCAL
- /* reset input */
-
- if( inp != (FILE *)NULL ) {
- fclose( inp );
- inp = (FILE *)NULL;
- in = fileno( stdin );
- }
-
- #endif LOCAL
-
- }
-
- /* display prompt */
-
- if(scroll==OFF&&wait==OFF)
- {
- if(prmpt_flg)
- {
- sprintf(prompt,"%s> ",confer);
- bco=bco+transmit(out,prompt,NOCRLF);
- }
- if(cntns_flg)
- sleep((unsigned)dtime);
- }
-
- /* clear line */
-
- for(i=0;i<LINLEN;++i) line[i]=(char)NULL;
-
- /* if scroll or wait mode, skip user input */
-
- if(scroll==ON||wait==ON)
- {
- #ifdef NETWORK
- /* check the socket for activity */
-
- if( read( in, line, LINLEN ) > 0 ) {
- stopscroll = ON;
- off = OFF;
- if( ioctl( in, FIONBIO, (char *)&off ) < NULL )
- perror( "ioctl2" );
- goto prompter;
- }
- #endif NETWORK
- if(timer==ON)
- {
- time(&time1);
- bco=bco+transmit(out,(char *)ctime(&time1),CRLF);
- }
- #ifdef SYSV2
- sleep((unsigned)dtime);
- #endif SYSV2
- #ifdef SYSV3
- u=sleep((unsigned)dtime);
- #endif SYSV3
- #ifdef BSD4
- sleep((unsigned)dtime);
- #endif BSD4
- #ifdef ULTRIX
- sleep((unsigned)dtime);
- #endif ULTRIX
- goto parser;
- }
-
- /* get input from user */
-
- getinp:
- if(inp==(FILE *)NULL) {
- /*if( mode[ 0 ] == 'S' )
- bco=bco+transmit(out,"\n",NOCRLF);*/
- bci=bci+receive( in,line,LINLEN,echoplex);
- #ifdef DBGC
- if( mode[ 0 ] == 'S' )
- fprintf( stderr, "rr: %s", line );
- #endif DBGC
- if( mode[ 0 ] == 'S' )
- sleep(( unsigned )dtime );
- /* strcpy( un, hp->h_name ); */
- } else {
- if(feof(inp)==NULL)
- {
- bco=bco+transmit(out,"\n",CRLF);
- i=rdline(inp,line,LINLEN);
- }
- else
- {
- i=fclose(inp);
- inp=(FILE *)NULL;
- goto getinp;
- }
- }
-
- /* command parser */
-
- parser:
- /* strcpy( un, hp->h_name ); */
-
- /* if user has hung up, do an "exit" command */
-
- if(hungup==ON)
- {
- strcpy(line,"exit");
- }
-
- /* restore effective uid, just in case */
-
- #ifdef SYSV2
- i=setuid(euid);
- #endif SYSV2
- #ifdef SYSV3
- i=setuid(euid);
- #endif SYSV3
-
- /* comments */
-
- if(strncmp(line,"*",1)==NULL)
- {
- if(echo==ON) bco=bco+transmit(out,line,CRLF);
- goto prompter;
- }
-
- /* process server commands */
-
- else if(strnicmp(line,"$server:",8)==NULL && mode[ 0 ] == 'S' ){
-
- /* directory change commands */
-
- if( line[ 8 ] == 'a' ||
- line[ 8 ] == 'c' ||
- line[ 8 ] == 'd' ){
-
- /* replace : with nulls and set pointers */
-
- j = strlen( line );
- k = 0;
- for( i = 9; i < j; ++i ){
- if( line[ i ] == ':' ){
- line[ i ] = (char )NULL;
- ++i;
- p[ k ] = line + i;
- ++k;
- }
- }
-
- /* issue chgusr command */
-
- if( line[ 8 ] == 'c')
- i=chgusr(p[ 0 ],p[ 1 ],p[ 3 ],p[ 4 ],"*",usrfil,OFF,p[ 2 ],pid,p[ 5 ]);
- else if( line[ 8 ] == 'a' ){
- setjsn( p[ 3 ], jsnfil );
- i=chgusr(p[ 0 ],p[ 1 ],p[ 3 ],p[ 4 ],"*",usrfil,OFF,p[ 2 ],pid,p[ 5 ]);
- } else if( line[ 8 ] == 'd' )
- i=chgusr(p[ 0 ],p[ 1 ],p[ 3 ],p[ 4 ],"*",usrfil,ON,p[ 2 ],pid,p[ 5 ]);
-
- /* send connection report */
-
- } else if( line[ 8 ] == 'r' ){
- lock(usrfil);
- #ifdef SYSV2
- usr=open(usrfil,O_RDWR|O_SYNC);
- #endif SYSV2
- #ifdef SYSV3
- usr=open(usrfil,O_RDWR|O_SYNC);
- #endif SYSV3
- #ifdef BSD4
- usr=open(usrfil,O_RDWR|O_FSYNC);
- #endif BSD4
- #ifdef ULTRIX
- usr=open(usrfil,O_RDWR|O_FSYNC);
- #endif ULTRIX
- for(;;){
- #ifdef SYSV2
- j=read(usr,&inpstr,(unsigned)reclen);
- #endif SYSV2
- #ifdef SYSV3
- j=read(usr,&inpstr,(unsigned)reclen);
- #endif SYSV3
- #ifdef BSD4
- j=read(usr,&inpstr,reclen);
- #endif BSD4
- #ifdef ULTRIX
- j=read(usr,&inpstr,reclen);
- #endif ULTRIX
- if( j == NULL )
- break;
-
- /* only send registered jsns */
-
- if(strncmp(inpstr.jsn," ",JSNLEN-1)!=NULL && ( strncmp(inpstr.jsn,jsn,JSNLEN-1) != NULL || strnicmp(inpstr.host,host,HOSTLEN-1) != NULL )){
- sprintf(sndbuf,"\n$server:a:%s:%s:%s:%s:%s:%s:\n %s\n %s ( %s@%s / %s ) connected.\n$server:m:%s:\n",inpstr.name,inpstr.un,inpstr.host,inpstr.jsn,inpstr.confer,inpstr.mode,server,inpstr.name,inpstr.un,inpstr.host,inpstr.jsn,inpstr.confer);
- bco=bco+transmit(out,sndbuf,CRLF);
- }
- }
- j=close(usr);
- unlock(usrfil);
-
- /* message commands */
-
- } else if( line[ 8 ] == 'b' ){
- strcpy( line, "broadcast" );
- goto parser;
- } else {
- j = strlen( line );
- for( i = 10; i < j; ++i ){
- if( line[ i ] == ':' ) {
- line[ i ] = (char)NULL;
- break;
- }
- }
- if( line[ 8 ] == 'm' ){
- strcpy( confer, &line[ 10 ]);
- strcpy( line, "send" );
- goto parser;
- }
- else if( line[ 8 ] == 'p' ){
- strcpy( tjsn, &line[ 10 ]);
- sprintf( line, "send %s", tjsn );
- goto parser;
- }
- }
- }
-
- /* set commands */
-
- else if(strnicmp(line,"set",3)==NULL)
- {
- change = OFF;
- bco=bco+transmit(out,server,CRLF);
-
- /* set server mode */
-
- if(strnicmp(line+3," server",7)==NULL)
- {
- #ifdef SERVER
- if(strncmp(line+10,ontst,3)==NULL){
- echo = OFF;
- mode[ 0 ] = 'S';
- prmpt_flg = OFF;
- strcpy( name, "Server" );
- dtime=1;
- on = ON;
- ioctl( in, FIONBIO, (char *)&on );
- } else if(strncmp(line+10,offtst,4)==NULL){
- echo = ON;
- mode[ 0 ] = 'U';
- prmpt_flg = ON;
- strcpy( name, "unknown" );
- off = OFF;
- ioctl( in, FIONBIO, (char *)&off );
- }
- if((i=chgusr(name,un,jsn,confer,rcvfil,usrfil,OFF,host,pid,mode)) != NULL ){
- bco=bco+transmit(out,server,CRLF);
- sprintf(line," Error: chgusr return code is %d.\n",i);
- bco=bco+transmit(out,line,CRLF);
- return(9);
- }
- #endif SERVER
- sprintf(line," Server mode set ");
- if(mode[ 0 ] == 'S' ){
- strcat(line,onstr);
- strcat(line,"\n$server:r:");
- } else
- strcat(line,offstr);
- }
-
- /* set name */
-
- else if(strnicmp(line+3," name",5)==NULL)
- {
- if(names==ON)
- {
- if(strncmp(line+8,BLANKS,1)==NULL)
- strncpy(name,line+9,32);
- if(strlen(name)==0)
- strcpy(name,"Anonymous");
-
- /* remove colons */
-
- j = strlen( name );
- for( i = 0; i < j; ++i ){
- if( name[ i ] == ':' )
- name[ i ] = ' ';
- }
-
- /* change user directory */
-
- if((i=chgusr(name,un,jsn,confer,rcvfil,usrfil,OFF,host,pid,mode))!=NULL)
- {
- bco=bco+transmit(out,server,CRLF);
- sprintf(line," Error: chgusr return code is %d.\n",i);
- bco=bco+transmit(out,line,CRLF);
- return(10);
- }
- sprintf(line," Name set to %s.\n",name);
- change = ON;
- }
- else
- strcpy(line,notallow);
- }
-
- /* set definition file name */
-
- else if(strnicmp(line+3," definition",11)==NULL)
- {
- if(files==ON)
- {
- #ifdef SYSV2
- i=setuid(uid);
- #endif SYSV2
- #ifdef SYSV3
- i=setuid(uid);
- #endif SYSV3
- if(strncmp(line+14,BLANKS,1)==NULL)
- strncpy(deffil,line+15,12);
- if(strlen(deffil)==0)
- strcpy(deffil,"slugdef.dat");
- def=fopen(deffil,"r");
- if(def!=NULL)
- {
- sprintf(line," Definition file set to %s.\n",deffil);
- i=fclose(def);
- }
- else
- sprintf(line," Definition file name set to %s, which does not exist.\n",deffil);
- #ifdef SYSV2
- i=setuid(euid);
- #endif SYSV2
- #ifdef SYSV3
- i=setuid(euid);
- #endif SYSV3
- }
- else
- strcpy(line,notallow);
- }
-
- /* set prologue file name */
-
- else if(strnicmp(line+3," prologue",9)==NULL)
- {
- if(files==ON)
- {
- #ifdef SYSV2
- i=setuid(uid);
- #endif SYSV2
- #ifdef SYSV3
- i=setuid(uid);
- #endif SYSV3
- if(strncmp(line+12,BLANKS,1)==NULL)
- strncpy(profil,line+15,12);
- if(strlen(profil)==0)
- strcpy(deffil,"slugpro.dat");
- def=fopen(profil,"r");
- if(def!=NULL)
- {
- sprintf(line," Prologue file set to %s.\n",deffil);
- i=fclose(def);
- }
- else
- sprintf(line," Prologue file name set to %s, which does not exist.\n",deffil);
- #ifdef SYSV2
- i=setuid(euid);
- #endif SYSV2
- #ifdef SYSV3
- i=setuid(euid);
- #endif SYSV3
- }
- else
- strcpy(line,notallow);
- }
-
- /* set wait string */
-
- else if(strnicmp(line+3," wait",5)==NULL)
- {
- if(strncmp(line+8,BLANKS,1)==NULL)
- strcpy(waitstr,line+9);
- if(strlen(waitstr)==0)
- strcpy(waitstr,"From");
- sprintf(line," Wait string set to %s.\n",waitstr);
- }
-
- /* set delay time */
-
- else if(strnicmp(line+3," delay",6)==NULL)
- {
- if(strncmp(line+9,BLANKS,1)==NULL)
- sscanf(line+10,"%d",&dtime);
- if(dtime<=0)
- dtime=15;
- sprintf(line," Delay time set to %d.\n",dtime);
- }
-
- /* set prompt mode */
-
- else if(strnicmp(line+3," prompt",7)==NULL)
- {
- if(strncmp(line+10,ontst,3)==NULL)
- prmpt_flg=ON;
- if(strncmp(line+10,offtst,4)==NULL)
- prmpt_flg=OFF;
- sprintf(line," Prompt set ");
- if(prmpt_flg==ON)
- strcat(line,onstr);
- else
- strcat(line,offstr);
- }
-
- /* set continuous mode */
-
- else if(strnicmp(line+3," continuous",11)==NULL)
- {
- if(strncmp(line+14,ontst,3)==NULL) {
- cntns_flg=ON;
- prmpt_flg=OFF;
- on = ON;
- if( ioctl( in, FIONBIO, (char *)&on ) < NULL )
- perror( "ioctl" );
- }
- if(strncmp(line+14,offtst,4)==NULL) {
- cntns_flg=OFF;
- prmpt_flg=ON;
- off = OFF;
- if( ioctl( in, FIONBIO, (char *)&off ) < NULL )
- perror( "ioctl" );
- }
- sprintf(line," Continuous mode set ");
- if(cntns_flg==ON) {
- strcat(line,onstr);
- } else {
- strcat(line,offstr);
- }
- }
-
- /* set novice mode */
-
- else if(strnicmp(line+3," novice",7)==NULL)
- {
- if(strncmp(line+10,ontst,3)==NULL)
- novice=ON;
- if(strncmp(line+10,offtst,4)==NULL)
- novice=OFF;
- sprintf(line," Novice mode set ");
- if(novice==ON)
- strcat(line,onstr);
- else
- strcat(line,offstr);
- }
-
- /* set timer mode */
-
- else if(strnicmp(line+3," timer",6)==NULL)
- {
- if(strncmp(line+9,ontst,3)==NULL)
- timer=ON;
- if(strncmp(line+9,offtst,4)==NULL)
- timer=OFF;
- sprintf(line," Timer mode set ");
- if(timer==ON)
- strcat(line,onstr);
- else
- strcat(line,offstr);
- }
-
- /* set echo mode */
-
- else if(strnicmp(line+3," echo",5)==NULL)
- {
- if(strncmp(line+8,ontst,3)==NULL)
- echo=ON;
- if(strncmp(line+8,offtst,4)==NULL)
- echo=OFF;
- sprintf(line," Echo mode set ");
- if(echo==ON)
- strcat(line,onstr);
- else
- strcat(line,offstr);
- }
-
- /* set echoplex */
-
- else if(strnicmp(line+3," echoplex",9)==NULL)
- {
- if(strncmp(line+12,ontst,3)==NULL)
- echoplex=ON;
- if(strncmp(line+12,offtst,4)==NULL)
- echoplex=OFF;
- sprintf(line," Echoplex set ");
- if(echoplex==ON)
- strcat(line,onstr);
- else
- strcat(line,offstr);
- }
-
- /* set echo mode */
-
- else if(strnicmp(line+3," echo",5)==NULL)
- {
- if(strncmp(line+8,ontst,3)==NULL)
- echo=ON;
- if(strncmp(line+8,offtst,4)==NULL)
- echo=OFF;
- sprintf(line," Echo mode set ");
- if(echo==ON)
- strcat(line,onstr);
- else
- strcat(line,offstr);
- }
-
- /* set ring mode */
-
- else if(strnicmp(line+3," ring",5)==NULL)
- {
- if(ringr==ON)
- {
- if(strncmp(line+8,ontst,3)==NULL)
- ringok=ON;
- if(strncmp(line+8,offtst,4)==NULL)
- ringok=OFF;
- sprintf(line," Ring mode set ");
- if(ringok==ON)
- strcat(line,onstr);
- else
- strcat(line,offstr);
- }
- else
- sprintf(line,notallow,CRLF,port);
- }
-
- /* set configuration */
-
- else if(strnicmp(line+3," config",7)==NULL)
- {
- if(files==ON)
- {
- #ifdef SYSV2
- i=setuid(uid);
- #endif SYSV2
- #ifdef SYSV3
- i=setuid(uid);
- #endif SYSV3
- i=chdir(homedir);
- con=fopen(confil,"w");
- chmod(confil,00600);
- i=repchar(deffil,' ','_');
- fprintf(con,"%s ",deffil);
- i=repchar(deffil,'_',' ');
- fprintf(con,"%u ",dtime);
- fprintf(con,"%d ",echo);
- fprintf(con,"%d ",echoplex);
- i=repchar(name,' ','_');
- fprintf(con,"%s ",name);
- i=repchar(name,'_',' ');
- fprintf(con,"%d ",novice);
- i=repchar(profil,' ','_');
- fprintf(con,"%s ",profil);
- i=repchar(profil,'_',' ');
- fprintf(con,"%d ",prmpt_flg);
- fprintf(con,"%d ",ringok);
- fprintf(con,"%d ",timer);
- i=repchar(waitstr,' ','_');
- fprintf(con,"%s ",waitstr);
- i=repchar(waitstr,'_',' ');
- j=fclose(con);
- #ifdef SYSV2
- i=setuid(euid);
- #endif SYSV2
- #ifdef SYSV3
- i=setuid(euid);
- #endif SYSV3
- i=chdir(slugdir);
- sprintf(line," Current configuration saved.\n");
- }
- else
- strcpy(line,notallow);
- }
-
- /* set login name */
-
- else if(strnicmp(line+3," login",6)==NULL)
- {
- if( network==ON )
- {
- if(strncmp(line+9,BLANKS,1)==NULL)
- {
- strncpy(un,line+10,UNLEN);
-
-
- /* try to verify */
-
- if( !verify( un, host ))
- un[ 0 ] = ( char )NULL;
-
- }
- if(strlen(un)==0)
- strcpy(un,"unknown");
-
- /* remove colons */
-
- j = strlen( un );
- for( i = 0; i < j; ++i ){
- if( un[ i ] == ':' )
- un[ i ] = ' ';
- }
-
- /* change user directory */
-
- if((i=chgusr(name,un,jsn,confer,rcvfil,usrfil,OFF,host,pid,mode))!=NULL)
- {
- bco=bco+transmit(out,server,CRLF);
- sprintf(line," Error: chgusr return code is %d.\n",i);
- bco=bco+transmit(out,line,CRLF);
- }
- sprintf(line," Login set to %s.\n",un);
- change = ON;
- }
- else
- strcpy(line,notallow);
- }
- else
- {
- sprintf(line," Error: Type \"help set\" for a list of options.\n");
- }
- bco=bco+transmit(out,line,CRLF);
- if( change ){
- sprintf(sndbuf,"$server:c:%s:%s:%s:%s:%s:%s:\n",name,un,host,jsn,confer,mode);
- brdcst=ON;
- goto sndmsg;
- }
- }
-
- /* show commands */
-
- else if(strnicmp(line,"show",4)==NULL)
- {
-
- bco=bco+transmit(out,server,CRLF);
- allon=OFF;
- conon=OFF;
- memon=OFF;
- logon=OFF;
- hoson=OFF;
- if(strnicmp(line+4," all",4)==NULL
- && admin==ON)
- {
- bco=bco+transmit(out, " JSN Login Hostname PID Mode Conference", CRLF);
- allon=ON;
- sprintf( scratch, " %%-4.4s %%-8.8s %%-16.16s %%-8.8s %%-1s %%-%ds", CFRLEN );
- }
- else if(strnicmp(line+4," buffer",7)==NULL)
- {
- if(strlen(msgbuf)==0)
- bco=bco+transmit(out," Error: empty message buffer.\n",CRLF);
- else
- {
- bco=bco+transmit(out," Contents of message buffer:",CRLF);
- for(i=0;i<strlen(msgbuf);++i)
- {
- sprintf(line,"%c",msgbuf[i]);
- bco=bco+transmit(out,line,NOCRLF);
- if(msgbuf[i]==(char)LF) bco=bco+transmit(out,"\r",NOCRLF);
- }
- bco=bco+transmit(out,BLANKS,CRLF);
- }
- }
- else if(strnicmp(line+4," confer",7)==NULL)
- {
- bco=bco+transmit(out," Users Conference name",CRLF);
- conon=ON;
- l= -1;
- }
- else if(strnicmp(line+4," config",7)==NULL)
- {
- bco=bco+transmit(out," Attribute State",CRLF);
- sprintf(line," definition file.. %s",deffil);
- bco=bco+transmit(out,line,CRLF);
- sprintf(line," delay time....... %d",dtime);
- bco=bco+transmit(out,line,CRLF);
- bco=bco+transmit(out," echo mode........",NOCRLF);
- if(echo==ON)
- bco=bco+transmit(out,ontst,CRLF);
- else
- bco=bco+transmit(out,offtst,CRLF);
- bco=bco+transmit(out," echoplex.........",NOCRLF);
- if(echoplex==ON)
- bco=bco+transmit(out,ontst,CRLF);
- else
- bco=bco+transmit(out,offtst,CRLF);
- sprintf(line," name............. %s",name);
- bco=bco+transmit(out,line,CRLF);
- bco=bco+transmit(out," novice mode......",NOCRLF);
- if(novice==ON)
- bco=bco+transmit(out,ontst,CRLF);
- else
- bco=bco+transmit(out,offtst,CRLF);
- sprintf(line," prologue file.... %s",profil);
- bco=bco+transmit(out,line,CRLF);
- bco=bco+transmit(out," prompt mode......",NOCRLF);
- if(prmpt_flg==ON)
- bco=bco+transmit(out,ontst,CRLF);
- else
- bco=bco+transmit(out,offtst,CRLF);
- bco=bco+transmit(out," ring mode........",NOCRLF);
- if(ringok==ON)
- bco=bco+transmit(out,ontst,CRLF);
- else
- bco=bco+transmit(out,offtst,CRLF);
- bco=bco+transmit(out," timer mode.......",NOCRLF);
- if(timer==ON)
- bco=bco+transmit(out,ontst,CRLF);
- else
- bco=bco+transmit(out,offtst,CRLF);
- sprintf(line," wait string...... %s\n",waitstr);
- bco=bco+transmit(out,line,CRLF);
- }
- else if(strnicmp(line+4," members",8)==NULL)
- {
- bco=bco+transmit(out," JSN Login Hostname Name",CRLF);
- memon=ON;
- sprintf( scratch, " %%-4.4s %%-8.8s %%-16.16s %%-%ds", NAMLEN );
- }
- else if(strnicmp(line+4," hosts",6)==NULL)
- {
- sprintf( scratch, " JSN%%-%ds Hostname%%-%ds", JSNLEN-3, HOSTLEN-8 );
- sprintf( line, scratch, BLANKS, BLANKS );
- bco=bco+transmit(out,line,CRLF);
- hoson=ON;
- sprintf( scratch, " %%-%ds %%-%ds", JSNLEN, HOSTLEN );
- }
- else if(strnicmp(line+4," logins",7)==NULL)
- {
- sprintf( scratch, " JSN%%-%ds Login%%-%ds", JSNLEN-3, UNLEN-5 );
- sprintf( line, scratch, BLANKS, BLANKS );
- bco=bco+transmit(out,line,CRLF);
- logon=ON;
- sprintf( scratch, " %%-%ds %%-%ds", JSNLEN, UNLEN );
- }
- else
- {
- sprintf(line," Error: Type \"help show\" for a list of options.\n");
- bco=bco+transmit(out,line,CRLF);
- }
-
- /* do directory show command */
-
- if(allon==ON||memon==ON||conon==ON||hoson==ON||logon==ON)
- {
- lock(usrfil);
- usr=open(usrfil,O_RDONLY);
- for(;;)
- {
- #ifdef SYSV2
- j=read(usr,&inpstr,(unsigned)reclen);
- #endif SYSV2
- #ifdef SYSV3
- j=read(usr,&inpstr,(unsigned)reclen);
- #endif SYSV3
- #ifdef BSD4
- j=read(usr,&inpstr,reclen);
- #endif BSD4
- #ifdef ULTRIX
- j=read(usr,&inpstr,reclen);
- #endif ULTRIX
- if( j == NULL )
- break;
- if(allon==ON
- && strncmp(inpstr.jsn," ",JSNLEN-1)!=NULL)
- {
- sprintf(line, scratch,
- inpstr.jsn,
- inpstr.un,
- inpstr.host,
- inpstr.pid,
- inpstr.mode,
- inpstr.confer);
- bco=bco+transmit(out,line,CRLF);
- }
- else if(memon==ON
- && strncmp(inpstr.confer,confer,strlen(confer))==NULL
- && strncmp(inpstr.jsn," ",JSNLEN-1)!=NULL
- && strncmp( inpstr.mode,"S",1)!=NULL)
- {
- sprintf(line, scratch,
- inpstr.jsn,
- inpstr.un,
- inpstr.host,
- inpstr.name);
- bco=bco+transmit(out,line,CRLF);
- }
- else if(hoson==ON
- && strncmp(inpstr.confer,confer,strlen(confer))==NULL
- && strncmp(inpstr.jsn," ",JSNLEN-1)!=NULL
- && strncmp( inpstr.mode,"S",1)!=NULL)
- {
- sprintf(line, scratch,
- inpstr.jsn,
- inpstr.host );
- bco=bco+transmit(out,line,CRLF);
- }
- else if(logon==ON
- && strncmp(inpstr.confer,confer,strlen(confer))==NULL
- && strncmp(inpstr.jsn," ",JSNLEN-1)!=NULL
- && strncmp( inpstr.mode,"S",1)!=NULL)
- {
- sprintf(line, scratch,
- inpstr.jsn,
- inpstr.un);
- bco=bco+transmit(out,line,CRLF);
- }
- else if(conon==ON
- && strncmp(inpstr.confer,"-",1)!=NULL
- && strncmp(inpstr.jsn," ",JSNLEN-1)!=NULL
- && strncmp( inpstr.mode,"S",1)!=NULL)
- {
- found=OFF;
- if(l<NULL)
- {
- l=0;
- count[l]=1;
- strcpy(sndbuf+(l*CFRLEN),
- inpstr.confer);
- found=ON;
- }
- else
- {
- for(k=0;k<=l;++k)
- {
- if(strncmp(inpstr.confer,
- sndbuf+(k*CFRLEN),
- strlen(sndbuf+(k*CFRLEN)))==NULL)
- {
- ++count[k];
- found=ON;
- }
- }
- }
- if(found==OFF)
- {
- ++l;
- count[l]=1;
- strcpy(sndbuf+(l*CFRLEN),
- inpstr.confer);
- }
- }
- }
- j=close(usr);
- unlock(usrfil);
- if(conon==ON)
- {
- for(i=0;i<=l;++i)
- {
- sprintf(line," %5d %s",count[i],sndbuf+(i*CFRLEN));
- bco=bco+transmit(out,line,CRLF);
- }
- }
- bco=bco+transmit(out,BLANKS,CRLF);
- }
- }
-
- /* pass through to system */
-
- else if(strncmp(line,"!",1)==NULL)
- {
- if(systm==ON)
- {
- #ifdef SYSV2
- i=setuid(uid);
- #endif SYSV2
- #ifdef SYSV3
- i=setuid(uid);
- #endif SYSV3
- i=chdir(homedir);
- i=system(line+1);
- if(i!=NULL)
- {
- bco=bco+transmit(out,server,CRLF);
- sprintf(line," Error: system return code is %d\n",i);
- bco=bco+transmit(out,line,CRLF);
- }
- #ifdef SYSV2
- i=setuid(euid);
- #endif SYSV2
- #ifdef SYSV3
- i=setuid(euid);
- #endif SYSV3
- i=chdir(slugdir);
- }
- else
- {
- bco=bco+transmit(out,server,CRLF);
- bco=bco+transmit(out,notallow,CRLF);
- }
-
- }
-
- /* output redirection */
-
- else if(strncmp(line,">",1)==NULL)
- {
- if(files==ON && dirct==ON)
- {
- #ifdef SYSV2
- i=setuid(uid);
- #endif SYSV2
- #ifdef SYSV3
- i=setuid(uid);
- #endif SYSV3
- i=chdir(homedir);
- bco=bco+transmit(out,server,CRLF);
- if(strlen(line+1)==0||strncmp(line+1,"output",6)==NULL)
- {
- bco=bco+transmit(out," Output redirection terminated.\n",CRLF);
- i=close(out);
- #ifdef NETWORK
- out=socket;
- #endif NETWORK
- #ifdef LOCAL
- out=fileno( stdout );
- #endif LOCAL
- }
- else
- {
- sprintf(sndbuf," Redirecting output to %s.\n",line+1);
- bco=bco+transmit(out,sndbuf,CRLF);
- out=open(line+1, O_APPEND | O_CREAT,
- 00600 );
- if(out==NULL)
- {
- bco=bco+transmit(out,server,CRLF);
- sprintf(sndbuf," Error: Unable to redirect output to %s.\n",
- line+1);
- bco=bco+transmit(out,sndbuf,CRLF);
- }
- else
- chmod(line+1,00600);
- }
- #ifdef SYSV2
- i=setuid(euid);
- #endif SYSV2
- #ifdef SYSV3
- i=setuid(euid);
- #endif SYSV3
- i=chdir(slugdir);
- }
- else
- {
- bco=bco+transmit(out,server,CRLF);
- bco=bco+transmit(out,notallow,CRLF);
- }
- }
-
- /* input redirection */
-
- else if(strncmp(line,"<",1)==NULL)
- {
- if(dirct==ON && files==ON)
- {
- #ifdef SYSV2
- i=setuid(uid);
- #endif SYSV2
- #ifdef SYSV3
- i=setuid(uid);
- #endif SYSV3
- i=chdir(homedir);
- bco=bco+transmit(out,server,CRLF);
- if(strlen(line+1)==0||strncmp(line+1,"input",5)==NULL)
- {
- bco=bco+transmit(out," Input redirection terminated.\n",CRLF);
- i=fclose(inp);
- inp=NULL;
- }
- else
- {
- sprintf(sndbuf," Redirecting input to %s.\n",
- line+1);
- bco=bco+transmit(out,sndbuf,CRLF);
- inp=fopen(line+1,"r");
- if(inp==NULL)
- {
- bco=bco+transmit(out,server,CRLF);
- sprintf(sndbuf," Error: Unable to redirect input to %s.\n",line+1);
- bco=bco+transmit(out,sndbuf,CRLF);
- }
- }
- #ifdef SYSV2
- i=setuid(euid);
- #endif SYSV2
- #ifdef SYSV3
- i=setuid(euid);
- #endif SYSV3
- i=chdir(slugdir);
- }
- else
- {
- bco=bco+transmit(out,server,CRLF);
- bco=bco+transmit(out,notallow,CRLF);
- }
- }
-
- /* add line to message buffer */
-
- else if( strncmp(line,BLANKS,1)==NULL
- || (strncmp(line, "From",4) == NULL && mode[ 0 ] == 'S')
- || (strncmp(line, "\n",1) == NULL && mode[ 0 ] == 'S' )){
- i=strlen(line);
- if((i+msgpos+nwlnln)<MSGLEN)
- {
- strcat(msgbuf,line);
- if( line[ 0 ] != '\n' )
- strcat(msgbuf,"\n");
- msgpos=msgpos+i+nwlnln;
- }
- else
- {
- bco=bco+transmit(out,server,CRLF);
- sprintf(line," Error: Message buffer is full.\n");
- bco=bco+transmit(out,line,CRLF);
- }
- }
-
- /* send private message */
-
- else if(strnicmp(line,"send ",5)==NULL && msgpos>0)
- {
- if(privt==ON)
- {
- prvflg=ON;
- strncpy(tjsn,line+5,JSNLEN-1);
- if(( thstp = strchr( line, '@' )) != (char *)NULL ){
- strcpy( thost, ++thstp );
- } else
- thost[ 0 ] = ( char )NULL;
- if( mode[ 0 ] == 'U' ){
- sprintf(line," < private message to %s >",tjsn);
- sprintf(idstr,idfrmt,name,un,host,jsn,line);
- if( thost[ 0 ] != ( char )NULL)
- sprintf(sndbuf," %s\n%s\n$server:p:%s@%s:\n",idstr,msgbuf,tjsn,thost);
- else
- sprintf(sndbuf," %s\n%s\n$server:p:%s:\n",idstr,msgbuf,tjsn);
- } else if( mode[ 0 ] == 'S' )
- strcpy( sndbuf, msgbuf );
- msgpos=0;
- msgbuf[msgpos]=(char)NULL;
- goto sndmsg;
- }
- else
- bco=bco+transmit(out,notallow,CRLF);
- }
-
- /* send public message */
-
- else if((strnicmp(line,"send",4)==NULL||(strlen(line)==0&&mode[ 0 ] != 'S') || line[ 0 ] == '\n' )&&msgpos>0 ){
- msgflg=ON;
- if( mode[ 0 ] == 'U' ){
- sprintf(idstr,idfrmt,name,un,host,jsn,normal);
- sprintf(sndbuf," %s\n%s\n$server:m:%s:\n",idstr,msgbuf,confer);
- } else if( mode[ 0 ] == 'S' )
- strcpy( sndbuf, msgbuf );
- msgpos=0;
- msgbuf[msgpos]=(char)NULL;
- goto sndmsg;
- }
-
- /* send broadcast message */
-
- else if(strnicmp(line,"broadcast",9)==NULL && msgpos>0)
- {
- if(brods==ON)
- {
- brdcst=ON;
- if( mode[ 0 ] == 'U' ){
- sprintf(idstr,idfrmt,name,un,host,jsn,broad);
- sprintf(sndbuf," %s\n%s\n$server:b:\n",idstr,msgbuf);
- } else if( mode[ 0 ] == 'S' )
- strcpy( sndbuf, msgbuf );
- msgpos=0;
- msgbuf[msgpos]=(char)NULL;
- goto sndmsg;
- }
- else
- bco=bco+transmit(out,notallow,CRLF);
- }
-
- /* check for messages */
-
- else if(( strlen(line)==0 || line[ 0 ] == '\n' ) && mode[ 0 ] == 'U' ) goto sndmsg;
-
- /* join another conference */
-
- else if(strnicmp(line,"join",4)==NULL)
- {
- if(joinc==ON)
- {
- sprintf(sndbuf," %s\n %s ( %s@%s / %s ) logged off %s.\n$server:m:%s:\n",server,name,un,host,jsn,confer,confer);
- join=ON;
- msgflg=ON;
- if(strncmp(line+4,"\0",1)==NULL)
- strcpy(newcfr,"\0");
- else
- strncpy(newcfr,line+5,CFRLEN-1);
- if(strlen(newcfr)==0) strcpy(newcfr,"Root");
-
- /* remove colons */
-
- j = strlen( newcfr );
- for( i = 0; i < j; ++i ){
- if( newcfr[ i ] == ':' )
- newcfr[ i ] = ' ';
- }
- bco=bco+transmit(out,server,CRLF);
- sprintf(line," Joining conference %s.",newcfr);
- bco=bco+transmit(out,line,CRLF);
- goto sndmsg;
- }
- else
- bco=bco+transmit(out,notallow,CRLF);
- }
-
- /* rewind command */
-
- else if(strnicmp(line,"rewind",6)==NULL)
- rewind(inp);
-
- /* exit slugnet */
-
- else if(strnicmp(line,"exit",4)==NULL
- || strnicmp(line,"bye",3)==NULL
- || strnicmp(line,"logoff",6)==NULL
- || strnicmp(line,"quit",4)==NULL
- || (strnicmp(line,"stop",4)==NULL && systm==ON))
- {
- atend=ON;
- msgflg=ON;
- sprintf(sndbuf,"$server:d:%s:%s:%s:%s:%s:%s:\n %s\n %s ( %s@%s / %s ) logged off.\n$server:m:%s:\n",name,un,host,jsn,confer,mode,server,name,un,host,jsn,confer);
- if(strncmp(line,"stop",4)==NULL) stop=ON;
- goto sndmsg;
- }
-
- /* bell + jsn: rings bell and transmits jsn */
-
- else if(strnicmp(line,"bell ",5)==NULL)
- {
- strncpy(tjsn,line+5,JSNLEN-1);
- sprintf(line," Jsn %s is ringing you.\007\n",tjsn);
- if(strlen(tjsn)>0&&ringok==ON)
- {
- bco=bco+transmit(out,server,CRLF);
- bco=bco+transmit(out,line,CRLF);
- }
- }
-
- /* bell: sends a control g. */
-
- else if(strnicmp(line,"bell" ,4)==NULL)
- {
- bco=bco+transmit(out,"\007",NOCRLF);
- }
-
- /* ring jsn: rings another jsn */
-
- else if(strnicmp(line,"ring ",5)==NULL)
- {
- bco=bco+transmit(out,server,CRLF);
- if(ringr==ON)
- {
- strncpy(tjsn,line+5,JSNLEN-1);
- if(strncmp(tjsn,jsn,4)!=NULL)
- {
- sprintf(line," Ringing jsn %s.\n",tjsn);
- if(strlen(tjsn)>0)
- {
- bco=bco+transmit(out,line,CRLF);
- sprintf(sndbuf,"$%sbell %s\n",tjsn,jsn);
- brdcst=ON;
- goto sndmsg;
- }
- else
- bco=bco+transmit(out," Missing or invalid jsn.\n",CRLF);
- }
- else
- bco=bco+transmit(out," You may not ring your own jsn.\n",CRLF);
- }
- else
- bco=bco+transmit(out,notallow,CRLF);
- }
-
- /* help command */
-
- else if(strnicmp(line,"help",4)==NULL)
- {
- bco=bco+transmit(out,server,CRLF);
- hlpon=OFF;
- hlp_found=OFF;
-
- /* find help topic requested */
-
- sndbuf[0]=(char)NULL;
- if(strncmp(line+4,BLANKS,1)==NULL)
- sprintf(sndbuf,"*%s",line+5);
- i=strlen(sndbuf);
- if(i<=1)
- {
- sprintf(sndbuf,"*EOF");
- i=4;
- }
-
- /* search help file */
-
- hlp=fopen(hlpfil,"r");
- if(hlp!=NULL)
- {
- while(feof(hlp)==NULL)
- {
- j=rdline(hlp,line,LINLEN-1);
- if(strncmp(line,"*",1)==NULL)
- {
- k=i;
- j=find(line,':',LINLEN-1);
- if(j>0&&j<i) k=j;
- if(strnicmp(line,sndbuf,k)==NULL&&strncmp(line,"*EOF",4)!=NULL)
- {
- hlpon=ON;
- hlp_found=ON;
- }
- else if(strncmp(line,"*EOF",4)==NULL&&hlp_found==OFF)
- {
- hlpon=ON;
- hlp_found=ON;
- }
- else
- {
- hlpon=OFF;
- if( hlp_found==ON) goto quithlp;
- }
- }
- else if(hlpon==ON)
- bco=bco+transmit(out,line,CRLF);
- }
- quithlp:
- i=fclose(hlp);
- }
- else
- bco=bco+transmit(out," Error: Help file not present\n",CRLF);
- }
-
- /* wait command */
-
- else if(strnicmp(line,"wait",4)==NULL)
- {
- bco=bco+transmit(out,server,CRLF);
- sprintf(line," Waiting for \"%s\".\n",waitstr);
- bco=bco+transmit(out,line,CRLF);
- wait=ON;
- #ifdef NETWORK
- on = ON;
- if( ioctl( in, FIONBIO, (char *)&on ) < NULL )
- perror( "ioctl1" );
- #endif NETWORK
- }
-
- /* scroll command */
-
- else if(strnicmp(line,"scroll",6)==NULL)
- {
- bco=bco+transmit(out,server,CRLF);
- bco=bco+transmit(out," Entering scroll mode.\n",CRLF);
- scroll=ON;
- #ifdef NETWORK
- on = ON;
- if( ioctl( in, FIONBIO, (char *)&on ) < NULL )
- perror( "ioctl1" );
- #endif NETWORK
- }
-
- /* delay command */
-
- else if(strnicmp(line,"delay",5)==NULL)
- {
- bco=bco+transmit(out,server,CRLF);
- sprintf(line," Delaying for %d seconds.\n",dtime);
- bco=bco+transmit(out,line,CRLF);
- #ifdef SYSV2
- sleep((unsigned)dtime);
- #endif SYSV2
- #ifdef SYSV3
- u=sleep((unsigned)dtime);
- #endif SYSV3
- #ifdef BSD4
- sleep((unsigned)dtime);
- #endif BSD4
- #ifdef ULTRIX
- sleep((unsigned)dtime);
- #endif ULTRIX
- }
-
- /* clear command - clears message buffer */
-
- else if(strnicmp(line,"clear",5)==NULL)
- {
- msgpos=NULL;
- msgbuf[msgpos]=(char)NULL;
- bco=bco+transmit(out,server,CRLF);
- bco=bco+transmit(out," Message buffer cleared.\n",CRLF);
- }
-
- /* write command - writes message buffer to file */
-
- else if(strnicmp(line,"write ",6)==NULL)
- {
- bco=bco+transmit(out,server,CRLF);
- if(files==OFF)
- bco=bco+transmit(out,notallow,CRLF);
- else
- {
- #ifdef SYSV2
- i=setuid(uid);
- #endif SYSV2
- #ifdef SYSV3
- i=setuid(uid);
- #endif SYSV3
- i=chdir(homedir);
- strcpy(tmpfil,line+6);
- if(strlen(tmpfil)==0)
- bco=bco+transmit(out," Error: Invalid file name.\n",CRLF);
- else if(msgpos<3)
- bco=bco+transmit(out," Error: Buffer too short.\n",CRLF);
- else
- {
-
- tmp=fopen(tmpfil,"r");
- if(tmp!=NULL)
- {
- i=fclose(tmp);
- bco=bco+transmit(out," Error: File exists.\n",CRLF);
- }
- else
- {
- tmp=fopen(tmpfil,"w");
- if(tmp==NULL)
- bco=bco+transmit(out," Error: Invalid file name.\n",CRLF);
- else
- {
- chmod(tmpfil,00600);
- i=1;
- while(i<msgpos)
- {
- #ifdef SYSV2
- fputc((int)((char)msgbuf[i]),tmp);
- #endif SYSV2
- #ifdef SYSV3
- fputc((int)((char)msgbuf[i]),tmp);
- #endif SYSV3
- #ifdef BSD4
- fputc((char)msgbuf[i],tmp);
- #endif BSD4
- #ifdef ULTRIX
- fputc((char)msgbuf[i],tmp);
- #endif ULTRIX
- if(msgbuf[i]=='\n')
- i=i+2;
- else
- ++i;
- }
- i=fclose(tmp);
- sprintf(line,"\n Buffer written to %s.\n",tmpfil);
- bco=bco+transmit(out,line,CRLF);
- }
- }
- }
- #ifdef SYSV2
- i=setuid(euid);
- #endif SYSV2
- #ifdef SYSV3
- i=setuid(euid);
- #endif SYSV3
- i=chdir(slugdir);
- }
- }
-
- /* see if command is in user's definition file */
-
- else
- {
- #ifdef SYSV2
- i=setuid(uid);
- #endif SYSV2
- #ifdef SYSV3
- i=setuid(uid);
- #endif SYSV3
- i=chdir(homedir);
- def=fopen(deffil,"r");
- if(def!=NULL)
- {
- while(feof(def)==NULL)
- {
- i=rdline(def,scratch,LINLEN);
- if(strncmp(scratch,"*",1)!=NULL)
- {
- i=find(scratch,'=',LINLEN);
- if(i>=0)
- {
- if(strnicmp(line,scratch,i)==NULL)
- {
- j=find(scratch,';',LINLEN);
- if(j>=0)
- {
- strncpy(sndbuf,scratch+i+1,j-i-1);
- strcpy(sndbuf+j-i-1,line+i);
- strncpy(line,sndbuf,LINLEN-1);
- i=fclose(def);
- #ifdef SYSV2
- i=setuid(euid);
- #endif SYSV2
- #ifdef SYSV3
- i=setuid(euid);
- #endif SYSV3
- i=chdir(slugdir);
- goto parser;
- }
- }
- }
- }
- }
- i=fclose(def);
- }
- #ifdef SYSV2
- i=setuid(euid);
- #endif SYSV2
- #ifdef SYSV3
- i=setuid(euid);
- #endif SYSV3
- i=chdir(slugdir);
-
- /* help blurb */
-
- if(novice==ON && mode[ 0 ] == 'U' ){
- bco=bco+transmit(out,server,CRLF);
- bco=bco+transmit(out," Type \"help\" for instructions.\n",CRLF);
- }
- else if( mode[ 0 ] == 'U' ){
- strcpy(sndbuf,line);
- line[0]=' ';
- strncpy(line+1,sndbuf,LINLEN-1);
- goto parser;
- }
- }
- }
-
- /* destroy receiver file, close input, output redirection files */
-
- cleanup:
- lock(rcvfil);
- i=unlink(rcvfil);
- unlock(rcvfil);
- if(inp != NULL)
- i=fclose(inp);
- #ifdef NETWORK
- if(out != socket )
- #endif NETWORK
- #ifdef LOCAL
- if(out != fileno( stdout ))
- #endif LOCAL
- i=close(out);
- inp=(FILE *)NULL;
- #ifdef NETWORK
- out=socket;
- #endif NETWORK
- #ifdef LOCAL
- out = fileno( stdout );
- #endif LOCAL
- if(stop==OFF && login==ON) goto wait_for_call;
- i=chdir(homedir);
- return(11);
- }
- \End\Of\Shar\
- else
- echo "will not over write ./slugnet.c"
- fi
- chmod 600 ./slugnet.c
- if [ `wc -c ./slugnet.c | awk '{printf $1}'` -ne 91130 ]
- then
- echo `wc -c ./slugnet.c | awk '{print "Got " $1 ", Expected " 91130}'`
- fi
- echo "Finished archive 4 of 6"
- exit
-