#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "private.h" int main(int argc, char **argv) { int retval = -1; struct options *opts = NULL; int unix_sock = -1; ktp_session_t *session = NULL; faux_msg_t *msg = NULL; faux_net_t *net = NULL; // Parse command line options opts = opts_init(); if (opts_parse(argc, argv, opts)) { fprintf(stderr, "Error: Can't parse command line options\n"); goto err; } // Connect to server unix_sock = ktp_connect_unix(opts->unix_socket_path); if (unix_sock < 0) { fprintf(stderr, "Error: Can't connect to server\n"); goto err; } session = ktp_session_new(unix_sock); assert(session); if (!session) { fprintf(stderr, "Error: Can't create klish session\n"); goto err; } net = faux_net_new(); faux_net_set_fd(net, ktp_session_fd(session)); msg = faux_msg_new(KTP_MAGIC, KTP_MAJOR, KTP_MINOR); faux_msg_set_cmd(msg, KTP_AUTH); faux_msg_send(msg, net); // write(ktp_session_fd(session), "hello", 5); faux_msg_free(msg); faux_net_free(net); retval = 0; err: ktp_session_free(session); ktp_disconnect(unix_sock); opts_free(opts); return retval; }