File TODO changed (mode: 100644) (index a3a6878..dc368df) |
1 |
1 |
== BEFORE FIRST RELEASE! == |
== BEFORE FIRST RELEASE! == |
2 |
|
[ ] $rg_pass_key should be done in init.php |
|
3 |
|
[ ] Test and fix update.php script. |
|
4 |
|
[ ] Fix the "edit repo" page! |
|
5 |
|
[ ] Update db structure at any function call (after an upgrade). (Deny any operation till schema update is done.) |
|
6 |
|
[ ] Check if repo_path is valid from security pov. |
|
7 |
|
[ ] Make available the push requests. |
|
|
2 |
|
[ ] Make available the merge requests. |
8 |
3 |
[ ] Add possibility to reject merge requests, to make them public, to delete etc. |
[ ] Add possibility to reject merge requests, to make them public, to delete etc. |
9 |
|
[ ] Should init.php must create db schema or we delay for the first access? |
|
|
4 |
|
[ ] rg_sql_querty must always return an error code! |
|
5 |
|
[ ] |
10 |
6 |
|
|
11 |
7 |
== Normal priority == |
== Normal priority == |
12 |
|
[ ] |
|
|
8 |
|
[ ] If a user pushes an unknown repo, we may automatically create a repo! |
|
9 |
|
[ ] Fix the "edit repo" page! |
13 |
10 |
[ ] rg-repos should be split in rg_repos and rg_var_lib. |
[ ] rg-repos should be split in rg_repos and rg_var_lib. |
14 |
11 |
[ ] 'cop' variable is not good - I do not remember what it means! |
[ ] 'cop' variable is not good - I do not remember what it means! |
15 |
12 |
[ ] $blocks = explode("@@left@@-=ROCKETGIT=-@@left@@", $a) - seems that \0 is replaced! |
[ ] $blocks = explode("@@left@@-=ROCKETGIT=-@@left@@", $a) - seems that \0 is replaced! |
File admin/init.php changed (mode: 100644) (index 8af30b3..c8c889b) |
1 |
1 |
<?php |
<?php |
2 |
|
// This is executed at the first instalation |
|
|
2 |
|
// This is executed at the first instalation. |
|
3 |
|
// Or, if you want to create another admin user. |
3 |
4 |
error_reporting(E_ALL); |
error_reporting(E_ALL); |
4 |
5 |
ini_set("track_errors", "On"); |
ini_set("track_errors", "On"); |
5 |
6 |
|
|
|
... |
... |
if ($db === FALSE) { |
20 |
21 |
exit(1); |
exit(1); |
21 |
22 |
} |
} |
22 |
23 |
|
|
23 |
|
$r = rg_sql_struct_update_if_needed($db, RG_NO_DROP_TABLES); |
|
|
24 |
|
$r = rg_sql_struct_update_if_needed($db, 0); |
24 |
25 |
if ($r !== TRUE) { |
if ($r !== TRUE) { |
25 |
26 |
echo "Cannot init structure. Check the logs!\n"; |
echo "Cannot init structure. Check the logs!\n"; |
26 |
27 |
exit(1); |
exit(1); |
|
... |
... |
while (1) { |
73 |
74 |
|
|
74 |
75 |
|
|
75 |
76 |
// Store the timestamp of the first install |
// Store the timestamp of the first install |
76 |
|
rg_state_set($db, "first_install", time()); |
|
|
77 |
|
$first_install = rg_state_get($db, "first_install"); |
|
78 |
|
if ($first_install == 0) |
|
79 |
|
rg_state_set($db, "first_install", time()); |
77 |
80 |
|
|
78 |
81 |
echo "Done!\n"; |
echo "Done!\n"; |
79 |
82 |
?> |
?> |
File hooks/post-receive changed (mode: 100755) (index 0355ab7..b71148d) |
... |
... |
while (($set = fgets($f))) { |
59 |
59 |
fclose($f); |
fclose($f); |
60 |
60 |
|
|
61 |
61 |
|
|
62 |
|
$diff = sprintf("%u", (microtime(TRUE) - $_start) * 1000); |
|
63 |
|
rg_log("Took " . $diff . "ms."); |
|
64 |
|
|
|
65 |
|
@file_put_contents($repo_path . "/rg/hook-post-receive", |
|
66 |
|
"repo: " . $repo . " ($repo_path)" |
|
67 |
|
. "\nat: " . sprintf("%u", $_start) |
|
68 |
|
. "\nuid: " . $uid |
|
69 |
|
. "\npara: $refname $old_rev $new_rev" |
|
70 |
|
. "\nTook: " . $diff . "ms" |
|
71 |
|
. "\n_SERVER: " . print_r($_SERVER, TRUE)); |
|
72 |
|
|
|
73 |
62 |
// Mark repository dirty for disk statistics and other stuff |
// Mark repository dirty for disk statistics and other stuff |
74 |
63 |
@file_put_contents($rg_path . "/dirty", ""); |
@file_put_contents($rg_path . "/dirty", ""); |
75 |
64 |
|
|
|
65 |
|
$a = array( |
|
66 |
|
"op" => "push", |
|
67 |
|
"itime" => getenv("ROCKETGIT_ITIME"), |
|
68 |
|
"uid" => $uid, |
|
69 |
|
"repo_id" => getenv("ROCKETGIT_REPO_ID") |
|
70 |
|
"old_rev" => $old_rev, |
|
71 |
|
"new_rev" => $new_rev, |
|
72 |
|
"refname" => $refname, |
|
73 |
|
"elap_ms" => $_start - getenv("ROCKETGIT_ITIME"), |
|
74 |
|
"ip" => getenv("ROCKETGIT_IP") |
|
75 |
|
); |
|
76 |
|
rg_repo_stats_push2file($a); |
|
77 |
|
|
76 |
78 |
rg_prof_end("post-receive"); |
rg_prof_end("post-receive"); |
77 |
79 |
rg_prof_log("rg_log"); |
rg_prof_log("rg_log"); |
78 |
80 |
?> |
?> |
File root/index.php changed (mode: 100644) (index 4e209dc..621d2de) |
... |
... |
$INC = dirname(__FILE__) . "/../inc"; |
6 |
6 |
require_once("/etc/rocketgit/config.php"); |
require_once("/etc/rocketgit/config.php"); |
7 |
7 |
require_once($INC . "/log.inc.php"); |
require_once($INC . "/log.inc.php"); |
8 |
8 |
include_once($INC . "/sql.inc.php"); |
include_once($INC . "/sql.inc.php"); |
|
9 |
|
include_once($INC . "/struct.inc.php"); |
9 |
10 |
include_once($INC . "/user.inc.php"); |
include_once($INC . "/user.inc.php"); |
10 |
11 |
include_once($INC . "/repo.inc.php"); |
include_once($INC . "/repo.inc.php"); |
11 |
12 |
include_once($INC . "/keys.inc.php"); |
include_once($INC . "/keys.inc.php"); |
|
... |
... |
if ($db === FALSE) { |
88 |
89 |
die("Cannot open database!"); |
die("Cannot open database!"); |
89 |
90 |
} |
} |
90 |
91 |
|
|
91 |
|
$r = rg_sql_struct_update_if_needed($db, RG_NO_DROP_TABLES); |
|
|
92 |
|
$r = rg_sql_struct_update_if_needed($db, 0); |
92 |
93 |
if ($r !== TRUE) { |
if ($r !== TRUE) { |
93 |
94 |
echo "Schema is not up-to-date! Try again later"; |
echo "Schema is not up-to-date! Try again later"; |
94 |
95 |
exit(1); |
exit(1); |
File samples/config.php changed (mode: 100644) (index 2cb3510..1b8f9a7) |
... |
... |
$rg_user_max_len = 32; |
34 |
34 |
// SSH parameters for authorized_keys |
// SSH parameters for authorized_keys |
35 |
35 |
$rg_ssh_paras = "no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty"; |
$rg_ssh_paras = "no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty"; |
36 |
36 |
|
|
37 |
|
// Random key that will be used for encription of the password for better security |
|
38 |
|
$rg_pass_key = "reigjmn9483jfisendfhwefhefhesfuhfskhjukhtw4khfwkur"; |
|
39 |
|
|
|
40 |
37 |
// From what address we will send mails (forgot pass etc.)? |
// From what address we will send mails (forgot pass etc.)? |
41 |
38 |
$rg_admin_name = "RocketGit Admin"; |
$rg_admin_name = "RocketGit Admin"; |
42 |
39 |
$rg_admin_email = "admin@site.tld"; |
$rg_admin_email = "admin@site.tld"; |
File scripts/cron.php changed (mode: 100644) (index db495c2..fbcbf65) |
... |
... |
require_once("/etc/rocketgit/config.php"); |
10 |
10 |
$INC = dirname(__FILE__) . "/../inc"; |
$INC = dirname(__FILE__) . "/../inc"; |
11 |
11 |
require_once($INC . "/log.inc.php"); |
require_once($INC . "/log.inc.php"); |
12 |
12 |
require_once($INC . "/sql.inc.php"); |
require_once($INC . "/sql.inc.php"); |
|
13 |
|
require_once($INC . "/struct.inc.php"); |
13 |
14 |
require_once($INC . "/repo.inc.php"); |
require_once($INC . "/repo.inc.php"); |
14 |
15 |
require_once($INC . "/keys.inc.php"); |
require_once($INC . "/keys.inc.php"); |
15 |
16 |
|
|
|
... |
... |
if ($db === FALSE) { |
27 |
28 |
exit(1); |
exit(1); |
28 |
29 |
} |
} |
29 |
30 |
|
|
30 |
|
$r = rg_sql_struct_update_if_needed($db, RG_NO_DROP_TABLES); |
|
|
31 |
|
$r = rg_sql_struct_update_if_needed($db, 0); |
31 |
32 |
if ($r !== TRUE) |
if ($r !== TRUE) |
32 |
33 |
exit(1); |
exit(1); |
33 |
34 |
|
|
File scripts/q.php changed (mode: 100644) (index c1bac8b..bd48577) |
... |
... |
require_once("/etc/rocketgit/config.php"); |
12 |
12 |
$INC = dirname(__FILE__) . "/../inc"; |
$INC = dirname(__FILE__) . "/../inc"; |
13 |
13 |
require_once($INC . "/log.inc.php"); |
require_once($INC . "/log.inc.php"); |
14 |
14 |
require_once($INC . "/sql.inc.php"); |
require_once($INC . "/sql.inc.php"); |
|
15 |
|
require_once($INC . "/struct.inc.php"); |
15 |
16 |
require_once($INC . "/repo.inc.php"); |
require_once($INC . "/repo.inc.php"); |
16 |
17 |
require_once($INC . "/prof.inc.php"); |
require_once($INC . "/prof.inc.php"); |
17 |
18 |
require_once($INC . "/mr.inc.php"); |
require_once($INC . "/mr.inc.php"); |
|
... |
... |
if ($db === FALSE) { |
32 |
33 |
exit(1); |
exit(1); |
33 |
34 |
} |
} |
34 |
35 |
|
|
35 |
|
$r = rg_sql_struct_update_if_needed($db, RG_NO_DROP_TABLES); |
|
|
36 |
|
$r = rg_sql_struct_update_if_needed($db, 0); |
36 |
37 |
if ($r !== TRUE) |
if ($r !== TRUE) |
37 |
38 |
exit(1); |
exit(1); |
38 |
39 |
|
|
File scripts/remote.php changed (mode: 100644) (index 20d22bb..b8061aa) |
... |
... |
$INC = dirname(__FILE__) . "/../inc"; |
9 |
9 |
require_once($INC . "/util.inc.php"); |
require_once($INC . "/util.inc.php"); |
10 |
10 |
require_once($INC . "/log.inc.php"); |
require_once($INC . "/log.inc.php"); |
11 |
11 |
require_once($INC . "/sql.inc.php"); |
require_once($INC . "/sql.inc.php"); |
|
12 |
|
require_once($INC . "/struct.inc.php"); |
12 |
13 |
require_once($INC . "/repo.inc.php"); |
require_once($INC . "/repo.inc.php"); |
13 |
14 |
require_once($INC . "/prof.inc.php"); |
require_once($INC . "/prof.inc.php"); |
14 |
15 |
|
|
|
... |
... |
$db = rg_sql_open($rg_sql); |
133 |
134 |
if ($db === FALSE) |
if ($db === FALSE) |
134 |
135 |
fatal("Internal error (db)!"); |
fatal("Internal error (db)!"); |
135 |
136 |
|
|
136 |
|
$r = rg_sql_struct_update_if_needed($db, RG_NO_DROP_TABLES); |
|
|
137 |
|
$r = rg_sql_struct_update_if_needed($db, 0); |
137 |
138 |
if ($r !== TRUE) |
if ($r !== TRUE) |
138 |
139 |
fatal("We are in a short maintenance. Try again later."); |
fatal("We are in a short maintenance. Try again later."); |
139 |
140 |
|
|
|
... |
... |
putenv("ROCKETGIT_REPO_ID=" . $ri['repo_id']); |
176 |
177 |
putenv("ROCKETGIT_REPO_RIGHTS=" . $rights); |
putenv("ROCKETGIT_REPO_RIGHTS=" . $rights); |
177 |
178 |
putenv("ROCKETGIT_REPO_PATH=" . $repo_path); |
putenv("ROCKETGIT_REPO_PATH=" . $repo_path); |
178 |
179 |
putenv("ROCKETGIT_IP=$ip"); |
putenv("ROCKETGIT_IP=$ip"); |
|
180 |
|
putenv("ROCKETGIT_ITIME=" . microtime(TRUE)); |
179 |
181 |
if ($push == 1) { |
if ($push == 1) { |
180 |
182 |
$namespace = "rg_" . rg_id(8); |
$namespace = "rg_" . rg_id(8); |
181 |
183 |
rg_log("namespace is $namespace."); |
rg_log("namespace is $namespace."); |
182 |
184 |
putenv("GIT_NAMESPACE=" . $namespace); |
putenv("GIT_NAMESPACE=" . $namespace); |
183 |
185 |
|
|
184 |
|
// Prepare refs to not receive: |
|
|
186 |
|
// Prepare refs to avoid: |
185 |
187 |
// "No refs in common and none specified; doing nothing. |
// "No refs in common and none specified; doing nothing. |
186 |
188 |
// Perhaps you should specify a branch such as 'master'." |
// Perhaps you should specify a branch such as 'master'." |
187 |
189 |
$dst = $repo_path . "/refs/namespaces/" . $namespace . "/refs/heads"; |
$dst = $repo_path . "/refs/namespaces/" . $namespace . "/refs/heads"; |
File tests/keys.php changed (mode: 100644) (index 0407357..0526db4) |
... |
... |
ini_set("track_errors", "On"); |
5 |
5 |
$INC = "../inc"; |
$INC = "../inc"; |
6 |
6 |
require_once($INC . "/util.inc.php"); |
require_once($INC . "/util.inc.php"); |
7 |
7 |
require_once($INC . "/keys.inc.php"); |
require_once($INC . "/keys.inc.php"); |
|
8 |
|
require_once($INC . "/sql.inc.php"); |
8 |
9 |
require_once($INC . "/struct.inc.php"); |
require_once($INC . "/struct.inc.php"); |
9 |
10 |
|
|
10 |
11 |
rg_log_set_file("keys.log"); |
rg_log_set_file("keys.log"); |
File tests/repo.php changed (mode: 100644) (index 38547df..b779f70) |
... |
... |
ini_set("track_errors", "On"); |
4 |
4 |
|
|
5 |
5 |
$INC = "../inc"; |
$INC = "../inc"; |
6 |
6 |
require_once($INC . "/repo.inc.php"); |
require_once($INC . "/repo.inc.php"); |
|
7 |
|
require_once($INC . "/sql.inc.php"); |
7 |
8 |
require_once($INC . "/struct.inc.php"); |
require_once($INC . "/struct.inc.php"); |
8 |
9 |
|
|
9 |
10 |
rg_log_set_file("repo.log"); |
rg_log_set_file("repo.log"); |
|
... |
... |
if ($r !== TRUE) { |
91 |
92 |
exit(1); |
exit(1); |
92 |
93 |
} |
} |
93 |
94 |
|
|
94 |
|
rg_log("Inserting a fake user"); |
|
|
95 |
|
$repo_id = time(); |
|
96 |
|
$repo_name = "repo-" . $repo_id; |
|
97 |
|
rg_log("Inserting a fake repo"); |
95 |
98 |
$sql = "INSERT INTO repos (repo_id, name, uid, itime" |
$sql = "INSERT INTO repos (repo_id, name, uid, itime" |
96 |
99 |
. ", disk_quota_mb, max_commit_size" |
. ", disk_quota_mb, max_commit_size" |
97 |
100 |
. ", master, description, git_dir_done, default_rights)" |
. ", master, description, git_dir_done, default_rights)" |
98 |
|
. " VALUES (1, 'repo1', 1, 0, 0, 0, 0, 'bla bla desc', 1, 'F')"; |
|
|
101 |
|
. " VALUES ($repo_id, '$repo_name', 1, 0, 0, 0, 0, 'bla bla desc', 1, 'F')"; |
99 |
102 |
$res = rg_sql_query($db, $sql); |
$res = rg_sql_query($db, $sql); |
100 |
103 |
if ($res === FALSE) { |
if ($res === FALSE) { |
101 |
|
rg_log("Cannot insert a user (" . rg_sql_error() . ")!"); |
|
|
104 |
|
rg_log("Cannot insert a repo (" . rg_sql_error() . ")!"); |
102 |
105 |
exit(1); |
exit(1); |
103 |
106 |
} |
} |
104 |
107 |
|
|
105 |
108 |
rg_log("test giving rights"); |
rg_log("test giving rights"); |
106 |
|
$repo_id = 1; |
|
107 |
109 |
$rr = array("repo_id" => $repo_id); |
$rr = array("repo_id" => $repo_id); |
108 |
110 |
$ri = rg_repo_info($db, $rr); |
$ri = rg_repo_info($db, $rr); |
109 |
111 |
$uid = 10; |
$uid = 10; |
|
... |
... |
if ($r !== FALSE) { |
171 |
173 |
exit(1); |
exit(1); |
172 |
174 |
} |
} |
173 |
175 |
|
|
|
176 |
|
|
|
177 |
|
// test stats |
|
178 |
|
$rg_repos = "repos"; |
|
179 |
|
$a = array( |
|
180 |
|
"itime" => time(), |
|
181 |
|
"ip" => "IPIPIPIPIPIP1", |
|
182 |
|
"repo_id" => 3000, |
|
183 |
|
"old_rev" => "abcdef", |
|
184 |
|
"new_rev" => "434343", |
|
185 |
|
"refname" => "refs/heads/xxx"); |
|
186 |
|
$f = rg_repo_stats_push2file($a); |
|
187 |
|
if ($f === FALSE) { |
|
188 |
|
echo "push2file returned FALSE!\n"; |
|
189 |
|
exit(1); |
|
190 |
|
} |
|
191 |
|
$r = unserialize(file_get_contents($rg_repos . "/qstats/$f")); |
|
192 |
|
if ($r === FALSE) { |
|
193 |
|
echo "Cannot get file or unserialize!\n"; |
|
194 |
|
exit(1); |
|
195 |
|
} |
|
196 |
|
if ($r['repo_id'] != 3000) { |
|
197 |
|
print_r($r); |
|
198 |
|
echo "rg_repo_stats_push2file is not working right!\n"; |
|
199 |
|
exit(1); |
|
200 |
|
} |
|
201 |
|
|
174 |
202 |
rg_sql_close($db); |
rg_sql_close($db); |
175 |
203 |
|
|
176 |
204 |
echo "repo: OK!\n"; |
echo "repo: OK!\n"; |
File tests/state.php changed (mode: 100644) (index 7df990f..dfbfe22) |
... |
... |
ini_set("track_errors", "On"); |
5 |
5 |
$INC = "../inc"; |
$INC = "../inc"; |
6 |
6 |
require_once($INC . "/log.inc.php"); |
require_once($INC . "/log.inc.php"); |
7 |
7 |
require_once($INC . "/sql.inc.php"); |
require_once($INC . "/sql.inc.php"); |
8 |
|
require_once($INC . "/state.inc.php"); |
|
9 |
8 |
require_once($INC . "/struct.inc.php"); |
require_once($INC . "/struct.inc.php"); |
|
9 |
|
require_once($INC . "/state.inc.php"); |
10 |
10 |
|
|
11 |
11 |
rg_log_set_file("state.log"); |
rg_log_set_file("state.log"); |
12 |
12 |
|
|
File tests/user.php changed (mode: 100644) (index 7ced4fe..e6501bb) |
... |
... |
ini_set("track_errors", "On"); |
4 |
4 |
|
|
5 |
5 |
$INC = "../inc"; |
$INC = "../inc"; |
6 |
6 |
require_once($INC . "/user.inc.php"); |
require_once($INC . "/user.inc.php"); |
|
7 |
|
require_once($INC . "/sql.inc.php"); |
7 |
8 |
require_once($INC . "/struct.inc.php"); |
require_once($INC . "/struct.inc.php"); |
8 |
9 |
|
|
9 |
10 |
$rg_sql_debug = 1; |
$rg_sql_debug = 1; |
|
... |
... |
$rg_sql_debug = 1; |
11 |
12 |
rg_log_set_file("user.log"); |
rg_log_set_file("user.log"); |
12 |
13 |
|
|
13 |
14 |
$rg_user_max_len = 20; |
$rg_user_max_len = 20; |
14 |
|
$rg_pass_key = "aaa"; |
|
15 |
15 |
$rg_session_time = 3600; |
$rg_session_time = 3600; |
16 |
16 |
$rg_user_allow = '/^[A-Za-z0-9_.-]*$/'; |
$rg_user_allow = '/^[A-Za-z0-9_.-]*$/'; |
17 |
17 |
$rg_admin_email = "admin@localhost"; |
$rg_admin_email = "admin@localhost"; |