Fix compilation on systems w/o setlocale()
This commit is contained in:
@@ -35,8 +35,6 @@
|
|||||||
|
|
||||||
#include "sudoers.h"
|
#include "sudoers.h"
|
||||||
|
|
||||||
#ifdef HAVE_SETLOCALE
|
|
||||||
|
|
||||||
static int current_locale = SUDOERS_LOCALE_USER;
|
static int current_locale = SUDOERS_LOCALE_USER;
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -45,7 +43,14 @@ sudoers_getlocale(void)
|
|||||||
return current_locale;
|
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)
|
sudoers_setlocale(int newlocale, int *prevlocale)
|
||||||
{
|
{
|
||||||
char *res = NULL;
|
char *res = NULL;
|
||||||
@@ -75,12 +80,21 @@ sudoers_setlocale(int newlocale, int *prevlocale)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return res ? 1 : 0;
|
return res ? true : false;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
int
|
bool
|
||||||
sudoers_setlocale(int newlocale, int *prevlocale)
|
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 */
|
#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>
|
* Todd C. Miller <Todd.Miller@courtesan.com>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
@@ -58,6 +58,8 @@
|
|||||||
*/
|
*/
|
||||||
#define LOG_INDENT " "
|
#define LOG_INDENT " "
|
||||||
|
|
||||||
|
bool sudoers_setlocale(int newlocale, int *prevlocale);
|
||||||
|
int sudoers_getlocale(void);
|
||||||
void audit_success(char *exec_args[]);
|
void audit_success(char *exec_args[]);
|
||||||
void audit_failure(char *exec_args[], char const *const fmt, ...);
|
void audit_failure(char *exec_args[], char const *const fmt, ...);
|
||||||
void log_allowed(int status);
|
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_error(int flags, const char *fmt, ...) __printflike(2, 3);
|
||||||
void log_fatal(int flags, const char *fmt, ...) __printflike(2, 3) __attribute__((__noreturn__));
|
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);
|
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 */
|
#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>
|
* Todd C. Miller <Todd.Miller@courtesan.com>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
Reference in New Issue
Block a user