xref: /illumos-gate/usr/src/cmd/bnu/security.c (revision 55fea89d)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
237c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
247c478bd9Sstevel@tonic-gate 
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ident	"%Z%%M%	%I%	%E% SMI"	/* from SVR4 bnu:security.c 1.3 */
277c478bd9Sstevel@tonic-gate /*
287c478bd9Sstevel@tonic-gate  */
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #include	"uucp.h"
317c478bd9Sstevel@tonic-gate #include	"log.h"
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate extern int guinfo();
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate /*
367c478bd9Sstevel@tonic-gate  *		SYMBOL DEFINITIONS
377c478bd9Sstevel@tonic-gate  */
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #define	FS		' '	/* Field seperator for output records. */
407c478bd9Sstevel@tonic-gate #define LOGCHECK	{ if (Collecting == FALSE) return; }
417c478bd9Sstevel@tonic-gate #define LOGCHECKC	{ if (Collecting == FALSE) return(NOTAVAIL); }
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate /*
447c478bd9Sstevel@tonic-gate  *		STRUCTURE DEFINITIONS
457c478bd9Sstevel@tonic-gate  */
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate struct secXfer			/* Data for construction of security record. */
487c478bd9Sstevel@tonic-gate 		{
497c478bd9Sstevel@tonic-gate 			char	reqSystem[MODSTR]; /* requester system name */
507c478bd9Sstevel@tonic-gate 			char	reqUser[MODSTR]; /* requester login name */
517c478bd9Sstevel@tonic-gate 			char	desSystem[MODSTR]; /* destination system name */
527c478bd9Sstevel@tonic-gate 			char	desUser[MODSTR]; /* destination login name */
537c478bd9Sstevel@tonic-gate 			char	desFile[MODSTR]; /* destination file name */
547c478bd9Sstevel@tonic-gate 			char	srcSystem[MODSTR]; /* source system name */
557c478bd9Sstevel@tonic-gate 			char	srcOwner[MODSTR]; /* source file owner */
567c478bd9Sstevel@tonic-gate 			char	srcFile[MODSTR]; /* source file name */
577c478bd9Sstevel@tonic-gate 			char	srcSize[MODSTR];/* source file size in Bytes .*/
58*55fea89dSDan Cross 			char	srcMtime[MODSTR]; /* modification date and time of
597c478bd9Sstevel@tonic-gate 						source file */
607c478bd9Sstevel@tonic-gate 			char	stime[MODSTR]; /* date and time that transfer
617c478bd9Sstevel@tonic-gate  							started */
627c478bd9Sstevel@tonic-gate 			char	etime[MODSTR]; /* date and time that transfer
637c478bd9Sstevel@tonic-gate  							completed */
647c478bd9Sstevel@tonic-gate 		};
657c478bd9Sstevel@tonic-gate 
667c478bd9Sstevel@tonic-gate struct secRexe			/* Data for construction of security record. */
677c478bd9Sstevel@tonic-gate 		{
687c478bd9Sstevel@tonic-gate 			char	cliSystem[MODSTR]; /* client system name */
697c478bd9Sstevel@tonic-gate 			char	cliUser[MODSTR]; /* client login name */
707c478bd9Sstevel@tonic-gate 			char	serUser[MODSTR]; /* server login name */
717c478bd9Sstevel@tonic-gate 			char	time[MODSTR]; /* date and time that command was
727c478bd9Sstevel@tonic-gate 						 issued*/
737c478bd9Sstevel@tonic-gate 			char	command[BUFSIZ]; /* command name and options */
747c478bd9Sstevel@tonic-gate 		};
757c478bd9Sstevel@tonic-gate /*
767c478bd9Sstevel@tonic-gate  *		LOCAL DATA
777c478bd9Sstevel@tonic-gate  */
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate static int		Collecting = TRUE; /* ok to collect security inf.*/
807c478bd9Sstevel@tonic-gate static int		LogFile = CLOSED; /* Log file file destriptor. */
817c478bd9Sstevel@tonic-gate static char		LogName[] = SECURITY; /* Name of our log file. */
827c478bd9Sstevel@tonic-gate static char		Record[LOGSIZE]; /* Place to build log records. */
837c478bd9Sstevel@tonic-gate static char		Type[MODSTR]; /* record type */
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate static struct secXfer	Xfer;	/* security transfer data. */
867c478bd9Sstevel@tonic-gate static struct secRexe	Rexe;	/* security remote execution data. */
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate /*
897c478bd9Sstevel@tonic-gate  *		LOCAL FUNCTIONS
907c478bd9Sstevel@tonic-gate  */
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate /*
947c478bd9Sstevel@tonic-gate  * Local Function:	newRec - Initialize new record
957c478bd9Sstevel@tonic-gate  */
967c478bd9Sstevel@tonic-gate 
97*55fea89dSDan Cross STATIC_FUNC void
newRec(type)987c478bd9Sstevel@tonic-gate newRec(type)
997c478bd9Sstevel@tonic-gate char * type;
1007c478bd9Sstevel@tonic-gate {
1017c478bd9Sstevel@tonic-gate 	register struct secXfer *	scptr = &Xfer;
1027c478bd9Sstevel@tonic-gate 	register struct secRexe *	reptr = &Rexe;
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate 	if EQUALS(type,"xfer"){
1057c478bd9Sstevel@tonic-gate 	   copyText(scptr->reqUser, sizeof(scptr->reqUser), NOTAVAIL);
1067c478bd9Sstevel@tonic-gate 	   copyText(scptr->desSystem, sizeof(scptr->desSystem), NOTAVAIL);
1077c478bd9Sstevel@tonic-gate 	   copyText(scptr->desUser, sizeof(scptr->desUser), NOTAVAIL);
1087c478bd9Sstevel@tonic-gate 	   copyText(scptr->desFile, sizeof(scptr->desFile), NOTAVAIL);
1097c478bd9Sstevel@tonic-gate 	   copyText(scptr->srcSystem, sizeof(scptr->srcSystem), NOTAVAIL);
1107c478bd9Sstevel@tonic-gate 	   copyText(scptr->srcOwner, sizeof(scptr->srcOwner), NOTAVAIL);
1117c478bd9Sstevel@tonic-gate 	   copyText(scptr->srcFile, sizeof(scptr->srcFile), NOTAVAIL);
1127c478bd9Sstevel@tonic-gate 	   copyText(scptr->srcMtime, sizeof(scptr->srcMtime), NOTAVAIL);
1137c478bd9Sstevel@tonic-gate 	   copyText(scptr->stime, sizeof(scptr->stime), NOTAVAIL);
1147c478bd9Sstevel@tonic-gate 	   copyText(scptr->etime, sizeof(scptr->etime), NOTAVAIL);
1157c478bd9Sstevel@tonic-gate 	}
1167c478bd9Sstevel@tonic-gate 	else {
1177c478bd9Sstevel@tonic-gate 	   copyText(reptr->cliSystem, sizeof(reptr->cliSystem), NOTAVAIL);
1187c478bd9Sstevel@tonic-gate 	   copyText(reptr->cliUser, sizeof(reptr->cliUser), NOTAVAIL);
1197c478bd9Sstevel@tonic-gate 	   copyText(reptr->serUser, sizeof(reptr->serUser), NOTAVAIL);
1207c478bd9Sstevel@tonic-gate 	   copyText(reptr->time, sizeof(reptr->time), NOTAVAIL);
1217c478bd9Sstevel@tonic-gate 	   copyText(reptr->command, sizeof(reptr->command), NOTAVAIL);
1227c478bd9Sstevel@tonic-gate 	}
1237c478bd9Sstevel@tonic-gate 	return;
1247c478bd9Sstevel@tonic-gate }
1257c478bd9Sstevel@tonic-gate 
1267c478bd9Sstevel@tonic-gate /*
1277c478bd9Sstevel@tonic-gate  *		EXTERNAL FUNCTIONS
1287c478bd9Sstevel@tonic-gate  */
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate 
1317c478bd9Sstevel@tonic-gate /*
1327c478bd9Sstevel@tonic-gate  * Function:	scInit - Initialize Security Package
1337c478bd9Sstevel@tonic-gate  *
1347c478bd9Sstevel@tonic-gate  * This function allows the security package to initialize its internal
135*55fea89dSDan Cross  * data structures.  It should be called when uucico starts running on master
1367c478bd9Sstevel@tonic-gate  * or slave, or uuxqt is invoked.
1377c478bd9Sstevel@tonic-gate  *
1387c478bd9Sstevel@tonic-gate  * Parameters:
1397c478bd9Sstevel@tonic-gate  *
1407c478bd9Sstevel@tonic-gate  *	type: file transfer or remote exec.
1417c478bd9Sstevel@tonic-gate  */
1427c478bd9Sstevel@tonic-gate 
1437c478bd9Sstevel@tonic-gate void
scInit(type)1447c478bd9Sstevel@tonic-gate scInit (type)
1457c478bd9Sstevel@tonic-gate char * type;
1467c478bd9Sstevel@tonic-gate 
1477c478bd9Sstevel@tonic-gate {
1487c478bd9Sstevel@tonic-gate 
1497c478bd9Sstevel@tonic-gate 	if (LogFile == CLOSED) {
1507c478bd9Sstevel@tonic-gate 		errno = 0;
1517c478bd9Sstevel@tonic-gate 		LogFile = open(LogName, O_WRONLY | O_APPEND);
1527c478bd9Sstevel@tonic-gate 		if (errno == ENOENT) {
1537c478bd9Sstevel@tonic-gate 			LogFile = creat(LogName, LOGFILEMODE);
1547c478bd9Sstevel@tonic-gate 			(void) chmod(LogName, LOGFILEMODE);
1557c478bd9Sstevel@tonic-gate 		}
1567c478bd9Sstevel@tonic-gate 		if (LogFile < 0){
1577c478bd9Sstevel@tonic-gate 			Collecting = FALSE;
1587c478bd9Sstevel@tonic-gate 			return;
1597c478bd9Sstevel@tonic-gate 		}
1607c478bd9Sstevel@tonic-gate 	}
1617c478bd9Sstevel@tonic-gate 	copyText(Type, sizeof(Type), type);
1627c478bd9Sstevel@tonic-gate 	newRec(Type);
1637c478bd9Sstevel@tonic-gate 	return;
1647c478bd9Sstevel@tonic-gate }
1657c478bd9Sstevel@tonic-gate 
1667c478bd9Sstevel@tonic-gate /*
1677c478bd9Sstevel@tonic-gate  * Function:	scWrite - write an entry to the log
1687c478bd9Sstevel@tonic-gate  *			  initialize the next entry
1697c478bd9Sstevel@tonic-gate  */
1707c478bd9Sstevel@tonic-gate 
1717c478bd9Sstevel@tonic-gate void
scWrite()1727c478bd9Sstevel@tonic-gate scWrite()
1737c478bd9Sstevel@tonic-gate 
1747c478bd9Sstevel@tonic-gate {
1757c478bd9Sstevel@tonic-gate 	static char	format[] = "%s%c%s%c%s%c%s%c%s%c%s%c%s%c%s%c%s%c%s%c(%s)%c(%s)%c(%s)";
1767c478bd9Sstevel@tonic-gate 
1777c478bd9Sstevel@tonic-gate 	register struct secXfer *	scptr;
1787c478bd9Sstevel@tonic-gate 
1797c478bd9Sstevel@tonic-gate 	LOGCHECK;
1807c478bd9Sstevel@tonic-gate 	scptr = &Xfer;			/* Point to security transfer data. */
1817c478bd9Sstevel@tonic-gate 	sprintf(Record, format,
1827c478bd9Sstevel@tonic-gate 		Type, FS,
1837c478bd9Sstevel@tonic-gate 		scptr->reqSystem, FS,
1847c478bd9Sstevel@tonic-gate 		scptr->reqUser, FS,
1857c478bd9Sstevel@tonic-gate 		scptr->desSystem, FS,
1867c478bd9Sstevel@tonic-gate 		scptr->desUser, FS,
1877c478bd9Sstevel@tonic-gate 		scptr->desFile, FS,
1887c478bd9Sstevel@tonic-gate 		scptr->srcSystem, FS,
1897c478bd9Sstevel@tonic-gate 		scptr->srcOwner, FS,
1907c478bd9Sstevel@tonic-gate 		scptr->srcFile, FS,
1917c478bd9Sstevel@tonic-gate 		scptr->srcSize, FS,
1927c478bd9Sstevel@tonic-gate 		scptr->srcMtime, FS,
1937c478bd9Sstevel@tonic-gate 		scptr->stime, FS,
1947c478bd9Sstevel@tonic-gate 		scptr->etime
1957c478bd9Sstevel@tonic-gate 	       );
1967c478bd9Sstevel@tonic-gate 
1977c478bd9Sstevel@tonic-gate 	/* Terminate the record and write it out. */
1987c478bd9Sstevel@tonic-gate 
1997c478bd9Sstevel@tonic-gate 	(void) strcat(Record, EOR);
2007c478bd9Sstevel@tonic-gate 	writeLog(Record,&LogFile,LogName,&Collecting);
2017c478bd9Sstevel@tonic-gate 	newRec(Type);
2027c478bd9Sstevel@tonic-gate 	return;
2037c478bd9Sstevel@tonic-gate }
2047c478bd9Sstevel@tonic-gate 
2057c478bd9Sstevel@tonic-gate /*
2067c478bd9Sstevel@tonic-gate  * Function:	scReqsys - log requestor system name
2077c478bd9Sstevel@tonic-gate  *
2087c478bd9Sstevel@tonic-gate  * Parameters:
2097c478bd9Sstevel@tonic-gate  *	reqsys: master machine name
2107c478bd9Sstevel@tonic-gate  */
2117c478bd9Sstevel@tonic-gate 
2127c478bd9Sstevel@tonic-gate void
scReqsys(reqsys)2137c478bd9Sstevel@tonic-gate scReqsys(reqsys)
2147c478bd9Sstevel@tonic-gate char * reqsys;
2157c478bd9Sstevel@tonic-gate 
2167c478bd9Sstevel@tonic-gate {
2177c478bd9Sstevel@tonic-gate 	register struct secXfer *	scptr = &Xfer;
2187c478bd9Sstevel@tonic-gate 
2197c478bd9Sstevel@tonic-gate 	LOGCHECK;
2207c478bd9Sstevel@tonic-gate 	copyText(scptr->reqSystem, sizeof(scptr->reqSystem), reqsys);
2217c478bd9Sstevel@tonic-gate 	return;
2227c478bd9Sstevel@tonic-gate }
2237c478bd9Sstevel@tonic-gate 
2247c478bd9Sstevel@tonic-gate /*
2257c478bd9Sstevel@tonic-gate  * Function:	scRequser - log requestor user name
2267c478bd9Sstevel@tonic-gate  *
2277c478bd9Sstevel@tonic-gate  * Parameters:
228*55fea89dSDan Cross  *	requser: one who issued the command
2297c478bd9Sstevel@tonic-gate  */
2307c478bd9Sstevel@tonic-gate 
2317c478bd9Sstevel@tonic-gate void
scRequser(requser)2327c478bd9Sstevel@tonic-gate scRequser(requser)
2337c478bd9Sstevel@tonic-gate char * requser;
2347c478bd9Sstevel@tonic-gate 
2357c478bd9Sstevel@tonic-gate {
2367c478bd9Sstevel@tonic-gate 	register struct secXfer *	scptr = &Xfer;
2377c478bd9Sstevel@tonic-gate 
2387c478bd9Sstevel@tonic-gate 	LOGCHECK;
2397c478bd9Sstevel@tonic-gate 	copyText(scptr->reqUser, sizeof(scptr->reqUser), requser);
2407c478bd9Sstevel@tonic-gate 	return;
2417c478bd9Sstevel@tonic-gate }
2427c478bd9Sstevel@tonic-gate 
2437c478bd9Sstevel@tonic-gate /*
2447c478bd9Sstevel@tonic-gate  * Function:	scStime - log start transfer time
2457c478bd9Sstevel@tonic-gate  *
2467c478bd9Sstevel@tonic-gate  */
2477c478bd9Sstevel@tonic-gate 
2487c478bd9Sstevel@tonic-gate void
scStime()2497c478bd9Sstevel@tonic-gate scStime()
2507c478bd9Sstevel@tonic-gate 
2517c478bd9Sstevel@tonic-gate {
2527c478bd9Sstevel@tonic-gate 	register struct secXfer *	scptr = &Xfer;
2537c478bd9Sstevel@tonic-gate 
2547c478bd9Sstevel@tonic-gate 	LOGCHECK;
2557c478bd9Sstevel@tonic-gate 	copyText(scptr->stime, sizeof(scptr->stime), timeStamp());
2567c478bd9Sstevel@tonic-gate 	return;
2577c478bd9Sstevel@tonic-gate }
2587c478bd9Sstevel@tonic-gate 
2597c478bd9Sstevel@tonic-gate /*
2607c478bd9Sstevel@tonic-gate  * Function:	scEtime - log end transfer time
2617c478bd9Sstevel@tonic-gate  *
2627c478bd9Sstevel@tonic-gate  */
2637c478bd9Sstevel@tonic-gate 
2647c478bd9Sstevel@tonic-gate void
scEtime()2657c478bd9Sstevel@tonic-gate scEtime()
2667c478bd9Sstevel@tonic-gate 
2677c478bd9Sstevel@tonic-gate {
2687c478bd9Sstevel@tonic-gate 	register struct secXfer *	scptr = &Xfer;
2697c478bd9Sstevel@tonic-gate 
2707c478bd9Sstevel@tonic-gate 	LOGCHECK;
2717c478bd9Sstevel@tonic-gate 	copyText(scptr->etime, sizeof(scptr->etime), timeStamp());
2727c478bd9Sstevel@tonic-gate 	return;
2737c478bd9Sstevel@tonic-gate }
2747c478bd9Sstevel@tonic-gate 
2757c478bd9Sstevel@tonic-gate /*
2767c478bd9Sstevel@tonic-gate  * Function:	scDest - log destination node, user and file name
2777c478bd9Sstevel@tonic-gate  *
2787c478bd9Sstevel@tonic-gate  * Parameters:
2797c478bd9Sstevel@tonic-gate  *	destsys: system where the dest file is sent to
2807c478bd9Sstevel@tonic-gate  *	destuser: user where the dest file is sent to
281*55fea89dSDan Cross  *	destfile: name of the dest file
2827c478bd9Sstevel@tonic-gate  *
2837c478bd9Sstevel@tonic-gate  */
2847c478bd9Sstevel@tonic-gate 
2857c478bd9Sstevel@tonic-gate void
scDest(destsys,destuser,destfile)2867c478bd9Sstevel@tonic-gate scDest(destsys, destuser, destfile)
2877c478bd9Sstevel@tonic-gate char * destsys;
2887c478bd9Sstevel@tonic-gate char * destuser;
2897c478bd9Sstevel@tonic-gate char * destfile;
2907c478bd9Sstevel@tonic-gate 
2917c478bd9Sstevel@tonic-gate {
2927c478bd9Sstevel@tonic-gate 	register struct secXfer *	scptr = &Xfer;
2937c478bd9Sstevel@tonic-gate 
2947c478bd9Sstevel@tonic-gate 	LOGCHECK;
2957c478bd9Sstevel@tonic-gate 	copyText(scptr->desSystem, sizeof(scptr->desSystem), destsys);
2967c478bd9Sstevel@tonic-gate 	copyText(scptr->desUser, sizeof(scptr->desUser), destuser);
2977c478bd9Sstevel@tonic-gate 	copyText(scptr->desFile, sizeof(scptr->desFile), destfile);
2987c478bd9Sstevel@tonic-gate 	return;
2997c478bd9Sstevel@tonic-gate }
3007c478bd9Sstevel@tonic-gate 
3017c478bd9Sstevel@tonic-gate /*
302*55fea89dSDan Cross  * Function:	scSrc - log source node, file owner, file name
303*55fea89dSDan Cross  *			modification time and size
3047c478bd9Sstevel@tonic-gate  *
3057c478bd9Sstevel@tonic-gate  * Parameters:
3067c478bd9Sstevel@tonic-gate  *	srcsys: system where the source file is recieved from
307*55fea89dSDan Cross  *	srcowner: owner of the source file
308*55fea89dSDan Cross  *	srcfile: name of the source file
3097c478bd9Sstevel@tonic-gate  *	srcmtime: modification date and time of source file
3107c478bd9Sstevel@tonic-gate  *	srcsize: size of the source file
3117c478bd9Sstevel@tonic-gate  *
3127c478bd9Sstevel@tonic-gate  */
3137c478bd9Sstevel@tonic-gate 
3147c478bd9Sstevel@tonic-gate void
scSrc(srcsys,srcowner,srcfile,srcmtime,srcsize)3157c478bd9Sstevel@tonic-gate scSrc(srcsys, srcowner, srcfile, srcmtime, srcsize)
3167c478bd9Sstevel@tonic-gate char * srcsys;
3177c478bd9Sstevel@tonic-gate char * srcowner;
3187c478bd9Sstevel@tonic-gate char * srcfile;
3197c478bd9Sstevel@tonic-gate char * srcmtime;
3207c478bd9Sstevel@tonic-gate char * srcsize;
3217c478bd9Sstevel@tonic-gate 
3227c478bd9Sstevel@tonic-gate {
3237c478bd9Sstevel@tonic-gate 	register struct secXfer *	scptr = &Xfer;
3247c478bd9Sstevel@tonic-gate 
3257c478bd9Sstevel@tonic-gate 	LOGCHECK;
3267c478bd9Sstevel@tonic-gate 	copyText(scptr->srcSystem, sizeof(scptr->srcSystem), srcsys);
3277c478bd9Sstevel@tonic-gate 	copyText(scptr->srcOwner, sizeof(scptr->srcOwner), srcowner );
3287c478bd9Sstevel@tonic-gate 	copyText(scptr->srcFile, sizeof(scptr->srcFile), srcfile);
3297c478bd9Sstevel@tonic-gate 	copyText(scptr->srcMtime, sizeof(scptr->srcMtime), srcmtime );
3307c478bd9Sstevel@tonic-gate 	copyText(scptr->srcSize, sizeof(scptr->srcSize), srcsize);
3317c478bd9Sstevel@tonic-gate 	return;
3327c478bd9Sstevel@tonic-gate }
3337c478bd9Sstevel@tonic-gate 
3347c478bd9Sstevel@tonic-gate /*
3357c478bd9Sstevel@tonic-gate  * Function:	scSize - get size of source file
3367c478bd9Sstevel@tonic-gate  *
3377c478bd9Sstevel@tonic-gate  * parameter	srcfile: name of the source file
3387c478bd9Sstevel@tonic-gate  *
3397c478bd9Sstevel@tonic-gate  */
3407c478bd9Sstevel@tonic-gate 
341*55fea89dSDan Cross char *
scSize(srcfile)3427c478bd9Sstevel@tonic-gate scSize(srcfile)
3437c478bd9Sstevel@tonic-gate char * srcfile;
3447c478bd9Sstevel@tonic-gate 
3457c478bd9Sstevel@tonic-gate {
3467c478bd9Sstevel@tonic-gate 	struct stat stbuf;
3477c478bd9Sstevel@tonic-gate 	static char size[MODSTR];
3487c478bd9Sstevel@tonic-gate 
3497c478bd9Sstevel@tonic-gate 	LOGCHECKC;
350*55fea89dSDan Cross 	if (stat(srcfile, &stbuf))
3517c478bd9Sstevel@tonic-gate     		return(NOTAVAIL);/* fail, set it ""  */
3527c478bd9Sstevel@tonic-gate 	sprintf(size,"%ld",stbuf.st_size);
3537c478bd9Sstevel@tonic-gate 	return(size);
3547c478bd9Sstevel@tonic-gate }
3557c478bd9Sstevel@tonic-gate 
3567c478bd9Sstevel@tonic-gate /*
3577c478bd9Sstevel@tonic-gate  * Function:	scOwn - get owner of source file
3587c478bd9Sstevel@tonic-gate  *
3597c478bd9Sstevel@tonic-gate  * parameter	srcfile: name of the source file
3607c478bd9Sstevel@tonic-gate  *
3617c478bd9Sstevel@tonic-gate  */
3627c478bd9Sstevel@tonic-gate 
3637c478bd9Sstevel@tonic-gate char *
scOwn(srcfile)3647c478bd9Sstevel@tonic-gate scOwn(srcfile)
3657c478bd9Sstevel@tonic-gate char * srcfile;
3667c478bd9Sstevel@tonic-gate 
3677c478bd9Sstevel@tonic-gate {
3687c478bd9Sstevel@tonic-gate 	struct stat stbuf;
3697c478bd9Sstevel@tonic-gate 	static char user[MODSTR];
3707c478bd9Sstevel@tonic-gate 
3717c478bd9Sstevel@tonic-gate 	LOGCHECKC;
372*55fea89dSDan Cross 	if (stat(srcfile, &stbuf))
3737c478bd9Sstevel@tonic-gate 		return(NOTAVAIL);
3747c478bd9Sstevel@tonic-gate 	(void) guinfo(stbuf.st_uid,user);
3757c478bd9Sstevel@tonic-gate 	return(user);
3767c478bd9Sstevel@tonic-gate }
3777c478bd9Sstevel@tonic-gate 
3787c478bd9Sstevel@tonic-gate /*
3797c478bd9Sstevel@tonic-gate  * Function:	scMtime - get modification date and time of source file
3807c478bd9Sstevel@tonic-gate  *
3817c478bd9Sstevel@tonic-gate  * parameter	srcfile: name of the source file
3827c478bd9Sstevel@tonic-gate  *
3837c478bd9Sstevel@tonic-gate  */
3847c478bd9Sstevel@tonic-gate 
3857c478bd9Sstevel@tonic-gate char *
scMtime(srcfile)3867c478bd9Sstevel@tonic-gate scMtime(srcfile)
3877c478bd9Sstevel@tonic-gate char * srcfile;
3887c478bd9Sstevel@tonic-gate 
3897c478bd9Sstevel@tonic-gate {
3907c478bd9Sstevel@tonic-gate 	struct stat stbuf;
3917c478bd9Sstevel@tonic-gate 	static char mtime[MODSTR];
3927c478bd9Sstevel@tonic-gate 	register struct tm *tp;
3937c478bd9Sstevel@tonic-gate 
3947c478bd9Sstevel@tonic-gate 	LOGCHECKC;
395*55fea89dSDan Cross 	if (stat(srcfile, &stbuf))
3967c478bd9Sstevel@tonic-gate 		return(NOTAVAIL);
3977c478bd9Sstevel@tonic-gate 	tp = localtime(&stbuf.st_mtime);
3987c478bd9Sstevel@tonic-gate 	(void) sprintf(mtime, "%d/%d-%d:%2.2d", tp->tm_mon + 1,
3997c478bd9Sstevel@tonic-gate 	    tp->tm_mday, tp->tm_hour, tp->tm_min);
4007c478bd9Sstevel@tonic-gate 	return(mtime);
4017c478bd9Sstevel@tonic-gate }
4027c478bd9Sstevel@tonic-gate 
403*55fea89dSDan Cross /*
4047c478bd9Sstevel@tonic-gate  * Function - scRexe: It is called when uuxqt is running
4057c478bd9Sstevel@tonic-gate  *
4067c478bd9Sstevel@tonic-gate  * Parameter:
4077c478bd9Sstevel@tonic-gate  *	clientsys - Client node name.
4087c478bd9Sstevel@tonic-gate  *	clientusr - Client user ID.
4097c478bd9Sstevel@tonic-gate  *	serverusr - Server user ID.
4107c478bd9Sstevel@tonic-gate  *	cmd - command to be execed by uuxqt
4117c478bd9Sstevel@tonic-gate  */
4127c478bd9Sstevel@tonic-gate 
4137c478bd9Sstevel@tonic-gate void
scRexe(clientsys,clientusr,serverusr,cmd)4147c478bd9Sstevel@tonic-gate scRexe(clientsys,clientusr,serverusr,cmd)
4157c478bd9Sstevel@tonic-gate char * clientsys;
4167c478bd9Sstevel@tonic-gate char * clientusr;
4177c478bd9Sstevel@tonic-gate char * serverusr;
4187c478bd9Sstevel@tonic-gate char * cmd;
4197c478bd9Sstevel@tonic-gate {
4207c478bd9Sstevel@tonic-gate 	register struct secRexe *	scptr = &Rexe;
4217c478bd9Sstevel@tonic-gate 
4227c478bd9Sstevel@tonic-gate 
4237c478bd9Sstevel@tonic-gate 	LOGCHECK;
4247c478bd9Sstevel@tonic-gate 	copyText(scptr->cliSystem, sizeof(scptr->cliSystem), clientsys);
4257c478bd9Sstevel@tonic-gate 	copyText(scptr->cliUser, sizeof(scptr->cliUser), clientusr);
4267c478bd9Sstevel@tonic-gate 	copyText(scptr->serUser, sizeof(scptr->serUser), serverusr);
4277c478bd9Sstevel@tonic-gate 	copyText(scptr->time, sizeof(scptr->time), timeStamp());
4287c478bd9Sstevel@tonic-gate 	copyText(scptr->command, sizeof(scptr->command), cmd);
4297c478bd9Sstevel@tonic-gate 	return;
4307c478bd9Sstevel@tonic-gate }
4317c478bd9Sstevel@tonic-gate 
4327c478bd9Sstevel@tonic-gate /*
4337c478bd9Sstevel@tonic-gate  * Function - scWlog: It is called when the violation is occurred
4347c478bd9Sstevel@tonic-gate  *
4357c478bd9Sstevel@tonic-gate  */
4367c478bd9Sstevel@tonic-gate 
4377c478bd9Sstevel@tonic-gate void
scWlog()4387c478bd9Sstevel@tonic-gate scWlog()
4397c478bd9Sstevel@tonic-gate {
4407c478bd9Sstevel@tonic-gate 	static char	format[] = "%s%c%s%c%s%c%s%c(%s)%c%s";
4417c478bd9Sstevel@tonic-gate 
4427c478bd9Sstevel@tonic-gate 	register struct secRexe *	scptr;
4437c478bd9Sstevel@tonic-gate 
4447c478bd9Sstevel@tonic-gate 	LOGCHECK;
4457c478bd9Sstevel@tonic-gate 	scptr = &Rexe;			/* Point to security remote exec data. */
4467c478bd9Sstevel@tonic-gate 	sprintf(Record, format,
4477c478bd9Sstevel@tonic-gate 		Type, FS,
4487c478bd9Sstevel@tonic-gate 		scptr->cliSystem, FS,
4497c478bd9Sstevel@tonic-gate 		scptr->cliUser, FS,
4507c478bd9Sstevel@tonic-gate 		scptr->serUser, FS,
4517c478bd9Sstevel@tonic-gate 		scptr->time, FS,
4527c478bd9Sstevel@tonic-gate 		scptr->command
4537c478bd9Sstevel@tonic-gate 	       );
4547c478bd9Sstevel@tonic-gate 
4557c478bd9Sstevel@tonic-gate 	/* Terminate the record and write it out. */
4567c478bd9Sstevel@tonic-gate 
4577c478bd9Sstevel@tonic-gate 	(void) strcat(Record, EOR);
4587c478bd9Sstevel@tonic-gate 	writeLog(Record,&LogFile,LogName,&Collecting);
4597c478bd9Sstevel@tonic-gate 	newRec(Type);
4607c478bd9Sstevel@tonic-gate 	return;
4617c478bd9Sstevel@tonic-gate }
462