cfgetispeed(a) != cfgetispeed(b) || cfgetospeed(a) != cfgetospeed(b))
return 1;
return memcmp(a->c_cc, b->c_cc, sizeof(a->c_cc));
-}
+}
int get_serial_speed(int fd) {
struct termios mode;
-
+
if (!tcgetattr(fd, &mode)) {
int i;
speed_t speed;
-
+
speed = cfgetospeed(&mode);
for (i = 0; speed_map[i].value != 0; i++)
if (speed_map[i].speed == speed)
int emit_console_event(char *dev, int speed) {
char *args[] = { "initctl", "emit", "--no-wait", "serial-console-available", NULL, NULL, NULL };
-
+
args[4] = dev;
if (speed)
asprintf(&args[5],"%d",speed);
execv("/sbin/initctl", args);
- return 1;
+ return 1;
}
int main(int argc, char **argv) {
char *device;
int speed;
-
+
if (argc < 2) {
printf("usage: console_check <device>\n");
exit(1);
int fd;
struct flock lock;
struct sigaction act, oldact;
-
+
lock.l_type = F_WRLCK;
lock.l_whence = SEEK_SET;
lock.l_start = 0;
lock.l_len = 0;
-
+
fd = open("/etc/securetty", O_RDWR);
if (fd == -1) {
syslog(LOG_ERR, "Couldn't open /etc/securetty: %s",strerror(errno));
int fd;
char *buf, *pos;
struct stat sbuf;
-
+
fd = open_and_lock_securetty();
if (fd == -1)
return 1;