Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Add the fossil_random_password() utility function and use it to generate a stronger initial admin-user password in the "fossil new" command. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
23a9f9bac2aaddb55e5d72689fcf4bb0 |
| User & Date: | drh 2019-08-23 12:42:56.884 |
References
|
2019-08-29
| ||
| 00:28 | Updated comment about "6-character random hex password" at the top level of the new setup docs to track [23a9f9bac2]. check-in: f304ba31fe user: wyoung tags: trunk | |
Context
|
2019-08-27
| ||
| 00:11 | On the /vdiff page, show a timeline with both check-ins using different highlights on each check-in. check-in: 6e40f866ab user: drh tags: vdiff-improvements | |
|
2019-08-24
| ||
| 18:32 | Merge fork check-in: 6c6aae9782 user: andygoth tags: trunk | |
|
2019-08-23
| ||
| 12:42 | Add the fossil_random_password() utility function and use it to generate a stronger initial admin-user password in the "fossil new" command. check-in: 23a9f9bac2 user: drh tags: trunk | |
| 12:23 | If the test-markdown-render or test-wiki-render commands are invoked without a repository in which to check for Wiki page names and artifact hashes, then substitute a temporary, empty, in-memory repository so that the commands will still work and won't give SQL errors. check-in: 0ac64dad80 user: drh tags: trunk | |
Changes
Changes to src/db.c.
| ︙ | ︙ | |||
2044 2045 2046 2047 2048 2049 2050 |
if( zUser==0 ){
zUser = "root";
}
db_multi_exec(
"INSERT OR IGNORE INTO user(login, info) VALUES(%Q,'')", zUser
);
db_multi_exec(
| | | | 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 |
if( zUser==0 ){
zUser = "root";
}
db_multi_exec(
"INSERT OR IGNORE INTO user(login, info) VALUES(%Q,'')", zUser
);
db_multi_exec(
"UPDATE user SET cap='s', pw=%Q"
" WHERE login=%Q", fossil_random_password(10), zUser
);
if( !setupUserOnly ){
db_multi_exec(
"INSERT OR IGNORE INTO user(login,pw,cap,info)"
" VALUES('anonymous',hex(randomblob(8)),'hmnc','Anon');"
"INSERT OR IGNORE INTO user(login,pw,cap,info)"
" VALUES('nobody','','gjorz','Nobody');"
|
| ︙ | ︙ |
Changes to src/util.c.
| ︙ | ︙ | |||
523 524 525 526 527 528 529 |
void fossil_pledge(const char *promises){
if( pledge(promises, 0) ){
fossil_panic("pledge(\"%s\",NULL) fails with errno=%d",
promises, (int)errno);
}
}
#endif /* defined(HAVE_PLEDGE) */
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 |
void fossil_pledge(const char *promises){
if( pledge(promises, 0) ){
fossil_panic("pledge(\"%s\",NULL) fails with errno=%d",
promises, (int)errno);
}
}
#endif /* defined(HAVE_PLEDGE) */
/*
** Construct a random password and return it as a string. N is the
** recommended number of characters for the password.
**
** Space to hold the returned string is obtained from fossil_malloc()
** and should be freed by the caller.
*/
char *fossil_random_password(int N){
char zSrc[60];
int nSrc;
int i;
char z[60];
/* Source characters for the password. Omit characters like "0", "O",
** "1" and "I" that might be easily confused */
static const char zAlphabet[] =
/* 0 1 2 3 4 5 */
/* 123456789 123456789 123456789 123456789 123456789 123456 */
"23456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ";
if( N<8 ) N = 8;
else if( N>sizeof(zAlphabet)-2 ) N = sizeof(zAlphabet)-2;
nSrc = sizeof(zAlphabet) - 1;
memcpy(zSrc, zAlphabet, nSrc);
for(i=0; i<N; i++){
unsigned r;
sqlite3_randomness(sizeof(r), &r);
r %= nSrc;
z[i] = zSrc[r];
zSrc[r] = zSrc[--nSrc];
}
z[i] = 0;
return fossil_strdup(z);
}
/*
** COMMAND: test-random-password
**
** Usage: %fossil test-random-password ?N?
**
** Generate a random password string of approximately N characters in length.
** If N is omitted, use 10. Values of N less than 8 are changed to 8
** and greater than 55 and changed to 55.
*/
void test_random_password(void){
int N = 10;
if( g.argc>=3 ){
N = atoi(g.argv[2]);
}
fossil_print("%s\n", fossil_random_password(N));
}
|