Bug 94323 - pm-functions can incorrectly run hooks more than once
Summary: pm-functions can incorrectly run hooks more than once
Status: RESOLVED WONTFIX
Alias: None
Product: pm-utils
Classification: Unclassified
Component: General (show other bugs)
Version: unspecified
Hardware: All Linux (All)
: medium normal
Assignee: Richard Hughes
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-02-28 01:54 UTC by /df
Modified: 2018-06-29 19:57 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
patch taken from running pm-functions; also fixes comment typo (308 bytes, text/plain)
2016-02-28 01:54 UTC, /df
Details
patch taken from running pm-functions; also fixes comment typo (317 bytes, patch)
2016-02-28 01:59 UTC, /df
Details | Splinter Review

Description /df 2016-02-28 01:54:18 UTC
Created attachment 122012 [details]
patch taken from running pm-functions; also fixes comment typo

The function run_hooks() in pm-functions proposes to-be-executed hooks that includes subdirectories in the hook directories but neither fully validates each such hook as a regular file nor handles a set of to-be-executed hooks in a subdirectory. This can cause a hook to be executed more than once.

At lines 241 on, there is a code path with no else clause:

  if [ -f "$syshooks/$base" ]; then
   hook="$syshooks/$base"
  elif [ -f "$phooks/$base" ]; then
   hook="$phooks/$base"
  fi

If the $base proposed by the for statement at line 229 doesn't match either of the -f tests (which will happen eg if a hook is configured in a subdirectory of the hook directory), the $hook from the previous iteration can be accidentally reused.

An easy fix is to insert the missing else clause before the fi line so that the script skips the subdirectory or other non-regular file and carries on with the next correctly specified hook, as in the attached patch.
Comment 1 /df 2016-02-28 01:59:57 UTC
Created attachment 122013 [details] [review]
patch taken from running pm-functions; also fixes comment typo

(attached wrong file)
Comment 2 Adam Jackson 2018-06-29 19:57:09 UTC
pm-utils hasn't been touched in eight years, none of this is likely to get addressed. Closing bugs and disabling the bz product.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.