From 5dbc17461d4ed68044ead7d9706db643ed4f2596 Mon Sep 17 00:00:00 2001 From: Peter Silva Date: Thu, 18 Jul 2024 15:50:42 -0400 Subject: [PATCH 01/16] add KNOWN_REDIRECTION_BUG as work-around for redhat 8 --- shim_copy_post.sh | 34 +++++++++++++++++++++++++--------- shim_post.sh | 20 +++++++++++++++----- 2 files changed, 40 insertions(+), 14 deletions(-) diff --git a/shim_copy_post.sh b/shim_copy_post.sh index 36e41e7..98d1051 100755 --- a/shim_copy_post.sh +++ b/shim_copy_post.sh @@ -5,8 +5,8 @@ cd shim_dirA which bash echo "FIXME: KNOWN ISSUE redirection close does not get posted!" -echo "#test 1 sha512 000 capturing stdout" -bash -c 'echo "hoho" >> ./hoho' +#echo "#test 1 sha512 000 capturing stdout" +#bash -c 'echo "hoho" >> ./hoho' echo "#test 0 comment 010 shim copy posting start" echo "#test 1 sha512 c program run." @@ -57,11 +57,21 @@ mkdir dirone echo "#test 1 link 110 symlink to directory" ln -s dirone link_to_dirone -echo "#test 1 sha512 120 stdout redirection in a subdir" -echo "fileone" >>link_to_dirone/fileone - -echo "#test 1 sha512 120 2nd stdout redirection in a subdir" -echo "lovely" >>link_to_dirone/filefive +if [ "${KNOWN_REDIRECTION_BUG}" ]; then + echo "#test 1 sha512 120 cp replaces redirection in a subdir" + cp hoho link_to_dirone/fileone +else + echo "#test 1 sha512 120 stdout redirection in a subdir" + echo "fileone" >>link_to_dirone/fileone +fi + +if [ "${KNOWN_REDIRECTION_BUG}" ]; then + echo "#test 1 sha512 120 cp replaces 2nd stdout redirection in a subdir" + cp hoho link_to_dirone/filefive +else + echo "#test 1 sha512 120 2nd stdout redirection in a subdir" + echo "lovely" >>link_to_dirone/filefive +fi echo "#test 1 directory 130 mkdir 2" mkdir dirone/dirtwo @@ -69,8 +79,13 @@ mkdir dirone/dirtwo echo "#test 1,1 link,rename 135 symlink in a sub-dir" ln -sf `pwd`/link_to_dirone/fileone dirone/link_to_fileone -echo "#test 1 sha512 140 stdout redirection in a subsubdir" -echo "filetwo" >>dirone/dirtwo/filetwo +if [ "${KNOWN_REDIRECTION_BUG}" ]; then + echo "#test 1 sha512 140 cp replaces redirection in a subsubdir" + cp hoho dirone/dirtwo/filetwo +else + echo "#test 1 sha512 140 stdout redirection in a subsubdir" + echo "filetwo" >>dirone/dirtwo/filetwo +fi echo "#test 1 rename 145 rename in a sub-dir" mv dirone/dirtwo/filetwo dirone/dirtwo/filefour @@ -90,6 +105,7 @@ touch test_file echo "#test 1 rename move test_file into dirthree subdir" mv test_file dirthree + echo "#test 1 sha512 create test_file (again)" echo 2 >test_file echo "#no post from touch, refused as repeat" diff --git a/shim_post.sh b/shim_post.sh index 1319d50..d5d253e 100755 --- a/shim_post.sh +++ b/shim_post.sh @@ -115,18 +115,28 @@ rm ~/test/hoho2.log echo "#test 1 directory 150 make second directory ." mkdir dirone -echo "#test 1 sha512 160 stdout redirection in a subdir" -echo "fileone" >>dirone/fileone +if [ "${KNOWN_REDIRECTION_BUG}" ]; then + echo "#test 1 sha512 160 cp to avoid stdout redirection in a subdir" + cp hoho dirone/fileone +else + echo "#test 1 sha512 160 stdout redirection in a subdir" + echo "fileone" >>dirone/fileone +fi echo "#test 1 directory 170 make third directory." mkdir dirone/dirtwo -echo "#test 1 sha512 180 stdout redirection in a subsubdir" -echo "filetwo" >>dirone/dirtwo/filetwo +if [ "${KNOWN_REDIRECTION_BUG}" ]; then + echo "#test 1 sha512 180 cp to avoid stdout redirection in a subsubdir" + cp hoho dirone/dirtwo/filetwo +else + echo "#test 1 sha512 180 stdout redirection in a subsubdir" + echo "filetwo" >>dirone/dirtwo/filetwo +fi echo "#test 1 rename 190 renaming subdirs should cause file rename events." mv dirone dirthree -echo "#test 2 remove 200 removing a whole tree events." +echo "#test 4 remove 200 removing a whole tree events." rm -rf dirthree echo "#test 2 remove 210 removing two files" rm hoho hoohoo From e3d8cf7ae11b8715309b657f0c9582c65e659b83 Mon Sep 17 00:00:00 2001 From: Peter Silva Date: Thu, 18 Jul 2024 16:12:56 -0400 Subject: [PATCH 02/16] missed one redirect --- shim_copy_post.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/shim_copy_post.sh b/shim_copy_post.sh index 98d1051..f3a8291 100755 --- a/shim_copy_post.sh +++ b/shim_copy_post.sh @@ -98,8 +98,13 @@ mv dirone dirthree echo "#test 1 link 135 symlink in a sub-dir" ln -sf `pwd`/dirthree/dirtwo/filefour dirthree/dirtwo/link2four -echo "#test 1 sha512 create test_file" -echo 1 >test_file +if [ "${KNOWN_REDIRECTION_BUG}" ]; then + echo "#test 1 sha512 create test_file" + cp hoho test_file +else + echo "#test 1 sha512 create test_file with redirection" + echo 1 >test_file +fi echo "#test 1 sha512 update test_file" touch test_file From 39de34b6932ddd1c4b166457cfff2d74b2481e74 Mon Sep 17 00:00:00 2001 From: Peter Silva Date: Fri, 19 Jul 2024 13:04:25 -0400 Subject: [PATCH 03/16] adding CFLAGS reminder for redhat8 package building --- RELEASE.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/RELEASE.rst b/RELEASE.rst index 6b966a9..56d81bb 100644 --- a/RELEASE.rst +++ b/RELEASE.rst @@ -124,6 +124,9 @@ To note changes: examine results, which include a valgrind run. - install package so that it is used for flow tests on at least one platform. - find redhat8 (with local disk) and run make test_shim + + - on redhat8 edit: Makefile to add -DINTERCEPT_SYSCALL to CFLAGS. + - find ubuntu18 (with local disk) and run make test_shim. - dch, and touch up your points if need be. - when ready to release, edit UNRELEASED to an appropriate status, usually unstable. @@ -137,6 +140,7 @@ To note changes: - go to an hpc account (on an intel node) * mkdir ~/Sarracenia; cd ~/Sarracenia * git clone https://github.com/MetPX/sarrac metpx-sr3c + * edit Makefile to add -DINTERCEPT_SYSCALL to CFLAGS. * cd metpx-sr3c * make rpm_rhel7 - go to a hpc account on a powerpc node From 7428a8373a4783a90f1eb54a30bee4da059eeb8c Mon Sep 17 00:00:00 2001 From: Peter Silva Date: Fri, 19 Jul 2024 18:43:47 -0400 Subject: [PATCH 04/16] finished implementing KNOWN_REDIRECTION_BUG, but it does not work --- libsr3shim.c | 2 +- shim_copy_post.sh | 17 +++++++++++------ shim_copy_post2.sh | 45 +++++++++++++++++++++++++++++++++++---------- 3 files changed, 47 insertions(+), 17 deletions(-) diff --git a/libsr3shim.c b/libsr3shim.c index 4f4bee8..ab24bcf 100644 --- a/libsr3shim.c +++ b/libsr3shim.c @@ -504,7 +504,7 @@ void srshim_realpost(const char *path) return; } if (sr_c->cfg->shim_defer_posting_to_exit) { - sr_shimdebug_msg(1, "srshim_realpost post deferred to exist ... %s\n", fn); + sr_shimdebug_msg(1, "srshim_realpost post deferred to exit ... %s\n", fn); return; } diff --git a/shim_copy_post.sh b/shim_copy_post.sh index f3a8291..636f67e 100755 --- a/shim_copy_post.sh +++ b/shim_copy_post.sh @@ -99,20 +99,25 @@ echo "#test 1 link 135 symlink in a sub-dir" ln -sf `pwd`/dirthree/dirtwo/filefour dirthree/dirtwo/link2four if [ "${KNOWN_REDIRECTION_BUG}" ]; then - echo "#test 1 sha512 create test_file" + echo "#test 1 sha512 141 create test_file" cp hoho test_file else - echo "#test 1 sha512 create test_file with redirection" + echo "#test 1 sha512 142 create test_file with redirection" echo 1 >test_file fi -echo "#test 1 sha512 update test_file" +echo "#test 1 sha512 151 update test_file" touch test_file -echo "#test 1 rename move test_file into dirthree subdir" +echo "#test 1 rename 152 move test_file into dirthree subdir" mv test_file dirthree -echo "#test 1 sha512 create test_file (again)" -echo 2 >test_file +if [ "${KNOWN_REDIRECTION_BUG}" ]; then + echo "#test 1 sha512 161 create test_file (again)" + cp dirthree/test_file >test_file +else + echo "#test 1 sha512 162 create test_file (again)" + echo 2 >test_file +fi echo "#no post from touch, refused as repeat" touch test_file echo "#test 1 rename move test_file into dirthree subdir (new name)" diff --git a/shim_copy_post2.sh b/shim_copy_post2.sh index f6cffa4..b5aa2e5 100755 --- a/shim_copy_post2.sh +++ b/shim_copy_post2.sh @@ -5,8 +5,14 @@ cd shim_dirA which bash echo "FIXME: KNOWN ISSUE redirection close does not get posted!" -echo "#test 1 sha512 000 capturing stdout" -bash -c 'echo "hoho" >> ./hoho' + +if [ "${KNOWN_REDIRECTION_BUG}" ]; then + echo "#test 1 sha512 000 work-around for capturing stdout" + cp ../pyiotest ./hoho +else + echo "#test 1 sha512 000 capturing stdout" + bash -c 'echo "hoho" >> ./hoho' +fi echo "#test 0 comment 010 shim copy posting start" echo "#test 1 sha512 c program run." @@ -57,11 +63,20 @@ mkdir dirone echo "#test 1 link 110 symlink to directory" ln -s dirone link_to_dirone -echo "#test 1 sha512 120 stdout redirection in a subdir" -echo "fileone" >>link_to_dirone/fileone +if [ "${KNOWN_REDIRECTION_BUG}" ]; then + echo "#test 1 sha512 120 workaround copy for stdout redirection in a subdir" + cp hoho link_to_dirone/fileone + + echo "#test 1 sha512 120 workaround copy for 2nd stdout redirection in a subdir" + cp hoho link_to_dirone/filefive +else + echo "#test 1 sha512 120 stdout redirection in a subdir" + echo "fileone" >>link_to_dirone/fileone + + echo "#test 1 sha512 120 2nd stdout redirection in a subdir" + echo "lovely" >>link_to_dirone/filefive +fi -echo "#test 1 sha512 120 2nd stdout redirection in a subdir" -echo "lovely" >>link_to_dirone/filefive echo "#test 1 directory 130 mkdir 2" mkdir dirone/dirtwo @@ -83,15 +98,25 @@ mv dirone dirthree echo "#test 1 link 135 symlink in a sub-dir" ln -sf `pwd`/dirthree/dirtwo/filefour dirthree/dirtwo/link2four -echo "#test 1 sha512 create test_file" -echo 1 >test_file +if [ "${KNOWN_REDIRECTION_BUG}" ]; then + echo "#test 1 sha512 workaround cp for create test_file with redirection" + cp ../pyiotest test_file +else + echo "#test 1 sha512 create test_file with redirection." + echo 1 >test_file +fi echo "#test 1 sha512 update test_file" touch test_file echo "#test 1 rename move test_file into dirthree subdir" mv test_file dirthree -echo "#test 1 sha512 create test_file (again)" -echo 2 >test_file +if [ "${KNOWN_REDIRECTION_BUG}" ]; then + echo "#test 1 sha512 workaround cp for create test_file in (again) from redirection" + cp ../pyiotest test_file +else + echo "#test 1 sha512 create test_file (again) from redirection" + echo 2 >test_file +fi echo "#no post from touch, refused as repeat" touch test_file echo "#test 1 rename move test_file into dirthree subdir (new name)" From f93c81c7517a7e124b1c5c9b98219e99e96d49ee Mon Sep 17 00:00:00 2001 From: Peter Silva Date: Mon, 22 Jul 2024 21:12:23 -0400 Subject: [PATCH 05/16] versioning LD_PRELOAD for shim tests --- shim_post.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/shim_post.sh b/shim_post.sh index d5d253e..0fd2697 100755 --- a/shim_post.sh +++ b/shim_post.sh @@ -1,4 +1,6 @@ +VERSION=`head -1 debian/changelog| sed 's/.*(//' | sed 's/).*//'` +MAJOR_VERSION=`echo \"${VERSION}\" | sed 's+\..*++g'` if [ ! "${SR_POST_CONFIG}" ]; then if [ ! -d ~/test ]; then @@ -55,9 +57,9 @@ EOT export SR_POST_CONFIG=local_post.conf if [ "${SYSTEM_SHIM_TEST}" ]; then - export LD_PRELOAD=libsr3shim.so.1.0.0 + export LD_PRELOAD=libsr3shim.so.${VERSION} else - export LD_PRELOAD=`pwd`/libsr3shim.so.1.0.0 + export LD_PRELOAD=`pwd`/libsr3shim.so.${VERSION} export LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} fi export SR_SHIMDEBUG=99 From 6ffe7f758d1d5e91d33fa4b7d0253b2612c95fcd Mon Sep 17 00:00:00 2001 From: Peter Silva Date: Wed, 24 Jul 2024 13:11:24 -0400 Subject: [PATCH 06/16] substantially improving build/install instructions --- BUILD.rst | 353 +++++++++++++++++++++++++++++++++++++++++++++++++++++ README.rst | 137 +-------------------- 2 files changed, 356 insertions(+), 134 deletions(-) create mode 100644 BUILD.rst diff --git a/BUILD.rst b/BUILD.rst new file mode 100644 index 0000000..f6fc0ef --- /dev/null +++ b/BUILD.rst @@ -0,0 +1,353 @@ + +---------------------------------------- +Building Sarracenia C Client from Source +---------------------------------------- + +The metpx-sr3c package is an AMQP C client for creating and consuming Sarracenia messages +implemented in C. It is written in the C programming language and thus requires a normal +C development environment (gcc, make) as well as some C libraries and helpers indicated +below. Valgrind is also used during development to test memory management. + +Source Code Documentation +------------------------- + +Partial implementation of Doxygen docs. +to view:: + + sudo apt install doxygen + sudo apt install graphviz + doxygen + +and run, and it will create the browseable docs/html/ subdirectory +with some documentation. Although only a few files out of the total +have been properly annoted so far, doxygen is configured to extract +as much information from the code as possible. (We have some pretty +call/caller graphs now!) + + +Build Dependencies +------------------ + +The librabbitmq version needs to be > 0.8, this is newer than what is in +ubuntu 16.04. So you need to git clone from https://github.com/alanxz/rabbitmq-c +then built it there. The launchpad PPA has a backport included to take care of +this:: + + export RABBIT_BUILD=*directory where rabbit has been built* + + +librabbitmq-dev - AMQP client library written in C - Dev Files +libssl-dev - OpenSSL client library (used for hash algorithms.) +libjson-c-dev - json-c header files. + +run dependencies:: + + librabbitmq4 - AMQP client library written in C + libssl - OpenSSL client library. + libjson-c3 - JSON manupulation library (for v03 parsing) + +On RPM-based distributions:: + + librabbitmq-devel + json-c-devel + +This JSON library changed API multiple times in it's history. Sarrac development +platform is ubuntu 18.04, where the libjson-c3 library is provided. Older linux +versions may have incompatible library versions and may not build or run correctly. +The Makefile includes the -DHAVE_JSONC option in CFLAGS. Removing this option +disables v03 message parsing, but makes it possible to build on such systems. +v03 posting will still work (dependency only required to receive messages.) + +BUILD +----- + +To build binaries for local testing, there is a Makefile that automates dependencies. +to do a local build, invoke the *make* command:: + + [sarra@edcm-dirt-rhel8-1 metpx-sr3c]$ make + echo "#define __sarra_version__ \"`head -1 debian/changelog| sed 's/.*(//' | sed 's/).*//'`\"" >sr_version.h + gcc -DINTERCEPT_SYSCALL -DHAVE_JSONC -DSR_APPNAME=\"sr3\" -DFORCE_LIBC_REGEX=\"/lib64/libc.so.6\" -fPIC -ftest-coverage -std=gnu99 -Wall -g -D_GNU_SOURCE -c sr_post.c + gcc -DINTERCEPT_SYSCALL -DHAVE_JSONC -DSR_APPNAME=\"sr3\" -DFORCE_LIBC_REGEX=\"/lib64/libc.so.6\" -fPIC -ftest-coverage -std=gnu99 -Wall -g -D_GNU_SOURCE -c sr_consume.c + gcc -DINTERCEPT_SYSCALL -DHAVE_JSONC -DSR_APPNAME=\"sr3\" -DFORCE_LIBC_REGEX=\"/lib64/libc.so.6\" -fPIC -ftest-coverage -std=gnu99 -Wall -g -D_GNU_SOURCE -c sr_context.c + gcc -DINTERCEPT_SYSCALL -DHAVE_JSONC -DSR_APPNAME=\"sr3\" -DFORCE_LIBC_REGEX=\"/lib64/libc.so.6\" -fPIC -ftest-coverage -std=gnu99 -Wall -g -D_GNU_SOURCE -c sr_config.c + gcc -DINTERCEPT_SYSCALL -DHAVE_JSONC -DSR_APPNAME=\"sr3\" -DFORCE_LIBC_REGEX=\"/lib64/libc.so.6\" -fPIC -ftest-coverage -std=gnu99 -Wall -g -D_GNU_SOURCE -c sr_event.c + gcc -DINTERCEPT_SYSCALL -DHAVE_JSONC -DSR_APPNAME=\"sr3\" -DFORCE_LIBC_REGEX=\"/lib64/libc.so.6\" -fPIC -ftest-coverage -std=gnu99 -Wall -g -D_GNU_SOURCE -c sr_credentials.c + gcc -DINTERCEPT_SYSCALL -DHAVE_JSONC -DSR_APPNAME=\"sr3\" -DFORCE_LIBC_REGEX=\"/lib64/libc.so.6\" -fPIC -ftest-coverage -std=gnu99 -Wall -g -D_GNU_SOURCE -c sr_cache.c + gcc -DINTERCEPT_SYSCALL -DHAVE_JSONC -DSR_APPNAME=\"sr3\" -DFORCE_LIBC_REGEX=\"/lib64/libc.so.6\" -fPIC -ftest-coverage -std=gnu99 -Wall -g -D_GNU_SOURCE -c sr_util.c + gcc -DINTERCEPT_SYSCALL -DHAVE_JSONC -DSR_APPNAME=\"sr3\" -DFORCE_LIBC_REGEX=\"/lib64/libc.so.6\" -fPIC -ftest-coverage -std=gnu99 -Wall -g -D_GNU_SOURCE -shared -Wl,-soname,libsr3c.so.1 -o libsr3c.so.1.0.0 sr_post.o sr_consume.o sr_context.o sr_config.o sr_event.o sr_credentials.o sr_cache.o sr_util.o -ldl -ljson-c -lrabbitmq -lcrypto -lc + gcc -DINTERCEPT_SYSCALL -DHAVE_JSONC -DSR_APPNAME=\"sr3\" -DFORCE_LIBC_REGEX=\"/lib64/libc.so.6\" -fPIC -ftest-coverage -std=gnu99 -Wall -g -D_GNU_SOURCE -shared -Wl,-soname,libsr3shim.so.1 -o libsr3shim.so.1.0.0 libsr3shim.c libsr3c.so.1.0.0 -ldl '-Wl,-rpath,$ORIGIN/../lib' -L/home/sarra/metpx-sr3c -ljson-c -lrabbitmq -lcrypto -lc + if [ ! -f libsr3c.so ]; \ + then \ + ln -s libsr3c.so.1.0.0 libsr3c.so ; \ + fi; + if [ ! -f libsr3c.so.1 ]; \ + then \ + ln -s libsr3c.so.1.0.0 libsr3c.so.1 ; \ + fi; + gcc -DINTERCEPT_SYSCALL -DHAVE_JSONC -DSR_APPNAME=\"sr3\" -DFORCE_LIBC_REGEX=\"/lib64/libc.so.6\" -fPIC -ftest-coverage -std=gnu99 -Wall -g -D_GNU_SOURCE -o sr_configtest sr_configtest.c -lsr3c '-Wl,-rpath,$ORIGIN/../lib' -L/home/sarra/metpx-sr3c -lrabbitmq -lcrypto + gcc -DINTERCEPT_SYSCALL -DHAVE_JSONC -DSR_APPNAME=\"sr3\" -DFORCE_LIBC_REGEX=\"/lib64/libc.so.6\" -fPIC -ftest-coverage -std=gnu99 -Wall -g -D_GNU_SOURCE -o sr_utiltest sr_utiltest.c -lsr3c '-Wl,-rpath,$ORIGIN/../lib' -L/home/sarra/metpx-sr3c -lrabbitmq -lcrypto + gcc -DINTERCEPT_SYSCALL -DHAVE_JSONC -DSR_APPNAME=\"sr3\" -DFORCE_LIBC_REGEX=\"/lib64/libc.so.6\" -fPIC -ftest-coverage -std=gnu99 -Wall -g -D_GNU_SOURCE -o sr_cachetest sr_cachetest.c -lsr3c '-Wl,-rpath,$ORIGIN/../lib' -L/home/sarra/metpx-sr3c -lrabbitmq -lcrypto + gcc -DINTERCEPT_SYSCALL -DHAVE_JSONC -DSR_APPNAME=\"sr3\" -DFORCE_LIBC_REGEX=\"/lib64/libc.so.6\" -fPIC -ftest-coverage -std=gnu99 -Wall -g -D_GNU_SOURCE -o sr3_cpost sr3_cpost.c -lsr3c '-Wl,-rpath,$ORIGIN/../lib' -L/home/sarra/metpx-sr3c -lrabbitmq -lcrypto + gcc -DINTERCEPT_SYSCALL -DHAVE_JSONC -DSR_APPNAME=\"sr3\" -DFORCE_LIBC_REGEX=\"/lib64/libc.so.6\" -fPIC -ftest-coverage -std=gnu99 -Wall -g -D_GNU_SOURCE -o sr3_cpump sr3_cpump.c -lsr3c '-Wl,-rpath,$ORIGIN/../lib' -L/home/sarra/metpx-sr3c -lrabbitmq -lcrypto + [sarra@edcm-dirt-rhel8-1 metpx-sr3c]$ + +Now the binaries ./sr3_cpost, and ./sr3_cpump, as well as the libsr3c.so and libsr3shim.so libraries are build in the current directory and can be tested. +There are other targets used to run sanity tests. + +To modify builds, edit the Makefile, and look for the line that begins with CFLAGS= +In the example above, for example, the -DINTERCEPT_SYSCALL flag has been added (appropriate for redhat 8) CFLAGS to adjust compilation. +Other flags of interest are below: + + + + +FORCE_LIBC_REGEX +~~~~~~~~~~~~~~~~ + +This option is set by default as it is usually desired. +If you see:: + + 2018-11-21 00:08:17,315 [ERROR] invalid regular expression: .*\/tmp\/.*. Ignored + +and the regex is valid... the symptom we had was that the library was +calling a version of the regular expresison routines included in a binary +(ksh93 in this case) instead of the ones in libc that were expected. +without this option being set, the shim library will compile and user +Korn Shell regular expression grammar instead of the libc/posix ones. +This is confusing in practice. + +Set the option:: + + -DFORCE_LIBC_REGEX=\"/lib/x86_64-linux-gnu/libc.so.6\" + +to the file containing the regcomp and regexec routines what are to be +used. The code uses dynamic library loading to force use of the specified +routines. Obviously this setting is architecture dependent and would +need adjustment if compiling on another platform, such as ARM or MIPS. + +SR_DEBUG_LOGS +~~~~~~~~~~~~~ + +To disable all log file support, so that diagnostics messages +are sent to standard error instead, include:: + + -DSR_DEBUG_LOGS=1 + + + + +Testing +-------- + +trust_but_verify +~~~~~~~~~~~~~~~~ + +ensure the c is compiled correctly, and the caching logic works:: + + make trust_but_verify + +It tests caching logic, and the timing is a little finicky, and timing +out of the last entry can sometimes cause failures. If that is all that is wrong, +just run the test again. + +It may not pass the first time through. Just try again. Once it has run through the +cache checks, it will run valgrind, and there should be no memory allocation problems. + + +shim_post +~~~~~~~~~ + +To run the next tests that validate the shim library, one must have a broker available +to post to and set BROKER appropriately. defaults are like below:: + + export BROKER=amqp://tfeed@localhost + +(assumes a local broker is configured and working using the python tools.) +Then can run the test:: + + make test_shim_post + +All tests should, ideally, succeed. on redhat8, they don't so we cannot proceed to the next +tests. On redhat8, there is a bug related to re-direction not working. so you need to +set KNOWN_REDIRECTION_BUG=y, and run the tests again:: + + [sarra@edcm-dirt-rhel8-1 metpx-sr3c]$ export KNOWN_REDIRECTION_BUG=y + [sarra@edcm-dirt-rhel8-1 metpx-sr3c]$ make test_shim_post + ./shim_post.sh >shim_post.log 2>&1 + #python3 ./check_shim_post.py shim_post.log exit_on_bad + python3 ./check_shim_test.py shim_post.log + RESULT: comment 000 shim test posting start + 2024-07-24 12:22:00,612 [INFO] shim published: { "pubTime":"20240724162200.6124081", "baseUrl":"file:/home/sarra", "relPath":"metpx-sr3c/hoho", "topic":"v03.post.metpx-sr3c", "identity":{ "method" : "sha512", "value" : "V/BeoaZp+hh0CbopUiR/1kckdUspp4oAnsDmhZhaIXVKb3gGPB5lrT62enDtl5lxQ/e+vO9GsuoRH1\nY+rlGhxQ==" } , "mtime":"20240724162200.60770176", "atime":"20240724162200.60670166", "mode":"0664", "size":"5", "toto":"pig"} + + RESULT: Good! 1 sha512 posts from 010 capturing stdout. as expected + 2024-07-24 12:22:00,619 [INFO] shim published: { "pubTime":"20240724162200.61952043", "baseUrl":"file:/home/sarra", "relPath":"metpx-sr3c/hoho", "topic":"v03.post.metpx-sr3c", "identity":{ "method" : "sha512", "value" : "oLy3C3cd4fYUxySoYWkojuncdJpsC7ud0PhjwrZlMdIbZbgb09PsTjRcL+pZAyobTz/lIxfaO/B1N0\n97aZsQqg==" } , "mtime":"20240724162200.61370234", "atime":"20240724162200.61070205", "mode":"0664", "size":"2", "toto":"pig"} + + RESULT: Good! 1 sha512 posts from 020 c program run.. as expected + 2024-07-24 12:22:00,637 [INFO] shim published: { "pubTime":"20240724162200.63695751", "baseUrl":"file:/home/sarra", "relPath":"metpx-sr3c/hoho", "topic":"v03.post.metpx-sr3c", "identity":{ "method" : "sha512", "value" : "m3HSJL1i83hdltRq0+o9czGb+8KJDKra4t/3JRlnPKcjI8PZm6XBHXx6zG4UuMXaDEZjR1wuXDre9G\n9zvN7AQw==" } , "mtime":"20240724162200.63270418", "atime":"20240724162200.61870282", "mode":"0664", "size":"5", "toto":"pig"} + + RESULT: Good! 1 sha512 posts from 030 python program run. as expected + 2024-07-24 12:22:00,647 [INFO] shim published: { "pubTime":"20240724162200.64737922", "baseUrl":"file:/home/sarra", "relPath":"metpx-sr3c/sub_dir1", "topic":"v03.post.metpx-sr3c", "mtime":"20240724162200.64270515", "atime":"20240724162200.64270515", "mode":"0775", "toto":"pig", "fileOp" : { "directory":""}} + + RESULT: Good! 1 directory posts from 040 make directory. as expected + 2024-07-24 12:22:00,653 [INFO] shim published: { "pubTime":"20240724162200.65374716", "baseUrl":"file:/home/sarra", "relPath":"metpx-sr3c/sub_dir2", "topic":"v03.post.metpx-sr3c", "mtime":"20240724162200.64270515", "atime":"20240724162200.64270515", "mode":"0775", "toto":"pig", "fileOp" : { "directory":"", "rename" : "sub_dir1" }} + + RESULT: Good! 1 rename posts from 050 rename directory. as expected + 2024-07-24 12:22:00,659 [INFO] shim published: { "pubTime":"20240724162200.65962601", "baseUrl":"file:/home/sarra", "relPath":"metpx-sr3c/sub_dir2", "topic":"v03.post.metpx-sr3c", "toto":"pig", "fileOp" : { "rmdir":""}} + + RESULT: Good! 1 rmdir posts from 060 remove directory. as expected + 2024-07-24 12:22:00,666 [INFO] shim published: { "pubTime":"20240724162200.66582152", "baseUrl":"file:/home/sarra", "relPath":"test/hoho_my_darling.txt", "topic":"v03.post.test", "identity":{ "method" : "sha512", "value" : "ZjDeqDLkEcT7j8fhfpiJIb6ledKyXWI0Ve5bctx6N4nRo+x5tNZFAPsAX/eJGefkvHUnw5Gh3fKNFF\ns7Yn254g==" } , "mtime":"20240724162200.6607069", "atime":"20240724162200.6607069", "mode":"0664", "size":"42273", "toto":"pig"} + + RESULT: Good! 1 sha512 posts from 070 cp command. as expected + 2024-07-24 12:22:00,672 [INFO] shim published: { "pubTime":"20240724162200.67182824", "baseUrl":"file:/home/sarra", "relPath":"metpx-sr3c/hihi", "topic":"v03.post.metpx-sr3c", "identity":{ "method" : "sha512", "value" : "z4PhNX7vuL3xVChQ1m2AB9Yg5AULVxXcg/SpIdNs6c5H0NE8XYXysP+DGNKHfuwvY7kxvUdBeoGlOD\nJ6+SfaPg==" } , "mtime":"20240724162200.66870767", "atime":"20240724162200.66870767", "mode":"0664", "size":"0", "toto":"pig"} + + RESULT: Good! 1 sha512 posts from 080 touch command. as expected + 2024-07-24 12:22:00,677 [INFO] shim published: { "pubTime":"20240724162200.67748101", "baseUrl":"file:/home/sarra", "relPath":"metpx-sr3c/haha", "topic":"v03.post.metpx-sr3c", "toto":"pig", "fileOp" : { "link":"hoho"}} + + RESULT: Good! 1 link posts from 090 symlink command. as expected + 2024-07-24 12:22:00,684 [INFO] shim published: { "pubTime":"20240724162200.68408558", "baseUrl":"file:/home/sarra", "relPath":"metpx-sr3c/hihi", "topic":"v03.post.metpx-sr3c", "toto":"pig", "fileOp" : { "link":"hoho", "rename" : "haha" }} + + RESULT: Good! 1 rename posts from 100 moving a symlink. as expected + 2024-07-24 12:22:00,690 [INFO] shim published: { "pubTime":"20240724162200.69031104", "baseUrl":"file:/home/sarra", "relPath":"metpx-sr3c/hoohoo", "topic":"v03.post.metpx-sr3c", "toto":"pig", "fileOp" : { "link":"hoho", "rename" : "hihi" }} + + RESULT: Good! 1 rename posts from 110 hardlink to a symlink. as expected + 2024-07-24 12:22:00,696 [INFO] shim published: { "pubTime":"20240724162200.69622963", "baseUrl":"file:/home/sarra", "relPath":"test/hoho2.log", "topic":"v03.post.test", "identity":{ "method" : "sha512", "value" : "ZjDeqDLkEcT7j8fhfpiJIb6ledKyXWI0Ve5bctx6N4nRo+x5tNZFAPsAX/eJGefkvHUnw5Gh3fKNFF\ns7Yn254g==" } , "mtime":"20240724162200.6607069", "atime":"20240724162200.66470728", "mode":"0664", "size":"42273", "toto":"pig", "fileOp": { "rename" : "/home/sarra/test/hoho_my_darling.txt" }} + + RESULT: Good! 1 rename posts from 120 moving a file.. as expected + 2024-07-24 12:22:00,702 [INFO] shim published: { "pubTime":"20240724162200.70214724", "baseUrl":"file:/home/sarra", "relPath":"metpx-sr3c/hihi", "topic":"v03.post.metpx-sr3c", "toto":"pig", "fileOp" : { "remove":""}} + + RESULT: Good! 1 remove posts from 130 removing a file.. as expected + 2024-07-24 12:22:00,708 [INFO] shim published: { "pubTime":"20240724162200.70795871", "baseUrl":"file:/home/sarra", "relPath":"test/hoho2.log", "topic":"v03.post.test", "toto":"pig", "fileOp" : { "remove":""}} + + RESULT: Good! 1 remove posts from 140 removing a file.. as expected + 2024-07-24 12:22:00,714 [INFO] shim published: { "pubTime":"20240724162200.71400629", "baseUrl":"file:/home/sarra", "relPath":"metpx-sr3c/dirone", "topic":"v03.post.metpx-sr3c", "mtime":"20240724162200.70971165", "atime":"20240724162200.70971165", "mode":"0775", "toto":"pig", "fileOp" : { "directory":""}} + + RESULT: Good! 1 directory posts from 150 make second directory .. as expected + 2024-07-24 12:22:00,720 [INFO] shim published: { "pubTime":"20240724162200.7206274", "baseUrl":"file:/home/sarra", "relPath":"metpx-sr3c/dirone/fileone", "topic":"v03.post.metpx-sr3c.dirone", "identity":{ "method" : "sha512", "value" : "m3HSJL1i83hdltRq0+o9czGb+8KJDKra4t/3JRlnPKcjI8PZm6XBHXx6zG4UuMXaDEZjR1wuXDre9G\n9zvN7AQw==" } , "mtime":"20240724162200.71571223", "atime":"20240724162200.71571223", "mode":"0664", "size":"5", "toto":"pig"} + + RESULT: Good! 1 sha512 posts from 160 cp to avoid stdout redirection in a subdir. as expected + 2024-07-24 12:22:00,726 [INFO] shim published: { "pubTime":"20240724162200.72676479", "baseUrl":"file:/home/sarra", "relPath":"metpx-sr3c/dirone/dirtwo", "topic":"v03.post.metpx-sr3c.dirone", "mtime":"20240724162200.72171281", "atime":"20240724162200.72171281", "mode":"0775", "toto":"pig", "fileOp" : { "directory":""}} + + RESULT: Good! 1 directory posts from 170 make third directory.. as expected + 2024-07-24 12:22:00,733 [INFO] shim published: { "pubTime":"20240724162200.73313262", "baseUrl":"file:/home/sarra", "relPath":"metpx-sr3c/dirone/dirtwo/filetwo", "topic":"v03.post.metpx-sr3c.dirone.dirtwo", "identity":{ "method" : "sha512", "value" : "m3HSJL1i83hdltRq0+o9czGb+8KJDKra4t/3JRlnPKcjI8PZm6XBHXx6zG4UuMXaDEZjR1wuXDre9G\n9zvN7AQw==" } , "mtime":"20240724162200.72871349", "atime":"20240724162200.72871349", "mode":"0664", "size":"5", "toto":"pig"} + + RESULT: Good! 1 sha512 posts from 180 cp to avoid stdout redirection in a subsubdir. as expected + 2024-07-24 12:22:00,739 [INFO] shim published: { "pubTime":"20240724162200.73938894", "baseUrl":"file:/home/sarra", "relPath":"metpx-sr3c/dirthree", "topic":"v03.post.metpx-sr3c", "mtime":"20240724162200.72171281", "atime":"20240724162200.70971165", "mode":"0775", "toto":"pig", "fileOp" : { "directory":"", "rename" : "dirone" }} + + RESULT: Good! 1 rename posts from 190 renaming subdirs should cause file rename events.. as expected + 2024-07-24 12:22:00,745 [INFO] shim published: { "pubTime":"20240724162200.74513463", "baseUrl":"file:/home/sarra", "relPath":"metpx-sr3c/dirthree/fileone", "topic":"v03.post.metpx-sr3c.dirthree", "toto":"pig", "fileOp" : { "remove":""}} + + 2024-07-24 12:22:00,745 [INFO] shim published: { "pubTime":"20240724162200.74544573", "baseUrl":"file:/home/sarra", "relPath":"metpx-sr3c/dirthree/dirtwo/filetwo", "topic":"v03.post.metpx-sr3c.dirthree.dirtwo", "toto":"pig", "fileOp" : { "remove":""}} + + 2024-07-24 12:22:00,745 [INFO] shim published: { "pubTime":"20240724162200.74571733", "baseUrl":"file:/home/sarra", "relPath":"metpx-sr3c/dirthree/dirtwo", "topic":"v03.post.metpx-sr3c.dirthree", "toto":"pig", "fileOp" : { "remove":""}} + + 2024-07-24 12:22:00,746 [INFO] shim published: { "pubTime":"20240724162200.74589953", "baseUrl":"file:/home/sarra", "relPath":"metpx-sr3c/dirthree", "topic":"v03.post.metpx-sr3c", "toto":"pig", "fileOp" : { "remove":""}} + + RESULT: Good! 4 remove posts from 200 removing a whole tree events.. as expected + 2024-07-24 12:22:00,751 [INFO] shim published: { "pubTime":"20240724162200.7514974", "baseUrl":"file:/home/sarra", "relPath":"metpx-sr3c/hoho", "topic":"v03.post.metpx-sr3c", "toto":"pig", "fileOp" : { "remove":""}} + + 2024-07-24 12:22:00,751 [INFO] shim published: { "pubTime":"20240724162200.75180644", "baseUrl":"file:/home/sarra", "relPath":"metpx-sr3c/hoohoo", "topic":"v03.post.metpx-sr3c", "toto":"pig", "fileOp" : { "remove":""}} + + RESULT: Good! 2 remove posts from 210 removing two files. as expected + RESULT: comment 220 shim test posting end + posts: {'sha512': 7, 'directory': 3, 'rename': 5, 'rmdir': 1, 'link': 1, 'remove': 8} + RESULT: summary: good: 21, bad 0, total 21 + [sarra@edcm-dirt-rhel8-1 metpx-sr3c]$ + + +IF that passes, then the next tests are:: + + make test_shim + +which will run test_shim_post again, and then mirror sub-directories of the local directory using many +different combinations of options. Project for future... get things to work on redhat without +the KNOW_REDIRECTION_BUG being set. + + +Build a Debian Package +---------------------- + +if on a debian derived OS, then assuming build dependencies are taken +care of:: + + debuild -uc -us + +will build a package you can install: + +* using the source code in the current directory. +* placing the .dpkg files in the parent directory. +* The current directory might need to be named metpx-sr3c (might only be a requirement for rpm builds... not sure.) + + +Build an RPM Package +-------------------- + +if on a redhat derived OS, then assuming build dependencies are taken +care of:: + + make rpm_rhel7 + + +Will run rpmbuild, and put the packages where that tool places them +(under ~/rpmbuild/RPMS ) + + +There is also a suse Makefile target. Has not be tested recently. +May or may not work. Left as a starting point for next person to try Suse. + + +Branches +-------- + +The main repository of sarrac is: https://github.com/MetPX/sarrac +As of 2022/12, development is on v3 compatible version of sarrac, now called metpx-sr3c. +The customer switched to sr3, so there is no need to continue with v2. +The existing git branches and their roles: + +* development ... the default development branch, launchpad.net daily packages built from here. +* pre-release ... v03 pre-release branch, tracks development punctually. launchpad.net pre-release packages built from here. +* stable ... v03 release branch, tracks pre-release punctually. launchpad.net stable packages built from here. +* v2 ... v2 development branch. (legacy) +* v2_stable ... v2 release branch, tracks v2 punctually. (legacy) +* issueXXX ... branch developed to address a particular issue. + + +Release Process +--------------- + +See `Releases `_ + +Proposed Coding Style Guidelines +-------------------------------- + +Generally, we used `Linux Kernel C Guidelines `_ + +but with one pythonic affectation: You know Rule 1? about the tabs with 8 characters? This code base is normally +indented like python instead, use four spaces, and not tabs. + +Also, in terms of documenting code, when adding new things one should add comments +keeping in mind compatbility with `doxygen `_ +Examples:: + + /** + * descriptive comment above a struct or function declaration. + */ + + /** + * sr_config_find_one() - find the name configuration file name + * \param sr_cfg: The configuration to be updated with the configuration found. + * \param original_one: The name provided by the user. + * + * Return pointer to the matching mask if there is one, NULL otherwise. + * The pointer to char will hold the absolute path of the config file corresponding to original_one + * + * Return: pointer to a static char buffer with a path name to the corresponding configuration file. + */ + + char foo; /**< description of foo class member */ + + +The code has a mix of comments is not entirely doxygen friendly just yet. Feel free +to improve. Other than that... the kernel C guidelines are the rule. + +FIXME: We ran a code reformatter on it once... should probably repeat from time to time, would be +useful to document which one was used. I believe it undoes for the pythonic exception. diff --git a/README.rst b/README.rst index e30524f..605e294 100644 --- a/README.rst +++ b/README.rst @@ -174,22 +174,6 @@ NOTE: The tests are disabled for now because the C consumer does lose messages. -Source Code Documentation -------------------------- - -Partial implementation of Doxygen docs. -to view:: - - sudo apt install doxygen - sudo apt install graphviz - doxygen - -and run, and it will create the browseable docs/html/ subdirectory -with some documentation. Although only a few files out of the total -have been properly annoted so far, doxygen is configured to extract -as much information from the code as possible. (We have some pretty -call/caller graphs now!) - Limitations of the C implementation ----------------------------------- @@ -205,74 +189,6 @@ Limitations of the C implementation - The C implementation uses the libc(7) regular expression routines, which are a little more limited than python ones. -Build Dependencies ------------------- - -The librabbitmq version needs to be > 0.8, this is newer than what is in -ubuntu 16.04. So you need to git clone from https://github.com/alanxz/rabbitmq-c -then built it there. The launchpad PPA has a backport included to take care of -this:: - - export RABBIT_BUILD=*directory where rabbit has been built* - - -librabbitmq-dev - AMQP client library written in C - Dev Files -libssl-dev - OpenSSL client library (used for hash algorithms.) -libjson-c-dev - json-c header files. - -run dependencies:: - - librabbitmq4 - AMQP client library written in C - libssl - OpenSSL client library. - libjson-c3 - JSON manupulation library (for v03 parsing) - -On RPM-based distributions:: - - librabbitmq-devel - json-c-devel - -This JSON library changed API multiple times in it's history. Sarrac development -platform is ubuntu 18.04, where the libjson-c3 library is provided. Older linux -versions may have incompatible library versions and may not build or run correctly. -The Makefile includes the -DHAVE_JSONC option in CFLAGS. Removing this option -disables v03 message parsing, but makes it possible to build on such systems. -v03 posting will still work (dependency only required to receive messages.) - -BUILD OPTIONS -------------- - -FORCE_LIBC_REGEX -~~~~~~~~~~~~~~~~ - -This option is set by default as it is usually desired. -If you see:: - - 2018-11-21 00:08:17,315 [ERROR] invalid regular expression: .*\/tmp\/.*. Ignored - -and the regex is valid... the symptom we had was that the library was -calling a version of the regular expresison routines included in a binary -(ksh93 in this case) instead of the ones in libc that were expected. -without this option being set, the shim library will compile and user -Korn Shell regular expression grammar instead of the libc/posix ones. -This is confusing in practice. - -Set the option:: - - -DFORCE_LIBC_REGEX=\"/lib/x86_64-linux-gnu/libc.so.6\" - -to the file containing the regcomp and regexec routines what are to be -used. The code uses dynamic library loading to force use of the specified -routines. Obviously this setting is architecture dependent and would -need adjustment if compiling on another platform, such as ARM or MIPS. - -SR_DEBUG_LOGS -~~~~~~~~~~~~~ - -To disable all log file support, so that diagnostics messages -are sent to standard error instead, include:: - - -DSR_DEBUG_LOGS=1 - Dorval Computing Centre ----------------------- @@ -289,60 +205,13 @@ To load sr3_cpost:: or it may be installed in the system locations (/usr/bin, etc...) +Build Process +------------- -Branches --------- - -The main repository of sarrac is: https://github.com/MetPX/sarrac -As of 2022/12, development is on v3 compatible version of sarrac, now called metpx-sr3c. -The customer switched to sr3, so there is no need to continue with v2. -The existing git branches and their roles: - -* development ... the default development branch, launchpad.net daily packages built from here. -* pre-release ... v03 pre-release branch, tracks development punctually. launchpad.net pre-release packages built from here. -* stable ... v03 release branch, tracks pre-release punctually. launchpad.net stable packages built from here. -* v2 ... v2 development branch. (legacy) -* v2_stable ... v2 release branch, tracks v2 punctually. (legacy) -* issueXXX ... branch developed to address a particular issue. +See `Building from Source `_ Release Process --------------- See `Releases `_ - -Proposed Coding Style Guidelines --------------------------------- - -Generally, we used `Linux Kernel C Guidelines `_ - -but with one pythonic affectation: You know Rule 1? about the tabs with 8 characters? This code base is normally -indented like python instead, use four spaces, and not tabs. - -Also, in terms of documenting code, when adding new things one should add comments -keeping in mind compatbility with `doxygen `_ -Examples:: - - /** - * descriptive comment above a struct or function declaration. - */ - - /** - * sr_config_find_one() - find the name configuration file name - * \param sr_cfg: The configuration to be updated with the configuration found. - * \param original_one: The name provided by the user. - * - * Return pointer to the matching mask if there is one, NULL otherwise. - * The pointer to char will hold the absolute path of the config file corresponding to original_one - * - * Return: pointer to a static char buffer with a path name to the corresponding configuration file. - */ - - char foo; /**< description of foo class member */ - - -The code has a mix of comments is not entirely doxygen friendly just yet. Feel free -to improve. Other than that... the kernel C guidelines are the rule. - -FIXME: We ran a code reformatter on it once... should probably repeat from time to time, would be -useful to document which one was used. I believe it undoes for the pythonic exception. From 6ba26fa718d3c27d64bea34f28e1398dee670d08 Mon Sep 17 00:00:00 2001 From: Peter Silva Date: Wed, 24 Jul 2024 13:11:56 -0400 Subject: [PATCH 07/16] adjusting shim_copy_post shell tests to pass on rh8 I thought only redirection in the login shell was a problem, but anyways completing implementation of the work-around for the redirection bug on redhat. --- shim_copy_post.sh | 9 +++++---- shim_copy_post2.sh | 13 +++++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/shim_copy_post.sh b/shim_copy_post.sh index 636f67e..a4e0f8e 100755 --- a/shim_copy_post.sh +++ b/shim_copy_post.sh @@ -99,7 +99,7 @@ echo "#test 1 link 135 symlink in a sub-dir" ln -sf `pwd`/dirthree/dirtwo/filefour dirthree/dirtwo/link2four if [ "${KNOWN_REDIRECTION_BUG}" ]; then - echo "#test 1 sha512 141 create test_file" + echo "#test 1 sha512 141 create test_file (without redirection)" cp hoho test_file else echo "#test 1 sha512 142 create test_file with redirection" @@ -113,13 +113,14 @@ mv test_file dirthree if [ "${KNOWN_REDIRECTION_BUG}" ]; then echo "#test 1 sha512 161 create test_file (again)" - cp dirthree/test_file >test_file + cp dirthree/test_file test_file else echo "#test 1 sha512 162 create test_file (again)" echo 2 >test_file + echo "#no post from touch, refused as repeat" + touch test_file fi -echo "#no post from touch, refused as repeat" -touch test_file + echo "#test 1 rename move test_file into dirthree subdir (new name)" mv test_file dirthree/new_test_file diff --git a/shim_copy_post2.sh b/shim_copy_post2.sh index b5aa2e5..0c9e653 100755 --- a/shim_copy_post2.sh +++ b/shim_copy_post2.sh @@ -84,8 +84,13 @@ mkdir dirone/dirtwo echo "#test 1,1 link,rename 135 symlink in a sub-dir" ln -sf `pwd`/link_to_dirone/fileone dirone/link_to_fileone -echo "#test 1 sha512 140 stdout redirection in a subsubdir" -echo "filetwo" >>dirone/dirtwo/filetwo +if [ "${KNOWN_REDIRECTION_BUG}" ]; then + echo "#test 1 sha512 140 creat file (work-around stdout redirection) in a subsubdir" + dd if=/dev/zero of=dirone/dirtwo/filetwo count=7 +else + echo "#test 1 sha512 140 stdout redirection in a subsubdir" + echo "filetwo" >>dirone/dirtwo/filetwo +fi echo "#test 1 rename 145 rename in a sub-dir" mv dirone/dirtwo/filetwo dirone/dirtwo/filefour @@ -116,9 +121,9 @@ if [ "${KNOWN_REDIRECTION_BUG}" ]; then else echo "#test 1 sha512 create test_file (again) from redirection" echo 2 >test_file + echo "#no post from touch, refused as repeat" + touch test_file fi -echo "#no post from touch, refused as repeat" -touch test_file echo "#test 1 rename move test_file into dirthree subdir (new name)" mv test_file dirthree/new_test_file From 6c83e4efc687b1629bcd14b7b8e00b06a0f678fe Mon Sep 17 00:00:00 2001 From: Peter Silva Date: Wed, 24 Jul 2024 13:28:32 -0400 Subject: [PATCH 08/16] intercept_syscall touch up. --- BUILD.rst | 11 ++++++++++- RELEASE.rst | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/BUILD.rst b/BUILD.rst index f6fc0ef..edf754c 100644 --- a/BUILD.rst +++ b/BUILD.rst @@ -282,7 +282,16 @@ Build an RPM Package -------------------- if on a redhat derived OS, then assuming build dependencies are taken -care of:: +care of. For redhat 8, add the INTERCEPT_SYSCALL symbol to CFLAGS in the +Makefile:: + + vi Makefile + /^CFLAGS= + a -DINTERCEPT_SYSCALL + :wq + + +For all Redhat versions:: make rpm_rhel7 diff --git a/RELEASE.rst b/RELEASE.rst index 56d81bb..fc375c5 100644 --- a/RELEASE.rst +++ b/RELEASE.rst @@ -125,7 +125,7 @@ To note changes: - install package so that it is used for flow tests on at least one platform. - find redhat8 (with local disk) and run make test_shim - - on redhat8 edit: Makefile to add -DINTERCEPT_SYSCALL to CFLAGS. + - on redhat8, edit Makefile to add -DINTERCEPT_SYSCALL to CFLAGS. - find ubuntu18 (with local disk) and run make test_shim. - dch, and touch up your points if need be. From 7ef04c809d4f5f5c7e7fc9bdbd71d4e5a1163264 Mon Sep 17 00:00:00 2001 From: Peter Silva Date: Wed, 24 Jul 2024 13:35:24 -0400 Subject: [PATCH 09/16] fix SR_DEBUG_LOGS being broken by addition of context to api signature --- Makefile | 2 +- sr_util.c | 4 +++- sr_util.h | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index fdbaf0d..42adbfc 100644 --- a/Makefile +++ b/Makefile @@ -43,7 +43,7 @@ LIBCLOCATION=$(shell ldd /bin/sh | awk '/libc\.so\./ { print; }' | cut -d' ' -f3 # On RHEL8, add -DINTERCEPT_SYSCALL to handle cases where mv calls syscall directly, instead of calling renameat2. # See sarrac issue #145 for more information about syscall/renameat2. -CFLAGS = -DHAVE_JSONC -DSR_APPNAME=\"sr3\" -DFORCE_LIBC_REGEX=\"$(LIBCLOCATION)\" -fPIC -ftest-coverage -std=gnu99 -Wall -g -D_GNU_SOURCE $(RABBIT_INCDIR) +CFLAGS = -DSR_DEBUG_LOGS -DHAVE_JSONC -DSR_APPNAME=\"sr3\" -DFORCE_LIBC_REGEX=\"$(LIBCLOCATION)\" -fPIC -ftest-coverage -std=gnu99 -Wall -g -D_GNU_SOURCE $(RABBIT_INCDIR) SARRA_HEADER = sr_cache.h sr_config.h sr_consume.h sr_context.h sr_credentials.h sr_event.h sr_post.h sr_util.h sr_version.h uthash.h SARRA_OBJECT = sr_post.o sr_consume.o sr_context.o sr_config.o sr_event.o sr_credentials.o sr_cache.o sr_util.o diff --git a/sr_util.c b/sr_util.c index fe61f15..4e91b32 100644 --- a/sr_util.c +++ b/sr_util.c @@ -174,8 +174,10 @@ struct sr_log_context_s* sr_log_setup(const char *fn, const char *mfn, bool logM ctx->mtab.i = 0; ctx->mtab.size = ctx->logrotate_count; } -#endif return(ctx); +#else + return; +#endif } /* global accessor for loglevel, ugly but better than using a global variable... */ diff --git a/sr_util.h b/sr_util.h index 34f8a71..6d28152 100644 --- a/sr_util.h +++ b/sr_util.h @@ -48,7 +48,7 @@ struct sr_log_context_s { // following macro allows compiler to find errors in sr_log_msg's variadic arguments. // it disables use of log files, redirecting it all to stderr. -#define sr_log_msg(prio, ... ) fprintf( stderr, __VA_ARGS__ ) +#define sr_log_msg(ctx, prio, ... ) fprintf( stderr, __VA_ARGS__ ) /* install libexplain, and libexplain-dev, and add -lexplain and you might get some messages. #include From c063aeda143f82804e04f7698c5d88b0e7d03fa0 Mon Sep 17 00:00:00 2001 From: Peter Silva Date: Wed, 24 Jul 2024 13:37:04 -0400 Subject: [PATCH 10/16] another patch for SR_DEBUG_LOGS --- sr_util.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sr_util.c b/sr_util.c index 4e91b32..162f08e 100644 --- a/sr_util.c +++ b/sr_util.c @@ -175,8 +175,6 @@ struct sr_log_context_s* sr_log_setup(const char *fn, const char *mfn, bool logM ctx->mtab.size = ctx->logrotate_count; } return(ctx); -#else - return; #endif } From 833ffb750524247be726a6e3a1731aeffc751887 Mon Sep 17 00:00:00 2001 From: Peter Silva Date: Wed, 24 Jul 2024 13:40:40 -0400 Subject: [PATCH 11/16] bugs in log messages found with -DSR_DEBUG_LOGS --- sr_consume.c | 5 ++--- sr_post.c | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/sr_consume.c b/sr_consume.c index 5f0d384..d3bf773 100644 --- a/sr_consume.c +++ b/sr_consume.c @@ -965,9 +965,8 @@ struct sr_message_s *sr_consume(struct sr_context *sr_c) assign_field(tag, value); sr_log_msg(sr_c->cfg->logctx,LOG_WARNING, - "skipping U64 header %d value:%ld\n", i, - (long long unsigned)(p->headers.entries[i].value. - value.u64)); + "skipping U64 header %d value:%lld\n", i, + (long long unsigned)(p->headers.entries[i].value.value.u64)); break; case AMQP_FIELD_KIND_ARRAY: diff --git a/sr_post.c b/sr_post.c index cea9758..a9c7324 100644 --- a/sr_post.c +++ b/sr_post.c @@ -587,8 +587,7 @@ void realpath_adjust(struct sr_log_context_s *logctx, const char *input_path, ch if (adjust == 0) { return_value = realpath(input_path, output_path); if (return_value) { - sr_log_msg(logctx,LOG_DEBUG, "%s realpath_adjust %d, %s -> %s \n", adjust, input_path, - output_path); + sr_log_msg(logctx,LOG_DEBUG, "realpath_adjust %d, %s -> %s \n", adjust, input_path, output_path); return; } // fallback to checking a directory for last path element. From 0a6b18d23825811e2ffcfc6d282320edefbe726a Mon Sep 17 00:00:00 2001 From: Peter Silva Date: Wed, 24 Jul 2024 13:41:08 -0400 Subject: [PATCH 12/16] erroneously made SR_DEBUG_LOGS a default CFLAG option --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 42adbfc..fdbaf0d 100644 --- a/Makefile +++ b/Makefile @@ -43,7 +43,7 @@ LIBCLOCATION=$(shell ldd /bin/sh | awk '/libc\.so\./ { print; }' | cut -d' ' -f3 # On RHEL8, add -DINTERCEPT_SYSCALL to handle cases where mv calls syscall directly, instead of calling renameat2. # See sarrac issue #145 for more information about syscall/renameat2. -CFLAGS = -DSR_DEBUG_LOGS -DHAVE_JSONC -DSR_APPNAME=\"sr3\" -DFORCE_LIBC_REGEX=\"$(LIBCLOCATION)\" -fPIC -ftest-coverage -std=gnu99 -Wall -g -D_GNU_SOURCE $(RABBIT_INCDIR) +CFLAGS = -DHAVE_JSONC -DSR_APPNAME=\"sr3\" -DFORCE_LIBC_REGEX=\"$(LIBCLOCATION)\" -fPIC -ftest-coverage -std=gnu99 -Wall -g -D_GNU_SOURCE $(RABBIT_INCDIR) SARRA_HEADER = sr_cache.h sr_config.h sr_consume.h sr_context.h sr_credentials.h sr_event.h sr_post.h sr_util.h sr_version.h uthash.h SARRA_OBJECT = sr_post.o sr_consume.o sr_context.o sr_config.o sr_event.o sr_credentials.o sr_cache.o sr_util.o From 95d19046bb4c9d824c17854b61fe31ce28f7a1f9 Mon Sep 17 00:00:00 2001 From: Peter Silva Date: Wed, 24 Jul 2024 14:16:26 -0400 Subject: [PATCH 13/16] update other shim tests to use correct library version --- shim_copy_baseDir.sh | 7 +++++-- shim_copy_flatten.sh | 7 +++++-- shim_copy_mirror.sh | 7 +++++-- shim_copy_mirror_sftp.sh | 7 +++++-- shim_copy_strip.sh | 7 +++++-- shim_copy_strip_slash.sh | 7 +++++-- 6 files changed, 30 insertions(+), 12 deletions(-) diff --git a/shim_copy_baseDir.sh b/shim_copy_baseDir.sh index 0e18616..a5f7969 100755 --- a/shim_copy_baseDir.sh +++ b/shim_copy_baseDir.sh @@ -1,4 +1,7 @@ +VERSION=`head -1 debian/changelog| sed 's/.*(//' | sed 's/).*//'` +MAJOR_VERSION=`echo \"${VERSION}\" | sed 's+\..*++g'` + # job step 0 - setup... if [ ! -d ~/test ]; then @@ -97,9 +100,9 @@ sr3 start subscribe/local_copy.conf export SR_POST_CONFIG=local_post.conf if [ "${SYSTEM_SHIM_TEST}" ]; then - export LD_PRELOAD=libsr3shim.so.1.0.0 + export LD_PRELOAD=libsr3shim.so.${VERSION} else - export LD_PRELOAD=`pwd`/libsr3shim.so.1.0.0:`pwd`/libsr3c.so.1.0.0 + export LD_PRELOAD=`pwd`/libsr3shim.so.${VERSION}:`pwd`/libsr3c.so.${VERSION} #export LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} fi export SR_SHIMDEBUG=99 diff --git a/shim_copy_flatten.sh b/shim_copy_flatten.sh index 594794f..4ab3f19 100755 --- a/shim_copy_flatten.sh +++ b/shim_copy_flatten.sh @@ -1,4 +1,7 @@ +VERSION=`head -1 debian/changelog| sed 's/.*(//' | sed 's/).*//'` +MAJOR_VERSION=`echo \"${VERSION}\" | sed 's+\..*++g'` + # job step 0 - setup... if [ ! -d ~/test ]; then @@ -95,9 +98,9 @@ sr3 start subscribe/local_copy.conf export SR_POST_CONFIG=local_post.conf if [ "${SYSTEM_SHIM_TEST}" ]; then - export LD_PRELOAD=libsr3shim.so.1.0.0 + export LD_PRELOAD=libsr3shim.so.${VERSION} else - export LD_PRELOAD=`pwd`/libsr3shim.so.1.0.0 + export LD_PRELOAD=`pwd`/libsr3shim.so.${VERSION} export LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} fi export SR_SHIMDEBUG=99 diff --git a/shim_copy_mirror.sh b/shim_copy_mirror.sh index d73b205..98dc0b9 100755 --- a/shim_copy_mirror.sh +++ b/shim_copy_mirror.sh @@ -1,5 +1,8 @@ +VERSION=`head -1 debian/changelog| sed 's/.*(//' | sed 's/).*//'` +MAJOR_VERSION=`echo \"${VERSION}\" | sed 's+\..*++g'` + # job step 0 - setup... if [ ! -d ~/test ]; then mkdir ~/test @@ -98,9 +101,9 @@ sr3 start subscribe/local_copy.conf export SR_POST_CONFIG=local_post.conf if [ "${SYSTEM_SHIM_TEST}" ]; then - export LD_PRELOAD=libsr3shim.so.1.0.0 + export LD_PRELOAD=libsr3shim.so.${VERSION} else - export LD_PRELOAD=`pwd`/libsr3shim.so.1.0.0 + export LD_PRELOAD=`pwd`/libsr3shim.so.${VERSION} export LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} fi export SR_SHIMDEBUG=99 diff --git a/shim_copy_mirror_sftp.sh b/shim_copy_mirror_sftp.sh index 6044c08..384decd 100755 --- a/shim_copy_mirror_sftp.sh +++ b/shim_copy_mirror_sftp.sh @@ -1,4 +1,7 @@ +VERSION=`head -1 debian/changelog| sed 's/.*(//' | sed 's/).*//'` +MAJOR_VERSION=`echo \"${VERSION}\" | sed 's+\..*++g'` + # job step 0 - setup... if [ ! -d ~/test ]; then @@ -94,9 +97,9 @@ sr3 start subscribe/local_copy.conf export SR_POST_CONFIG=local_post.conf if [ "${SYSTEM_SHIM_TEST}" ]; then - export LD_PRELOAD=libsr3shim.so.1.0.0 + export LD_PRELOAD=libsr3shim.so.${VERSION} else - export LD_PRELOAD=`pwd`/libsr3shim.so.1.0.0 + export LD_PRELOAD=`pwd`/libsr3shim.so.${VERSION} export LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} fi export SR_SHIMDEBUG=99 diff --git a/shim_copy_strip.sh b/shim_copy_strip.sh index fcb8b4b..2f7e11f 100755 --- a/shim_copy_strip.sh +++ b/shim_copy_strip.sh @@ -1,4 +1,7 @@ +VERSION=`head -1 debian/changelog| sed 's/.*(//' | sed 's/).*//'` +MAJOR_VERSION=`echo \"${VERSION}\" | sed 's+\..*++g'` + # job step 0 - setup... if [ ! -d ~/test ]; then @@ -108,9 +111,9 @@ sr3 start subscribe/local_copy.conf export SR_POST_CONFIG=local_post.conf if [ "${SYSTEM_SHIM_TEST}" ]; then - export LD_PRELOAD=libsr3shim.so.1.0.0 + export LD_PRELOAD=libsr3shim.so.${VERSION} else - export LD_PRELOAD=`pwd`/libsr3shim.so.1.0.0 + export LD_PRELOAD=`pwd`/libsr3shim.so.${VERSION} export LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} fi export SR_SHIMDEBUG=99 diff --git a/shim_copy_strip_slash.sh b/shim_copy_strip_slash.sh index 6b1f740..696a28f 100755 --- a/shim_copy_strip_slash.sh +++ b/shim_copy_strip_slash.sh @@ -1,4 +1,7 @@ +VERSION=`head -1 debian/changelog| sed 's/.*(//' | sed 's/).*//'` +MAJOR_VERSION=`echo \"${VERSION}\" | sed 's+\..*++g'` + # job step 0 - setup... if [ ! -d ~/test ]; then @@ -101,9 +104,9 @@ sr3 start subscribe/local_copy.conf export SR_POST_CONFIG=local_post.conf if [ "${SYSTEM_SHIM_TEST}" ]; then - export LD_PRELOAD=libsr3shim.so.1.0.0 + export LD_PRELOAD=libsr3shim.so.${VERSION} else - export LD_PRELOAD=`pwd`/libsr3shim.so.1.0.0:`pwd`/libsr3c.so.1.0.0 + export LD_PRELOAD=`pwd`/libsr3shim.so.${VERSION}:`pwd`/libsr3c.so.${VERSION} #export LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} fi export SR_SHIMDEBUG=99 From 24b359a79bdc528a0788c1013ed26b7be0c68261 Mon Sep 17 00:00:00 2001 From: Peter Silva Date: Wed, 24 Jul 2024 14:45:51 -0400 Subject: [PATCH 14/16] move centos rpm building from RELEASE to BUILD docs --- BUILD.rst | 20 ++++++++++++++++++++ Makefile | 2 +- RELEASE.rst | 32 -------------------------------- 3 files changed, 21 insertions(+), 33 deletions(-) diff --git a/BUILD.rst b/BUILD.rst index edf754c..12c096f 100644 --- a/BUILD.rst +++ b/BUILD.rst @@ -285,6 +285,9 @@ if on a redhat derived OS, then assuming build dependencies are taken care of. For redhat 8, add the INTERCEPT_SYSCALL symbol to CFLAGS in the Makefile:: + git clone https://github.com/MetPX/sarrac metpx-sr3c + cd metpx-sr3c + vi Makefile /^CFLAGS= a -DINTERCEPT_SYSCALL @@ -304,6 +307,23 @@ There is also a suse Makefile target. Has not be tested recently. May or may not work. Left as a starting point for next person to try Suse. + +Suse +~~~~ + +on a Suse distribution, this has worked in the past:: + + zypper addrepo https://download.opensuse.org/repositories/network:messaging:amqp/openSUSE_Leap_15.1/network:messaging:amqp.repo + zypper refresh + zypper install librabbitmq4 librabbitmq-devel + zypper install libopenssl-devel libjson-c-devel + make rpm_suse15 + + +( notes from: https://github.com/MetPX/sarrac/issues/73 ) + + + Branches -------- diff --git a/Makefile b/Makefile index fdbaf0d..b045ca2 100644 --- a/Makefile +++ b/Makefile @@ -43,7 +43,7 @@ LIBCLOCATION=$(shell ldd /bin/sh | awk '/libc\.so\./ { print; }' | cut -d' ' -f3 # On RHEL8, add -DINTERCEPT_SYSCALL to handle cases where mv calls syscall directly, instead of calling renameat2. # See sarrac issue #145 for more information about syscall/renameat2. -CFLAGS = -DHAVE_JSONC -DSR_APPNAME=\"sr3\" -DFORCE_LIBC_REGEX=\"$(LIBCLOCATION)\" -fPIC -ftest-coverage -std=gnu99 -Wall -g -D_GNU_SOURCE $(RABBIT_INCDIR) +CFLAGS = -DINTERCEPT_SYSCALL -DHAVE_JSONC -DSR_APPNAME=\"sr3\" -DFORCE_LIBC_REGEX=\"$(LIBCLOCATION)\" -fPIC -ftest-coverage -std=gnu99 -Wall -g -D_GNU_SOURCE $(RABBIT_INCDIR) SARRA_HEADER = sr_cache.h sr_config.h sr_consume.h sr_context.h sr_credentials.h sr_event.h sr_post.h sr_util.h sr_version.h uthash.h SARRA_OBJECT = sr_post.o sr_consume.o sr_context.o sr_config.o sr_event.o sr_credentials.o sr_cache.o sr_util.o diff --git a/RELEASE.rst b/RELEASE.rst index fc375c5..357f66d 100644 --- a/RELEASE.rst +++ b/RELEASE.rst @@ -152,35 +152,3 @@ The rpm build targets run *rpmbuild* which places the packages in a standard tre ~/rpmbuild/RPMS//..rpm on each arch the rpm will be created in the appropriate directory. - - - - - - -Building RPMS -------------- - -This is the general procedure when building rpms on a system that has never -had an RPM build on it before. -Clone source to metpx-sr3c directory (needed by rpm build rules):: - - git clone https://github.com/MetPX/sarrac metpx-sr3c - cd sr3c - -on Suse:: - - zypper addrepo https://download.opensuse.org/repositories/network:messaging:amqp/openSUSE_Leap_15.1/network:messaging:amqp.repo - zypper refresh - zypper install librabbitmq4 librabbitmq-devel - zypper install libopenssl-devel libjson-c-devel - make rpm_suse15 - -on Redhat/Centos:: - - # install dependencies somehow... unclear in general. - make rpm_rhel7 - - -( notes from: https://github.com/MetPX/sarrac/issues/73 ) - From ea7ad29b4da2b061494788f7ffefbdf5113e5b76 Mon Sep 17 00:00:00 2001 From: Peter Silva Date: Wed, 24 Jul 2024 16:33:24 -0400 Subject: [PATCH 15/16] much better fix so that redirection is still tested, in spite of bug. --- shim_copy_baseDir.sh | 8 ++++- shim_copy_flatten.sh | 7 +++- shim_copy_mirror.sh | 8 ++++- shim_copy_mirror_sftp.sh | 8 ++++- shim_copy_post.sh | 46 +++++++----------------- shim_copy_post2.sh | 49 ++++++++----------------- shim_copy_strip.sh | 7 +++- shim_copy_strip_slash.sh | 7 +++- shim_post.sh | 77 ++-------------------------------------- 9 files changed, 69 insertions(+), 148 deletions(-) diff --git a/shim_copy_baseDir.sh b/shim_copy_baseDir.sh index a5f7969..dece9f2 100755 --- a/shim_copy_baseDir.sh +++ b/shim_copy_baseDir.sh @@ -106,7 +106,13 @@ else #export LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} fi export SR_SHIMDEBUG=99 -./shim_copy_post2.sh & + +if [ "${KNOWN_REDIRECTION_BUG}" ]; then + bash ./shim_copy_post2.sh & +else + ./shim_copy_post2.sh & +fi + unset SR_POST_CONFIG unset SR_SHIMDEBUG unset LD_PRELOAD diff --git a/shim_copy_flatten.sh b/shim_copy_flatten.sh index 4ab3f19..6706b9e 100755 --- a/shim_copy_flatten.sh +++ b/shim_copy_flatten.sh @@ -104,7 +104,12 @@ else export LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} fi export SR_SHIMDEBUG=99 -./shim_copy_post.sh & +if [ "${KNOWN_REDIRECTION_BUG}" ]; then + bash ./shim_copy_post.sh & +else + ./shim_copy_post.sh & +fi + unset SR_POST_CONFIG unset SR_SHIMDEBUG unset LD_PRELOAD diff --git a/shim_copy_mirror.sh b/shim_copy_mirror.sh index 98dc0b9..38d9485 100755 --- a/shim_copy_mirror.sh +++ b/shim_copy_mirror.sh @@ -107,7 +107,13 @@ else export LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} fi export SR_SHIMDEBUG=99 -./shim_copy_post2.sh & + +if [ "${KNOWN_REDIRECTION_BUG}" ]; then + bash ./shim_copy_post2.sh & +else + ./shim_copy_post2.sh & +fi + unset SR_POST_CONFIG unset SR_SHIMDEBUG unset LD_PRELOAD diff --git a/shim_copy_mirror_sftp.sh b/shim_copy_mirror_sftp.sh index 384decd..c5f5f0a 100755 --- a/shim_copy_mirror_sftp.sh +++ b/shim_copy_mirror_sftp.sh @@ -103,7 +103,13 @@ else export LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} fi export SR_SHIMDEBUG=99 -./shim_copy_post2.sh & + +if [ "${KNOWN_REDIRECTION_BUG}" ]; then + bash ./shim_copy_post2.sh & +else + ./shim_copy_post2.sh & +fi + unset SR_POST_CONFIG unset SR_SHIMDEBUG unset LD_PRELOAD diff --git a/shim_copy_post.sh b/shim_copy_post.sh index a4e0f8e..1961c07 100755 --- a/shim_copy_post.sh +++ b/shim_copy_post.sh @@ -57,21 +57,11 @@ mkdir dirone echo "#test 1 link 110 symlink to directory" ln -s dirone link_to_dirone -if [ "${KNOWN_REDIRECTION_BUG}" ]; then - echo "#test 1 sha512 120 cp replaces redirection in a subdir" - cp hoho link_to_dirone/fileone -else - echo "#test 1 sha512 120 stdout redirection in a subdir" - echo "fileone" >>link_to_dirone/fileone -fi +echo "#test 1 sha512 120 stdout redirection in a subdir" +echo "fileone" >>link_to_dirone/fileone -if [ "${KNOWN_REDIRECTION_BUG}" ]; then - echo "#test 1 sha512 120 cp replaces 2nd stdout redirection in a subdir" - cp hoho link_to_dirone/filefive -else - echo "#test 1 sha512 120 2nd stdout redirection in a subdir" - echo "lovely" >>link_to_dirone/filefive -fi +echo "#test 1 sha512 120 2nd stdout redirection in a subdir" +echo "lovely" >>link_to_dirone/filefive echo "#test 1 directory 130 mkdir 2" mkdir dirone/dirtwo @@ -79,13 +69,8 @@ mkdir dirone/dirtwo echo "#test 1,1 link,rename 135 symlink in a sub-dir" ln -sf `pwd`/link_to_dirone/fileone dirone/link_to_fileone -if [ "${KNOWN_REDIRECTION_BUG}" ]; then - echo "#test 1 sha512 140 cp replaces redirection in a subsubdir" - cp hoho dirone/dirtwo/filetwo -else - echo "#test 1 sha512 140 stdout redirection in a subsubdir" - echo "filetwo" >>dirone/dirtwo/filetwo -fi +echo "#test 1 sha512 140 stdout redirection in a subsubdir" +echo "filetwo" >>dirone/dirtwo/filetwo echo "#test 1 rename 145 rename in a sub-dir" mv dirone/dirtwo/filetwo dirone/dirtwo/filefour @@ -98,25 +83,18 @@ mv dirone dirthree echo "#test 1 link 135 symlink in a sub-dir" ln -sf `pwd`/dirthree/dirtwo/filefour dirthree/dirtwo/link2four -if [ "${KNOWN_REDIRECTION_BUG}" ]; then - echo "#test 1 sha512 141 create test_file (without redirection)" - cp hoho test_file -else - echo "#test 1 sha512 142 create test_file with redirection" - echo 1 >test_file -fi +echo "#test 1 sha512 142 create test_file with redirection" +echo 1 >test_file echo "#test 1 sha512 151 update test_file" touch test_file echo "#test 1 rename 152 move test_file into dirthree subdir" mv test_file dirthree -if [ "${KNOWN_REDIRECTION_BUG}" ]; then - echo "#test 1 sha512 161 create test_file (again)" - cp dirthree/test_file test_file -else - echo "#test 1 sha512 162 create test_file (again)" - echo 2 >test_file +echo "#test 1 sha512 162 create test_file (again)" +echo 2 >test_file + +if [ ! "${KNOWN_REDIRECTION_BUG}" ]; then echo "#no post from touch, refused as repeat" touch test_file fi diff --git a/shim_copy_post2.sh b/shim_copy_post2.sh index 0c9e653..430d89a 100755 --- a/shim_copy_post2.sh +++ b/shim_copy_post2.sh @@ -63,19 +63,11 @@ mkdir dirone echo "#test 1 link 110 symlink to directory" ln -s dirone link_to_dirone -if [ "${KNOWN_REDIRECTION_BUG}" ]; then - echo "#test 1 sha512 120 workaround copy for stdout redirection in a subdir" - cp hoho link_to_dirone/fileone - - echo "#test 1 sha512 120 workaround copy for 2nd stdout redirection in a subdir" - cp hoho link_to_dirone/filefive -else - echo "#test 1 sha512 120 stdout redirection in a subdir" - echo "fileone" >>link_to_dirone/fileone +echo "#test 1 sha512 120 stdout redirection in a subdir" +echo "fileone" >>link_to_dirone/fileone - echo "#test 1 sha512 120 2nd stdout redirection in a subdir" - echo "lovely" >>link_to_dirone/filefive -fi +echo "#test 1 sha512 120 2nd stdout redirection in a subdir" +echo "lovely" >>link_to_dirone/filefive echo "#test 1 directory 130 mkdir 2" @@ -84,13 +76,8 @@ mkdir dirone/dirtwo echo "#test 1,1 link,rename 135 symlink in a sub-dir" ln -sf `pwd`/link_to_dirone/fileone dirone/link_to_fileone -if [ "${KNOWN_REDIRECTION_BUG}" ]; then - echo "#test 1 sha512 140 creat file (work-around stdout redirection) in a subsubdir" - dd if=/dev/zero of=dirone/dirtwo/filetwo count=7 -else - echo "#test 1 sha512 140 stdout redirection in a subsubdir" - echo "filetwo" >>dirone/dirtwo/filetwo -fi +echo "#test 1 sha512 140 stdout redirection in a subsubdir" +echo "filetwo" >>dirone/dirtwo/filetwo echo "#test 1 rename 145 rename in a sub-dir" mv dirone/dirtwo/filetwo dirone/dirtwo/filefour @@ -103,27 +90,21 @@ mv dirone dirthree echo "#test 1 link 135 symlink in a sub-dir" ln -sf `pwd`/dirthree/dirtwo/filefour dirthree/dirtwo/link2four -if [ "${KNOWN_REDIRECTION_BUG}" ]; then - echo "#test 1 sha512 workaround cp for create test_file with redirection" - cp ../pyiotest test_file -else - echo "#test 1 sha512 create test_file with redirection." - echo 1 >test_file -fi +echo "#test 1 sha512 create test_file with redirection." +echo 1 >test_file echo "#test 1 sha512 update test_file" touch test_file echo "#test 1 rename move test_file into dirthree subdir" mv test_file dirthree -if [ "${KNOWN_REDIRECTION_BUG}" ]; then - echo "#test 1 sha512 workaround cp for create test_file in (again) from redirection" - cp ../pyiotest test_file -else - echo "#test 1 sha512 create test_file (again) from redirection" - echo 2 >test_file - echo "#no post from touch, refused as repeat" - touch test_file +echo "#test 1 sha512 create test_file (again) from redirection" +echo 2 >test_file + +if [ ! "${KNOWN_REDIRECTION_BUG}" ]; then + echo "#no post from touch, refused as repeat" + touch test_file fi + echo "#test 1 rename move test_file into dirthree subdir (new name)" mv test_file dirthree/new_test_file diff --git a/shim_copy_strip.sh b/shim_copy_strip.sh index 2f7e11f..07e5706 100755 --- a/shim_copy_strip.sh +++ b/shim_copy_strip.sh @@ -117,7 +117,12 @@ else export LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} fi export SR_SHIMDEBUG=99 -./shim_copy_post.sh & + +if [ "${KNOWN_REDIRECTION_BUG}" ]; then + bash ./shim_copy_post.sh & +else + ./shim_copy_post.sh & +fi unset SR_POST_CONFIG unset SR_SHIMDEBUG unset LD_PRELOAD diff --git a/shim_copy_strip_slash.sh b/shim_copy_strip_slash.sh index 696a28f..2d2ee68 100755 --- a/shim_copy_strip_slash.sh +++ b/shim_copy_strip_slash.sh @@ -110,7 +110,12 @@ else #export LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} fi export SR_SHIMDEBUG=99 -./shim_copy_post.sh & + +if [ "${KNOWN_REDIRECTION_BUG}" ]; then + bash ./shim_copy_post.sh & +else + ./shim_copy_post.sh & +fi unset SR_POST_CONFIG unset SR_SHIMDEBUG unset LD_PRELOAD diff --git a/shim_post.sh b/shim_post.sh index 0fd2697..57a251a 100755 --- a/shim_post.sh +++ b/shim_post.sh @@ -66,81 +66,10 @@ EOT exec $0 fi -set -x - -which bash - -echo "#test 0 comment 000 shim test posting start" -echo "#test 1 sha512 010 capturing stdout" -bash -c 'echo "hoho" >> ./hoho' - -echo "#test 1 sha512 020 c program run." -truncate --size=2 ./hoho - -echo "#test 1 sha512 030 python program run" -/usr/bin/python3 pyiotest - -grep lovely pyiotest - -echo "#test 1 directory 040 make directory" -mkdir sub_dir1 - -echo "#test 1 rename 050 rename directory" -mv sub_dir1 sub_dir2 - -echo "#test 1 rmdir 060 remove directory" -rmdir sub_dir2 - - -echo "#test 1 sha512 070 cp command" -cp libsr3shim.c ~/test/hoho_my_darling.txt - -echo "#test 1 sha512 080 touch command" -touch hihi - -echo "#test 1 link 090 symlink command" -ln -s hoho haha - -echo "#test 1 rename 100 moving a symlink" -mv haha hihi - -echo "#test 1 rename 110 hardlink to a symlink" -ln hihi hoohoo -echo "#test 1 rename 120 moving a file. " -mv ~/test/hoho_my_darling.txt ~/test/hoho2.log -echo "#test 1 remove 130 removing a file. " -rm hihi - -echo "#test 1 remove 140 removing a file." -rm ~/test/hoho2.log - -echo "#test 1 directory 150 make second directory ." - -mkdir dirone -if [ "${KNOWN_REDIRECTION_BUG}" ]; then - echo "#test 1 sha512 160 cp to avoid stdout redirection in a subdir" - cp hoho dirone/fileone +if [ "${KNOWN_REDIRECTION_BUG}" ];then + bash ./shim_post_run.sh else - echo "#test 1 sha512 160 stdout redirection in a subdir" - echo "fileone" >>dirone/fileone + . ./shim_post_run.sh fi -echo "#test 1 directory 170 make third directory." -mkdir dirone/dirtwo - -if [ "${KNOWN_REDIRECTION_BUG}" ]; then - echo "#test 1 sha512 180 cp to avoid stdout redirection in a subsubdir" - cp hoho dirone/dirtwo/filetwo -else - echo "#test 1 sha512 180 stdout redirection in a subsubdir" - echo "filetwo" >>dirone/dirtwo/filetwo -fi -echo "#test 1 rename 190 renaming subdirs should cause file rename events." -mv dirone dirthree -echo "#test 4 remove 200 removing a whole tree events." -rm -rf dirthree -echo "#test 2 remove 210 removing two files" -rm hoho hoohoo -echo "#test 0 comment 220 shim test posting end" -echo "#test 0 comment 230 test to ensure previous completes" From 568a64420f08af60453ed24f62355c556ad7b5d1 Mon Sep 17 00:00:00 2001 From: Peter Silva Date: Thu, 25 Jul 2024 11:22:21 -0400 Subject: [PATCH 16/16] INTERCEPT_SYSCALL should not be default --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b045ca2..fdbaf0d 100644 --- a/Makefile +++ b/Makefile @@ -43,7 +43,7 @@ LIBCLOCATION=$(shell ldd /bin/sh | awk '/libc\.so\./ { print; }' | cut -d' ' -f3 # On RHEL8, add -DINTERCEPT_SYSCALL to handle cases where mv calls syscall directly, instead of calling renameat2. # See sarrac issue #145 for more information about syscall/renameat2. -CFLAGS = -DINTERCEPT_SYSCALL -DHAVE_JSONC -DSR_APPNAME=\"sr3\" -DFORCE_LIBC_REGEX=\"$(LIBCLOCATION)\" -fPIC -ftest-coverage -std=gnu99 -Wall -g -D_GNU_SOURCE $(RABBIT_INCDIR) +CFLAGS = -DHAVE_JSONC -DSR_APPNAME=\"sr3\" -DFORCE_LIBC_REGEX=\"$(LIBCLOCATION)\" -fPIC -ftest-coverage -std=gnu99 -Wall -g -D_GNU_SOURCE $(RABBIT_INCDIR) SARRA_HEADER = sr_cache.h sr_config.h sr_consume.h sr_context.h sr_credentials.h sr_event.h sr_post.h sr_util.h sr_version.h uthash.h SARRA_OBJECT = sr_post.o sr_consume.o sr_context.o sr_config.o sr_event.o sr_credentials.o sr_cache.o sr_util.o