From 238924457849e53eae3771bc6240883b37e1ff34 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Sat, 19 Mar 2016 08:59:02 +0200 Subject: Fix some compilation issues on Solaris * configure.ac: Check for libnsl * src/pies.c (string_to_syslog_facility): LOG_AUTHPRIV and LOG_FTP may be undefined. * src/piesctl.c (EX_NOTFOUND): Rename to EX_PIES_NOTFOUND. (com_list): Use default_cond. * src/sysvinit.c (console_stty): Make sure CBAUDEX is defined. * src/utmp.c (fill_utmp): Declare locals right before using them. --- configure.ac | 2 ++ src/pies.c | 4 ++++ src/piesctl.c | 34 +++++++++++++++++----------------- src/sysvinit.c | 4 ++++ src/utmp.c | 23 +++++++++++------------ 5 files changed, 38 insertions(+), 29 deletions(-) diff --git a/configure.ac b/configure.ac index 830d0a7..78702b4 100644 --- a/configure.ac +++ b/configure.ac @@ -34,6 +34,8 @@ AC_PROG_LEX # Checks for libraries. AC_CHECK_LIB(crypt, crypt) +AC_SEARCH_LIBS(socket, socket) +AC_SEARCH_LIBS(gethostbyaddr, nsl) # Checks for header files. AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdint.h stdlib.h\ diff --git a/src/pies.c b/src/pies.c index 695c1b0..3fb181c 100644 --- a/src/pies.c +++ b/src/pies.c @@ -636,10 +636,14 @@ string_to_syslog_facility (const char *key, int *pres) { static struct tokendef tokdef_fac[] = { {"auth", LOG_AUTH}, +#ifdef LOG_AUTHPRIV {"authpriv", LOG_AUTHPRIV}, +#endif {"cron", LOG_CRON}, {"daemon", LOG_DAEMON}, +#ifdef LOG_FTP {"ftp", LOG_FTP}, +#endif {"kern", LOG_KERN}, {"lpr", LOG_LPR}, {"mail", LOG_MAIL}, diff --git a/src/piesctl.c b/src/piesctl.c index d10bd0e..71efbcd 100644 --- a/src/piesctl.c +++ b/src/piesctl.c @@ -54,8 +54,8 @@ int dump; struct grecs_sockaddr_hints hints = { .flags = GRECS_AH_PASSIVE }; -#define EX_OK 0 -#define EX_NOTFOUND 1 +#define EX_OK 0 +#define EX_PIES_NOTFOUND 1 int exit_status = EX_OK; @@ -1006,7 +1006,7 @@ shttp_process (struct shttp_connection *conn, int method, char const *uri) case 404: /* Not found */ case 409: /* Conflict */ - exit_status = EX_NOTFOUND; + exit_status = EX_PIES_NOTFOUND; shttp_print_error (conn); return; @@ -1484,11 +1484,24 @@ parse_condition_to_uri (char const *base, struct cmdline_parser_state *state, return ret; } +/* Provide default condition if there are no more arguments */ +static struct cmdline_parser_state * +default_cond (struct cmdline_parser_state *state) +{ + if (!peek_token (state)) + { + static char *dfl[] = { "type", "component", NULL }; + state->argc = sizeof (dfl) / sizeof (dfl[0]); + state->argv = dfl; + } + return state; +} + static void com_list (struct cmdline_parser_state *state) { struct shttp_connection *conn = state->conn; - char *uri = parse_condition_to_uri ("/programs", state, 0); + char *uri = parse_condition_to_uri ("/programs", default_cond (state), 0); shttp_io_init (&conn->req); shttp_process (conn, METH_GET, uri); @@ -1583,19 +1596,6 @@ shttp_print_response_status (struct shttp_connection *conn) } } -/* Provide default condition if there are no more arguments */ -static struct cmdline_parser_state * -default_cond (struct cmdline_parser_state *state) -{ - if (!peek_token (state)) - { - static char *dfl[] = { "type", "component", NULL }; - state->argc = sizeof (dfl) / sizeof (dfl[0]); - state->argv = dfl; - } - return state; -} - static void com_stop (struct cmdline_parser_state *state) { diff --git a/src/sysvinit.c b/src/sysvinit.c index 9043619..3078834 100644 --- a/src/sysvinit.c +++ b/src/sysvinit.c @@ -82,6 +82,10 @@ console_open (int mode) return -1; } +#ifndef CBAUDEX +# define CBAUDEX 0 +#endif + void console_stty (void) { diff --git a/src/utmp.c b/src/utmp.c index b2a232f..e13b74d 100644 --- a/src/utmp.c +++ b/src/utmp.c @@ -79,18 +79,14 @@ fill_utmp (UTMPX *utmp, int type, const char *user, const char *id, pid_t pid, const char *line) { -#if defined HAVE_STRUCT_UTMP_UT_HOST - struct utsname uts; -#endif -#if defined HAVE_STRUCT_UTMP_UT_TV - struct timeval tv; -#endif - memset (utmp, 0, sizeof (*utmp)); #if defined(HAVE_STRUCT_UTMP_UT_TV) || defined(HAVE_STRUCT_UTMPX_UT_TV) - gettimeofday (&tv, 0); - utmp->ut_tv.tv_sec = tv.tv_sec; - utmp->ut_tv.tv_usec = tv.tv_usec; + { + struct timeval tv; + gettimeofday (&tv, 0); + utmp->ut_tv.tv_sec = tv.tv_sec; + utmp->ut_tv.tv_usec = tv.tv_usec; + } #elif defined(HAVE_STRUCT_UTMP_UT_TIME) || defined(HAVE_STRUCT_UTMPX_UT_TIME) time (&utmp->ut_time); #endif @@ -100,8 +96,11 @@ fill_utmp (UTMPX *utmp, utmp->ut_pid = pid; strncpy (utmp->ut_line, line, sizeof(utmp->ut_line)); #if defined(HAVE_STRUCT_UTMP_UT_HOST) || defined(HAVE_STRUCT_UTMPX_UT_HOST) - if (uname (&uts) == 0) - strncpy (utmp->ut_host, uts.release, sizeof(utmp->ut_host)); + { + struct utsname uts; + if (uname (&uts) == 0) + strncpy (utmp->ut_host, uts.release, sizeof(utmp->ut_host)); + } #endif } -- cgit v1.2.1