xfree(data);
main(int argc, char **argv){	Buffer b;	Key *keys[2], *key;	struct passwd *pw;	int key_fd[2], i, found, version = 2, fd;	u_char *signature, *data;	char *host;	u_int slen, dlen;	key_fd[0] = open(_PATH_HOST_RSA_KEY_FILE, O_RDONLY);	key_fd[1] = open(_PATH_HOST_DSA_KEY_FILE, O_RDONLY);	seteuid(getuid());	setuid(getuid());#ifdef DEBUG_SSH_KEYSIGN	log_init("ssh-keysign", SYSLOG_LEVEL_DEBUG3, SYSLOG_FACILITY_AUTH, 0);#endif	if (key_fd[0] == -1 && key_fd[1] == -1)		fatal("could not open any host key");	if ((pw = getpwuid(getuid())) == NULL)		fatal("getpwuid failed");	pw = pwcopy(pw);	SSLeay_add_all_algorithms();	found = 0;	for (i = 0; i < 2; i++) {		keys[i] = NULL;		if (key_fd[i] == -1)			continue;		keys[i] = key_load_private_pem(key_fd[i], KEY_UNSPEC,		    NULL, NULL);		close(key_fd[i]);		if (keys[i] != NULL)			found = 1;	}	if (!found)		fatal("no hostkey found");	buffer_init(&b);	if (msg_recv(STDIN_FILENO, &b) < 0)		fatal("msg_recv failed");	if (buffer_get_char(&b) != version)		fatal("bad version");	fd = buffer_get_int(&b);	if ((fd == STDIN_FILENO) || (fd == STDOUT_FILENO))		fatal("bad fd");	if ((host = get_local_name(fd)) == NULL)		fatal("cannot get sockname for fd");	data = buffer_get_string(&b, &dlen);	if (valid_request(pw, host, &key, data, dlen) < 0)		fatal("not a valid request");	xfree(data);	xfree(host);	found = 0;	for (i = 0; i < 2; i++) {		if (keys[i] != NULL &&		    key_equal(key, keys[i])) {			found = 1;			break;		}	}	if (!found)		fatal("no matching hostkey found");	if (key_sign(keys[i], &signature, &slen, data, dlen) != 0)		fatal("key_sign failed");	/* send reply */	buffer_clear(&b);	buffer_put_string(&b, signature, slen);	msg_send(STDOUT_FILENO, version, &b);	return (0);}