/* File autogenerated by gengetopt version 2.13.1 generated with the following command: gengetopt --unamed-opts=CLIENT [SERVER] --no-handle-help --no-handle-error --input shishi.ggo --file-name shishi_cmd The developers of gengetopt consider the fixed text that goes in all gengetopt output files to be in the public domain: we make no copyright claims on it. */ /* If we use autoconf. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include "getopt.h" #include "shishi_cmd.h" static void clear_given (struct gengetopt_args_info *args_info); static void clear_args (struct gengetopt_args_info *args_info); static int cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required, const char *additional_error); static char * gengetopt_strdup (const char *s); static void clear_given (struct gengetopt_args_info *args_info) { args_info->help_given = 0 ; args_info->version_given = 0 ; args_info->destroy_given = 0 ; args_info->list_given = 0 ; args_info->renew_given = 0 ; args_info->forwardable_given = 0 ; args_info->forwarded_given = 0 ; args_info->proxiable_given = 0 ; args_info->proxy_given = 0 ; args_info->renewable_given = 0 ; args_info->client_name_given = 0 ; args_info->encryption_type_given = 0 ; args_info->endtime_given = 0 ; args_info->realm_given = 0 ; args_info->renew_till_given = 0 ; args_info->server_name_given = 0 ; args_info->starttime_given = 0 ; args_info->ticket_granter_given = 0 ; args_info->configuration_file_given = 0 ; args_info->ticket_file_given = 0 ; args_info->library_options_given = 0 ; args_info->quiet_given = 0 ; args_info->system_configuration_file_given = 0 ; args_info->ticket_write_file_given = 0 ; args_info->verbose_given = 0 ; } static void clear_args (struct gengetopt_args_info *args_info) { args_info->destroy_flag = 0; args_info->list_flag = 0; args_info->renew_flag = 0; args_info->forwardable_flag = 0; args_info->forwarded_flag = 0; args_info->proxiable_flag = 0; args_info->proxy_flag = 0; args_info->renewable_flag = 0; args_info->client_name_arg = NULL; args_info->encryption_type_arg = NULL; args_info->endtime_arg = NULL; args_info->realm_arg = NULL; args_info->renew_till_arg = NULL; args_info->server_name_arg = NULL; args_info->starttime_arg = NULL; args_info->ticket_granter_arg = NULL; args_info->configuration_file_arg = NULL; args_info->ticket_file_arg = NULL; args_info->library_options_arg = NULL; args_info->quiet_flag = 0; args_info->system_configuration_file_arg = NULL; args_info->ticket_write_file_arg = NULL; } void cmdline_parser_print_version (void) { printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION); } void cmdline_parser_print_help (void) { cmdline_parser_print_version (); printf("\n%s\n", "Shishi command line client. If no command is given, Shishi\nacquire or list a valid ticket for you, identified by CLIENT (if\nempty, default username in default realm), for the service SERVER (if\nempty, ticket granting ticket for client realm)."); printf("\nUsage: shishi [OPTIONS]... [CLIENT [SERVER]]...\n\n"); printf("%s\n"," -h, --help Print help and exit"); printf("%s\n"," -V, --version Print version and exit"); printf("%s\n","\nCommands:"); printf("%s\n"," -d, --destroy Destroy tickets in local cache, limited by any \n --client-name or --server-name. \n (default=off)"); printf("%s\n"," -l, --list List tickets in local cache, limited by any \n --client-name and --server-name. \n (default=off)"); printf("%s\n"," -r, --renew Renew ticket. Use --server-name to specify \n ticket, default is the most recent renewable \n ticket granting ticket for the default realm. \n (default=off)"); printf("%s\n","\nFlags:"); printf("%s\n"," --forwardable Get a forwardable ticket, i.e., one that can be \n used to get forwarded tickets. (default=off)"); printf("%s\n"," --forwarded Get a forwarded ticket. (default=off)"); printf("%s\n"," --proxiable Get a proxiable ticket, i.e., one that can be \n used to get proxy tickets. (default=off)"); printf("%s\n"," --proxy Get a proxy ticket. (default=off)"); printf("%s\n"," --renewable Get a renewable ticket. (default=off)"); printf("%s\n","\nOptions:"); printf("%s\n"," --client-name=NAME Client name. Default is login username."); printf("%s\n"," -E, --encryption-type=ETYPE,[ETYPE...]\n Encryption types to use. ETYPE is either \n registered name or integer. Valid values \n include 'aes128', 'aes256', 'aes' (same as \n 'aes256'), '3des', 'des-md5', 'des-md4', \n 'des-crc', 'des' (same as 'des-md5'), and \n 'arcfour'."); printf("%s\n"," -e, --endtime=STRING Specify when ticket validity should expire. \n The time syntax may be relative (to the start \n time), such as '20 hours', or absolute, such \n as '2001-02-03 04:05:06 CET'. The default is \n 8 hours after the start time."); printf("%s\n"," --realm=STRING Set default realm."); printf("%s\n"," --renew-till=STRING Specify renewable life of ticket. Implies \n --renewable. Accepts same time syntax as \n --endtime. If --renewable is specified, the \n default is 1 week after the start time."); printf("%s\n"," --server-name=NAME Server name. Default is 'krbtgt/REALM' where \n REALM is client realm."); printf("%s\n"," -s, --starttime=STRING Specify when ticket should start to be valid. \n Accepts same time syntax as --endtime. The \n default is to become valid immediately."); printf("%s\n"," --ticket-granter=NAME Service name in ticket to use for \n authenticating request. Only for TGS. \n Defaults to 'krbtgt/REALM@REALM' where REALM \n is client realm."); printf("%s\n","\nOther options:"); printf("%s\n"," --configuration-file=FILE Read user configuration from FILE."); printf("%s\n"," -c, --ticket-file=FILE Read tickets from FILE."); printf("%s\n"," -o, --library-options=STRING Parse STRING as a configuration file statement."); printf("%s\n"," -q, --quiet Don't produce any diagnostic output.\n (default=off)"); printf("%s\n"," --system-configuration-file=FILE\n Read system configuration from FILE."); printf("%s\n"," --ticket-write-file=FILE Write tickets from FILE. Default is to write \n them back to where they were read from."); printf("%s\n"," -v, --verbose Produce verbose output.\n Use multiple times to increase amount of \n information."); } void cmdline_parser_init (struct gengetopt_args_info *args_info) { clear_given (args_info); clear_args (args_info); args_info->inputs = NULL; args_info->inputs_num = 0; } void cmdline_parser_free (struct gengetopt_args_info *args_info) { unsigned int i; if (args_info->client_name_arg) { free (args_info->client_name_arg); /* free previous argument */ args_info->client_name_arg = 0; } if (args_info->encryption_type_arg) { free (args_info->encryption_type_arg); /* free previous argument */ args_info->encryption_type_arg = 0; } if (args_info->endtime_arg) { free (args_info->endtime_arg); /* free previous argument */ args_info->endtime_arg = 0; } if (args_info->realm_arg) { free (args_info->realm_arg); /* free previous argument */ args_info->realm_arg = 0; } if (args_info->renew_till_arg) { free (args_info->renew_till_arg); /* free previous argument */ args_info->renew_till_arg = 0; } if (args_info->server_name_arg) { free (args_info->server_name_arg); /* free previous argument */ args_info->server_name_arg = 0; } if (args_info->starttime_arg) { free (args_info->starttime_arg); /* free previous argument */ args_info->starttime_arg = 0; } if (args_info->ticket_granter_arg) { free (args_info->ticket_granter_arg); /* free previous argument */ args_info->ticket_granter_arg = 0; } if (args_info->configuration_file_arg) { free (args_info->configuration_file_arg); /* free previous argument */ args_info->configuration_file_arg = 0; } if (args_info->ticket_file_arg) { free (args_info->ticket_file_arg); /* free previous argument */ args_info->ticket_file_arg = 0; } if (args_info->library_options_arg) { free (args_info->library_options_arg); /* free previous argument */ args_info->library_options_arg = 0; } if (args_info->system_configuration_file_arg) { free (args_info->system_configuration_file_arg); /* free previous argument */ args_info->system_configuration_file_arg = 0; } if (args_info->ticket_write_file_arg) { free (args_info->ticket_write_file_arg); /* free previous argument */ args_info->ticket_write_file_arg = 0; } for (i = 0; i < args_info->inputs_num; ++i) free (args_info->inputs [i]); if (args_info->inputs_num) free (args_info->inputs); clear_given (args_info); } /* gengetopt_strdup() */ /* strdup.c replacement of strdup, which is not standard */ char * gengetopt_strdup (const char *s) { char *result = NULL; if (!s) return result; result = (char*)malloc(strlen(s) + 1); if (result == (char*)0) return (char*)0; strcpy(result, s); return result; } int cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info) { return cmdline_parser2 (argc, argv, args_info, 0, 1, 1); } int cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required) { int result; result = cmdline_parser_internal (argc, argv, args_info, override, initialize, check_required, NULL); return result; } int cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name) { return EXIT_SUCCESS; } int cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required, const char *additional_error) { int c; /* Character of the parsed option. */ int error = 0; struct gengetopt_args_info local_args_info; if (initialize) cmdline_parser_init (args_info); cmdline_parser_init (&local_args_info); optarg = 0; optind = 1; opterr = 1; optopt = '?'; while (1) { int option_index = 0; char *stop_char; static struct option long_options[] = { { "help", 0, NULL, 'h' }, { "version", 0, NULL, 'V' }, { "destroy", 0, NULL, 'd' }, { "list", 0, NULL, 'l' }, { "renew", 0, NULL, 'r' }, { "forwardable", 0, NULL, 0 }, { "forwarded", 0, NULL, 0 }, { "proxiable", 0, NULL, 0 }, { "proxy", 0, NULL, 0 }, { "renewable", 0, NULL, 0 }, { "client-name", 1, NULL, 0 }, { "encryption-type", 1, NULL, 'E' }, { "endtime", 1, NULL, 'e' }, { "realm", 1, NULL, 0 }, { "renew-till", 1, NULL, 0 }, { "server-name", 1, NULL, 0 }, { "starttime", 1, NULL, 's' }, { "ticket-granter", 1, NULL, 0 }, { "configuration-file", 1, NULL, 0 }, { "ticket-file", 1, NULL, 'c' }, { "library-options", 1, NULL, 'o' }, { "quiet", 0, NULL, 'q' }, { "system-configuration-file", 1, NULL, 0 }, { "ticket-write-file", 1, NULL, 0 }, { "verbose", 0, NULL, 'v' }, { NULL, 0, NULL, 0 } }; stop_char = 0; c = getopt_long (argc, argv, "hVdlrE:e:s:c:o:qv", long_options, &option_index); if (c == -1) break; /* Exit from `while (1)' loop. */ switch (c) { case 'h': /* Print help and exit. */ if (local_args_info.help_given) { fprintf (stderr, "%s: `--help' (`-h') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->help_given && ! override) continue; local_args_info.help_given = 1; args_info->help_given = 1; cmdline_parser_free (&local_args_info); return 0; case 'V': /* Print version and exit. */ cmdline_parser_print_version (); cmdline_parser_free (&local_args_info); exit (EXIT_SUCCESS); case 'd': /* Destroy tickets in local cache, limited by any --client-name or --server-name.. */ if (local_args_info.destroy_given) { fprintf (stderr, "%s: `--destroy' (`-d') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->destroy_given && ! override) continue; local_args_info.destroy_given = 1; args_info->destroy_given = 1; args_info->destroy_flag = !(args_info->destroy_flag); break; case 'l': /* List tickets in local cache, limited by any --client-name and --server-name.. */ if (local_args_info.list_given) { fprintf (stderr, "%s: `--list' (`-l') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->list_given && ! override) continue; local_args_info.list_given = 1; args_info->list_given = 1; args_info->list_flag = !(args_info->list_flag); break; case 'r': /* Renew ticket. Use --server-name to specify ticket, default is the most recent renewable ticket granting ticket for the default realm.. */ if (local_args_info.renew_given) { fprintf (stderr, "%s: `--renew' (`-r') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->renew_given && ! override) continue; local_args_info.renew_given = 1; args_info->renew_given = 1; args_info->renew_flag = !(args_info->renew_flag); break; case 'E': /* Encryption types to use. ETYPE is either registered name or integer. Valid values include 'aes128', 'aes256', 'aes' (same as 'aes256'), '3des', 'des-md5', 'des-md4', 'des-crc', 'des' (same as 'des-md5'), and 'arcfour'.. */ if (local_args_info.encryption_type_given) { fprintf (stderr, "%s: `--encryption-type' (`-E') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->encryption_type_given && ! override) continue; local_args_info.encryption_type_given = 1; args_info->encryption_type_given = 1; if (args_info->encryption_type_arg) free (args_info->encryption_type_arg); /* free previous string */ args_info->encryption_type_arg = gengetopt_strdup (optarg); break; case 'e': /* Specify when ticket validity should expire. The time syntax may be relative (to the start time), such as '20 hours', or absolute, such as '2001-02-03 04:05:06 CET'. The default is 8 hours after the start time.. */ if (local_args_info.endtime_given) { fprintf (stderr, "%s: `--endtime' (`-e') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->endtime_given && ! override) continue; local_args_info.endtime_given = 1; args_info->endtime_given = 1; if (args_info->endtime_arg) free (args_info->endtime_arg); /* free previous string */ args_info->endtime_arg = gengetopt_strdup (optarg); break; case 's': /* Specify when ticket should start to be valid. Accepts same time syntax as --endtime. The default is to become valid immediately.. */ if (local_args_info.starttime_given) { fprintf (stderr, "%s: `--starttime' (`-s') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->starttime_given && ! override) continue; local_args_info.starttime_given = 1; args_info->starttime_given = 1; if (args_info->starttime_arg) free (args_info->starttime_arg); /* free previous string */ args_info->starttime_arg = gengetopt_strdup (optarg); break; case 'c': /* Read tickets from FILE.. */ if (local_args_info.ticket_file_given) { fprintf (stderr, "%s: `--ticket-file' (`-c') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->ticket_file_given && ! override) continue; local_args_info.ticket_file_given = 1; args_info->ticket_file_given = 1; if (args_info->ticket_file_arg) free (args_info->ticket_file_arg); /* free previous string */ args_info->ticket_file_arg = gengetopt_strdup (optarg); break; case 'o': /* Parse STRING as a configuration file statement.. */ if (local_args_info.library_options_given) { fprintf (stderr, "%s: `--library-options' (`-o') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->library_options_given && ! override) continue; local_args_info.library_options_given = 1; args_info->library_options_given = 1; if (args_info->library_options_arg) free (args_info->library_options_arg); /* free previous string */ args_info->library_options_arg = gengetopt_strdup (optarg); break; case 'q': /* Don't produce any diagnostic output.\n. */ if (local_args_info.quiet_given) { fprintf (stderr, "%s: `--quiet' (`-q') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->quiet_given && ! override) continue; local_args_info.quiet_given = 1; args_info->quiet_given = 1; args_info->quiet_flag = !(args_info->quiet_flag); break; case 'v': /* Produce verbose output.\nUse multiple times to increase amount of information.. */ local_args_info.verbose_given++; break; case 0: /* Long option with no short option */ /* Get a forwardable ticket, i.e., one that can be used to get forwarded tickets.. */ if (strcmp (long_options[option_index].name, "forwardable") == 0) { if (local_args_info.forwardable_given) { fprintf (stderr, "%s: `--forwardable' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->forwardable_given && ! override) continue; local_args_info.forwardable_given = 1; args_info->forwardable_given = 1; args_info->forwardable_flag = !(args_info->forwardable_flag); } /* Get a forwarded ticket.. */ else if (strcmp (long_options[option_index].name, "forwarded") == 0) { if (local_args_info.forwarded_given) { fprintf (stderr, "%s: `--forwarded' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->forwarded_given && ! override) continue; local_args_info.forwarded_given = 1; args_info->forwarded_given = 1; args_info->forwarded_flag = !(args_info->forwarded_flag); } /* Get a proxiable ticket, i.e., one that can be used to get proxy tickets.. */ else if (strcmp (long_options[option_index].name, "proxiable") == 0) { if (local_args_info.proxiable_given) { fprintf (stderr, "%s: `--proxiable' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->proxiable_given && ! override) continue; local_args_info.proxiable_given = 1; args_info->proxiable_given = 1; args_info->proxiable_flag = !(args_info->proxiable_flag); } /* Get a proxy ticket.. */ else if (strcmp (long_options[option_index].name, "proxy") == 0) { if (local_args_info.proxy_given) { fprintf (stderr, "%s: `--proxy' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->proxy_given && ! override) continue; local_args_info.proxy_given = 1; args_info->proxy_given = 1; args_info->proxy_flag = !(args_info->proxy_flag); } /* Get a renewable ticket.. */ else if (strcmp (long_options[option_index].name, "renewable") == 0) { if (local_args_info.renewable_given) { fprintf (stderr, "%s: `--renewable' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->renewable_given && ! override) continue; local_args_info.renewable_given = 1; args_info->renewable_given = 1; args_info->renewable_flag = !(args_info->renewable_flag); } /* Client name. Default is login username.. */ else if (strcmp (long_options[option_index].name, "client-name") == 0) { if (local_args_info.client_name_given) { fprintf (stderr, "%s: `--client-name' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->client_name_given && ! override) continue; local_args_info.client_name_given = 1; args_info->client_name_given = 1; if (args_info->client_name_arg) free (args_info->client_name_arg); /* free previous string */ args_info->client_name_arg = gengetopt_strdup (optarg); } /* Set default realm.. */ else if (strcmp (long_options[option_index].name, "realm") == 0) { if (local_args_info.realm_given) { fprintf (stderr, "%s: `--realm' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->realm_given && ! override) continue; local_args_info.realm_given = 1; args_info->realm_given = 1; if (args_info->realm_arg) free (args_info->realm_arg); /* free previous string */ args_info->realm_arg = gengetopt_strdup (optarg); } /* Specify renewable life of ticket. Implies --renewable. Accepts same time syntax as --endtime. If --renewable is specified, the default is 1 week after the start time.. */ else if (strcmp (long_options[option_index].name, "renew-till") == 0) { if (local_args_info.renew_till_given) { fprintf (stderr, "%s: `--renew-till' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->renew_till_given && ! override) continue; local_args_info.renew_till_given = 1; args_info->renew_till_given = 1; if (args_info->renew_till_arg) free (args_info->renew_till_arg); /* free previous string */ args_info->renew_till_arg = gengetopt_strdup (optarg); } /* Server name. Default is 'krbtgt/REALM' where REALM is client realm.. */ else if (strcmp (long_options[option_index].name, "server-name") == 0) { if (local_args_info.server_name_given) { fprintf (stderr, "%s: `--server-name' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->server_name_given && ! override) continue; local_args_info.server_name_given = 1; args_info->server_name_given = 1; if (args_info->server_name_arg) free (args_info->server_name_arg); /* free previous string */ args_info->server_name_arg = gengetopt_strdup (optarg); } /* Service name in ticket to use for authenticating request. Only for TGS. Defaults to 'krbtgt/REALM@REALM' where REALM is client realm.. */ else if (strcmp (long_options[option_index].name, "ticket-granter") == 0) { if (local_args_info.ticket_granter_given) { fprintf (stderr, "%s: `--ticket-granter' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->ticket_granter_given && ! override) continue; local_args_info.ticket_granter_given = 1; args_info->ticket_granter_given = 1; if (args_info->ticket_granter_arg) free (args_info->ticket_granter_arg); /* free previous string */ args_info->ticket_granter_arg = gengetopt_strdup (optarg); } /* Read user configuration from FILE.. */ else if (strcmp (long_options[option_index].name, "configuration-file") == 0) { if (local_args_info.configuration_file_given) { fprintf (stderr, "%s: `--configuration-file' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->configuration_file_given && ! override) continue; local_args_info.configuration_file_given = 1; args_info->configuration_file_given = 1; if (args_info->configuration_file_arg) free (args_info->configuration_file_arg); /* free previous string */ args_info->configuration_file_arg = gengetopt_strdup (optarg); } /* Read system configuration from FILE.. */ else if (strcmp (long_options[option_index].name, "system-configuration-file") == 0) { if (local_args_info.system_configuration_file_given) { fprintf (stderr, "%s: `--system-configuration-file' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->system_configuration_file_given && ! override) continue; local_args_info.system_configuration_file_given = 1; args_info->system_configuration_file_given = 1; if (args_info->system_configuration_file_arg) free (args_info->system_configuration_file_arg); /* free previous string */ args_info->system_configuration_file_arg = gengetopt_strdup (optarg); } /* Write tickets from FILE. Default is to write them back to where they were read from.. */ else if (strcmp (long_options[option_index].name, "ticket-write-file") == 0) { if (local_args_info.ticket_write_file_given) { fprintf (stderr, "%s: `--ticket-write-file' option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->ticket_write_file_given && ! override) continue; local_args_info.ticket_write_file_given = 1; args_info->ticket_write_file_given = 1; if (args_info->ticket_write_file_arg) free (args_info->ticket_write_file_arg); /* free previous string */ args_info->ticket_write_file_arg = gengetopt_strdup (optarg); } break; case '?': /* Invalid option. */ /* `getopt_long' already printed an error message. */ goto failure; default: /* bug: option not considered. */ fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : "")); abort (); } /* switch */ } /* while */ args_info->verbose_given += local_args_info.verbose_given; local_args_info.verbose_given = 0; cmdline_parser_free (&local_args_info); if ( error ) return (EXIT_FAILURE); if (optind < argc) { int i = 0 ; args_info->inputs_num = argc - optind ; args_info->inputs = (char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ; while (optind < argc) args_info->inputs[ i++ ] = gengetopt_strdup (argv[optind++]) ; } return 0; failure: cmdline_parser_free (&local_args_info); return (EXIT_FAILURE); }