xaizek / rocketgit (License: AGPLv3+) (since 2018-12-09)
Light and fast Git hosting solution suitable to serve both as a hub or as a personal code storage with its tickets, pull requests, API and much more.
Commit 3f1836953c50735c7860da1f951eb82a42a1940b

Big change allowing http and https to work in parallel
Author: Catalin(ux) M. BOIE
Author date (UTC): 2017-05-24 15:19
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2017-05-24 16:51
Parent(s): 6c355fe874750a9b5f454cbeeea28b5cf0f00236
Signing key:
Tree: e50d8ad0993205ed46483143c87de90ba75f59e4
File Lines added Lines deleted
inc/admin.inc.php 80 1
inc/bug.inc.php 4 2
inc/git.inc.php 1 2
inc/repo.inc.php 7 6
inc/user.inc.php 12 5
inc/user/repo/bug/main.php 1 1
inc/util.inc.php 33 16
root/index.php 66 4
root/themes/default/admin/settings/menu.html 1 0
root/themes/default/admin/settings/web/hints.html 5 0
root/themes/default/admin/settings/web/main.html 30 0
root/themes/default/doc/api.html 24 24
root/themes/default/hints/repo/clone_http.html 1 1
root/themes/default/mail/user/welcome.body.txt 1 1
root/themes/default/repo/bug/list_note/line.html 1 1
root/themes/default/user/hints/login.html 12 0
root/themes/default/user/settings/apikeys/hints.html 1 1
samples/config.php 0 5
samples/rg.conf 29 10
scripts/remote.php 9 0
tests/admin_set_web.php 13 11
tests/config.php 4 3
tests/http.inc.php 17 7
File inc/admin.inc.php changed (mode: 100644) (index d297e7e..2396e8d)
... ... function rg_clean_logs($dir)
475 475 } }
476 476 } }
477 477
478 /*
479 * Admin ->Settings -> Web menu
480 */
481 function rg_admin_settings_web($db, $rg)
482 {
483 rg_log_enter('admin_settings_web');
484
485 $ret = '';
486 $errmsg = array();
487 $hints = array();
488 while ($rg['doit'] == 1) {
489 if (!rg_valid_referer()) {
490 $errmsg[] = 'invalid referer; try again';
491 break;
492 }
493
494 if (!rg_token_valid($db, $rg, 'admin_settings_web', FALSE)) {
495 $errmsg[] = 'invalid token; try again';
496 break;
497 }
498
499 $hostname = rg_var_str('hostname');
500 $http_allow = rg_var_uint('http_allow');
501 $https_allow = rg_var_uint('https_allow');
502
503 if (($http_allow == 0) && ($https_allow == 0)) {
504 $errmsg[] = 'you must enable at least one of HTTP/HTTPS';
505 break;
506 }
507
508 $r = rg_state_set($db, 'hostname', $hostname);
509 if ($r === FALSE) {
510 $errmsg[] = 'cannot set state; try again';
511 break;
512 }
513
514 $r = rg_state_set($db, 'http_allow', $http_allow);
515 if ($r === FALSE) {
516 $errmsg[] = 'cannot set state; try again';
517 break;
518 }
519
520 $r = rg_state_set($db, 'https_allow', $https_allow);
521 if ($r === FALSE) {
522 $errmsg[] = 'cannot set state; try again';
523 break;
524 }
525
526 $rg['hostname'] = $hostname;
527 $rg['http_allow'] = $http_allow;
528 $rg['https_allow'] = $https_allow;
529
530 $ret .= rg_template('admin/settings/ok.html',
531 $rg, TRUE /*xss*/);
532 break;
533 }
534
535 // Load defaults
536 while (1) {
537 // Data is already in $rg
538 break;
539 }
540
541 $hints[]['HTML:hint'] = rg_template('admin/settings/web/hints.html',
542 $rg, TRUE /*xss*/);
543
544 $rg['HTML:hints'] = rg_template_table('hints/list', $hints, $rg);
545 $rg['HTML:errmsg'] = rg_template_errmsg($errmsg);
546 $rg['rg_form_token'] = rg_token_get($db, $rg, 'admin_settings_web');
547 $ret .= rg_template('admin/settings/web/main.html', $rg, TRUE /*xss*/);
548
549 rg_log_exit();
550 return $ret;
551 }
552
478 553 /* /*
479 554 * Admin ->Settings -> SSH menu * Admin ->Settings -> SSH menu
480 555 */ */
 
... ... function rg_admin_settings($db, &$rg, $paras)
691 766
692 767 $ret = ''; $ret = '';
693 768
694 $_op = empty($paras) ? 'ssh' : array_shift($paras);
769 $_op = empty($paras) ? 'web' : array_shift($paras);
695 770
696 771 $rg['url_up'] = $rg['url']; $rg['url_up'] = $rg['url'];
697 772 $rg['url'] .= '/' . $_op; $rg['url'] .= '/' . $_op;
 
... ... function rg_admin_settings($db, &$rg, $paras)
701 776 $rg, TRUE /*xss*/); $rg, TRUE /*xss*/);
702 777
703 778 switch ($_op) { switch ($_op) {
779 case 'web':
780 $ret .= rg_admin_settings_web($db, $rg);
781 break;
782
704 783 case 'ssh': case 'ssh':
705 784 $ret .= rg_admin_settings_ssh($db, $rg); $ret .= rg_admin_settings_ssh($db, $rg);
706 785 break; break;
File inc/bug.inc.php changed (mode: 100644) (index 34af410..5e5e135)
... ... function rg_bug_note_add($db, $repo_id, $bug_id, $login_uid, $data)
977 977 'bug' => array( 'bug' => array(
978 978 'bug_id' => $bug_id, 'bug_id' => $bug_id,
979 979 'title' => $_bi['title'], 'title' => $_bi['title'],
980 'url' => $_ri['url_repo'] . '/bug/' . $bug_id),
980 'url' => rg_base_url()
981 . rg_re_bugpage($_ui, $_ri['name'], $bug_id)
982 ),
981 983 'ri' => array( 'ri' => array(
982 984 'repo_id' => $repo_id, 'repo_id' => $repo_id,
983 985 'name' => $_ri['name']), 'name' => $_ri['name']),
 
... ... function rg_bug_note_list($db, $repo_id, $bug_id, $offset)
1035 1037 $_ui = rg_user_info($db, $row['uid'], "", ""); $_ui = rg_user_info($db, $row['uid'], "", "");
1036 1038 if ($_ui['exists'] == 1) { if ($_ui['exists'] == 1) {
1037 1039 $row['note_owner'] = $_ui['username']; $row['note_owner'] = $_ui['username'];
1038 $row['note_owner_url'] = rg_base_url() . rg_re_userpage($_ui);
1040 $row['note_owner_url'] = rg_re_userpage($_ui);
1039 1041 $row['HTML:note_gravatar'] = $_ui['HTML:gravatar']; $row['HTML:note_gravatar'] = $_ui['HTML:gravatar'];
1040 1042 } else { } else {
1041 1043 $row['note_owner'] = "?"; $row['note_owner'] = "?";
File inc/git.inc.php changed (mode: 100644) (index 125262c..ee5fa2f)
... ... function rg_git_update_branch($db, $a)
1773 1773 'repo_id' => $a['repo_id'], 'repo_id' => $a['repo_id'],
1774 1774 'name' => $a['repo_name'], 'name' => $a['repo_name'],
1775 1775 'url' => rg_base_url() . $a['login_url'] 'url' => rg_base_url() . $a['login_url']
1776 . '/' . $a['repo_name'],
1777 'clone_url' => $a['repo_clone_url_http']
1776 . '/' . $a['repo_name']
1778 1777 ); );
1779 1778 unset($ev['repo_id']); unset($ev['repo_name']); unset($ev['repo_id']); unset($ev['repo_name']);
1780 1779 $r = rg_event_add($db, $ev); $r = rg_event_add($db, $ev);
File inc/repo.inc.php changed (mode: 100644) (index 34e5165..d4017e7)
... ... function rg_repo_cosmetic($db, &$row)
123 123 $_ui = rg_user_info($db, $row['uid'], '', ''); $_ui = rg_user_info($db, $row['uid'], '', '');
124 124 if ($_ui['exists'] == 1) { if ($_ui['exists'] == 1) {
125 125 $row['owner'] = $_ui['username']; $row['owner'] = $_ui['username'];
126 $row['url_user'] = rg_base_url() . rg_re_userpage($_ui);
127 $row['url_repo'] = rg_base_url() . rg_re_repopage($_ui, $row['name']);
126 $row['url_user'] = rg_re_userpage($_ui);
127 $row['url_repo'] = rg_re_repopage($_ui, $row['name']);
128 128
129 129 $row['clone_url_ssh'] = rg_re_repo_ssh($_ui['organization'], $row['clone_url_ssh'] = rg_re_repo_ssh($_ui['organization'],
130 130 $_ui['username'], $row['name']); $_ui['username'], $row['name']);
131 131 $row['clone_url_git'] = rg_re_repo_git($_ui['organization'], $row['clone_url_git'] = rg_re_repo_git($_ui['organization'],
132 132 $_ui['username'], $row['name']); $_ui['username'], $row['name']);
133 $row['clone_url_http'] = rg_re_repo_http($_ui['organization'],
134 $_ui['username'], $row['name']);
133 $row['clone_url_http'] = rg_base_url()
134 . rg_re_repo_http($_ui['organization'],
135 $_ui['username'], $row['name']);
135 136 } }
136 137
137 138 $row['master_name'] = '-'; $row['master_name'] = '-';
 
... ... function rg_repo_admin($db, &$rg, $paras)
2047 2048 break; break;
2048 2049
2049 2050 case 'lock': case 'lock':
2050 $rg['form_url'] = $rg['ri']['url_repo'] . "/admin/lock";
2051 $rg['form_url'] = $rg['ri']['url_repo'] . '/admin/lock';
2051 2052 $ret .= rg_repo_lock_high_level($db, $rg); $ret .= rg_repo_lock_high_level($db, $rg);
2052 2053 break; break;
2053 2054
2054 2055 default: default:
2055 $rg['form_url'] = $rg['ri']['url_repo'] . "/admin";
2056 $rg['form_url'] = $rg['ri']['url_repo'] . '/admin';
2056 2057 $ret .= rg_repo_edit_high_level($db, $rg); $ret .= rg_repo_edit_high_level($db, $rg);
2057 2058 break; break;
2058 2059 } }
File inc/user.inc.php changed (mode: 100644) (index d163e79..561943a)
... ... function rg_user_edit($db, $d)
589 589 'category' => 2000, 'category' => 2000,
590 590 'prio' => 50, 'prio' => 50,
591 591 'ui' => $d, 'ui' => $d,
592 'url' => rg_base_url()
592 'base_url' => rg_base_url()
593 593 ); );
594 594 $r = rg_event_add($db, $event); $r = rg_event_add($db, $event);
595 595 if ($r === FALSE) { if ($r === FALSE) {
 
... ... function rg_user_set_session_cookie($db, $uid, $sess_time, $lock_ip)
890 890 rg_log_enter("user_set_session_cookie: uid=$uid"); rg_log_enter("user_set_session_cookie: uid=$uid");
891 891
892 892 $secure = FALSE; $secure = FALSE;
893 if (isset($_SERVER['HTTPS']))
893 if (isset($_SERVER['HTTPS'])) {
894 894 $secure = TRUE; $secure = TRUE;
895 $cookie_name = 'sids';
896 } else {
897 $cookie_name = 'sidu';
898 }
895 899
896 900 $sid = rg_id(40); $sid = rg_id(40);
897 901 if ($uid > 0) if ($uid > 0)
898 902 rg_sess_add($db, $uid, $sid, $sess_time, $lock_ip); rg_sess_add($db, $uid, $sid, $sess_time, $lock_ip);
899 903 else else
900 904 $sid = "X" . $sid; $sid = "X" . $sid;
901 if (isset($_SERVER['SERVER_NAME']))
902 setcookie('sid', $sid, 0, '/', $_SERVER['SERVER_NAME'],
905 if (isset($_SERVER['SERVER_NAME'])) {
906 rg_log('DEBUG: setting cookie ' . $cookie_name . ' to ' . $sid);
907 setcookie($cookie_name, $sid, 0, '/', $_SERVER['SERVER_NAME'],
903 908 $secure, TRUE /*httponly*/); $secure, TRUE /*httponly*/);
909 }
904 910
905 911 rg_log_exit(); rg_log_exit();
906 912 return $sid; return $sid;
 
... ... function rg_user_auto_login($db, $uid, $lock_ip, &$ui)
925 931 break; break;
926 932 } }
927 933
928 rg_user_set_session_cookie($db, $uid, $ui['session_time'], $lock_ip);
934 rg_user_set_session_cookie($db, $uid, $ui['session_time'],
935 $lock_ip);
929 936
930 937 $ret = TRUE; $ret = TRUE;
931 938 break; break;
File inc/user/repo/bug/main.php changed (mode: 100644) (index c9ce253..1eb294b)
... ... default: // show - go directly to a bug
99 99 $rg['bug'] = array(); $rg['bug'] = array();
100 100 $rg['bug']['bug_id'] = $bug_id; $rg['bug']['bug_id'] = $bug_id;
101 101 if ($bug_id > 0) { if ($bug_id > 0) {
102 $rg['bug']['url'] = $rg['ri']['url_repo'] . "/bug/"
102 $rg['bug']['url'] = $rg['ri']['url_repo'] . '/bug/'
103 103 . $rg['bug']['bug_id']; . $rg['bug']['bug_id'];
104 104 include($INC . "/user/repo/bug/show/show.php"); include($INC . "/user/repo/bug/show/show.php");
105 105 $_bug_body .= $_bug_show; $_bug_body .= $_bug_show;
File inc/util.inc.php changed (mode: 100644) (index a2f6c5f..e48ef9a)
... ... function rg_re_bugpage($ui, $repo_name, $bug_id)
234 234 return rg_re_repopage($ui, $repo_name) . "/bug/" . $bug_id; return rg_re_repopage($ui, $repo_name) . "/bug/" . $bug_id;
235 235 } }
236 236
237 /*
238 * Returns the correct URL to the current virtual host
239 */
237 240 function rg_base_url() function rg_base_url()
238 241 { {
239 global $rg_web_url;
242 global $rg_base_url;
240 243
241 if (!empty($rg_web_url))
242 return $rg_web_url;
244 return $rg_base_url;
245 }
243 246
244 if (!isset($_SERVER['SERVER_NAME']))
245 return 'http://' . php_uname('n');
247 /*
248 * Builds a correct URL to refer to the current virtualhost
249 */
250 function rg_base_url_build($hostname, $http_allow, $https_allow)
251 {
252 global $rg_base_url;
246 253
247 $port = '';
248 if (isset($_SERVER['HTTPS'])) {
249 $proto = 'https';
250 if ($_SERVER['SERVER_PORT'] != 443)
251 $port = ':' . $_SERVER['SERVER_PORT'];
252 } else {
253 $proto = 'http';
254 if ($_SERVER['SERVER_PORT'] != 80)
255 $port = ':' . $_SERVER['SERVER_PORT'];
254 // We are forced to use something if we cannot get them from cache/db
255 if ($hostname === FALSE)
256 $hostname = php_uname('n');
257 if ($http_allow === FALSE)
258 $http_allow = 80;
259 if ($https_allow === FALSE)
260 $https_allow = 443;
261
262 $add = '';
263 if (strcmp($https_allow, '443') != 0)
264 $add = ':' . $https_allow;
265
266 if (strcmp($https_allow, '0') != 0) {
267 $rg_base_url = 'https://' . $hostname . $add;
268 return;
256 269 } }
257 270
258 return $proto . '://' . $_SERVER['SERVER_NAME'] . $port;
271 $add = '';
272 if (strcmp($http_allow, '80') != 0)
273 $add = ':' . $http_allow;
274
275 $rg_base_url = 'http://' . $hostname . $add;
259 276 } }
260 277
261 278 function rg_re_repo_ssh($organization, $user, $repo) function rg_re_repo_ssh($organization, $user, $repo)
 
... ... function rg_re_repo_http($organization, $user, $repo)
300 317 if ($organization == 0) if ($organization == 0)
301 318 $prefix = '/user'; $prefix = '/user';
302 319
303 return rg_base_url() . $prefix . "/"
320 return $prefix . "/"
304 321 . rawurlencode($user) . "/" . rawurlencode($repo); . rawurlencode($user) . "/" . rawurlencode($repo);
305 322 } }
306 323
File root/index.php changed (mode: 100644) (index e0488cf..3bea946)
... ... $rg['login_ui'] = rg_user_empty();
54 54 $rg['target_ui'] = array("ok" => 1, "exists" => 0, "uid" => 0); $rg['target_ui'] = array("ok" => 1, "exists" => 0, "uid" => 0);
55 55 $rg['ri'] = array("repo_id" => 0, "uid" => 0); $rg['ri'] = array("repo_id" => 0, "uid" => 0);
56 56 $rg['bug'] = array("bug_id" => 0); $rg['bug'] = array("bug_id" => 0);
57 $rg['debug'] = isset($rg_allow_debug) ? rg_var_uint('rg_debug') : 0;
58 $rg['base_url'] = rg_base_url();
57 $rg['debug'] = isset($rg_allow_debug) ?
58 rg_var_uint('rg_debug') | intval(rg_var_cookie_re('rg_debug', '/[^0-9]/')) : 0;
59 if ($rg['debug'] == 1)
60 setcookie('rg_debug', '1', 0, '/', $_SERVER['SERVER_NAME'],
61 FALSE /*secure*/, FALSE /*httponly*/);
62 $rg['https'] = strcmp(rg_var_str('HTTPS'), 'on') == 0 ? 1 : 0;
59 63
60 64 $sparas = rg_var_str('SCRIPT_NAME'); $sparas = rg_var_str('SCRIPT_NAME');
61 65 rg_log("DEBUG: sparas=$sparas"); rg_log("DEBUG: sparas=$sparas");
 
... ... if (strcmp($_t, "op") == 0) {
71 75 } }
72 76
73 77 $rg['doit'] = rg_var_uint("doit"); $rg['doit'] = rg_var_uint("doit");
74 $rg['sid'] = rg_var_cookie_re("sid", "/[^A-Za-z0-9]/");
78 $rg['sid_cookie_name'] = $rg['https'] == 1 ? 'sids' : 'sidu';
79 $rg['sid'] = rg_var_cookie_re($rg['sid_cookie_name'], '/[^A-Za-z0-9]/');
75 80 $rg['token'] = rg_var_re("token", "A-Za-z0-9"); $rg['token'] = rg_var_re("token", "A-Za-z0-9");
76 81 $user = ""; $repo = ""; $organization = 0; // TODO: those are really used? $user = ""; $repo = ""; $organization = 0; // TODO: those are really used?
77 82
 
