+ /* do the security thing */
+ amfree(buf);
+ buf = stralloc(get_client_line());
+ 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)) {
+#define sc "OPTIONS "
+ if(strncmp(line, sc, sizeof(sc)-1) == 0) {
+#undef sc
+ 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);
+ fflush(stdin);
+ if ((dup2(ctlfdout, fileno(stdout)) < 0)
+ || (dup2(ctlfdin, fileno(stdin)) < 0)) {
+ error("amandad: Failed to setup stdin or stdout");
+ /*NOTREACHED*/
+ }
+ }