[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    [PATCH] Repair konsole on USE_LOGIN systems
From:       Marc Espie <espie () schutzenberger ! liafa ! jussieu ! fr>
Date:       2000-11-24 16:51:35
[Download RAW message or body]

The following patch repairs konsole on OpenBSD, and almost certainly other
USE_LOGIN systems.

Note the typo: ttyname(0).

This does prevent konsole to run on any situation where stdin is not a tty,
such as when launching konsole from xdm/kdm.

At the least, this line should be fixed in kde 2.0.1

The rest is there to fill the utmp entry completely (strip /dev/ from
ttynames entries, you'll see that xterm does the same thing, and fill
ut_time). I'm not 100% sure all utmp work the same.

On the other hand, there is a missing patch here: konsole also needs
elevated privileges on many systems to write to utmp.

But reading konsole's code, it drops all privileges in main(), and later
in makePty, right after registering this.

Since this code is old enough to have been in the cvs repository forever,
I don't know why the privileges are dropped twice.

In any case, on OpenBSD, it's enough to drop the privileges after filling
utmp. This is mostly harmless though, as said privileges are setgid utmp.


--- TEPty.C.orig	Fri Nov 24 17:37:36 2000
+++ TEPty.C	Fri Nov 24 17:40:51 2000
@@ -227,7 +227,11 @@ void TEPty::donePty()
 #elif defined(USE_LOGIN)
   char *tty_name=ttyname(0);
   if (tty_name)
+  {
+	  if (strncmp(tty_name, "/dev/", 5) == 0)
+		tty_name += 5;
         logout(tty_name);
+  }
 #endif
   if (needGrantPty) chownpty(fd,FALSE);
   emit done(status);
@@ -442,10 +446,13 @@ void TEPty::makePty(const char* dev, con
      l_struct.ut_host[UT_HOSTSIZE]=0;
   }
 
-  if (! (str_ptr=ttyname(0)) ) {
+  if (! (str_ptr=ttyname(tt)) ) {
     abort();
   }
+  if (strncmp(str_ptr, "/dev/", 5) == 0)
+  	str_ptr += 5;
   strncpy(l_struct.ut_line, str_ptr, UT_LINESIZE);
+  time(&l_struct.ut_time);
 
   login(&l_struct);
 #endif

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic