$NetBSD: patch-ad,v 1.9 2005/03/07 23:29:49 tv Exp $ --- loginrec.c.orig 2004-08-15 05:12:52.000000000 -0400 +++ loginrec.c @@ -406,8 +406,8 @@ login_set_addr(struct logininfo *li, con int login_write (struct logininfo *li) { -#ifndef HAVE_CYGWIN - if ((int)geteuid() != 0) { +#if !defined(HAVE_CYGWIN) && !defined(HAVE_INTERIX) + if ((int)geteuid() != ROOTUID) { logit("Attempt to write login records by non-root user (aborting)"); return 1; } @@ -415,7 +415,7 @@ login_write (struct logininfo *li) /* set the timestamp */ login_set_current_time(li); -#ifdef USE_LOGIN +#if defined(USE_LOGIN) && (HAVE_UMTP_H) syslogin_write_entry(li); #endif #ifdef USE_LASTLOG @@ -589,7 +589,7 @@ line_abbrevname(char *dst, const char *s ** into account. **/ -#if defined(USE_UTMP) || defined (USE_WTMP) || defined (USE_LOGIN) +#if defined(USE_UTMP) || defined (USE_WTMP) || (defined (USE_LOGIN) && defined (HAVE_UTMP_H)) /* build the utmp structure */ void @@ -725,8 +725,6 @@ construct_utmpx(struct logininfo *li, st line_stripname(utx->ut_line, li->line, sizeof(utx->ut_line)); set_utmpx_time(li, utx); utx->ut_pid = li->pid; - /* strncpy(): Don't necessarily want null termination */ - strncpy(utx->ut_name, li->username, MIN_SIZEOF(utx->ut_name, li->username)); if (li->type == LTYPE_LOGOUT) return; @@ -736,6 +734,8 @@ construct_utmpx(struct logininfo *li, st * for logouts. */ + /* strncpy(): Don't necessarily want null termination */ + strncpy(utx->ut_name, li->username, MIN_SIZEOF(utx->ut_name, li->username)); # ifdef HAVE_HOST_IN_UTMPX strncpy(utx->ut_host, li->hostname, MIN_SIZEOF(utx->ut_host, li->hostname)); # endif @@ -1357,7 +1357,7 @@ wtmpx_get_entry(struct logininfo *li) ** Low-level libutil login() functions **/ -#ifdef USE_LOGIN +#if defined(USE_LOGIN) && defined(HAVE_UTMP_H) static int syslogin_perform_login(struct logininfo *li) {