Diff
Not logged in

Differences From:

File src/db.c part of check-in [1f1d96529c] - Users unconditionally inherit capabilities of "anonymous". New capability "v" means to inherit capabilities of user "developer". Login is prohibited if the password is empty. by drh on 2008-08-03 16:47:43. Also file src/db.c part of check-in [5fb14b9a0f] - Include non-sym- tags in tagview web page. Also merge mainline into tagview branch. by eric on 2008-08-21 20:59:01. [view]

To:

File src/db.c part of check-in [bf75ea9852] - The "configuration" command will now sync ticket report formats, shunned UUIDs, and user information (but not user passwords). Added the "config merge" method. Fix an initialization bug that was given Admin privilege to anonymous by default. by drh on 2008-10-04 20:40:27. [view]

@@ -746,35 +746,12 @@
   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);
+** 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");
@@ -790,14 +767,44 @@
      "VALUES(%Q,'','s','')", zUser
   );
   db_multi_exec(
      "INSERT INTO user(login,pw,cap,info)"
-     "   VALUES('anonymous','anonymous','aghknw','Anon');"
+     "   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);