Re: screen says "Bad tty" if /dev/console is a symlink
On Mon, 2013-01-28 at 14:17:13 +0400, Игорь Пашев wrote:
> So, is it ok?
>
> Index: screen/tty.sh
> ===================================================================
> --- screen.orig/tty.sh 2013-01-27 02:16:57.916935245 +0000
> +++ screen/tty.sh 2013-01-27 02:33:12.831241123 +0000
> @@ -1506,11 +1506,21 @@
> char *tty;
> {
> struct stat st;
> + char * real;
> + int rc;
>
> - if (lstat(tty, &st) || !S_ISCHR(st.st_mode) ||
> - (st.st_nlink > 1 && strncmp(tty, "/dev/", 5)))
> + real = realpath(tty, NULL);
> + if (!real)
> return -1;
> - return 0;
> +
> + if (lstat(real, &st) || !S_ISCHR(st.st_mode) ||
> + (st.st_nlink > 1 && strncmp(real, "/dev/", 5)))
(You might want to indent this in the same way as the previous code,
by adding the missing space.)
> + rc = -1;
> + else
> + rc = 0;
> +
> + free(real);
> + return rc;
> }
Looks good to me.
Thanks,
Guillem
Reply to: