/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI"
#ifndef UUCHECK
#include "uucp.h"
#endif
/* field array indexes for PERMISSIONS parameters */
#define U_LOGNAME 0
/* NUMFLDS should be one more than the highest U_ value */
struct keywords {
char* kword;
int kvalue;
};
{"LOGNAME", U_LOGNAME},
{"MACHINE", U_MACHINE},
{"CALLBACK", U_CALLBACK},
{"REQUEST", U_REQUEST},
{"SENDFILES", U_SENDFILES},
{"READ", U_READPATH},
{"WRITE", U_WRITEPATH},
{"NOREAD", U_NOREADPATH},
{"NOWRITE", U_NOWRITEPATH},
{"MYNAME", U_MYNAME},
{"COMMANDS", U_COMMANDS},
{"VALIDATE", U_VALIDATE},
{"PUBDIR", U_PUBDIR},
{"DIRECT", U_DIRECT},
{"ALIAS", U_ALIAS},
{"PATH", U_PATH},
};
/* for all options on paths - read, write, noread, nowrite */
/* NB: all pointers assumed to point to static data */
/* option variables */
/* NB: _Pubdir and _Path assumed to point to dynamic data */
struct name_value
{
char *name;
char *value;
};
/* file pointer for PERMISSIONS */
/* functions */
extern char *next_token(), *nextarg();
static void fillFlds();
static void fillList();
userFind(), validateFind();
int
noSpool()
{
return(_NoSpool);
}
/*
* fill in fields for login name
* name - the login id
* rmtname - remote system name
*
* return:
* 0 -> found login name
* FAIL -> did not find login
*/
int
{
int ret;
if (ret) {
return(FAIL);
}
}
else
return(ret);
}
/*
* fill in fields for machine name
* return:
* 0 -> found machine name
* FAIL -> did not find machine
*/
int
char *name;
{
int i, ret;
/* see if there is a default line */
/* mchFind is from MASTER mode - switch role is always ok */
return(ret);
}
/*
* this function will find a login name in the LOGNAME
* field.
* input:
* return:
* SUCCESS -> found
* FAIL -> not found
*/
static int
{
char *arg;
return(FAIL);
while (*fld) {
return(SUCCESS);
}
return (FAIL);
}
/*
* interpret the _Flds options and set the option variables
*/
static void
fillFlds()
{
else
}
else
}
else
}
else
}
}
#ifndef UUCHECK
#else /* UUCHECK */
exit(1);
}
#endif /* UUCHECK */
}
#ifndef UUCHECK
#else /* UUCHECK */
exit(1);
}
#endif /* UUCHECK */
}
return;
}
/*
* input:
* type - list type (read, write, noread, nowrite, command)
* output:
* list - filled in with items.
* return:
* number of items in list
*/
static void
int type;
char *list[];
{
char *p;
int num;
int maxlist = 0;
/* find list limit */
else if (type == U_COMMANDS)
if (p == NULL || !*p) {
/* no names specified, default already setup */
return;
}
num = 0;
if (*p == ':') { /* null path */
*p++ = NULLCHAR;
continue;
}
while (*p && *p != ':')
p++;
if (*p == ':')
*p++ = NULLCHAR;
num++;
}
return;
}
/*
* Find the line of PERMISSIONS for login.
* The search is determined by the type field
* (type=U_LOGNAME, U_MACHINE or U_VALIDATE)
* For U_LOGNAME:
* search for "name" in a LOGNAME= option
* For U_MACHINE:
* search for "name" in a MACHINE= option
* For U_VALIDATE:
* search for "rmtname" in a VALIDATE= option and
* for the same entry see if "name" is in the LOGNAME= option
* input:
* name -> search name
* logname -> for validate entry
* type -> U_MACHINE or U_LOGNAME
* output:
* The global values of all options will be set
* (e.g. _RPaths, _WPaths, _Request, ...)
* return:
* 0 -> ok
* FAIL -> no match found
*/
static int
int type;
{
/* call ourself recursively to set defaults */
} else {
/*
* Handle case where looking for DEFAULT entry.
* First initialize all defaults to their "base"
* values. Then the DEFAULT entry, if found,
* will override these settings.
*/
/* set up Commands defaults */
/*
* put defaults we read in in here so they're not overwritten
* by non-DEFAULT entries.
*/
buf = default_buf;
}
return(0); /* I don't think this will ever happen */
return(FAIL);
}
for (;;) {
return(FAIL);
}
while (p && *p) {
switch (type) {
case U_VALIDATE:
break;
continue;
case U_LOGNAME:
break;
continue;
case U_MACHINE:
break;
continue;
}
fillFlds();
/* fill in path lists */
if (!requestOK())
/* fill in command list */
return(0);
}
}
}
/*
* see if name is in a VALIDATE option
* return:
* FAIL -> not found
* SUCCESS -> found
*/
static int
char *name;
{
return(FAIL);
}
for (;;) {
return(FAIL);
}
continue;
return (SUCCESS);
}
}
}
/*
* see if name is in an ALIAS option
* return:
* NULL -> not found
* otherwise -> machine name
*/
char *
char *name;
{
return(NULL);
}
for (;;) {
return(NULL);
}
continue;
#ifndef UUCHECK
"PERMISSIONS file: ALIAS is one-to-many:",
#else /* UUCHECK */
return(NULL);
}
#endif /* UUCHECK */
}
}
}
/*
* parse a line in PERMISSIONS and return a vector
* of fields (flds)
*
* return:
* 0 - OK
* EOF - at end of file
*/
int
char *flds[];
char *buf;
{
int i;
char *p;
/* initialize defaults in case parameter is not specified */
for (i=0;i<NUMFLDS;i++)
return(EOF);
for (p=line;p && *p;) {
p = next_token (p, &pair);
for (i=0; i<NUMFLDS; i++) {
break;
}
}
#ifndef UUCHECK
#else /* UUCHECK */
if (i >= NUMFLDS) {
(void) printf("\n*****************************\n");
(void) printf("*****************************\n");
Uerrors++;
return(0);
}
#endif /* UUCHECK */
}
return(0);
}
/*
* return a name value pair
* string -> input pointer
* pair -> name value pair
* return:
* pointer to next character
*/
char *
char *string;
struct name_value *pair;
{
string++;
string++;
if (*string)
&& (*string != '\n'))
string++;
if (*string)
return (string);
}
/*
* get a line from the PERMISSIONS
* take care of comments (#) in col 1
* and continuations (\) in last col
* return:
* len of line
* 0 -> end of file
*/
int
char *line;
{
char *p, *c;
p = line;
/* remove trailing white space */
*c-- = NULLCHAR;
continue;
if ( *(p-1) == '\\')
p--;
else
break;
}
return(p-line);
}
/*
* get the next colon separated argument from the list
* return:
* p -> pointer to next arg in string
* input:
* str -> pointer to input string
* output:
* name -> pointer to arg string
*/
char *
{
char *p, *b;
*b++ = *p++;
*b++ = NULLCHAR;
if (*p == ':')
p++;
return(p);
}
/*
* check if requesting files is permitted
* return
* TRUE -> request permitted
* FALSE -> request denied
*/
int
{
return(_Request);
}
/*
* myName - return my name from PERMISSIONS file
* or if not there, from uucpname()
* return: none
*/
void
char *name;
{
if (*_MyName)
else
return;
}
/*
* check for callback required for any transaction
* return:
* TRUE -> callback required
* FALSE-> callback NOT required
*/
int
callBack()
{
return(_CallBack);
}
/*
* check for callback to send any files from here
* This means that the called (SLAVE) system will not switch roles.
* return:
* TRUE -> callback requried to send files
* FALSE-> callback NOT required to send files
*/
int
{
return(_Switch);
}
/*
* Check to see if command is valid for a specific machine.
* The PERMISSIONS file has an option COMMANDS=name1:name2:... for
* any machine that does not have the default list which is
* rmail
* Note that the PERMISSIONS file is read once for each system
* at the time the Rmtname is set in xprocess().
* Return codes:
* ok: TRUE
* fail: FALSE
*/
int
{
}
/*
* check a name against a list
* input:
* name -> name
* list -> list of names
* return:
* TRUE -> found path
* FALSE -> not found
*/
static int
{
int i;
/* ino set to 0 so stat is only done first time */
_ino[i] = 0;
/* try to match inodes */
if ( _ino[i] == 0 ) {
}
}
return(TRUE);
}
}
}
*tend = '\0';
break;
} else
}
}
return(FALSE);
}
/*
* Check "name" against a BASENAME or full name of _Commands list.
* If "name" specifies full path, check full, else check BASENAME.
* input:
* name -> name
* output:
* fullname -> copy full command name into fullname if
* a full path was specified in _Commands;
* if not, put name into fullname.
* return:
* TRUE -> found path
* FALSE -> not found
*/
static int
char *name;
char *fullname;
{
int i;
char *bname;
/* if ALL specified in the list
* set allok and continue in case
* a full path name is specified for the command
*/
continue;
}
if (name[0] != '/')
else
return(TRUE);
}
}
/* ALL was specified and the command was not found in list */
return(TRUE);
}
return(FALSE);
}
/*
* input:
* path pathname
* flag CK_READ or CK_WRITE
* output:
* path may be modified to canonical form
* (../, ./, // will be interpreted/removed)
* returns:
* 0 -> success
* FAIL -> failure - not a valid path for access
*/
int
char *path;
{
char *s;
/*
* this is probably redundant,
* because expfile did it, but that's ok
* Note - the /../ check is not required because of canPath
*/
return(FAIL);
return(0);
return(0);
/* ok if uucp generated D. or X. name for the spool directory */
if ( (*s++ == '/')
&& (*(++s) == '.')
return(0);
}
/* path name not valid */
return(FAIL);
}
/*
* check write permission of file.
* if mopt != NULL and permissions are ok,
* a side effect of this routine is to make
* directories up to the last part of the
* "to" ( if they do not exit).
* Input:
* to - a path name of the destination file or directory
* from - full path name of source file
* opt - create directory option (NULL - don't create)
* Output:
* to - will be the full path name of the destination file
* returns:
* 0 ->success
* FAIL -> failure
*/
int
{
char *lxp, *p;
struct stat s;
return(FAIL);
}
*++p = '/';
return(FAIL);
}
}
/* to is now the full path name of the destination file */
return(0);
return(FAIL); /* file exists, but not writeable */
/* file does not exist--check directory and make when necessary */
return(FAIL); /* no directory part of name */
lxp++;
/* should check WRITEANY on parent before mkdirs() */
return(FAIL); /* no directory and no opt to make them */
return(FAIL);
}
/* the directory now exists--check for writability */
return(0);
return(FAIL);
}