summaryrefslogtreecommitdiffstats
path: root/server/tools/tools_util.c
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2009-07-03 14:34:47 +0200
committerSimo Sorce <ssorce@redhat.com>2009-07-06 13:02:29 -0400
commite1fdffdf9e94dee7de479c155188b80fd41dbcc8 (patch)
tree59e266c1a5cfc879f2badb983e0a8bc4ed74033c /server/tools/tools_util.c
parentbc1352717c7354005b4e6f70b6a51ed6b5146796 (diff)
downloadsssd_unused-e1fdffdf9e94dee7de479c155188b80fd41dbcc8.tar.gz
sssd_unused-e1fdffdf9e94dee7de479c155188b80fd41dbcc8.tar.xz
sssd_unused-e1fdffdf9e94dee7de479c155188b80fd41dbcc8.zip
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.
Diffstat (limited to 'server/tools/tools_util.c')
-rw-r--r--server/tools/tools_util.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/server/tools/tools_util.c b/server/tools/tools_util.c
index d15a1a78..0d3220ee 100644
--- a/server/tools/tools_util.c
+++ b/server/tools/tools_util.c
@@ -22,6 +22,7 @@
#include <talloc.h>
#include <tevent.h>
#include <popt.h>
+#include <errno.h>
#include "util/util.h"
#include "confdb/confdb.h"
@@ -228,13 +229,33 @@ int parse_groups(TALLOC_CTX *mem_ctx, const char *optstr, char ***_out)
return EOK;
}
+int set_locale(void)
+{
+ char *c;
+
+ c = setlocale(LC_ALL, "");
+ if (c == NULL) {
+ return EIO;
+ }
+
+ errno = 0;
+ c = bindtextdomain(PACKAGE, LOCALEDIR);
+ if (c == NULL) {
+ return errno;
+ }
+
+ errno = 0;
+ c = textdomain(PACKAGE);
+ if (c == NULL) {
+ return errno;
+ }
+
+ return EOK;
+}
+
int init_sss_tools(struct tools_ctx **ctx)
{
int ret;
- /* Set up LOCALE */
- setlocale (LC_ALL, "");
- bindtextdomain (PACKAGE, LOCALEDIR);
- textdomain (PACKAGE);
/* Connect to the database */
ret = setup_db(ctx);
@@ -248,3 +269,4 @@ int init_sss_tools(struct tools_ctx **ctx)
fini:
return ret;
}
+