source: npl/internetserver/poptop_ppp/patches/ppp-2.4.2-libutil.patch @ c5c522c

gcc484ntopperl-5.22
Last change on this file since c5c522c was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100644
File size: 2.1 KB
  • ppp-2.4.2/pppd/sys-linux.c

    glibc provides logwtmp in libutil, so we'll use that instead.
    
     
    21512151
    21522152/********************************************************************
    21532153 *
    2154  * Update the wtmp file with the appropriate user name and tty device.
    2155  */
    2156 
    2157 void logwtmp (const char *line, const char *name, const char *host)
    2158 {
    2159     struct utmp ut, *utp;
    2160     pid_t  mypid = getpid();
    2161 #if __GLIBC__ < 2
    2162     int    wtmp;
    2163 #endif
    2164 
    2165 /*
    2166  * Update the signon database for users.
    2167  * Christoph Lameter: Copied from poeigl-1.36 Jan 3, 1996
    2168  */
    2169     utmpname(_PATH_UTMP);
    2170     setutent();
    2171     while ((utp = getutent()) && (utp->ut_pid != mypid))
    2172         /* nothing */;
    2173 
    2174     if (utp)
    2175         memcpy(&ut, utp, sizeof(ut));
    2176     else
    2177         /* some gettys/telnetds don't initialize utmp... */
    2178         memset(&ut, 0, sizeof(ut));
    2179 
    2180     if (ut.ut_id[0] == 0)
    2181         strncpy(ut.ut_id, line + 3, sizeof(ut.ut_id));
    2182 
    2183     strncpy(ut.ut_user, name, sizeof(ut.ut_user));
    2184     strncpy(ut.ut_line, line, sizeof(ut.ut_line));
    2185 
    2186     time(&ut.ut_time);
    2187 
    2188     ut.ut_type = USER_PROCESS;
    2189     ut.ut_pid  = mypid;
    2190 
    2191     /* Insert the host name if one is supplied */
    2192     if (*host)
    2193         strncpy (ut.ut_host, host, sizeof(ut.ut_host));
    2194 
    2195     /* Insert the IP address of the remote system if IP is enabled */
    2196     if (ipcp_protent.enabled_flag && ipcp_hisoptions[0].neg_addr)
    2197         memcpy(&ut.ut_addr, (char *) &ipcp_hisoptions[0].hisaddr,
    2198                  sizeof(ut.ut_addr));
    2199 
    2200     /* CL: Makes sure that the logout works */
    2201     if (*host == 0 && *name==0)
    2202         ut.ut_host[0]=0;
    2203 
    2204     pututline(&ut);
    2205     endutent();
    2206 /*
    2207  * Update the wtmp file.
    2208  */
    2209 #if __GLIBC__ >= 2
    2210     updwtmp(_PATH_WTMP, &ut);
    2211 #else
    2212     wtmp = open(_PATH_WTMP, O_APPEND|O_WRONLY);
    2213     if (wtmp >= 0) {
    2214         flock(wtmp, LOCK_EX);
    2215 
    2216         if (write (wtmp, (char *)&ut, sizeof(ut)) != sizeof(ut))
    2217             warn("error writing %s: %m", _PATH_WTMP);
    2218 
    2219         flock(wtmp, LOCK_UN);
    2220 
    2221         close (wtmp);
    2222     }
    2223 #endif
    2224 }
    2225 
    2226 
    2227 /********************************************************************
    2228  *
    22292154 * sifvjcomp - config tcp header compression
    22302155 */
    22312156
Note: See TracBrowser for help on using the repository browser.