summaryrefslogtreecommitdiff
path: root/x11/kdebase11/files/patch-ao
blob: 21845750507c3c91d2ce8c27f1b7d8769f918b7a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
*** kvt/utmp.c.orig	Sun Aug 10 08:43:56 1997
--- kvt/utmp.c	Sun Sep 13 13:42:02 1998
***************
*** 60,65 ****
--- 60,70 ----
  #include <utmp.h>
  #include <unistd.h>
  
+ #define UTMP_SUPPORT 1
+ #define HAVE_UTIL 1
+ #define USE_LASTLOG 1
+ #define USE_TTYENT 1
+ 
  #ifdef HAVE_LASTLOG_H
  #include <lastlog.h>
  #endif
***************
*** 73,78 ****
--- 78,95 ----
  #include <stdio.h>
  #include <memory.h>
  
+ #if USE_LASTLOG
+ # include <paths.h>
+ #endif /* USE_LASTLOG */
+ 
+ #if USE_TTYENT
+ # include <ttyent.h>
+ #endif /* USE_TTYENT */
+ 
+ #if HAVE_UTIL
+ #include <sys/param.h>
+ #endif /* HAVE_UTIL */
+ 
  void cleanutent(void);
  void makeutent(char *);
  
***************
*** 118,130 ****
   **************************************************************************/
  int utmp_pos; /* position of utmp-stamp */
  
- 
  /*
   * on Sparcs login/logouts are logged at /var/adm/wtmp
   * but talk(d)/finger only look at /etc/utmp
   */
  #ifndef UTMP
! #define UTMP "/etc/utmp"
  #endif
  
  #ifndef USER_PROCESS
--- 135,146 ----
   **************************************************************************/
  int utmp_pos; /* position of utmp-stamp */
  
  /*
   * on Sparcs login/logouts are logged at /var/adm/wtmp
   * but talk(d)/finger only look at /etc/utmp
   */
  #ifndef UTMP
! #define UTMP _PATH_UTMP
  #endif
  
  #ifndef USER_PROCESS
***************
*** 143,148 ****
--- 159,166 ----
   *************************************************************************/
  #ifdef BSD
  
+ char global_ut_line[UT_LINESIZE];
+ 
  /**************************************************************************
   * get_tslot() - grabbed from xvt-1.0 - modified by David Perry
   *
***************
*** 156,162 ****
    char buf[200], name[200];
    int i;
    
!   if ((fs = fopen(TTYTAB,"r")) == NULL)
      return(-1);
    i = 1;
    while (fgets(buf,200,fs) != NULL) 
--- 174,180 ----
    char buf[200], name[200];
    int i;
    
!   if ((fs = fopen(_PATH_TTYS,"r")) == NULL)
      return(-1);
    i = 1;
    while (fgets(buf,200,fs) != NULL) 
***************
*** 182,187 ****
--- 200,215 ----
  int write_utmp(char *ttyname, struct utmp * u) 
  {
    FILE *utmp;
+ #if USE_LASTLOG
+     FILE *llfp;
+     struct lastlog ll;
+ #endif /* USE_LASTLOG */
+ #if HAVE_UTIL
+     extern char *display_name;
+     char *p;
+     char wthost[MAXHOSTNAMELEN];
+ #endif /* HAVE_UTIL */
+ 
    if((utmp = fopen(UTMP,"r+")) == NULL)
      return -1;
    utmp_pos = get_tslot(ttyname) * sizeof(struct utmp);
***************
*** 191,196 ****
--- 219,253 ----
    fwrite((char *)u, sizeof(struct utmp),1,utmp);
    fclose(utmp);
    madeutent = 1;
+ 
+ #if USE_LASTLOG
+     /* make a lastlog entry */
+     ll.ll_time = (time_t) u->ut_time;
+     (void) strncpy(ll.ll_line, u->ut_line, sizeof ll.ll_line - 1);
+     ll.ll_line[sizeof ll.ll_line - 1] = '\0';
+     (void) strncpy(ll.ll_host, u->ut_host, sizeof ll.ll_host - 1);
+     ll.ll_host[sizeof ll.ll_host - 1] = '\0';
+     llfp = fopen(_PATH_LASTLOG, "a+");
+     if (llfp) {
+         (void) fseek(llfp, getuid(), 0);
+         (void) fwrite(&ll, sizeof ll, 1, llfp);
+         (void) fclose(llfp);
+     }
+ #endif /* USE_LASTLOG */
+ 
+ #if HAVE_UTIL
+     /* save ut_line for later */
+     (void) strncpy(global_ut_line, u->ut_line, sizeof global_ut_line);
+ 
+     /* finally, log the entry to wtmp */
+     (void) strncpy(wthost, display_name, sizeof wthost - 1);
+     wthost[sizeof wthost - 1] = '\0';
+     p = strchr(wthost, ':');
+     if (p)
+         *p = '\0';
+     logwtmp(global_ut_line, u->ut_name, wthost);
+ #endif /* HAVE_UTIL */
+ 
    return(utmp_pos);
  }
  
***************
*** 250,255 ****
--- 307,313 ----
    memset(&u,0,sizeof(u));
    fwrite((char *)&u,sizeof(struct utmp),1,ut);
    fclose(ut);
+     logwtmp(global_ut_line, "", "");
  }