Skip to content
Closed
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
23 changes: 16 additions & 7 deletions usr/src/security-misc/emerg-shutdown.c#security-misc-shared
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
#include <fcntl.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Accepted.

#include <poll.h>
#include <linux/input.h>
#include <linux/vt.h>
Expand All @@ -110,7 +109,7 @@

#define max_sig_num 31

int console_fd = 0;
int console_fd = -1;
Comment on lines -113 to +112
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Accepted. (Doesn't actually do anything but this is probably a more reasonable default.)


/* Adapted from kloak/src/keycodes.c */
struct name_value {
Expand Down Expand Up @@ -277,7 +276,7 @@ bool bitset_get(const uint64_t *bits, uint32_t i) {
}

void print(int fd, const char *str) {
size_t len = strlen(str) + 1;
size_t len = strlen(str);
Comment on lines -280 to +279
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Already applied from an earlier PR.

while (true) {
ssize_t write_len = write(fd, str, len);
if (write_len < 0) {
Expand Down Expand Up @@ -384,6 +383,7 @@ void load_list(const char *arg, size_t *result_list_len_ref, char ***result_list

arg_part = strtok(arg_val, sep);
if (arg_part == NULL) {
free(arg_copy);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Accepted.

return;
}

Expand All @@ -392,7 +392,7 @@ void load_list(const char *arg, size_t *result_list_len_ref, char ***result_list
result_list = safe_reallocarray(result_list, result_list_len, sizeof(char *));
result_list[result_list_len - 1] = safe_calloc(1, strlen(arg_part) + 1);
strcpy(result_list[result_list_len - 1], arg_part);
} while ((arg_part = strtok(NULL, ",")) != NULL);
} while ((arg_part = strtok(NULL, sep)) != NULL);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Already applied from an earlier PR.


*result_list_len_ref = result_list_len;
*result_list_ref = result_list;
Expand Down Expand Up @@ -691,13 +691,15 @@ void hw_monitor(int argc, char **argv) {
}

for (pkl_idx = 0; pkl_idx < panic_key_list_len; pkl_idx++) {
bool group_supported = false;
for (kg_idx = 0; panic_key_list[pkl_idx][kg_idx] != 0; kg_idx++) {
if (!bitset_get(key_flags, panic_key_list[pkl_idx][kg_idx])) {
supports_panic = false;
if (bitset_get(key_flags, panic_key_list[pkl_idx][kg_idx])) {
group_supported = true;
break;
}
}
if (!supports_panic) {
if (!group_supported) {
supports_panic = false;
Comment on lines +694 to +702
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Accepted.

break;
}
}
Expand Down Expand Up @@ -895,6 +897,7 @@ void hw_monitor(int argc, char **argv) {
if (paranoid_mode) {
/* Something was removed, we don't care what, shut down now */
kill_system();
exit(0);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

exit() was moved into kill_system().

}

for (tdl_idx = 0; tdl_idx < target_dev_list_len; tdl_idx++) {
Expand Down Expand Up @@ -952,6 +955,11 @@ void fifo_monitor(char **argv) {
arg_part = strtok(arg_copy, "=");
/* returns everything after the = sign */
arg_part = strtok(NULL, "");
if (arg_part == NULL) {
print(fd_stderr, "Timeout value is empty!\n");
print_usage();
exit(1);
}
Comment on lines +958 to +962
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Already accepted from an earlier PR.

errno = 0;
monitor_fifo_timeout = strtol(arg_part, &arg_num_end, 10);
if (errno == ERANGE || monitor_fifo_timeout > UINT_MAX) {
Expand Down Expand Up @@ -1051,6 +1059,7 @@ int main(int argc, char **argv) {
}

kill_system();
exit(0);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

exit() was moved into kill_system().

}
if (strcmp(argv[1], "--monitor-fifo") == 0) {
if (argc != 3) {
Expand Down