char *chroot; /* Chroot before the login */
char *login; /* login program */
char *logopt; /* options for login program */
- char *tty; /* name of tty */
- char *vcline; /* line of virtual console */
+ const char *tty; /* name of tty */
+ const char *vcline; /* line of virtual console */
char *term; /* terminal type */
char *initstring; /* modem init string */
char *issue; /* alternative issue file or directory */
int numspeed; /* number of baud rates to try */
int clocal; /* CLOCAL_MODE_* */
int kbmode; /* Keyboard mode if virtual console */
+ int tty_is_stdin; /* is the tty the standard input stream */
speed_t speeds[MAX_SPEED]; /* baud rates to be tried */
};
static void parse_args(int argc, char **argv, struct options *op);
static void parse_speeds(struct options *op, char *arg);
static void update_utmp(struct options *op);
-static void open_tty(char *tty, struct termios *tp, struct options *op);
+static void open_tty(const char *tty, struct termios *tp, struct options *op);
static void termio_init(struct options *op, struct termios *tp);
static void reset_vc(const struct options *op, struct termios *tp, int canon);
static void auto_baud(struct termios *tp);
}
}
+ /* resolve the tty path in case it was provided as stdin */
+ if (strcmp(op->tty, "-") == 0) {
+ op->tty_is_stdin = 1;
+ int fd = get_terminal_name(NULL, &op->tty, NULL);
+ if (fd < 0) {
+ log_warn(_("could not get terminal name: %d"), fd);
+ }
+ }
+
/* On virtual console remember the line which is used for */
if (strncmp(op->tty, "tty", 3) == 0 &&
strspn(op->tty + 3, "0123456789") == strlen(op->tty+3))
time_t t;
pid_t pid = getpid();
pid_t sid = getsid(0);
- char *vcline = op->vcline;
- char *line = op->tty;
+ const char *vcline = op->vcline;
+ const char *line = op->tty;
struct utmpx *utp;
/*
str2memcpy(ut.ut_id, vcline, sizeof(ut.ut_id));
else {
size_t len = strlen(line);
- char * ptr;
+ const char * ptr;
if (len >= sizeof(ut.ut_id))
ptr = line + len - sizeof(ut.ut_id);
else
#endif /* SYSV_STYLE */
/* Set up tty as stdin, stdout & stderr. */
-static void open_tty(char *tty, struct termios *tp, struct options *op)
+static void open_tty(const char *tty, struct termios *tp, struct options *op)
{
const pid_t pid = getpid();
int closed = 0;
/* Set up new standard input, unless we are given an already opened port. */
- if (strcmp(tty, "-") != 0) {
+ if (!op->tty_is_stdin) {
char buf[PATH_MAX+1];
struct group *gr = NULL;
struct stat st;