• Bug#265910: putty: FTBFS on amd64: time(&utmp_entry.ut_time) has wrong

    From Kurt Roeckx@1:229/2 to All on Sun Aug 15 19:20:06 2004
    From: [email protected]

    Package: putty
    Version: 0.55-1
    Tags: patch

    Putty fails to build on amd64 because of 32bit compatiblity in
    ut_tv.

    From /usr/include/bits/utmp.h:
    /* The ut_session and ut_tv fields must be the same size when
    * compiled
    32- and 64-bit. This allows data files and shared memory to be
    shared between 32- and 64-bit applications. */
    #if __WORDSIZE == 64 && defined __WORDSIZE_COMPAT32
    int32_t ut_session; /* Session ID, used for
    windowing. */
    struct
    {
    int32_t tv_sec; /* Seconds. */
    int32_t tv_usec; /* Microseconds. */
    } ut_tv; /* Time entry was made. */
    #else
    long int ut_session; /* Session ID, used for
    windowing. */
    struct timeval ut_tv; /* Time entry was made. */
    #endif
    [...]
    # define ut_time ut_tv.tv_sec


    So in the call time(&utmp_entry.ut_time) you get an int32_t *
    instead of an time_t *.

    I've attached a patch which creates a temporary variable which
    then puts it into the ut_tv.tv_sec. I'm not very happy about
    utmp's tv_sec still being 32 bit but I guess there is little I
    can do about it.


    Kurt


    --- unix/pty.c.orig 2004-06-20 19:07:38.000000000 +0200
    +++ unix/pty.c 2004-08-15 17:45:11.704264784 +0200
    @@ -97,6 +97,7 @@
    #endif
    struct passwd *pw;
    FILE *wtmp;
    + time_t uttime;

    pw = getpwuid(getuid());
    memset(&utmp_entry, 0, sizeof(utmp_entry));
    @@ -106,7 +107,8 @@
    strncpy(utmp_entry.ut_id, ttyname+8, lenof(utmp_entry.ut_id));
    strncpy(utmp_entry.ut_user, pw->pw_name, lenof(utmp_entry.ut_user));
    strncpy(utmp_entry.ut_host, location, lenof(utmp_entry.ut_host));
    - time(&utmp_entry.ut_time);
    + time(&uttime);
    + utmp_entry.ut_time = uttime;

    #if defined HAVE_PUTUTLINE
    utmpname(UTMP_FILE);
    @@ -141,13 +143,15 @@
    {
    #ifndef OMIT_UTMP
    FILE *wtmp;
    + time_t uttime;

    if (!pty_stamped_utmp)
    return;

    utmp_entry.ut_type = DEAD_PROCESS;
    memset(utmp_entry.ut_user, 0, lenof(utmp_entry.ut_user));
    - time(&utmp_entry.ut_time);
    + time(&uttime);
    + utmp_entry.ut_time = uttime;

    if ((wtmp = fopen(WTMP_FI