… | |
… | |
33 | * You should have received a copy of the GNU General Public License |
33 | * You should have received a copy of the GNU General Public License |
34 | * along with this program; if not, write to the Free Software |
34 | * along with this program; if not, write to the Free Software |
35 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
35 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
36 | *----------------------------------------------------------------------*/ |
36 | *----------------------------------------------------------------------*/ |
37 | |
37 | |
38 | #include "../config.h" |
38 | #include "config.h" |
39 | |
39 | |
40 | #include "ptytty.h" |
40 | #include "ptytty.h" |
41 | |
41 | |
42 | #if UTMP_SUPPORT |
42 | #if UTMP_SUPPORT |
43 | |
43 | |
… | |
… | |
162 | strncpy (ll.ll_host, host, sizeof (ll.ll_host)); |
162 | strncpy (ll.ll_host, host, sizeof (ll.ll_host)); |
163 | if (stat (fname, &st) != 0) |
163 | if (stat (fname, &st) != 0) |
164 | return; |
164 | return; |
165 | if (S_ISDIR (st.st_mode)) |
165 | if (S_ISDIR (st.st_mode)) |
166 | { |
166 | { |
167 | sprintf (lastlogfile, "%.*s/%.*s", |
167 | snprintf (lastlogfile, sizeof (lastlogfile), "%s/%s", fname, |
168 | (int)(sizeof (lastlogfile) - sizeof (pwent->pw_name) - 2), fname, |
|
|
169 | (int)sizeof (pwent->pw_name), |
|
|
170 | (!pwent->pw_name || pwent->pw_name[0] == '\0') ? "unknown" |
168 | (!pwent->pw_name || pwent->pw_name[0] == '\0') ? "unknown" |
171 | : pwent->pw_name); |
169 | : pwent->pw_name); |
172 | if ((fd = open (lastlogfile, O_WRONLY | O_CREAT, 0644)) >= 0) |
170 | if ((fd = open (lastlogfile, O_WRONLY | O_CREAT, 0644)) >= 0) |
173 | { |
171 | { |
174 | write (fd, &ll, sizeof (ll)); |
172 | write (fd, &ll, sizeof (ll)); |