|
| 1 | +-- This Source Code Form is subject to the terms of the Mozilla Public |
| 2 | +-- License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 | +-- file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 4 | + |
| 5 | +--[[ |
| 6 | +# openssh_portable Grammar Module |
| 7 | +
|
| 8 | +## Variables |
| 9 | +* `printf_messages` |
| 10 | +--]] |
| 11 | + |
| 12 | +local l = require "lpeg" |
| 13 | +l.locale(l) |
| 14 | +local ip = require "lpeg.ip_address" |
| 15 | + |
| 16 | +local M = {} |
| 17 | +setfenv(1, M) -- Remove external access to contain everything in the module |
| 18 | + |
| 19 | +local ipv46 = ip.v4_field + ip.v6_field |
| 20 | + |
| 21 | +printf_messages = { |
| 22 | + -- openssh-portable/auth.c |
| 23 | + -- {"%s %s%s%s for %s%.100s from %.200s port %d ssh2%s%s", "authmsg", "method", "submethod != NULL ? "/" : """, "submethod == NULL ? "" : submethod", "authctxt->valid ? "" : "invalid user "", "authctxt->user", "ssh_remote_ipaddr(ssh)", "ssh_remote_port(ssh)", "extra != NULL ? ": " : """, "extra != NULL ? extra : """}, |
| 24 | + {"%s %s%s%s for %s%.100s from %.200s port %d ssh2%s%s", |
| 25 | + "authmsg", |
| 26 | + l.Cg((l.P(1)-l.S"/ ")^1, "method"), |
| 27 | + l.P"/"^-1, |
| 28 | + (l.Cg((l.P(1)-l.S" ")^1, "submethod"))^-1, |
| 29 | + l.P"invalid user "^-1, |
| 30 | + "user", |
| 31 | + l.Cg(ipv46, "ssh_remote_ipaddr"), |
| 32 | + "ssh_remote_port", |
| 33 | + l.P":"^-1, |
| 34 | + "extra" |
| 35 | + }, |
| 36 | + |
| 37 | + -- openssh-portable/nchan.c |
| 38 | + {"channel %d: chan_shutdown_write: close() failed for fd %d: %.100s", "self", "wfd", "strerror"}, |
| 39 | + {"channel %d: chan_shutdown_read: close() failed for fd %d: %.100s", "self", "rfd", "strerror"}, |
| 40 | + |
| 41 | + -- openssh-portable/openbsd-compat/port-aix.c |
| 42 | + {"Can't retrieve attribute SYSTEM for %s: %.100s", "user", "strerror"}, |
| 43 | + {"Can't retrieve attribute auth1 for %s: %.100s", "user", "strerror"}, |
| 44 | + {"Account %s has unsupported auth1 value '%s'", "user", "p"}, |
| 45 | + {"Password can't be changed for user %s: %.100s", "name", "msg"}, |
| 46 | + {"Login restricted for %s: %.100s", "pw_name", "msg"}, |
| 47 | + |
| 48 | + -- openssh-portable/openbsd-compat/port-linux.c |
| 49 | + {"%s: getcon failed with %s", "__func__", "strerror"}, |
| 50 | + |
| 51 | + -- openssh-portable/mux.c |
| 52 | + {"%s: invalid forwarding type %u", "__func__", "ftype"}, |
| 53 | + {"%s: streamlocal and dynamic forwards are mutually exclusive", "__func__"}, |
| 54 | + {"%s: invalid listen port %u", "__func__", "listen_port"}, |
| 55 | + {"%s: invalid connect port %u", "__func__", "connect_port"}, |
| 56 | + {"%s: missing connect host", "__func__"}, |
| 57 | + {"slave-requested %s failed", "fwd_desc"}, |
| 58 | + |
| 59 | + -- openssh-portable/sshconnect.c |
| 60 | + {"Server version \"%.100s\" uses unsafe RSA signature scheme; disabling use of RSA keys", "remote_version"}, |
| 61 | + {"%s host key for IP address '%.128s' not in list of known hosts.", "type", "ip"}, |
| 62 | + {"Failed to add the %s host key for IP address '%.128s' to the list of known hosts (%.500s).", "type", "ip", "user_hostfiles"}, |
| 63 | + {"Warning: Permanently added the %s host key for IP address '%.128s' to the list of known hosts.", "type", "ip"}, |
| 64 | + {"Host key fingerprint is %s\n%s", "fp", "ra"}, |
| 65 | + {"Failed to add the host to the list of known hosts (%.500s).", "user_hostfiles"}, |
| 66 | + {"Warning: Permanently added '%.200s' (%s) to the list of known hosts.", "hostp", "type"}, |
| 67 | + {"%s", "msg"}, |
| 68 | + {"WARNING: %s key found for host %s\nin %s:%lu\n%s key fingerprint %s.", "key_type", "host", "file", "line", "key_type", "fp"}, |
| 69 | + |
| 70 | + -- openssh-portable/ssh-keygen.c |
| 71 | + {"%s:%lu: ignoring host name with wildcard: %.64s", "path", "linenum", "hosts"}, |
| 72 | + {"%s:%lu: invalid line", "path", "linenum"}, |
| 73 | + {"Host %s not found in %s", "name", "identity_file"}, |
| 74 | + {"WARNING: %s contains unhashed entries", "old"}, |
| 75 | + {"Signed %s key %s: id \"%s\" serial %llu%s%s valid %s", "sshkey_cert_type", "out", "key_id", "serial", l.P" for " + l.P"", "cert_principals", "valid"}, |
| 76 | + |
| 77 | + -- openssh-portable/auth2.c |
| 78 | + {"Authentication methods list \"%s\" contains disabled method, skipping", "auth_methods"}, |
| 79 | + |
| 80 | + -- openssh-portable/auth-options.c |
| 81 | + {"Authentication tried for %.100s with correct key but not from a permitted host (host=%.200s, ip=%.200s).", "pw_name", "remote_host", "remote_ip"}, |
| 82 | + {"Bad options in %.100s file, line %lu: %.50s", "file", "linenum", "opts"}, |
| 83 | + {"Authentication tried for %.100s with valid certificate but not from a permitted host (ip=%.200s).", "pw_name", "remote_ip"}, |
| 84 | + {"Certificate extension \"%s\" is not supported", "name"}, |
| 85 | + |
| 86 | + -- openssh-portable/gss-serv-krb5.c |
| 87 | + {"krb5_parse_name(): %.100s", "errmsg"}, |
| 88 | + {"Authorized to %s, krb5 principal %s (krb5_kuserok)", "name", "value"}, |
| 89 | + {"krb5_cc_new_unique(): %.100s", "errmsg"}, |
| 90 | + {"krb5_cc_gen_new(): %.100s", "krb5_get_err_text"}, |
| 91 | + {"ssh_krb5_cc_gen(): %.100s", "errmsg"}, |
| 92 | + {"krb5_cc_initialize(): %.100s", "errmsg"}, |
| 93 | + |
| 94 | + -- openssh-portable/dh.c |
| 95 | + {"WARNING: could not open %s (%s), using fixed modulus", "_PATH_DH_MODULI", "strerror"}, |
| 96 | + {"WARNING: no suitable primes in %s", "_PATH_DH_MODULI"}, |
| 97 | + {"WARNING: line %d disappeared in %s, giving up", "which", "_PATH_DH_MODULI"}, |
| 98 | + {"invalid public DH value (%d/%d)", "bits_set", "BN_num_bits"}, |
| 99 | + |
| 100 | + -- openssh-portable/session.c |
| 101 | + {"User %.100s not allowed because %s exists", "pw_name", "nl"}, |
| 102 | + {"subsystem request for %.100s by user %s failed, subsystem not found", "subsys", "pw_name"}, |
| 103 | + {"%s: no session %d req %.100s", "__func__", "self", "rtype"}, |
| 104 | + |
| 105 | + -- openssh-portable/sftp-client.c |
| 106 | + {"%s: not a regular file\n", "new_src"}, |
| 107 | + {"%s: lstat failed: %s", "filename", "strerror"}, |
| 108 | + |
| 109 | + -- openssh-portable/sshd.c |
| 110 | + {"RESTART FAILED: av[0]='%.100s', error: %.100s.", "saved_argv", "strerror"}, |
| 111 | + {"Could not write ident string to %s port %d", "ssh_remote_ipaddr", "ssh_remote_port"}, |
| 112 | + {"Did not receive identification string from %s port %d", "ssh_remote_ipaddr", "ssh_remote_port"}, |
| 113 | + {"Bad protocol version identification '%.100s' from %s port %d", "client_version_string", "ssh_remote_ipaddr", "ssh_remote_port"}, |
| 114 | + {"probed from %s port %d with %s. Don't panic.", "ssh_remote_ipaddr", "ssh_remote_port", "client_version_string"}, |
| 115 | + {"scanned from %s port %d with %s. Don't panic.", "ssh_remote_ipaddr", "ssh_remote_port", "client_version_string"}, |
| 116 | + {"Client version \"%.100s\" uses unsafe RSA signature scheme; disabling use of RSA keys", "remote_version"}, |
| 117 | + {"Protocol major versions differ for %s port %d: %.200s vs. %.200s", "ssh_remote_ipaddr", "ssh_remote_port", "server_version_string", "client_version_string"}, |
| 118 | + {"Server listening on %s port %s%s%s.", "ntop", "strport", l.P" rdomain " + l.P"", "rdomain"}, |
| 119 | + {"Received signal %d; terminating.", "received_sigterm"}, |
| 120 | + |
| 121 | + -- openssh-portable/auth.c |
| 122 | + {"User %.100s not allowed because account is locked", "pw_name"}, |
| 123 | + {"User %.100s not allowed because shell %.100s does not exist", "pw_name", "shell"}, |
| 124 | + {"User %.100s not allowed because shell %.100s is not executable", "pw_name", "shell"}, |
| 125 | + {"User %.100s from %.100s not allowed because listed in DenyUsers", "pw_name", "hostname"}, |
| 126 | + {"User %.100s from %.100s not allowed because not listed in AllowUsers", "pw_name", "hostname"}, |
| 127 | + {"User %.100s from %.100s not allowed because not in any group", "pw_name", "hostname"}, |
| 128 | + {"User %.100s from %.100s not allowed because a group is listed in DenyGroups", "pw_name", "hostname"}, |
| 129 | + {"User %.100s from %.100s not allowed because none of user's groups are listed in AllowGroups", "pw_name", "hostname"}, |
| 130 | + {"ROOT LOGIN REFUSED FROM %.200s port %d", "ssh_remote_ipaddr", "ssh_remote_port"}, |
| 131 | + {"Authentication refused for %.100s: bad owner or modes for %.200s", "pw_name", "user_hostfile"}, |
| 132 | + {"User %s %s %s is not a regular file", "pw_name", "file_type", "file"}, |
| 133 | + {"Authentication refused: %s", "line"}, |
| 134 | + {"Login name %.100s does not match stored username %.100s", "user", "pw_name"}, |
| 135 | + {"Invalid user %.100s from %.100s port %d", "user", "ssh_remote_ipaddr", "ssh_remote_port"}, |
| 136 | + {"Nasty PTR record \"%s\" is set up for %s, ignoring", "name", "ntop"}, |
| 137 | + {"reverse mapping checking getaddrinfo for %.700s [%s] failed.", "name", "ntop"}, |
| 138 | + {"Address %.100s maps to %.600s, but this does not map back to the address.", "ntop", "name"}, |
| 139 | + |
| 140 | + -- openssh-portable/dispatch.c |
| 141 | + {"dispatch_protocol_error: type %d seq %u", "type", "seq"}, |
| 142 | + {"dispatch_protocol_ignore: type %d seq %u", "type", "seq"}, |
| 143 | + |
| 144 | + -- openssh-portable/clientloop.c |
| 145 | + {"DISPLAY \"%s\" invalid; disabling X11 forwarding", "display"}, |
| 146 | + {"Timeout, server %s not responding.", "host"}, |
| 147 | + |
| 148 | + -- openssh-portable/auth2-pubkey.c |
| 149 | + {"%s: unsupported public key algorithm: %s", "__func__", "pkalg"}, |
| 150 | + {"refusing previously-used %s key", "sshkey_type"}, |
| 151 | + {"%s: key type %s not in PubkeyAcceptedKeyTypes", "__func__", "sshkey_ssh_name"}, |
| 152 | + |
| 153 | + -- openssh-portable/monitor.c |
| 154 | + {"wrong user name passed to monitor: expected %s != %.100s", "userstyle", "cp"}, |
| 155 | + |
| 156 | + -- openssh-portable/auth-shadow.c |
| 157 | + {"Account %.100s has expired", "sp_namp"}, |
| 158 | + {"User %.100s password has expired (root forced)", "user"}, |
| 159 | + {"User %.100s password has expired (password aged)", "user"}, |
| 160 | + |
| 161 | + -- openssh-portable/auth-rhosts.c |
| 162 | + {"User %s hosts file %s is not a regular file", "server_user", "filename"}, |
| 163 | + {"Rhosts authentication refused for %.100s: no home directory %.200s", "pw_name", "pw_dir"}, |
| 164 | + {"Rhosts authentication refused for %.100s: bad ownership or modes for home directory.", "pw_name"}, |
| 165 | + {"Rhosts authentication refused for %.100s: bad modes for %.200s", "pw_name", "buf"}, |
| 166 | + |
| 167 | + -- openssh-portable/ssh.c |
| 168 | + {"No user exists for uid %lu", "original_real_uid"}, |
| 169 | + {"%s, %s", "SSH_RELEASE", "version"}, |
| 170 | + {"Allocated port %u for remote forward to %s:%d", "allocated_port", "connect_host", "connect_port"}, |
| 171 | + {"Warning: remote port forwarding failed for listen path %s", "listen_path"}, |
| 172 | + {"Warning: remote port forwarding failed for listen port %d", "listen_port"}, |
| 173 | + |
| 174 | + -- openssh-portable/moduli.c |
| 175 | + {"Limited memory: %u MB; limit %lu MB", "largememory", "LARGE_MAXIMUM"}, |
| 176 | + {"Increased memory: %u MB; need %u bytes", "largememory", "bytes"}, |
| 177 | + {"Decreased memory: %u MB; want %u bytes", "largememory", "bytes"}, |
| 178 | + {"%.24s Sieve next %u plus %u-bit", "ctime", "largenumbers", "power"}, |
| 179 | + {"%.24s Sieved with %u small primes in %lld seconds", "ctime", "largetries", "duration"}, |
| 180 | + {"%.24s Found %u candidates", "ctime", "r"}, |
| 181 | + {"mkstemp(%s): %s", "tmp", "strerror"}, |
| 182 | + {"write_checkpoint: fdopen: %s", "strerror"}, |
| 183 | + {"failed to write to checkpoint file '%s': %s", "cpfile", "strerror"}, |
| 184 | + {"Failed to load checkpoint from '%s'", "cpfile"}, |
| 185 | + {"Loaded checkpoint from '%s' line %lu", "cpfile", "lineno"}, |
| 186 | + {"%.24s processed %lu in %s", "ctime", "processed", "fmt_time"}, |
| 187 | + {"%.24s processed %lu of %lu (%lu%%) in %s, ETA %s", "ctime", "processed", "num_to_process", "percent", "fmt_time", "eta_str"}, |
| 188 | + {"%.24s Found %u safe primes of %u candidates in %ld seconds", "ctime", "count_out", "count_possible", "duration"}, |
| 189 | + |
| 190 | + -- openssh-portable/channels.c |
| 191 | + {"%s: %d: bad id", "__func__", "id"}, |
| 192 | + {"%s: %d: bad id: channel free", "__func__", "id"}, |
| 193 | + {"Non-public channel %d, type %d.", "id", "type"}, |
| 194 | + {"channel_send_open: %d: bad id", "id"}, |
| 195 | + {"%s: %d: unknown channel id", "__func__", "id"}, |
| 196 | + {"channel %d: rcvd big packet %zu, maxpack %u", "self", "win_len", "local_maxpacket"}, |
| 197 | + {"channel %d: rcvd too much data %zu, win %u", "self", "win_len", "local_window"}, |
| 198 | + {"channel %d: ext data for non open", "self"}, |
| 199 | + {"channel %d: bad ext data", "self"}, |
| 200 | + {"channel %d: rcvd too much extended_data %zu, win %u", "self", "data_len", "local_window"}, |
| 201 | + {"channel %d: open failed: %s%s%s", "self", "reason2txt", l.P": " + l.P"", "msg"}, |
| 202 | + {"Received window adjust for non-open channel %d.", "id"}, |
| 203 | + {"%s: %d: unknown", "__func__", "id"}, |
| 204 | + {"Received request to connect to host %.100s port %d, but the request was denied.", "host", "port"}, |
| 205 | + {"Received request to connect to path %.100s, but the request was denied.", "path"}, |
| 206 | + |
| 207 | + -- openssh-portable/serverloop.c |
| 208 | + {"Timeout, client not responding from %s", "remote_id"}, |
| 209 | + {"Exiting on signal %d", "received_sigterm"}, |
| 210 | + {"refused local port forward: originator %s port %d, target %s port %d", "originator", "originator_port", "target", "target_port"}, |
| 211 | + {"refused streamlocal port forward: originator %s port %d, target %s", "originator", "originator_port", "target"}, |
| 212 | + |
| 213 | + -- openssh-portable/packet.c |
| 214 | + {"Finished discarding for %.200s port %d", "ssh_remote_ipaddr", "ssh_remote_port"}, |
| 215 | + {"Bad packet length %u.", "packlen"}, |
| 216 | + {"padding error: need %d block %d mod %d", "need", "block_size", "need % block_size"}, |
| 217 | + {"Disconnecting %s: %.100s", "remote_id", "buf"}, |
| 218 | + {"packet_set_maxsize: called twice: old %d new %d", "max_packet_size", "s"}, |
| 219 | + {"packet_set_maxsize: bad size %d", "s"}, |
| 220 | + |
| 221 | + -- openssh-portable/compat.c |
| 222 | + {"ignoring bad proto spec: '%s'.", "p"}, |
| 223 | + |
| 224 | + -- openssh-portable/ttymodes.c |
| 225 | + {"tcgetattr: %.100s", "strerror"}, |
| 226 | + {"parse_tty_modes: unknown opcode %d", "opcode"}, |
| 227 | + {"parse_tty_modes: n_bytes_ptr != n_bytes: %d %d", "n_bytes_ptr", "n_bytes"}, |
| 228 | + {"Setting tty modes failed: %.100s", "strerror"}, |
| 229 | + |
| 230 | + -- openssh-portable/sftp-server.c |
| 231 | + {"%s%sclose \"%s\" bytes read %llu written %llu", "emsg", l.P" " + l.P"", "handle_to_name", "handle_bytes_read", "handle_bytes_write"}, |
| 232 | + {"%s%sclosedir \"%s\"", "emsg", l.P" " + l.P"", "handle_to_name"}, |
| 233 | + {"sent status %s", "status_to_message"}, |
| 234 | + {"open \"%s\" flags %s mode 0%o", "name", "string_from_portable", "mode"}, |
| 235 | + {"set \"%s\" size %llu", "name", "size"}, |
| 236 | + {"set \"%s\" mode %04o", "name", "perm"}, |
| 237 | + {"set \"%s\" modtime %s", "name", "buf"}, |
| 238 | + {"set \"%s\" owner %lu group %lu", "name", "uid", "gid"}, |
| 239 | + {"opendir \"%s\"", "path"}, |
| 240 | + {"remove name \"%s\"", "name"}, |
| 241 | + {"mkdir name \"%s\" mode 0%o", "name", "mode"}, |
| 242 | + {"rmdir name \"%s\"", "name"}, |
| 243 | + {"rename old \"%s\" new \"%s\"", "oldpath", "newpath"}, |
| 244 | + {"symlink old \"%s\" new \"%s\"", "oldpath", "newpath"}, |
| 245 | + {"posix-rename old \"%s\" new \"%s\"", "oldpath", "newpath"}, |
| 246 | + {"statvfs \"%s\"", "path"}, |
| 247 | + {"hardlink old \"%s\" new \"%s\"", "oldpath", "newpath"}, |
| 248 | + {"session closed for local user %s from [%s]", "pw_name", "client_addr"}, |
| 249 | + {"session opened for local user %s from [%s]", "pw_name", "client_addr"}, |
| 250 | + |
| 251 | + -- openssh-portable/loginrec.c |
| 252 | + {"Writing login record failed for %s", "username"}, |
| 253 | + {"%s: tty not found", "__func__"}, |
| 254 | + {"%s: lseek: %s", "__func__", "strerror"}, |
| 255 | + {"%s: Couldn't seek to tty %d slot in %s", "__func__", "tty", "UTMP_FILE"}, |
| 256 | + {"%s: error writing %s: %s", "__func__", "UTMP_FILE", "strerror"}, |
| 257 | + {"%s: utmp_write_library() failed", "__func__"}, |
| 258 | + {"%s: utmp_write_direct() failed", "__func__"}, |
| 259 | + {"%s: invalid type field", "__func__"}, |
| 260 | + {"%s: not implemented!", "__func__"}, |
| 261 | + {"%s: problem writing %s: %s", "__func__", "WTMP_FILE", "strerror"}, |
| 262 | + {"%s: problem opening %s: %s", "__func__", "WTMP_FILE", "strerror"}, |
| 263 | + {"%s: couldn't stat %s: %s", "__func__", "WTMP_FILE", "strerror"}, |
| 264 | + {"%s: read of %s failed: %s", "__func__", "WTMP_FILE", "strerror"}, |
| 265 | + {"%s: logout() returned an error", "__func__"}, |
| 266 | + {"%s: Invalid type field", "__func__"}, |
| 267 | + {"%s: Couldn't stat %s: %s", "__func__", "LASTLOG_FILE", "strerror"}, |
| 268 | + {"%s: %.100s is not a file or directory!", "__func__", "LASTLOG_FILE"}, |
| 269 | + {"%s: %s->lseek(): %s", "__func__", "lastlog_file", "strerror"}, |
| 270 | + {"%s: Error writing to %s: %s", "__func__", "LASTLOG_FILE", "strerror"}, |
| 271 | + {"%s: fstat of %s failed: %s", "__func__", "_PATH_BTMP", "strerror"}, |
| 272 | + {"Excess permission or bad ownership on file %s", "_PATH_BTMP"}, |
| 273 | + |
| 274 | + -- openssh-portable/auth-krb5.c |
| 275 | + {"mkstemp(): %.100s", "strerror"}, |
| 276 | + {"fchmod(): %.100s", "strerror"}, |
| 277 | + |
| 278 | + -- openssh-portable/auth2-hostbased.c |
| 279 | + {"%s: key type %s not in HostbasedAcceptedKeyTypes", "__func__", "sshkey_type"}, |
| 280 | + {"userauth_hostbased mismatch: client sends %s, but we resolve %s to %s", "chost", "ipaddr", "resolvedname"}, |
| 281 | +} |
| 282 | + |
| 283 | +return M |
0 commit comments