-
-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUGFIX] Fix crash if no read permissions for /proc/uptime, and use fallbacks instead #66
Conversation
This crash occured on locked-down systems, e.g. Android. Also... Adds support for macOS and BSD systems with this entry. Adds fallback to the `uptime` command for systems that have it (e.g. Android!) Adds test cases as appropriate.
Also fix some weird formatting in the uptime entry tests.
Sorry, I didn't really think then -- I only force pushed a rebase to master, feel free to force push over it if you're working on anything on this branch (I've gotten too used to working on branches on my own 馃槙) |
Hey Michael, no problem I've not started to work on this one last WE. First question though, is |
Unfortunately no 馃槮 - both busybox and the BSDs accept no arguments to It may be possible to use the output of
|
Thanks for the precision ! EDIT : Yes you're right, no need to play with |
3ae6ca3
to
8b6ecb8
Compare
BSD systems report seconds for < 1 minute uptime! So support has been added to parse this. Additionally improved readibility of our huge regex's comments. Changed the regex's test to be far more robust, using various sensibly chosen values, permutating them with variations of the current system time and user/load average section of the `uptime` output. This basically means we test our regex with over 45,000 strings :) Localisation fix also added to `check_output` in `Uptime`.
I've made some changes to the tests so they're a lot less hotch-potch, with purposefully picked values on edge-cases etc. I've also added variations for the current time, and users/loadaverage sections taking us to many thousands of strings tested on the regex... Maybe it's extreme but it picked up on a problem when I added seconds support in the last commit 馃槂. Let me know if this is better! |
On some systems without read permissions on
/proc/uptime
(e.g. Android), or lacking/proc/uptime
(BSD) Archey will fail with a traceback. This PR fixes this bug and adds additional fallback detections to the Uptime entry to support these systems.Description
Reworked the uptime entry somewhat to now try a few methods of detecting uptime, hopefully preventing complete failure with a traceback.
The uptime is now found as follows:
time
module for Linux, macOS and BSD.uptime
command (fromprocps
(-ng
)Added test cases for this new behaviour, as well as getting
uptime
output from various systems and making sure these are all handled correctly.How has this been tested ?
Using the test cases with various different systems' behaviour, and on my local machine as usual 馃槂
Types of changes :
Checklist :
(I removed the unneeded checklist items so our PR progress bar is somewhat meaningful 馃槂)