Prevent compile errors on OSX (#198)
build CHANGE prevent compile errors on OSX
* Prevent compile errors on OSX
clangtidy cmake files too
fix possible buffer overflow too
* Fix travis build error
The imported include path setting is only later needed!
* Fix libssh version detection
Cmake variable is now LIBSSH_VERSION!
* python: do not put generated files into the source tree
Untracked content shows up in git submodules, causing stuff to be marked
"dirty" by various git-level tools.
Tested by temporarily putting the resulting target within `ALL`. The
result is the same as without this change (and it remains unusable with
no generated index, at least when building out-of-tree, BTW).
* apply review notes
* Prevent compile errors on OSX
clangtidy cmake files too
fix possible buffer overflow too
* Fix travis build error
The imported include path setting is only later needed!
* Fix libssh version detection
Cmake variable is now LIBSSH_VERSION!
* apply review notes
Co-authored-by: Jan Kundrát <jkt@flaska.net>
diff --git a/src/io.c b/src/io.c
index 4c5ef55..cb294bf 100644
--- a/src/io.c
+++ b/src/io.c
@@ -813,8 +813,9 @@
nc_write_starttag_and_msg(struct nc_session *session, const void *buf, size_t count)
{
int ret = 0, c;
- char chunksize[20];
+ char chunksize[24];
+ // warning: ‘%zu’ directive writing between 4 and 20 bytes into a region of size 18 [-Wformat-overflow=]
if (session->version == NC_VERSION_11) {
sprintf(chunksize, "\n#%zu\n", count);
ret = nc_write(session, chunksize, strlen(chunksize));
diff --git a/src/session_server.c b/src/session_server.c
index a60f34b..239c7cf 100644
--- a/src/session_server.c
+++ b/src/session_server.c
@@ -1720,11 +1720,11 @@
static int
nc_accept_unix(struct nc_session *session, int sock)
{
+#ifdef SO_PEERCRED
const struct passwd *pw;
struct ucred ucred;
char *username;
socklen_t len;
-
session->ti_type = NC_TI_UNIX;
len = sizeof(ucred);
@@ -1754,6 +1754,9 @@
session->ti.unixsock.sock = sock;
return 1;
+#else
+ return -1;
+#endif
}
API int
diff --git a/src/session_server_ssh.c b/src/session_server_ssh.c
index fb0dc85..412fbac 100644
--- a/src/session_server_ssh.c
+++ b/src/session_server_ssh.c
@@ -19,10 +19,14 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <pwd.h>
+#ifndef __APPLE__
#include <shadow.h>
#include <crypt.h>
+#endif
#include <errno.h>
#include <time.h>
+#include <fcntl.h>
+#include <unistd.h>
#include "config.h"
#include "session_server.h"
@@ -660,6 +664,7 @@
static char *
auth_password_get_pwd_hash(const char *username)
{
+#ifndef __APPLE__
struct passwd *pwd, pwd_buf;
struct spwd *spwd, spwd_buf;
char *pass_hash = NULL, buf[256];
@@ -698,6 +703,9 @@
}
return strdup(pass_hash);
+#else
+ return strdup("");
+#endif
}
static int