Commit fd15040c authored by Niels Möller's avatar Niels Möller

Configure tests for strerror and strsignal

Rev: configure.in:1.14
Rev: doc/TODO:1.45
Rev: src/client.c:1.65
Rev: src/client_password.c:1.7
Rev: src/io.c:1.61
Rev: src/lsh.c:1.54
Rev: src/lsh_types.h:1.33
Rev: src/lsh_writekey.c:1.8
Rev: src/lshd.c:1.49
Rev: src/randomness.c:1.16
Rev: src/reaper.c:1.12
Rev: src/server_password.c:1.20
Rev: src/server_pty.c:1.13
Rev: src/server_session.c:1.7
Rev: src/ssh1_fallback.c:1.7
Rev: src/tcpforward.c:1.9
parent b9cc4a7b
......@@ -272,7 +272,7 @@ dnl Checks for library functions.
AC_FUNC_ALLOCA
AC_FUNC_MEMCMP
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(select socket strerror strtol)
AC_CHECK_FUNCS(select socket strerror strsignal strtol)
AC_CHECK_FUNCS(getspnam)
AC_CHECK_FUNCS(vsnprintf inet_aton)
AC_CHECK_FUNCS(openpty)
......
......@@ -244,5 +244,3 @@ such device).
Add some workaround for the poll()-bug in linux/glibc-2.07 reported by
Bazsi.
Write a configure test for strsignal.
......@@ -269,7 +269,7 @@ static int do_exit_signal(struct channel_request *c,
werror("%us", length, msg);
werror("Remote process was killed by %z.%z\n",
signal ? strsignal(signal) : "an unknown signal",
signal ? STRSIGNAL(signal) : "an unknown signal",
core ? "(core dumped remotely)\n": "");
ALIST_SET(channel->request_types, ATOM_EXIT_STATUS, NULL);
......
......@@ -69,7 +69,7 @@ static int echo_on(int fd)
if (tcgetattr(fd, &t) < 0)
{
werror("Can't get terminal attributes: %z\n", strerror(errno));
werror("Can't get terminal attributes: %z\n", STRERROR(errno));
return 0;
}
......@@ -77,7 +77,7 @@ static int echo_on(int fd)
if (tcsetattr(fd, TCSANOW, &t) < 0)
{
werror("Can't set terminal attributes: %z\n", strerror(errno));
werror("Can't set terminal attributes: %z\n", STRERROR(errno));
return 0;
}
......@@ -90,7 +90,7 @@ static int echo_off(int fd)
if (tcgetattr(fd, &t) < 0)
{
werror("Can't get terminal attributes: %z\n", strerror(errno));
werror("Can't get terminal attributes: %z\n", STRERROR(errno));
return 0;
}
......@@ -98,7 +98,7 @@ static int echo_off(int fd)
if (tcsetattr(fd, TCSAFLUSH, &t) < 0)
{
werror("Can't set terminal attributes: %z\n", strerror(errno));
werror("Can't set terminal attributes: %z\n", STRERROR(errno));
return 0;
}
......@@ -117,14 +117,14 @@ struct lsh_string *read_password(int max_length, struct lsh_string *prompt)
if (fd < 0)
{
werror("Can't open /dev/tty: %z\n", strerror(errno));
werror("Can't open /dev/tty: %z\n", STRERROR(errno));
return 0;
}
tty = fdopen(fd, "rw");
if (!tty)
{
close(fd);
werror("Can't fdopen /dev/tty: %z\n", strerror(errno));
werror("Can't fdopen /dev/tty: %z\n", STRERROR(errno));
return 0;
}
......
......@@ -179,7 +179,7 @@ int io_iter(struct io_backend *b)
case EINTR:
return 1;
default:
fatal("io_iter: poll failed: %z", strerror(errno));
fatal("io_iter: poll failed: %z", STRERROR(errno));
}
{
......@@ -252,7 +252,7 @@ static int do_read(struct abstract_read **r, UINT32 length, UINT8 *buffer)
return A_EOF;
default:
werror("io.c: do_read: read() failed (errno %i), %z\n",
errno, strerror(errno));
errno, STRERROR(errno));
debug(" fd = %i, buffer = %xi, length = %i\n",
closure->fd, buffer, length);
return A_FAIL;
......@@ -342,7 +342,7 @@ static void write_callback(struct lsh_fd *fd)
close_fd(fd, CLOSE_BROKEN_PIPE);
break;
default:
werror("io.c: write failed, %z\n", strerror(errno));
werror("io.c: write failed, %z\n", STRERROR(errno));
close_fd(fd, CLOSE_WRITE_FAILED);
......@@ -364,7 +364,7 @@ static void listen_callback(struct lsh_fd *fd)
(struct sockaddr *) &peer, &addr_len);
if (conn < 0)
{
werror("io.c: accept() failed, %z", strerror(errno));
werror("io.c: accept() failed, %z", STRERROR(errno));
return;
}
res = FD_LISTEN_CALLBACK(self->callback, conn,
......@@ -772,14 +772,14 @@ int write_raw_with_poll(int fd, UINT32 length, UINT8 *data)
void io_set_nonblocking(int fd)
{
if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0)
fatal("io_set_nonblocking: fcntl() failed, %z", strerror(errno));
fatal("io_set_nonblocking: fcntl() failed, %z", STRERROR(errno));
}
void io_set_close_on_exec(int fd)
{
if (fcntl(fd, F_SETFD, 1) < 0)
fatal("Can't set close-on-exec flag for fd %i: %z\n",
fd, strerror(errno));
fd, STRERROR(errno));
}
/* ALL file descripters handled by the backend should use non-blocking mode,
......
......@@ -321,7 +321,7 @@ int main(int argc, char **argv)
if (tty < 0)
{
werror("lsh: Failed to open tty (errno = %i): %z\n",
errno, strerror(errno));
errno, STRERROR(errno));
use_pty = 0;
}
else
......@@ -334,7 +334,7 @@ int main(int argc, char **argv)
if ( (err = dup(STDERR_FILENO)) < 0)
{
werror("Can't dup stderr: %z\n", strerror(errno));
werror("Can't dup stderr: %z\n", STRERROR(errno));
return EXIT_FAILURE;
}
......
......@@ -58,6 +58,18 @@
#define UNUSED
#endif
#if HAVE_STRERROR
#define STRERROR strerror
#else
#define STRERROR(x) (sys_errlist[x])
#endif
#if HAVE_STRSIGNAL
#define STRSIGNAL strsignal
#else
#define STRSIGNAL(x) (sys_siglist[x])
#endif
/* Some macros */
/* Reads a 32-bit integer, in network byte order */
......
......@@ -129,7 +129,7 @@ static int do_write_key(struct sexp_handler *h, struct sexp *private)
O_CREAT | O_EXCL | O_WRONLY, 0644)) < 0)
{
werror("lsh_writekey: Failed to open %z (errno = %i): %z\n",
closure->public_file, errno, strerror(errno));
closure->public_file, errno, STRERROR(errno));
return LSH_FAIL | LSH_DIE;
}
......@@ -137,7 +137,7 @@ static int do_write_key(struct sexp_handler *h, struct sexp *private)
O_CREAT | O_EXCL | O_WRONLY, 0600)) < 0)
{
werror("lsh_writekey: Failed to open %z (errno = %i): %z\n",
closure->private_file, errno, strerror(errno));
closure->private_file, errno, STRERROR(errno));
return LSH_FAIL | LSH_DIE;
}
......@@ -145,7 +145,7 @@ static int do_write_key(struct sexp_handler *h, struct sexp *private)
sexp_format(public, SEXP_TRANSPORT, 0))))
{
werror("lsh_writekey: Writing to %z failed (errno = %i): %z\n",
closure->public_file, errno, strerror(errno));
closure->public_file, errno, STRERROR(errno));
return LSH_FAIL | LSH_DIE;
}
......@@ -153,7 +153,7 @@ static int do_write_key(struct sexp_handler *h, struct sexp *private)
sexp_format(private, SEXP_CANONICAL, 0))))
{
werror("lsh_writekey: Writing to %z failed (errno = %i): %z\n",
closure->private_file, errno, strerror(errno));
closure->private_file, errno, STRERROR(errno));
return LSH_FAIL | LSH_DIE;
}
......@@ -196,7 +196,7 @@ int main(int argc UNUSED, char **argv UNUSED)
if (errno != EEXIST)
{
werror("lsh_writekey: Creating directory %z failed "
"(errno = %i): %z\n", buf, errno, strerror(errno));
"(errno = %i): %z\n", buf, errno, STRERROR(errno));
return EXIT_FAILURE;
}
}
......
......@@ -207,7 +207,7 @@ static int read_host_key(const char *name,
if (fd < 0)
{
werror("lshd: Could not open %z (errno = %i): %z\n",
name, errno, strerror(errno));
name, errno, STRERROR(errno));
return 0;
}
else
......@@ -481,7 +481,7 @@ int main(int argc, char **argv)
{
if (res & LSH_COMMAND_FAILED)
werror("lshd: Failed to bind port. (errno = %d) %z\n",
errno, strerror(errno));
errno, STRERROR(errno));
else
werror("lshd: Unexpected failure from listen: %d\n", res);
return EXIT_FAILURE;
......
......@@ -142,7 +142,7 @@ static void do_device_random(struct randomness *r, UINT32 length, UINT8 *dst)
break;
default:
fatal("Read from random device failed (errno = %i): %z\n",
errno, strerror(errno));
errno, STRERROR(errno));
}
else
{
......@@ -167,7 +167,7 @@ struct randomness *make_device_random(const char *device)
if (fd < 0)
{
werror("make_device_random: Failed to open '%z' (errno = %i): %z\n",
device, errno, strerror(errno));
device, errno, STRERROR(errno));
return NULL;
}
else
......
......@@ -136,7 +136,7 @@ static void reap(struct reaper *r)
return;
default:
fatal("reaper.c: waitpid failed (errno = %i), %z\n",
errno, strerror(errno));
errno, STRERROR(errno));
}
}
}
......
......@@ -217,17 +217,17 @@ int change_uid(struct unix_user *user)
* still running as root. */
if (initgroups(user->name->data, user->gid) < 0)
{
werror("initgroups failed: %z\n", strerror(errno));
werror("initgroups failed: %z\n", STRERROR(errno));
return 0;
}
if (setgid(user->gid) < 0)
{
werror("setgid failed: %z\n", strerror(errno));
werror("setgid failed: %z\n", STRERROR(errno));
return 0;
}
if (setuid(user->uid) < 0)
{
werror("setuid failed: %z\n", strerror(errno));
werror("setuid failed: %z\n", STRERROR(errno));
return 0;
}
return 1;
......@@ -242,7 +242,7 @@ int change_dir(struct unix_user *user)
if (chdir("/") < 0)
{
werror("Strange: home directory was NULL, and chdir(\"/\") failed: %z\n",
strerror(errno));
STRERROR(errno));
return 0;
}
}
......@@ -250,10 +250,10 @@ int change_dir(struct unix_user *user)
{
werror("chdir to %z failed (using / instead): %z\n",
user->home ? (char *) user->home->data : "none",
strerror(errno));
STRERROR(errno));
if (chdir("/") < 0)
{
werror("chdir(\"/\") failed: %z\n", strerror(errno));
werror("chdir(\"/\") failed: %z\n", STRERROR(errno));
return 0;
}
}
......@@ -290,7 +290,7 @@ static int do_setuid(struct ssh_service *c,
{
case -1:
/* Error */
werror("fork failed: %z\n", strerror(errno));
werror("fork failed: %z\n", STRERROR(errno));
return LSH_FAIL | LSH_DIE;
case 0:
/* Child */
......
......@@ -63,10 +63,10 @@ static void do_kill_pty_info(struct resource *r)
closure->super.alive = 0;
if (close(closure->master) < 0)
werror("do_kill_pty_info: closing master failed (errno = %i): %z\n",
errno, strerror(errno));
errno, STRERROR(errno));
if (close(closure->slave) < 0)
werror("do_kill_pty_info: closing slave failed (errno = %i): %z\n",
errno, strerror(errno));
errno, STRERROR(errno));
}
}
......@@ -176,7 +176,7 @@ int pty_allocate(struct pty_info *pty,
if ((pty->master = open("/dev/ptmx", O_RDWR | O_NOCTTY)) < 0)
{
werror("pty_allocate: Opening /dev/ptmx failed (errno = %i): %z\n",
errno, strerror(errno));
errno, STRERROR(errno));
return 0;
}
......@@ -285,7 +285,7 @@ int tty_setctty(struct pty_info *pty)
if (setsid() < 0)
{
werror("tty_setctty: setsid() failed, already process group leader?\n"
" (errno = %i): %z\n", errno, strerror(errno));
" (errno = %i): %z\n", errno, STRERROR(errno));
return 0;
}
#if HAVE_UNIX98_PTYS
......@@ -301,7 +301,7 @@ int tty_setctty(struct pty_info *pty)
{
werror("tty_setctty: open(\"%z\") failed,\n"
" (errno = %i): %z\n",
pty->tty_name->data, errno, strerror(errno));
pty->tty_name->data, errno, STRERROR(errno));
return 0;
}
close(fd);
......@@ -333,7 +333,7 @@ int tty_setctty(struct pty_info *pty)
if (ioctl(pty->slave, TIOCSCTTY, NULL) == -1)
{
werror("tty_setctty: Failed to set the controlling tty.\n"
" (errno = %i): %z\n", errno, strerror(errno));
" (errno = %i): %z\n", errno, STRERROR(errno));
return 0;
}
......
......@@ -130,7 +130,7 @@ static void do_kill_process(struct resource *r)
if (kill(self->pid, self->signal) < 0)
{
werror("do_kill_process: kill() failed (errno = %i): %z\n",
errno, strerror(errno));
errno, STRERROR(errno));
}
}
}
......@@ -380,7 +380,7 @@ struct lsh_string *format_exit_signal(struct ssh_channel *channel,
int core, int signal)
{
struct lsh_string *msg = ssh_format("Process killed by %lz.\n",
strsignal(signal));
STRSIGNAL(signal));
return format_channel_request(ATOM_EXIT_SIGNAL,
channel,
......@@ -489,19 +489,19 @@ static int make_pipe(int *fds)
{
if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) < 0)
{
werror("socketpair() failed: %z\n", strerror(errno));
werror("socketpair() failed: %z\n", STRERROR(errno));
return 0;
}
debug("Created socket pair. Using fd:s %i <-- %i\n", fds[0], fds[1]);
if (SHUTDOWN(fds[0], SHUT_WR) < 0)
{
werror("shutdown(%i, SEND) failed: %z\n", fds[0], strerror(errno));
werror("shutdown(%i, SEND) failed: %z\n", fds[0], STRERROR(errno));
goto fail;
}
if (SHUTDOWN(fds[1], SHUT_RD) < 0)
{
werror("shutdown(%i, REC) failed: %z\n", fds[0], strerror(errno));
werror("shutdown(%i, REC) failed: %z\n", fds[0], STRERROR(errno));
fail:
{
int saved_errno = errno;
......@@ -615,7 +615,7 @@ static int make_pty(struct pty_info *pty, int *in, int *out, int *err)
close(in[1]);
werror("make_pty: duping pty filedescriptors failed (errno = %i): %z\n",
errno, strerror(errno));
errno, STRERROR(errno));
}
errno = saved_errno;
return 0;
......@@ -666,7 +666,7 @@ static int do_spawn_shell(struct channel_request *c,
switch(child = fork())
{
case -1:
werror("fork() failed: %z\n", strerror(errno));
werror("fork() failed: %z\n", STRERROR(errno));
/* Close and return channel_failure */
break;
case 0:
......@@ -836,7 +836,7 @@ static int do_spawn_shell(struct channel_request *c,
}
else
debug("Child: execle() failed (errno = %i): %z\n",
exec_errno, strerror(exec_errno));
exec_errno, STRERROR(exec_errno));
_exit(EXIT_FAILURE);
}
#undef MAX_ENV
......
......@@ -57,7 +57,7 @@ static int fall_back_to_ssh1(struct ssh1_fallback *c,
if (pid < 0)
{
werror("Forking to start fallback sshd1 failed with %z\n",
strerror(errno));
STRERROR(errno));
return LSH_FAIL | LSH_DIE;
}
else if (pid == 0)
......@@ -94,7 +94,7 @@ static int fall_back_to_ssh1(struct ssh1_fallback *c,
"-V" ,version, /* Compatibility mode */
NULL);
werror("lshd: fall_back_to_ssh1: execl failed (errno = %i): %z\n",
errno, strerror(errno));
errno, STRERROR(errno));
_exit(EXIT_FAILURE);
/* To make gcc happy, if _exit is not declared as NORETURN */
return 0;
......
......@@ -193,7 +193,7 @@ static int do_open_direct_tcpip(struct channel_open *c,
KILL(direct_tcpip);
return CHANNEL_OPEN_CALLBACK(response, NULL,
SSH_OPEN_CONNECT_FAILED,
strerror(errno),
STRERROR(errno),
NULL);
}
REMEMBER_RESOURCE(connection->resources,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment