]> git.pld-linux.org Git - packages/util-linux.git/blob - util-linux-login.patch
stado plomb na util-linuxa
[packages/util-linux.git] / util-linux-login.patch
1 diff -Nur util-linux-2.9r/login-utils/login.c util-linux-2.9r.pld/login-utils/login.c
2 --- util-linux-2.9r/login-utils/login.c Sun May  2 04:16:35 1999
3 +++ util-linux-2.9r.pld/login-utils/login.c     Sun May 23 13:49:11 1999
4 @@ -154,7 +154,7 @@
5  
6  #define SLEEP_EXIT_TIMEOUT 5
7  
8 -#ifdef __linux__
9 +#ifndef __linux__ /* sami se qrna masakrujcie logi -- ³obuzy jedne */
10  #define DO_PS_FIDDLING
11  #endif
12  
13 @@ -272,6 +272,41 @@
14      return 0;
15  }
16  
17 +#if USE_PAM
18 +#define        _PATH_BTMPX     "/var/log/btmpx"
19 +static void logbtmp(const char *line, const char *username, const char *hostname)
20 +{
21 +       struct utmp ut;
22 +
23 +       memset(&ut, 0, sizeof(ut));
24 +
25 +       strncpy(ut.ut_user, username, sizeof(ut.ut_user));
26 +
27 +       strncpy(ut.ut_id, line + 3, sizeof(ut.ut_id));
28 +       strncpy(ut.ut_line, line, sizeof(ut.ut_line));
29 +       ut.ut_line[sizeof(ut.ut_line)-1] = 0;
30 +
31 +#if defined(_HAVE_UT_TV)
32 +       gettimeofday(&ut.ut_tv, NULL);
33 +#else
34 +       time(&t) ;
35 +       ut.ut_time = t;         /* ut_time is not always a time_t */
36 +#endif
37 +
38 +       ut.ut_type = LOGIN_PROCESS;     /* XXX doesn't matter */
39 +       ut.ut_pid = getpid();
40 +       if (hostname) {
41 +           strncpy(ut.ut_host, hostname, sizeof(ut.ut_host));
42 +           ut.ut_host[sizeof(ut.ut_host)-1] = 0;
43 +           if (hostaddress.h_addr_list)
44 +             memcpy(&ut.ut_addr, hostaddress.h_addr_list[0],
45 +                    sizeof(ut.ut_addr));
46 +       }
47 +       
48 +       updwtmp(_PATH_BTMPX, &ut);
49 +}
50 +#endif /* USE_PAM */
51 +
52  
53  int
54  main(int argc, char **argv)
55 @@ -457,8 +492,6 @@
56      else
57        tty = ttyn;
58      
59 -    openlog("login", LOG_ODELAY, LOG_AUTHPRIV);
60 -
61  #if 0
62      /* other than iso-8859-1 */
63      printf("\033(K");
64 @@ -516,7 +549,8 @@
65                (retcode == PAM_AUTHINFO_UNAVAIL))) {
66             pam_get_item(pamh, PAM_USER, (const void **) &username);
67             syslog(LOG_NOTICE,_("FAILED LOGIN %d FROM %s FOR %s, %s"),
68 -           failcount, hostname, username, pam_strerror(pamh, retcode));
69 +               failcount, hostname, username, pam_strerror(pamh, retcode));
70 +           logbtmp(ttyn + 5, username, hostname);
71             fprintf(stderr,_("Login incorrect\n\n"));
72             pam_set_item(pamh,PAM_USER,NULL);
73             retcode = pam_authenticate(pamh, 0);
74 @@ -525,13 +559,16 @@
75         if (retcode != PAM_SUCCESS) {
76             pam_get_item(pamh, PAM_USER, (const void **) &username);
77  
78 -           if (retcode == PAM_MAXTRIES) 
79 +           if (retcode == PAM_MAXTRIES) {
80                 syslog(LOG_NOTICE,_("TOO MANY LOGIN TRIES (%d) FROM %s FOR "
81                         "%s, %s"), failcount, hostname, username,
82                          pam_strerror(pamh, retcode));
83 -           else
84 +               logbtmp(ttyn + 5, username, hostname);
85 +           } else {
86                 syslog(LOG_NOTICE,_("FAILED LOGIN SESSION FROM %s FOR %s, %s"),
87                         hostname, username, pam_strerror(pamh, retcode));
88 +               logbtmp(ttyn + 5, username, hostname);
89 +           }
90  
91             fprintf(stderr,_("\nLogin incorrect\n"));
92             pam_end(pamh, retcode);
93 @@ -561,8 +598,12 @@
94      retcode = pam_open_session(pamh, 0);
95      PAM_FAIL_CHECK;
96  
97 +    openlog("login", LOG_ODELAY, LOG_AUTHPRIV);
98 +
99  #else /* ! USE_PAM */
100  
101 +    openlog("login", LOG_ODELAY, LOG_AUTHPRIV);
102 +
103      for (cnt = 0;; ask = 1) {
104  #  ifndef __linux__
105         ioctlval = 0;
106 @@ -838,6 +879,20 @@
107                     && utp->ut_type >= INIT_PROCESS
108                     && utp->ut_type <= DEAD_PROCESS)
109                         break;
110 +
111 +       /*
112 +        * XXX If we can't find a pre-existing entry by pid, try by line
113 +        * XXX BSD network daemons may rely on this.
114 +        */
115 +       if (utp == NULL) {
116 +           endutent();
117 +           setutent();
118 +           memset(&ut, 0, sizeof(ut));
119 +           ut.ut_type = LOGIN_PROCESS; /* XXX doesn't matter */
120 +           strncpy(ut.ut_id, ttyn + 8, sizeof(ut.ut_id));
121 +           strncpy(ut.ut_line, ttyn + 5, sizeof(ut.ut_line));
122 +           utp = getutid(&ut);
123 +       }
124         
125         if (utp) {
126             memcpy(&ut, utp, sizeof(ut));
127 @@ -848,14 +903,19 @@
128         /* endutent(); superfluous, error for glibc */
129         
130         if (ut.ut_id[0] == 0)
131 -         strncpy(ut.ut_id, ttyn + 8, sizeof(ut.ut_id));
132 +           strncpy(ut.ut_id, ttyn + 8, sizeof(ut.ut_id));
133         
134         strncpy(ut.ut_user, username, sizeof(ut.ut_user));
135         strncpy(ut.ut_line, ttyn + 5, sizeof(ut.ut_line));
136         ut.ut_line[sizeof(ut.ut_line)-1] = 0;
137 -       time(&t);
138 +
139 +#if defined(_HAVE_UT_TV)
140 +       gettimeofday(&ut.ut_tv, NULL);
141 +#else
142 +       time(&t) ;
143         ut.ut_time = t;         /* ut_time is not always a time_t */
144 -                               /* (we might test #ifdef _HAVE_UT_TV ) */
145 +#endif
146 +
147         ut.ut_type = USER_PROCESS;
148         ut.ut_pid = mypid;
149         if (hostname) {
150 @@ -1068,6 +1128,8 @@
151  #endif
152      signal(SIGINT, SIG_DFL);
153      
154 +    openlog("login", LOG_ODELAY, LOG_AUTHPRIV);
155 +
156      /* discard permissions last so can't get killed and drop core */
157      if(setuid(pwd->pw_uid) < 0 && pwd->pw_uid) {
158         syslog(LOG_ALERT, _("setuid() failed"));
This page took 0.11594 seconds and 4 git commands to generate.