]> git.pld-linux.org Git - packages/proftpd.git/blame - proftpd-wtmp.patch
- added Obsolete: glftpd
[packages/proftpd.git] / proftpd-wtmp.patch
CommitLineData
8db28cde
PG
1--- ./src/log.c.org Sun Oct 21 21:11:04 2001
2+++ ./src/log.c Sun Oct 21 21:20:07 2001
c8b81d76 3@@ -131,26 +131,16 @@
12bef652 4
c8b81d76
TO
5 int log_wtmp(char *line, const char *name, const char *host,
6 pr_netaddr_t *ip) {
12bef652
JR
7- struct stat buf;
8 struct utmp ut;
728c4cc1
JR
9 int res = 0;
10- static int fd = -1;
8db28cde 11
12bef652
JR
12-#if (defined(SVR4) || defined(__SVR4)) && \
13- !(defined(LINUX) || defined(__hpux) || defined (_AIX))
ff5ecb89 14- /* This "auxilliary" utmp doesn't exist under linux. */
8db28cde
PG
15-#ifdef __sparcv9
16- struct futmpx utx;
17- time_t t;
18-#else
ff5ecb89 19- struct utmpx utx;
8db28cde 20-#endif
12bef652 21- static int fdx = -1;
8db28cde
PG
22+ static int washere = 0;
23
4c6dc458
TO
24- if (fdx < 0 && (fdx = open(WTMPX_FILE, O_WRONLY|O_APPEND, 0)) < 0) {
25- log_pri(PR_LOG_WARNING, "wtmpx %s: %s", WTMPX_FILE, strerror(errno));
728c4cc1
JR
26- return -1;
27- }
12bef652
JR
28+ if (!washere) {
29+ utmpname(_PATH_WTMP);
30+ washere = 1;
31+ } else
32+ washere = 0;
8db28cde 33
12bef652
JR
34 /* Unfortunately, utmp string fields are terminated by '\0' if they are
35 * shorter than the size of the field, but if they are exactly the size of
c8b81d76 36@@ -158,43 +148,7 @@
12bef652
JR
37 * Insane if you ask me. Unless there's massive uproar, I prefer to err on
38 * the side of caution and always null-terminate our strings.
39 */
4c6dc458 40- if (fstat(fdx,&buf) == 0) {
ff5ecb89
JR
41- memset(&utx,0,sizeof(utx));
42- sstrncpy(utx.ut_user,name,sizeof(utx.ut_user));
4c6dc458 43- sstrncpy(utx.ut_id, "ftp",sizeof(utx.ut_user));
ff5ecb89
JR
44- sstrncpy(utx.ut_line,line,sizeof(utx.ut_line));
45- sstrncpy(utx.ut_host,host,sizeof(utx.ut_host));
d5bd2d19 46- utx.ut_syslen = strlen(utx.ut_host)+1;
ff5ecb89 47- utx.ut_pid = getpid();
8db28cde
PG
48-#ifdef __sparcv9
49- time(&t);
50- utx.ut_tv.tv_sec = (time32_t)t;
51-#else
ff5ecb89 52- time(&utx.ut_tv.tv_sec);
8db28cde 53-#endif
4c6dc458 54- if (*name)
ff5ecb89
JR
55- utx.ut_type = USER_PROCESS;
56- else
57- utx.ut_type = DEAD_PROCESS;
4c6dc458 58-#ifdef HAVE_UT_UT_EXIT
ff5ecb89
JR
59- utx.ut_exit.e_termination = 0;
60- utx.ut_exit.e_exit = 0;
4c6dc458
TO
61-#endif /* HAVE_UT_UT_EXIT */
62- if (write(fdx, (char *)&utx,sizeof(utx)) != sizeof(utx))
728c4cc1
JR
63- ftruncate(fdx, buf.st_size);
64- } else {
4c6dc458 65- log_debug(DEBUG0, "%s fstat(): %s",WTMPX_FILE,strerror(errno));
728c4cc1
JR
66- res = -1;
67- }
12bef652
JR
68-
69-#else /* Non-SVR4 systems */
70-
4c6dc458
TO
71- if (fd < 0 && (fd = open(WTMP_FILE,O_WRONLY|O_APPEND,0)) < 0) {
72- log_pri(PR_LOG_WARNING, "wtmp %s: %s", WTMP_FILE, strerror(errno));
728c4cc1
JR
73- return -1;
74- }
4c6dc458
TO
75
76- if (fstat(fd,&buf) == 0) {
77 memset(&ut,0,sizeof(ut));
728c4cc1
JR
78 #ifdef HAVE_UTMAXTYPE
79 #ifdef LINUX
c8b81d76 80@@ -227,13 +181,12 @@
728c4cc1
JR
81 #endif /* HAVE_UT_UT_HOST */
82
12bef652 83 time(&ut.ut_time);
4c6dc458 84- if (write(fd, (char *)&ut,sizeof(ut)) != sizeof(ut))
728c4cc1
JR
85- ftruncate(fd,buf.st_size);
86- } else {
4c6dc458 87- log_debug(DEBUG0, "%s fstat(): %s",WTMP_FILE,strerror(errno));
728c4cc1 88- res = -1;
12bef652
JR
89- }
90-#endif /* SVR4 */
91+
92+ setutent();
93+ while ((getutent())) ;
94+ pututline(&ut);
95+ if (!washere)
96+ endutent();
728c4cc1
JR
97
98 return res;
12bef652 99 }
This page took 0.03639 seconds and 4 git commands to generate.