#include "stream.h"
#include "version.h"
-#ifdef SSH_SECURITY
-
/*
* Number of seconds ssh has to start up
*/
void * arg,
void * datap)
{
+ int result;
struct sec_handle *rh;
char *amandad_path=NULL, *client_username=NULL, *ssh_keys=NULL;
assert(fn != NULL);
assert(hostname != NULL);
- (void)conf_fn; /* Quiet unused parameter warning */
-
- auth_debug(1, ("%s: ssh: ssh_connect: %s\n", debug_prefix_time(NULL),
- hostname));
+ auth_debug(1, "ssh_connect: %s\n", hostname);
rh = alloc(SIZEOF(*rh));
security_handleinit(&rh->sech, &ssh_security_driver);
rh->ev_timeout = NULL;
rh->rc = NULL;
+ /* get the canonical hostname */
rh->hostname = NULL;
- if (try_resolving_hostname(hostname, &rh->hostname)) {
+ if ((result = resolve_hostname(hostname, 0, NULL, &rh->hostname)) != 0
+ || rh->hostname == NULL) {
security_seterror(&rh->sech,
- "%s: ssh could not resolve hostname", hostname);
+ _("ssh_security could not find canonical name for '%s': %s"),
+ hostname, gai_strerror(result));
(*fn)(arg, &rh->sech, S_ERROR);
return;
}
rh->rs = tcpma_stream_client(rh, newhandle++);
+ rh->rc->conf_fn = conf_fn;
+ rh->rc->datap = datap;
if (rh->rs == NULL)
goto error;
}
if(rh->rc->read == -1) {
if (runssh(rh->rs->rc, amandad_path, client_username, ssh_keys) < 0) {
- security_seterror(&rh->sech, "can't connect to %s: %s",
+ security_seterror(&rh->sech, _("can't connect to %s: %s"),
hostname, rh->rs->rc->errmsg);
goto error;
}
memset(rpipe, -1, SIZEOF(rpipe));
memset(wpipe, -1, SIZEOF(wpipe));
if (pipe(rpipe) < 0 || pipe(wpipe) < 0) {
- rc->errmsg = newvstralloc(rc->errmsg, "pipe: ", strerror(errno), NULL);
+ rc->errmsg = newvstrallocf(rc->errmsg, _("pipe: %s"), strerror(errno));
return (-1);
}
switch (rc->pid = fork()) {
case -1:
- rc->errmsg = newvstralloc(rc->errmsg, "fork: ", strerror(errno), NULL);
+ rc->errmsg = newvstrallocf(rc->errmsg, _("fork: %s"), strerror(errno));
aclose(rpipe[0]);
aclose(rpipe[1]);
aclose(wpipe[0]);
safe_fd(-1, 0);
if(!xamandad_path || strlen(xamandad_path) <= 1)
- xamandad_path = vstralloc(libexecdir, "/", "amandad",
+ xamandad_path = vstralloc(amlibexecdir, "/", "amandad",
versionsuffix(), NULL);
if(!xclient_username || strlen(xclient_username) <= 1)
xclient_username = CLIENT_LOGIN;
/* should never go here, shut up compiler warning */
return(-1);
}
-
-#endif /* SSH_SECURITY */