Fossil SCM

docker experiment: create project-code at first valid push.

jan.nijtmans 2014-10-02 15:26 trunk
Commit 98e3626c0a1229e7deabe3a9e98610fa39192dbe
2 files changed -6 +10 -5
-6
--- src/db.c
+++ src/db.c
@@ -1335,16 +1335,10 @@
13351335
db_multi_exec(
13361336
"INSERT INTO config(name,value,mtime)"
13371337
" VALUES('server-code', lower(hex(randomblob(20))),now());"
13381338
);
13391339
}
1340
- if( db_get("project-code", 0)==0 ) {
1341
- db_multi_exec(
1342
- "INSERT INTO config(name,value,mtime)"
1343
- " VALUES('project-code', lower(hex(randomblob(20))),now());"
1344
- );
1345
- }
13461340
}
13471341
}
13481342
13491343
/*
13501344
** Return a pointer to a string that contains the RHS of an IN operator
13511345
--- src/db.c
+++ src/db.c
@@ -1335,16 +1335,10 @@
1335 db_multi_exec(
1336 "INSERT INTO config(name,value,mtime)"
1337 " VALUES('server-code', lower(hex(randomblob(20))),now());"
1338 );
1339 }
1340 if( db_get("project-code", 0)==0 ) {
1341 db_multi_exec(
1342 "INSERT INTO config(name,value,mtime)"
1343 " VALUES('project-code', lower(hex(randomblob(20))),now());"
1344 );
1345 }
1346 }
1347 }
1348
1349 /*
1350 ** Return a pointer to a string that contains the RHS of an IN operator
1351
--- src/db.c
+++ src/db.c
@@ -1335,16 +1335,10 @@
1335 db_multi_exec(
1336 "INSERT INTO config(name,value,mtime)"
1337 " VALUES('server-code', lower(hex(randomblob(20))),now());"
1338 );
1339 }
 
 
 
 
 
 
1340 }
1341 }
1342
1343 /*
1344 ** Return a pointer to a string that contains the RHS of an IN operator
1345
+10 -5
--- src/xfer.c
+++ src/xfer.c
@@ -1065,29 +1065,34 @@
10651065
10661066
/* pull SERVERCODE PROJECTCODE
10671067
** push SERVERCODE PROJECTCODE
10681068
**
10691069
** The client wants either send or receive. The server should
1070
- ** verify that the project code matches.
1070
+ ** verify that the project code matches. If there is no project
1071
+ ** code yet, set the new project code to the provided one.
10711072
*/
10721073
if( xfer.nToken==3
10731074
&& (blob_eq(&xfer.aToken[0], "pull") || blob_eq(&xfer.aToken[0], "push"))
10741075
&& blob_is_uuid(&xfer.aToken[1])
10751076
&& blob_is_uuid(&xfer.aToken[2])
10761077
){
10771078
const char *zPCode;
10781079
zPCode = db_get("project-code", 0);
1080
+ login_check_credentials();
10791081
if( zPCode==0 ){
1080
- fossil_panic("missing project code");
1081
- }
1082
- if( !blob_eq_str(&xfer.aToken[2], zPCode, -1) ){
1082
+ if( g.perm.Write ){
1083
+ db_set("project-code", blob_str(&xfer.aToken[2]), 0);
1084
+ zPCode = db_get("project-code", 0);
1085
+ }else{
1086
+ fossil_panic("missing project code");
1087
+ }
1088
+ } else if( !blob_eq_str(&xfer.aToken[2], zPCode, -1) ){
10831089
cgi_reset_content();
10841090
@ error wrong\sproject
10851091
nErr++;
10861092
break;
10871093
}
1088
- login_check_credentials();
10891094
if( blob_eq(&xfer.aToken[0], "pull") ){
10901095
if( !g.perm.Read ){
10911096
cgi_reset_content();
10921097
@ error not\sauthorized\sto\sread
10931098
nErr++;
10941099
--- src/xfer.c
+++ src/xfer.c
@@ -1065,29 +1065,34 @@
1065
1066 /* pull SERVERCODE PROJECTCODE
1067 ** push SERVERCODE PROJECTCODE
1068 **
1069 ** The client wants either send or receive. The server should
1070 ** verify that the project code matches.
 
1071 */
1072 if( xfer.nToken==3
1073 && (blob_eq(&xfer.aToken[0], "pull") || blob_eq(&xfer.aToken[0], "push"))
1074 && blob_is_uuid(&xfer.aToken[1])
1075 && blob_is_uuid(&xfer.aToken[2])
1076 ){
1077 const char *zPCode;
1078 zPCode = db_get("project-code", 0);
 
1079 if( zPCode==0 ){
1080 fossil_panic("missing project code");
1081 }
1082 if( !blob_eq_str(&xfer.aToken[2], zPCode, -1) ){
 
 
 
 
1083 cgi_reset_content();
1084 @ error wrong\sproject
1085 nErr++;
1086 break;
1087 }
1088 login_check_credentials();
1089 if( blob_eq(&xfer.aToken[0], "pull") ){
1090 if( !g.perm.Read ){
1091 cgi_reset_content();
1092 @ error not\sauthorized\sto\sread
1093 nErr++;
1094
--- src/xfer.c
+++ src/xfer.c
@@ -1065,29 +1065,34 @@
1065
1066 /* pull SERVERCODE PROJECTCODE
1067 ** push SERVERCODE PROJECTCODE
1068 **
1069 ** The client wants either send or receive. The server should
1070 ** verify that the project code matches. If there is no project
1071 ** code yet, set the new project code to the provided one.
1072 */
1073 if( xfer.nToken==3
1074 && (blob_eq(&xfer.aToken[0], "pull") || blob_eq(&xfer.aToken[0], "push"))
1075 && blob_is_uuid(&xfer.aToken[1])
1076 && blob_is_uuid(&xfer.aToken[2])
1077 ){
1078 const char *zPCode;
1079 zPCode = db_get("project-code", 0);
1080 login_check_credentials();
1081 if( zPCode==0 ){
1082 if( g.perm.Write ){
1083 db_set("project-code", blob_str(&xfer.aToken[2]), 0);
1084 zPCode = db_get("project-code", 0);
1085 }else{
1086 fossil_panic("missing project code");
1087 }
1088 } else if( !blob_eq_str(&xfer.aToken[2], zPCode, -1) ){
1089 cgi_reset_content();
1090 @ error wrong\sproject
1091 nErr++;
1092 break;
1093 }
 
1094 if( blob_eq(&xfer.aToken[0], "pull") ){
1095 if( !g.perm.Read ){
1096 cgi_reset_content();
1097 @ error not\sauthorized\sto\sread
1098 nErr++;
1099

Keyboard Shortcuts

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