2
Copyright (C) 2003-2004 Douglas Thain and the University of Wisconsin
3
Copyright (C) 2005- The University of Notre Dame
4
This software is distributed under the GNU General Public License.
5
See the file COPYING for details.
12
#include "domain_name_cache.h"
14
#include "stringtools.h"
21
static void show_use( const char *cmd )
23
fprintf(stderr,"Use: %s [options]\n",cmd);
24
fprintf(stderr,"Where options are:\n");
25
fprintf(stderr," -a <type> Allow this auth type\n");
26
fprintf(stderr," -p <num> Port number\n");
27
fprintf(stderr," -r <host> Remote host\n");
28
fprintf(stderr," -d <flag> Debugging\n");
29
fprintf(stderr,"Where debug flags arg: ");
30
debug_flags_print(stderr);
35
int main( int argc, char *argv[] )
37
struct link *link, *master;
38
char *subject=0, *type=0;
46
debug_config(argv[0]);
48
while((c=getopt(argc,argv,"a:p:r:d:o:O:"))!=(char)-1) {
51
portnum = atoi(optarg);
57
debug_flags_set(optarg);
60
debug_config_file(optarg);
63
debug_config_file_size(string_metric_parse(optarg));
66
if(!auth_register_byname(optarg)) fatal("couldn't register %s authentication",optarg);
75
char addr[LINK_ADDRESS_MAX];
77
stoptime = time(0)+timeout;
79
if(!domain_name_cache_lookup(hostname,addr)) fatal("unknown host name: %s",hostname);
81
link = link_connect(addr,portnum,stoptime);
82
if(!link) fatal("couldn't connect to %s:%d: %s",hostname,portnum,strerror(errno));
84
if(auth_assert(link,&type,&subject,stoptime)) {
85
printf("server thinks I am %s %s\n",type,subject);
86
if(link_readline(link,line,sizeof(line),stoptime)) {
87
printf("got message: %s\n",line);
89
printf("lost connection!\n");
92
printf("unable to authenticate.\n");
98
stoptime = time(0)+timeout;
100
master = link_serve(portnum);
101
if(!master) fatal("couldn't serve port %d: %s\n",portnum,strerror(errno));
103
while(time(0)<stoptime) {
104
link = link_accept(master,stoptime);
107
if(auth_accept(link,&type,&subject,stoptime)) {
109
link_putfstring(link,"Hello %s:%s, it is now %s",stoptime,type,subject,ctime(&t)); /* ctime ends with newline */
111
printf("couldn't auth accept\n");