summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am8
-rw-r--r--src/tests/files-tests.c13
-rw-r--r--src/tools/sssctl/sssctl_data.c3
-rw-r--r--src/tools/sssctl/sssctl_logs.c3
-rw-r--r--src/tools/tools_util.c5
-rw-r--r--src/tools/tools_util.h17
-rw-r--r--src/util/files.c (renamed from src/tools/files.c)22
-rw-r--r--src/util/selinux.c (renamed from src/tools/selinux.c)0
-rw-r--r--src/util/util.h19
9 files changed, 44 insertions, 46 deletions
diff --git a/Makefile.am b/Makefile.am
index 161db1980..c292c1317 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -583,8 +583,6 @@ SSSD_RESPONDER_OBJ = \
SSSD_TOOLS_OBJ = \
src/tools/sss_sync_ops.c \
src/tools/tools_util.c \
- src/tools/files.c \
- src/tools/selinux.c \
src/tools/common/sss_tools.c \
src/tools/common/sss_process.c \
src/confdb/confdb_setup.c \
@@ -1052,6 +1050,8 @@ libsss_util_la_SOURCES = \
src/util/become_user.c \
src/util/util_watchdog.c \
src/util/sss_ptr_hash.c \
+ src/util/files.c \
+ src/util/selinux.c \
$(NULL)
libsss_util_la_CFLAGS = \
$(AM_CFLAGS) \
@@ -2016,8 +2016,8 @@ files_tests_SOURCES = \
src/tests/files-tests.c \
src/util/check_and_open.c \
src/util/atomic_io.c \
- src/tools/selinux.c \
- src/tools/files.c
+ src/util/selinux.c \
+ src/util/files.c
files_tests_CFLAGS = \
$(AM_CFLAGS) \
$(CHECK_CFLAGS)
diff --git a/src/tests/files-tests.c b/src/tests/files-tests.c
index e96a60af1..9feb9274a 100644
--- a/src/tests/files-tests.c
+++ b/src/tests/files-tests.c
@@ -32,7 +32,6 @@
#include <popt.h>
#include "config.h"
-#include "tools/tools_util.h"
#include "util/util.h"
#include "tests/common.h"
@@ -144,7 +143,7 @@ START_TEST(test_remove_tree)
fail_if(ret == -1, "Cannot chdir\n");
/* and finally wipe it out.. */
- ret = remove_tree(dir_path);
+ ret = sss_remove_tree(dir_path);
fail_unless(ret == EOK, "remove_tree failed\n");
/* check if really gone */
@@ -193,7 +192,7 @@ START_TEST(test_remove_subtree)
fail_if(ret == -1, "Cannot chdir\n");
/* and finally wipe it out.. */
- ret = remove_subtree(dir_path);
+ ret = sss_remove_subtree(dir_path);
fail_unless(ret == EOK, "remove_subtree failed\n");
/* check if really gone */
@@ -240,7 +239,7 @@ START_TEST(test_simple_copy)
/* and finally copy.. */
DEBUG(SSSDBG_FUNC_DATA,
"Will copy from '%s' to '%s'\n", dir_path, dst_path);
- ret = copy_tree(dir_path, dst_path, 0700, uid, gid);
+ ret = sss_copy_tree(dir_path, dst_path, 0700, uid, gid);
fail_unless(ret == EOK, "copy_tree failed\n");
/* check if really copied */
@@ -284,7 +283,7 @@ START_TEST(test_copy_file)
/* Copy this file to a new file */
DEBUG(SSSDBG_FUNC_DATA,
"Will copy from 'foo' to 'bar'\n");
- ret = copy_file_secure(foo_path, bar_path, 0700, uid, gid, 0);
+ ret = sss_copy_file_secure(foo_path, bar_path, 0700, uid, gid, 0);
fail_unless(ret == EOK, "copy_file_secure failed\n");
/* check if really copied */
@@ -326,7 +325,7 @@ START_TEST(test_copy_symlink)
/* and finally copy.. */
DEBUG(SSSDBG_FUNC_DATA,
"Will copy from '%s' to '%s'\n", dir_path, dst_path);
- ret = copy_tree(dir_path, dst_path, 0700, uid, gid);
+ ret = sss_copy_tree(dir_path, dst_path, 0700, uid, gid);
fail_unless(ret == EOK, "copy_tree failed\n");
/* check if really copied */
@@ -365,7 +364,7 @@ START_TEST(test_copy_node)
/* and finally copy.. */
DEBUG(SSSDBG_FUNC_DATA,
"Will copy from '%s' to '%s'\n", dir_path, dst_path);
- ret = copy_tree(dir_path, dst_path, 0700, uid, gid);
+ ret = sss_copy_tree(dir_path, dst_path, 0700, uid, gid);
fail_unless(ret == EOK, "copy_tree failed\n");
/* check if really copied and without special files */
diff --git a/src/tools/sssctl/sssctl_data.c b/src/tools/sssctl/sssctl_data.c
index 29c5e6760..860c5df55 100644
--- a/src/tools/sssctl/sssctl_data.c
+++ b/src/tools/sssctl/sssctl_data.c
@@ -23,7 +23,6 @@
#include "util/util.h"
#include "db/sysdb.h"
-#include "tools/common/sss_tools.h"
#include "tools/common/sss_process.h"
#include "tools/sssctl/sssctl.h"
#include "tools/tools_util.h"
@@ -241,7 +240,7 @@ errno_t sssctl_cache_remove(struct sss_cmdline *cmdline,
}
printf(_("Removing cache files...\n"));
- ret = remove_subtree(DB_PATH);
+ ret = sss_remove_subtree(DB_PATH);
if (ret != EOK) {
fprintf(stderr, _("Unable to remove cache files\n"));
return ret;
diff --git a/src/tools/sssctl/sssctl_logs.c b/src/tools/sssctl/sssctl_logs.c
index 1aea54e36..472a553d1 100644
--- a/src/tools/sssctl/sssctl_logs.c
+++ b/src/tools/sssctl/sssctl_logs.c
@@ -23,7 +23,6 @@
#include <signal.h>
#include "util/util.h"
-#include "tools/common/sss_tools.h"
#include "tools/common/sss_process.h"
#include "tools/sssctl/sssctl.h"
#include "tools/tools_util.h"
@@ -57,7 +56,7 @@ errno_t sssctl_logs_remove(struct sss_cmdline *cmdline,
if (opts.delete) {
printf(_("Deleting log files...\n"));
- ret = remove_subtree(LOG_PATH);
+ ret = sss_remove_subtree(LOG_PATH);
if (ret != EOK) {
fprintf(stderr, _("Unable to remove log files\n"));
return ret;
diff --git a/src/tools/tools_util.c b/src/tools/tools_util.c
index 5e51a4089..87a17491d 100644
--- a/src/tools/tools_util.c
+++ b/src/tools/tools_util.c
@@ -33,7 +33,6 @@
#include "util/util.h"
#include "confdb/confdb.h"
#include "db/sysdb.h"
-#include "tools/tools_util.h"
#include "tools/sss_sync_ops.h"
static int setup_db(struct tools_ctx *ctx)
@@ -414,7 +413,7 @@ int remove_homedir(TALLOC_CTX *mem_ctx,
}
/* Remove the tree */
- ret = remove_tree(homedir);
+ ret = sss_remove_tree(homedir);
if (ret != EOK) {
DEBUG(SSSDBG_CRIT_FAILURE, "Cannot remove homedir %s: %d\n",
homedir, ret);
@@ -502,7 +501,7 @@ int create_homedir(const char *skeldir,
selinux_file_context(homedir);
- ret = copy_tree(skeldir, homedir, 0777 & ~default_umask, uid, gid);
+ ret = sss_copy_tree(skeldir, homedir, 0777 & ~default_umask, uid, gid);
if (ret != EOK) {
DEBUG(SSSDBG_CRIT_FAILURE,
"Cannot populate user's home directory: [%d][%s].\n",
diff --git a/src/tools/tools_util.h b/src/tools/tools_util.h
index 389c7b5c4..fcfd8a659 100644
--- a/src/tools/tools_util.h
+++ b/src/tools/tools_util.h
@@ -111,21 +111,4 @@ errno_t sss_mc_refresh_group(const char *groupname);
errno_t sss_mc_refresh_grouplist(struct tools_ctx *tctx,
char **groupnames);
-/* from files.c */
-int remove_tree(const char *root);
-int remove_subtree(const char *root);
-
-int copy_tree(const char *src_root, const char *dst_root,
- mode_t mode_root, uid_t uid, gid_t gid);
-int
-copy_file_secure(const char *src,
- const char *dest,
- mode_t mode,
- uid_t uid, gid_t gid,
- bool force);
-
-/* from selinux.c */
-int selinux_file_context(const char *dst_name);
-int reset_selinux_file_context(void);
-
#endif /* __TOOLS_UTIL_H__ */
diff --git a/src/tools/files.c b/src/util/files.c
index 9f4e7caa7..5827b29d8 100644
--- a/src/tools/files.c
+++ b/src/util/files.c
@@ -65,7 +65,6 @@
#include <talloc.h>
#include "util/util.h"
-#include "tools/tools_util.h"
struct copy_ctx {
const char *src_orig;
@@ -140,7 +139,7 @@ static int remove_tree_with_ctx(TALLOC_CTX *mem_ctx,
dev_t parent_dev,
bool keep_root_dir);
-int remove_tree(const char *root)
+int sss_remove_tree(const char *root)
{
TALLOC_CTX *tmp_ctx = NULL;
int ret;
@@ -155,7 +154,7 @@ int remove_tree(const char *root)
return ret;
}
-int remove_subtree(const char *root)
+int sss_remove_subtree(const char *root)
{
TALLOC_CTX *tmp_ctx = NULL;
int ret;
@@ -489,11 +488,11 @@ done:
}
int
-copy_file_secure(const char *src,
- const char *dest,
- mode_t mode,
- uid_t uid, gid_t gid,
- bool force)
+sss_copy_file_secure(const char *src,
+ const char *dest,
+ mode_t mode,
+ uid_t uid, gid_t gid,
+ bool force)
{
int ifd = -1;
int ofd = -1;
@@ -761,8 +760,10 @@ done:
* For several reasons, including the fact that we copy even special files
* (pipes, etc) from the skeleton directory, the skeldir needs to be trusted
*/
-int copy_tree(const char *src_root, const char *dst_root,
- mode_t mode_root, uid_t uid, gid_t gid)
+int sss_copy_tree(const char *src_root,
+ const char *dst_root,
+ mode_t mode_root,
+ uid_t uid, gid_t gid)
{
int ret = EOK;
struct copy_ctx *cctx = NULL;
@@ -806,4 +807,3 @@ fail:
talloc_free(cctx);
return ret;
}
-
diff --git a/src/tools/selinux.c b/src/util/selinux.c
index 5e9c458f9..5e9c458f9 100644
--- a/src/tools/selinux.c
+++ b/src/util/selinux.c
diff --git a/src/util/util.h b/src/util/util.h
index 9b64dead8..80411ec91 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -681,4 +681,23 @@ int sss_unique_filename(TALLOC_CTX *owner, char *path_tmpl);
int setup_watchdog(struct tevent_context *ev, int interval);
void teardown_watchdog(void);
+/* from files.c */
+int sss_remove_tree(const char *root);
+int sss_remove_subtree(const char *root);
+
+int sss_copy_tree(const char *src_root,
+ const char *dst_root,
+ mode_t mode_root,
+ uid_t uid, gid_t gid);
+
+int sss_copy_file_secure(const char *src,
+ const char *dest,
+ mode_t mode,
+ uid_t uid, gid_t gid,
+ bool force);
+
+/* from selinux.c */
+int selinux_file_context(const char *dst_name);
+int reset_selinux_file_context(void);
+
#endif /* __SSSD_UTIL_H__ */