Sisyphus repository
Last update: 18 august 2018 | SRPMs: 18645 | Visits: 12093605
en ru br
ALT Linux repos
S:0.60-alt35
5.0: 0.60-alt26
4.1: 0.60-alt25
4.0: 0.60-alt25
3.0: 0.60-alt22

Group :: System/Base
RPM: SimplePAMApps

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

Patch: SimplePAMApps-0.60-owl-alt-login-su-ut_id.patch
Download


diff -uprk.orig SimplePAMApps-0.60.orig/common/lib/wtmp.c SimplePAMApps-0.60/common/lib/wtmp.c
--- SimplePAMApps-0.60.orig/common/lib/wtmp.c	1999-01-27 19:27:16 +0300
+++ SimplePAMApps-0.60/common/lib/wtmp.c	2004-02-08 20:01:56 +0300
@@ -3,9 +3,6 @@
  */
 
 #define RHOST_UNKNOWN_NAME        ""     /* perhaps "[from.where?]" */
-
-#define DEVICE_FILE_PREFIX        "/dev/"
-
 #define WTMP_LOCK_TIMEOUT         3      /* in seconds */
 
 #include <fcntl.h>
@@ -41,19 +38,31 @@
  */
 
 static
-const struct utmp *find_utmp_entry(const char *ut_line
-        , const char *ut_id)
+const struct utmp *find_utmp_entry(const char *ut_line, char *ut_id)
 {
-    struct utmp *u_tmp_p;
+    struct utmp *u_tmp_p, *best;
 
+    setutent();
+    best = NULL;
     while ((u_tmp_p = getutent()) != NULL)
 	if ((u_tmp_p->ut_type == INIT_PROCESS ||
-             u_tmp_p->ut_type == LOGIN_PROCESS ||
-             u_tmp_p->ut_type == USER_PROCESS ||
-             u_tmp_p->ut_type == DEAD_PROCESS) &&
-            !strncmp(u_tmp_p->ut_id, ut_id, UT_IDSIZE) &&
-            !strncmp(u_tmp_p->ut_line, ut_line, UT_LINESIZE))
-                break;
+	     u_tmp_p->ut_type == LOGIN_PROCESS ||
+	     u_tmp_p->ut_type == USER_PROCESS) &&
+	    !strncmp(u_tmp_p->ut_line, ut_line, UT_LINESIZE)) {
+	    if (!strncmp(u_tmp_p->ut_id, ut_id, UT_IDSIZE))
+		break;
+	    best = u_tmp_p;
+	}
+
+    if (!u_tmp_p && best) {
+	u_tmp_p = best;
+	strncpy(ut_id, u_tmp_p->ut_id, UT_IDSIZE);
+    }
+
+#if 0
+    fprintf(stderr, "find_utmp_entry: '%.32s' '%.4s': %p\n",
+	ut_line, ut_id, u_tmp_p);
+#endif
 
     return u_tmp_p;
 }
@@ -72,11 +81,11 @@ void set_terminal_name(const char *termi
     if ( *terminal == '/' ) {     /* now deal with filenames */
 	int o1, o2;
 
-	o1 = strncmp(DEVICE_FILE_PREFIX, terminal, 5) ? 0 : 5;
+	o1 = strncmp("/dev/", terminal, 5) ? 0 : 5;
 	if (!strncmp("/dev/tty", terminal, 8)) {
 	    o2 = 8;
 	} else {
-	    o2 = strlen(terminal) - sizeof(UT_IDSIZE);
+	    o2 = (int)strlen(terminal) - UT_IDSIZE;
 	    if (o2 < 0)
 		o2 = 0;
 	}
@@ -203,7 +212,6 @@ int utmp_do_open_session(const char *use
     set_terminal_name(terminal, ut_line, ut_id);
 
     utmpname(_PATH_UTMP);
-    setutent();                                           /* rewind file */
     u_tmp_p = find_utmp_entry(ut_line, ut_id);
 
     /* reset new entry */
 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin