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

Add text to avoid empty input for input workaround #888

Open
wants to merge 1 commit into
base: beta
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
25 changes: 25 additions & 0 deletions howdy/src/pam/enter_device.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ EnterDevice::EnterDevice()

libevdev_set_name(dev_ptr, "enter device");
libevdev_enable_event_type(dev_ptr, EV_KEY);
libevdev_enable_event_code(dev_ptr, EV_KEY, KEY_SPACE, nullptr);
libevdev_enable_event_code(dev_ptr, EV_KEY, KEY_ENTER, nullptr);

int err;
Expand All @@ -24,6 +25,30 @@ EnterDevice::EnterDevice()
raw_uinput_device.reset(uinput_dev_ptr);
};

void EnterDevice::send_space_press() const {
auto *uinput_dev_ptr = raw_uinput_device.get();

int err;
if ((err = libevdev_uinput_write_event(uinput_dev_ptr, EV_KEY, KEY_SPACE,
1)) != 0) {
throw std::runtime_error(std::string("Failed to write event: ") +
strerror(-err));
}

if ((err = libevdev_uinput_write_event(uinput_dev_ptr, EV_KEY, KEY_SPACE,
0)) != 0) {
throw std::runtime_error(std::string("Failed to write event: ") +
strerror(-err));
}

if ((err = libevdev_uinput_write_event(uinput_dev_ptr, EV_SYN, SYN_REPORT,
0)) != 0)
{
throw std::runtime_error(std::string("Failed to write event: ") +
strerror(-err));
};
}

void EnterDevice::send_enter_press() const {
auto *uinput_dev_ptr = raw_uinput_device.get();

Expand Down
1 change: 1 addition & 0 deletions howdy/src/pam/enter_device.hh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class EnterDevice {

public:
EnterDevice();
void send_space_press() const;
void send_enter_press() const;
~EnterDevice() = default;
};
Expand Down
4 changes: 4 additions & 0 deletions howdy/src/pam/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,10 @@ auto identify(pam_handle_t *pamh, int flags, int argc, const char **argv,
enter_device.send_enter_press();
}

// try it one more time with an non-empty input field
enter_device.send_space_press();
enter_device.send_enter_press();

Comment on lines +412 to +415
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part should be either in the first send try or in the loop.

if (retries == MAX_RETRIES) {
syslog(LOG_WARNING,
"Failed to send enter input before the retries limit");
Expand Down