DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400 Tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400 Tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ T c

⟦d490b824a⟧ TextFile

    Length: 3934 (0xf5e)
    Types: TextFile
    Names: »check_id.c«

Derivation

└─⟦8ee07855d⟧ Bits:30000545 8mm tape, Rational 1000, DTIA 2_1_6
    └─ ⟦0c25cb74a⟧ »DATA« 
        └─⟦038380b96⟧ 
└─⟦d0624311f⟧ Bits:30000529 8mm tape, Rational 1000, DTIA 2_1_7
    └─ ⟦f494b5154⟧ »DATA« 
        └─⟦038380b96⟧ 
            └─ ⟦this⟧ »check_id.c« 
└─⟦8ee07855d⟧ Bits:30000545 8mm tape, Rational 1000, DTIA 2_1_6
    └─ ⟦0c25cb74a⟧ »DATA« 
        └─⟦0732ea0cf⟧ 
└─⟦d0624311f⟧ Bits:30000529 8mm tape, Rational 1000, DTIA 2_1_7
    └─ ⟦f494b5154⟧ »DATA« 
        └─⟦0732ea0cf⟧ 
            └─ ⟦this⟧ »../../dtia/release_apollo_2.1/check_id.c« 
└─⟦8ee07855d⟧ Bits:30000545 8mm tape, Rational 1000, DTIA 2_1_6
    └─ ⟦0c25cb74a⟧ »DATA« 
        └─⟦25fab149a⟧ 
└─⟦d0624311f⟧ Bits:30000529 8mm tape, Rational 1000, DTIA 2_1_7
    └─ ⟦f494b5154⟧ »DATA« 
        └─⟦25fab149a⟧ 
            └─ ⟦this⟧ »../../dtia/release_sun_2.1/check_id.c« 
└─⟦8ee07855d⟧ Bits:30000545 8mm tape, Rational 1000, DTIA 2_1_6
    └─ ⟦0c25cb74a⟧ »DATA« 
        └─⟦be254d495⟧ 
└─⟦d0624311f⟧ Bits:30000529 8mm tape, Rational 1000, DTIA 2_1_7
    └─ ⟦f494b5154⟧ »DATA« 
        └─⟦be254d495⟧ 
            └─ ⟦this⟧ »../../dtia/release_aix_2.1/check_id.c« 
└─⟦8ee07855d⟧ Bits:30000545 8mm tape, Rational 1000, DTIA 2_1_6
    └─ ⟦0c25cb74a⟧ »DATA« 
        └─⟦c67979795⟧ 
└─⟦d0624311f⟧ Bits:30000529 8mm tape, Rational 1000, DTIA 2_1_7
    └─ ⟦f494b5154⟧ »DATA« 
        └─⟦c67979795⟧ 
            └─ ⟦this⟧ »../../dtia/release_hp_2.1/check_id.c« 

TextFile


#ifndef	lint
#ifndef	DEBUG
static char SCCS_id[] = "@(#)check_id.c 2.1 90/08/02 19:03:57  Copyright(c) 1990 by Rational.";
#else
static char SCCS_id[] = "@(#)check_id.c DEBUG 2.1 90/08/02 19:03:57  Copyright(c) 1990 by Rational.";
#endif
#endif

#define	CHECK_ID
#include	"talk.h"
#undef	CHECK_ID

static	jmp_buf	env;
static	void	check(e)	int	e;	
{
	switch(e){
	case	E_OK:
		return;
	default:
		longjmp(env,e);
	}
}

typedef	struct	passwd	*ptr_pwd;

static	char	default_shell[]="/bin/sh";
#define	NIL_SHELL	0
#define	BOURNE_SHELL	1
#define	C_SHELL		2
#define	K_SHELL		3
static	char	*user_shell = NULL;
static	short	shell_kind = NIL_SHELL;
static	char	*user_home = NULL;
static	int	user_gid = -1;
static	int	user_uid = -1;

