⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 quipurc.c

📁 ftam等标准协议服务器和客户端的源代码。
💻 C
📖 第 1 页 / 共 2 页
字号:
/* A 'C' version of the shellscript dishinit  * By Steve Titcombe * * Most of this has fixed calls to other functions, and will require going  * through again to strip out all unnecessary error trapping, etc. * (Utterly Horrible Hack.) */#ifndef	lintstatic char *rcsid = "$Header: /xtel/isode/isode/others/quipu/uips/dish/RCS/quipurc.c,v 9.0 1992/06/16 12:44:21 isode Rel $";#endif/* *				  NOTICE * *    Acquisition, use, and distribution of this module and related *    materials are subject to the restrictions of a license agreement. *    Consult the Preface in the User's Manual for the full terms of *    this agreement. * */#include <fcntl.h>#include <signal.h>#include <pwd.h>#include "quipu/util.h"#include "quipu/bind.h"#include "quipu/read.h"#include "quipu/sequence.h"#include "quipu/ds_error.h"#include "tailor.h"#include "quipu/dua.h"#include "quipu/ds_search.h"#include "quipu/list.h"#include "quipu/entry.h"#include "quipu/modify.h"#include <sys/stat.h>#define ORG_PERSON "thornPerson & quipuObject"	/* this should probably go elsewhere !!! */	LLog    *log_dua;	DN	sequence_dn() ;	DN      dn, moddn ;	DN	fixed_pos = NULLDN ;	PS      opt;	PS      rps;	PS	fileps ;	FILE	*fp_quipurc ;	FILE	*fp_draft ;	FILE	*fp_tailor ;	Filter	get_filter ();struct	entrymod	*ems_append() ;struct	entrymod	*modify_avs() ;static	struct	ds_bind_arg	bindarg ;static	struct	ds_bind_arg	bindresult ;static	struct	ds_bind_error	binderr ;	struct	ds_read_arg	read_arg;	struct	DSError		read_error;	struct	ds_read_result	read_result;	struct	ds_modifyentry_arg	mod_arg ;	struct	DSError			mod_error ;	struct	DSError			search_error;	struct	ds_search_result	search_result;static	struct	ds_search_arg search_arg =	{		default_common_args,		NULLDN,		SRA_ONELEVEL,		NULLFILTER, /* filter */		FALSE,		FALSE,		{       /* eis */			FALSE,			NULLATTR,			EIS_ATTRIBUTESANDVALUES		}	};static	struct	dua_sequence	*current_sequence = NULL_DS;	struct	entrymod	*emnew ;AV_Sequence	avst = NULLAV ;Attr_Sequence	as_flag = NULLATTR ;Attr_Sequence	trail = NULLATTR ;Attr_Sequence	eptr ;Attr_Sequence	temp ;Attr_Sequence	as ;AttributeType	at;#ifdef TURBO_DISKextern	Attr_Sequence	fget_attributes() ;#elseextern	Attr_Sequence	get_attributes() ;#endifextern	char		*TidyString() ;	Entry	current_entry ;	Entry	entry_ptr ;	char	Manager[LINESIZE] ;	char	Password[LINESIZE] ;	char	Local[LINESIZE] ;	char	filterstring[LINESIZE] ;	main(){	struct  passwd  *pw_entry ;	struct  passwd  *getpwuid() ;	struct	stat	buf ;	int	i = 1 ;	int     uid ;	int	um ;	char	pass1[LINESIZE] ;	char	pass2[LINESIZE] ;	char	Read_in_Stuff[LINESIZE] ;	char	**vecptr ;	char 	*tmpdraft ;	char	home_dir[LINESIZE] ;	char	*p, *part1, *part2 ;	char	quipurc_file[100] ;	char	tailor_file[100] ;	char	user_name[9] ;	char	*localptr = Local ;	EntryInfo	*ptr ;	static  CommonArgs ca = default_common_args;		vecptr = (char **) malloc(100) ;	vecptr[0] = malloc (LINESIZE) ;	(void) strcpy(vecptr[0], "showentry") ;	(void) strcpy(pass1, "x") ;	(void) strcpy(pass2, "y") ;	tmpdraft = malloc (LINESIZE) ;	(void) strcpy(tmpdraft, "/tmp/dish-") ;	if ((opt = ps_alloc (std_open)) == NULLPS)		fatal (-62, "ps_alloc failed");	if (std_setup (opt, stderr) == NOTOK)		fatal (-63, "std_setup failed");	if ((rps = ps_alloc (std_open)) == NULLPS)		fatal (-64, "ps_alloc 2 failed");	if (std_setup (rps, stdout) == NOTOK)		fatal (-65, "std_setup 2 failed");	(void) strcpy(filterstring, "userid=") ;	/* Sort out files, userids etc. */	uid=getuid() ;	if ((pw_entry=getpwuid(uid)) == 0)	{		ps_printf(rps, "Who are you? (no name for your uid number)\n") ;		exit(1) ;	}	(void) strcpy(user_name, pw_entry->pw_name) ;	(void) strcat(tmpdraft, user_name) ;	if (getenv("HOME") == 0) 	{		ps_printf(rps, "No home directory?!!") ;		(void) strcpy(home_dir, pw_entry->pw_dir) ;	}	else	{		(void) strcpy(home_dir, getenv("HOME")) ;	}	(void) strcpy(quipurc_file, home_dir) ;	(void) strcat(quipurc_file, "/.quipurc") ;	(void) strcpy(tailor_file, isodefile ("dishinit", 1));	Manager[0] = 0;	Password[0] = 0;	Local[0] = 0;	(void) stat(tailor_file, &buf) ;#ifndef HPUX	(void) seteuid(buf.st_uid) ;	/* set effective to enable */					/* us to read protected file */#else	(void) setresuid(-1, buf.st_uid, -1) ; /* set effective to enable */				/* us to read protected file */#endif	if ((fp_tailor = fopen(tailor_file, "r")) == 0)	{		ps_print(rps, "Can't open Tailor File. Abort.\n") ;		exit(1) ;	}	while (fgets (Read_in_Stuff, LINESIZE, fp_tailor) != 0)	{		if (!strcmp(Read_in_Stuff, "##Anything after this line is copied into the users ~/.quipurc file\n"))		{			break ;		}		p = SkipSpace (Read_in_Stuff);		if (( *p == '#') || (*p == '\0'))			continue;  		/* ignore comments and blanks */		part1 = p;		if ((part2 = index (p,':')) == NULLCP) {			ps_printf (opt,"Seperator missing '%s'. Ignoring..\n",p);		}		*part2++ = '\0';		part2 = TidyString (part2);		if (lexequ(part1, "manager") == 0)		{			(void) strcpy(Manager, part2) ;		}		else		if (lexequ(part1, "password") == 0)		{			(void) strcpy(Password, part2) ;		}		else		if (lexequ(part1, "local") == 0)		{			(void) strcpy(Local, part2) ;		}		else		{			ps_printf(rps, "Error in tailor. What's a %s?\n", part1) ;		}	}	(void) setuid(uid) ;			/* Restore Userid to original user. *//* create ~/.quipurc file. NB this does eradicate anything in there. * 			   (Theoretically nothing.)  */	if (Manager[0] == 0) {		ps_print(rps, "Can't find out the managers name\n") ;		exit(1) ;	}	if (Password[0] == 0) {		ps_print(rps, "Can't find out the managers password\n") ;		exit(1) ;	}	if (Local[0] == 0) {		ps_print(rps, "Can't find out where to search\n") ;		exit(1) ;	}	um = umask(0177) ;	if ((fp_quipurc = fopen(quipurc_file, "w")) == 0)	{		ps_printf(rps, "Can't open ~/.quipurc. Aborting..\n") ;		exit(1) ;	}	(void) umask(um) ;		if ((fileps = ps_alloc(std_open)) == NULLPS)	{		fatal (-66, "ps_alloc 2 failed");	}	if (std_setup (fileps, fp_quipurc) == NOTOK)	{		fatal (-67, "std_setup 2 failed");	}	/* Sorting out the bind section */	quipu_syntaxes() ;		/* set up the needed function pointers */	dsap_init(&i, &vecptr) ;	(void) strcpy(bindarg.dba_passwd, Password) ;	bindarg.dba_version = DBA_VERSION_V1988;	bindarg.dba_passwd_len = strlen(bindarg.dba_passwd) ;	if ((bindarg.dba_dn = str2dn (Manager)) == NULLDN) 	{		ps_printf (opt,"Invalid Manager name %s !?!\n",Manager) ;		exit(1) ;	}	if (ds_bind (&bindarg, &binderr, &bindresult) != OK)	{		ps_printf(rps, "Can't bind as the manager.\n") ;		exit(1);	}	/* Hopefully, should be successfully bound *//* * We now call the search stuff with the right bits, to see if we can get a * match of uid='user_name'. Once there, we echo lots of information from * their entry out to the .quipurc file. * Hopefully there should only be one match. This assumes that ALL dir info * up to date, and that SG do not allow multiple users with the same login. *//* set up the appropriate structures and defaults. */	search_arg.sra_common = ca; /* struct copy */	search_arg.sra_common.ca_servicecontrol.svc_sizelimit = 2 ;	search_arg.sra_eis.eis_allattributes = FALSE ;	search_arg.sra_searchaliases = FALSE;	search_arg.sra_subset = SRA_ONELEVEL;	search_arg.sra_eis.eis_infotypes = EIS_ATTRIBUTESANDVALUES ;	search_arg.sra_eis.eis_select = NULLATTR ;	search_arg.sra_eis.eis_allattributes = TRUE ;	search_arg.sra_filter = filter_alloc() ;		/* Default filter. */		search_arg.sra_filter->flt_next = NULLFILTER;		search_arg.sra_filter->flt_type = FILTER_ITEM;		search_arg.sra_filter->FUFILT = NULLFILTER;			if (*localptr == '@')	{		localptr++;	}	if ((search_arg.sra_baseobject = str2dn(localptr)) == NULLDN)	{		ps_printf (opt,"Invalid sequence in username %s.\n", localptr);		exit(1) ;	}	(void) strcat(filterstring, user_name) ;	search_arg.sra_filter->flt_un.flt_un_item.fi_type = FILTERITEM_EQUALITY ;	if ((search_arg.sra_filter->flt_un.flt_un_item.fi_un.fi_un_ava.ava_type = AttrT_new ("userid")) == NULLAttrT)	{		ps_printf(rps, "Oops, userid is not a valid attr type. ABORT!!\n") ;		exit(1) ;	}	if ((search_arg.sra_filter->flt_un.flt_un_item.fi_un.fi_un_ava.ava_value = str2AttrV (user_name, search_arg.sra_filter->flt_un.flt_un_item.fi_un.fi_un_ava.ava_type->oa_syntax)) == NULLAttrV)	{		ps_printf(rps, "%s is not a valid attribute value.\n", user_name) ;	}/* call search *//* We now ought to be in the right place, and with the search stuff set, * ready to call search, and receive one (or no) entry back, which then  * gets processed accordingly. */	if (ds_search (&search_arg, &search_error, &search_result) != DS_OK)	{		ps_printf(rps, "Search failed...\n") ;		exit (1) ;		/* This is not the same as coming back with */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -