From e1fdffdf9e94dee7de479c155188b80fd41dbcc8 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Fri, 3 Jul 2009 14:34:47 +0200 Subject: Check for root before initializing Also move setting locale to separate function to be called before anything else to make sure the "Not root" message would be localized. --- server/tools/tools_util.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'server/tools/tools_util.h') diff --git a/server/tools/tools_util.h b/server/tools/tools_util.h index 7c66c119d..0520731ad 100644 --- a/server/tools/tools_util.h +++ b/server/tools/tools_util.h @@ -22,6 +22,16 @@ } \ } while(0) +#define CHECK_ROOT(val, prg_name) do { \ + val = getuid(); \ + if (val != 0) { \ + DEBUG(1, ("Running under %d, must be root\n", val)); \ + ERROR("%s must be run as root\n", prg_name); \ + val = EXIT_FAILURE; \ + goto fini; \ + } \ +} while(0) + enum id_domain { ID_IN_LOCAL = 0, ID_IN_LEGACY_LOCAL, @@ -50,4 +60,6 @@ enum id_domain find_domain_for_id(struct tools_ctx *ctx, uint32_t id, struct sss_domain_info **dom_ret); +int set_locale(void); + #endif /* __TOOLS_UTIL_H__ */ -- cgit