]> git.pld-linux.org Git - packages/libutempter.git/blob - utempter-lastlog.patch
- rel 10
[packages/libutempter.git] / utempter-lastlog.patch
1 diff -ur utempter-0.5.2.orig/utempter.c utempter-0.5.2/utempter.c
2 --- utempter-0.5.2.orig/utempter.c      Thu Apr  8 18:19:36 1999
3 +++ utempter-0.5.2/utempter.c   Fri May  5 04:19:51 2000
4 @@ -88,6 +88,8 @@
5      int i;
6      struct stat sb;
7      char * id;
8 +    int fd;
9 +    struct lastlog ll;
10   
11      if (argc < 3) usage();
12  
13 @@ -115,6 +117,7 @@
14         host = NULL;
15      }
16  
17 +    memset(&ll, 0, sizeof(ll));
18      memset(&utx, 0, sizeof(utx));
19      if (add)
20         utx.ut_type = USER_PROCESS;
21 @@ -130,6 +133,7 @@
22      checkDevice(device);
23  
24      strncpy(utx.ut_line, device + 5, sizeof(utx.ut_line));
25 +    strncpy(ll.ll_line, device + 5, sizeof(ll.ll_line));
26  
27      pw = getpwuid(getuid());
28      if (!pw) {
29 @@ -139,8 +143,10 @@
30  
31      strncpy(utx.ut_user, pw->pw_name, sizeof(utx.ut_user));
32  
33 -    if (host) 
34 +    if (host) {
35         strncpy(utx.ut_host, host, sizeof(utx.ut_host));
36 +       strncpy(ll.ll_host, host, sizeof(ll.ll_host));
37 +    }
38  
39      if (!strncmp("pts/", utx.ut_line, 4)) {
40         id = utx.ut_line + 3;
41 @@ -152,9 +158,16 @@
42      strncpy(utx.ut_id, id, sizeof(utx.ut_id));
43  
44      gettimeofday(&utx.ut_tv, NULL);
45 +    ll.ll_time = time(NULL);
46  
47      pututxline(&utx);
48      updwtmpx(_PATH_WTMP, &utx);
49 +
50 +    if ((fd = open(_PATH_LASTLOG, O_RDWR)) != -1) {
51 +       lseek(fd, (off_t) ((long)pw->pw_uid * sizeof(ll)), SEEK_SET);
52 +       write(fd, &ll, sizeof(ll));
53 +       close(fd);
54 +    }
55  
56      return 0;
57  }
This page took 0.064243 seconds and 3 git commands to generate.