Skip to content

[pipeline] Set CAP_SYS_TIME for settimeofday ok in syncd test#1068

Merged
lguohan merged 3 commits intosonic-net:masterfrom
jimmyzhai:fix_settimeofday_failure
Jun 22, 2022
Merged

[pipeline] Set CAP_SYS_TIME for settimeofday ok in syncd test#1068
lguohan merged 3 commits intosonic-net:masterfrom
jimmyzhai:fix_settimeofday_failure

Conversation

@jimmyzhai
Copy link
Copy Markdown
Contributor

The fix #1067 is not enough. If docker user is non-root, set capability CAP_SYS_TIME for settimeofday success in syncd test, then test_watchdog_timer_clock_rollback can be run.

@jimmyzhai jimmyzhai requested review from kcudnik and lguohan June 17, 2022 13:32
@jimmyzhai
Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@jimmyzhai
Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).


tests_SOURCES = tests.cpp
tests_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON)
tests_LDFLAGS = -Wl,-rpath,$(top_srcdir)/lib/.libs -Wl,-rpath,$(top_srcdir)/meta/.libs
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this is required here ? those directories are already passed in below LDADD

Copy link
Copy Markdown
Contributor Author

@jimmyzhai jimmyzhai Jun 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running syncd/tests depends on env LD_LIBRARY_PATH:

+ LD_LIBRARY_PATH=/sonic/src/sonic-sairedis/lib/.libs:/sonic/src/sonic-sairedis/meta/.libs
+ export LD_LIBRARY_PATH
...
+ exec /sonic/src/sonic-sairedis/syncd/.libs/tests

After setting linux capability, for security reason, LD_LIBRARY_PATH is ignored, referring to man ld.so:

Secure-execution mode
For security reasons, if the dynamic linker determines that a binary should be run in secure-execution mode, the effects of some environment variables are voided or modified, and furthermore those environment variables are stripped from the environment, so that the program does not even see the definitions...
A binary is executed in secure-execution mode ...
* A process with a non-root user ID executed a binary that conferred capabilities to the process.

Then have to specify -rpath option for runtime linker to locate shared libraries libsairedis, libsaimetadata, etc.

@lguohan lguohan merged commit bd47844 into sonic-net:master Jun 22, 2022
qiluo-msft pushed a commit to sonic-net/sonic-swss-common that referenced this pull request Jun 22, 2022
…s' (#633)

Following sonic-net/sonic-sairedis#1067 and sonic-net/sonic-sairedis#1068, it fixes the below failure at `make check` of building syncd in step 'Compile sonic sairedis':

```
Making check in syncd
make[2]: Entering directory '/__w/1/s/syncd'
make check-TESTS
make[3]: Entering directory '/__w/1/s/syncd'
tests: tests.cpp:843: void test_watchdog_timer_clock_rollback(): Assertion `settimeofday(&currentTime, NULL) == 0' failed.
/bin/bash: line 5: 13004 Aborted (core dumped) ${dir}$tst
FAIL: tests
```
@jimmyzhai jimmyzhai deleted the fix_settimeofday_failure branch June 23, 2022 00:31
itamar-talmon pushed a commit to itamar-talmon/sonic-swss-common that referenced this pull request Jul 19, 2022
…s' (sonic-net#633)

Following sonic-net/sonic-sairedis#1067 and sonic-net/sonic-sairedis#1068, it fixes the below failure at `make check` of building syncd in step 'Compile sonic sairedis':

```
Making check in syncd
make[2]: Entering directory '/__w/1/s/syncd'
make check-TESTS
make[3]: Entering directory '/__w/1/s/syncd'
tests: tests.cpp:843: void test_watchdog_timer_clock_rollback(): Assertion `settimeofday(&currentTime, NULL) == 0' failed.
/bin/bash: line 5: 13004 Aborted (core dumped) ${dir}$tst
FAIL: tests
```
pettershao-ragilenetworks pushed a commit to pettershao-ragilenetworks/sonic-sairedis that referenced this pull request Nov 18, 2022
…net#1068)

The fix sonic-net#1067 is not enough. If docker user is non-root, set capability CAP_SYS_TIME for settimeofday success in syncd test, then test_watchdog_timer_clock_rollback can be run.

Co-authored-by: junhuazhai <junhuazhai@contoso.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants