4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
22 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
23 /* All Rights Reserved */
26 #ident "%Z%%M% %I% %E% SMI" /* from SVR4 bnu:security.c 1.3 */
39 #define FS ' ' /* Field seperator for output records. */
40 #define LOGCHECK { if (Collecting == FALSE) return; }
41 #define LOGCHECKC { if (Collecting == FALSE) return(NOTAVAIL); }
44 * STRUCTURE DEFINITIONS
47 struct secXfer
/* Data for construction of security record. */
49 char reqSystem
[MODSTR
]; /* requester system name */
50 char reqUser
[MODSTR
]; /* requester login name */
51 char desSystem
[MODSTR
]; /* destination system name */
52 char desUser
[MODSTR
]; /* destination login name */
53 char desFile
[MODSTR
]; /* destination file name */
54 char srcSystem
[MODSTR
]; /* source system name */
55 char srcOwner
[MODSTR
]; /* source file owner */
56 char srcFile
[MODSTR
]; /* source file name */
57 char srcSize
[MODSTR
];/* source file size in Bytes .*/
58 char srcMtime
[MODSTR
]; /* modification date and time of
60 char stime
[MODSTR
]; /* date and time that transfer
62 char etime
[MODSTR
]; /* date and time that transfer
66 struct secRexe
/* Data for construction of security record. */
68 char cliSystem
[MODSTR
]; /* client system name */
69 char cliUser
[MODSTR
]; /* client login name */
70 char serUser
[MODSTR
]; /* server login name */
71 char time
[MODSTR
]; /* date and time that command was
73 char command
[BUFSIZ
]; /* command name and options */
79 static int Collecting
= TRUE
; /* ok to collect security inf.*/
80 static int LogFile
= CLOSED
; /* Log file file destriptor. */
81 static char LogName
[] = SECURITY
; /* Name of our log file. */
82 static char Record
[LOGSIZE
]; /* Place to build log records. */
83 static char Type
[MODSTR
]; /* record type */
85 static struct secXfer Xfer
; /* security transfer data. */
86 static struct secRexe Rexe
; /* security remote execution data. */
94 * Local Function: newRec - Initialize new record
101 register struct secXfer
* scptr
= &Xfer
;
102 register struct secRexe
* reptr
= &Rexe
;
104 if EQUALS(type
,"xfer"){
105 copyText(scptr
->reqUser
, sizeof(scptr
->reqUser
), NOTAVAIL
);
106 copyText(scptr
->desSystem
, sizeof(scptr
->desSystem
), NOTAVAIL
);
107 copyText(scptr
->desUser
, sizeof(scptr
->desUser
), NOTAVAIL
);
108 copyText(scptr
->desFile
, sizeof(scptr
->desFile
), NOTAVAIL
);
109 copyText(scptr
->srcSystem
, sizeof(scptr
->srcSystem
), NOTAVAIL
);
110 copyText(scptr
->srcOwner
, sizeof(scptr
->srcOwner
), NOTAVAIL
);
111 copyText(scptr
->srcFile
, sizeof(scptr
->srcFile
), NOTAVAIL
);
112 copyText(scptr
->srcMtime
, sizeof(scptr
->srcMtime
), NOTAVAIL
);
113 copyText(scptr
->stime
, sizeof(scptr
->stime
), NOTAVAIL
);
114 copyText(scptr
->etime
, sizeof(scptr
->etime
), NOTAVAIL
);
117 copyText(reptr
->cliSystem
, sizeof(reptr
->cliSystem
), NOTAVAIL
);
118 copyText(reptr
->cliUser
, sizeof(reptr
->cliUser
), NOTAVAIL
);
119 copyText(reptr
->serUser
, sizeof(reptr
->serUser
), NOTAVAIL
);
120 copyText(reptr
->time
, sizeof(reptr
->time
), NOTAVAIL
);
121 copyText(reptr
->command
, sizeof(reptr
->command
), NOTAVAIL
);
132 * Function: scInit - Initialize Security Package
134 * This function allows the security package to initialize its internal
135 * data structures. It should be called when uucico starts running on master
136 * or slave, or uuxqt is invoked.
140 * type: file transfer or remote exec.
149 if (LogFile
== CLOSED
) {
151 LogFile
= open(LogName
, O_WRONLY
| O_APPEND
);
152 if (errno
== ENOENT
) {
153 LogFile
= creat(LogName
, LOGFILEMODE
);
154 (void) chmod(LogName
, LOGFILEMODE
);
161 copyText(Type
, sizeof(Type
), type
);
167 * Function: scWrite - write an entry to the log
168 * initialize the next entry
175 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)";
177 register struct secXfer
* scptr
;
180 scptr
= &Xfer
; /* Point to security transfer data. */
181 sprintf(Record
, format
,
183 scptr
->reqSystem
, FS
,
185 scptr
->desSystem
, FS
,
188 scptr
->srcSystem
, FS
,
197 /* Terminate the record and write it out. */
199 (void) strcat(Record
, EOR
);
200 writeLog(Record
,&LogFile
,LogName
,&Collecting
);
206 * Function: scReqsys - log requestor system name
209 * reqsys: master machine name
217 register struct secXfer
* scptr
= &Xfer
;
220 copyText(scptr
->reqSystem
, sizeof(scptr
->reqSystem
), reqsys
);
225 * Function: scRequser - log requestor user name
228 * requser: one who issued the command
236 register struct secXfer
* scptr
= &Xfer
;
239 copyText(scptr
->reqUser
, sizeof(scptr
->reqUser
), requser
);
244 * Function: scStime - log start transfer time
252 register struct secXfer
* scptr
= &Xfer
;
255 copyText(scptr
->stime
, sizeof(scptr
->stime
), timeStamp());
260 * Function: scEtime - log end transfer time
268 register struct secXfer
* scptr
= &Xfer
;
271 copyText(scptr
->etime
, sizeof(scptr
->etime
), timeStamp());
276 * Function: scDest - log destination node, user and file name
279 * destsys: system where the dest file is sent to
280 * destuser: user where the dest file is sent to
281 * destfile: name of the dest file
286 scDest(destsys
, destuser
, destfile
)
292 register struct secXfer
* scptr
= &Xfer
;
295 copyText(scptr
->desSystem
, sizeof(scptr
->desSystem
), destsys
);
296 copyText(scptr
->desUser
, sizeof(scptr
->desUser
), destuser
);
297 copyText(scptr
->desFile
, sizeof(scptr
->desFile
), destfile
);
302 * Function: scSrc - log source node, file owner, file name
303 * modification time and size
306 * srcsys: system where the source file is recieved from
307 * srcowner: owner of the source file
308 * srcfile: name of the source file
309 * srcmtime: modification date and time of source file
310 * srcsize: size of the source file
315 scSrc(srcsys
, srcowner
, srcfile
, srcmtime
, srcsize
)
323 register struct secXfer
* scptr
= &Xfer
;
326 copyText(scptr
->srcSystem
, sizeof(scptr
->srcSystem
), srcsys
);
327 copyText(scptr
->srcOwner
, sizeof(scptr
->srcOwner
), srcowner
);
328 copyText(scptr
->srcFile
, sizeof(scptr
->srcFile
), srcfile
);
329 copyText(scptr
->srcMtime
, sizeof(scptr
->srcMtime
), srcmtime
);
330 copyText(scptr
->srcSize
, sizeof(scptr
->srcSize
), srcsize
);
335 * Function: scSize - get size of source file
337 * parameter srcfile: name of the source file
347 static char size
[MODSTR
];
350 if (stat(srcfile
, &stbuf
))
351 return(NOTAVAIL
);/* fail, set it "" */
352 sprintf(size
,"%ld",stbuf
.st_size
);
357 * Function: scOwn - get owner of source file
359 * parameter srcfile: name of the source file
369 static char user
[MODSTR
];
372 if (stat(srcfile
, &stbuf
))
374 (void) guinfo(stbuf
.st_uid
,user
);
379 * Function: scMtime - get modification date and time of source file
381 * parameter srcfile: name of the source file
391 static char mtime
[MODSTR
];
392 register struct tm
*tp
;
395 if (stat(srcfile
, &stbuf
))
397 tp
= localtime(&stbuf
.st_mtime
);
398 (void) sprintf(mtime
, "%d/%d-%d:%2.2d", tp
->tm_mon
+ 1,
399 tp
->tm_mday
, tp
->tm_hour
, tp
->tm_min
);
404 * Function - scRexe: It is called when uuxqt is running
407 * clientsys - Client node name.
408 * clientusr - Client user ID.
409 * serverusr - Server user ID.
410 * cmd - command to be execed by uuxqt
414 scRexe(clientsys
,clientusr
,serverusr
,cmd
)
420 register struct secRexe
* scptr
= &Rexe
;
424 copyText(scptr
->cliSystem
, sizeof(scptr
->cliSystem
), clientsys
);
425 copyText(scptr
->cliUser
, sizeof(scptr
->cliUser
), clientusr
);
426 copyText(scptr
->serUser
, sizeof(scptr
->serUser
), serverusr
);
427 copyText(scptr
->time
, sizeof(scptr
->time
), timeStamp());
428 copyText(scptr
->command
, sizeof(scptr
->command
), cmd
);
433 * Function - scWlog: It is called when the violation is occurred
440 static char format
[] = "%s%c%s%c%s%c%s%c(%s)%c%s";
442 register struct secRexe
* scptr
;
445 scptr
= &Rexe
; /* Point to security remote exec data. */
446 sprintf(Record
, format
,
448 scptr
->cliSystem
, FS
,
455 /* Terminate the record and write it out. */
457 (void) strcat(Record
, EOR
);
458 writeLog(Record
,&LogFile
,LogName
,&Collecting
);