static	int	fill_user_infos(p)	ptr_pwd	p; 
{
#define	TAIL(p)	(rindex(p,'/')==NULL?NULL:rindex(p,'/')+1)
	char	*tail;
	if (p == NULL)	return	E_BAD_USER;
	user_shell = malloc (strlen(p->pw_shell)+1);
	if (user_shell == NULL)	return	E_RESOURCE_LIMIT;
	strcpy(user_shell,p->pw_shell);
	user_home = malloc (strlen(p->pw_dir)+1);
	if (user_home == NULL)	return	E_RESOURCE_LIMIT;
	strcpy(user_home,p->pw_dir);
	user_uid = p->pw_uid;
	user_gid = p->pw_gid;
	tail = TAIL(user_shell);
	if (tail == NULL) {
		user_shell = default_shell;
		tail = TAIL(user_shell);
	}
	if (tail && access(user_shell,X_OK))	return	E_BAD_USER;
	if (access(user_home,F_OK))		return	E_BAD_USER;
	if (tail == NULL)		shell_kind = BOURNE_SHELL;
	else if (strcmp(tail,"sh")==0)	shell_kind = BOURNE_SHELL;
	else if (strcmp(tail,"csh")==0)	shell_kind = C_SHELL;
	else if (strcmp(tail,"ksh")==0)	shell_kind = K_SHELL;
	else	shell_kind = NIL_SHELL;
	return	E_OK;
}
char	*get_user_shell() { 
	return	user_shell; 
}
char	*get_user_home() { 
	return	user_home; 
}
int	get_user_uid() { 
	return	user_uid; 
}
int	get_user_gid() { 
	return	user_gid; 
}
int	is_nilshell() { 
	return	shell_kind == NIL_SHELL; 
}
int	is_cshell() { 
	return	shell_kind == C_SHELL; 
}
int	is_kshell() { 
	return	shell_kind == K_SHELL; 
}
int	is_bourneshell() { 
	return	shell_kind == BOURNE_SHELL; 
}

static	check_user_identity(user_name,password)
char	*user_name;
char	*password; 
{
	ptr_pwd	password_entry=(ptr_pwd)NULL;
	short	error;
	char	*s,c;
	for (s=user_name;*s;s++) {
		c= *s;
		if (isupper(c))	*s=tolower(c);
	}
	password_entry=getpwnam(user_name);
	error = fill_user_infos(password_entry);
	if (error)	return	error;
	else {
		char	*c,salt[3],*crypt();
		if (strcmp(password_entry->pw_passwd,"")==0) {
			error=(strcmp(password,"")==0)?E_OK:E_BAD_USER;
		} else {
			strncpy(salt,password_entry->pw_passwd,2);
			salt[2]='\0';
			c=crypt(password,salt);
			error=(c==NULL)?E_BAD_USER:
			    (strcmp(c,password_entry->pw_passwd)?E_BAD_USER:E_OK);
		}
	}
	return	error?error:(too_many_sons()?E_RESOURCE_LIMIT:E_OK);
}

static	int	version() {
	static	char	v[]="2.1";
	char	*p=v;
	int	i,j;
	i = j = 0;
	while ( (*p!='\0') && (*p!='.') ) {
		if ( (*p<'0') || (*p>'9') )	return	0;
		i *= 10;
		i += (*p - '0');
		p++;
	}
	if (*p != '.')	return	0;
	p++;
	while (*p!='\0') {
		if ( (*p<'0') || (*p>'9') )	return	0;
		j *= 10;
		j += (*p - '0');
		p++;
	}
	return	(i<<8) | (j);
}

int	check_identity(in,out,host_name_out,user_name_out)
int	in,out;
char	**user_name_out,**host_name_out; 
{
	char	*host_name,*user_name,*password,*trace_file;
	int	identity,error;
	switch(error=setjmp(env)){
	case	0:
		break;
	default:
		return error;
	}
	check(rw_read_str(in,&host_name));
	put_unix_host(host_name);
	check(rw_read_str(in,&user_name));
	put_unix_name(user_name);
	check(rw_read_str(in,&password));
	get_unix_name(&user_name);
	get_unix_host(&host_name);
	identity = check_user_identity(user_name,password);
	check(rw_read_str(in,&trace_file));
#ifdef	DEBUG
	trace_file_name(trace_file);
#endif
	check(rw_write_int(out,PLATFORM));
	check(rw_write_int(out,version()));
	check(rw_write_int(out,identity));
	*user_name_out=user_name;
	*host_name_out=host_name;
	return	identity;
}