Skip to content

Commit 5e0db87

Browse files
author
Carlos Cabanero
committed
Update to OpenSSH v8.9.0
- Build only for iOS platforms as MacOSX still has some compatibility issues we need to fix. #2
1 parent 5f0e66a commit 5e0db87

File tree

8 files changed

+357
-104
lines changed

8 files changed

+357
-104
lines changed

Sources/openssh-apple/main.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ OutputLevel.default = .error
55

66
enum Config {
77
static let opensshOrigin = "https://github.com/openssh/openssh-portable.git"
8-
static let opensshBranch = "V_8_6"
9-
static let opensshVersion = "8.6.0"
8+
static let opensshBranch = "V_8_9"
9+
static let opensshVersion = "8.9.0"
1010

1111
static let opensslLibsURL = "https://github.com/blinksh/openssl-apple/releases/download/v1.1.1k/openssl-libs.zip"
1212
static let opensslFrameworksURL = "https://github.com/blinksh/openssl-apple/releases/download/v1.1.1k/openssl-dynamic.frameworks.zip"
1313

1414
static let frameworkName = "OpenSSH"
1515

16-
static let platforms: [Platform] = Platform.allCases
17-
// static let platforms: [Platform] = [.iPhoneOS]
18-
// static let platforms: [Platform] = [Platform.Catalyst]
16+
//static let platforms: [Platform] = Platform.allCases
17+
static let platforms: [Platform] = [.iPhoneOS, .iPhoneSimulator]
18+
//static let platforms: [Platform] = [Platform.MacOSX]
1919
}
2020

