Opened 7 years ago

Closed 7 years ago

#3056 closed defect (fixed)

MemorySegmentMappedTest.badAllocate fails when run as root user

Reported by: muks Owned by: muks
Priority: medium Milestone: Sprint-20130723
Component: data source Version:
Keywords: Cc:
CVSS Scoring: Parent Tickets:
Sensitive: no Defect Severity: N/A
Sub-Project: DNS Feature Depending on Ticket:
Estimated Difficulty: 0 Add Hours to Ticket: 0
Total Hours: 0.59 Internal?: no

Description (last modified by muks)

MemorySegmentMappedTest.badAllocate sets the mode on the mapped file to 0444, and tries to re-open the mapped file for writing (call indirectly to growSegment()).

This test works in all cases except when the user running the test is root. root is able to write to a mode 0444 file.

We should fix it so that this testcase is skipped when run as the root user.

Subtickets

Change History (9)

comment:1 follow-up: Changed 7 years ago by muks

  • Owner changed from muks to UnAssigned
  • Status changed from new to reviewing

I think a ChangeLog is unnecessary for this issue as it's in tests. What do you think?

comment:2 Changed 7 years ago by muks

trac3056 is ready for review.

comment:3 Changed 7 years ago by muks

  • Description modified (diff)

comment:4 in reply to: ↑ 1 Changed 7 years ago by jreed

Replying to muks:

I think a ChangeLog is unnecessary for this issue as it's in tests. What do you think?

Please add a ChangeLog? entry, especially since the issue was reported by a user on a mailing list. (We do have some examples of ChangeLog? entries for fixing unittests.)

comment:5 Changed 7 years ago by vorner

  • Owner changed from UnAssigned to vorner

comment:6 Changed 7 years ago by vorner

  • Owner changed from vorner to muks

About the changelog, I think I agree with Jeremy ‒ if it was noticed by users, it should have a changelog.

The change looks OK and solves the described problem. But if I run the complete tests as root, I get this error:

Running test: cmdctl_test.py
.............................FF......
======================================================================
FAIL: test_check_file (__main__.TestSecureHTTPServer)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/vorner/work/bind10/src/bin/cmdctl/tests/cmdctl_test.py", line 684, in test_check_file
    self.assertRaises(CmdctlException, check_file, file_name)
AssertionError: CmdctlException not raised by check_file

======================================================================
FAIL: test_check_key_and_cert (__main__.TestSecureHTTPServer)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/vorner/work/bind10/src/bin/cmdctl/tests/cmdctl_test.py", line 709, in test_check_key_and_cert
    keyfile, certfile)
AssertionError: CmdctlException not raised by _check_key_and_cert

----------------------------------------------------------------------

I don't know if it's related enough or I should create a new ticket. But I guess it'll be a similar problem.

comment:7 Changed 7 years ago by muks

  • Owner changed from muks to vorner

There were other such issues.. they've all been fixed now.

How does this look for the ChangeLog entry?

XXX.	[bug]		muks
	When running some unittests as root that depended on insufficient
	file permissions, the tests used to fail because the root user
	could still access such files. Such tests are now skipped when
	they are run as the root user.
	(Trac #3056, git ...)

comment:8 Changed 7 years ago by vorner

  • Owner changed from vorner to muks
  • Total Hours changed from 0 to 0.59

It works now, thank you. Please merge.

comment:9 Changed 7 years ago by muks

  • Resolution set to fixed
  • Status changed from reviewing to closed

Merged to master branch in commit 92ebabdbcf6168666b03d7f7fbb31f899be39322:

* d7c133c [3056] Skip some more tests when run as the root user
* 949a252 [3056] Skip DataSrcClientsBuilderTest.loadUnreadableZone test when run as the root user
* 473c1e6 [3056] Skip another test for root user
* da1318c [3056] Skip another test for root user
* bf471e6 [3056] Skip another test for root user
* 3c1f096 [3056] Skip MemorySegmentMappedTest.badAllocate test when run as the root user

Resolving as fixed. Thank you for the reviews Michal.

Note: See TracTickets for help on using tickets.