int main(int argc, char **argv) { struct xmpp xmpp = { 0 }; int i, port = XMPP_PORT, fd, ret = 1; char *jid = 0, *pwdfile = 0, *srv = 0; for (i = 1; i < argc - 1 && argv[i][0] == '-'; i++) switch (argv[i][1]) { case 'j': jid = argv[++i]; break; case 'k': pwdfile = argv[++i]; break; case 's': srv = argv[++i]; break; case 'l': show_log = atoi(argv[++i]); break; case 'p': port = atoi(argv[++i]); break; default: die_usage(); } if (!jid) die_usage(); xmpp.io_context = &fd; xmpp.send = io_send; xmpp.tls_fn = use_tls ? start_tls : 0; xmpp.stream_fn = stream_handler; xmpp.node_fn = node_handler; xmpp.auth_fn = auth_handler; xmpp.use_sasl = use_sasl; xmpp.jid = jid; read_pw(pwdfile, &xmpp); if (xmpp_init(&xmpp, 4096)) return 1; if (!srv) srv = xmpp.server; fd = tcp_connect(srv, port); if (fd < 0) return 1; if (!(xmpp_start(&xmpp) || process_connection(fd, &xmpp))) ret = 0; xmpp_printf(&xmpp, "</stream:stream>"); xmpp_clean(&xmpp); close(fd); shutdown(fd, 2); return ret; }
int main(int argc, char **argv) { krb5_context context; krb5_ccache ccache; krb5_principal p; char *name; char *pw; if (argc != 2) usage(); #ifdef HAVE_ALARM alarm( TIMEOUT ); #endif name = argv[1]; pw = read_pw(stdin); if (!pw) die("No proper password provided."); if (!strcmp(name, "root")) /* In this case, heimdal's su.c creates a principal for the * current uid, but I don't quite understand why. */ die("Won't log in root."); if (krb5_init_context (&context)) die("krb5_init_context failed."); if (krb5_make_principal(context, &p, NULL, name, NULL)) die("krb5_make_principal failed."); if (!krb5_kuserok(context, p, name)) die("krb5_kuserok doesn't know the user."); if (krb5_cc_gen_new(context, &krb5_mcc_ops, &ccache)) die("krb5_cc_gen_new failed."); if (krb5_verify_user_lrealm(context, p, ccache, pw, TRUE, NULL)) die("krb5_verify_user_lrealm failed."); /* Authentication successful. */ /* TODO: Keep the credential cache in some way. Perhaps write it to * disk, and, write the file name used to stdout. */ return EXIT_SUCCESS; }