[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: screen says "Bad tty" if /dev/console is a symlink



> I guess you meant PATH_MAX here, in any case POSIX does not guarantee
> MAX variables to be defined, it would be better to use the POSIX.1-2008
> variant of realpath(3) that allocates when passed a NULL (by checking
> if it's available at configure time).

I thought my libc did not support it, but now I see even
canonicalize_file_name() o_O


> I don't understand why do you a realpath() here depending on the
> number of hard links.

Me too, but original code has "(st.st_nlink > 1 && strncmp(tty, "/dev/", 5))",
so if number of links == 1, then there is no pathname check.
No path check -> No realpath mess.

> Otherwise if this function
> is called on something like ttyname(3)'s return value, then changing
> this function is the correct thing to do.

Yes, CheckTtyname() is used with the value returned by ttyname() :
===== screen.cc =======
 978 #define SET_TTYNAME(fatal) do \
 979   { \
 980     if (!(attach_tty = ttyname(0))) \
 981       { \
 982     if (fatal) \
 983       Panic(0, "Must be connected to a terminal."); \
 984     else \
 985       attach_tty = ""; \
 986       } \
 987     else \
 988       { \
 989     if (stat(attach_tty, &st)) \
 990       Panic(errno, "Cannot access '%s'", attach_tty); \
 991     if (CheckTtyname(attach_tty)) \
 992       Panic(0, "Bad tty '%s'", attach_tty); \
 993       } \
 994     if (strlen(attach_tty) >= MAXPATHLEN) \
 995       Panic(0, "TtyName too long - sorry."); \
 996   } while (0)


Reply to: