743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
|
zRepositorySchema2,
(char*)0
);
isNewRepo = 1;
}
/*
** Fill an empty repository database with the basic information for a
** repository. This function is shared between 'create_repository_cmd'
** ('new') and 'reconstruct_cmd' ('reconstruct'), both of which create
** new repositories.
**
** The makeInitialVersion flag determines whether or not an initial
** manifest is created. The makeServerCodes flag determines whether or
** not server and project codes are invented for this repository.
*/
void db_initial_setup (int makeInitialVersion, int makeServerCodes){
char *zDate;
const char *zUser;
Blob hash;
Blob manifest;
db_set("content-schema", CONTENT_SCHEMA, 0);
db_set("aux-schema", AUX_SCHEMA, 0);
if( makeServerCodes ){
db_multi_exec(
"INSERT INTO config(name,value)"
" VALUES('server-code', lower(hex(randomblob(20))));"
"INSERT INTO config(name,value)"
" VALUES('project-code', lower(hex(randomblob(20))));"
);
}
if( !db_is_global("autosync") ) db_set_int("autosync", 1, 0);
if( !db_is_global("localauth") ) db_set_int("localauth", 0, 0);
zUser = db_get("default-user", 0);
if( zUser==0 ){
#ifdef __MINGW32__
zUser = getenv("USERNAME");
#else
zUser = getenv("USER");
#endif
}
if( zUser==0 ){
zUser = "root";
}
db_multi_exec(
"INSERT INTO user(login, pw, cap, info)"
"VALUES(%Q,'','s','')", zUser
);
db_multi_exec(
"INSERT INTO user(login,pw,cap,info)"
" VALUES('anonymous','anonymous','aghknw','Anon');"
"INSERT INTO user(login,pw,cap,info)"
" VALUES('nobody','','jor','Nobody');"
"INSERT INTO user(login,pw,cap,info)"
" VALUES('developer','','deipt','Dev');"
);
user_select();
if (makeInitialVersion){
blob_zero(&manifest);
blob_appendf(&manifest, "C initial\\sempty\\sbaseline\n");
zDate = db_text(0, "SELECT datetime('now')");
zDate[10]='T';
|
|
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
|
zRepositorySchema2,
(char*)0
);
isNewRepo = 1;
}
/*
** Create the default user accounts in the USER table.
*/
void db_create_default_users(void){
const char *zUser;
zUser = db_get("default-user", 0);
if( zUser==0 ){
#ifdef __MINGW32__
zUser = getenv("USERNAME");
#else
zUser = getenv("USER");
#endif
}
if( zUser==0 ){
zUser = "root";
}
db_multi_exec(
"INSERT INTO user(login, pw, cap, info)"
"VALUES(%Q,'','s','')", zUser
);
db_multi_exec(
"INSERT INTO user(login,pw,cap,info)"
" VALUES('anonymous','anonymous','ghknw','Anon');"
"INSERT INTO user(login,pw,cap,info)"
" VALUES('nobody','','jor','Nobody');"
"INSERT INTO user(login,pw,cap,info)"
" VALUES('developer','','deipt','Dev');"
);
}
/*
** Fill an empty repository database with the basic information for a
** repository. This function is shared between 'create_repository_cmd'
** ('new') and 'reconstruct_cmd' ('reconstruct'), both of which create
** new repositories.
**
** The makeInitialVersion flag determines whether or not an initial
** manifest is created. The makeServerCodes flag determines whether or
** not server and project codes are invented for this repository.
*/
void db_initial_setup (int makeInitialVersion, int makeServerCodes){
char *zDate;
Blob hash;
Blob manifest;
db_set("content-schema", CONTENT_SCHEMA, 0);
db_set("aux-schema", AUX_SCHEMA, 0);
if( makeServerCodes ){
db_multi_exec(
"INSERT INTO config(name,value)"
" VALUES('server-code', lower(hex(randomblob(20))));"
"INSERT INTO config(name,value)"
" VALUES('project-code', lower(hex(randomblob(20))));"
);
}
if( !db_is_global("autosync") ) db_set_int("autosync", 1, 0);
if( !db_is_global("localauth") ) db_set_int("localauth", 0, 0);
db_create_default_users();
user_select();
if (makeInitialVersion){
blob_zero(&manifest);
blob_appendf(&manifest, "C initial\\sempty\\sbaseline\n");
zDate = db_text(0, "SELECT datetime('now')");
zDate[10]='T';
|