diff options
author | Ed Schouten <ed@80386.nl> | 2011-06-22 00:36:41 +0200 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-06-24 20:56:31 -0700 |
commit | eb6eb771ff9f53c56bd60f28c5598eee9e2fb9b2 (patch) | |
tree | 6fef58f5af0588ffba6216b2b0f2b6edd6b2811a /sessreg.c | |
parent | aad7bed11410413b186e0d5af1783686405b47e6 (diff) |
Only split off /dev/ instead trimming to last /.
This prevents pseudo-terminals with names like /dev/pts/0 from getting
trimmed to just 0 instead of pts/0.
Signed-off-by: Ed Schouten <ed@80386.nl>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'sessreg.c')
-rw-r--r-- | sessreg.c | 10 |
1 files changed, 3 insertions, 7 deletions
@@ -188,7 +188,6 @@ main (int argc, char **argv) #if defined(USE_UTMP) && !defined(SYSV) int utmp; #endif - char *line_tmp; #ifndef USE_UTMPX int wtmp; #endif @@ -287,12 +286,9 @@ main (int argc, char **argv) } #endif if (!lflag) { - sysnerr ((line_tmp = ttyname (0)) != NULL, "ttyname"); - line = strrchr(line_tmp, '/'); - if (line) - line = line + 1; - else - line = line_tmp; + sysnerr ((line = ttyname (0)) != NULL, "ttyname"); + if (strncmp(line, "/dev/", 5) == 0) + line += 5; } time (¤t_time); #ifdef USE_UTMP |