Merge ~pkopylov/qa-regression-testing:fix-test-util-linux-swapon into qa-regression-testing:master

Proposed by Pavel Kopylov
Status: Needs review
Proposed branch: ~pkopylov/qa-regression-testing:fix-test-util-linux-swapon
Merge into: qa-regression-testing:master
Diff against target: 43 lines (+17/-3)
1 file modified
scripts/test-util-linux.py (+17/-3)
Reviewer Review Type Date Requested Status
Ubuntu Security Team Pending
Review via email: mp+442107@code.staging.launchpad.net

Description of the change

There is a problem with the swapon utility. Here is the display_summary(void) function which uses get_swaps(). If /proc/swaps doesn't contain any partition on Ubuntu 16 the get_swaps() returns NULL and there is no output of either swapon --show or swapon --summary at all.

Also, the swapon's manual declares command line keys --summary and -s as deprecated, so the right solution is using a similar key named --show.

So, I suggest checking if /proc/swaps exists at all and if this file contains at least two strings (because the first string in this file is just titles).

To post a comment you must log in.
Revision history for this message
Steve Beattie (sbeattie) wrote :

Hay Pavel, thanks for submitting this. One issue with converting to swapon --show is that the Ubuntu Security Team is still supporting 14.04 LTS / trusty, where the swapon command does not support the --show argument.

I have pushed a commit that will use swapon --show in newer releases, and also checks the contents of /proc/swaps, and doesn't expect any output from swapon if there's no entries besides the column headers in /proc/swaps. Probably the better solution is to always create a small swapfile and check the output of swapon to ensure it's present.

The commit is at https://git.launchpad.net/qa-regression-testing/commit/?id=079add3ae1812d37164c80cf06ff6d399a8b27c3

Thanks!

There was an error fetching revisions from git servers. Please try again in a few minutes. If the problem persists, contact Launchpad support.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches