List of commits:
Subject Hash Author Date (UTC)
Bulk changes e3771b115feb49698383730893ced1bac5670cac Catalin(ux) M. BOIE 2011-06-29 21:50:03
Ignore Changelog-last file. 32260f93743a577cbaf7cefd335517e4a42edcf0 Catalin(ux) M. BOIE 2011-06-27 21:20:53
Ignore *.out files. 265ba83a2df891cdcc7b35801a46cfc2583983ee Catalin(ux) M. BOIE 2011-06-27 21:20:23
Added shadow-utils as dependency fot user/groupadd. f5816c0bd992881439706041986a3a178eaf69bd Catalin(ux) M. BOIE 2011-06-27 21:08:32
More rpm fixes. 701daf680d15dc69a2a8709f6de5167b55ce02c2 Catalin(ux) M. BOIE 2011-06-27 21:01:24
Add rocketgit user and group. 1b2f9e1e16ed98d5eadd575a87bf0ff738d710c4 Catalin(ux) M. BOIE 2011-06-27 20:59:59
Other bulk stuff. 6cbfef4abe177ad8dad6bdc5ba3fb1d0e2270a9b Catalin(ux) M. BOIE 2011-06-27 19:50:32
Ignore *.log files. a87bc5c123478e429f430684a0962c8301e7cf90 Catalin(ux) M. BOIE 2011-06-27 19:49:58
Exclude from tar some bogus files. 77766d5276226ab0d6a03985a462daef3c91856a Catalin(ux) M. BOIE 2011-06-27 19:49:26
Lots of stuff. c1778920e66c4561f63632030fff66bff71d4395 Catalin(ux) M. BOIE 2011-06-27 17:33:14
Another round of fixes. 3c6df6f5a6053d322f93814b3a8ccc8555951d9f Catalin(ux) M. BOIE 2011-05-04 03:22:27
Another round of fixes. 0d841811babba24b643404169b645379377a92f9 Catalin(ux) M. BOIE 2011-05-03 03:29:10
Bulk updates. 31a2d477a86a3a408c44720bb8c8e280fc4894d2 Catalin(ux) M. BOIE 2011-04-06 20:37:51
Bulk update. 852d93d3bf7995ca427982f4ec1aa2bd1bf75063 Catalin(ux) M. BOIE 2011-04-06 15:22:02
Do not log IP. For IPv6 is eating a whole line. Session is enough. aae5180a3eed608170972b9a49bf19be37353141 Catalin(ux) M. BOIE 2011-03-18 04:07:53
Another bulk update. 9578a66fd047f044525e37469e6fc1db052ad486 Catalin(ux) M. BOIE 2011-03-16 04:27:24
Another bulk commit. 2ad8a84b27b80b66efa680f778dbf562d08da099 Catalin(ux) M. BOIE 2011-03-15 04:10:24
Bulk changes. 71ffd566d62b019302ffaeebaae0ab5edddc93d3 Catalin(ux) M. BOIE 2011-03-05 23:42:55
Bulk changes. 4a55c6d1cbe7d70e3982412d93c451d1f22e9448 Catalin(ux) M. BOIE 2011-03-04 21:57:58
Added license file, main page and first css. be67fd56b67c6bafb054aed02500a597c33b7f5d Catalin(ux) M. BOIE 2011-03-03 22:56:43
Commit e3771b115feb49698383730893ced1bac5670cac - Bulk changes
Author: Catalin(ux) M. BOIE
Author date (UTC): 2011-06-29 21:50
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2011-06-29 21:50
Parent(s): 32260f93743a577cbaf7cefd335517e4a42edcf0
Signing key:
Tree: 0b40d369928499d222cdbe066c6f3516ad6f5c5a
File Lines added Lines deleted
Makefile.in 5 5
README 18 6
admin/init.php 60 0
admin/sql.php 0 19
duilder 13 10
hooks/pre-commit 1 1
hooks/update 1 1
inc/admin/users/edit.php 1 1
inc/db.inc.php 24 16
inc/db/struct.inc.php 14 8
inc/db_sqlite.inc.php 0 0
inc/keys.inc.php 9 8
inc/personal/personal.php 1 1
inc/repo.inc.php 4 4
inc/repo/repo_page.php 2 2
inc/rights.inc.php 1 1
inc/state.inc.php 30 9
inc/user.inc.php 23 13
inc/util.inc.php 12 0
rocketgit.spec.in 18 7
root/index.php 3 3
samples/config.php 2 1
scripts/cron.php 2 2
scripts/q.php 8 3
scripts/ssh.php 1 1
tests/db.php 22 15
tests/keys.php 11 13
tests/repo.php 5 8
tests/rights.php 1 1
tests/state.php 11 13
tests/user.php 5 8
tests/util.php 1 1
File Makefile.in changed (mode: 100644) (index 6f08479..0e44ee9)
1 export CC := gcc
2 export INCS +=
3 export LIBS +=
4
5 1 .PHONY: all .PHONY: all
6 2 all: junk all: junk
7 3
 
... ... clean:
16 12
17 13 install: all install: all
18 14 @mkdir -p $(I_USR_SHARE)/$(PRJ) @mkdir -p $(I_USR_SHARE)/$(PRJ)
19 cp -vdr inc hooks root scripts $(I_USR_SHARE)/$(PRJ)
15 cp -vdr admin inc hooks root scripts $(I_USR_SHARE)/$(PRJ)
20 16 @mkdir -p $(I_ETC)/xinetd.d @mkdir -p $(I_ETC)/xinetd.d
21 17 cp -vd samples/rg $(I_ETC)/xinetd.d/rocketgit cp -vd samples/rg $(I_ETC)/xinetd.d/rocketgit
22 18 @mkdir -p $(I_ETC)/cron.d @mkdir -p $(I_ETC)/cron.d
 
... ... install: all
26 22 @mkdir -p $(I_ETC)/rocketgit @mkdir -p $(I_ETC)/rocketgit
27 23 cp -vd samples/config.php $(I_ETC)/rocketgit/ cp -vd samples/config.php $(I_ETC)/rocketgit/
28 24 cp -vd samples/config.php $(I_ETC)/rocketgit/config.php.sample cp -vd samples/config.php $(I_ETC)/rocketgit/config.php.sample
25 @mkdir -p $(I_VAR_LOG)/$(PRJ)
26 @chown rocketgit:rocketgit $(I_VAR_LOG)/$(PRJ)
27 @mkdir -p $(I_VAR_RUN)/$(PRJ)
28 @chown rocketgit:rocketgit $(I_VAR_RUN)/$(PRJ)
File README changed (mode: 100644) (index 29918cb..897b3b7)
1 client does pull:
2 SSH_ORIGINAL_COMMAND=git-upload-pack '/aa/bb/cc/dd.git'
3
4 client does push:
5 SSH_ORIGINAL_COMMAND=git-receive-pack '/aa/bb/cc/dd.git'
6
7 1 == Rights == == Rights ==
8 2 A - Admin - can edit repo info, can add/remove rights for users A - Admin - can edit repo info, can add/remove rights for users
9 3 F - Fetch F - Fetch
 
... ... Z - Forced push (history rewriting)
13 7
14 8 Notes: Notes:
15 9 - For anonymous access, we store rights directly in repo info row. - For anonymous access, we store rights directly in repo info row.
10
11 == Install ==
12 . Install and configure PostgreSQL server
13 . Create a rocketgit user
14 # su - postgres
15 $ createuser -d -R -S -W rocketgit
16
17 . Create the database
18 # su - postgres
19 $ createdb -O rocketgit rocketgit
20
21 . Set correct rights in pg_hba.conf:
22 local rocketgit rocketgit trust
23
24 . Run instalation script
25 # php /usr/share/rocketgit/admin/init.php
26
27 . SELinux
File admin/init.php added (mode: 100644) (index 0000000..a11ba03)
1 <?php
2 // This is executed at the first instalation
3 error_reporting(E_ALL);
4 ini_set("track_errors", "On");
5
6 require_once("/etc/rocketgit/config.php");
7
8 $INC = dirname(__FILE__) . "/../inc";
9 require_once($INC . "/util.inc.php");
10 require_once($INC . "/log.inc.php");
11 require_once($INC . "/db.inc.php");
12 require_once($INC . "/db/struct.inc.php");
13 require_once($INC . "/repo.inc.php");
14
15 $db = rg_sql_open($rg_db);
16 if ($db === FALSE) {
17 echo "Internal error (" . rg_sql_error() . ")!";
18 exit(1);
19 }
20
21 if (rg_db_struct_run($db, TRUE, 0) !== TRUE) {
22 echo "Cannot init structure (" . rg_sql_error() . ")!\n";
23 exit(1);
24 }
25
26 // creating admin user
27 $uid = 0;
28 $is_admin = 1;
29 $disk_quota_mb = 0;
30 $rights = rg_rights_all("user");
31 $user = "admin";
32 $email = "";
33 while (1) {
34 $user0 = readline("User [$user]: ");
35 if (!empty($user0))
36 $user = $user0;
37 $email0 = readline("E-mail [$email]: ");
38 if (!empty($email0))
39 $email = $email0;
40 while (1) {
41 $pass = readline("Password: ");
42 $pass2 = readline("Password (confirmation): ");
43 if (strcmp($pass, $pass2) != 0) {
44 echo "Passwords mismatch!\n";
45 continue;
46 }
47 break;
48 }
49
50 $r = rg_user_edit($db, $uid, $user, $email, $pass, $is_admin,
51 $disk_quota_mb, $rights);
52 if ($r !== TRUE) {
53 echo "Cannot create user (" . rg_user_error() . ")!\n";
54 continue;
55 }
56 break;
57 }
58
59 echo "Done!\n";
60 ?>
File admin/sql.php deleted (index 96db998..0000000)
1 <?php
2 error_reporting(E_ALL);
3
4 require_once("/etc/rg/config.php");
5
6 $INC = dirname(__FILE__) . "/../inc";
7 require_once($INC . "/log.inc.php");
8 require_once($INC . "/db.inc.php");
9 require_once($INC . "/db/struct.inc.php");
10 require_once($INC . "/repo.inc.php");
11
12 $db = rg_sql_open($rg_db);
13 if ($db === FALSE)
14 fatal("Internal error (db)!");
15
16 rg_db_struct_run($db, TRUE);
17
18 echo "Done!\n";
19 ?>
File duilder changed (mode: 100755) (index eb0f11a..a15834c)
... ... function duilder_tar()
229 229 (cd .. \ (cd .. \
230 230 && rm -rf "${P}" \ && rm -rf "${P}" \
231 231 && cp -a --link "${PRJ}" "${P}" \ && cp -a --link "${PRJ}" "${P}" \
232 && tar czvf "${PRJ}/${P}.tar.gz" \
232 && tar czf "${PRJ}/${P}.tar.gz" \
233 233 --exclude-vcs \ --exclude-vcs \
234 234 --exclude ${P}/Makefile \ --exclude ${P}/Makefile \
235 235 ${ADD_EXCLUDE} \ ${ADD_EXCLUDE} \
 
... ... fi
317 317
318 318
319 319 ###### Main stuff ###### Main stuff
320 echo
321 echo "Duilder builder script"
322 echo "Copyright Catalin(ux) M. BOIE - catab at embedromix dot ro"
323 echo
324 echo "PRJ=${PRJ}, VER=${VER}, REV=${REV}"
325 echo "System: `uname -a`"
320 echo "[*] Duilder builder script"
321 echo "[*] Copyright Catalin(ux) M. BOIE - catab at embedromix dot ro"
322 echo "[*] PRJ=${PRJ}, VER=${VER}, REV=${REV}"
323 echo "[*] System: `uname -a`"
326 324
327 325 ETC="/etc" ETC="/etc"
328 326 BIN="/bin" BIN="/bin"
 
... ... USR_LIB="/usr/lib"
333 331 USR_SHARE="/usr/share" USR_SHARE="/usr/share"
334 332 USR_SHARE_DOC="/usr/share/doc/${PRJ}-${VER}" USR_SHARE_DOC="/usr/share/doc/${PRJ}-${VER}"
335 333 SBIN="/usr/sbin" SBIN="/usr/sbin"
336 VAR="/var"
337 VAR_LOG="/var/log/${PRJ}"
334 VAR_LOG="/var/log"
335 VAR_RUN="/var/run"
338 336
339 337 while [ "${1}" != "" ]; do while [ "${1}" != "" ]; do
340 338 VAR="`echo ${1} | cut -d'=' -f1`" VAR="`echo ${1} | cut -d'=' -f1`"
 
... ... while [ "${1}" != "" ]; do
356 354 USR_LIB="${VAL}" USR_LIB="${VAL}"
357 355 ;; ;;
358 356 --localstatedir) --localstatedir)
359 VAR="${VAL}"
357 VAR_RUN="${VAL}"
358 ;;
359 --log-dir)
360 VAR_LOG="${VAL}"
360 361 ;; ;;
361 362 --datadir) --datadir)
362 363 USR_SHARE="${VAL}" USR_SHARE="${VAL}"
 
... ... echo "s#@SBIN@#${SBIN}#g" >> tmp.sed
465 466 echo "s#@USR_SBIN@#${USR_SBIN}#g" >> tmp.sed echo "s#@USR_SBIN@#${USR_SBIN}#g" >> tmp.sed
466 467 echo "s#@VAR@#${VAR}#g" >> tmp.sed echo "s#@VAR@#${VAR}#g" >> tmp.sed
467 468 echo "s#@VAR_LOG@#${VAR_LOG}#g" >> tmp.sed echo "s#@VAR_LOG@#${VAR_LOG}#g" >> tmp.sed
469 echo "s#@VAR_RUN@#${VAR_RUN}#g" >> tmp.sed
468 470 echo "s#@USR_INCLUDE@#${USR_INCLUDE}#g" >> tmp.sed echo "s#@USR_INCLUDE@#${USR_INCLUDE}#g" >> tmp.sed
469 471 echo "s#@USR_INC@#${USR_INCLUDE}#g" >> tmp.sed echo "s#@USR_INC@#${USR_INCLUDE}#g" >> tmp.sed
470 472 echo "s#@USR_LIB@#${USR_LIB}#g" >> tmp.sed echo "s#@USR_LIB@#${USR_LIB}#g" >> tmp.sed
 
... ... if [ -r Makefile.in ]; then
497 499 echo "export I_LIB := \$(DESTDIR)${USR_LIB}" >> Makefile echo "export I_LIB := \$(DESTDIR)${USR_LIB}" >> Makefile
498 500 echo "export I_VAR := \$(DESTDIR)${VAR}" >> Makefile echo "export I_VAR := \$(DESTDIR)${VAR}" >> Makefile
499 501 echo "export I_VAR_LOG := \$(DESTDIR)${VAR_LOG}" >> Makefile echo "export I_VAR_LOG := \$(DESTDIR)${VAR_LOG}" >> Makefile
502 echo "export I_VAR_RUN := \$(DESTDIR)${VAR_RUN}" >> Makefile
500 503 echo >> Makefile echo >> Makefile
501 504 echo "# DB stuff" >> Makefile echo "# DB stuff" >> Makefile
502 505 echo "export DB_SUPPORT := ${DB_SUPPORT}" >> Makefile echo "export DB_SUPPORT := ${DB_SUPPORT}" >> Makefile
File hooks/pre-commit changed (mode: 100755) (index b599393..804285b)
... ... ini_set("track_errors", "On");
7 7
8 8 $_start = microtime(TRUE); $_start = microtime(TRUE);
9 9
10 require_once("/etc/rg/config.php");
10 require_once("/etc/rocketgit/config.php");
11 11
12 12 $INC = dirname(__FILE__) . "/../inc"; $INC = dirname(__FILE__) . "/../inc";
13 13 require_once($INC . "/util.inc.php"); require_once($INC . "/util.inc.php");
File hooks/update changed (mode: 100755) (index 95e40c6..0de5d4d)
... ... ini_set("track_errors", "On");
7 7
8 8 $_start = microtime(TRUE); $_start = microtime(TRUE);
9 9
10 require_once("/etc/rg/config.php");
10 require_once("/etc/rocketgit/config.php");
11 11
12 12 $INC = dirname(__FILE__) . "/../inc"; $INC = dirname(__FILE__) . "/../inc";
13 13 require_once($INC . "/util.inc.php"); require_once($INC . "/util.inc.php");
File inc/admin/users/edit.php changed (mode: 100644) (index 40ab930..cd62055)
... ... if ($doit == 1) {
40 40 } else if ($_ui['exists'] == 0) { } else if ($_ui['exists'] == 0) {
41 41 $_user_edit .= "User does not exists!<br />"; $_user_edit .= "User does not exists!<br />";
42 42 } else { } else {
43 $xuser = $_ui['user'];
43 $xuser = $_ui['username'];
44 44 $email = $_ui['email']; $email = $_ui['email'];
45 45 $xpass = ""; $xpass = "";
46 46 $is_admin = $_ui['is_admin']; $is_admin = $_ui['is_admin'];
File inc/db.inc.php changed (mode: 100644) (index 510a17a..c549c4a)
... ... $rg_sql_debug = 0;
5 5
6 6 $rg_sql_error = ""; $rg_sql_error = "";
7 7
8 if (!function_exists("pg_connect"))
9 die("FATAL: php PostgreSQL is not installed!");
10
8 11 /* /*
9 12 * Set error string * Set error string
10 13 */ */
 
... ... function rg_sql_open($str)
33 36 if ($rg_sql_debug > 0) if ($rg_sql_debug > 0)
34 37 rg_log("DB: opening [$str]..."); rg_log("DB: opening [$str]...");
35 38
36 if (strncmp($str, "sqlite:", 7) != 0) {
37 sql_set_error("$str connect string not supported");
38 return FALSE;
39 }
40
41 $file = substr($str, 7);
42
43 $db = new SQLite3($file);
39 $db = @pg_pconnect($str);
44 40 if ($db === FALSE) { if ($db === FALSE) {
45 rg_sql_set_error("Cannot connect to database $file: " . $db->lastErrorMsg());
41 rg_sql_set_error("cannot connect to database (" . $php_errormsg . ")");
46 42 return FALSE; return FALSE;
47 43 } }
48 44
 
... ... function rg_sql_open($str)
54 50 */ */
55 51 function rg_sql_escape($db, $str) function rg_sql_escape($db, $str)
56 52 { {
57 return $db->escapeString($str);
53 return pg_escape_string($db, $str);
58 54 } }
59 55
60 56 /* /*
 
... ... function rg_sql_query($db, $sql)
67 63 if ($rg_sql_debug > 0) if ($rg_sql_debug > 0)
68 64 rg_log("DB: running [$sql]..."); rg_log("DB: running [$sql]...");
69 65
70 $res = $db->query($sql);
66 $res = @pg_query($db, $sql);
71 67 if ($res === FALSE) { if ($res === FALSE) {
72 rg_sql_set_error("$sql: " . $db->lastErrorMsg());
68 rg_sql_set_error("$sql: " . @pg_last_error($db));
73 69 return FALSE; return FALSE;
74 70 } }
75 71
 
... ... function rg_sql_query($db, $sql)
81 77 */ */
82 78 function rg_sql_close($db) function rg_sql_close($db)
83 79 { {
84 $db->close();
80 pg_close($db);
85 81 } }
86 82
87 83 /* /*
 
... ... function rg_sql_close($db)
89 85 */ */
90 86 function rg_sql_free_result($res) function rg_sql_free_result($res)
91 87 { {
92 $res->finalize();
88 pg_free_result($res);
93 89 } }
94 90
95 91 /* /*
 
... ... function rg_sql_free_result($res)
97 93 */ */
98 94 function rg_sql_fetch_array($res) function rg_sql_fetch_array($res)
99 95 { {
100 return $res->fetchArray(SQLITE3_ASSOC);
96 return pg_fetch_assoc($res);
101 97 } }
102 98
103 99 function rg_sql_last_id($db) function rg_sql_last_id($db)
104 100 { {
105 return $db->lastInsertRowID();
101 $sql = "SELECT lastval() AS id";
102 $res = rg_sql_query($db, $sql);
103 if ($res === FALSE)
104 return FALSE;
105
106 $row = rg_sql_fetch_array($res);
107 rg_sql_free_result($res);
108 return $row['id'];
109 }
110
111 function rg_sql_num_rows($res)
112 {
113 return pg_num_rows($res);
106 114 } }
107 115
108 116 ?> ?>
File inc/db/struct.inc.php changed (mode: 100644) (index dc1d75a..2f2d9c8)
... ... $rg_db_struct = array();
5 5
6 6 $rg_db_struct[0] = array( $rg_db_struct[0] = array(
7 7 "repos" => "CREATE TABLE repos" "repos" => "CREATE TABLE repos"
8 . " (repo_id INTEGER PRIMARY KEY"
8 . " (repo_id SERIAL PRIMARY KEY"
9 9 . ", name TEXT" . ", name TEXT"
10 10 . ", uid INTEGER" . ", uid INTEGER"
11 11 . ", itime INTEGER" . ", itime INTEGER"
12 12 . ", disk_quota_mb INTEGER" . ", disk_quota_mb INTEGER"
13 13 . ", max_commit_size INTEGER" . ", max_commit_size INTEGER"
14 14 . ", master INTEGER" . ", master INTEGER"
15 . ", desc TEXT"
15 . ", description TEXT"
16 16 . ", git_dir_done INTEGER" . ", git_dir_done INTEGER"
17 17 . ", default_rights TEXT" . ", default_rights TEXT"
18 18 . ", deleted INTEGER" . ", deleted INTEGER"
 
... ... $rg_db_struct[0] = array(
28 28 . " (var TEXT PRIMARY KEY" . " (var TEXT PRIMARY KEY"
29 29 . ", value TEXT)", . ", value TEXT)",
30 30 "keys" => "CREATE TABLE keys" "keys" => "CREATE TABLE keys"
31 . " (key_id INTEGER PRIMARY KEY"
31 . " (key_id SERIAL PRIMARY KEY"
32 32 . ", itime INTEGER" . ", itime INTEGER"
33 33 . ", uid INTEGER" . ", uid INTEGER"
34 34 . ", key TEXT)", . ", key TEXT)",
35 35 "users" => "CREATE TABLE users" "users" => "CREATE TABLE users"
36 . " (uid INTEGER PRIMARY KEY"
37 . ", user TEXT"
36 . " (uid SERIAL PRIMARY KEY"
37 . ", username TEXT"
38 38 . ", salt TEXT" . ", salt TEXT"
39 39 . ", pass TEXT" . ", pass TEXT"
40 40 . ", email TEXT" . ", email TEXT"
 
... ... $rg_db_struct[0] = array(
66 66 /* /*
67 67 * Generate structure * Generate structure
68 68 */ */
69 function rg_db_struct_run($db, $ignore_errors)
69 function rg_db_struct_run($db, $ignore_errors, $drop_tables)
70 70 { {
71 71 global $rg_db_struct; global $rg_db_struct;
72 72
73 73 foreach ($rg_db_struct as $index => $sqls) { foreach ($rg_db_struct as $index => $sqls) {
74 74 foreach ($sqls as $table => $sql) { foreach ($sqls as $table => $sql) {
75 //echo "[$table] Running [$sql]...\n";
75 echo "Drop & create table [$table]...\n";
76
77 $sql2 = "DROP TABLE IF EXISTS $table";
78 $res = rg_sql_query($db, $sql2);
79 rg_sql_free_result($res);
80
76 81 $res = rg_sql_query($db, $sql); $res = rg_sql_query($db, $sql);
77 82 if ($res === FALSE) { if ($res === FALSE) {
78 echo "WARN: Cannot create '$table' table ($sql)!\n";
83 echo "WARN: Cannot create '$table' table ($sql) (" . rg_sql_error() . ")!\n";
79 84 if (!$ignore_errors) if (!$ignore_errors)
80 85 return FALSE; return FALSE;
81 86 } }
87 rg_sql_free_result($res);
82 88 } }
83 89 } }
84 90
File inc/db_sqlite.inc.php copied from file inc/db.inc.php (similarity 100%)
File inc/keys.inc.php changed (mode: 100644) (index b75c3af..0c13e62)
... ... function rg_keys_remove($db, $rg_ui, $key_id)
63 63 { {
64 64 // mark dirty // mark dirty
65 65 if (rg_state_set($db, "authorized_keys", 1) === FALSE) { if (rg_state_set($db, "authorized_keys", 1) === FALSE) {
66 rg_keys_set_error("Cannot make state dirty!");
66 rg_keys_set_error("Cannot make state dirty (" . rg_state_error() . ")!");
67 67 return FALSE; return FALSE;
68 68 } }
69 69
 
... ... function rg_keys_add($db, $rg_ui, $key)
97 97
98 98 // set dirty // set dirty
99 99 if (rg_state_set($db, "authorized_keys", 1) === FALSE) { if (rg_state_set($db, "authorized_keys", 1) === FALSE) {
100 rg_keys_set_error("Cannot make state dirty!");
100 rg_keys_set_error("cannot make state dirty: " . rg_state_error());
101 101 return FALSE; return FALSE;
102 102 } }
103 103
 
... ... function rg_keys_regen($db)
123 123 global $rg_ssh_paras; global $rg_ssh_paras;
124 124
125 125 $dirty = rg_state_get($db, "authorized_keys"); $dirty = rg_state_get($db, "authorized_keys");
126 if ($dirty == 0) {
126 if ($dirty === 0) {
127 127 rg_log("Skip generation because is not dirty!"); rg_log("Skip generation because is not dirty!");
128 128 return TRUE; return TRUE;
129 129 } }
 
... ... function rg_keys_regen($db)
131 131 $tmp = $rg_keys_file . ".tmp"; $tmp = $rg_keys_file . ".tmp";
132 132 $f = @fopen($tmp, "w"); $f = @fopen($tmp, "w");
133 133 if ($f === FALSE) { if ($f === FALSE) {
134 rg_keys_set_error("Cannot open file $tmp ($php_errormsg)!");
134 rg_keys_set_error("cannot open file $tmp ($php_errormsg)");
135 135 return FALSE; return FALSE;
136 136 } }
137 137
138 138 if (chmod($tmp, 0600) === FALSE) { if (chmod($tmp, 0600) === FALSE) {
139 rg_keys_set_error("Cannot chmod tmp file ($php_errmsg)!");
139 rg_keys_set_error("cannot chmod tmp file ($php_errmsg)");
140 fclose($f);
140 141 return FALSE; return FALSE;
141 142 } }
142 143
143 144 $sql = "SELECT uid, key FROM keys"; $sql = "SELECT uid, key FROM keys";
144 145 $res = rg_sql_query($db, $sql); $res = rg_sql_query($db, $sql);
145 146 if ($res === FALSE) { if ($res === FALSE) {
146 rg_keys_set_error("Cannot query (" . rg_sql_error() . ")");
147 rg_keys_set_error("cannot query (" . rg_sql_error() . ")");
147 148 return FALSE; return FALSE;
148 149 } }
149 150 while (($row = rg_sql_fetch_array($res))) { while (($row = rg_sql_fetch_array($res))) {
 
... ... function rg_keys_regen($db)
153 154 . "," . $rg_ssh_paras . "," . $rg_ssh_paras
154 155 . " " . $row['key'] . "\n"; . " " . $row['key'] . "\n";
155 156 if (@fwrite($f, $buf) === FALSE) { if (@fwrite($f, $buf) === FALSE) {
156 rg_keys_set_error("Cannot write. Disk space problems? ($php_errormsg)");
157 rg_keys_set_error("cannot write. Disk space problems? ($php_errormsg)");
157 158 fclose($f); fclose($f);
158 159 unlink($tmp); unlink($tmp);
159 160 rg_sql_free_result($res); rg_sql_free_result($res);
 
... ... function rg_keys_regen($db)
165 166 fclose($f); fclose($f);
166 167
167 168 if (@rename($tmp, $rg_keys_file) === FALSE) { if (@rename($tmp, $rg_keys_file) === FALSE) {
168 rg_keys_set_error("Cannot rename $tmp to $rg_keys_file ($php_errormsg)!");
169 rg_keys_set_error("cannot rename $tmp to $rg_keys_file ($php_errormsg)");
169 170 unlink($tmp); unlink($tmp);
170 171 return FALSE; return FALSE;
171 172 } }
File inc/personal/personal.php changed (mode: 100644) (index 5a80ef1..3bb262f)
... ... case 1: // edit info
43 43 } else { } else {
44 44 // TODO: Check if user has the right to edit this info! // TODO: Check if user has the right to edit this info!
45 45
46 $xuser = $rg_ui['user'];
46 $xuser = $rg_ui['username'];
47 47 $email = $rg_ui['email']; $email = $rg_ui['email'];
48 48 $xpass = ""; $xpass = "";
49 49 $session_time = $rg_ui['session_time']; $session_time = $rg_ui['session_time'];
File inc/repo.inc.php changed (mode: 100644) (index e07ec4c..6af30b2)
... ... function rg_repo_create($db, $master, $rg_ui, $name, $max_commit_size, $desc,
204 204 $itime = time(); $itime = time();
205 205
206 206 $sql = "INSERT INTO repos (uid, master, name, itime" $sql = "INSERT INTO repos (uid, master, name, itime"
207 . ", max_commit_size, desc, git_dir_done, default_rights"
207 . ", max_commit_size, description, git_dir_done, default_rights"
208 208 . ", max_users)" . ", max_users)"
209 209 . " VALUES (" . $rg_ui['uid'] . ", $master, '$e_name', $itime" . " VALUES (" . $rg_ui['uid'] . ", $master, '$e_name', $itime"
210 210 . ", $max_commit_size, '$e_desc', 0, '$rights', $max_users)"; . ", $max_commit_size, '$e_desc', 0, '$rights', $max_users)";
 
... ... function rg_repo_update($db, &$new)
281 281
282 282 $sql = "UPDATE repos SET name = '$e_name'" $sql = "UPDATE repos SET name = '$e_name'"
283 283 . ", max_commit_size = " . $new['max_commit_size'] . ", max_commit_size = " . $new['max_commit_size']
284 . ", desc = '$e_desc'"
284 . ", description = '$e_desc'"
285 285 . ", default_rights = '" . $new['default_rights'] . "'" . ", default_rights = '" . $new['default_rights'] . "'"
286 286 . ", max_users = " . $new['max_users'] . ", max_users = " . $new['max_users']
287 287 . " WHERE repo_id = " . $new['repo_id']; . " WHERE repo_id = " . $new['repo_id'];
 
... ... function rg_repo_list_query($db, $url, $sql)
335 335 if ($_ui['exists'] != 1) if ($_ui['exists'] != 1)
336 336 $v = "?" . $row['uid'] . "?"; $v = "?" . $row['uid'] . "?";
337 337 else else
338 $v = $_ui['user'];
338 $v = $_ui['username'];
339 339 $ret .= " <td>$v</td>\n"; $ret .= " <td>$v</td>\n";
340 340 } }
341 $ret .= " <td><small>" . nl2br($row['desc']) . "</small></td>\n";
341 $ret .= " <td><small>" . nl2br($row['description']) . "</small></td>\n";
342 342 if ($row['master'] > 0) { if ($row['master'] > 0) {
343 343 $master_repo = "?"; $master_repo = "?";
344 344 $_mi = rg_repo_info($db, $row['master'], ""); $_mi = rg_repo_info($db, $row['master'], "");
File inc/repo/repo_page.php changed (mode: 100644) (index d0ea909..9f286dd)
... ... case 3: // delete
153 153 $_rt = ""; $_rt = "";
154 154 if ($show_repo_info == 1) { if ($show_repo_info == 1) {
155 155 $_rt = "Repo <b>" . $ri['name'] . "</b><br />\n"; $_rt = "Repo <b>" . $ri['name'] . "</b><br />\n";
156 if (!empty($ri['desc']))
157 $_rt .= "<small>" . $ri['desc'] . "</small><br />\n";
156 if (!empty($ri['description']))
157 $_rt .= "<small>" . $ri['description'] . "</small><br />\n";
158 158 $_rt .= "<br />\n"; $_rt .= "<br />\n";
159 159 $_dr = rg_rights_text("repo", $ri['default_rights']); $_dr = rg_rights_text("repo", $ri['default_rights']);
160 160 $_rt .= "Default rights: " . implode(", ", $_dr) . "<br />\n"; $_rt .= "Default rights: " . implode(", ", $_dr) . "<br />\n";
File inc/rights.inc.php changed (mode: 100644) (index 78f39b7..3d8c054)
... ... function rg_rights_list($db, $type, $obj_id, $url)
248 248 $_u = $row['uid']; $_u = $row['uid'];
249 249 $_ui = rg_user_info($db, $row['uid'], "", ""); $_ui = rg_user_info($db, $row['uid'], "", "");
250 250 if ($_ui['exists'] == 1) if ($_ui['exists'] == 1)
251 $_u = $_ui['user'];
251 $_u = $_ui['username'];
252 252
253 253 $ret .= " <td>" . $_u . "</td>\n"; $ret .= " <td>" . $_u . "</td>\n";
254 254
File inc/state.inc.php changed (mode: 100644) (index ec90371..b629f96)
1 1 <?php <?php
2 2 require_once($INC . "/db.inc.php"); require_once($INC . "/db.inc.php");
3 3
4 function rg_state_set_error($str)
5 {
6 global $rg_state_error;
7
8 rg_log("\tError: $str");
9 $rg_state_error = $str;
10 }
11
12 function rg_state_error()
13 {
14 global $rg_state_error;
15 return $rg_state_error;
16 }
17
4 18 /* /*
5 19 * Get state * Get state
6 20 */ */
 
... ... function rg_state_get($db, $var)
10 24
11 25 $sql = "SELECT value FROM state WHERE var = '$e_var'"; $sql = "SELECT value FROM state WHERE var = '$e_var'";
12 26 $res = rg_sql_query($db, $sql); $res = rg_sql_query($db, $sql);
13 if ($res === FALSE)
14 return FALSE;
15
16 $row = rg_sql_fetch_array($res);
17 if (!isset($row['value']))
27 if ($res === FALSE) {
28 rg_state_set_error("state: " . rg_sql_error());
18 29 return FALSE; return FALSE;
30 }
19 31
32 $rows = rg_sql_num_rows($res);
33 if ($rows == 0) {
34 $ret = "";
35 } else {
36 $row = rg_sql_fetch_array($res);
37 $ret = $row['value'];
38 }
20 39 rg_sql_free_result($res); rg_sql_free_result($res);
21 40
22 return $row['value'];
41 return $ret;
23 42 } }
24 43
25 44 /* /*
 
... ... function rg_state_set($db, $var, $value)
30 49 $e_var = rg_sql_escape($db, $var); $e_var = rg_sql_escape($db, $var);
31 50 $e_value = rg_sql_escape($db, $value); $e_value = rg_sql_escape($db, $value);
32 51
33 if (rg_state_get($db, $var) === FALSE) {
52 if (rg_state_get($db, $var) === "") {
34 53 $sql = "INSERT INTO state (var, value)" $sql = "INSERT INTO state (var, value)"
35 54 . " VALUES('$e_var', '$e_value')"; . " VALUES('$e_var', '$e_value')";
36 55 } else { } else {
 
... ... function rg_state_set($db, $var, $value)
38 57 . " WHERE var = '$e_var'"; . " WHERE var = '$e_var'";
39 58 } }
40 59 $res = rg_sql_query($db, $sql); $res = rg_sql_query($db, $sql);
41 if ($res === FALSE)
60 if ($res === FALSE) {
61 rg_state_set_error("state: " . rg_sql_error());
42 62 return FALSE; return FALSE;
63 }
43 64 rg_sql_free_result($res); rg_sql_free_result($res);
44 65
45 66 return TRUE; return TRUE;
46 67 } }
47 ?>
68 ?>
File inc/user.inc.php changed (mode: 100644) (index ae4a415..63568c8)
... ... require_once($INC . "/sess.inc.php");
6 6 require_once($INC . "/rights.inc.php"); require_once($INC . "/rights.inc.php");
7 7
8 8 $rg_user_rights = array( $rg_user_rights = array(
9 "C" => "Create repository",
9 "C" => "Create repositories",
10 10 "U" => "Add users" "U" => "Add users"
11 11 ); );
12 12
 
... ... function rg_user_pass_ok($pass)
55 55 function rg_user_ok($user) function rg_user_ok($user)
56 56 { {
57 57 global $rg_user_allow; global $rg_user_allow;
58 global $rg_user_min_len;
58 59 global $rg_user_max_len; global $rg_user_max_len;
59 60
60 61 if (rg_chars_allow($user, $rg_user_allow) !== TRUE) { if (rg_chars_allow($user, $rg_user_allow) !== TRUE) {
61 rg_user_set_error("Invalid user name (invalid chars [$user] [$rg_user_allow])");
62 rg_user_set_error("invalid user name (invalid chars [$user] [$rg_user_allow])");
63 return FALSE;
64 }
65
66 if (strlen($user) < $rg_user_min_len) {
67 rg_user_set_error("User name too short (shorter than $rg_user_min_len)");
62 68 return FALSE; return FALSE;
63 69 } }
64 70
65 71 if (strlen($user) > $rg_user_max_len) { if (strlen($user) > $rg_user_max_len) {
66 rg_user_set_error("User name too long");
72 rg_user_set_error("user name too long (longer than $rg_user_max_len)");
67 73 return FALSE; return FALSE;
68 74 } }
69 75
 
... ... function rg_user_edit($db, $uid, $user, $email, $pass, $is_admin,
98 104 return FALSE; return FALSE;
99 105
100 106 $now = time(); $now = time();
101 $sql = "INSERT INTO users (user, salt, pass, email, itime"
107 $sql = "INSERT INTO users (username, salt, pass, email, itime"
102 108 . ", is_admin, disk_quota_mb, rights, session_time)" . ", is_admin, disk_quota_mb, rights, session_time)"
103 109 . " VALUES ('$e_user', '$e_salt', '$e_pass'" . " VALUES ('$e_user', '$e_salt', '$e_pass'"
104 110 . ", '$e_email', $now, $is_admin, $disk_quota_mb" . ", '$e_email', $now, $is_admin, $disk_quota_mb"
 
... ... function rg_user_edit($db, $uid, $user, $email, $pass, $is_admin,
108 114 if (!empty($pass)) if (!empty($pass))
109 115 $salt_pass_add = ", pass = '$e_pass', salt = '$e_salt'"; $salt_pass_add = ", pass = '$e_pass', salt = '$e_salt'";
110 116
111 $sql = "UPDATE users SET user = '$e_user'"
117 $sql = "UPDATE users SET username = '$e_user'"
112 118 . $salt_pass_add . $salt_pass_add
113 119 . ", email = '$e_email'" . ", email = '$e_email'"
114 120 . ", is_admin = $is_admin" . ", is_admin = $is_admin"
 
... ... function rg_user_info($db, $uid, $user, $email)
166 172 return FALSE; return FALSE;
167 173
168 174 $e_user = rg_sql_escape($db, $user); $e_user = rg_sql_escape($db, $user);
169 $add = " AND user = '$e_user'";
175 $add = " AND username = '$e_user'";
170 176 } else if (!empty($email)) { } else if (!empty($email)) {
171 177 $e_email = rg_sql_escape($db, $email); $e_email = rg_sql_escape($db, $email);
172 178 $add = " AND email = '$e_email'"; $add = " AND email = '$e_email'";
 
... ... function rg_user_info($db, $uid, $user, $email)
182 188 } }
183 189
184 190 $ret['ok'] = 1; $ret['ok'] = 1;
185 $row = rg_sql_fetch_array($res);
191 $rows = rg_sql_num_rows($res);
192 if ($rows > 0)
193 $row = rg_sql_fetch_array($res);
186 194 rg_sql_free_result($res); rg_sql_free_result($res);
187 if (!isset($row['user'])) {
188 rg_user_set_error("User not found!");
195 if ($rows == 0) {
196 rg_user_set_error("user not found");
189 197 return $ret; return $ret;
190 198 } }
191 199
 
... ... function rg_user_list($db, $url)
391 399 $ret .= "<font color=red>Cannot remove!</font><br />"; $ret .= "<font color=red>Cannot remove!</font><br />";
392 400 } }
393 401
394 $sql = "SELECT * FROM users ORDER BY user";
402 $sql = "SELECT * FROM users ORDER BY username";
395 403 $res = rg_sql_query($db, $sql); $res = rg_sql_query($db, $sql);
396 404 if ($res === FALSE) { if ($res === FALSE) {
397 405 rg_user_set_error("Cannot get info (" . rg_sql_error() . ")!"); rg_user_set_error("Cannot get info (" . rg_sql_error() . ")!");
 
... ... function rg_user_list($db, $url)
413 421 $ret .= "</tr>\n"; $ret .= "</tr>\n";
414 422 while (($row = rg_sql_fetch_array($res))) { while (($row = rg_sql_fetch_array($res))) {
415 423 $ret .= "<tr>\n"; $ret .= "<tr>\n";
416 $ret .= " <td>" . $row['user'] . "</td>\n";
424 $ret .= " <td>" . $row['username'] . "</td>\n";
417 425 $ret .= " <td>" . $row['email'] . "</td>\n"; $ret .= " <td>" . $row['email'] . "</td>\n";
418 426 $ret .= " <td>" . ($row['is_admin'] == 1 ? "Yes" : "No") . "</td>\n"; $ret .= " <td>" . ($row['is_admin'] == 1 ? "Yes" : "No") . "</td>\n";
419 427 $ret .= " <td>" . gmdate("Y-m-d H:i:s", $row['itime']) . "</td>\n"; $ret .= " <td>" . gmdate("Y-m-d H:i:s", $row['itime']) . "</td>\n";
 
... ... function rg_user_forgot_pass_uid($db, $token)
488 496
489 497 $ret['ok'] = 1; $ret['ok'] = 1;
490 498
491 $row = rg_sql_fetch_array($res);
499 $rows = rg_sql_num_rows($res);
500 if ($rows > 0)
501 $row = rg_sql_fetch_array($res);
492 502 rg_sql_free_result($res); rg_sql_free_result($res);
493 if (!isset($row['uid']))
503 if ($rows == 0)
494 504 return $ret; return $ret;
495 505
496 506 $ret['uid'] = $row['uid']; $ret['uid'] = $row['uid'];
File inc/util.inc.php changed (mode: 100644) (index 86962e8..6b1a456)
... ... function rg_chars_allow($name, $allowed_regexp)
132 132
133 133 return TRUE; return TRUE;
134 134 } }
135
136 /*
137 * Deletes a folder and the files inside it
138 */
139 function rg_rmdir($dir)
140 {
141 $scan = glob($dir);
142 foreach ($scan as $junk => $path)
143 @unlink($path);
144 @rmdir($dir);
145 }
146
135 147 ?> ?>
File rocketgit.spec.in changed (mode: 100644) (index 32980fa..d78fb9d)
... ... Source: http://kernel.embedromix.ro/us/rocketgit/%{name}-%{version}.tar.gz
8 8 URL: http://kernel.embedromix.ro/us/ URL: http://kernel.embedromix.ro/us/
9 9 BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot
10 10 BuildArch: noarch BuildArch: noarch
11 Requires: httpd, php-process, php-cli, xinetd, shadow-utils
11 Requires: httpd, php-process, php-cli, php-pgsql, xinetd, shadow-utils
12 12
13 13
14 14 %description %description
 
... ... Light and fast Git hosting solution, similar with Gitorious/GitHub/etc.
16 16
17 17 %pre %pre
18 18 getent group rocketgit || groupadd -r rocketgit getent group rocketgit || groupadd -r rocketgit
19 getent passwd rocketgit || useradd -r -g rocketgit -s /sbin/nologin -d /home/rocketgit -c "RocketGit user" rocketgit
19 getent passwd rocketgit || useradd -r -g rocketgit -s /sbin/nologin -m -d /home/rocketgit -c "RocketGit user" rocketgit
20
21 %post
22 if [ $1 -ne 0 ]; then
23 /sbin/service xinetd reload &>/dev/null || :
24 fi
25
26 %postun
27 if [ $1 = 0 ]; then
28 userdel rocketgit
29 fi
20 30
21 31 %prep %prep
22 32 %setup %setup
 
... ... rm -rf ${RPM_BUILD_ROOT}
38 48 @USR_SHARE@/@PRJ@ @USR_SHARE@/@PRJ@
39 49 %doc README LICENSE Changelog TODO %doc README LICENSE Changelog TODO
40 50 %dir /etc/@PRJ@ %dir /etc/@PRJ@
41 %config /etc/@PRJ@/config.php
42 %config /etc/@PRJ@/config.php.sample
51 %config(noreplace) /etc/@PRJ@/config.php
52 /etc/@PRJ@/config.php.sample
43 53 %config /etc/cron.d/rocketgit %config /etc/cron.d/rocketgit
44 %config /etc/xinetd.d/rocketgit
45 %config /etc/httpd/conf.d/rocketgit.conf
46
54 %config(noreplace) /etc/xinetd.d/rocketgit
55 %config(noreplace) /etc/httpd/conf.d/rocketgit.conf
56 %attr(0700,rocketgit,rocketgit) %dir /var/run/@PRJ@
57 %attr(0700,rocketgit,rocketgit) %dir /var/log/@PRJ@
47 58
48 59 %changelog %changelog
49 60 * Mon Jun 27 2011 Catalin(ux) M. BOIE <catab at embedromix dot ro> 0.2 * Mon Jun 27 2011 Catalin(ux) M. BOIE <catab at embedromix dot ro> 0.2
File root/index.php changed (mode: 100644) (index 391b97e..e91a2da)
... ... $ROOT = dirname(__FILE__);
9 9
10 10 $THEME = $ROOT . "/themes/default"; $THEME = $ROOT . "/themes/default";
11 11
12 require_once("/etc/rg/config.php");
12 require_once("/etc/rocketgit/config.php");
13 13 require_once($INC . "/log.inc.php"); require_once($INC . "/log.inc.php");
14 14 include_once($INC . "/db.inc.php"); include_once($INC . "/db.inc.php");
15 15 include_once($INC . "/user.inc.php"); include_once($INC . "/user.inc.php");
 
... ... foreach ($amenu as $_op => $_info) {
92 92 $add = "&nbsp;"; $add = "&nbsp;";
93 93 } }
94 94
95 if (isset($rg_ui['user']))
96 $menu .= "&nbsp;&nbsp;&nbsp;[" . $rg_ui['user'] . "]\n";
95 if (isset($rg_ui['username']))
96 $menu .= "&nbsp;&nbsp;&nbsp;[" . $rg_ui['username'] . "]\n";
97 97 $menu .= "<br />\n"; $menu .= "<br />\n";
98 98
99 99
File samples/config.php changed (mode: 100644) (index 46ff1e7..a7548de)
... ... $rg_base = "/home/rocketgit";
6 6 $rg_base_repo = $rg_base . "/repositories"; $rg_base_repo = $rg_base . "/repositories";
7 7
8 8 // Database // Database
9 $rg_db = "sqlite:/home/rocketgit/rg.sqlite";
9 $rg_db = "user=rocketgit dbname=rocketgit";
10 10 $rg_db_debug = 1; $rg_db_debug = 1;
11 11
12 12 // Session // Session
 
... ... $rg_repo_max_len = 64;
28 28 $rg_user_allow = '/^[A-Za-z0-9_.-]*$/'; $rg_user_allow = '/^[A-Za-z0-9_.-]*$/';
29 29
30 30 // Allowed user name length // Allowed user name length
31 $rg_user_min_len = 3;
31 32 $rg_user_max_len = 32; $rg_user_max_len = 32;
32 33
33 34 // SSH parameters for authorized_keys // SSH parameters for authorized_keys
File scripts/cron.php changed (mode: 100644) (index 4931eae..1af7ead)
... ... ini_set("track_errors", "On");
5 5
6 6 $now = time(); $now = time();
7 7
8 require_once("/etc/rg/config.php");
8 require_once("/etc/rocketgit/config.php");
9 9
10 10 $INC = dirname(__FILE__) . "/../inc"; $INC = dirname(__FILE__) . "/../inc";
11 11 require_once($INC . "/log.inc.php"); require_once($INC . "/log.inc.php");
 
... ... require_once($INC . "/keys.inc.php");
16 16 rg_log_set_file("/tmp/rg_cron.log"); rg_log_set_file("/tmp/rg_cron.log");
17 17
18 18 // locking // locking
19 $lock = "/var/run/rg/cron.lock";
19 $lock = "/var/run/rocketgit/cron.lock";
20 20 rg_lock_or_exit($lock); rg_lock_or_exit($lock);
21 21
22 22 $rg_sql_debug = $rg_db_debug; $rg_sql_debug = $rg_db_debug;
File scripts/q.php changed (mode: 100644) (index d636337..25336fb)
... ... ini_set("track_errors", "On");
7 7 $now = time(); $now = time();
8 8 $_s = microtime(TRUE); $_s = microtime(TRUE);
9 9
10 require_once("/etc/rg/config.php");
10 require_once("/etc/rocketgit/config.php");
11 11
12 12 $INC = dirname(__FILE__) . "/../inc"; $INC = dirname(__FILE__) . "/../inc";
13 13 require_once($INC . "/log.inc.php"); require_once($INC . "/log.inc.php");
 
... ... require_once($INC . "/repo.inc.php");
17 17 rg_log_set_file("/tmp/rg_q.log"); rg_log_set_file("/tmp/rg_q.log");
18 18
19 19 // locking // locking
20 $lock = "/var/run/rg/q.lock";
20 $lock = "/var/run/rocketgit/q.lock";
21 21 rg_lock_or_exit($lock); rg_lock_or_exit($lock);
22 22
23 23 $rg_sql_debug = $rg_db_debug; $rg_sql_debug = $rg_db_debug;
 
... ... while ($runs-- > 0) {
83 83 } }
84 84
85 85 rg_log("Make hooks links..."); rg_log("Make hooks links...");
86 symlink("/BIG1T/sync1/Dev/rg/scripts/hooks_update", $dst . "/hooks/upate");
86 $_dir = @readlink($dst . "/hooks");
87 if (strcmp($_dir, $rg_scripts . "/hooks") != 0) {
88 rg_log("\thooks is not a link to scripts one, make it...");
89 @rg_rmdir($dst . "/hooks");
90 symlink($rg_scripts . "/hooks", $dst . "/");
91 }
87 92 } }
88 93 rg_sql_free_result($res); rg_sql_free_result($res);
89 94
File scripts/ssh.php changed (mode: 100644) (index 56c4f09..4ce8b50)
... ... ini_set("track_errors", "On");
5 5
6 6 $_start = microtime(TRUE); $_start = microtime(TRUE);
7 7
8 require_once("/etc/rg/config.php");
8 require_once("/etc/rocketgit/config.php");
9 9
10 10 $INC = dirname(__FILE__) . "/../inc"; $INC = dirname(__FILE__) . "/../inc";
11 11 require_once($INC . "/util.inc.php"); require_once($INC . "/util.inc.php");
File tests/db.php changed (mode: 100644) (index 6f060e6..c83320d)
... ... error_reporting(E_ALL | E_STRICT);
4 4 $INC = "../inc"; $INC = "../inc";
5 5 require_once($INC . "/db.inc.php"); require_once($INC . "/db.inc.php");
6 6
7 @unlink("test.sqlite");
8
9 $db = rg_sql_open("sqlite:test.sqlite");
7 echo "db: open connection...\n";
8 $db = rg_sql_open("dbname=trg");
10 9 if ($db === FALSE) { if ($db === FALSE) {
11 echo "Cannot create a database (" . rg_sql_error() . ")!";
10 echo "Cannot create a database (" . rg_sql_error() . ")!\n";
11 exit(1);
12 }
13
14 echo "db: drop 'test' table...\n";
15 $sql = "DROP TABLE IF EXISTS test";
16 $res = rg_sql_query($db, $sql);
17 if ($res === FALSE) {
18 echo "Cannot create table 'test' (" . rg_sql_error() . ")!\n";
12 19 exit(1); exit(1);
13 20 } }
14 21
15 // test creation
22 echo "db: test creation of a table...\n";
16 23 $sql = "CREATE TABLE test (id TEXT PRIMARY KEY)"; $sql = "CREATE TABLE test (id TEXT PRIMARY KEY)";
17 24 $res = rg_sql_query($db, $sql); $res = rg_sql_query($db, $sql);
18 25 if ($res === FALSE) { if ($res === FALSE) {
19 echo "Cannot create table!";
26 echo "Cannot create table 'test' (" . rg_sql_error() . ")!\n";
20 27 exit(1); exit(1);
21 28 } }
22 29
23 // test insert
30 echo "db: test insert...\n";
24 31 $sql = "INSERT INTO test (id) VALUES ('aaa')"; $sql = "INSERT INTO test (id) VALUES ('aaa')";
25 32 $res = rg_sql_query($db, $sql); $res = rg_sql_query($db, $sql);
26 33 if ($res === FALSE) { if ($res === FALSE) {
27 echo "Cannot insert!";
34 echo "Cannot insert!\n";
28 35 exit(1); exit(1);
29 36 } }
30 37
31 // test insert with the same key
38 echo "db: test insert with the same key...\n";
32 39 $sql = "INSERT INTO test (id) VALUES ('aaa')"; $sql = "INSERT INTO test (id) VALUES ('aaa')";
33 40 $res = @rg_sql_query($db, $sql); $res = @rg_sql_query($db, $sql);
34 41 if ($res !== FALSE) { if ($res !== FALSE) {
35 echo "I can do double insert!";
42 echo "I can do double insert!\n";
36 43 exit(1); exit(1);
37 44 } }
38 45
39 // test delete
46 echo "db: test delete...\n";
40 47 $sql = "DELETE FROM test WHERE id = 'aaa'"; $sql = "DELETE FROM test WHERE id = 'aaa'";
41 48 $res = rg_sql_query($db, $sql); $res = rg_sql_query($db, $sql);
42 49 if ($res === FALSE) { if ($res === FALSE) {
43 echo "Cannot delete!";
50 echo "Cannot delete!\n";
44 51 exit(1); exit(1);
45 52 } }
46 53
47 rg_sql_close($db);
54 // TODO: test rg_sql_last_id
48 55
49 @unlink("test.sqlite");
56 rg_sql_close($db);
50 57
51 echo "OK!\n";
58 echo "db: OK!\n";
52 59 ?> ?>
File tests/keys.php changed (mode: 100644) (index 204c664..ecdb581)
... ... require_once($INC . "/db/struct.inc.php");
7 7
8 8 rg_log_set_file("keys.log"); rg_log_set_file("keys.log");
9 9
10 @unlink("keys.sqlite");
10 $rg_db_debug = 1;
11 11
12 $db = rg_sql_open("sqlite:keys.sqlite");
12 $db = rg_sql_open("dbname=trg");
13 13 if ($db === FALSE) { if ($db === FALSE) {
14 echo "Cannot create a database (" . rg_sql_error() . ")!";
14 echo "Cannot create a database (" . rg_sql_error() . ")!\n";
15 15 exit(1); exit(1);
16 16 } }
17 17
18 18 // state table // state table
19 $r = rg_db_struct_run($db, FALSE);
19 $r = rg_db_struct_run($db, FALSE, 1);
20 20 if ($r === FALSE) { if ($r === FALSE) {
21 echo "Cannot create tables!";
21 echo "Cannot create structure!\n";
22 22 exit(1); exit(1);
23 23 } }
24 24
 
... ... $rg_ui = array("uid" => 1, "is_admin" => 0);
27 27 $key = "aaa 'bbb' first_key"; $key = "aaa 'bbb' first_key";
28 28 $key_id1 = rg_keys_add($db, $rg_ui, $key); $key_id1 = rg_keys_add($db, $rg_ui, $key);
29 29 if ($key_id1 === FALSE) { if ($key_id1 === FALSE) {
30 echo "Cannot add key (" . rg_keys_error() . ")!\n";
30 echo "Cannot add key 1 (" . rg_keys_error() . ")!\n";
31 31 exit(1); exit(1);
32 32 } }
33 33
 
... ... $rg_ui = array("uid" => 2, "is_admin" => 0);
36 36 $key = "aaa 'bbb' second_key"; $key = "aaa 'bbb' second_key";
37 37 $key_id2 = rg_keys_add($db, $rg_ui, $key); $key_id2 = rg_keys_add($db, $rg_ui, $key);
38 38 if ($key_id2 === FALSE) { if ($key_id2 === FALSE) {
39 echo "Cannot add key (" . rg_keys_error() . ")!\n";
39 echo "Cannot add key 2 (" . rg_keys_error() . ")!\n";
40 40 exit(1); exit(1);
41 41 } }
42 42
 
... ... $rg_keys_file = "afile.txt";
47 47 $rg_ssh_paras = "ssh1,ssh2,ssh3"; $rg_ssh_paras = "ssh1,ssh2,ssh3";
48 48 $r = rg_keys_regen($db); $r = rg_keys_regen($db);
49 49 if ($r === FALSE) { if ($r === FALSE) {
50 echo "Cannot regenerate keys (" . rg_keys_error() . ")!";
50 echo "Cannot regenerate keys (" . rg_keys_error() . ")!\n";
51 51 exit(1); exit(1);
52 52 } }
53 $c = file_get_contents("afile.txt");
53 $c = @file_get_contents("afile.txt");
54 54 if ($c === FALSE) { if ($c === FALSE) {
55 55 echo "Cannot regenerate file: " . rg_keys_error() . "!\n"; echo "Cannot regenerate file: " . rg_keys_error() . "!\n";
56 56 exit(1); exit(1);
 
... ... if (strcmp($c, $e) != 0) {
69 69 $rg_ui = array("uid" => 1, "is_admin" => 0); $rg_ui = array("uid" => 1, "is_admin" => 0);
70 70 $r = rg_keys_remove($db, $rg_ui, $key_id1); $r = rg_keys_remove($db, $rg_ui, $key_id1);
71 71 if ($r === FALSE) { if ($r === FALSE) {
72 echo "Cannot remove key (" . rg_keys_error() . ")!";
72 echo "Cannot remove key (" . rg_keys_error() . ")!\n";
73 73 exit(1); exit(1);
74 74 } }
75 75
76 76
77 77 rg_sql_close($db); rg_sql_close($db);
78 78
79 @unlink("keys.sqlite");
80
81 echo "OK\n";
79 echo "keys: OK\n";
82 80 ?> ?>
File tests/repo.php changed (mode: 100644) (index 3bc9499..11363db)
... ... if ($c !== FALSE) {
76 76 exit(1); exit(1);
77 77 } }
78 78
79
80 @unlink("repo.sqlite");
81
82 $db = rg_sql_open("sqlite:repo.sqlite");
79 $db = rg_sql_open("dbname=trg");
83 80 if ($db === FALSE) { if ($db === FALSE) {
84 81 echo "Cannot create a database (" . rg_sql_error() . ")!\n"; echo "Cannot create a database (" . rg_sql_error() . ")!\n";
85 82 exit(1); exit(1);
86 83 } }
87 84
88 $r = rg_db_struct_run($db, FALSE);
85 $r = rg_db_struct_run($db, FALSE, 1);
89 86 if ($r === FALSE) { if ($r === FALSE) {
90 87 echo "Cannot create struct!\n"; echo "Cannot create struct!\n";
91 88 exit(1); exit(1);
 
... ... if ($r === FALSE) {
93 90
94 91 $sql = "INSERT INTO repos (repo_id, name, uid, itime" $sql = "INSERT INTO repos (repo_id, name, uid, itime"
95 92 . ", disk_quota_mb, max_commit_size" . ", disk_quota_mb, max_commit_size"
96 . ", master, desc, git_dir_done, default_rights)"
93 . ", master, description, git_dir_done, default_rights)"
97 94 . " VALUES (1, 'repo1', 1, 0, 0, 0, 0, 'bla bla desc', 1, 'F')"; . " VALUES (1, 'repo1', 1, 0, 0, 0, 0, 'bla bla desc', 1, 'F')";
98 95 $res = rg_sql_query($db, $sql); $res = rg_sql_query($db, $sql);
99 96 if ($res === FALSE) { if ($res === FALSE) {
100 echo "Cannot insert a user!\n";
97 echo "Cannot insert a user (" . rg_sql_error() . ")!\n";
101 98 exit(1); exit(1);
102 99 } }
103 100
 
... ... if ($r === FALSE) {
151 148 exit(1); exit(1);
152 149 } }
153 150
154 @unlink("repo.sqlite");
151 rg_sql_close($db);
155 152
156 153 echo "OK\n"; echo "OK\n";
157 154 ?> ?>
File tests/rights.php changed (mode: 100644) (index ce5638e..8917b72)
... ... if (strcmp($r, $e) != 0) {
30 30 exit(1); exit(1);
31 31 } }
32 32
33 echo "OK\n";
33 echo "rights: OK\n";
34 34 ?> ?>
File tests/state.php changed (mode: 100644) (index e84f877..6a77217)
... ... require_once($INC . "/db/struct.inc.php");
9 9
10 10 rg_log_set_file("state.log"); rg_log_set_file("state.log");
11 11
12 @unlink("state.sqlite");
12 $rg_db_debug = 1;
13 13
14 $db = rg_sql_open("sqlite:state.sqlite");
14 $db = rg_sql_open("dbname=trg");
15 15 if ($db === FALSE) { if ($db === FALSE) {
16 echo "Cannot create a database (" . rg_sql_error() . ")!";
16 echo "Cannot create a database (" . rg_sql_error() . ")!\n";
17 17 exit(1); exit(1);
18 18 } }
19 19
20 20 // state table // state table
21 $r = rg_db_struct_run($db, FALSE);
21 $r = rg_db_struct_run($db, FALSE, 1);
22 22 if ($r === FALSE) { if ($r === FALSE) {
23 echo "Cannot create tables!";
23 echo "Cannot create structure!\n";
24 24 exit(1); exit(1);
25 25 } }
26 26
27 27 // check return for an invalid state // check return for an invalid state
28 28 $r = rg_state_get($db, "asdsdsdf"); $r = rg_state_get($db, "asdsdsdf");
29 if ($r !== FALSE) {
30 echo "Cannot get FALSE for an unknown key!\n";
29 if ($r !== "") {
30 echo "Cannot get '' (but '$r') for an unknown key!\n";
31 31 exit(1); exit(1);
32 32 } }
33 33
34 34 $r = rg_state_set($db, "a", "bau"); $r = rg_state_set($db, "a", "bau");
35 35 if ($r !== TRUE) { if ($r !== TRUE) {
36 echo "Cannot get a TRUE for setting a key1 ($r)!\n";
36 echo "Cannot get a TRUE for setting 'a' to 'bau' ($r)!\n";
37 37 exit(1); exit(1);
38 38 } }
39 39
40 40 $r = rg_state_set($db, "a", "cucu"); $r = rg_state_set($db, "a", "cucu");
41 41 if ($r !== TRUE) { if ($r !== TRUE) {
42 echo "Cannot get a TRUE for setting a key2 ($r)!\n";
42 echo "Cannot get a TRUE for setting 'a' to 'cucu' ($r)!\n";
43 43 exit(1); exit(1);
44 44 } }
45 45
46 46 $r = rg_state_get($db, "a"); $r = rg_state_get($db, "a");
47 47 if (strcmp($r, "cucu") != 0) { if (strcmp($r, "cucu") != 0) {
48 echo "Cannot get correct state ($r != cucu)!\n";
48 echo "Cannot get correct state ('$r' != 'cucu')!\n";
49 49 exit(1); exit(1);
50 50 } }
51 51
52 52 rg_sql_close($db); rg_sql_close($db);
53 53
54 @unlink("state.sqlite");
55
56 echo "OK\n";
54 echo "state: OK\n";
57 55 ?> ?>
File tests/user.php changed (mode: 100644) (index d7673c4..585cd32)
... ... $rg_pass_key = "aaa";
12 12 $rg_session_time = 3600; $rg_session_time = 3600;
13 13 $rg_user_allow = '/^[A-Za-z0-9_.-]*$/'; $rg_user_allow = '/^[A-Za-z0-9_.-]*$/';
14 14
15 @unlink("user.sqlite");
16 15
17 $db = rg_sql_open("sqlite:user.sqlite");
16 $db = rg_sql_open("dbname=trg");
18 17 if ($db === FALSE) { if ($db === FALSE) {
19 echo "Cannot create a database (" . rg_sql_error() . ")!";
18 echo "Cannot create a database (" . rg_sql_error() . ")!\n";
20 19 exit(1); exit(1);
21 20 } }
22 21
23 $r = rg_db_struct_run($db, FALSE);
22 $r = rg_db_struct_run($db, FALSE, 1);
24 23 if ($r === FALSE) { if ($r === FALSE) {
25 echo "Cannot create structure!";
24 echo "Cannot create structure!\n";
26 25 exit(1); exit(1);
27 26 } }
28 27
 
... ... if ($r['uid'] != $uid) {
115 114 exit(1); exit(1);
116 115 } }
117 116
118 @unlink("user.sqlite");
119
120 echo "OK\n";
117 echo "user: OK\n";
121 118 ?> ?>
File tests/util.php changed (mode: 100644) (index 070f43a..776327b)
... ... if (strlen($id) != 16) {
10 10 exit(1); exit(1);
11 11 } }
12 12
13 echo "OK\n";
13 echo "util: OK\n";
14 14 ?> ?>
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://rocketgit.com/user/catalinux/rocketgit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/catalinux/rocketgit

Clone this repository using git:
git clone git://git.rocketgit.com/user/catalinux/rocketgit

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