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

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

Details

Reviewers
werner
Summary

Greetings,

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.

Thanks,
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

Repository
rG GnuPG
Lint
Lint Skipped
Unit
Unit Tests Skipped
jason created this revision.Tue, Nov 19, 7:58 PM
jason edited the summary of this revision. (Show Details)