Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix device and spool file locking #33

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Fix device and spool file locking #33

wants to merge 2 commits into from

Conversation

jkrzyszt
Copy link
Contributor

@jkrzyszt jkrzyszt commented Apr 3, 2021

Refactor Heyu device and spool file locking code to follow recommendations
found in "Secure Programming Cookbook for C and C++" book by John Viega
and Matt Messier.

While being at it, allow using only one of lock file formats, HDF UUCP
(default) or binary, when reading form a lock file. Support for reading
and also creating binary locks instead of the default HDP UCCP can be
selected at compile time if needed. Reading PIDs with both methods while
creating only the HDF UUCP lock files seems incompatible with systems
and/or 3rd party applications which use binary format. For lock files to
work correctly, all applications must use either the same format or both
formats in parallel when both creating and checking lock files.

Signed-off-by: Janusz Krzysztofik [email protected]

Refactor Heyu device and spool file locking code to follow recommendations
found in "Secure Programming Cookbook for C and C++" book by John Viega
and Matt Messier.

While being at it, allow using only one of lock file formats, HDF UUCP
(default) or binary, when reading form a lock file.  Support for reading
and also creating binary locks instead of the default HDP UCCP can be
selected at compile time if needed.  Reading PIDs with both methods while
creating only the HDF UUCP lock files seems incompatible with systems
and/or 3rd party applications which use binary format.  For lock files to
work correctly, all applications must use either the same format or both
formats in parallel when both creating and checking lock files.

Signed-off-by: Janusz Krzysztofik <[email protected]>
A patch supposed to fix locking introduced inconsistent use of an argument
accepted by device_lock(), first interpreted as a lock file pathname, then
as a name of device or resource protected by the lock.  That inconsistency
resulted in a pathname pointing to an unexistent file used when trying to
confirm successful locking by reading back content of the lock file just
created.

Update device_lock() to accept device / resource name instead of lock file
pathname as its argument and calculate lock file pathname itself, then
update its user.

Also, fix incorrect resource name used when trying to remove write lock
file on error before exit.

Signed-off-by: Janusz Krzysztofik <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant