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 abe986682dea732dbd4248fac63bdd6b015b8f2e

3-4 bugs fixed after the first day of alpha1
Author: Catalin(ux) M. BOIE
Author date (UTC): 2012-10-18 18:43
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2012-10-18 18:43
Parent(s): b6d33127f42dc9d1ecf2cf1850a8dedfacf47eff
Signing key:
Tree: 40ceb435132f707adfa6d74861f834bc15ca5c8e
File Lines added Lines deleted
.exclude 0 1
Makefile.in 1 1
README 3 0
TODO 6 1
admin/init.php 3 2
duilder.conf 1 1
inc/bug.inc.php 2 1
inc/repo.inc.php 10 1
inc/repo/repo.php 1 1
inc/rights.inc.php 9 2
inc/user/repo-page.php 1 0
inc/user/repo/admin.php 1 1
inc/util.inc.php 14 6
rocketgit.spec.in 3 0
scripts/remote.php 1 1
File .exclude changed (mode: 100644) (index 476a6b6..06a4014)
1 .exclude
2 1 cata cata
3 2 *.log *.log
4 3 Makefile Makefile
File Makefile.in changed (mode: 100644) (index 5e9380e..310b5f5)
... ... install: all
30 30 @mkdir -p $(I_VAR_LOG)/$(PRJ)-web @mkdir -p $(I_VAR_LOG)/$(PRJ)-web
31 31 @-chown apache:apache $(I_VAR_LOG)/$(PRJ)-web @-chown apache:apache $(I_VAR_LOG)/$(PRJ)-web
32 32 @chmod 0700 $(I_VAR_LOG)/$(PRJ)-web @chmod 0700 $(I_VAR_LOG)/$(PRJ)-web
33 @mkdir -p $(I_VAR_LIB)/$(PRJ) $(I_VAR_LIB)/$(PRJ)/locks $(I_VAR_LIB)/$(PRJ)/repos
33 @mkdir -p $(I_VAR_LIB)/$(PRJ) $(I_VAR_LIB)/$(PRJ)/locks $(I_VAR_LIB)/$(PRJ)/repos $(I_VAR_LIB)/$(PRJ)/q_merge_requests
34 34 @-chown -R rocketgit:rocketgit $(I_VAR_LIB)/$(PRJ) @-chown -R rocketgit:rocketgit $(I_VAR_LIB)/$(PRJ)
File README changed (mode: 100644) (index 90bf862..69d280c)
71 71 -A INPUT -m tcp -p tcp --dport http -j ACCEPT -A INPUT -m tcp -p tcp --dport http -j ACCEPT
72 72 -A INPUT -m tcp -p tcp --dport https -j ACCEPT -A INPUT -m tcp -p tcp --dport https -j ACCEPT
73 73
74 . PHP
75 Adjust php.ini to allow enough RAM and execution time.
76
74 77
75 78 == Thanks == == Thanks ==
76 79 . Special thanks to my family that supported me in this project. . Special thanks to my family that supported me in this project.
File TODO changed (mode: 100644) (index d8ad80b..7837153)
6 6 [ ] All internal error should show a special page? [ ] All internal error should show a special page?
7 7 [ ] Deleting a SSH key should be done with token. [ ] Deleting a SSH key should be done with token.
8 8 [ ] All operations must be verified with tokens. [ ] All operations must be verified with tokens.
9 [ ]
9 [ ] If the confirmation code is truncated, an internal error is generated
10 instead of a user error!
11 [ ] Third option: anybody can create an account but must be validated by admin.
12 [ ] After creating the account, keep the user logged in and allow login
13 even if is not confirmed (option in config).
10 14
11 15
12 16 == Medium == == Medium ==
17 [ ] Check if if we remove rocketgit, the repos stay!
13 18 [ ] Bug rights: add note, anonymous add note, add label, add global search. [ ] Bug rights: add note, anonymous add note, add label, add global search.
14 19 [ ] Allow user to specify if is on windows/linux/etc. to be able to give [ ] Allow user to specify if is on windows/linux/etc. to be able to give
15 20 specific hints. Hm. THe user may have multiple OSs. specific hints. Hm. THe user may have multiple OSs.
File admin/init.php changed (mode: 100644) (index 5d7aade..c9a0e0f)
... ... require_once($INC . "/log.inc.php");
12 12 require_once($INC . "/sql.inc.php"); require_once($INC . "/sql.inc.php");
13 13 require_once($INC . "/struct.inc.php"); require_once($INC . "/struct.inc.php");
14 14 require_once($INC . "/state.inc.php"); require_once($INC . "/state.inc.php");
15 require_once($INC . "/rights.inc.php");
15 16
16 17 rg_log_set_file("init.log"); rg_log_set_file("init.log");
17 18
 
... ... $_u = array();
32 33 $_u['uid'] = 0; $_u['uid'] = 0;
33 34 $_u['username'] = "admin"; $_u['username'] = "admin";
34 35 $_u['realname'] = "Master admin"; $_u['realname'] = "Master admin";
35 $_u['email'] = $_u['rg_admin_email;
36 $_u['email'] = $rg_admin_email;
36 37 $_u['is_admin'] = 1; $_u['is_admin'] = 1;
37 38 $_u['disk_quota_mb'] = 0; $_u['disk_quota_mb'] = 0;
38 39 $_u['rights'] = rg_rights_all("user"); $_u['rights'] = rg_rights_all("user");
 
... ... if ($first_install == 0)
82 83
83 84 $install_id = rg_state_get($db, "install_id"); $install_id = rg_state_get($db, "install_id");
84 85 if (empty($install_id)) if (empty($install_id))
85 rg_state_set($db, "install_id", sha1sum(microtime(TRUE)));
86 rg_state_set($db, "install_id", sha1(microtime(TRUE)));
86 87
87 88 echo "Done!\n"; echo "Done!\n";
88 89 ?> ?>
File duilder.conf changed (mode: 100644) (index b2d85e5..4d35852)
1 1 PRJ="rocketgit" PRJ="rocketgit"
2 VER="0.11"
2 VER="0.12"
3 3 REV="1" REV="1"
4 4 EXCLUDE=".exclude" EXCLUDE=".exclude"
5 5 EXPORT_PATH="/data/www/umbrella/kernel/us/rocketgit" EXPORT_PATH="/data/www/umbrella/kernel/us/rocketgit"
File inc/bug.inc.php changed (mode: 100644) (index 1d2c24f..7e4f243)
... ... function rg_bug_search_load($db, $repo_id, $uid, $name)
492 492
493 493 $e_name = rg_sql_escape($db, $name); $e_name = rg_sql_escape($db, $name);
494 494
495 $sql = "SELECT name, data, for_all_users FROM bug_search"
495 $sql = "SELECT uid, name, data, for_all_users"
496 . " FROM bug_search"
496 497 . " WHERE (repo_id = $repo_id OR repo_id = 0)" . " WHERE (repo_id = $repo_id OR repo_id = 0)"
497 498 . " AND (uid = $uid OR for_all_users = 1)" . " AND (uid = $uid OR for_all_users = 1)"
498 499 . " AND name = '$e_name'" . " AND name = '$e_name'"
File inc/repo.inc.php changed (mode: 100644) (index 957cca7..ed54763)
... ... function rg_repo_name2base($rr)
93 93 return rg_user_name2path($rr) . "/repos/"; return rg_user_name2path($rr) . "/repos/";
94 94 } }
95 95
96 $rg_repo_info_cache = array();
97 function rg_repo_invalidate_cache($rr)
98 {
99 global $rg_repo_info_cache;
100
101 $key = implode("__", $rr);
102 if (isset($rg_repo_info_cache[$key]))
103 unset($rg_repo_info_cache[$key]);
104 }
105
96 106 /* /*
97 107 * Return info about a repo * Return info about a repo
98 108 * @param rr contains data about user and repo * @param rr contains data about user and repo
99 109 */ */
100 $rg_repo_info_cache = array();
101 110 function rg_repo_info($db, $rr) function rg_repo_info($db, $rr)
102 111 { {
103 112 global $rg_repo_info_cache; global $rg_repo_info_cache;
File inc/repo/repo.php changed (mode: 100644) (index 5116e0d..a9d24f6)
... ... $max_commit_size = rg_var_uint("max_commit_size");
13 13 $max_users = rg_var_uint("max_users"); $max_users = rg_var_uint("max_users");
14 14 $description = rg_var_str("description"); $description = rg_var_str("description");
15 15 $master_repo_id = rg_var_uint("master_repo_id"); $master_repo_id = rg_var_uint("master_repo_id");
16 $rights = isset($_REQUEST['rights']) ? rg_rights_a2s($_REQUEST['rights']) : $rg_repo_rights_default;
16 $rights = isset($_REQUEST['rights']) ? rg_rights_a2s(rg_var_str("rights")) : $rg_repo_rights_default;
17 17 $repo_id = rg_var_uint("repo_id"); $repo_id = rg_var_uint("repo_id");
18 18
19 19 if (empty($subop)) if (empty($subop))
File inc/rights.inc.php changed (mode: 100644) (index 3afd2e7..dd6adbf)
... ... function rg_rights_get($db, $type, $obj_id, $uid)
150 150 $ret['ok'] = 0; $ret['ok'] = 0;
151 151 $ret['rights'] = ""; $ret['rights'] = "";
152 152
153 if ($uid == 0) {
154 $ret['ok'] = 1;
155 return $ret;
156 }
157
153 158 $sql = "SELECT rights FROM rights" $sql = "SELECT rights FROM rights"
154 159 . " WHERE type = '$type'" . " WHERE type = '$type'"
155 160 . " AND uid = $uid" . " AND uid = $uid"
 
... ... function rg_rights_get($db, $type, $obj_id, $uid)
172 177 $ret['exists'] = 1; $ret['exists'] = 1;
173 178 } }
174 179
175 rg_log("\tdb rights: " . $ret['rights'] . ".");
180 rg_log("\tdb rights: [" . $ret['rights'] . "].");
176 181
177 182 return $ret; return $ret;
178 183 } }
 
