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.42 by ayin, Mon Nov 5 00:50:06 2007 UTC vs.
Revision 1.43 by ayin, Mon Nov 19 11:26:34 2007 UTC

160 if (stat (fname, &st) != 0) 160 if (stat (fname, &st) != 0)
161 return; 161 return;
162 if (S_ISDIR (st.st_mode)) 162 if (S_ISDIR (st.st_mode))
163 { 163 {
164 sprintf (lastlogfile, "%.*s/%.*s", 164 sprintf (lastlogfile, "%.*s/%.*s",
165 sizeof (lastlogfile) - sizeof (pwent->pw_name) - 2, fname, 165 (int)(sizeof (lastlogfile) - sizeof (pwent->pw_name) - 2), fname,
166 sizeof (pwent->pw_name), 166 (int)sizeof (pwent->pw_name),
167 (!pwent->pw_name || pwent->pw_name[0] == '\0') ? "unknown" 167 (!pwent->pw_name || pwent->pw_name[0] == '\0') ? "unknown"
168 : pwent->pw_name); 168 : pwent->pw_name);
169 if ((fd = open (lastlogfile, O_WRONLY | O_CREAT, 0644)) >= 0) 169 if ((fd = open (lastlogfile, O_WRONLY | O_CREAT, 0644)) >= 0)
170 { 170 {
171 write (fd, &ll, sizeof (ll)); 171 write (fd, &ll, sizeof (ll));
178 if (lseek (fd, (off_t) ((long)pwent->pw_uid * sizeof (ll)), 178 if (lseek (fd, (off_t) ((long)pwent->pw_uid * sizeof (ll)),
179 SEEK_SET) != -1) 179 SEEK_SET) != -1)
180 write (fd, &ll, sizeof (ll)); 180 write (fd, &ll, sizeof (ll));
181 close (fd); 181 close (fd);
182 } 182 }
183# endif /* HAVE_STRUCT_LASTLOG */ 183# endif /* HAVE_STRUCT_LASTLOG */
184} 184}
185#endif /* LASTLOG_SUPPORT */ 185#endif /* LASTLOG_SUPPORT */
186 186
187/* ------------------------------------------------------------------------- */ 187/* ------------------------------------------------------------------------- */
188 188
189/* 189/*
190 * make and write utmp and wtmp entries 190 * make and write utmp and wtmp entries
206#ifdef HAVE_STRUCT_UTMPX 206#ifdef HAVE_STRUCT_UTMPX
207 struct utmpx *utx = &this->utx; 207 struct utmpx *utx = &this->utx;
208#endif 208#endif
209 int i; 209 int i;
210 struct passwd *pwent = getpwuid (getuid ()); 210 struct passwd *pwent = getpwuid (getuid ());
211 const char *name = (pwent && pwent->pw_name) ? pwent->pw_name : "?";
211 212
212 if (!strncmp (pty, "/dev/", 5)) 213 if (!strncmp (pty, "/dev/", 5))
213 pty += 5; /* skip /dev/ prefix */ 214 pty += 5; /* skip /dev/ prefix */
214 215
215#if defined(HAVE_UTMP_PID) || defined(HAVE_STRUCT_UTMPX) 216#if defined(HAVE_UTMP_PID) || defined(HAVE_STRUCT_UTMPX)
246 247
247#ifdef HAVE_STRUCT_UTMP 248#ifdef HAVE_STRUCT_UTMP
248 strncpy (ut->ut_line, pty, sizeof (ut->ut_line)); 249 strncpy (ut->ut_line, pty, sizeof (ut->ut_line));
249 ut->ut_time = time (NULL); 250 ut->ut_time = time (NULL);
250# ifdef HAVE_UTMP_PID 251# ifdef HAVE_UTMP_PID
251 strncpy (ut->ut_user, (pwent && pwent->pw_name) ? pwent->pw_name : "?", 252 strncpy (ut->ut_user, name, sizeof (ut->ut_user));
252 sizeof (ut->ut_user));
253 strncpy (ut->ut_id, ut_id, sizeof (ut->ut_id)); 253 strncpy (ut->ut_id, ut_id, sizeof (ut->ut_id));
254 ut->ut_time = time (NULL); 254 ut->ut_time = time (NULL);
255 ut->ut_pid = cmd_pid; 255 ut->ut_pid = cmd_pid;
256# ifdef HAVE_UTMP_HOST 256# ifdef HAVE_UTMP_HOST
257 strncpy (ut->ut_host, hostname, sizeof (ut->ut_host)); 257 strncpy (ut->ut_host, hostname, sizeof (ut->ut_host));
259 ut->ut_type = USER_PROCESS; 259 ut->ut_type = USER_PROCESS;
260 pututline (ut); 260 pututline (ut);
261 endutent (); /* close the file */ 261 endutent (); /* close the file */
262 utmp_pos = 0; 262 utmp_pos = 0;
263# else 263# else
264 strncpy (ut->ut_name, (pwent && pwent->pw_name) ? pwent->pw_name : "?", 264 strncpy (ut->ut_name, name, sizeof (ut->ut_name));
265 sizeof (ut->ut_name));
266# ifdef HAVE_UTMP_HOST 265# ifdef HAVE_UTMP_HOST
267 strncpy (ut->ut_host, hostname, sizeof (ut->ut_host)); 266 strncpy (ut->ut_host, hostname, sizeof (ut->ut_host));
268# endif 267# endif
269# endif 268# endif
270#endif 269#endif
271 270
272#ifdef HAVE_STRUCT_UTMPX 271#ifdef HAVE_STRUCT_UTMPX
273 strncpy (utx->ut_line, pty, sizeof (utx->ut_line)); 272 strncpy (utx->ut_line, pty, sizeof (utx->ut_line));
274 strncpy (utx->ut_user, (pwent && pwent->pw_name) ? pwent->pw_name : "?", 273 strncpy (utx->ut_user, name, sizeof (utx->ut_user));
275 sizeof (utx->ut_user));
276 strncpy (utx->ut_id, ut_id, sizeof (utx->ut_id)); 274 strncpy (utx->ut_id, ut_id, sizeof (utx->ut_id));
277# if HAVE_UTMPX_SESSION 275# if HAVE_UTMPX_SESSION
278 utx->ut_session = getsid (0); 276 utx->ut_session = getsid (0);
279# endif 277# endif
280 utx->ut_tv.tv_sec = time (NULL); 278 utx->ut_tv.tv_sec = time (NULL);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines