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

#261: Support generic serial #263

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/CONFIGURATION
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ The syntax is the following:
| `volume_uuid` | Element | UUID of the device's volume used to store pads | `6F6B-42FC` |

### Note:
Some cheap devices don't report a vendor and/or model. To use these devices you can use "Generic" for these values, then it won't be checked.
Some cheap devices don't report a vendor and/or model, some not even a serial (see https://github.com/mcdope/pam_usb/issues/261). To use these devices you can use "Generic" for these values, then it won't be checked.
Be aware that this reduces security if you have `one_time_pads` disabled since the device containing the volume won't be checked anymore (but these attributes could be faked with a custom firmware anyway).

### Example:
Expand Down
19 changes: 18 additions & 1 deletion src/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,33 @@ static int pusb_device_connected(t_pusb_options *opts, UDisksClient *udisks)
if (udisks_object_peek_drive(object))
{
drive = udisks_object_get_drive(object);
retval = strcmp(udisks_drive_get_serial(drive), opts->device_list[currentDevice].serial) == 0;

if (strcmp(opts->device_list[currentDevice].serial, "Generic") != 0)
{
retval = strcmp(udisks_drive_get_serial(drive), opts->device_list[currentDevice].serial) == 0;
}
else
{
log_error("'Generic' serial configured, this reduces your security! Please use a proper device exposing vendor, model, and serial.\n");
retval = 1;
}

if (strcmp(opts->device_list[currentDevice].vendor, "Generic") != 0)
{
retval = retval && strcmp(udisks_drive_get_vendor(drive), opts->device_list[currentDevice].vendor) == 0;
}
else
{
log_error("'Generic' vendor configured, this reduces your security! Please use a proper device exposing vendor, model, and serial.\n");
}

if (strcmp(opts->device_list[currentDevice].model, "Generic") != 0)
{
retval = retval && strcmp(udisks_drive_get_model(drive), opts->device_list[currentDevice].model) == 0;
}
else
{
log_error("'Generic' model configured, this reduces your security! Please use a proper device exposing vendor, model, and serial.\n");
}

g_object_unref(drive);
Expand Down
Loading