Fossil SCM

Added --admin-user|-A USERNAME to the new command which will set the default admin user name. If not supplied, the existing mechanism is used to determine the default user name. This implements [9195b1e5f3].

jeremy_c 2010-01-26 14:38 trunk
Commit b8d812efb91513b22723b65f8b52a1c7349bb4b1
+2 -2
--- src/clone.c
+++ src/clone.c
@@ -66,19 +66,19 @@
6666
"DELETE FROM private;"
6767
);
6868
shun_artifacts();
6969
g.zLogin = db_text(0, "SELECT login FROM user WHERE cap LIKE '%%s%%'");
7070
if( g.zLogin==0 ){
71
- db_create_default_users(1);
71
+ db_create_default_users(1,0);
7272
}
7373
printf("Repository cloned into %s\n", g.argv[3]);
7474
}else{
7575
db_create_repository(g.argv[3]);
7676
db_open_repository(g.argv[3]);
7777
db_begin_transaction();
7878
db_record_repository_filename(g.argv[3]);
79
- db_initial_setup(0, 0);
79
+ db_initial_setup(0, 0, 0);
8080
user_select();
8181
db_set("content-schema", CONTENT_SCHEMA, 0);
8282
db_set("aux-schema", AUX_SCHEMA, 0);
8383
db_set("last-sync-url", g.argv[2], 0);
8484
db_multi_exec(
8585
--- src/clone.c
+++ src/clone.c
@@ -66,19 +66,19 @@
66 "DELETE FROM private;"
67 );
68 shun_artifacts();
69 g.zLogin = db_text(0, "SELECT login FROM user WHERE cap LIKE '%%s%%'");
70 if( g.zLogin==0 ){
71 db_create_default_users(1);
72 }
73 printf("Repository cloned into %s\n", g.argv[3]);
74 }else{
75 db_create_repository(g.argv[3]);
76 db_open_repository(g.argv[3]);
77 db_begin_transaction();
78 db_record_repository_filename(g.argv[3]);
79 db_initial_setup(0, 0);
80 user_select();
81 db_set("content-schema", CONTENT_SCHEMA, 0);
82 db_set("aux-schema", AUX_SCHEMA, 0);
83 db_set("last-sync-url", g.argv[2], 0);
84 db_multi_exec(
85
--- src/clone.c
+++ src/clone.c
@@ -66,19 +66,19 @@
66 "DELETE FROM private;"
67 );
68 shun_artifacts();
69 g.zLogin = db_text(0, "SELECT login FROM user WHERE cap LIKE '%%s%%'");
70 if( g.zLogin==0 ){
71 db_create_default_users(1,0);
72 }
73 printf("Repository cloned into %s\n", g.argv[3]);
74 }else{
75 db_create_repository(g.argv[3]);
76 db_open_repository(g.argv[3]);
77 db_begin_transaction();
78 db_record_repository_filename(g.argv[3]);
79 db_initial_setup(0, 0, 0);
80 user_select();
81 db_set("content-schema", CONTENT_SCHEMA, 0);
82 db_set("aux-schema", AUX_SCHEMA, 0);
83 db_set("last-sync-url", g.argv[2], 0);
84 db_multi_exec(
85
+1 -1
--- src/configure.c
+++ src/configure.c
@@ -487,11 +487,11 @@
487487
if( (aConfig[i].groupMask & mask)==0 ) continue;
488488
if( zName[0]!='@' ){
489489
db_multi_exec("DELETE FROM config WHERE name=%Q", zName);
490490
}else if( strcmp(zName,"@user")==0 ){
491491
db_multi_exec("DELETE FROM user");
492
- db_create_default_users(0);
492
+ db_create_default_users(0, 0);
493493
}else if( strcmp(zName,"@concealed")==0 ){
494494
db_multi_exec("DELETE FROM concealed");
495495
}else if( strcmp(zName,"@shun")==0 ){
496496
db_multi_exec("DELETE FROM shun");
497497
}else if( strcmp(zName,"@reportfmt")==0 ){
498498
--- src/configure.c
+++ src/configure.c
@@ -487,11 +487,11 @@
487 if( (aConfig[i].groupMask & mask)==0 ) continue;
488 if( zName[0]!='@' ){
489 db_multi_exec("DELETE FROM config WHERE name=%Q", zName);
490 }else if( strcmp(zName,"@user")==0 ){
491 db_multi_exec("DELETE FROM user");
492 db_create_default_users(0);
493 }else if( strcmp(zName,"@concealed")==0 ){
494 db_multi_exec("DELETE FROM concealed");
495 }else if( strcmp(zName,"@shun")==0 ){
496 db_multi_exec("DELETE FROM shun");
497 }else if( strcmp(zName,"@reportfmt")==0 ){
498
--- src/configure.c
+++ src/configure.c
@@ -487,11 +487,11 @@
487 if( (aConfig[i].groupMask & mask)==0 ) continue;
488 if( zName[0]!='@' ){
489 db_multi_exec("DELETE FROM config WHERE name=%Q", zName);
490 }else if( strcmp(zName,"@user")==0 ){
491 db_multi_exec("DELETE FROM user");
492 db_create_default_users(0, 0);
493 }else if( strcmp(zName,"@concealed")==0 ){
494 db_multi_exec("DELETE FROM concealed");
495 }else if( strcmp(zName,"@shun")==0 ){
496 db_multi_exec("DELETE FROM shun");
497 }else if( strcmp(zName,"@reportfmt")==0 ){
498
+1 -1
--- src/construct.c
+++ src/construct.c
@@ -140,11 +140,11 @@
140140
db_create_repository(zRepository);
141141
db_open_repository(zRepository);
142142
db_open_config(0);
143143
db_begin_transaction();
144144
145
- db_initial_setup(0, 1);
145
+ db_initial_setup(0, 0, 1);
146146
147147
printf("project-id: %s\n", db_get("project-code", 0));
148148
printf("server-id: %s\n", db_get("server-code", 0));
149149
printf("admin-user: %s (no password set yet!)\n", g.zLogin);
150150
printf("baseline: %s\n", db_text(0, "SELECT uuid FROM blob"));
151151
--- src/construct.c
+++ src/construct.c
@@ -140,11 +140,11 @@
140 db_create_repository(zRepository);
141 db_open_repository(zRepository);
142 db_open_config(0);
143 db_begin_transaction();
144
145 db_initial_setup(0, 1);
146
147 printf("project-id: %s\n", db_get("project-code", 0));
148 printf("server-id: %s\n", db_get("server-code", 0));
149 printf("admin-user: %s (no password set yet!)\n", g.zLogin);
150 printf("baseline: %s\n", db_text(0, "SELECT uuid FROM blob"));
151
--- src/construct.c
+++ src/construct.c
@@ -140,11 +140,11 @@
140 db_create_repository(zRepository);
141 db_open_repository(zRepository);
142 db_open_config(0);
143 db_begin_transaction();
144
145 db_initial_setup(0, 0, 1);
146
147 printf("project-id: %s\n", db_get("project-code", 0));
148 printf("server-id: %s\n", db_get("server-code", 0));
149 printf("admin-user: %s (no password set yet!)\n", g.zLogin);
150 printf("baseline: %s\n", db_text(0, "SELECT uuid FROM blob"));
151
+19 -5
--- src/db.c
+++ src/db.c
@@ -922,13 +922,16 @@
922922
}
923923
924924
/*
925925
** Create the default user accounts in the USER table.
926926
*/
927
-void db_create_default_users(int setupUserOnly){
927
+void db_create_default_users(int setupUserOnly, const char *zDefaultUser){
928928
const char *zUser;
929929
zUser = db_get("default-user", 0);
930
+ if( zUser==0 ){
931
+ zUser = zDefaultUser;
932
+ }
930933
if( zUser==0 ){
931934
#ifdef __MINGW32__
932935
zUser = getenv("USERNAME");
933936
#else
934937
zUser = getenv("USER");
@@ -964,11 +967,11 @@
964967
** The zInitialDate parameter determines the date of the initial check-in
965968
** that is automatically created. If zInitialDate is 0 then no initial
966969
** check-in is created. The makeServerCodes flag determines whether or
967970
** not server and project codes are invented for this repository.
968971
*/
969
-void db_initial_setup (const char *zInitialDate, int makeServerCodes){
972
+void db_initial_setup (const char *zInitialDate, const char *zDefaultUser, int makeServerCodes){
970973
char *zDate;
971974
Blob hash;
972975
Blob manifest;
973976
974977
db_set("content-schema", CONTENT_SCHEMA, 0);
@@ -981,11 +984,11 @@
981984
" VALUES('project-code', lower(hex(randomblob(20))));"
982985
);
983986
}
984987
if( !db_is_global("autosync") ) db_set_int("autosync", 1, 0);
985988
if( !db_is_global("localauth") ) db_set_int("localauth", 0, 0);
986
- db_create_default_users(0);
989
+ db_create_default_users(0, zDefaultUser);
987990
user_select();
988991
989992
if( zInitialDate ){
990993
int rid;
991994
blob_zero(&manifest);
@@ -1008,30 +1011,41 @@
10081011
}
10091012
10101013
/*
10111014
** COMMAND: new
10121015
**
1013
-** Usage: %fossil new FILENAME
1016
+** Usage: %fossil new ?OPTIONS? FILENAME
10141017
**
10151018
** Create a repository for a new project in the file named FILENAME.
10161019
** This command is distinct from "clone". The "clone" command makes
10171020
** a copy of an existing project. This command starts a new project.
1021
+**
1022
+** By default, your current login name is used to create the default
1023
+** admin user. This can be overridden using the -A|--admin-user
1024
+** parameter.
1025
+**
1026
+** Options:
1027
+**
1028
+** --admin-user|-A USERNAME
1029
+**
10181030
*/
10191031
void create_repository_cmd(void){
10201032
char *zPassword;
10211033
const char *zDate; /* Date of the initial check-in */
1034
+ const char *zDefaultUser; /* Optional name of the default user */
10221035
10231036
zDate = find_option("date-override",0,1);
1037
+ zDefaultUser = find_option("admin-user","A",1);
10241038
if( zDate==0 ) zDate = "now";
10251039
if( g.argc!=3 ){
10261040
usage("REPOSITORY-NAME");
10271041
}
10281042
db_create_repository(g.argv[2]);
10291043
db_open_repository(g.argv[2]);
10301044
db_open_config(0);
10311045
db_begin_transaction();
1032
- db_initial_setup(zDate, 1);
1046
+ db_initial_setup(zDate, zDefaultUser, 1);
10331047
db_end_transaction(0);
10341048
printf("project-id: %s\n", db_get("project-code", 0));
10351049
printf("server-id: %s\n", db_get("server-code", 0));
10361050
zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin);
10371051
printf("admin-user: %s (initial password is \"%s\")\n", g.zLogin, zPassword);
10381052
--- src/db.c
+++ src/db.c
@@ -922,13 +922,16 @@
922 }
923
924 /*
925 ** Create the default user accounts in the USER table.
926 */
927 void db_create_default_users(int setupUserOnly){
928 const char *zUser;
929 zUser = db_get("default-user", 0);
 
 
 
930 if( zUser==0 ){
931 #ifdef __MINGW32__
932 zUser = getenv("USERNAME");
933 #else
934 zUser = getenv("USER");
@@ -964,11 +967,11 @@
964 ** The zInitialDate parameter determines the date of the initial check-in
965 ** that is automatically created. If zInitialDate is 0 then no initial
966 ** check-in is created. The makeServerCodes flag determines whether or
967 ** not server and project codes are invented for this repository.
968 */
969 void db_initial_setup (const char *zInitialDate, int makeServerCodes){
970 char *zDate;
971 Blob hash;
972 Blob manifest;
973
974 db_set("content-schema", CONTENT_SCHEMA, 0);
@@ -981,11 +984,11 @@
981 " VALUES('project-code', lower(hex(randomblob(20))));"
982 );
983 }
984 if( !db_is_global("autosync") ) db_set_int("autosync", 1, 0);
985 if( !db_is_global("localauth") ) db_set_int("localauth", 0, 0);
986 db_create_default_users(0);
987 user_select();
988
989 if( zInitialDate ){
990 int rid;
991 blob_zero(&manifest);
@@ -1008,30 +1011,41 @@
1008 }
1009
1010 /*
1011 ** COMMAND: new
1012 **
1013 ** Usage: %fossil new FILENAME
1014 **
1015 ** Create a repository for a new project in the file named FILENAME.
1016 ** This command is distinct from "clone". The "clone" command makes
1017 ** a copy of an existing project. This command starts a new project.
 
 
 
 
 
 
 
 
 
1018 */
1019 void create_repository_cmd(void){
1020 char *zPassword;
1021 const char *zDate; /* Date of the initial check-in */
 
1022
1023 zDate = find_option("date-override",0,1);
 
1024 if( zDate==0 ) zDate = "now";
1025 if( g.argc!=3 ){
1026 usage("REPOSITORY-NAME");
1027 }
1028 db_create_repository(g.argv[2]);
1029 db_open_repository(g.argv[2]);
1030 db_open_config(0);
1031 db_begin_transaction();
1032 db_initial_setup(zDate, 1);
1033 db_end_transaction(0);
1034 printf("project-id: %s\n", db_get("project-code", 0));
1035 printf("server-id: %s\n", db_get("server-code", 0));
1036 zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin);
1037 printf("admin-user: %s (initial password is \"%s\")\n", g.zLogin, zPassword);
1038
--- src/db.c
+++ src/db.c
@@ -922,13 +922,16 @@
922 }
923
924 /*
925 ** Create the default user accounts in the USER table.
926 */
927 void db_create_default_users(int setupUserOnly, const char *zDefaultUser){
928 const char *zUser;
929 zUser = db_get("default-user", 0);
930 if( zUser==0 ){
931 zUser = zDefaultUser;
932 }
933 if( zUser==0 ){
934 #ifdef __MINGW32__
935 zUser = getenv("USERNAME");
936 #else
937 zUser = getenv("USER");
@@ -964,11 +967,11 @@
967 ** The zInitialDate parameter determines the date of the initial check-in
968 ** that is automatically created. If zInitialDate is 0 then no initial
969 ** check-in is created. The makeServerCodes flag determines whether or
970 ** not server and project codes are invented for this repository.
971 */
972 void db_initial_setup (const char *zInitialDate, const char *zDefaultUser, int makeServerCodes){
973 char *zDate;
974 Blob hash;
975 Blob manifest;
976
977 db_set("content-schema", CONTENT_SCHEMA, 0);
@@ -981,11 +984,11 @@
984 " VALUES('project-code', lower(hex(randomblob(20))));"
985 );
986 }
987 if( !db_is_global("autosync") ) db_set_int("autosync", 1, 0);
988 if( !db_is_global("localauth") ) db_set_int("localauth", 0, 0);
989 db_create_default_users(0, zDefaultUser);
990 user_select();
991
992 if( zInitialDate ){
993 int rid;
994 blob_zero(&manifest);
@@ -1008,30 +1011,41 @@
1011 }
1012
1013 /*
1014 ** COMMAND: new
1015 **
1016 ** Usage: %fossil new ?OPTIONS? FILENAME
1017 **
1018 ** Create a repository for a new project in the file named FILENAME.
1019 ** This command is distinct from "clone". The "clone" command makes
1020 ** a copy of an existing project. This command starts a new project.
1021 **
1022 ** By default, your current login name is used to create the default
1023 ** admin user. This can be overridden using the -A|--admin-user
1024 ** parameter.
1025 **
1026 ** Options:
1027 **
1028 ** --admin-user|-A USERNAME
1029 **
1030 */
1031 void create_repository_cmd(void){
1032 char *zPassword;
1033 const char *zDate; /* Date of the initial check-in */
1034 const char *zDefaultUser; /* Optional name of the default user */
1035
1036 zDate = find_option("date-override",0,1);
1037 zDefaultUser = find_option("admin-user","A",1);
1038 if( zDate==0 ) zDate = "now";
1039 if( g.argc!=3 ){
1040 usage("REPOSITORY-NAME");
1041 }
1042 db_create_repository(g.argv[2]);
1043 db_open_repository(g.argv[2]);
1044 db_open_config(0);
1045 db_begin_transaction();
1046 db_initial_setup(zDate, zDefaultUser, 1);
1047 db_end_transaction(0);
1048 printf("project-id: %s\n", db_get("project-code", 0));
1049 printf("server-id: %s\n", db_get("server-code", 0));
1050 zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin);
1051 printf("admin-user: %s (initial password is \"%s\")\n", g.zLogin, zPassword);
1052

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button