View | Details | Raw Unified | Return to bug 3580
Collapse All | Expand All

(-)SimplePAMApps-0.60.orig/common/lib/wtmp.c (-15 / +23 lines)
Lines 3-11 Link Here
3
 */
3
 */
4
4
5
#define RHOST_UNKNOWN_NAME        ""     /* perhaps "[from.where?]" */
5
#define RHOST_UNKNOWN_NAME        ""     /* perhaps "[from.where?]" */
6
7
#define DEVICE_FILE_PREFIX        "/dev/"
8
9
#define WTMP_LOCK_TIMEOUT         3      /* in seconds */
6
#define WTMP_LOCK_TIMEOUT         3      /* in seconds */
10
7
11
#include <fcntl.h>
8
#include <fcntl.h>
Lines 41-59 Link Here
41
 */
38
 */
42
39
43
static
40
static
44
const struct utmp *find_utmp_entry(const char *ut_line
41
const struct utmp *find_utmp_entry(const char *ut_line, char *ut_id)
45
        , const char *ut_id)
46
{
42
{
47
    struct utmp *u_tmp_p;
43
    struct utmp *u_tmp_p, *best;
48
44
45
    setutent();
46
    best = NULL;
49
    while ((u_tmp_p = getutent()) != NULL)
47
    while ((u_tmp_p = getutent()) != NULL)
50
	if ((u_tmp_p->ut_type == INIT_PROCESS ||
48
	if ((u_tmp_p->ut_type == INIT_PROCESS ||
51
             u_tmp_p->ut_type == LOGIN_PROCESS ||
49
	     u_tmp_p->ut_type == LOGIN_PROCESS ||
52
             u_tmp_p->ut_type == USER_PROCESS ||
50
	     u_tmp_p->ut_type == USER_PROCESS) &&
53
             u_tmp_p->ut_type == DEAD_PROCESS) &&
51
	    !strncmp(u_tmp_p->ut_line, ut_line, UT_LINESIZE)) {
54
            !strncmp(u_tmp_p->ut_id, ut_id, UT_IDSIZE) &&
52
	    if (!strncmp(u_tmp_p->ut_id, ut_id, UT_IDSIZE))
55
            !strncmp(u_tmp_p->ut_line, ut_line, UT_LINESIZE))
53
		break;
56
                break;
54
	    best = u_tmp_p;
55
	}
56
57
    if (!u_tmp_p && best) {
58
	u_tmp_p = best;
59
	strncpy(ut_id, u_tmp_p->ut_id, UT_IDSIZE);
60
    }
61
62
#if 0
63
    fprintf(stderr, "find_utmp_entry: '%.32s' '%.4s': %p\n",
64
	ut_line, ut_id, u_tmp_p);
65
#endif
57
66
58
    return u_tmp_p;
67
    return u_tmp_p;
59
}
68
}
Lines 72-82 void set_terminal_name(const char *termi Link Here
72
    if ( *terminal == '/' ) {     /* now deal with filenames */
81
    if ( *terminal == '/' ) {     /* now deal with filenames */
73
	int o1, o2;
82
	int o1, o2;
74
83
75
	o1 = strncmp(DEVICE_FILE_PREFIX, terminal, 5) ? 0 : 5;
84
	o1 = strncmp("/dev/", terminal, 5) ? 0 : 5;
76
	if (!strncmp("/dev/tty", terminal, 8)) {
85
	if (!strncmp("/dev/tty", terminal, 8)) {
77
	    o2 = 8;
86
	    o2 = 8;
78
	} else {
87
	} else {
79
	    o2 = strlen(terminal) - sizeof(UT_IDSIZE);
88
	    o2 = (int)strlen(terminal) - UT_IDSIZE;
80
	    if (o2 < 0)
89
	    if (o2 < 0)
81
		o2 = 0;
90
		o2 = 0;
82
	}
91
	}
Lines 203-209 int utmp_do_open_session(const char *use Link Here
203
    set_terminal_name(terminal, ut_line, ut_id);
212
    set_terminal_name(terminal, ut_line, ut_id);
204
213
205
    utmpname(_PATH_UTMP);
214
    utmpname(_PATH_UTMP);
206
    setutent();                                           /* rewind file */
207
    u_tmp_p = find_utmp_entry(ut_line, ut_id);
215
    u_tmp_p = find_utmp_entry(ut_line, ut_id);
208
216
209
    /* reset new entry */
217
    /* reset new entry */

Return to bug 3580