Exemple #1
0
OM_uint32 GSSAPI_CALLCONV _gsskrb5_display_status
(OM_uint32		*minor_status,
 OM_uint32		 status_value,
 int			 status_type,
 const gss_OID	 mech_type,
 OM_uint32		*message_context,
 gss_buffer_t	 status_string)
{
    krb5_context context;
    char *buf = NULL;
    int e = 0;

    GSSAPI_KRB5_INIT (&context);

    status_string->length = 0;
    status_string->value = NULL;

    if (gss_oid_equal(mech_type, GSS_C_NO_OID) == 0 &&
	gss_oid_equal(mech_type, GSS_KRB5_MECHANISM) == 0) {
	*minor_status = 0;
	return GSS_C_GSS_CODE;
    }

    if (status_type == GSS_C_GSS_CODE) {
	if (GSS_SUPPLEMENTARY_INFO(status_value))
	    e = asprintf(&buf, "%s",
			 supplementary_error(GSS_SUPPLEMENTARY_INFO(status_value)));
	else
	    e = asprintf (&buf, "%s %s",
			  calling_error(GSS_CALLING_ERROR(status_value)),
			  routine_error(GSS_ROUTINE_ERROR(status_value)));
    } else if (status_type == GSS_C_MECH_CODE) {
	const char *buf2 = krb5_get_error_message(context, status_value);
	if (buf2) {
	    buf = strdup(buf2);
	    krb5_free_error_message(context, buf2);
	} else {
	    e = asprintf(&buf, "unknown mech error-code %u",
			 (unsigned)status_value);
	}
    } else {
	*minor_status = EINVAL;
	return GSS_S_BAD_STATUS;
    }

    if (e < 0 || buf == NULL) {
	*minor_status = ENOMEM;
	return GSS_S_FAILURE;
    }

    *message_context = 0;
    *minor_status = 0;

    status_string->length = strlen(buf);
    status_string->value  = buf;

    return GSS_S_COMPLETE;
}
Exemple #2
0
GSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
gss_display_status(OM_uint32 *minor_status,
    OM_uint32 status_value,
    int status_type,
    const gss_OID mech_type,
    OM_uint32 *message_content,
    gss_buffer_t status_string)
{
	OM_uint32 major_status;

	_mg_buffer_zero(status_string);
	*message_content = 0;

	major_status = _gss_mg_get_error(mech_type, status_type,
					 status_value, status_string);
	if (major_status == GSS_S_COMPLETE) {

	    *message_content = 0;
	    *minor_status = 0;
	    return GSS_S_COMPLETE;
	}

	*minor_status = 0;
	switch (status_type) {
	case GSS_C_GSS_CODE: {
	    	char *buf = NULL;
		int e;

		if (GSS_SUPPLEMENTARY_INFO(status_value))
		    e = asprintf(&buf, "%s", supplementary_error(
		        GSS_SUPPLEMENTARY_INFO(status_value)));
		else
		    e = asprintf (&buf, "%s %s",
		        calling_error(GSS_CALLING_ERROR(status_value)),
			routine_error(GSS_ROUTINE_ERROR(status_value)));

		if (e < 0 || buf == NULL)
		    break;

		status_string->length = strlen(buf);
		status_string->value  = buf;

		return GSS_S_COMPLETE;
	}
	case GSS_C_MECH_CODE: {
		OM_uint32 maj_junk, min_junk;
		gss_buffer_desc oid;
		char *buf = NULL;
		int e;

		maj_junk = gss_oid_to_str(&min_junk, mech_type, &oid);
		if (maj_junk != GSS_S_COMPLETE) {
		    oid.value = rk_UNCONST("unknown");
		    oid.length = 7;
		}
		
		e = asprintf (&buf, "unknown mech-code %lu for mech %.*s",
			  (unsigned long)status_value,
			  (int)oid.length, (char *)oid.value);
		if (maj_junk == GSS_S_COMPLETE)
		    gss_release_buffer(&min_junk, &oid);

		if (e < 0 || buf == NULL)
		    break;

		status_string->length = strlen(buf);
		status_string->value  = buf;

		return GSS_S_COMPLETE;
	}
	}
	_mg_buffer_zero(status_string);
	return (GSS_S_BAD_STATUS);
}
Exemple #3
0
void
main (int argc, char *argv[])
{
  int command_line_arg;
  int unused;

  /* Machine specific initialization. (JAT) */

  machine_setup();

  /* Error initialization. */

  program_name = "ddl";

  /* Set defaults */

  yydebug = 0;
  min_warning_priority = DRC_MIN_WARNING_PRIORITY + 2;

  /* Parse command line arguments. */

  while ((command_line_arg
          = getopt_long(argc, argv, "dhvw", long_options, &unused)) != -1) {
    switch (command_line_arg) {
    case 'd':
      yydebug = 1;
      break;
    case 'h':
      print_help_information(long_options, options_help);
      exit(EXIT_SUCCESS);
      break;
    case 'v':
      printf("p2 version %s\n", version_string);
      exit(EXIT_SUCCESS);
      break;
    case 'w':
      min_warning_priority = 1; /* Enable all warnings. */
      break;
    case '?':
      calling_error("illegal or unrecognized option");
      break;
    }
  }

  if (optind == argc) 
    calling_error("ddl takes exactly one argument");
  
  /* Parse input file name and open input file. */

  parse_input_file_name(argv[optind], file_name);

  yyin = fopen(file_name, "r");
  if (yyin == NULL)
    error("Can't open file %s\n", file_name);

  /* Parse. */

  if (yyparse() != 0)
    error("parsing failed");

  /* Exit. */

  exit(EXIT_SUCCESS);
}
Exemple #4
0
Fichier : xp-main.c Projet : mpw/p2
int
main (int argc, char *argv[])
{
  int command_line_arg;
  int unused;

  /* Machine specific initialization. (JAT) */

  machine_setup();

  /* Error initialization. */

  program_name = "xp";

  /* Set defaults. */

  yydebug = 0;
  enable_hierarchy_comments = 0;
  min_warning_priority = DRC_MIN_WARNING_PRIORITY + 2;

  while ((command_line_arg
          = getopt_long(argc, argv, "cdhvw", long_options, &unused)) != -1) {
    switch (command_line_arg) {
    case 'c':
      enable_hierarchy_comments = 1;
      break;
    case 'd':
      yydebug = 1;
      break;
    case 'h':
      print_help_information(long_options, options_help);
      exit(EXIT_SUCCESS);
      break;
    case 'v':
      printf("xp version %s\n", version_string);
      exit(EXIT_SUCCESS);
      break;
    case 'w':
      min_warning_priority = 1; /* Enable all warnings. */
      break;
    case '?':
      calling_error("illegal or unrecognized option");
      break;
    }
  }

  if (optind == argc)
    calling_error("xp takes exactly one argument");

  /* Parse input file name and open input file. */

  {
    char layer_name[MAX_IDENT_LEN];
    char *s;

    strcpy(layer_name, argv[optind]);
    s = strrchr(layer_name, '.');
    if (s != NULL) {
      *s++ = '\0';
      if (strcmp(s, "xp") != 0)
        calling_error("illegal file name extension %s", s);
    }
    sprintf(file_name, "%s.nxp", layer_name);
    sprintf(cdef_name, "%s.cdef", layer_name);
    sprintf(kdef_name, "%s.kdef", layer_name);

    yyin = fopen(file_name, "r");
    if (yyin == NULL)
      error("Can't open file %s", file_name);
  }

  /* Find minimum and maximum layer operation numbers. */ 

  {
    int i;

    min_special_op = max_special_op = op_tab[0].op_num;

    for(i = 0; op_tab[i].op_num; i++)
    {
      if (min_special_op > op_tab[i].op_num)
        min_special_op = op_tab[i].op_num;
      else if (max_special_op < op_tab[i].op_num)
        max_special_op = op_tab[i].op_num;
#ifndef NDEBUG
      /* Make sure operation table initialization values are in the
         legal range. */
      if (op_tab[i].num_arg < 0 || op_tab[i].num_arg > MAX_OP_PARAM)
        error("operation %s: number of arguments %d must be in range 1...%d",
              op_tab[i].name, op_tab[i].num_arg, MAX_OP_PARAM);
      if (strlen(op_tab[i].constname) >= CONSTNAME_LEN)
        error("operation %s: length of operation number constant > %d",
              op_tab[i].name, CONSTNAME_LEN);
      if (strlen(op_tab[i].proc) > PROC_LEN)
        error("operation %s: length of operation argument list > %d",
              op_tab[i].name, PROC_LEN);
      if (strlen(op_tab[i].oparglist) > OPARGLIST_LEN)
        error("operation %s: length of operation argument list > %d",
              op_tab[i].name, OPARGLIST_LEN);
#endif      
    }
  }

  /* Initialize. */

  init_type_system();
  member_ctype = UNDEFINED_CTYPE;

  {
    int q;
    for(q = 0; q < MAX_NUM_OPS+1; q++)
      seen[q] = FALSE;
  }
  
  /* Parse. */

  if (yyparse() != 0)
    error("parsing failed");

  /* Report. */

  have_all_operations_been_seen();

  /* Generate layerdef. */

  gen_layerdef();

  /* Exit. */

  exit(EXIT_SUCCESS);
}