summaryrefslogtreecommitdiff
path: root/security/openssh/patches/patch-ad
blob: 1f25ee592650f5624d43f625016596c7e6dc243a (plain)
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
$NetBSD: patch-ad,v 1.10 2005/05/25 23:17:11 reed 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_UTMP_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)
 {