... ... function rg_rights_mask($val, $mask)
298 303 function rg_rights_allow($rights, $needed_rights) function rg_rights_allow($rights, $needed_rights)
299 304 { {
300 305 $r = rg_rights_mask($rights, $needed_rights); $r = rg_rights_mask($rights, $needed_rights);
301 if (strcmp($r, $needed_rights) != 0)
306 if (strcmp($r, $needed_rights) != 0) {
307 rg_log("rights_allow: [$r] != [$needed_rights]!");
302 308 return FALSE; return FALSE;
309 }
303 310
304 311 return TRUE; return TRUE;
305 312 } }
File inc/user/repo-page.php changed (mode: 100644) (index be8d7a9..a9ef6ab)
... ... while (1) {
31 31
32 32 rg_log("git dir is not ready yet. Sleep 1 second and loop."); rg_log("git dir is not ready yet. Sleep 1 second and loop.");
33 33 sleep(1); sleep(1);
34 rg_repo_invalidate_cache($rr);
34 35 } }
35 36
36 37 $ui = rg_user_info($db, 0, $rr['user'], ""); $ui = rg_user_info($db, 0, $rr['user'], "");
File inc/user/repo/admin.php changed (mode: 100644) (index 451cdde..606e967)
... ... $_url_admin = rg_re_repopage($rg_ui, $rr['repo']) . "/admin";
8 8 $_admin_more = array_merge($more, $ri); $_admin_more = array_merge($more, $ri);
9 9 $_admin_more['url_admin'] = $_url_admin; $_admin_more['url_admin'] = $_url_admin;
10 10
11 $_op = @$paras[0];
11 $_op = empty($paras) ? "" : $paras[0];
12 12 switch ($_op) { switch ($_op) {
13 13 case 'edit': case 'edit':
14 14 include($INC . "/user/repo/edit/edit.php"); include($INC . "/user/repo/edit/edit.php");
File inc/util.inc.php changed (mode: 100644) (index 63abecc..7b95106)
... ... function rg_lock($file)
68 68 global $rg_lock_dir; global $rg_lock_dir;
69 69
70 70 if (!isset($rg_lock_dir)) if (!isset($rg_lock_dir))
71 $rg_lock_dir = "/var/lib/rocketgit";
71 $rg_lock_dir = "/var/lib/rocketgit/locks";
72 72
73 73 // Double locking? // Double locking?
74 74 if (isset($_lock[$file])) if (isset($_lock[$file]))
 
... ... function rg_var_str($name)
213 213
214 214 if (isset($_COOKIE[$name])) if (isset($_COOKIE[$name]))
215 215 $ret = $_COOKIE[$name]; $ret = $_COOKIE[$name];
216
217 if (isset($_POST[$name]))
216 else if (isset($_POST[$name]))
218 217 $ret = $_POST[$name]; $ret = $_POST[$name];
219
220 if (isset($_GET[$name]))
218 else if (isset($_GET[$name]))
221 219 $ret = $_GET[$name]; $ret = $_GET[$name];
222 220
223 return htmlspecialchars($ret, ENT_QUOTES);
221 if (is_string($ret))
222 return htmlspecialchars($ret, ENT_QUOTES);
223
224 if (is_array($ret)) {
225 $ret2 = array();
226 foreach ($ret as $k => $v)
227 $ret2[$k] = htmlspecialchars($v, ENT_QUOTES);
228 return $ret;
229 }
230
231 return "";
224 232 } }
225 233
226 234 function rg_var_int($name) function rg_var_int($name)
File rocketgit.spec.in changed (mode: 100644) (index 10be4e3..13b61a4)
... ... rm -rf ${RPM_BUILD_ROOT}
60 60 %attr(0700,rocketgit,rocketgit) %dir /var/log/@PRJ@ %attr(0700,rocketgit,rocketgit) %dir /var/log/@PRJ@
61 61 %attr(0700,apache,apache) %dir /var/log/@PRJ@-web %attr(0700,apache,apache) %dir /var/log/@PRJ@-web
62 62 %attr(0700,rocketgit,rocketgit) %dir /var/lib/@PRJ@ %attr(0700,rocketgit,rocketgit) %dir /var/lib/@PRJ@
63 %attr(0700,rocketgit,rocketgit) %dir /var/lib/@PRJ@/locks
64 %attr(0700,rocketgit,rocketgit) %dir /var/lib/@PRJ@/repos
65 %attr(0700,rocketgit,rocketgit) %dir /var/lib/@PRJ@/q_merge_requests
63 66 %config(noreplace) /etc/logrotate.d/rocketgit %config(noreplace) /etc/logrotate.d/rocketgit
64 67
65 68 %changelog %changelog
File scripts/remote.php changed (mode: 100644) (index 78e4c5f..3bcac66)
... ... if ($ret['ok'] !== 1)
158 158 $rights = $ret['rights']; $rights = $ret['rights'];
159 159
160 160 if (rg_rights_allow($rights, $needed_rights) === FALSE) if (rg_rights_allow($rights, $needed_rights) === FALSE)
161 fatal("Repo does not exists.");
161 fatal("You have no rights to access this repo!");
162 162
163 163 // TODO: limit per connection // TODO: limit per connection
164 164 // TODO: limit time and/or cpu // TODO: limit time and/or cpu
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