+ /* do the security thing */
+ amfree(buf);
+ fflush(stdout);
+ cmdout = stdout;
+ cmdin = stdin;
+ buf = stralloc(get_client_line(cmdin));
+ check_security_buffer(buf);
+ }
+ else {
+ ctlfdout = DATA_FD_OFFSET + 0;
+ ctlfdin = DATA_FD_OFFSET + 1;
+ datafdout = DATA_FD_OFFSET + 2;
+ close(DATA_FD_OFFSET +3);
+
+ /* read the REQ packet */
+ for(; (line = agets(stdin)) != NULL; free(line)) {
+ if(strncmp_const(line, "OPTIONS ") == 0) {
+ g_options = parse_g_options(line+8, 1);
+ if(!g_options->hostname) {
+ g_options->hostname = alloc(MAX_HOSTNAME_LENGTH+1);
+ gethostname(g_options->hostname, MAX_HOSTNAME_LENGTH);
+ g_options->hostname[MAX_HOSTNAME_LENGTH] = '\0';
+ }
+ }
+ }
+ amfree(line);
+
+ if(amandad_auth && g_options->auth) {
+ if(strcasecmp(amandad_auth, g_options->auth) != 0) {
+ printf("ERROR recover program ask for auth=%s while amidxtaped is configured for '%s'\n",
+ g_options->auth, amandad_auth);
+ error("ERROR recover program ask for auth=%s while amidxtaped is configured for '%s'",
+ g_options->auth, amandad_auth);
+ /*NOTREACHED*/
+ }
+ }
+ /* send the REP packet */
+ printf("CONNECT CTL %d DATA %d\n", DATA_FD_OFFSET, DATA_FD_OFFSET+1);
+ printf("\n");
+ fflush(stdout);
+ fclose(stdin);
+ fclose(stdout);
+ cmdout = fdopen(ctlfdout, "a");
+ if (!cmdout) {
+ error("amidxtaped: Can't fdopen(ctlfdout): %s", strerror(errno));
+ /*NOTREACHED*/
+ }
+ cmdin = fdopen(ctlfdin, "r");
+ if (!cmdin) {
+ error("amidxtaped: Can't fdopen(ctlfdin): %s", strerror(errno));
+ /*NOTREACHED*/
+ }
+ }