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>
23 int main(int argc, char **argv)
25 char *host, *file, *rfile, *ibuf = NULL;
26 int code, i, count = 0, conn;
35 conn = mr_connect_internal(host, SERVICE_NAME);
38 com_err(whoami, errno, ": can't connect to %s:%s", host, SERVICE_NAME);
42 code = mr_send_krb5_auth(conn, host);
44 code = mr_send_auth(conn, host);
46 com_err(whoami, code, "attempting authorization");
48 for (i = 2; i < argc; i++)
50 if (argv[i][0] != '-')
59 fprintf(stderr, "Sending file %s to %s as %s\n", file, host, rfile);
60 mr_send_file(conn, file, rfile, 0);
67 fprintf(stderr, "Sending (encrypted) file %s to %s as %s\n",
69 mr_send_file(conn, file, rfile, 1);
75 ibuf = strdup("/tmp/moira-updateXXXXX");
78 com_err(whoami, ENOMEM, "sending instructions");
82 fprintf(stderr, "Sending instructions %s to %s as %s\n",
84 mr_send_file(conn, file, ibuf, 0);
92 fprintf(stderr, "Sending instructions %s to %s as %s\n",
94 mr_send_file(conn, file, ibuf, 0);
99 fprintf(stderr, "No instructions sent.");
102 fprintf(stderr, "Executing instructions %s on %s\n", ibuf, host);
103 code = mr_execute(conn, ibuf);
105 com_err(whoami, code, "executing");
111 fprintf(stderr, "Executing instructions %s on %s\n", file, host);
112 code = mr_execute(conn, file);
114 com_err(whoami, code, "executing");
129 fprintf(stderr, "Usage: test host [commands...]\n");
130 fprintf(stderr, " Commands are:\n");
131 fprintf(stderr, "\t-s srcfile dstfile\tsends file\n");
132 fprintf(stderr, "\t-S srcfile dstfile\tsends encrypted file\n");
133 fprintf(stderr, "\t-i srcfile\t\tsends instructions\n");
134 fprintf(stderr, "\t-I srcfile dstfile\tsends instructions\n");
135 fprintf(stderr, "\t-x\t\texecutes last instructions\n");
136 fprintf(stderr, "\t-X file\t\texecutes file\n");