... ... rg_log_ml('_SERVER: ' . print_r($_SERVER, TRUE));
97 102 $rg['ct'] = isset($_SERVER['CONTENT_TYPE']) ? $_SERVER['CONTENT_TYPE'] : ''; $rg['ct'] = isset($_SERVER['CONTENT_TYPE']) ? $_SERVER['CONTENT_TYPE'] : '';
98 103
99 104
105 // Force state loading, for sure we will need it
106 rg_cache_get('state');
107
100 108 $r = rg_struct_ok($db); $r = rg_struct_ok($db);
101 109 if ($r === FALSE) { if ($r === FALSE) {
102 110 echo "Internal error; please try again later."; echo "Internal error; please try again later.";
103 111 exit(0); exit(0);
104 112 } }
105 113
114 // Sets http(s)_allow and hostname
115 $http_allow = rg_state_get($db, 'http_allow');
116 $https_allow = rg_state_get($db, 'https_allow');
117 $hostname = rg_state_get($db, 'hostname');
118 if (isset($_SERVER['SERVER_NAME'])) {
119 $sn = $_SERVER['SERVER_NAME'];
120 $port = $_SERVER['SERVER_PORT'];
121
122 if ($hostname === FALSE) {
123 $hostname = $sn;
124 } else if (empty($hostname)) {
125 $hostname = $sn;
126 rg_state_set($db, 'hostname', $hostname);
127 }
128
129 if ($rg['https'] == 1) {
130 if ($https_allow === FALSE) {
131 $https_allow = $port;
132 } else if (strcmp($https_allow, '') == 0) {
133 $https_allow = $port;
134 rg_state_set($db, 'https_allow', $https_allow);
135 }
136
137 // We have https, no need for http!
138 if (($http_allow === FALSE) || (strcmp($http_allow, '') == 0))
139 $http_allow = '0';
140 } else {
141 if ($http_allow === FALSE) {
142 $http_allow = $port;
143 } else if (strcmp($http_allow, '') == 0) {
144 $http_allow = $port;
145 rg_state_set($db, 'http_allow', $http_allow);
146 }
147 }
148 }
149 rg_log('DEBUG: hostname=' . $hostname . ' http_allow=' . $http_allow
150 . ' https_allow=' . $https_allow);
151 rg_base_url_build($hostname, $http_allow, $https_allow);
152 rg_log('DEBUG: base_url=' . rg_base_url());
153 $rg['hostname'] = $hostname;
154 $rg['http_allow'] = $http_allow;
155 $rg['https_allow'] = $https_allow;
156 $rg['base_url'] = rg_base_url();
157
158
106 159 // Is it a http push/fetch? // Is it a http push/fetch?
107 160 $r = rg_user_http_git($db, $rg, $paras); $r = rg_user_http_git($db, $rg, $paras);
108 161 if ($r === TRUE) { if ($r === TRUE) {
 
... ... if (strcmp($_op, 'api') == 0) {
118 171 header('Access-Control-Allow-Headers: Authorization'); header('Access-Control-Allow-Headers: Authorization');
119 172 header('Content-Type: application/json;charset=UTF-8'); header('Content-Type: application/json;charset=UTF-8');
120 173
121 $_auth = isset($_SERVER['HTTP_AUTHORIZATION']) ? $_SERVER['HTTP_AUTHORIZATION'] : '';
174 $_auth = isset($_SERVER['HTTP_AUTHORIZATION']) ?
175 $_SERVER['HTTP_AUTHORIZATION'] : '';
122 176 $_t = explode(' ', $_auth, 2); $_t = explode(' ', $_auth, 2);
123 177 $_user = trim($_t[0]); $_user = trim($_t[0]);
124 178 if (isset($_t[1])) if (isset($_t[1]))
 
... ... if ($rg['login_ui']['uid'] > 0) {
210 264 } }
211 265
212 266
267 // Redirect if http is not allowed and https is and the user is not logged in
268 if (($rg['https'] == 0)
269 && ($rg['login_ui']['uid'] == 0)
270 && (strcmp($http_allow, '0') == 0)
271 && (strcmp($https_allow, '0') != 0))
272 rg_redirect(rg_base_url() . $sparas);
273
274
213 275 $rg['HTML:rg_body'] = $body; $rg['HTML:rg_body'] = $body;
214 276 $_c = rg_template("index.html", $rg, TRUE /* xss */); $_c = rg_template("index.html", $rg, TRUE /* xss */);
215 277
File root/themes/default/admin/settings/menu.html changed (mode: 100644) (index 6ea52e1..70623b1)
1 1 <div class="menu menu3"> <div class="menu menu3">
2 2 <ul> <ul>
3 <li@@if(@@admin_settings_menu::web@@ == 1){{ class="selected"}}{{}}><a href="/op/admin/settings/web">Web</a></li>
3 4 <li@@if(@@admin_settings_menu::ssh@@ == 1){{ class="selected"}}{{}}><a href="/op/admin/settings/ssh">SSH</a></li> <li@@if(@@admin_settings_menu::ssh@@ == 1){{ class="selected"}}{{}}><a href="/op/admin/settings/ssh">SSH</a></li>
4 5 <li@@if(@@admin_settings_menu::git@@ == 1){{ class="selected"}}{{}}><a href="/op/admin/settings/git">Git</a></li> <li@@if(@@admin_settings_menu::git@@ == 1){{ class="selected"}}{{}}><a href="/op/admin/settings/git">Git</a></li>
5 6 </ul> </ul>
File root/themes/default/admin/settings/web/hints.html added (mode: 100644) (index 0000000..f84c17f)
1 <br />
2 - RocketGit will respect the host named defined in the web server to contruct
3 URLs; please make sure it is correct. Here you can overwrite it.<br />
4 - It is recommended to disable HTTP access and allow only HTTPS.<br />
5 - Do not activate HTTP and/or HTTPS if are not enabled in the web server.
File root/themes/default/admin/settings/web/main.html added (mode: 100644) (index 0000000..fc6bbf7)
1 <div class="formarea">
2
3 <div class="formarea_title">Web settings</div>
4
5 @@errmsg@@
6
7 <form method="post" action="@@url@@">
8 <input type="hidden" name="doit" value="1" />
9 <input type="hidden" name="token" value="@@rg_form_token@@" />
10
11 <p>
12 <label for="hostname">Host name</label><br />
13 <input type="text" name="hostname" id="hostname" value="@@hostname@@" />
14 </p>
15
16 <p>
17 <label for="http_allow">HTTP access (put 0 to disallow, else, the port)</label><br />
18 <input type="text" name="http_allow" id="http_allow" value="@@http_allow@@" />
19 </p>
20
21 <p>
22 <label for="https_allow">HTTPS access (put 0 to disallow, else, the port)</label><br />
23 <input type="text" name="https_allow" id="https_allow" value="@@https_allow@@" />
24 </p>
25
26 <input type="submit" value="Update" />
27 </form>
28 </div>
29
30 @@hints@@
File root/themes/default/doc/api.html changed (mode: 100644) (index 4c58179..f2bd038)
20 20 <b>Parameters</b>: user, uid<br /> <b>Parameters</b>: user, uid<br />
21 21 Example: Example:
22 22 <div class="term"> <div class="term">
23 $ curl --header 'Authorization: bla this_is_bla_api_key' \
23 $ curl --header 'Authorization: bla this_is_your_api_key' \
24 24 --data '{"cmd": "user_info", "user": "bla"}' \ --data '{"cmd": "user_info", "user": "bla"}' \
25 @@base_url@@/op/api
25 @@base_url@@/op/api
26 26 $ ssh rocketgit@rocketgit.com api user_info user=bla $ ssh rocketgit@rocketgit.com api user_info user=bla
27 27 { {
28 28 "ok": 1, "ok": 1,
 
... ... $ ssh rocketgit@rocketgit.com api user_info user=bla
58 58 <b>Parameters</b>: user<br /> <b>Parameters</b>: user<br />
59 59 Example: Example:
60 60 <div class="term"> <div class="term">
61 $ curl --header 'Authorization: bla this_is_bla_api_key' \
61 $ curl --header 'Authorization: put_here_your_username this_is_your_api_key' \
62 62 --data '{"cmd": "user_rights_list", "user": "bla"}' \ --data '{"cmd": "user_rights_list", "user": "bla"}' \
63 @@base_url@@/op/api
63 @@base_url@@/op/api
64 64 $ ssh rocketgit@rocketgit.com api user_rights_list user=bla $ ssh rocketgit@rocketgit.com api user_rights_list user=bla
65 65 [ [
66 66 { {
 
... ... $ ssh rocketgit@rocketgit.com api user_rights_list user=bla
94 94 <b>Parameters</b>: user<br /> <b>Parameters</b>: user<br />
95 95 Example: Example:
96 96 <div class="term"> <div class="term">
97 $ curl --header 'Authorization: bla this_is_bla_api_key' \
97 $ curl --header 'Authorization: put_here_your_username this_is_your_api_key' \
98 98 --data '{"cmd": "user_ssh_keys_list", "user": "bla"}' \ --data '{"cmd": "user_ssh_keys_list", "user": "bla"}' \
99 @@base_url@@/op/api
99 @@base_url@@/op/api
100 100 $ ssh rocketgit@rocketgit.com api user_ssh_keys_list user=bla $ ssh rocketgit@rocketgit.com api user_ssh_keys_list user=bla
101 101 [ [
102 102 { {
 
... ... $ ssh rocketgit@rocketgit.com api user_wh_list user=bla
173 173 <b>Parameters</b>: name/repo_id, bug_id<br /> <b>Parameters</b>: name/repo_id, bug_id<br />
174 174 Example: Example:
175 175 <div class="term"> <div class="term">
176 $ curl --header 'Authorization: bla this_is_bla_api_key' \
176 $ curl --header 'Authorization: put_here_your_username this_is_your_api_key' \
177 177 --data '{"cmd": "repo_bug_info", "name": "repo1", "bug_id": 2}' \ --data '{"cmd": "repo_bug_info", "name": "repo1", "bug_id": 2}' \
178 @@base_url@@/op/api
178 @@base_url@@/op/api
179 179 $ ssh rocketgit@rocketgit.com api repo_bug_info name=repo1 bug_id=2 $ ssh rocketgit@rocketgit.com api repo_bug_info name=repo1 bug_id=2
180 180 { {
181 181 "bug_id": "2", "bug_id": "2",
 
... ... $ ssh rocketgit@rocketgit.com api repo_bug_info name=repo1 bug_id=2
209 209 <b>Parameters</b>: name, repo_id<br /> <b>Parameters</b>: name, repo_id<br />
210 210 Example: Example:
211 211 <div class="term"> <div class="term">
212 $ curl --header 'Authorization: bla this_is_bla_api_key' \
212 $ curl --header 'Authorization: put_here_your_username this_is_your_api_key' \
213 213 --data '{"cmd": "repo_bug_list", "name": "repo1"}' \ --data '{"cmd": "repo_bug_list", "name": "repo1"}' \
214 @@base_url@@/op/api
214 @@base_url@@/op/api
215 215 $ ssh rocketgit@rocketgit.com api repo_bug_list name=repo1 $ ssh rocketgit@rocketgit.com api repo_bug_list name=repo1
216 216 [ [
217 217 "1", "1",
 
... ... $ ssh rocketgit@rocketgit.com api repo_bug_list name=repo1
225 225 <b>Parameters</b>: none<br /> <b>Parameters</b>: none<br />
226 226 Example: Example:
227 227 <div class="term"> <div class="term">
228 $ curl --header 'Authorization: bla this_is_bla_api_key' \
228 $ curl --header 'Authorization: put_here_your_username this_is_your_api_key' \
229 229 --data '{"cmd": "repo_list"}' \ --data '{"cmd": "repo_list"}' \
230 @@base_url@@/op/api
230 @@base_url@@/op/api
231 231 $ ssh rocketgit@rocketgit.com api repo_list $ ssh rocketgit@rocketgit.com api repo_list
232 232 [ [
233 233 "repo1", "repo1",
 
... ... $ ssh rocketgit@rocketgit.com api repo_list
242 242 <b>Parameters</b>: name, repo_id<br /> <b>Parameters</b>: name, repo_id<br />
243 243 Example: Example:
244 244 <div class="term"> <div class="term">
245 $ curl --header 'Authorization: bla this_is_bla_api_key' \
245 $ curl --header 'Authorization: put_here_your_username this_is_your_api_key' \
246 246 --data '{"cmd": "repo_info", "name": "repo1"}' \ --data '{"cmd": "repo_info", "name": "repo1"}' \
247 @@base_url@@/op/api
247 @@base_url@@/op/api
248 248 $ ssh rocketgit@rocketgit.com api repo_info name=repo1 $ ssh rocketgit@rocketgit.com api repo_info name=repo1
249 249 { {
250 250 "repo_id": "769", "repo_id": "769",
 
... ... $ ssh rocketgit@rocketgit.com api repo_info name=repo1
254 254 "disk_quota_mb": null, "disk_quota_mb": null,
255 255 "max_commit_size": "0", "max_commit_size": "0",
256 256 "master": "0", "master": "0",
257 "<b>Description</b>": "here is a <b>Description</b>",
257 "description": "here is a description",
258 258 "git_dir_done": "1", "git_dir_done": "1",
259 259 "deleted": "0", "deleted": "0",
260 260 "disk_used_mb": "0", "disk_used_mb": "0",
261 261 "public": "1", "public": "1",
262 262 "last_bug_id": "1", "last_bug_id": "1",
263 263 "license": "GPLv3", "license": "GPLv3",
264 "template": "",
264 "template": "OS type(s) and version(s)?\n\nApplication version(s) affected?\n\nSteps to reproduce?",
265 265 "last_mr_id": "0", "last_mr_id": "0",
266 266 "ok": 1, "ok": 1,
267 267 "exists": 1, "exists": 1,
268 "clone_url": "ssh:\/\/rocketgit@rg.embedromix.ro:2222\/user\/bla\/repo1",
269 "HTML:<b>Description</b>_nlbr": "here is a <b>Description</b>",
268 "HTML:description_nlbr": "here is a description",
270 269 "HTML:itime_nice": "2015-11-18", "HTML:itime_nice": "2015-11-18",
271 270 "owner": "bla", "owner": "bla",
272 "url_user": "http:\/\/r1i:9000\/user\/bla",
273 "url_repo": "http:\/\/r1i:9000\/user\/bla\/repo1",
274 "clone_url_ssh": "ssh:\/\/rocketgit@rg.embedromix.ro:2222\/user\/bla\/repo1",
275 "clone_url_git": "git:\/\/rg.embedromix.ro\/user\/bla\/repo1",
271 "url_user": "\/user\/bla",
272 "url_repo": "\/user\/bla\/repo1",
273 "clone_url_ssh": "ssh:\/\/rocketgit@rocketgit.com\/user\/bla\/repo1",
274 "clone_url_git": "git:\/\/rocketgit.com\/user\/bla\/repo1",
275 "clone_url_http": "http:\/\/rocketgit.com\/user\/bla\/repo1",
276 276 "master_name": "-", "master_name": "-",
277 277 "disk_used": "0B" "disk_used": "0B"
278 278 } }
 
... ... $ ssh rocketgit@rocketgit.com api repo_info name=repo1
284 284 <b>Parameters</b>: name, repo_id<br /> <b>Parameters</b>: name, repo_id<br />
285 285 Example: Example:
286 286 <div class="term"> <div class="term">
287 $ curl --header 'Authorization: bla this_is_bla_api_key' \
287 $ curl --header 'Authorization: put_here_your_username this_is_your_api_key' \
288 288 --data '{"cmd": "repo_pr_list", "name": "repo1"}' \ --data '{"cmd": "repo_pr_list", "name": "repo1"}' \
289 @@base_url@@/op/api
289 @@base_url@@/op/api
290 290 $ ssh rocketgit@rocketgit.com api repo_pr_list name=repo1 $ ssh rocketgit@rocketgit.com api repo_pr_list name=repo1
291 291 [ [
292 292 { {
File root/themes/default/hints/repo/clone_http.html changed (mode: 100644) (index 009d786..cf71305)
1 1 <br /> <br />
2 Clone this repository using http:<br />
2 Clone this repository using HTTP(S):<br />
3 3 <div class="xcode"> <div class="xcode">
4 4 git clone @@ri::clone_url_http@@<br /> git clone @@ri::clone_url_http@@<br />
5 5 </div> </div>
File root/themes/default/mail/user/welcome.body.txt changed (mode: 100644) (index 7a0fba0..879c13f)
... ... your e-mail address, by clicking the link below:
10 10 In order to be able to receive notifications and to recover a lost password, In order to be able to receive notifications and to recover a lost password,
11 11 please confirm your e-mail address, by clicking the link below: please confirm your e-mail address, by clicking the link below:
12 12 }} }}
13 @@url@@/op/confirm/@@ui::confirm_token@@
13 @@base_url@@/op/confirm/@@ui::confirm_token@@
14 14
15 15 Enjoy your stay! Enjoy your stay!
16 16
File root/themes/default/repo/bug/list_note/line.html changed (mode: 100644) (index 58fab3a..08500e4)
1 1 <a name="note-@@note_id@@"></a> <a name="note-@@note_id@@"></a>
2 2 <div class="note"> <div class="note">
3 @@if(@@note_owner_url@@ = ""){{@@note_gravatar@@}}{{<a target="_blank" href="@@note_owner_url@@">@@note_gravatar@@</a>}}
3 @@if(@@note_owner_url@@ == ""){{@@note_gravatar@@}}{{<a target="_blank" href="@@note_owner_url@@">@@note_gravatar@@</a>}}
4 4
5 5 <div class="note_body"> <div class="note_body">
6 6 <b>@@if(@@note_owner_url@@ == ""){{@@note_owner@@}}{{<a target="_blank" href="@@note_owner_url@@">@@note_owner@@</a>}}</b> - @@note_creation@@ - <a href="@@bug::bug_id@@#note-@@note_id@@">Link</a><br /> <b>@@if(@@note_owner_url@@ == ""){{@@note_owner@@}}{{<a target="_blank" href="@@note_owner_url@@">@@note_owner@@</a>}}</b> - @@note_creation@@ - <a href="@@bug::bug_id@@#note-@@note_id@@">Link</a><br />
File root/themes/default/user/hints/login.html changed (mode: 100644) (index 7e4604b..9dc64be)
1 @@if(@@http_allow@@ != 0){{
2 @@if(@@https_allow@@ != 0){{
3 @@if(@@https@@ == 0){{
4 <br />
5 <div class="hint_warn">
6 You are accessing this site using HTTP protocol, but HTTPS is also available.
7 Please use it: <a href="@@base_url@@/op/login">@@base_url@@/op/login</a>.
8 </div>
9 }}
10 }}
11 }}
12
1 13 <br /> <br />
2 14 If you lose your password, 2fa device or all scratch codes, If you lose your password, 2fa device or all scratch codes,
3 15 just run <b>rg_change_pass</b>, as root, on your rocketgit machine. just run <b>rg_change_pass</b>, as root, on your rocketgit machine.
File root/themes/default/user/settings/apikeys/hints.html changed (mode: 100644) (index 9eccb13..2bcf3ee)
1 1 <br /> <br />
2 API keys are used to access RocketGit's API by HTTPS.<br />
2 API keys are used to access RocketGit's API by HTTP(S).<br />
3 3 Check <a href="/op/doc/api">API documentation</a> for more info.<br /> Check <a href="/op/doc/api">API documentation</a> for more info.<br />
4 4 Example: Example:
5 5 <div class="term"> <div class="term">
File samples/config.php changed (mode: 100644) (index bcf9003..8d999e0)
... ... $rg_git_host = "";
79 79 // Git port - put 0 to disable (standard is 9418) // Git port - put 0 to disable (standard is 9418)
80 80 $rg_git_port = 9418; $rg_git_port = 9418;
81 81
82 // HTTP(S) host name and port (some scripts could not detect this)
83 // Format: http[s]://host_name[:port]
84 // No '/' in the end.
85 $rg_web_url = '';
86
87 82 // How many days to keep the log files? Put 0 to not delete them. // How many days to keep the log files? Put 0 to not delete them.
88 83 $rg_logs_lifetime = 31; $rg_logs_lifetime = 31;
89 84
File samples/rg.conf changed (mode: 100644) (index 0623eb4..dd65dba)
28 28
29 29 <VirtualHost *:80> <VirtualHost *:80>
30 30 ServerName rg.domain.tld ServerName rg.domain.tld
31 ServerAlias rg
31 ServerAlias rg www.rg.domain.tld
32 32 DocumentRoot /usr/share/rocketgit/root/ DocumentRoot /usr/share/rocketgit/root/
33 33 ErrorLog logs/rocketgit-error_log ErrorLog logs/rocketgit-error_log
34 34 CustomLog logs/rocketgit-access_log common CustomLog logs/rocketgit-access_log common
 
37 37 MaxKeepAliveRequests 1000 MaxKeepAliveRequests 1000
38 38 KeepAliveTimeout 10 KeepAliveTimeout 10
39 39 TraceEnable off TraceEnable off
40 ServerSignature Off
41 UseCanonicalName On
40 42
41 43 RewriteEngine On RewriteEngine On
42 44
43 # If you do not want HTTPS, comment the following lines and the HTTPS
44 # virtual host, below.
45 RewriteCond %{HTTPS} off
46 RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [redirect=301,last,qsappend]
47
48 45 # Allow .ico, 'themes' folder and robots.txt # Allow .ico, 'themes' folder and robots.txt
49 46 # Also, avoid scripts that are looking for exploits # Also, avoid scripts that are looking for exploits
50 47 RewriteCond %{REQUEST_URI} ^/(favicon\.ico|themes/.*|robots\.txt|\.well-known/.*)$ RewriteCond %{REQUEST_URI} ^/(favicon\.ico|themes/.*|robots\.txt|\.well-known/.*)$
51 48 RewriteRule .* - [last] RewriteRule .* - [last]
52 49
50 # https://httpd.apache.org/docs/2.4/rewrite/remapping.html
51 RewriteCond "%{HTTP_HOST}" "!^rg\.domain\.tld$" [nocase]
52 RewriteRule "^/?(.*)" "http://rg.domain.tld/$1" [last,redirect=301,noescape]
53 53 # all rest # all rest
54 54 RewriteRule (.*) /index.php [last] RewriteRule (.*) /index.php [last]
55 55
 
72 72 #LogLevel debug #rewrite:trace8 #LogLevel debug #rewrite:trace8
73 73 # Set ServerName correctly, else, this VirtualHost will not match # Set ServerName correctly, else, this VirtualHost will not match
74 74 #ServerName rg.domain.tld #ServerName rg.domain.tld
75 ServerAlias rg
76 75 DocumentRoot /usr/share/rocketgit/root/ DocumentRoot /usr/share/rocketgit/root/
77 76 ErrorLog logs/rocketgit-ssl_error_log ErrorLog logs/rocketgit-ssl_error_log
78 77 CustomLog logs/rocketgit-ssl_request_log \ CustomLog logs/rocketgit-ssl_request_log \
 
83 82 MaxKeepAliveRequests 1000 MaxKeepAliveRequests 1000
84 83 KeepAliveTimeout 10 KeepAliveTimeout 10
85 84 TraceEnable off TraceEnable off
85 ServerSignature Off
86 UseCanonicalName On
86 87
87 88 RewriteEngine On RewriteEngine On
88 89
89 90 # Allow .ico, 'themes' folder and robots.txt # Allow .ico, 'themes' folder and robots.txt
90 RewriteCond %{REQUEST_URI} ^/(favicon\.ico|themes/.*|robots\.txt)$
91 RewriteCond %{REQUEST_URI} ^/(favicon\.ico|themes/.*|robots\.txt|\.well-known/.*)$
91 92 RewriteRule .* - [last] RewriteRule .* - [last]
92 93
94 # Canonical name for https
95 # https://httpd.apache.org/docs/2.4/rewrite/remapping.html
96 RewriteCond "%{HTTP_HOST}" "!^rg\.domain\.tld$" [nocase]
97 RewriteRule "^/?(.*)" "https://rg.domain.tld/$1" [last,redirect=301,noescape]
98
93 99 # all rest # all rest
94 100 RewriteRule (.*) /index.php [last] RewriteRule (.*) /index.php [last]
95 101
 
103 109
104 110 LogLevel warn LogLevel warn
105 111 SSLEngine on SSLEngine on
106 SSLProtocol all -SSLv2 -SSLv3
107 # Specify the cyphers to get an A+ on Qualys (ssllabs.com); recommended
112 SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
113 # Specify the cyphers to get an A+ on Qualys (ssllabs.com)
108 114 # https://www.digicert.com/ssl-support/ssl-enabling-perfect-forward-secrecy.htm # https://www.digicert.com/ssl-support/ssl-enabling-perfect-forward-secrecy.htm
115 # https://wiki.mozilla.org/Security/Server_Side_TLS#Recommended_configurations
116 # https://mozilla.github.io/server-side-tls/ssl-config-generator/
109 117 SSLHonorCipherOrder on SSLHonorCipherOrder on
118 # Below is "Configure without RC4" configuration and is recommended.
110 119 SSLCipherSuite "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS !RC4" SSLCipherSuite "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS !RC4"
120
111 121 # or, respect the system settings: # or, respect the system settings:
112 122 # Pay attention on next line! It fails on RedHat6! # Pay attention on next line! It fails on RedHat6!
113 123 #SSLCipherSuite PROFILE=SYSTEM #SSLCipherSuite PROFILE=SYSTEM
114 124
125 # https://mozilla.github.io/server-side-tls/ssl-config-generator/
126 # TODO
127 #SSLUseStapling on
128 #SSLStaplingResponderTimeout 5
129 #SSLStaplingReturnResponderErrors off
130 # Another line here must be 'SSLCACertificateFile ...'
131 # below line must be outside of VirtualHost section
132 # SSLStaplingCache shmcb:/run/httpd/ocsp(128000)
133
115 134 # https://developer.mozilla.org/en-US/docs/Web/HTTP/Public_Key_Pinning # https://developer.mozilla.org/en-US/docs/Web/HTTP/Public_Key_Pinning
116 135 # To generate pin-sha256 string: openssl s_client -servername <server> -connect <server>:443 | openssl x509 -pubkey -noout | openssl rsa -pubin -outform der | openssl dgst -sha256 -binary | openssl enc -base64 # To generate pin-sha256 string: openssl s_client -servername <server> -connect <server>:443 | openssl x509 -pubkey -noout | openssl rsa -pubin -outform der | openssl dgst -sha256 -binary | openssl enc -base64
117 136 # Header always set Public-Key-Pins "pin-sha256=\"base64+primary==\"; pin-sha256=\"base64+backup==\"; max-age=5184000; includeSubDomains; report-uri=\"https://www.example.org/hpkp-report\"" # Header always set Public-Key-Pins "pin-sha256=\"base64+primary==\"; pin-sha256=\"base64+backup==\"; max-age=5184000; includeSubDomains; report-uri=\"https://www.example.org/hpkp-report\""
File scripts/remote.php changed (mode: 100644) (index 7321acb..f43a90c)
... ... $db = rg_sql_open($rg_sql);
71 71 if ($db === FALSE) if ($db === FALSE)
72 72 fatal("Internal error (db)!"); fatal("Internal error (db)!");
73 73
74 // Force ste state loading, for sure we will need it
75 rg_cache_get('state');
76
74 77 if (rg_struct_ok($db) === FALSE) if (rg_struct_ok($db) === FALSE)
75 78 fatal("We are in a short maintenance window. Try again later."); fatal("We are in a short maintenance window. Try again later.");
76 79
80 $hostname = rg_state_get($db, 'hostname');
81 $http_allow = rg_state_get($db, 'http_allow');
82 $https_allow = rg_state_get($db, 'https_allow');
83 rg_base_url_build($hostname, $http_allow, $https_allow);
84 rg_log('DEBUG: base_url=' . rg_base_url());
85
77 86 if (isset($_SERVER['SSH_CONNECTION'])) { if (isset($_SERVER['SSH_CONNECTION'])) {
78 87 rg_log("SSH connection: " . $_SERVER['SSH_CONNECTION']); rg_log("SSH connection: " . $_SERVER['SSH_CONNECTION']);
79 88
File tests/admin_set_web.php copied from file tests/admin_set_git.php (similarity 70%) (mode: 100644) (index e79f4a5..6a61fe3)
... ... require_once($INC . '/util.inc.php');
11 11 require_once('helpers.inc.php'); require_once('helpers.inc.php');
12 12 require_once('http.inc.php'); require_once('http.inc.php');
13 13
14 rg_log_set_file('admin_set_git.log');
14 rg_log_set_file('admin_set_web.log');
15 15
16 16 $rg_sql = 'host=localhost user=rocketgit dbname=rocketgit connect_timeout=10'; $rg_sql = 'host=localhost user=rocketgit dbname=rocketgit connect_timeout=10';
17 17 $rg_no_db = TRUE; $rg_no_db = TRUE;
18 18 require_once('common.php'); require_once('common.php');
19 19
20 $_testns = 'admin_set_git';
20 $_testns = 'admin_set_web';
21 21 $rg_cache_enable = TRUE; $rg_cache_enable = TRUE;
22 22 $rg_cache_debug = TRUE; $rg_cache_debug = TRUE;
23 23
24 24 $rg_ui = array('is_admin' => 1); $rg_ui = array('is_admin' => 1);
25 25 rg_test_create_user($db, $rg_ui); rg_test_create_user($db, $rg_ui);
26 test_login($test_url, $rg_ui, $good_sid);
26 test_login($test_url, $rg_ui);
27 27
28 28
29 29 rg_log(''); rg_log('');
30 rg_log_enter('Loading Admin -> Settings -> Git...');
30 rg_log_enter('Loading Admin -> Settings -> Web...');
31 31 $data = array(); $data = array();
32 $headers = array("Cookie: sid=" . $good_sid);
33 $r = do_req($test_url . '/op/admin/settings/git', $data, $headers);
32 $headers = array();
33 $r = do_req($test_url . '/op/admin/settings/web', $data, $headers);
34 34 if ($r === FALSE) { if ($r === FALSE) {
35 35 rg_log("Cannot load page!"); rg_log("Cannot load page!");
36 36 exit(1); exit(1);
37 37 } }
38 if (!isset($r['tokens']['admin_settings_git'])) {
38 if (!isset($r['tokens']['admin_settings_web'])) {
39 39 rg_log_ml('r:' . print_r($r, TRUE)); rg_log_ml('r:' . print_r($r, TRUE));
40 rg_log("No token?!");
40 rg_log("No 'admin_settings_web' token?!");
41 41 exit(1); exit(1);
42 42 } }
43 $token = $r['tokens']['admin_settings_git'];
43 $token = $r['tokens']['admin_settings_web'];
44 44
45 45 rg_log('Posting the form...'); rg_log('Posting the form...');
46 46 $data = array( $data = array(
 
... ... $data = array(
48 48 'token' => $token 'token' => $token
49 49 ); );
50 50 $list = array( $list = array(
51 'git_patch_limit' => rand(5000, 7000)
51 'hostname' => '',
52 'http_allow' => '',
53 'https_allow' => ''
52 54 ); );
53 55 foreach ($list as $var => $def) { foreach ($list as $var => $def) {
54 56 $v = rg_state_get($db, $var); $v = rg_state_get($db, $var);
 
... ... foreach ($list as $var => $def) {
61 63 else else
62 64 $data[$var] = $v; $data[$var] = $v;
63 65 } }
64 $r = do_req($test_url . '/op/admin/settings/git', $data, $headers);
66 $r = do_req($test_url . '/op/admin/settings/web', $data, $headers);
65 67 if (!strstr($r['body'], 'Configuration has been successfully saved.')) { if (!strstr($r['body'], 'Configuration has been successfully saved.')) {
66 68 rg_log_ml('r: ' . print_r($r, TRUE)); rg_log_ml('r: ' . print_r($r, TRUE));
67 69 rg_log("Cannot post form!"); rg_log("Cannot post form!");
File tests/config.php changed (mode: 100644) (index 130a75b..99abeb6)
... ... $rg_theme = "util";
27 27 $rg_lang = "en"; $rg_lang = "en";
28 28 $rg_cache_enable = FALSE; $rg_cache_enable = FALSE;
29 29 $rg_event_socket = ""; $rg_event_socket = "";
30 $rg_ssh_host = 'rg';
30 $rg_ssh_host = 'rg.embedromix.ro';
31 31 $rg_ssh_port = 2222; $rg_ssh_port = 2222;
32 32 $rg_git_host = 'localhost'; $rg_git_host = 'localhost';
33 33 $rg_git_port = 9418; $rg_git_port = 9418;
34 34
35 35 // For http testing // For http testing
36 $test_url = "http://rg:9000";
37 $rg_web_url = 'http://rg:9000';
36 $test_url = "http://rg.embedromix.ro:9000";
38 37 $rg_debug = 1; $rg_debug = 1;
39 38
39 $rg_base_url = $test_url;
40
40 41 ?> ?>
File tests/http.inc.php changed (mode: 100644) (index c33e330..c43bea9)
... ... function do_req($url, &$data, &$headers)
106 106 } }
107 107 } }
108 108
109 // find sid
110 $x = preg_match('/Set-Cookie: sid=([a-zA-Z0-9]*)/', $ret['header'], $matches);
111 if (($x === FALSE) || (!isset($matches[1]))) {
112 $ret['sid'] = "";
113 //rg_log("CHECK: no sid found");
114 } else {
115 $ret['sid'] = $matches[1];
109 // Find cookies
110 $ret['cookies'] = array();
111 $x = preg_match_all('/Set-Cookie: (.*?)=(.*?)[;]/',
112 $ret['header'], $matches, PREG_SET_ORDER);
113 if ($x !== FALSE) {
114 foreach ($matches as $junk => $info) {
115 $k = $info[1];
116 $v = $info[2];
117 $ret['cookies'][$k] = $v;
118 }
116 119 } }
120 //rg_log_ml('ret[cookies]: ' . print_r($ret['cookies'], TRUE));
121
122 $ret['sid'] = '';
123 if (isset($ret['cookies']['sidu']))
124 $ret['sid'] = $ret['cookies']['sidu'];
125 if (isset($ret['cookies']['sids']))
126 $ret['sid'] = $ret['cookies']['sids'];
117 127
118 128 $ret['tokens'] = array(); $ret['tokens'] = array();
119 129 $x = preg_match_all('/ name="token" value="([a-zA-Z0-9_:]*)"/', $x = preg_match_all('/ name="token" value="([a-zA-Z0-9_:]*)"/',
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/rocketgit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/rocketgit

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master