|
1 |
| -#define _ISOC11_SOURCE 1 |
2 |
| -#define __STDC_VERSION__ 201112L |
| 1 | +#define _GNU_SOURCE |
3 | 2 |
|
4 | 3 | #include <stdio.h>
|
5 | 4 | #include <sys/ioctl.h>
|
@@ -190,32 +189,15 @@ int main(int argc, char *const argv[]) {
|
190 | 189 | break;
|
191 | 190 | }
|
192 | 191 | }
|
193 |
| - while (!masterPassword) { |
194 |
| -#if defined(READLINE) |
195 |
| - masterPassword = readline( "Your master password: " ); |
196 |
| -#elif defined(EDITLINE) |
197 |
| - EditLine *e = el_init("mpw", stdin, stdout, stderr); |
198 |
| - int count = 0; |
199 |
| - char *line = el_gets(e, &count); |
200 |
| - masterPassword = strdup(strsep(&line, "\n")); |
201 |
| - el_end(e); |
202 |
| - |
203 |
| - if (count < 0) { |
204 |
| - fprintf(stderr, "Could not read master password: %d\n", errno); |
205 |
| - continue; |
206 |
| - } |
207 |
| -#else |
208 |
| - fprintf(stderr, "Missing master password for user: %s\n", userName); |
209 |
| - return 1; |
210 |
| -#endif |
211 |
| - } |
| 192 | + while (!masterPassword) |
| 193 | + masterPassword = getpass( "Your master password: " ); |
212 | 194 | trc("masterPassword: %s\n", masterPassword);
|
213 | 195 |
|
214 | 196 | // Calculate the master key salt.
|
215 | 197 | const char *mpKeyScope = ScopeForVariant(MPElementVariantPassword);
|
216 | 198 | trc("key scope: %s\n", mpKeyScope);
|
217 | 199 | const uint32_t n_userNameLength = htonl(strlen(userName));
|
218 |
| - size_t masterKeySaltLength = strlen(mpKeyScope) + sizeof(n_userNameLength) + strlen(userName); |
| 200 | + const size_t masterKeySaltLength = strlen(mpKeyScope) + sizeof(n_userNameLength) + strlen(userName); |
219 | 201 | char *masterKeySalt = malloc( masterKeySaltLength );
|
220 | 202 | if (!masterKeySalt) {
|
221 | 203 | fprintf(stderr, "Could not allocate master key salt: %d\n", errno);
|
@@ -251,7 +233,7 @@ int main(int argc, char *const argv[]) {
|
251 | 233 | trc("site scope: %s\n", mpSiteScope);
|
252 | 234 | const uint32_t n_siteNameLength = htonl(strlen(siteName));
|
253 | 235 | const uint32_t n_siteCounter = htonl(siteCounter);
|
254 |
| - size_t sitePasswordInfoLength = strlen(mpSiteScope) + sizeof(n_siteNameLength) + strlen(siteName) + sizeof(n_siteCounter); |
| 236 | + const size_t sitePasswordInfoLength = strlen(mpSiteScope) + sizeof(n_siteNameLength) + strlen(siteName) + sizeof(n_siteCounter); |
255 | 237 | char *sitePasswordInfo = malloc( sitePasswordInfoLength );
|
256 | 238 | if (!sitePasswordInfo) {
|
257 | 239 | fprintf(stderr, "Could not allocate site seed: %d\n", errno);
|
|
0 commit comments