1
- From 51b3d58afef6796fe0568deb4c3765e24cc828c9 Mon Sep 17 00:00:00 2001
2
- From: liuh-80 <liuh@microsoft .com>
3
- Date: Fri , 30 Sep 2022 16:57 :03 +0800
4
- Subject: [PATCH] Export remote info for authorization. authorization.
1
+ From 27402e9ed5de5e957ef0084d4f6dd6a62a2534ee Mon Sep 17 00:00:00 2001
2
+ From: ab952469 <asha.behera@broadcom .com>
3
+ Date: Sun , 30 Mar 2025 07:59 :03 -0700
4
+ Subject: [PATCH] [PATCH] Export remote info for authorization. authorization.
5
5
6
6
---
7
- auth.c | 11 +++++++++++
7
+ auth.c | 14 +++ +++++++++++
8
8
auth.h | 3 +++
9
9
session.c | 3 +++
10
- sshd.c | 5 ++ +++
11
- 4 files changed, 22 insertions(+)
10
+ sshd.c | 3 +++
11
+ 4 files changed, 23 insertions(+)
12
12
13
13
diff --git a/auth.c b/auth.c
14
- index c3693ba3f..96d551922 100644
14
+ index 88578ec..2c64ee7 100644
15
15
--- a/auth.c
16
16
+++ b/auth.c
17
- @@ -764 ,3 +764,14 @@ auth_authorise_keyopts(struct ssh *ssh, struct passwd *pw,
18
- fatal_f("failed to restrict session");
19
- sshauthopt_free(restricted) ;
17
+ @@ -1103 ,3 +1103,17 @@ auth_authorise_keyopts(struct ssh *ssh, struct passwd *pw,
18
+
19
+ return 0 ;
20
20
}
21
21
+
22
22
+ /* Export remote IP address and port for authorization. */
23
23
+ void
24
24
+ export_remote_info(struct ssh *ssh)
25
25
+ {
26
- + const char *remote_ip = ssh_remote_ipaddr(ssh);
27
- + const int remote_port = ssh_remote_port(ssh);
28
- + const char remote_addr_port[32 + INET6_ADDRSTRLEN];
29
- + snprintf(remote_addr_port, sizeof(remote_addr_port), "%s %d", remote_ip, remote_port);
30
- + setenv("SSH_CLIENT_IPADDR_PORT", remote_addr_port, 1);
26
+ + if (ssh != NULL)
27
+ + {
28
+ + const char *remote_ip = ssh_remote_ipaddr(ssh);
29
+ + const int remote_port = ssh_remote_port(ssh);
30
+ + const char remote_addr_port[32 + INET6_ADDRSTRLEN];
31
+ + snprintf(remote_addr_port, sizeof(remote_addr_port), "%s %d", remote_ip, remote_port);
32
+ + setenv("SSH_CLIENT_IPADDR_PORT", remote_addr_port, 1);
33
+ + }
31
34
+ }
32
- \ No newline at end of file
33
35
diff --git a/auth.h b/auth.h
34
- index 3cfce0eaf..3a34742b1 100644
36
+ index 5da9fe7..95483ac 100644
35
37
--- a/auth.h
36
38
+++ b/auth.h
37
- @@ -229 ,6 +229 ,9 @@ struct passwd *fakepw(void);
39
+ @@ -234 ,6 +234 ,9 @@ pid_t subprocess(const char *, struct passwd *,
38
40
39
41
int sys_auth_passwd(struct ssh *, const char *);
40
42
@@ -45,10 +47,10 @@ index 3cfce0eaf..3a34742b1 100644
45
47
krb5_error_code ssh_krb5_cc_gen(krb5_context, krb5_ccache *);
46
48
#endif
47
49
diff --git a/session.c b/session.c
48
- index a638ceef1..c615cb3d0 100644
50
+ index 4128d26..3fa7c02 100644
49
51
--- a/session.c
50
52
+++ b/session.c
51
- @@ -619 ,6 +619 ,9 @@ do_exec_pty(struct ssh *ssh, Session *s, const char *command)
53
+ @@ -624 ,6 +624 ,9 @@ do_exec_pty(struct ssh *ssh, Session *s, const char *command)
52
54
/* Close the extra descriptor for the pseudo tty. */
53
55
close(ttyfd);
54
56
@@ -59,19 +61,10 @@ index a638ceef1..c615cb3d0 100644
59
61
#ifndef HAVE_OSF_SIA
60
62
do_login(ssh, s, command);
61
63
diff --git a/sshd.c b/sshd.c
62
- index 3ef0c1452..2f67a0304 100644
64
+ index e894ad6..c276421 100644
63
65
--- a/sshd.c
64
66
+++ b/sshd.c
65
- @@ -1737,6 +1737,8 @@ main(int ac, char **av)
66
- test_flag = 2;
67
- break;
68
- case 'C':
69
- + /* Export remote IP address and port for authorization. */
70
- + export_remote_info(ssh);
71
- connection_info = get_connection_info(ssh, 0, 0);
72
- if (parse_server_match_testspec(connection_info,
73
- optarg) == -1)
74
- @@ -2252,6 +2254,9 @@ main(int ac, char **av)
67
+ @@ -2196,6 +2196,9 @@ main(int ac, char **av)
75
68
*/
76
69
remote_ip = ssh_remote_ipaddr(ssh);
77
70
@@ -82,5 +75,5 @@ index 3ef0c1452..2f67a0304 100644
82
75
audit_connection_from(remote_ip, remote_port);
83
76
#endif
84
77
- -
85
- 2.35.1.windows.2
78
+ 2.7.4
86
79
0 commit comments