|
Lines 926-932
do_gen_all_hostkeys(struct passwd *pw)
Link Here
|
| 926 |
} |
926 |
} |
| 927 |
|
927 |
|
| 928 |
static void |
928 |
static void |
| 929 |
printhost(FILE *f, const char *name, Key *public, int ca, int hash) |
929 |
printhost(FILE *f, const char *name, const char *comment, Key *public, |
|
|
930 |
int ca, int hash) |
| 930 |
{ |
931 |
{ |
| 931 |
if (print_fingerprint) { |
932 |
if (print_fingerprint) { |
| 932 |
enum fp_rep rep; |
933 |
enum fp_rep rep; |
|
Lines 949-954
printhost(FILE *f, const char *name, Key
Link Here
|
| 949 |
fprintf(f, "%s%s%s ", ca ? CA_MARKER : "", ca ? " " : "", name); |
950 |
fprintf(f, "%s%s%s ", ca ? CA_MARKER : "", ca ? " " : "", name); |
| 950 |
if (!key_write(public, f)) |
951 |
if (!key_write(public, f)) |
| 951 |
fatal("key_write failed"); |
952 |
fatal("key_write failed"); |
|
|
953 |
if (comment != NULL && *comment) |
| 954 |
fprintf(f, " %s", comment); |
| 952 |
fprintf(f, "\n"); |
955 |
fprintf(f, "\n"); |
| 953 |
} |
956 |
} |
| 954 |
} |
957 |
} |
|
Lines 1052-1058
do_known_hosts(struct passwd *pw, const
Link Here
|
| 1052 |
continue; |
1055 |
continue; |
| 1053 |
} |
1056 |
} |
| 1054 |
} |
1057 |
} |
| 1055 |
|
|
|
| 1056 |
if (*cp == HASH_DELIM) { |
1058 |
if (*cp == HASH_DELIM) { |
| 1057 |
if (find_host || delete_host) { |
1059 |
if (find_host || delete_host) { |
| 1058 |
cp2 = host_hash(name, cp, strlen(cp)); |
1060 |
cp2 = host_hash(name, cp, strlen(cp)); |
|
Lines 1068-1079
do_known_hosts(struct passwd *pw, const
Link Here
|
| 1068 |
"line %d type %s%s\n", name, |
1070 |
"line %d type %s%s\n", name, |
| 1069 |
num, key_type(pub), |
1071 |
num, key_type(pub), |
| 1070 |
ca ? " (CA key)" : ""); |
1072 |
ca ? " (CA key)" : ""); |
| 1071 |
printhost(out, cp, pub, ca, 0); |
1073 |
printhost(out, cp, kp, pub, ca, 0); |
| 1072 |
} |
1074 |
} |
| 1073 |
if (delete_host && !c && !ca) |
1075 |
if (delete_host && !c && !ca) |
| 1074 |
printhost(out, cp, pub, ca, 0); |
1076 |
printhost(out, cp, kp, pub, ca, 0); |
| 1075 |
} else if (hash_hosts) |
1077 |
} else if (hash_hosts) |
| 1076 |
printhost(out, cp, pub, ca, 0); |
1078 |
printhost(out, cp, kp, pub, ca, 0); |
| 1077 |
} else { |
1079 |
} else { |
| 1078 |
if (find_host || delete_host) { |
1080 |
if (find_host || delete_host) { |
| 1079 |
c = (match_hostname(name, cp, |
1081 |
c = (match_hostname(name, cp, |
|
Lines 1083-1093
do_known_hosts(struct passwd *pw, const
Link Here
|
| 1083 |
"line %d type %s%s\n", name, |
1085 |
"line %d type %s%s\n", name, |
| 1084 |
num, key_type(pub), |
1086 |
num, key_type(pub), |
| 1085 |
ca ? " (CA key)" : ""); |
1087 |
ca ? " (CA key)" : ""); |
| 1086 |
printhost(out, name, pub, |
1088 |
printhost(out, name, kp, pub, |
| 1087 |
ca, hash_hosts && !ca); |
1089 |
ca, hash_hosts && !ca); |
| 1088 |
} |
1090 |
} |
| 1089 |
if (delete_host && !c && !ca) |
1091 |
if (delete_host && !c && !ca) |
| 1090 |
printhost(out, cp, pub, ca, 0); |
1092 |
printhost(out, cp, kp, pub, ca, 0); |
| 1091 |
} else if (hash_hosts) { |
1093 |
} else if (hash_hosts) { |
| 1092 |
for (cp2 = strsep(&cp, ","); |
1094 |
for (cp2 = strsep(&cp, ","); |
| 1093 |
cp2 != NULL && *cp2 != '\0'; |
1095 |
cp2 != NULL && *cp2 != '\0'; |
|
Lines 1096-1111
do_known_hosts(struct passwd *pw, const
Link Here
|
| 1096 |
fprintf(stderr, "Warning: " |
1098 |
fprintf(stderr, "Warning: " |
| 1097 |
"ignoring CA key for host: " |
1099 |
"ignoring CA key for host: " |
| 1098 |
"%.64s\n", cp2); |
1100 |
"%.64s\n", cp2); |
| 1099 |
printhost(out, cp2, pub, ca, 0); |
1101 |
printhost(out, cp2, kp, pub, |
|
|
1102 |
ca, 0); |
| 1100 |
} else if (strcspn(cp2, "*?!") != |
1103 |
} else if (strcspn(cp2, "*?!") != |
| 1101 |
strlen(cp2)) { |
1104 |
strlen(cp2)) { |
| 1102 |
fprintf(stderr, "Warning: " |
1105 |
fprintf(stderr, "Warning: " |
| 1103 |
"ignoring host name with " |
1106 |
"ignoring host name with " |
| 1104 |
"metacharacters: %.64s\n", |
1107 |
"metacharacters: %.64s\n", |
| 1105 |
cp2); |
1108 |
cp2); |
| 1106 |
printhost(out, cp2, pub, ca, 0); |
1109 |
printhost(out, cp2, kp, pub, |
|
|
1110 |
ca, 0); |
| 1107 |
} else |
1111 |
} else |
| 1108 |
printhost(out, cp2, pub, ca, 1); |
1112 |
printhost(out, cp2, kp, pub, |
|
|
1113 |
ca, 1); |
| 1109 |
} |
1114 |
} |
| 1110 |
has_unhashed = 1; |
1115 |
has_unhashed = 1; |
| 1111 |
} |
1116 |
} |