client UPDATE set known_hosts file/mode
Added two new API calls, one of them sets the path to the known_hosts
file and the other sets the behaviour of host key checking. Now the
client's host key checking functionality is similar to the one described
in man ssh_config under StrictHostKeyChecking.
diff --git a/src/io.c b/src/io.c
index b2cf495..d9b5c54 100644
--- a/src/io.c
+++ b/src/io.c
@@ -1177,7 +1177,7 @@
}
struct passwd *
-nc_getpwuid(uid_t uid, struct passwd *pwd_buf, char **buf, size_t *buf_size)
+nc_getpw(uid_t uid, const char *username, struct passwd *pwd_buf, char **buf, size_t *buf_size)
{
struct passwd *pwd = NULL;
long sys_size;
@@ -1200,11 +1200,19 @@
return NULL;
}
- ret = getpwuid_r(uid, pwd_buf, *buf, *buf_size, &pwd);
+ if (username) {
+ ret = getpwnam_r(username, pwd_buf, *buf, *buf_size, &pwd);
+ } else {
+ ret = getpwuid_r(uid, pwd_buf, *buf, *buf_size, &pwd);
+ }
} while (ret && (ret == ERANGE));
if (ret) {
- ERR(NULL, "Retrieving UID \"%lu\" passwd entry failed (%s).", (unsigned long)uid, strerror(ret));
+ if (username) {
+ ERR(NULL, "Retrieving username \"%s\" passwd entry failed (%s).", username, strerror(ret));
+ } else {
+ ERR(NULL, "Retrieving UID \"%lu\" passwd entry failed (%s).", (unsigned long)uid, strerror(ret));
+ }
}
return pwd;
}