2121
extension Platform {
@@ -32,11 +32,11 @@ extension Platform {
3232
try? sh("rm -rf openssh-portable")
3333
try sh("git clone --depth 1 \(Config.opensshOrigin) --branch \(Config.opensshBranch)")
3434
try sh("LC_CTYPE=C find ./openssh-portable -type f -exec sed -i '' -e 's/__progname/blink__progname/' {} \\;")
35-
try sh("cp -f readpass.c sshkey.h authfd.h log.c ssh-sk-helper.c misc.c openssh-portable/")
3635
try sh("LC_CTYPE=C find ./openssh-portable -type f -exec sed -i '' -e 's/ssh_init(/openssh_init(/' {} \\;")
3736
try sh("LC_CTYPE=C find ./openssh-portable -type f -exec sed -i '' -e 's/ssh_free(/openssh_free(/' {} \\;")
3837
try sh("LC_CTYPE=C find ./openssh-portable -type f -exec sed -i '' -e 's/match_pattern_list(/openssh_match_pattern_list(/' {} \\;")
3938
try sh("LC_CTYPE=C find ./openssh-portable -type f -exec sed -i '' -e 's/match_hostname(/openssh_match_hostname(/' {} \\;")
39+
try sh("cp -f authfd.h log.c misc.c readpass.c ssh-sk-helper.c ssh-sk.h sshkey.h openssh-portable/")
4040

4141
try download(url: Config.opensslLibsURL)
4242
try? sh("rm -rf openssl")
@@ -278,4 +278,4 @@ let releaseMD =
278278
| \(xcframeworkdStaticZipName) | \(try sha(path: xcframeworkdStaticZipName)) |
279279
"""
280280

281-
try write(content: releaseMD, atPath: "release.md")
281+
try write(content: releaseMD, atPath: "release.md")

authfd.h

+31-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: authfd.h,v 1.49 2020/06/26 05:03:36 djm Exp $ */
1+
/* $OpenBSD: authfd.h,v 1.51 2021/12/19 22:10:24 djm Exp $ */
22

33
/*
44
* Author: Tatu Ylonen <[email protected]>
@@ -18,13 +18,30 @@
1818

1919
#include <sys/types.h>
2020

21+
struct sshbuf;
22+
struct sshkey;
23+
2124
/* List of identities returned by ssh_fetch_identitylist() */
2225
struct ssh_identitylist {
2326
size_t nkeys;
2427
struct sshkey **keys;
2528
char **comments;
2629
};
2730

31+
/* Key destination restrictions */
32+
struct dest_constraint_hop {
33+
char *user; /* wildcards allowed */
34+
char *hostname; /* used to matching cert principals and for display */
35+
int is_ca;
36+
u_int nkeys; /* number of entries in *both* 'keys' and 'key_is_ca' */
37+
struct sshkey **keys;
38+
int *key_is_ca;
39+
};
40+
struct dest_constraint {
41+
struct dest_constraint_hop from;
42+
struct dest_constraint_hop to;
43+
};
44+
2845
int ssh_get_authentication_socket(int *fdp);
2946
int ssh_get_authentication_socket_path(const char *authsocket, int *fdp);
3047
void ssh_close_authentication_socket(int sock);
@@ -33,18 +50,25 @@ int ssh_lock_agent(int sock, int lock, const char *password);
3350
int ssh_fetch_identitylist(int sock, struct ssh_identitylist **idlp);
3451
void ssh_free_identitylist(struct ssh_identitylist *idl);
3552
int ssh_add_identity_constrained(int sock, struct sshkey *key,
36-
const char *comment, u_int life, u_int confirm, u_int maxsign,
37-
const char *provider);
53+
const char *comment, u_int life, u_int confirm, u_int maxsign,
54+
const char *provider, struct dest_constraint **dest_constraints,
55+
size_t ndest_constraints);
3856
int ssh_agent_has_key(int sock, const struct sshkey *key);
3957
int ssh_remove_identity(int sock, const struct sshkey *key);
4058
int ssh_update_card(int sock, int add, const char *reader_id,
41-
const char *pin, u_int life, u_int confirm);
59+
const char *pin, u_int life, u_int confirm,
60+
struct dest_constraint **dest_constraints,
61+
size_t ndest_constraints);
4262
int ssh_remove_all_identities(int sock, int version);
4363

4464
int ssh_agent_sign(int sock, const struct sshkey *key,
4565
u_char **sigp, size_t *lenp,
4666
const u_char *data, size_t datalen, const char *alg, u_int compat);
4767

68+
int ssh_agent_bind_hostkey(int sock, const struct sshkey *key,
69+
const struct sshbuf *session_id, const struct sshbuf *signature,
70+
int forwarding);
71+
4872
/* Messages for the authentication agent connection. */
4973
#define SSH_AGENTC_REQUEST_RSA_IDENTITIES 1
5074
#define SSH_AGENT_RSA_IDENTITIES_ANSWER 2
@@ -78,6 +102,9 @@ int ssh_agent_sign(int sock, const struct sshkey *key,
78102
#define SSH2_AGENTC_ADD_ID_CONSTRAINED 25
79103
#define SSH_AGENTC_ADD_SMARTCARD_KEY_CONSTRAINED 26
80104

105+
/* generic extension mechanism */
106+
#define SSH_AGENTC_EXTENSION 27
107+
81108
#define SSH_AGENT_CONSTRAIN_LIFETIME 1
82109
#define SSH_AGENT_CONSTRAIN_CONFIRM 2
83110
#define SSH_AGENT_CONSTRAIN_MAXSIGN 3

log.c

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: log.c,v 1.58 2021/04/15 16:24:31 markus Exp $ */
1+
/* $OpenBSD: log.c,v 1.60 2021/09/16 15:11:19 djm Exp $ */
22
/*
33
* Author: Tatu Ylonen <[email protected]>
44
* Copyright (c) 1995 Tatu Ylonen <[email protected]>, Espoo, Finland
@@ -346,6 +346,7 @@ do_log(LogLevel level, int force, const char *suffix, const char *fmt,
346346
int pri = LOG_INFO;
347347
int saved_errno = errno;
348348
log_handler_fn *tmp_handler;
349+
const char *progname = argv0 != NULL ? argv0 : blink__progname;
349350

350351
if (!force && level > log_level)
351352
return;
@@ -403,16 +404,18 @@ do_log(LogLevel level, int force, const char *suffix, const char *fmt,
403404
tmp_handler(level, force, fmtbuf, log_handler_ctx);
404405
log_handler = tmp_handler;
405406
} else if (log_on_stderr) {
406-
snprintf(msgbuf, sizeof msgbuf, "%.*s\r\n",
407+
snprintf(msgbuf, sizeof msgbuf, "%s%s%.*s\r\n",
408+
(log_on_stderr > 1) ? progname : "",
409+
(log_on_stderr > 1) ? ": " : "",
407410
(int)sizeof msgbuf - 3, fmtbuf);
408411
(void)write(log_stderr_fd, msgbuf, strlen(msgbuf));
409412
} else {
410413
#if defined(HAVE_OPENLOG_R) && defined(SYSLOG_DATA_INIT)
411-
openlog_r(argv0 ? argv0 : blink__progname, LOG_PID, log_facility, &sdata);
414+
openlog_r(blink__progname, LOG_PID, log_facility, &sdata);
412415
syslog_r(pri, &sdata, "%.500s", fmtbuf);
413416
closelog_r(&sdata);
414417
#else
415-
openlog(argv0 ? argv0 : blink__progname, LOG_PID, log_facility);
418+
openlog(blink__progname, LOG_PID, log_facility);
416419
syslog(pri, "%.500s", fmtbuf);
417420
closelog();
418421
#endif
@@ -466,10 +469,11 @@ sshlogv(const char *file, const char *func, int line, int showfunc,
466469
const char *cp;
467470
size_t i;
468471

469-
snprintf(tag, sizeof(tag), "%.48s:%.48s():%d",
470-
(cp = strrchr(file, '/')) == NULL ? file : cp + 1, func, line);
472+
snprintf(tag, sizeof(tag), "%.48s:%.48s():%d (pid=%ld)",
473+
(cp = strrchr(file, '/')) == NULL ? file : cp + 1, func, line,
474+
(long)getpid());
471475
for (i = 0; i < nlog_verbose; i++) {
472-
if (match_pattern_list(tag, log_verbose[i], 0) == 1) {
476+
if (openssh_match_pattern_list(tag, log_verbose[i], 0) == 1) {
473477
forced = 1;
474478
break;
475479
}
@@ -493,4 +497,4 @@ sshlogdirect(LogLevel level, int forced, const char *fmt, ...)
493497
va_start(args, fmt);
494498
do_log(level, forced, NULL, fmt, args);
495499
va_end(args);
496-
}
500+
}

0 commit comments

Comments
 (0)