Fix compilation on systems w/o setlocale()
This commit is contained in:
@@ -35,8 +35,6 @@
|
||||
|
||||
#include "sudoers.h"
|
||||
|
||||
#ifdef HAVE_SETLOCALE
|
||||
|
||||
static int current_locale = SUDOERS_LOCALE_USER;
|
||||
|
||||
int
|
||||
@@ -45,7 +43,14 @@ sudoers_getlocale(void)
|
||||
return current_locale;
|
||||
}
|
||||
|
||||
int
|
||||
/*
|
||||
* Set locale to user or sudoers value.
|
||||
* Returns true on success and false on failure,
|
||||
* If prevlocale is non-NULL it will be filled in with the
|
||||
* old SUDOERS_LOCALE_* value.
|
||||
*/
|
||||
#ifdef HAVE_SETLOCALE
|
||||
bool
|
||||
sudoers_setlocale(int newlocale, int *prevlocale)
|
||||
{
|
||||
char *res = NULL;
|
||||
@@ -75,12 +80,21 @@ sudoers_setlocale(int newlocale, int *prevlocale)
|
||||
}
|
||||
break;
|
||||
}
|
||||
return res ? 1 : 0;
|
||||
return res ? true : false;
|
||||
}
|
||||
#else
|
||||
int
|
||||
bool
|
||||
sudoers_setlocale(int newlocale, int *prevlocale)
|
||||
{
|
||||
return 1;
|
||||
switch (newlocale) {
|
||||
case SUDOERS_LOCALE_USER:
|
||||
case SUDOERS_LOCALE_SUDOERS:
|
||||
if (prevlocale)
|
||||
*prevlocale = current_locale;
|
||||
current_locale = newlocale;
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_SETLOCALE */
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999-2005, 2009-2010
|
||||
* Copyright (c) 1999-2005, 2009-2012
|
||||
* Todd C. Miller <Todd.Miller@courtesan.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
@@ -58,6 +58,8 @@
|
||||
*/
|
||||
#define LOG_INDENT " "
|
||||
|
||||
bool sudoers_setlocale(int newlocale, int *prevlocale);
|
||||
int sudoers_getlocale(void);
|
||||
void audit_success(char *exec_args[]);
|
||||
void audit_failure(char *exec_args[], char const *const fmt, ...);
|
||||
void log_allowed(int status);
|
||||
@@ -67,7 +69,5 @@ void log_failure(int status, int flags);
|
||||
void log_error(int flags, const char *fmt, ...) __printflike(2, 3);
|
||||
void log_fatal(int flags, const char *fmt, ...) __printflike(2, 3) __attribute__((__noreturn__));
|
||||
void writeln_wrap(FILE *fp, char *line, size_t len, size_t maxlen);
|
||||
int sudoers_setlocale(int newlocale, int *prevlocale);
|
||||
int sudoers_getlocale(void);
|
||||
|
||||
#endif /* _LOGGING_H */
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1993-1996, 1998-2005, 2007-2011
|
||||
* Copyright (c) 1993-1996, 1998-2005, 2007-2012
|
||||
* Todd C. Miller <Todd.Miller@courtesan.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
|
Reference in New Issue
Block a user