xref: /illumos-gate/usr/src/lib/krb5/ss/invocation.c (revision 19ee0c13)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * Copyright 1987, 1988 by MIT Student Information Processing Board
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * For copyright information, see copyright.h.
57c478bd9Sstevel@tonic-gate  */
6*19ee0c13S 
7*19ee0c13S /*
8*19ee0c13S  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
9*19ee0c13S  * Use is subject to license terms.
10*19ee0c13S  */
11*19ee0c13S 
12*19ee0c13S 
137c478bd9Sstevel@tonic-gate #include "ss_internal.h"
147c478bd9Sstevel@tonic-gate #include "copyright.h"
157c478bd9Sstevel@tonic-gate #define	size	sizeof(ss_data *)
167c478bd9Sstevel@tonic-gate 
177c478bd9Sstevel@tonic-gate 
ss_create_invocation(subsystem_name,version_string,info_ptr,request_table_ptr,code_ptr)187c478bd9Sstevel@tonic-gate int ss_create_invocation(subsystem_name, version_string, info_ptr,
197c478bd9Sstevel@tonic-gate 			 request_table_ptr, code_ptr)
207c478bd9Sstevel@tonic-gate 	char *subsystem_name, *version_string;
217c478bd9Sstevel@tonic-gate 	char *info_ptr;
227c478bd9Sstevel@tonic-gate 	ss_request_table *request_table_ptr;
237c478bd9Sstevel@tonic-gate 	int *code_ptr;
247c478bd9Sstevel@tonic-gate {
257c478bd9Sstevel@tonic-gate 	register int sci_idx;
267c478bd9Sstevel@tonic-gate 	register ss_data *new_table;
277c478bd9Sstevel@tonic-gate 	register ss_data **table;
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate 	*code_ptr = 0;
307c478bd9Sstevel@tonic-gate 	table = _ss_table;
317c478bd9Sstevel@tonic-gate 	new_table = (ss_data *) malloc(sizeof(ss_data));
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate 	if (table == (ss_data **) NULL) {
347c478bd9Sstevel@tonic-gate 		table = (ss_data **) malloc(2 * size);
357c478bd9Sstevel@tonic-gate 		table[0] = table[1] = (ss_data *)NULL;
367c478bd9Sstevel@tonic-gate 	}
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate 	for (sci_idx = 1; table[sci_idx] != (ss_data *)NULL; sci_idx++)
397c478bd9Sstevel@tonic-gate 		;
407c478bd9Sstevel@tonic-gate 	table = (ss_data **) realloc((char *)table,
417c478bd9Sstevel@tonic-gate 				     ((unsigned)sci_idx+2)*size);
427c478bd9Sstevel@tonic-gate 	table[sci_idx+1] = (ss_data *) NULL;
437c478bd9Sstevel@tonic-gate 	table[sci_idx] = new_table;
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate 	new_table->subsystem_name = subsystem_name;
467c478bd9Sstevel@tonic-gate 	new_table->subsystem_version = version_string;
477c478bd9Sstevel@tonic-gate 	new_table->argv = (char **)NULL;
487c478bd9Sstevel@tonic-gate 	new_table->current_request = (char *)NULL;
497c478bd9Sstevel@tonic-gate 	new_table->info_dirs = (char **)malloc(sizeof(char *));
507c478bd9Sstevel@tonic-gate 	*new_table->info_dirs = (char *)NULL;
517c478bd9Sstevel@tonic-gate 	new_table->info_ptr = info_ptr;
52*19ee0c13S 	/* Solaris Kerberos */
53*19ee0c13S 	new_table->prompt = malloc((unsigned)strlen(subsystem_name)+3);
547c478bd9Sstevel@tonic-gate 	strcpy(new_table->prompt, subsystem_name);
55*19ee0c13S 	strcat(new_table->prompt, ": ");
567c478bd9Sstevel@tonic-gate #ifdef silly
577c478bd9Sstevel@tonic-gate 	new_table->abbrev_info = ss_abbrev_initialize("/etc/passwd", code_ptr);
587c478bd9Sstevel@tonic-gate #else
597c478bd9Sstevel@tonic-gate 	new_table->abbrev_info = NULL;
607c478bd9Sstevel@tonic-gate #endif
617c478bd9Sstevel@tonic-gate 	new_table->flags.escape_disabled = 0;
627c478bd9Sstevel@tonic-gate 	new_table->flags.abbrevs_disabled = 0;
637c478bd9Sstevel@tonic-gate 	new_table->rqt_tables =
647c478bd9Sstevel@tonic-gate 		(ss_request_table **) calloc(2, sizeof(ss_request_table *));
657c478bd9Sstevel@tonic-gate 	*(new_table->rqt_tables) = request_table_ptr;
667c478bd9Sstevel@tonic-gate 	*(new_table->rqt_tables+1) = (ss_request_table *) NULL;
677c478bd9Sstevel@tonic-gate 	_ss_table = table;
687c478bd9Sstevel@tonic-gate 	return(sci_idx);
697c478bd9Sstevel@tonic-gate }
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate void
ss_delete_invocation(sci_idx)727c478bd9Sstevel@tonic-gate ss_delete_invocation(sci_idx)
737c478bd9Sstevel@tonic-gate 	int sci_idx;
747c478bd9Sstevel@tonic-gate {
757c478bd9Sstevel@tonic-gate 	register ss_data *t;
767c478bd9Sstevel@tonic-gate 	int ignored_code;
777c478bd9Sstevel@tonic-gate 
787c478bd9Sstevel@tonic-gate 	t = ss_info(sci_idx);
797c478bd9Sstevel@tonic-gate 	free(t->prompt);
8056a424ccSmp 	free(t->rqt_tables);
817c478bd9Sstevel@tonic-gate 	while(t->info_dirs[0] != (char *)NULL)
827c478bd9Sstevel@tonic-gate 		ss_delete_info_dir(sci_idx, t->info_dirs[0], &ignored_code);
837c478bd9Sstevel@tonic-gate 	free((char *)t->info_dirs);
847c478bd9Sstevel@tonic-gate 	free((char *)t);
857c478bd9Sstevel@tonic-gate }
86