Clean up build and lintian warnings (#328)

* Added wrapper macros to suppress compiler warnings about unused return
  values of setres*id() functions. We don't need checks at that point
  as it does't affect our program.
* Added marco in configure.ac script to overwrite default AR_FLAGS,which
  were causing build warnings.
* Removed debian/watch file as is not needed anymore, because now this
  is native Debian package.
This commit is contained in:
KLuka 2015-07-27 19:32:28 +02:00
parent 8ac3a4efcf
commit 7cc877cdd8
4 changed files with 14 additions and 9 deletions

View file

@ -25,6 +25,9 @@ AC_C_CONST
AC_PROG_GCC_TRADITIONAL AC_PROG_GCC_TRADITIONAL
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])
dnl Overwrite default archiver flags.
AC_SUBST(AR_FLAGS, [cr])
dnl Check for header files that do not exist on all platforms dnl Check for header files that do not exist on all platforms
AC_CHECK_HEADERS([libutil.h pthread.h pty.h strings.h sys/prctl.h sys/uio.h \ AC_CHECK_HEADERS([libutil.h pthread.h pty.h strings.h sys/prctl.h sys/uio.h \
util.h utmp.h utmpx.h]) util.h utmp.h utmpx.h])

2
debian/watch vendored
View file

@ -1,2 +0,0 @@
version=3
https://github.com/shellinabox/shellinabox/tags .*/v?(\d\S*)\.tar\.gz

View file

@ -128,6 +128,8 @@ typedef struct pam_handle pam_handle_t;
#define UNUSED(x) do { (void)(x); } while (0) #define UNUSED(x) do { (void)(x); } while (0)
#endif #endif
#define UNUSED_RETURN(x) do { (void)((x)+1); } while (0)
#undef pthread_once #undef pthread_once
#undef execle #undef execle
int execle(const char *, const char *, ...); int execle(const char *, const char *, ...);
@ -668,8 +670,8 @@ void destroyUtmp(struct Utmp *utmp) {
uid_t r_gid, e_gid, s_gid; uid_t r_gid, e_gid, s_gid;
check(!getresuid(&r_uid, &e_uid, &s_uid)); check(!getresuid(&r_uid, &e_uid, &s_uid));
check(!getresgid(&r_gid, &e_gid, &s_gid)); check(!getresgid(&r_gid, &e_gid, &s_gid));
setresuid(0, 0, 0); UNUSED_RETURN(setresuid(0, 0, 0));
setresgid(0, 0, 0); UNUSED_RETURN(setresgid(0, 0, 0));
setutxent(); setutxent();
pututxline(&utmp->utmpx); pututxline(&utmp->utmpx);
@ -1543,9 +1545,10 @@ static void childProcess(struct Service *service, int width, int height,
cfsetospeed(&tt, B38400); cfsetospeed(&tt, B38400);
tcsetattr(0, TCSAFLUSH, &tt); tcsetattr(0, TCSAFLUSH, &tt);
// Assert root privileges in order to update utmp entry. // Assert root privileges in order to update utmp entry. We can only do that,
setresuid(0, 0, 0); // if we have root permissions otherwise this fails.
setresgid(0, 0, 0); UNUSED_RETURN(setresuid(0, 0, 0));
UNUSED_RETURN(setresgid(0, 0, 0));
#ifdef HAVE_UTMPX_H #ifdef HAVE_UTMPX_H
setutxent(); setutxent();
struct utmpx utmpx = utmp->utmpx; struct utmpx utmpx = utmp->utmpx;

View file

@ -59,10 +59,11 @@
#include "shellinabox/privileges.h" #include "shellinabox/privileges.h"
#include "logging/logging.h" #include "logging/logging.h"
#define UNUSED_RETURN(x) do { (void)((x)+1); } while (0)
int runAsUser = -1; int runAsUser = -1;
int runAsGroup = -1; int runAsGroup = -1;
#ifndef HAVE_GETRESUID #ifndef HAVE_GETRESUID
int getresuid(uid_t *ruid, uid_t *euid, uid_t *suid) { int getresuid(uid_t *ruid, uid_t *euid, uid_t *suid) {
*ruid = getuid(); *ruid = getuid();
@ -136,7 +137,7 @@ void lowerPrivileges(void) {
// Temporarily lower user privileges. If we used to have "root" privileges, // Temporarily lower user privileges. If we used to have "root" privileges,
// we can later still regain them. // we can later still regain them.
setresuid(-1, -1, 0); UNUSED_RETURN(setresuid(-1, -1, 0));
if (runAsUser >= 0) { if (runAsUser >= 0) {
// Try to switch to the user-provided user id. // Try to switch to the user-provided user id.