ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/logging.C
(Generate patch)

Comparing rxvt-unicode/src/logging.C (file contents):
Revision 1.46 by root, Mon May 5 16:51:52 2008 UTC vs.
Revision 1.49 by root, Mon Feb 21 07:41:02 2011 UTC

15 * Copyright (c) 1997 Raul Garcia Garcia <rgg@tid.es> 15 * Copyright (c) 1997 Raul Garcia Garcia <rgg@tid.es>
16 * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> 16 * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com>
17 * - extensive modifications 17 * - extensive modifications
18 * Copyright (c) 1999 D J Hawkey Jr <hawkeyd@visi.com> 18 * Copyright (c) 1999 D J Hawkey Jr <hawkeyd@visi.com>
19 * - lastlog support 19 * - lastlog support
20 * Copyright (c) 2004-2006 Marc Lehmann <pcg@goof.com> 20 * Copyright (c) 2004-2006 Marc Lehmann <schmorp@schmorp.de>
21 * Copyright (c) 2006 Emanuele Giaquinta <e.giaquinta@glauco.it> 21 * Copyright (c) 2006 Emanuele Giaquinta <e.giaquinta@glauco.it>
22 * 22 *
23 * This program is free software; you can redistribute it and/or modify 23 * This program is free software; you can redistribute it and/or modify
24 * it under the terms of the GNU General Public License as published by 24 * it under the terms of the GNU General Public License as published by
25 * the Free Software Foundation; either version 2 of the License, or 25 * the Free Software Foundation; either version 2 of the License, or
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
44#include <cstdio> 44#include <cstdio>
45#include <cstring>
45 46
46#include <sys/types.h> 47#include <sys/types.h>
47#include <sys/stat.h> 48#include <sys/stat.h>
48#include <fcntl.h> 49#include <fcntl.h>
49#include <unistd.h> 50#include <unistd.h>
161 strncpy (ll.ll_host, host, sizeof (ll.ll_host)); 162 strncpy (ll.ll_host, host, sizeof (ll.ll_host));
162 if (stat (fname, &st) != 0) 163 if (stat (fname, &st) != 0)
163 return; 164 return;
164 if (S_ISDIR (st.st_mode)) 165 if (S_ISDIR (st.st_mode))
165 { 166 {
166 sprintf (lastlogfile, "%.*s/%.*s", 167 snprintf (lastlogfile, sizeof (lastlogfile), "%s/%s", fname,
167 (int)(sizeof (lastlogfile) - sizeof (pwent->pw_name) - 2), fname,
168 (int)sizeof (pwent->pw_name),
169 (!pwent->pw_name || pwent->pw_name[0] == '\0') ? "unknown" 168 (!pwent->pw_name || pwent->pw_name[0] == '\0') ? "unknown"
170 : pwent->pw_name); 169 : pwent->pw_name);
171 if ((fd = open (lastlogfile, O_WRONLY | O_CREAT, 0644)) >= 0) 170 if ((fd = open (lastlogfile, O_WRONLY | O_CREAT, 0644)) >= 0)
172 { 171 {
173 write (fd, &ll, sizeof (ll)); 172 write (fd, &ll, sizeof (ll));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines