diff options
-rw-r--r-- | debian/changelog | 1 | ||||
-rw-r--r-- | ssh-vulnkey.c | 96 |
2 files changed, 56 insertions, 41 deletions
diff --git a/debian/changelog b/debian/changelog index 299842d51..200979f74 100644 --- a/debian/changelog +++ b/debian/changelog | |||
@@ -1,6 +1,7 @@ | |||
1 | openssh (1:4.7p1-10) UNRELEASED; urgency=low | 1 | openssh (1:4.7p1-10) UNRELEASED; urgency=low |
2 | 2 | ||
3 | * Add a FILES section to ssh-vulnkey(1) (thanks, Hugh Daniel). | 3 | * Add a FILES section to ssh-vulnkey(1) (thanks, Hugh Daniel). |
4 | * ssh-vulnkey handles options in authorized_keys (LP: #230029). | ||
4 | 5 | ||
5 | -- Colin Watson <cjwatson@debian.org> Wed, 14 May 2008 09:47:29 +0100 | 6 | -- Colin Watson <cjwatson@debian.org> Wed, 14 May 2008 09:47:29 +0100 |
6 | 7 | ||
diff --git a/ssh-vulnkey.c b/ssh-vulnkey.c index ba87cbd28..3297c431a 100644 --- a/ssh-vulnkey.c +++ b/ssh-vulnkey.c | |||
@@ -138,55 +138,69 @@ do_filename(const char *filename, int quiet_open) | |||
138 | f = stdin; | 138 | f = stdin; |
139 | while (read_keyfile_line(f, filename, line, sizeof(line), | 139 | while (read_keyfile_line(f, filename, line, sizeof(line), |
140 | &linenum) != -1) { | 140 | &linenum) != -1) { |
141 | cp = line; | 141 | int i; |
142 | switch (*cp) { | 142 | char *space; |
143 | case '#': | 143 | int type; |
144 | case '\n': | 144 | |
145 | case '\0': | 145 | /* Chop trailing newline. */ |
146 | continue; | 146 | i = strlen(line) - 1; |
147 | } | 147 | if (line[i] == '\n') |
148 | /* Skip leading whitespace. */ | 148 | line[i] = '\0'; |
149 | for (; *cp && (*cp == ' ' || *cp == '\t'); cp++) | 149 | |
150 | /* Skip leading whitespace, empty and comment lines. */ | ||
151 | for (cp = line; *cp == ' ' || *cp == '\t'; cp++) | ||
150 | ; | 152 | ; |
151 | /* Cope with ssh-keyscan output. */ | 153 | if (!*cp || *cp == '\n' || *cp == '#') |
152 | comment = NULL; | 154 | continue; |
153 | if (*cp) { | 155 | |
154 | char *space; | 156 | /* Cope with ssh-keyscan output and options in |
155 | int type; | 157 | * authorized_keys files. |
156 | 158 | */ | |
157 | space = strchr(cp, ' '); | 159 | space = strchr(cp, ' '); |
158 | if (!space) | 160 | if (!space) |
159 | continue; | 161 | continue; |
160 | *space = '\0'; | 162 | *space = '\0'; |
161 | type = key_type_from_name(cp); | 163 | type = key_type_from_name(cp); |
162 | if (type == KEY_UNSPEC) { | 164 | *space = ' '; |
163 | comment = xstrdup(cp); | 165 | /* Leading number (RSA1) or valid type (RSA/DSA) indicates |
164 | cp = space + 1; | 166 | * that we have no host name or options to skip. |
167 | */ | ||
168 | if (atoi(cp) == 0 && type == KEY_UNSPEC) { | ||
169 | int quoted = 0; | ||
170 | |||
171 | for (; *cp && (quoted || (*cp != ' ' && *cp != '\t')); cp++) { | ||
172 | if (*cp == '\\' && cp[1] == '"') | ||
173 | cp++; /* Skip both */ | ||
174 | else if (*cp == '"') | ||
175 | quoted = !quoted; | ||
165 | } | 176 | } |
166 | *space = ' '; | 177 | /* Skip remaining whitespace. */ |
178 | for (; *cp == ' ' || *cp == '\t'; cp++) | ||
179 | ; | ||
180 | if (!*cp) | ||
181 | continue; | ||
167 | } | 182 | } |
168 | if (!comment) | 183 | |
169 | comment = xstrdup(filename); | 184 | /* Read and process the key itself. */ |
170 | if (*cp) { | 185 | key = key_new(KEY_RSA1); |
171 | key = key_new(KEY_RSA1); | 186 | if (key_read(key, &cp) == 1) { |
187 | while (*cp == ' ' || *cp == '\t') | ||
188 | cp++; | ||
189 | if (!do_key(key, *cp ? cp : filename)) | ||
190 | ret = 0; | ||
191 | found = 1; | ||
192 | } else { | ||
193 | key_free(key); | ||
194 | key = key_new(KEY_UNSPEC); | ||
172 | if (key_read(key, &cp) == 1) { | 195 | if (key_read(key, &cp) == 1) { |
173 | if (!do_key(key, comment)) | 196 | while (*cp == ' ' || *cp == '\t') |
197 | cp++; | ||
198 | if (!do_key(key, *cp ? cp : filename)) | ||
174 | ret = 0; | 199 | ret = 0; |
175 | key_free(key); | ||
176 | found = 1; | 200 | found = 1; |
177 | } else { | ||
178 | key_free(key); | ||
179 | key = key_new(KEY_UNSPEC); | ||
180 | if (key_read(key, &cp) == 1) { | ||
181 | if (!do_key(key, comment)) | ||
182 | ret = 0; | ||
183 | key_free(key); | ||
184 | found = 1; | ||
185 | } | ||
186 | } | 201 | } |
187 | } | 202 | } |
188 | xfree(comment); | 203 | key_free(key); |
189 | comment = NULL; | ||
190 | } | 204 | } |
191 | if (f != stdin) | 205 | if (f != stdin) |
192 | fclose(f); | 206 | fclose(f); |