Page MenuHome GnuPG

Improve the quality of the example "scd-event" script
Needs ReviewPublic

Authored by jason on Nov 19 2019, 7:58 PM.




My company has begun to use the "scd-event" script in our deployment of
GnuPG to employee workstations.

I noticed after reviewing the example script that there are a number of
problems with its implementation. Some of the more glaring concerns include
the following:

  1. The --new-code option appears twice in the case statement.
  2. Option parsing requires = for option arguments, but this is not mentioned in the usage message.
  3. The usage message mentions the --old-code option twice.

I decided to rewrite this script so that option parsing would be more
robust. I also included a number of fixes for style problems.

To parse the options, I chose to use the GNU getopt utility. This tool
allows for long options (thus, we can't use getopts). It also allows for
options that are separated by a space or by an = character from their
option arguments.

Since I spent the time to make these improvements, I thought I might as well
submit the changes upstream so that others might benefit.

Jason Franklin

Test Plan

Currently, our team uses the scd-event script to lock the screen when the
GnuPG smart card is removed from the reader. To test, you may want to
change the statement that is executed in the final if statement of the
script. This will allow you to observe that the script is invoked as one
would expect.

Let me know if there are any problems, and I'll work on a fix ASAP!

Diff Detail

rG GnuPG
Lint Skipped
Unit Tests Skipped

Event Timeline

jason edited the summary of this revision. (Show Details)

Thanks for the patch. However, this the getopt is unfortunately GNU specific which is the reason why the original code open coded the option parser.