3 * Test client for update_server protocol.
5 * Copyright 1992-1998 by the Massachusetts Institute of Technology.
6 * For copying and distribution information, please see the file
10 #include <mit-copyright.h>
24 int main(int argc, char **argv)
26 char *host, service_address[256], *file, *rfile, buf[256];
30 initialize_sms_error_table();
31 initialize_krb_error_table();
38 sprintf(service_address, "%s:%s", host, SERVICE_NAME);
39 conn = start_server_connection(service_address, "");
40 if (!conn || (connection_status(conn) == CON_STOPPED))
42 com_err(whoami, connection_errno(conn),
43 " can't connect to update %s", service_address);
44 return MR_CANT_CONNECT;
46 code = send_auth(host);
48 com_err(whoami, code, " authorization attempt failed");
50 for (i = 2; i < argc; i++)
52 if (argv[i][0] != '-')
61 fprintf(stderr, "Sending file %s to %s as %s\n", file, host, rfile);
62 send_file(file, rfile, 0);
69 fprintf(stderr, "Sending (encrypted) file %s to %s as %s\n",
71 send_file(file, rfile, 1);
77 strcpy(buf, "/tmp/moira-updateXXXXX");
79 fprintf(stderr, "Sending instructions %s to %s as %s\n",
81 send_file(file, buf, 0);
89 fprintf(stderr, "Sending instructions %s to %s as %s\n",
91 send_file(file, buf, 0);
94 fprintf(stderr, "Executing instructions %s on %s\n", buf, host);
97 com_err(whoami, code, "executing");
103 fprintf(stderr, "Executing instructions %s on %s\n", file, host);
104 code = execute(file);
106 com_err(whoami, code, "executing");
115 conn = sever_connection(conn);
121 fprintf(stderr, "Usage: test host [commands...]\n");
122 fprintf(stderr, " Commands are:\n");
123 fprintf(stderr, "\t-s srcfile dstfile\tsends file\n");
124 fprintf(stderr, "\t-S srcfile dstfile\tsends encrypted file\n");
125 fprintf(stderr, "\t-i srcfile\t\tsends instructions\n");
126 fprintf(stderr, "\t-I srcfile dstfile\tsends instructions\n");
127 fprintf(stderr, "\t-x\t\texecutes last instructions\n");
128 fprintf(stderr, "\t-X file\t\texecutes file\n");