((ply_boot_client_answer_handler_t) request->handler) (request->user_data, answer, client);
}
+ else if (memcmp (byte, PLY_BOOT_PROTOCOL_RESPONSE_TYPE_NO_ANSWER, sizeof (uint8_t)) == 0)
+ {
+ ((ply_boot_client_answer_handler_t) request->handler) (request->user_data, NULL, client);
+ }
else
goto out;
pid_t pid;
int command_input_sender_fd, command_input_receiver_fd;
+ /* answer may be NULL which means,
+ * "The daemon can't ask the user questions,
+ * do all the prompting from the client"
+ */
+
gave_answer = false;
- if (!ply_open_unidirectional_pipe (&command_input_sender_fd,
- &command_input_receiver_fd)) return false;
+ if (answer != NULL &&
+ !ply_open_unidirectional_pipe (&command_input_sender_fd,
+ &command_input_receiver_fd))
+ return false;
pid = fork ();
if (pid == 0)
{
char **args;
- close (command_input_sender_fd);
args = split_string (answer_state->command, ' ');
- dup2 (command_input_receiver_fd, STDIN_FILENO);
+ if (answer != NULL)
+ {
+ close (command_input_sender_fd);
+ dup2 (command_input_receiver_fd, STDIN_FILENO);
+ }
execvp (args[0], args);
ply_trace ("could not run command: %m");
_exit (127);
}
- close (command_input_receiver_fd);
- if (write (command_input_sender_fd, answer, strlen (answer)) < 0)
- goto out;
+ if (answer != NULL)
+ {
+ close (command_input_receiver_fd);
+
+ if (write (command_input_sender_fd, answer, strlen (answer)) < 0)
+ goto out;
+ }
gave_answer = true;
out:
- close (command_input_sender_fd);
+ if (answer != NULL)
+ close (command_input_sender_fd);
waitpid (pid, exit_status, 0);
return gave_answer;
#define PLY_BOOT_PROTOCOL_RESPONSE_TYPE_ACK "\x6"
#define PLY_BOOT_PROTOCOL_RESPONSE_TYPE_NAK "\x15"
#define PLY_BOOT_PROTOCOL_RESPONSE_TYPE_ANSWER "\x2"
+#define PLY_BOOT_PROTOCOL_RESPONSE_TYPE_NO_ANSWER "\x5"
#endif /* PLY_BOOT_PROTOCOL_H */
/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
size_t size;
- /* FIXME: support up to 4 billion
+ /* splash plugin isn't able to ask for password,
+ * punt to client
*/
- if (strlen (password) > 255)
- ply_error ("password to long to fit in buffer");
-
- size = (uint8_t) strlen (password);
-
- if (!ply_write (connection->fd,
- PLY_BOOT_PROTOCOL_RESPONSE_TYPE_ANSWER,
- strlen (PLY_BOOT_PROTOCOL_RESPONSE_TYPE_ANSWER)) ||
- !ply_write (connection->fd,
- &size, sizeof (uint8_t)) ||
- !ply_write (connection->fd,
- password, size))
- ply_error ("could not write bytes: %m");
+ if (password == NULL)
+ {
+ if (!ply_write (connection->fd,
+ PLY_BOOT_PROTOCOL_RESPONSE_TYPE_NO_ANSWER,
+ strlen (PLY_BOOT_PROTOCOL_RESPONSE_TYPE_NO_ANSWER)))
+ ply_error ("could not write bytes: %m");
+ }
+ else
+ {
+ /* FIXME: support up to 4 billion
+ */
+ if (strlen (password) > 255)
+ ply_error ("password to long to fit in buffer");
+
+ size = (uint8_t) strlen (password);
+
+ if (!ply_write (connection->fd,
+ PLY_BOOT_PROTOCOL_RESPONSE_TYPE_ANSWER,
+ strlen (PLY_BOOT_PROTOCOL_RESPONSE_TYPE_ANSWER)) ||
+ !ply_write (connection->fd,
+ &size, sizeof (uint8_t)) ||
+ !ply_write (connection->fd,
+ password, size))
+ ply_error ("could not write bytes: %m");
+ }
ply_answer_free (answer);
}
if (splash->plugin_interface->ask_for_password == NULL)
{
- ply_answer_with_string (answer, "");
+ ply_answer_unknown (answer);
return;
}
#define CLEAR_LINE_SEQUENCE "\033[2K\r\n"
#define BACKSPACE "\b\033[0K"
+void ask_for_password (ply_boot_splash_plugin_t *plugin,
+ ply_answer_t *answer);
+
+ply_boot_splash_plugin_interface_t *ply_boot_splash_plugin_get_interface (void);
struct _ply_boot_splash_plugin
{
ply_event_loop_t *loop;
assert (plugin != NULL);
- ply_window_set_mode (window, PLY_WINDOW_MODE_TEXT);
+ if (window != NULL)
+ {
+ ply_boot_splash_plugin_interface_t *interface;
+
+ ply_window_set_mode (window, PLY_WINDOW_MODE_TEXT);
- ply_window_set_keyboard_input_handler (window,
- (ply_window_keyboard_input_handler_t)
- on_keyboard_input, plugin);
- ply_window_set_backspace_handler (window,
- (ply_window_backspace_handler_t)
- on_backspace, plugin);
- ply_window_set_enter_handler (window,
- (ply_window_enter_handler_t)
- on_enter, plugin);
+ ply_window_set_keyboard_input_handler (window,
+ (ply_window_keyboard_input_handler_t)
+ on_keyboard_input, plugin);
+ ply_window_set_backspace_handler (window,
+ (ply_window_backspace_handler_t)
+ on_backspace, plugin);
+ ply_window_set_enter_handler (window,
+ (ply_window_enter_handler_t)
+ on_enter, plugin);
+
+ interface = ply_boot_splash_plugin_get_interface ();
+
+ interface->ask_for_password = ask_for_password;
+ }
plugin->loop = loop;
.update_status = update_status,
.on_boot_output = on_boot_output,
.hide_splash_screen = hide_splash_screen,
- .ask_for_password = ask_for_password,
};
return &plugin_interface;