* [LTP] [PATCHv2] logrotate: fix permission issue for test2
@ 2024-06-20 3:27 Po-Hsu Lin
2024-06-20 5:05 ` Petr Vorel
2024-06-20 5:09 ` Petr Vorel
0 siblings, 2 replies; 4+ messages in thread
From: Po-Hsu Lin @ 2024-06-20 3:27 UTC (permalink / raw)
To: ltp; +Cc: po-hsu.lin
When running this logrotate test on Ubuntu, this test will fail with:
logrotate_tests 2 TINFO: sleep 1 min to wait for rotating logs
logrotate_tests 2 TFAIL: [ -f /var/log/tst_largelogfile.1.gz ] failed unexpectedly
logrotate_tests 2 TFAIL: Failed to create a compressed file
Look more closely to what this test is trying to do we will see there
are two issues here in the tst_largelog.conf:
1. "include /etc/logrotate.d"
This will rotate other log files defined here, since we are just testing
the log rotation capability I think there is no need to rotate log files
other than the testfile itself.
2. Permission issue
Trying to rotate the target file on Ubuntu will cause the following error:
error: skipping "/var/log/tst_largelogfile" because parent directory has
insecure permissions (It's world writable or writable by group which
is not "root") Set "su" directive in config file to tell logrotate
which user/group should be used for rotation.
Fix these by removing the extra include, reuse the existing user/group
setting for test1 with setup() as suggested by Petr Vorel.
Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
---
.../commands/logrotate/logrotate_tests.sh | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/testcases/commands/logrotate/logrotate_tests.sh b/testcases/commands/logrotate/logrotate_tests.sh
index 1f3e61294..c382fd1e4 100755
--- a/testcases/commands/logrotate/logrotate_tests.sh
+++ b/testcases/commands/logrotate/logrotate_tests.sh
@@ -25,7 +25,16 @@ TST_NEEDS_CMDS="crontab file grep logrotate"
TST_TESTFUNC=test
TST_NEEDS_TMPDIR=1
TST_CNT=2
+TST_SETUP=setup
TST_CLEANUP=cleanup
+PERMISSION=
+
+setup()
+{
+ local group="syslog"
+ grep -q $group /etc/group || group="root"
+ PERMISSION="su root $group"
+}
cleanup()
{
@@ -47,10 +56,6 @@ check_log()
test1()
{
- local group="syslog"
-
- grep -q $group /etc/group || group="root"
-
cat >tst_logrotate.conf <<-EOF
#****** Begin Config file *******
# create new (empty) log files after rotating old ones
@@ -60,7 +65,7 @@ test1()
compress
/var/log/tst_logfile {
- su root $group
+ $PERMISSION
rotate 5
weekly
}
@@ -95,9 +100,8 @@ test2()
create
# compress the log files
compress
- # RPM packages drop log rotation information into this directory
- include /etc/logrotate.d
/var/log/tst_largelogfile {
+ $PERMISSION
rotate 5
size=2k
}
--
2.25.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [LTP] [PATCHv2] logrotate: fix permission issue for test2
2024-06-20 3:27 [LTP] [PATCHv2] logrotate: fix permission issue for test2 Po-Hsu Lin
@ 2024-06-20 5:05 ` Petr Vorel
2024-06-20 5:09 ` Petr Vorel
1 sibling, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2024-06-20 5:05 UTC (permalink / raw)
To: Po-Hsu Lin; +Cc: ltp
Hi Po-Hsu Lin,
thanks a lot, merged!
FYI I added a following commit to require root for the test
(/var/log directory usually needs it).
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [LTP] [PATCHv2] logrotate: fix permission issue for test2
2024-06-20 3:27 [LTP] [PATCHv2] logrotate: fix permission issue for test2 Po-Hsu Lin
2024-06-20 5:05 ` Petr Vorel
@ 2024-06-20 5:09 ` Petr Vorel
2024-06-20 6:43 ` Po-Hsu Lin
1 sibling, 1 reply; 4+ messages in thread
From: Petr Vorel @ 2024-06-20 5:09 UTC (permalink / raw)
To: Po-Hsu Lin; +Cc: ltp
Hi Po-Hsu,
> When running this logrotate test on Ubuntu, this test will fail with:
> logrotate_tests 2 TINFO: sleep 1 min to wait for rotating logs
> logrotate_tests 2 TFAIL: [ -f /var/log/tst_largelogfile.1.gz ] failed unexpectedly
> logrotate_tests 2 TFAIL: Failed to create a compressed file
> Look more closely to what this test is trying to do we will see there
> are two issues here in the tst_largelog.conf:
> 1. "include /etc/logrotate.d"
> This will rotate other log files defined here, since we are just testing
> the log rotation capability I think there is no need to rotate log files
> other than the testfile itself.
BTW (for next time): I would have separated these 2 changes into 2 commits.
Kind regards,
Petr
> 2. Permission issue
> Trying to rotate the target file on Ubuntu will cause the following error:
> error: skipping "/var/log/tst_largelogfile" because parent directory has
> insecure permissions (It's world writable or writable by group which
> is not "root") Set "su" directive in config file to tell logrotate
> which user/group should be used for rotation.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [LTP] [PATCHv2] logrotate: fix permission issue for test2
2024-06-20 5:09 ` Petr Vorel
@ 2024-06-20 6:43 ` Po-Hsu Lin
0 siblings, 0 replies; 4+ messages in thread
From: Po-Hsu Lin @ 2024-06-20 6:43 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
On Thu, Jun 20, 2024 at 1:09 PM Petr Vorel <pvorel@suse.cz> wrote:
> Hi Po-Hsu,
>
> > When running this logrotate test on Ubuntu, this test will fail with:
> > logrotate_tests 2 TINFO: sleep 1 min to wait for rotating logs
> > logrotate_tests 2 TFAIL: [ -f /var/log/tst_largelogfile.1.gz ] failed
> unexpectedly
> > logrotate_tests 2 TFAIL: Failed to create a compressed file
>
> > Look more closely to what this test is trying to do we will see there
> > are two issues here in the tst_largelog.conf:
>
> > 1. "include /etc/logrotate.d"
> > This will rotate other log files defined here, since we are just testing
> > the log rotation capability I think there is no need to rotate log files
> > other than the testfile itself.
>
> BTW (for next time): I would have separated these 2 changes into 2 commits.
>
> OK no problem,
thank you.
Po-Hsu
> Kind regards,
> Petr
>
> > 2. Permission issue
> > Trying to rotate the target file on Ubuntu will cause the following
> error:
> > error: skipping "/var/log/tst_largelogfile" because parent directory
> has
> > insecure permissions (It's world writable or writable by group
> which
> > is not "root") Set "su" directive in config file to tell
> logrotate
> > which user/group should be used for rotation.
>
>
>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-06-20 6:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-20 3:27 [LTP] [PATCHv2] logrotate: fix permission issue for test2 Po-Hsu Lin
2024-06-20 5:05 ` Petr Vorel
2024-06-20 5:09 ` Petr Vorel
2024-06-20 6:43 ` Po-Hsu Lin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox