1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
$NetBSD: patch-loginrec.c,v 1.3 2015/03/20 22:41:19 rodent Exp $
Interix support and related fixes. Fix build on FreeBSD.
--- loginrec.c.orig 2014-01-17 01:23:24.000000000 +0000
+++ loginrec.c
@@ -432,8 +432,8 @@ login_set_addr(struct logininfo *li, con
int
login_write(struct logininfo *li)
{
-#ifndef HAVE_CYGWIN
- if (geteuid() != 0) {
+#if !defined(HAVE_CYGWIN) && !defined(HAVE_INTERIX)
+ if (geteuid() != ROOTUID) {
logit("Attempt to write login records by non-root user (aborting)");
return (1);
}
@@ -441,7 +441,7 @@ login_write(struct logininfo *li)
/* set the timestamp */
login_set_current_time(li);
-#ifdef USE_LOGIN
+#if defined(USE_LOGIN) && (HAVE_UTMP_H)
syslogin_write_entry(li);
#endif
#ifdef USE_LASTLOG
@@ -625,7 +625,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
@@ -762,10 +762,6 @@ construct_utmpx(struct logininfo *li, st
set_utmpx_time(li, utx);
utx->ut_pid = li->pid;
- /* strncpy(): Don't necessarily want null termination */
- strncpy(utx->ut_user, li->username,
- MIN_SIZEOF(utx->ut_user, li->username));
-
if (li->type == LTYPE_LOGOUT)
return;
@@ -774,6 +770,12 @@ construct_utmpx(struct logininfo *li, st
* for logouts.
*/
+ /* strncpy(): Don't necessarily want null termination */
+#if defined(__FreeBSD__)
+ strncpy(utx->ut_user, li->username, MIN_SIZEOF(utx->ut_user, li->username));
+#else
+ strncpy(utx->ut_name, li->username, MIN_SIZEOF(utx->ut_name, li->username));
+#endif
# ifdef HAVE_HOST_IN_UTMPX
strncpy(utx->ut_host, li->hostname,
MIN_SIZEOF(utx->ut_host, li->hostname));
@@ -1409,7 +1411,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)
{
|