Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions cf-agent/verify_files_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,14 @@ static PromiseResult VerifyCopy(EvalContext *ctx,
return PROMISE_RESULT_FAIL;
}

Log(LOG_LEVEL_INFO, "ENT-13508: After stat of '%s': st_size = %jd, sizeof(struct stat) = %zu, sizeof(off_t) = %zu",
source, (intmax_t) ssb.st_size, sizeof(struct stat), sizeof(off_t));

unsigned char *stat_size_bytes = (unsigned char *)&ssb.st_size;
Log(LOG_LEVEL_INFO, "ENT-13508: Raw bytes of ssb.st_size after stat: %02x %02x %02x %02x %02x %02x %02x %02x",
stat_size_bytes[0], stat_size_bytes[1], stat_size_bytes[2], stat_size_bytes[3],
stat_size_bytes[4], stat_size_bytes[5], stat_size_bytes[6], stat_size_bytes[7]);

PromiseResult result = PROMISE_RESULT_NOOP;
if (ssb.st_nlink > 1) /* Preserve hard link structure when copying */
{
Expand Down Expand Up @@ -1803,6 +1811,14 @@ bool CopyRegularFile(EvalContext *ctx, const char *source, const char *dest, con
return false;
}

Log(LOG_LEVEL_INFO, "ENT-13508: Comparing sizes: new_stat.st_size = %jd, sstat->st_size = %jd, &sstat = %p, &sstat->st_size = %p",
(intmax_t) new_stat.st_size, (intmax_t) sstat->st_size, (void*)sstat, (void*)&sstat->st_size);

unsigned char *size_bytes = (unsigned char *)&sstat->st_size;
Log(LOG_LEVEL_INFO, "ENT-13508: Raw bytes of sstat->st_size (sizeof=%zu): %02x %02x %02x %02x %02x %02x %02x %02x",
sizeof(sstat->st_size), size_bytes[0], size_bytes[1], size_bytes[2], size_bytes[3],
size_bytes[4], size_bytes[5], size_bytes[6], size_bytes[7]);

if ((S_ISREG(new_stat.st_mode)) && (new_stat.st_size != sstat->st_size))
{
RecordFailure(ctx, pp, attr,
Expand Down
10 changes: 7 additions & 3 deletions cf-serverd/server_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -857,19 +857,23 @@ int StatFile(ServerConnectionState *conn, char *sendbuffer, char *ofilename)

/* send as plain text */

Log(LOG_LEVEL_DEBUG, "OK: type = %d, mode = %jo, lmode = %jo, "
Log(LOG_LEVEL_INFO, "ENT-13508: statbuf.st_size = %jd, cfst.cf_size = %jd",
(intmax_t) statbuf.st_size, (intmax_t) cfst.cf_size);

Log(LOG_LEVEL_INFO, "OK: type = %d, mode = %jo, lmode = %jo, "
"uid = %ju, gid = %ju, size = %jd, atime=%jd, mtime = %jd",
cfst.cf_type, (uintmax_t) cfst.cf_mode, (uintmax_t) cfst.cf_lmode,
(uintmax_t) cfst.cf_uid, (uintmax_t) cfst.cf_gid, (intmax_t) cfst.cf_size,
(intmax_t) cfst.cf_atime, (intmax_t) cfst.cf_mtime);

snprintf(sendbuffer, CF_MSGSIZE,
"OK: %d %ju %ju %ju %ju %jd %jd %jd %jd %d %d %d %jd",
"OK: %d %ju %ju %ju %ju %jd %jd %jd %jd %jd %jd %jd %jd",
cfst.cf_type, (uintmax_t) cfst.cf_mode, (uintmax_t) cfst.cf_lmode,
(uintmax_t) cfst.cf_uid, (uintmax_t) cfst.cf_gid, (intmax_t) cfst.cf_size,
(intmax_t) cfst.cf_atime, (intmax_t) cfst.cf_mtime, (intmax_t) cfst.cf_ctime,
cfst.cf_makeholes, cfst.cf_ino, cfst.cf_nlink, (intmax_t) cfst.cf_dev);
(intmax_t) cfst.cf_makeholes, (intmax_t) cfst.cf_ino, (intmax_t) cfst.cf_nlink, (intmax_t) cfst.cf_dev);

Log(LOG_LEVEL_INFO, "ENT-13508: sendbuffer = '%s'", sendbuffer);
SendTransaction(conn->conn_info, sendbuffer, 0, CF_DONE);

memset(sendbuffer, 0, CF_MSGSIZE);
Expand Down
9 changes: 9 additions & 0 deletions libcfnet/stat_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <logging.h> /* Log */
#include <crypto.h> /* EncryptString */
#include <misc_lib.h> /* ProgrammingError */
#include <stdint.h>

static void NewStatCache(Stat *data, AgentConnection *conn)
{
Expand Down Expand Up @@ -226,6 +227,8 @@ int cf_remote_stat(AgentConnection *conn, bool encrypt, const char *file,

Stat cfst;

Log(LOG_LEVEL_INFO, "ENT-13508: Received STAT response: '%s'", recvbuffer);

ret = StatParseResponse(recvbuffer, &cfst);
if (!ret)
{
Expand All @@ -234,6 +237,8 @@ int cf_remote_stat(AgentConnection *conn, bool encrypt, const char *file,
return -1;
}

Log(LOG_LEVEL_INFO, "ENT-13508: Parsed cf_size = %jd", (intmax_t) cfst.cf_size);

// If remote path is symbolic link, receive actual path here
int recv_len = ReceiveTransaction(conn->conn_info, recvbuffer, NULL);
if (recv_len == -1)
Expand Down Expand Up @@ -358,6 +363,8 @@ bool StatParseResponse(const char *const buf, Stat *const statbuf)
assert(buf != NULL);
assert(statbuf != NULL);

Log(LOG_LEVEL_INFO, "%s", buf);

// use intmax_t here to provide enough space for large values coming over the protocol
intmax_t d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12 = 0, d13 = 0;
int res = sscanf(buf, "OK:"
Expand Down Expand Up @@ -402,5 +409,7 @@ bool StatParseResponse(const char *const buf, Stat *const statbuf)
statbuf->cf_nlink = d12;
statbuf->cf_dev = (dev_t)d13;

Log(LOG_LEVEL_INFO, "ENT-13508: Size of file %jd", (intmax_t) statbuf->cf_size);

return true;
}
3 changes: 2 additions & 1 deletion tests/acceptance/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ endif
# Keep the '+' in front for the command, needed for the sub-make
# to run in parallel; TODO fix "make -n" not working:
check-local:
+ $(TESTS_ENVIRONMENT) MAKE=$(MAKE) $(srcdir)/testall
chmod 600 $(srcdir)/00_basics/03_bodies/114.cf $(srcdir)/default.cf.sub $(srcdir)/dcs.cf.sub $(srcdir)/plucked.cf.sub
$(srcdir)/testall --verbose --printlog $(srcdir)/00_basics/03_bodies/114.cf


EXTRA_DIST = default.cf.sub dcs.cf.sub plucked.cf.sub run_with_server.cf.sub \
Expand Down
4 changes: 0 additions & 4 deletions tests/load/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ EXTRA_DIST = \
run_db_load.sh \
run_lastseen_threaded_load.sh

TESTS = \
run_db_load.sh \
run_lastseen_threaded_load.sh

check_PROGRAMS = db_load lastseen_load lastseen_threaded_load


Expand Down
157 changes: 1 addition & 156 deletions tests/unit/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -86,108 +86,9 @@ libdb_la_LIBADD = ../../libntech/libutils/libutils.la
libdb_la_CFLAGS = $(AM_CFLAGS)

check_PROGRAMS = \
processes_select_test \
arg_split_test \
assoc_test \
getopt_test \
item_test \
rlist_test \
domainname_test \
set_domainname_test \
evalfunction_test \
eval_context_test \
regex_test \
lastseen_test \
lastseen_migration_test \
changes_migration_test \
db_test \
db_concurrent_test \
item_lib_test \
crypto_symmetric_test \
persistent_lock_test \
package_versions_compare_test \
files_lib_test \
files_copy_test \
parsemode_test \
parser_test \
passopenfile_test \
policy_test \
sort_test \
file_name_test \
logging_test \
granules_test \
scope_test \
conversion_test \
files_interfaces_test \
connection_management_test \
expand_test \
string_expressions_test \
var_expressions_test \
process_terminate_unix_test \
process_test \
exec-config-test \
generic_agent_test \
syntax_test \
sysinfo_test \
variable_test \
verify_databases_test \
protocol_test \
mon_cpu_test \
mon_load_test \
mon_processes_test \
mustache_test \
class_test \
key_test \
cf_upgrade_test \
matching_test \
strlist_test \
addr_lib_test \
policy_server_test \
split_process_line_test \
new_packages_promise_test \
iteration_test

if HAVE_AVAHI_CLIENT
if HAVE_AVAHI_COMMON
check_PROGRAMS += \
findhub_test \
avahi_config_test
endif
endif

if !NT
check_PROGRAMS += redirection_test
noinst_PROGRAMS = redirection_test_stub

redirection_test_stub_SOURCES = redirection_test_stub.c
endif

check_SCRIPTS = dynamic_dependency_test.sh \
tar_portability_test.sh

if WITH_INIT_D_SCRIPT
check_SCRIPTS += init_script_test.sh
endif

EXTRA_DIST += $(check_SCRIPTS)

TESTS = $(check_PROGRAMS) $(check_SCRIPTS)

if MACOSX
XFAIL_TESTS = set_domainname_test
XFAIL_TESTS += process_test
XFAIL_TESTS += mon_processes_test
XFAIL_TESTS += rlist_test
endif

if AIX
XFAIL_TESTS = rlist_test
endif

if HPUX
XFAIL_TESTS = mon_load_test # Redmine #3569
endif

TESTS = $(check_PROGRAMS)

processes_select_test_SOURCES = processes_select_test.c
processes_select_test_LDADD = libtest.la ../../libpromises/libpromises.la
Expand All @@ -199,17 +100,6 @@ TESTS_ENVIRONMENT = DYLD_FORCE_FLAT_NAMESPACE=yes

conversion_test_SOURCES = conversion_test.c ../../libpromises/conversion.c

if !BUILTIN_EXTENSIONS
check_PROGRAMS += enterprise_extension_test

enterprise_extension_test_SOURCES = enterprise_extension_test.c

check_LTLIBRARIES += cfengine-enterprise.la
cfengine_enterprise_la_SOURCES = enterprise_extension_test_lib.c
cfengine_enterprise_la_LDFLAGS = $(AM_LDFLAGS) \
-avoid-version -module -shared -export-dynamic -rpath /
EXTRA_enterprise_extension_test_DEPENDENCIES = cfengine-enterprise.la
endif

set_domainname_test_SOURCES = set_domainname_test.c
set_domainname_test_LDADD = libtest.la ../../libpromises/libpromises.la
Expand Down Expand Up @@ -306,44 +196,8 @@ rlist_test_CPPFLAGS = $(AM_CPPFLAGS)

process_test_LDADD = libtest.la ../../libpromises/libpromises.la

if LINUX

check_PROGRAMS += linux_process_test

linux_process_test_SOURCES = linux_process_test.c \
../../libpromises/process_unix.c \
../../libpromises/process_linux.c \
../../libntech/libutils/file_lib.c
linux_process_test_LDADD = libtest.la ../../libntech/libutils/libutils.la

endif

if AIX

check_PROGRAMS += aix_process_test
# We need to use -Wl,-bexpall when linking tests binaries on AIX
# because they provide dummy versions of some standard functions.
set_domainname_test_LDFLAGS = -Wl,-bexpall
evalfunction_test_LDFLAGS = -Wl,-bexpall
aix_process_test_SOURCES = aix_process_test.c \
../../libpromises/process_unix.c \
../../libpromises/process_aix.c \
../../libntech/libutils/file_lib.c
aix_process_test_LDADD = libtest.la ../../libntech/libutils/libutils.la

endif

if SOLARIS

check_PROGRAMS += solaris_process_test

solaris_process_test_SOURCES = solaris_process_test.c \
../../libpromises/process_unix.c \
../../libpromises/process_solaris.c \
../../libntech/libutils/file_lib.c
solaris_process_test_LDADD = libtest.la ../../libntech/libutils/libutils.la

endif

process_terminate_unix_test_SOURCES = process_terminate_unix_test.c \
../../libpromises/process_unix.c
Expand Down Expand Up @@ -399,14 +253,5 @@ cf_upgrade_test_SOURCES = cf_upgrade_test.c \
cf_upgrade_test_CPPFLAGS = -I$(top_srcdir)/cf-upgrade -I$(top_srcdir)/libntech/libutils -I$(top_srcdir)
cf_upgrade_test_LDADD = libtest.la ../../libntech/libcompat/libcompat.la

if !NT
check_PROGRAMS += nfs_test
nfs_test_SOURCES = nfs_test.c
nfs_test_LDADD = ../../libpromises/libpromises.la libtest.la

init_script_test_helper_SOURCES = init_script_test_helper.c
init_script_test.sh: init_script_test_helper
CLEANFILES += init_script_test_helper
endif
EXTRA_DIST += init_script_test_helper.c
EXTRA_DIST += init_script_test.sh
Loading