List of commits:
Subject Hash Author Date (UTC)
Lots of changes all over the place 3ddbd9e686f514eed1e715d7702a910ca3f8b22c Catalin(ux) M. BOIE 2020-04-01 07:17:57
More tests updates d5d45ace725f6ab336998a328136a2f7f9474df1 Catalin(ux) M. BOIE 2020-04-01 05:30:54
Lots of tests updates 183c4af52e56ae4e4fd74a35e2b17ac79952aec6 Catalin(ux) M. BOIE 2020-03-20 16:10:33
Improved a little bit the mail reporting for admin 576f96d554b1e273391ac54404bf5f885325e5e8 Catalin(ux) M. BOIE 2020-03-03 19:25:17
Worker and builder big changes 90f596e4fd8fa291b1da831bce609b486c7a5875 Catalin(ux) M. BOIE 2020-01-06 13:31:20
Samples update (switch to systemd services for builder and worker) 8bfde1fb79778d024350bf5d75f076fb5e178512 Catalin(ux) M. BOIE 2020-01-06 12:50:21
builder: show queue in the web page 6cab7820b0bd2622afb77391a9e9515e0e837eef Catalin(ux) M. BOIE 2020-01-06 12:49:26
totp: Allow also years for 'val' command d666df0cec948f938469b9eb12a1b981cb41cfa1 Catalin(ux) M. BOIE 2020-01-04 14:39:33
worker: change git clone parameters because we could not clone 8eb2727ac17e12e148f39c72e1f4bd1e31319b33 Catalin(ux) M. BOIE 2019-12-19 03:34:26
Added a TODO for worker 492fb4546829f53adacd74c4647c3634f7c37065 Catalin(ux) M. BOIE 2019-12-18 22:23:12
worker improvements 4387b00291b5848aa08c303f9d62a126a6806a35 Catalin(ux) M. BOIE 2019-12-18 22:17:23
.spec: require tidy for building the tests c0deab2ce24388c91d2bc2e96338a260c9657dd6 Catalin(ux) M. BOIE 2019-12-18 22:15:29
nginx configuration update 015c9404229f2ff7fb91cc57ab21289f01878334 Catalin(ux) M. BOIE 2019-12-18 21:55:13
Added Business model to comparison c62d466580aca0ff3371f3ba369959c7ef7631d0 Catalin(ux) M. BOIE 2019-11-21 20:44:16
CSS small correction ded9ef6bce5bebfa815bc7ae5733bc8e0810af3b Catalin(ux) M. BOIE 2019-11-21 18:20:41
Added LDAP/qrencode to features/thanks pages d269d59787f61045f5831c6985899c28da08ebeb Catalin(ux) M. BOIE 2019-11-21 18:20:22
Invalidate slave table cache when updating the db structure, else new slaves will not be created 8e1bf7feeb87818179e7152a356e0f408da706f2 Catalin(ux) M. BOIE 2019-11-19 19:33:15
docker: push also the latest label a72e2e74355d772ae45bb99798ad47082390943c Catalin(ux) M. BOIE 2019-11-19 19:32:11
More statistics changes (load, cpu, mem) e7f38e72405a227788a7011ea17dd57d0d4de67c Catalin(ux) M. BOIE 2019-11-19 19:31:24
Cosmetic 0a0b258e8993cb5035e018b049018ac41b99eb01 Catalin(ux) M. BOIE 2019-11-17 11:09:56
Commit 3ddbd9e686f514eed1e715d7702a910ca3f8b22c - Lots of changes all over the place
Author: Catalin(ux) M. BOIE
Author date (UTC): 2020-04-01 07:17
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2020-04-01 07:19
Parent(s): d5d45ace725f6ab336998a328136a2f7f9474df1
Signer:
Signing key:
Signing status: N
Tree: bdcd705b81b67ad5f41b7f2e9b232dccc0816a65
File Lines added Lines deleted
Makefile.in 1 0
TODO 54 12
hooks/post-receive 2 0
hooks/pre-commit 2 0
hooks/pre-receive 2 0
hooks/update 6 1
inc/admin.inc.php 22 24
inc/bug.inc.php 14 8
inc/builder.inc.php 3 6
inc/cache.inc.php 14 13
inc/conn.inc.php 1 3
inc/events.inc.php 3 5
inc/fixes.inc.php 7 13
inc/git.inc.php 183 119
inc/keys.inc.php 17 10
inc/ldap.inc.php 8 5
inc/log.inc.php 2 1
inc/mr.inc.php 6 4
inc/plan.inc.php 24 7
inc/prof.inc.php 1 1
inc/repo.inc.php 33 20
inc/sql.inc.php 1 1
inc/state.inc.php 3 0
inc/struct.inc.php 2 14
inc/totp.inc.php 26 9
inc/user.inc.php 114 66
inc/user/repo-page.php 4 4
inc/util.inc.php 269 46
inc/wh/cloud.inc.php 3 2
inc/wh/core.inc.php 3 4
inc/wh/http.inc.php 9 12
inc/workers.inc.php 3 3
root/index.php 19 16
root/themes/default/admin/ldap/list/nodata.html 1 1
root/themes/default/admin/plans/list/nodata.html 1 1
root/themes/default/builder/cmds/nodata.html 1 1
root/themes/default/builder/queue/nodata.html 1 1
root/themes/default/features.html 2 1
root/themes/default/main.css 26 5
root/themes/default/repo/commit.html 8 0
root/themes/default/repo/commits/footer.html 4 0
root/themes/default/repo/commits/header.html 4 0
root/themes/default/repo/commits/line.html 19 0
root/themes/default/repo/commits/nodata.html 0 0
root/themes/default/repo/err/diff.html 1 1
root/themes/default/repo/err/stats.html 1 1
root/themes/default/repo/log/footer.html 3 1
root/themes/default/repo/log/header.html 11 7
root/themes/default/repo/log/line.html 6 6
root/themes/default/repo/mr/page.html 2 2
samples/nginx.conf 2 2
scripts/cache.php 18 18
scripts/events.php 6 6
scripts/remote.php 2 1
scripts/worker.TODO 2 2
scripts/worker.php 1 1
selinux/build.sh 1 1
File Makefile.in changed (mode: 100644) (index e96e806..43acfdf)
... ... install: all
44 44 cp -vd --no-clobber samples/worker-main.conf.sample $(I_ETC)/$(PRJ)/ cp -vd --no-clobber samples/worker-main.conf.sample $(I_ETC)/$(PRJ)/
45 45 @mkdir -pv $(I_USR)/lib/systemd/system @mkdir -pv $(I_USR)/lib/systemd/system
46 46 cp -vd samples/*.service $(I_USR)/lib/systemd/system/ cp -vd samples/*.service $(I_USR)/lib/systemd/system/
47 systemctl daemon-reload
47 48 @ @
48 49 @echo "Installing tools..." @echo "Installing tools..."
49 50 @mkdir -pv $(I_USR_SBIN) @mkdir -pv $(I_USR_SBIN)
File TODO changed (mode: 100644) (index 1d838cd..ea8fe66)
1 1 == Where I stopped last time == == Where I stopped last time ==
2 [ ] Add command to build_jobs.status to be displayed nicely on web.
3 [ ] Replace serialize with rg_serialize and unserialize with rg_unserialize.
4 We need to also convert the database.
5 [ ] Use users.last_seen to detect an active user.
6 It is updated by a fetch by ssh, for example?
2
3 == Now ==
4 [ ] Functional test for 'rg_process_input'! No release without this!
5 We will need to fake some requests, even if no git data will be passed.
7 6 [ ] docker [ ] docker
8 [ ] rg_admin_email should be extracted from database[users][admin][email]/state.
9 [ ] docker: ssh and git clone URLs are using docker hostname which probably
10 is not working. Use some environment variables?
11 Or disable them if admin did not set the correct URL?
12 Or use the IP address?
13 Search for php_uname?
14 7 [ ] Resync nginx conf on rg2. [ ] Resync nginx conf on rg2.
15 [ ] worker: have a flag which allows intrnet access?
8 [ ] worker: have a flag which allows internet access?
16 9 Better to let the owner provide a template which may have or Better to let the owner provide a template which may have or
17 10 may have not Internet access. Think about private networks! Better may have not Internet access. Think about private networks! Better
18 11 with template. with template.
 
20 13 [ ] [ ]
21 14
22 15 == BEFORE NEXT RELEASE == == BEFORE NEXT RELEASE ==
16 [ ] docker: ssh and git clone URLs are using docker hostname which probably
17 is not working. Use some environment variables?
18 Or disable them if admin did not set the correct URL?
19 Or use the IP address?
20 Search for php_uname?
21 [ ] Seems I have to move some stuff from 'update' hook to 'post-receive'
22 because in 'update' we are not sure if update was really made.
23 Take care of anonymous push.
24 [ ] Use users.last_seen to detect an active user.
25 It is updated by a fetch by ssh, for example?
26 [ ] Add command to build_jobs.status to be displayed nicely on web.
27 [ ] Error handling for helpers called from rg_exec (is a mess).
28 [ ] rg_admin_email(s) should be extracted from database[users][admin][email]/state.
29 [ ] Investigate nginx 'gzip_vary on;'.
30 [ ] Logout token prohibits a 304 HTTP code! Bad!
31 Why the logout token is regenerated?! Probably because the cache daemon
32 is restarted!
33 [ ] user_login_by_user_pass_helper: when splitting login_token, verify to have
34 only digits, else, just abort.
35 [ ] Investigate --push-option for git-push: we may instruct the server to do
36 stuff.
37 [ ] Should I add the event string to table 'events'? Maybe we want to filter
38 by it in the future? Or make graphs?
39 [ ] stats: add a graph with the events queue (not processed yet events)?
40 [ ] In nginx we can set 'fastcgi_param WEB_ssl_session_id $ssl_session_id;'.
41 Can we use this for session identification?
42 https://nginx.org/en/docs/http/ngx_http_ssl_module.html
43 [ ] Check notes_body class if it really needs width: 100%!
44 [ ] rg_cache_get returns FALSE on error but also if the key is not found.
45 We should distinguish the two cases. Really?
46 [ ] Build a php file with all the templates, to be in RAM?
47 [ ] Report the number of user confirmations.
48 [ ] Captcha
49 [ ] If a repo has no activity (bugs, pushes, merge requests), do not show it
50 in the Discovery page.
51 [ ] "IanKelling" (LWN) complained about gravatar (send browsing info to
52 gravatar). Should we make this optional? Allow user to upload a picture?
53 [ ] Sometimes, we set the cache repo_path with empty string. We should not.
54 [ ] totp + git:// - functinal testing.
55 [ ] We need to suggest setting 'ssh.variant=ssh' if port is not standard.
56 [ ] nginx passes HTTP_USER_AGENT=git/2.24.1, use it for statistics.
57 [ ] Add sourcehut.org in comparison.
58 [ ] exec2: from time to time log the number of bytes sent/received?
59 [ ] Add posibility to mirror a rocketgit instance into another.
60 Maybe at user level? Something like: mirror all repos (including bug
61 reports etc.).
62 Some users may want to use a local instance, but mirror it in the
63 official rocketgit.com site, for backup purposes.
64 Should be mirror stuff back?
23 65 [ ] wh: are available for all users? Should we configure this? [ ] wh: are available for all users? Should we configure this?
24 66 Think about a user which has push rights but is not the owner of the project. Think about a user which has push rights but is not the owner of the project.
25 67 [ ] push/etc: show how what IPs are validated with TOTP? [ ] push/etc: show how what IPs are validated with TOTP?
File hooks/post-receive changed (mode: 100755) (index 9856d15..8f10969)
... ... ini_set("track_errors", "On");
16 16
17 17 $_start = microtime(TRUE); $_start = microtime(TRUE);
18 18
19 $rg_log_sid = getenv('ROCKETGIT_LOG_SID');
20
19 21 $conf = getenv("ROCKETGIT_CONF_FILE"); $conf = getenv("ROCKETGIT_CONF_FILE");
20 22 if (empty($conf)) if (empty($conf))
21 23 $conf = "/etc/rocketgit/config.php"; $conf = "/etc/rocketgit/config.php";
File hooks/pre-commit changed (mode: 100755) (index 5ab9d41..0293e0d)
... ... ini_set("track_errors", "On");
8 8
9 9 $_start = microtime(TRUE); $_start = microtime(TRUE);
10 10
11 $rg_log_sid = getenv('ROCKETGIT_LOG_SID');
12
11 13 $conf = getenv("ROCKETGIT_CONF_FILE"); $conf = getenv("ROCKETGIT_CONF_FILE");
12 14 if (empty($conf)) if (empty($conf))
13 15 $conf = "/etc/rocketgit/config.php"; $conf = "/etc/rocketgit/config.php";
File hooks/pre-receive changed (mode: 100755) (index 8f128b1..58e0dc5)
... ... ini_set("track_errors", "On");
11 11
12 12 $_start = microtime(TRUE); $_start = microtime(TRUE);
13 13
14 $rg_log_sid = getenv('ROCKETGIT_LOG_SID');
15
14 16 $conf = getenv("ROCKETGIT_CONF_FILE"); $conf = getenv("ROCKETGIT_CONF_FILE");
15 17 if (empty($conf)) if (empty($conf))
16 18 $conf = "/etc/rocketgit/config.php"; $conf = "/etc/rocketgit/config.php";
File hooks/update changed (mode: 100755) (index d138e39..67697ad)
... ... ini_set("track_errors", "On");
12 12
13 13 $_start = microtime(TRUE); $_start = microtime(TRUE);
14 14
15 $rg_log_sid = getenv('ROCKETGIT_LOG_SID');
16
15 17 $conf = getenv("ROCKETGIT_CONF_FILE"); $conf = getenv("ROCKETGIT_CONF_FILE");
16 18 if (empty($conf)) if (empty($conf))
17 19 $conf = "/etc/rocketgit/config.php"; $conf = "/etc/rocketgit/config.php";
 
... ... $a['repo_path'] = getenv("ROCKETGIT_REPO_PATH");
44 46 $a['repo_name'] = getenv("ROCKETGIT_REPO_NAME"); $a['repo_name'] = getenv("ROCKETGIT_REPO_NAME");
45 47 $a['repo_uid'] = sprintf("%u", getenv("ROCKETGIT_REPO_UID")); $a['repo_uid'] = sprintf("%u", getenv("ROCKETGIT_REPO_UID"));
46 48 $a['repo_clone_url_http'] = getenv('ROCKETGIT_REPO_CLONE_URL'); $a['repo_clone_url_http'] = getenv('ROCKETGIT_REPO_CLONE_URL');
49 $a['log_sid'] = $rg_log_sid;
47 50
48 51 rg_log("Start a=" . rg_array2string($a)); rg_log("Start a=" . rg_array2string($a));
49 52 rg_log("_SERVER: " . rg_array2string($_SERVER)); rg_log("_SERVER: " . rg_array2string($_SERVER));
 
... ... if (strncmp($a['refname'], "refs/tags/", 10) == 0) {
93 96 } else if (strncmp($a['refname'], "refs/remotes/", 13) == 0) { } else if (strncmp($a['refname'], "refs/remotes/", 13) == 0) {
94 97 rg_git_fatal("No action for remotes for now!"); rg_git_fatal("No action for remotes for now!");
95 98 } else { } else {
96 rg_git_fatal("Unknown refname type provided [" . $a['refname'] . "]");
99 $m = "Unknown refname type provided [" . $a['refname'] . "]";
100 rg_internal_error($m);
101 rg_git_fatal($m);
97 102 } }
98 103
99 104 rg_prof_end("hook-update"); rg_prof_end("hook-update");
File inc/admin.inc.php changed (mode: 100644) (index 76e750f..35df737)
... ... require_once($INC . "/workers.inc.php");
8 8 */ */
9 9 $rg_admin_functions = array( $rg_admin_functions = array(
10 10 6000 => "rg_admin_invite", 6000 => "rg_admin_invite",
11 6001 => "rg_admin_invite_one"
11 6001 => "rg_admin_invite_one",
12 // new new style
13 'admin_invite' => 'rg_admin_invite',
14 'admin_invite_one' => 'rg_admin_invite_one'
12 15 ); );
13 16 rg_event_register_functions($rg_admin_functions); rg_event_register_functions($rg_admin_functions);
14 17
 
... ... function rg_admin_invite($db, $event)
29 32
30 33 $ret[] = array_merge($event, $ret[] = array_merge($event,
31 34 array( array(
32 'category' => 6001,
35 'category' => 'admin_invite_one',
33 36 'prio' => 100, 'prio' => 100,
34 37 'email' => trim($t[0]), 'email' => trim($t[0]),
35 38 'name' => trim($t[1]) 'name' => trim($t[1])
 
... ... function rg_admin_invites_high_level($db, $rg)
159 162 break; break;
160 163
161 164 $event = array( $event = array(
162 'category' => 6000,
165 'category' => 'admin_invite',
163 166 'prio' => 50, 'prio' => 50,
164 167 'ui' => $rg['login_ui']); 'ui' => $rg['login_ui']);
165 168 $event = array_merge($event, $inv); $event = array_merge($event, $inv);
 
... ... function rg_admin_report1_suggestions($db, $from, $to)
308 311 rg_sql_free_result($res); rg_sql_free_result($res);
309 312 } }
310 313
311 $ret .= "\nTotal suggestions: " . $total;
314 $ret .= 'Total suggestions: ' . $total;
312 315 $ret .= "\nYesterday suggestions: " . $yesterday; $ret .= "\nYesterday suggestions: " . $yesterday;
313 316 $ret .= $yesterday_text; $ret .= $yesterday_text;
314 317
 
... ... function rg_admin_report1($db, $rg)
332 335 . " and " . gmdate('Y-m-d H:i:s', $y_end) . " UTC\n"; . " and " . gmdate('Y-m-d H:i:s', $y_end) . " UTC\n";
333 336 $body .= 'For site ' . $site . "\n"; $body .= 'For site ' . $site . "\n";
334 337
338 $g = array();
335 339 $list = array( $list = array(
336 340 'users' => 'users', 'users' => 'users',
337 341 'repos' => 'repositories', 'repos' => 'repositories',
 
... ... function rg_admin_report1($db, $rg)
351 355 $total_yesterday_changes = 0; $total_yesterday_changes = 0;
352 356 $body .= "\n" . 'Yesterday' . "\t" . 'Total' . "\t" . 'Category' . "\n"; $body .= "\n" . 'Yesterday' . "\t" . 'Total' . "\t" . 'Category' . "\n";
353 357 foreach ($list as $table => $text) { foreach ($list as $table => $text) {
358 $g[$table] = array();
359
354 360 // Yesterday // Yesterday
355 361 $sql = "SELECT COUNT(*) AS count FROM " . $table $sql = "SELECT COUNT(*) AS count FROM " . $table
356 362 . " WHERE itime >= $y_start" . " WHERE itime >= $y_start"
 
... ... function rg_admin_report1($db, $rg)
362 368 $row = rg_sql_fetch_array($res); $row = rg_sql_fetch_array($res);
363 369 $yesterday = $row['count']; $yesterday = $row['count'];
364 370 $total_yesterday_changes += $row['count']; $total_yesterday_changes += $row['count'];
371 $g[$table]['yesterday'] = $yesterday;
365 372 rg_sql_free_result($res); rg_sql_free_result($res);
366 373 } }
367 374
 
... ... function rg_admin_report1($db, $rg)
373 380 } else { } else {
374 381 $row = rg_sql_fetch_array($res); $row = rg_sql_fetch_array($res);
375 382 $total = $row['total']; $total = $row['total'];
383 $g[$table]['total'] = $total;
376 384 rg_sql_free_result($res); rg_sql_free_result($res);
377 385 } }
378 386
379 $body .= $yesterday . "\t" . $total . "\t" . $text . "\n";
387 $body .= $yesterday . "\t\t" . $total . "\t" . $text . "\n";
380 388 } }
381 389
382 390 $body .= "\nYesterday users:"; $body .= "\nYesterday users:";
 
... ... function rg_admin_report1($db, $rg)
423 431 $rg['ui']['email'] = $rg_admin_email; $rg['ui']['email'] = $rg_admin_email;
424 432 $rg['mail'] = array(); $rg['mail'] = array();
425 433 $rg['mail']['subject'] = 'RocketGit report' $rg['mail']['subject'] = 'RocketGit report'
426 . ' [' . $users . 'u]'
427 . ' [' . $repos . 'r]'
434 . ' [' . $g['users']['yesterday'] . 'u]'
435 . ' [' . $g['repos']['yesterday'] . 'r]'
428 436 . ' [' . $total_yesterday_changes . 'c]' . ' [' . $total_yesterday_changes . 'c]'
429 437 . ' (' . $site . ')'; . ' (' . $site . ')';
430 438 $rg['mail']['body'] = $body; $rg['mail']['body'] = $body;
 
... ... function rg_admin_settings_ssh($db, $rg)
619 627
620 628 // Load defaults // Load defaults
621 629 while (1) { while (1) {
622 $r = rg_state_get($db, 'max_ssh_keys');
630 $r = rg_state_get_uint($db, 'max_ssh_keys');
623 631 if ($r === FALSE) { if ($r === FALSE) {
624 632 $ret = rg_template('admin/settings/load_err.html', $ret = rg_template('admin/settings/load_err.html',
625 633 $rg, TRUE /*xss*/); $rg, TRUE /*xss*/);
626 634 break; break;
627 635 } }
628 if (empty($r))
629 $r = $rg_max_ssh_keys;
630 636 $rg['max_ssh_keys'] = $r; $rg['max_ssh_keys'] = $r;
631 637
632 $r = rg_state_get($db, 'ssh_key_min_bits_rsa');
638 $r = rg_state_get_uint($db, 'ssh_key_min_bits_rsa');
633 639 if ($r === FALSE) { if ($r === FALSE) {
634 640 $ret = rg_template('admin/settings/load_err.html', $ret = rg_template('admin/settings/load_err.html',
635 641 $rg, TRUE /*xss*/); $rg, TRUE /*xss*/);
636 642 break; break;
637 643 } }
638 if (empty($r))
639 $r = 2048;
640 644 $rg['ssh_key_min_bits_rsa'] = $r; $rg['ssh_key_min_bits_rsa'] = $r;
641 645
642 $r = rg_state_get($db, 'ssh_key_allow_dsa');
646 $r = rg_state_get_uint($db, 'ssh_key_allow_dsa');
643 647 if ($r === FALSE) { if ($r === FALSE) {
644 648 $ret = rg_template('admin/settings/load_err.html', $ret = rg_template('admin/settings/load_err.html',
645 649 $rg, TRUE /*xss*/); $rg, TRUE /*xss*/);
646 650 break; break;
647 651 } }
648 if (empty($r))
649 $r = 0;
650 652 $rg['ssh_key_allow_dsa'] = $r; $rg['ssh_key_allow_dsa'] = $r;
651 653
652 $r = rg_state_get($db, 'ssh_key_min_bits_ecdsa');
654 $r = rg_state_get_uint($db, 'ssh_key_min_bits_ecdsa');
653 655 if ($r === FALSE) { if ($r === FALSE) {
654 656 $ret = rg_template('admin/settings/load_err.html', $ret = rg_template('admin/settings/load_err.html',
655 657 $rg, TRUE /*xss*/); $rg, TRUE /*xss*/);
656 658 break; break;
657 659 } }
658 if (empty($r))
659 $r = 256;
660 660 $rg['ssh_key_min_bits_ecdsa'] = $r; $rg['ssh_key_min_bits_ecdsa'] = $r;
661 661
662 $r = rg_state_get($db, 'AuthorizedKeysCommand');
662 $r = rg_state_get_uint($db, 'AuthorizedKeysCommand');
663 663 if ($r === FALSE) { if ($r === FALSE) {
664 664 $ret = rg_template('admin/settings/load_err.html', $ret = rg_template('admin/settings/load_err.html',
665 665 $rg, TRUE /*xss*/); $rg, TRUE /*xss*/);
666 666 break; break;
667 667 } }
668 if (empty($r))
669 $r = 0;
670 668 $rg['AuthorizedKeysCommand'] = $r; $rg['AuthorizedKeysCommand'] = $r;
671 669
672 670 $hints[]['HTML:hint'] = rg_template('admin/settings/ssh/hints.html', $hints[]['HTML:hint'] = rg_template('admin/settings/ssh/hints.html',
 
... ... function rg_admin_settings_git($db, $rg)
722 720
723 721 // Load defaults // Load defaults
724 722 while (1) { while (1) {
725 $r = rg_state_get($db, 'git_patch_limit');
723 $r = rg_state_get_uint($db, 'git_patch_limit');
726 724 if ($r === FALSE) { if ($r === FALSE) {
727 725 $ret = rg_template('admin/settings/load_err.html', $ret = rg_template('admin/settings/load_err.html',
728 726 $rg, TRUE /*xss*/); $rg, TRUE /*xss*/);
729 727 break; break;
730 728 } }
731 if (empty($r))
729 if ($r == 0)
732 730 $r = $rg_git_patch_limit_default; $r = $rg_git_patch_limit_default;
733 731 $rg['git_patch_limit'] = $r; $rg['git_patch_limit'] = $r;
734 732
File inc/bug.inc.php changed (mode: 100644) (index 5e5e135..167696b)
... ... $rg_bug_functions = array(
38 38 4000 => "rg_bug_event_note_add_all", 4000 => "rg_bug_event_note_add_all",
39 39 4001 => "rg_bug_event_note_add_one", 4001 => "rg_bug_event_note_add_one",
40 40 4100 => "rg_bug_event_add_all", 4100 => "rg_bug_event_add_all",
41 4101 => "rg_bug_event_add_one"
41 4101 => "rg_bug_event_add_one",
42 // new new style
43 'bug_event_note_add_all' => 'rg_bug_event_note_add_all',
44 'bug_event_note_add_one' => 'rg_bug_event_note_add_one',
45 'bug_event_add_all' => 'rg_bug_event_add_all',
46 'bug_event_add_one' => 'rg_bug_event_add_one'
42 47 ); );
43 48 rg_event_register_functions($rg_bug_functions); rg_event_register_functions($rg_bug_functions);
44 49
 
... ... function rg_bug_event_add_all($db, $event)
73 78 $ret = array(); $ret = array();
74 79
75 80 $x = $event; $x = $event;
76 $x['category'] = 4101;
81 $x['category'] = 'bug_event_add_one';
77 82 $x['prio'] = 100; $x['prio'] = 100;
78 83 $x['ui'] = array(); $x['ui'] = array();
79 84
 
... ... function rg_bug_event_note_add_all($db, $event)
144 149 $ret = array(); $ret = array();
145 150
146 151 $x = $event; $x = $event;
147 $x['category'] = 4001;
152 $x['category'] = 'bug_event_note_add_one';
148 153 $x['prio'] = 100; $x['prio'] = 100;
149 154 $x['ui'] = array(); $x['ui'] = array();
150 155
 
... ... function rg_bug_edit($db, $login_ui, $ri, $data)
453 458
454 459 // TODO: seems I do not distinguish between 'add' and 'edit' // TODO: seems I do not distinguish between 'add' and 'edit'
455 460 $event = array( $event = array(
456 'category' => 4100,
461 'category' => 'bug_event_add_all',
457 462 'prio' => 200, 'prio' => 200,
458 463 'ui' => $login_ui, 'ui' => $login_ui,
459 464 'ri' => array( 'ri' => array(
 
... ... function rg_bug_search_load($db, $repo_id, $uid, $name)
689 694 $rows = rg_sql_num_rows($res); $rows = rg_sql_num_rows($res);
690 695 if ($rows > 0) { if ($rows > 0) {
691 696 $row = rg_sql_fetch_array($res); $row = rg_sql_fetch_array($res);
692 $_data = @unserialize($row['data']);
697 $_data = rg_unserialize($row['data']);
693 698 if ($_data === FALSE) { if ($_data === FALSE) {
694 rg_bug_set_error("cannot unserialize search data");
699 rg_bug_set_error('cannot unserialize search data: '
700 . rg_util_error());
695 701 break; break;
696 702 } }
697 703 $ret = $_data; $ret = $_data;
 
... ... function rg_bug_search_save($db, $repo_id, $uid, $q)
731 737 if ($old === FALSE) if ($old === FALSE)
732 738 break; break;
733 739
734 $data = serialize($q);
740 $data = rg_serialize($q);
735 741
736 742 // Global? // Global?
737 743 if (isset($q['global']) && (strcmp($q['global'], "on") == 0)) if (isset($q['global']) && (strcmp($q['global'], "on") == 0))
 
... ... function rg_bug_note_add($db, $repo_id, $bug_id, $login_uid, $data)
971 977 $who_added_text = $_ui['username']; $who_added_text = $_ui['username'];
972 978
973 979 $event = array( $event = array(
974 'category' => 4000,
980 'category' => 'bug_event_note_add_all',
975 981 'prio' => 200, 'prio' => 200,
976 982 'ui' => $_ui, 'ui' => $_ui,
977 983 'bug' => array( 'bug' => array(
File inc/builder.inc.php changed (mode: 100644) (index d9cd509..a7d6fd0)
... ... function rg_builder_load_jobs($db, $where)
28 28 // TODO: set 'url' when adding the job in queue! // TODO: set 'url' when adding the job in queue!
29 29 // Why not now? // Why not now?
30 30
31 // TODO: in case of errors, we should abort the job!
31 32 $row['request'] = rg_unserialize($row['request']); $row['request'] = rg_unserialize($row['request']);
32 if ($row['request'] === FALSE) {
33 rg_internal_error('cannot unserialize request!');
33 if ($row['request'] === FALSE)
34 34 $row['request'] = array(); $row['request'] = array();
35 }
36 35 $row['status'] = rg_unserialize($row['status']); $row['status'] = rg_unserialize($row['status']);
37 if ($row['status'] === FALSE) {
38 rg_internal_error('cannot unserialize status!');
36 if ($row['status'] === FALSE)
39 37 $row['status'] = array(); $row['status'] = array();
40 }
41 38
42 39 $ret['list'][$jid] = $row; $ret['list'][$jid] = $row;
43 40 } }
File inc/cache.inc.php changed (mode: 100644) (index a242a7b..14af748)
... ... function rg_cache_core_dump()
65 65 if (!$rg_cache_core_enable) if (!$rg_cache_core_enable)
66 66 return ''; return '';
67 67
68 return "rg_cache:\n" . print_r($rg_cache, TRUE);
68 return 'rg_cache: ' . rg_array2string($rg_cache);
69 69 } }
70 70
71 71 /* /*
 
... ... function rg_cache_core_adump($ns_var)
346 346 */ */
347 347 function rg_cache_prepare_key($s) function rg_cache_prepare_key($s)
348 348 { {
349 return addcslashes($s, "\n\r\\");
349 return $s;
350 350 } }
351 351
352 352 /* /*
 
... ... function rg_cache_prepare_key($s)
354 354 */ */
355 355 function rg_cache_prepare($s) function rg_cache_prepare($s)
356 356 { {
357 $x = serialize($s);
358 return addcslashes($x, "\n\r\\");
357 return rg_serialize($s);
359 358 } }
360 359
361 360 /* /*
 
... ... function rg_cache_send($cmd, $para, $flags)
384 383 rg_log('Sending [' . $xcmd . ']...'); rg_log('Sending [' . $xcmd . ']...');
385 384 $ret = rg_socket($rg_cache_socket, $xcmd . "\n", $ret = rg_socket($rg_cache_socket, $xcmd . "\n",
386 385 $rg_cache_timeout, $rg_cache_tries, $flags); $rg_cache_timeout, $rg_cache_tries, $flags);
387 if ($rg_cache_debug)
388 rg_log('Received [' . $ret . ']');
389 386 if ($ret === FALSE) if ($ret === FALSE)
390 387 return FALSE; return FALSE;
388 if ($rg_cache_debug)
389 rg_log('Received [' . $ret . ']');
391 390
392 391 if ($flags & RG_SOCKET_NO_WAIT) if ($flags & RG_SOCKET_NO_WAIT)
393 392 return TRUE; return TRUE;
 
... ... function rg_cache_send($cmd, $para, $flags)
419 418 if (!isset($t[2])) if (!isset($t[2]))
420 419 return TRUE; return TRUE;
421 420
422 return trim(stripcslashes($t[2]));
421 return trim($t[2]);
423 422 break; break;
424 423 } }
425 424 } }
426 425
427 426 /* /*
428 427 * Returns a variable from the cache daemon * Returns a variable from the cache daemon
428 * Return FALSE on error.
429 429 */ */
430 430 function rg_cache_get($ns_var) function rg_cache_get($ns_var)
431 431 { {
 
... ... function rg_cache_get($ns_var)
445 445 if ($r === FALSE) if ($r === FALSE)
446 446 break; break;
447 447
448 $ret = @unserialize($r);
448 $ret = rg_unserialize($r);
449 449 if ($ret === FALSE) { if ($ret === FALSE) {
450 rg_internal_error("Cannot userialize [$r]!");
450 rg_cache_set_error('cannot unserialize answer: '
451 . rg_util_error());
451 452 break; break;
452 453 } }
453 454
 
... ... function rg_cache_get($ns_var)
456 457 } }
457 458
458 459 if ($rg_cache_debug) if ($rg_cache_debug)
459 rg_log_ml('cache_get[' . $ns_var . '] returns: '
460 . ($ret === FALSE ? 'FALSE' : print_r($ret, TRUE)));
460 rg_log('cache_get[' . $ns_var . '] returns: '
461 . ($ret === FALSE ? 'FALSE' : rg_array2string($ret)));
461 462
462 463 rg_prof_end('cache_get'); rg_prof_end('cache_get');
463 464 return $ret; return $ret;
 
... ... function rg_cache_set($ns_var, $value, $flags)
482 483 break; break;
483 484
484 485 if ($rg_cache_debug) if ($rg_cache_debug)
485 rg_log_ml('cache_set[' . $ns_var . '] = ' . print_r($value, TRUE));
486 rg_log('cache_set[' . $ns_var . '] = ' . rg_array2string($value));
486 487
487 488 $ret = TRUE; $ret = TRUE;
488 489 break; break;
 
... ... function rg_cache_merge($ns_var, $list, $flags)
553 554 $ret = rg_cache_send('MERGE', $para, $flags); $ret = rg_cache_send('MERGE', $para, $flags);
554 555
555 556 if ($rg_cache_debug) if ($rg_cache_debug)
556 rg_log_ml('cache_merge[' . $ns_var . '] = ' . print_r($list, TRUE));
557 rg_log('cache_merge[' . $ns_var . '] = ' . rg_array2string($list));
557 558
558 559 rg_prof_end('cache_merge'); rg_prof_end('cache_merge');
559 560 return $ret; return $ret;
File inc/conn.inc.php changed (mode: 100644) (index 184d07a..4c52ed1)
... ... $rg_events = array('r' => array(), 'w' => array());
9 9 */ */
10 10 function rg_conn_prepare($s) function rg_conn_prepare($s)
11 11 { {
12 if (is_array($s))
13 $s = serialize($s);
14 return addcslashes($s, "\n\r\\");
12 return rg_serialize($s);
15 13 } }
16 14
17 15 /* /*
File inc/events.inc.php changed (mode: 100644) (index da4a3d4..890bbf7)
... ... function rg_event_add($db, $event)
109 109 $prio = $event['prio']; unset($event['prio']); $prio = $event['prio']; unset($event['prio']);
110 110 $params = array("now" => $now, $params = array("now" => $now,
111 111 "prio" => $prio, "prio" => $prio,
112 "data" => serialize($event));
112 "data" => rg_serialize($event));
113 113 $sql = "INSERT INTO events (itime, prio, data)" $sql = "INSERT INTO events (itime, prio, data)"
114 114 . " VALUES (@@now@@, @@prio@@, @@data@@)"; . " VALUES (@@now@@, @@prio@@, @@data@@)";
115 115 $res = rg_sql_query_params($db, $sql, $params); $res = rg_sql_query_params($db, $sql, $params);
 
... ... function rg_event_process_queue($db, &$notify_list)
250 250
251 251 $sql = "UPDATE events SET fail = 1 WHERE id = @@id@@"; $sql = "UPDATE events SET fail = 1 WHERE id = @@id@@";
252 252 while (1) { while (1) {
253 $ev = unserialize($row['data']);
254 if ($ev === FALSE) {
255 rg_internal_error("Cannot unserialize data");
253 $ev = rg_unserialize($row['data']);
254 if ($ev === FALSE)
256 255 break; break;
257 }
258 256
259 257 $ev['prio'] = $row['prio']; $ev['prio'] = $row['prio'];
260 258 $ev['itime'] = $row['itime']; $ev['itime'] = $row['itime'];
File inc/fixes.inc.php changed (mode: 100644) (index ffccb58..24f991a)
... ... function rg_fixes_wh_ver2($db)
353 353
354 354 $params = array( $params = array(
355 355 'id' => $row['id'], 'id' => $row['id'],
356 'idata' => serialize($idata)
356 'idata' => rg_serialize($idata)
357 357 ); );
358 358 $sql = 'UPDATE webhooks SET idata = @@idata@@' $sql = 'UPDATE webhooks SET idata = @@idata@@'
359 359 . ' WHERE id = @@id@@'; . ' WHERE id = @@id@@';
 
... ... function rg_fixes_wh_ver3($db)
415 415 if (empty($row['idata'])) if (empty($row['idata']))
416 416 $idata = array(); $idata = array();
417 417 else else
418 $idata = unserialize($row['idata']);
418 $idata = rg_unserialize($row['idata']);
419 419 $idata['url'] = $row['url']; $idata['url'] = $row['url'];
420 420 $idata['key'] = $row['key']; $idata['key'] = $row['key'];
421 421 $idata['opaque'] = $row['opaque']; $idata['opaque'] = $row['opaque'];
 
... ... function rg_fixes_wh_ver3($db)
423 423
424 424 $params = array( $params = array(
425 425 'id' => $row['id'], 'id' => $row['id'],
426 'idata' => serialize($idata)
426 'idata' => rg_serialize($idata)
427 427 ); );
428 428 $sql = 'UPDATE webhooks SET idata = @@idata@@' $sql = 'UPDATE webhooks SET idata = @@idata@@'
429 429 . ' WHERE id = @@id@@'; . ' WHERE id = @@id@@';
 
... ... function rg_fixes_wh_ver4($db)
485 485 if (empty($row['idata'])) if (empty($row['idata']))
486 486 $idata = array(); $idata = array();
487 487 else else
488 $idata = unserialize($row['idata']);
488 $idata = rg_unserialize($row['idata']);
489 489 if (isset($idata['flags'])) { if (isset($idata['flags'])) {
490 490 $flags = $idata['flags']; $flags = $idata['flags'];
491 491 unset($idata['flags']); unset($idata['flags']);
 
... ... function rg_fixes_wh_ver4($db)
496 496 $params = array( $params = array(
497 497 'id' => $row['id'], 'id' => $row['id'],
498 498 'flags' => $flags, 'flags' => $flags,
499 'idata' => serialize($idata)
499 'idata' => rg_serialize($idata)
500 500 ); );
501 501 $sql = 'UPDATE webhooks SET flags = @@flags@@' $sql = 'UPDATE webhooks SET flags = @@flags@@'
502 502 . ', idata = @@idata@@' . ', idata = @@idata@@'
 
... ... function rg_fixes_needed($db)
830 830
831 831 $ret = FALSE; $ret = FALSE;
832 832 while (1) { while (1) {
833 $old = rg_state_get($db, "fixes_version");
833 $old = rg_state_get_uint($db, "fixes_version");
834 834 if ($old === FALSE) if ($old === FALSE)
835 835 break; break;
836 836
837 if ($old === "")
838 $old = 0;
839
840 837 rg_log("DEBUG: old=$old new=$rg_fixes_ver"); rg_log("DEBUG: old=$old new=$rg_fixes_ver");
841 838 if ($old == $rg_fixes_ver) { if ($old == $rg_fixes_ver) {
842 839 // fixes are up to date // fixes are up to date
 
... ... function rg_fixes_update($db)
864 861
865 862 $ret = FALSE; $ret = FALSE;
866 863 while (1) { while (1) {
867 $old = rg_state_get($db, "fixes_version");
864 $old = rg_state_get_uint($db, "fixes_version");
868 865 if ($old === FALSE) if ($old === FALSE)
869 866 break; break;
870 867
871 if ($old === "")
872 $old = 0;
873
874 868 if ($old == $rg_fixes_ver) { if ($old == $rg_fixes_ver) {
875 869 $ret = TRUE; $ret = TRUE;
876 870 break; break;
File inc/git.inc.php changed (mode: 100644) (index 1a16e22..7f8e8d3)
... ... function rg_git_fatal($msg)
42 42 } }
43 43
44 44 /* /*
45 * Returns true if a repo is empty, else, false
45 * Returns 1 if a repo is empty, 0 if not, -1 on error
46 46 */ */
47 47 function rg_git_repo_is_empty($repo_path) function rg_git_repo_is_empty($repo_path)
48 48 { {
 
... ... function rg_git_repo_is_empty($repo_path)
53 53 $repo_path .= '/.git'; $repo_path .= '/.git';
54 54
55 55 if (!file_exists($repo_path . '/refs/heads')) if (!file_exists($repo_path . '/refs/heads'))
56 return TRUE;
56 return 1;
57 57
58 58 $scan = glob($repo_path . '/refs/heads/*'); $scan = glob($repo_path . '/refs/heads/*');
59 59 if ($scan === FALSE) { if ($scan === FALSE) {
60 rg_internal_error('globa returned false');
61 return FALSE;
60 rg_internal_error('glob returned false');
61 return -1;
62 62 } }
63 63
64 64 if (empty($scan)) if (empty($scan))
65 return TRUE;
65 return 1;
66 66
67 67 rg_log_ml('DEBUG: scan: ' . print_r($scan, TRUE)); rg_log_ml('DEBUG: scan: ' . print_r($scan, TRUE));
68 return FALSE;
68 return 0;
69 69 } }
70 70
71 71 /* /*
72 * Returns true if the branch contains no commit
72 * Returns true if the ref is present in the repo
73 73 */ */
74 function rg_git_branch_is_empty($repo_path, $ref)
74 function rg_git_ref_exists($repo_path, $ref)
75 75 { {
76 76 if (empty($repo_path)) if (empty($repo_path))
77 77 $repo_path = '.'; $repo_path = '.';
 
... ... function rg_git_branch_is_empty($repo_path, $ref)
79 79 if (file_exists($repo_path . '/.git')) if (file_exists($repo_path . '/.git'))
80 80 $repo_path .= '/.git'; $repo_path .= '/.git';
81 81
82 if (!file_exists($repo_path . '/refs/heads/' . $ref))
82 if (file_exists($repo_path . '/refs/heads/' . $ref))
83 83 return TRUE; return TRUE;
84 84
85 85 return FALSE; return FALSE;
 
... ... function rg_git_patch_limit($db)
159 159 global $rg_git_patch_limit_force; global $rg_git_patch_limit_force;
160 160 global $rg_git_patch_limit_default; global $rg_git_patch_limit_default;
161 161
162 // This is for functionl tests
162 // This is for functional tests
163 163 if (isset($rg_git_patch_limit_force)) if (isset($rg_git_patch_limit_force))
164 164 return $rg_git_patch_limit_force; return $rg_git_patch_limit_force;
165 165
166 $r = rg_state_get($db, 'git_patch_limit');
167 if (($r === FALSE) || empty($r))
166 $r = rg_state_get_uint($db, 'git_patch_limit');
167 if (($r === FALSE) || ($r === 0))
168 168 return $rg_git_patch_limit_default; return $rg_git_patch_limit_default;
169 169
170 return intval($r);
170 return $r;
171 171 } }
172 172
173 173 /* /*
 
... ... function rg_git_quote($s)
282 282 */ */
283 283 function rg_git_install_hooks($dst) function rg_git_install_hooks($dst)
284 284 { {
285 global $php_errormsg;
286 285 global $rg_scripts; global $rg_scripts;
287 286
288 287 rg_prof_start("git_install_hooks"); rg_prof_start("git_install_hooks");
 
... ... function rg_git_install_hooks($dst)
316 315 rg_log("Link hooks dir..."); rg_log("Link hooks dir...");
317 316 if (symlink($rg_scripts . "/hooks", $dst . "/hooks") === FALSE) { if (symlink($rg_scripts . "/hooks", $dst . "/hooks") === FALSE) {
318 317 rg_git_set_error("cannot make symlink [$rg_scripts/hooks]" rg_git_set_error("cannot make symlink [$rg_scripts/hooks]"
319 . "->[$dst/] ($php_errormsg).");
318 . "->[$dst/] (" . rg_php_err() . ").");
320 319 break; break;
321 320 } }
322 321
 
... ... function rg_git_install_hooks($dst)
334 333 */ */
335 334 function rg_git_init($dst) function rg_git_init($dst)
336 335 { {
337 global $php_errormsg;
338
339 336 rg_prof_start("git_init"); rg_prof_start("git_init");
340 337 rg_log_enter("git_init: dst=$dst"); rg_log_enter("git_init: dst=$dst");
341 338
 
... ... function rg_git_init($dst)
345 342 if (!file_exists($dir)) { if (!file_exists($dir)) {
346 343 $r = @mkdir($dir, 0700, TRUE); $r = @mkdir($dir, 0700, TRUE);
347 344 if ($r === FALSE) { if ($r === FALSE) {
348 rg_git_set_error("cannot create dir [$dir] ($php_errormsg)");
345 rg_git_set_error("cannot create dir [$dir] (" . rg_php_err() . ")");
349 346 break; break;
350 347 } }
351 348 } }
 
... ... function rg_git_init($dst)
361 358 } }
362 359
363 360 if (!@mkdir($dst2 . '/rocketgit')) { if (!@mkdir($dst2 . '/rocketgit')) {
364 rg_git_set_error("cannot create '$dst/rocketgit' dir ($php_errormsg)");
361 rg_git_set_error("cannot create '$dst/rocketgit' dir (" . rg_php_err() . ")");
365 362 break; break;
366 363 } }
367 364
 
... ... function rg_git_init($dst)
386 383
387 384 function rg_git_clone($src, $dst) function rg_git_clone($src, $dst)
388 385 { {
389 global $php_errormsg;
390
391 386 rg_prof_start("git_clone"); rg_prof_start("git_clone");
392 387 rg_log_enter("git_clone: src=$src, dst=$dst"); rg_log_enter("git_clone: src=$src, dst=$dst");
393 388
 
... ... function rg_git_clone($src, $dst)
397 392 if (!file_exists($dir)) { if (!file_exists($dir)) {
398 393 $r = @mkdir($dir, 0700, TRUE); $r = @mkdir($dir, 0700, TRUE);
399 394 if ($r === FALSE) { if ($r === FALSE) {
400 rg_git_set_error("cannot create dir [$dir] ($php_errormsg)");
395 rg_git_set_error("cannot create dir [$dir] (" . rg_php_err() . ")");
401 396 break; break;
402 397 } }
403 398 } }
 
... ... function rg_git_clone($src, $dst)
412 407 } }
413 408
414 409 if (!@mkdir($dst . "/rocketgit", 0700)) { if (!@mkdir($dst . "/rocketgit", 0700)) {
415 rg_git_set_error("cannot create '$dst/rocketgit' dir ($php_errormsg)");
410 rg_git_set_error("cannot create '$dst/rocketgit' dir (" . rg_php_err() . ")");
416 411 break; break;
417 412 } }
418 413 } }
 
... ... function rg_git_load_ref($repo_path, $ref)
629 624 * Returns a common ancestor between two commits (FALSE on error) * Returns a common ancestor between two commits (FALSE on error)
630 625 * TODO: Unit testing * TODO: Unit testing
631 626 */ */
632 function rg_git_merge_base($repo_path, $a, $b)
627 function rg_git_merge_base($repo_path, $refname_or_hash, $b)
633 628 { {
634 629 global $rg_git_zero; global $rg_git_zero;
635 630 global $rg_git_empty; global $rg_git_empty;
636 631
637 632 rg_prof_start('git_merge_base'); rg_prof_start('git_merge_base');
638 rg_log_enter('git_merge_base' . ' a=' . $a . ' b=' . $b);
633 rg_log_enter('git_merge_base' . ' refname_or_hash=' . $refname_or_hash
634 . ' b=' . $b);
639 635
640 636 $ret = FALSE; $ret = FALSE;
641 637 while (1) { while (1) {
642 if (rg_git_branch_is_empty($repo_path, $a)) {
638 $r = rg_git_repo_is_empty($repo_path);
639 if ($r === -1)
640 break;
641
642 if ($r === 1) {
643 rg_log('DEBUG_MERGE: repo is empty. Return rg_git_empty.');
643 644 $ret = $rg_git_empty; $ret = $rg_git_empty;
644 645 break; break;
645 646 } }
646 647
647 if (empty($repo_path))
648 $add = '';
649 else
650 $add = ' --git-dir=' . escapeshellarg($repo_path);
648 $head = rg_git_load_ref($repo_path, $refname_or_hash);
649 rg_log('DEBUG_MERGE: head=' . $head);
650 if ($head === FALSE)
651 break;
652 if (!rg_git_ref_exists($repo_path, $refname_or_hash))
653 rg_log('DEBUG_MERGE: ref does not exists, probably is a hash');
651 654
655 // TODO: we cannot use the caching because refname_or_hash
656 // can be a refname which is a moving target.
657 if (0) {
652 658 if (!empty($repo_path)) { if (!empty($repo_path)) {
653 $head = rg_git_load_ref($repo_path, $a);
654 if ($head === FALSE)
655 break;
656
657 659 // TODO: why do we use escape here?! // TODO: why do we use escape here?!
658 660 $key = 'git' $key = 'git'
659 661 . '::' . sha1($repo_path) . '::' . sha1($repo_path)
 
... ... function rg_git_merge_base($repo_path, $a, $b)
666 668 break; break;
667 669 } }
668 670 } }
671 }
672
673 if (empty($repo_path))
674 $add = '';
675 else
676 $add = ' --git-dir=' . escapeshellarg($repo_path);
669 677
670 678 $cmd = RG_GIT_CMD $cmd = RG_GIT_CMD
671 679 . $add . $add
672 680 . ' merge-base' . ' merge-base'
673 . ' ' . escapeshellarg($a)
681 . ' ' . escapeshellarg($refname_or_hash)
674 682 . ' ' . escapeshellarg($b); . ' ' . escapeshellarg($b);
675 $a = rg_exec($cmd, '', FALSE, FALSE, FALSE);
676 if ($a['ok'] != 1) {
677 rg_git_set_error('error on git merge_base ('
678 . $a['errmsg'] . ')');
683 $r = rg_exec($cmd, '', FALSE, FALSE, FALSE);
684 if ($r['ok'] != 1) {
685 rg_git_set_error('error on git merge-base ('
686 . $r['errmsg'] . ')');
679 687 break; break;
680 688 } }
681 689
682 $ret = trim($a['data']);
690 $ret = trim($r['data']);
683 691
692 if (0) {
684 693 if (!empty($repo_path)) if (!empty($repo_path))
685 694 rg_cache_set($key, $ret, RG_SOCKET_NO_WAIT); rg_cache_set($key, $ret, RG_SOCKET_NO_WAIT);
695 }
686 696
687 697 break; break;
688 698 } }
 
... ... function rg_git_ls_tree($repo_path, $tree, $path)
779 789
780 790 $ret = FALSE; $ret = FALSE;
781 791 while (1) { while (1) {
782 if (rg_git_repo_is_empty($repo_path)) {
792 $r = rg_git_repo_is_empty($repo_path);
793 if ($r === -1)
794 break;
795
796 if ($r === 1) {
783 797 $ret = array(); $ret = array();
784 798 break; break;
785 799 } }
 
... ... function rg_git_diff2array($diff, &$out)
1165 1179 return $ret; return $ret;
1166 1180 } }
1167 1181
1182 /*
1183 * Returns 1 if a range of commits contain at least a merge,
1184 * 0 if not, -1 on error.
1185 */
1186 function rg_git_log_has_merges($repo_path, $from, $to)
1187 {
1188 global $rg_git_debug;
1189
1190 rg_prof_start('git_log_has_merges');
1191 rg_log_enter('git_log_has_merges: repo_path=' . $repo_path
1192 . ' from=' . $from . ' to=' . $to);
1193
1194 $ret = -1;
1195 while (1) {
1196 $from_to = rg_git_from_to($from, $to);
1197
1198 $cmd = RG_GIT_CMD . ' --no-pager'
1199 . ' --git-dir=' . escapeshellarg($repo_path)
1200 . ' log'
1201 . ' --merges --oneline --max-count=1';
1202 if (!empty($from_to))
1203 $cmd .= ' ' . escapeshellarg($from_to);
1204 $a = rg_exec($cmd, '', FALSE, FALSE, FALSE);
1205 if ($a['ok'] != 1) {
1206 rg_internal_error("error on log (" . $a['errmsg'] . ")"
1207 . " cmd=" . $cmd);
1208 rg_git_set_error('could not generate log; try again later');
1209 break;
1210 }
1211
1212 $rg_git_debug && rg_log('a:' . print_r($a, TRUE));
1213 if (empty($a['data'])) {
1214 $ret = 0;
1215 break;
1216 }
1217
1218 $ret = 1;
1219 break;
1220 }
1221
1222 rg_log_exit();
1223 rg_prof_end('git_log_has_merges');
1224 return $ret;
1225 }
1226
1168 1227 /* /*
1169 1228 * Show last @max commits, no merges, sort by topo * Show last @max commits, no merges, sort by topo
1170 1229 * @also_patch = TRUE if caller needs also the patch * @also_patch = TRUE if caller needs also the patch
 
... ... function rg_git_log_simple($repo_path, $max, $from, $to, $also_patch, $files,
1189 1248 $max_count = ($max == 0) ? "" : " --max-count=$max"; $max_count = ($max == 0) ? "" : " --max-count=$max";
1190 1249 $patches = $also_patch ? " --patch" : ""; $patches = $also_patch ? " --patch" : "";
1191 1250 $from_to = rg_git_from_to($from, $to); $from_to = rg_git_from_to($from, $to);
1251
1192 1252 $id = rg_id(16); $id = rg_id(16);
1193 1253 $sep_start = '-=ROCKETGIT-START-' . $id . '=-'; $sep_start = '-=ROCKETGIT-START-' . $id . '=-';
1194 1254 $sep_end = '-=ROCKETGIT_END_OF_VARS-' . $id . '=-'; $sep_end = '-=ROCKETGIT_END_OF_VARS-' . $id . '=-';
 
... ... function rg_git_diff($id, $a, $template_file)
1721 1781 if ($rg_git_debug > 90) if ($rg_git_debug > 90)
1722 1782 rg_log_ml("DEBUG: finfo: " . print_r($finfo, TRUE)); rg_log_ml("DEBUG: finfo: " . print_r($finfo, TRUE));
1723 1783
1724 $ret .= "<br />\n";
1725
1726 1784 $v = rg_visible_string($finfo['file']); $v = rg_visible_string($finfo['file']);
1727 1785 $f = rg_xss_safe($v); $f = rg_xss_safe($v);
1728 1786 $ret .= '<a name="file-' . $id . '-' . sha1($finfo['file']) . '"></a>' . "\n"; $ret .= '<a name="file-' . $id . '-' . sha1($finfo['file']) . '"></a>' . "\n";
 
... ... function rg_git_update_branch($db, $a)
1990 2048 . "\nYou have no rights to delete a branch."); . "\nYou have no rights to delete a branch.");
1991 2049 $history['history_category'] = REPO_CAT_GIT_BRANCH_DELETE; $history['history_category'] = REPO_CAT_GIT_BRANCH_DELETE;
1992 2050 $history['history_message'] = 'Reference ' . $a['refname'] $history['history_message'] = 'Reference ' . $a['refname']
1993 . ' deleted';
2051 . ' deleted (was ' . $a['old_rev'] . ')';
1994 2052 rg_repo_history_insert($db, $history); rg_repo_history_insert($db, $history);
1995 2053 break; break;
1996 2054 } }
 
... ... function rg_git_update_branch($db, $a)
2011 2069 $x = $_x; $x = $_x;
2012 2070 $x['needed_rights'] = 'O'; $x['needed_rights'] = 'O';
2013 2071 if ((rg_rights_allow($db, $x) !== TRUE) && ($check_fast_forward == 1)) { if ((rg_rights_allow($db, $x) !== TRUE) && ($check_fast_forward == 1)) {
2014 $merge_base = rg_git_merge_base($a['repo_path'], $a['old_rev'],
2015 $a['new_rev']);
2072 $merge_base = rg_git_merge_base($a['repo_path'],
2073 $a['old_rev'], $a['new_rev']);
2016 2074 if ($merge_base === FALSE) { if ($merge_base === FALSE) {
2017 2075 rg_log("Error in merge_base: " . rg_git_error()); rg_log("Error in merge_base: " . rg_git_error());
2018 2076 rg_git_fatal($a['refname'] . "\nInternal error." rg_git_fatal($a['refname'] . "\nInternal error."
2019 2077 . " Please try again later."); . " Please try again later.");
2020 2078 } }
2021 2079
2022 if (strcmp($merge_base, $a['old_rev']) != 0)
2080 if (strcmp($merge_base, $a['old_rev']) != 0) {
2081 rg_log('DEBUG: merge_base=' . $merge_base);
2082 rg_log('DEBUG: merge_base != old_rev [' . $a['old_rev'] . ']');
2023 2083 rg_git_fatal($a['refname'] rg_git_fatal($a['refname']
2024 2084 . "\nYou have no rights to do a non fast-forward push;" . "\nYou have no rights to do a non fast-forward push;"
2025 . " Do a fetch and re-base before pushing.");
2085 . " Do a merge or re-base before pushing.");
2086 }
2026 2087 } }
2027 2088
2028 2089 // Check if user pushes a merge commit // Check if user pushes a merge commit
2029 // TODO: Check all commits, not only the last one!
2030 2090 $x = $_x; $x = $_x;
2031 2091 $x['needed_rights'] = 'M'; $x['needed_rights'] = 'M';
2032 2092 if (rg_rights_allow($db, $x) !== TRUE) { if (rg_rights_allow($db, $x) !== TRUE) {
2033 if (rg_git_rev_ok($a['new_rev'] . "^2") !== FALSE)
2093 $r = rg_git_log_has_merges($a['repo_path'],
2094 $a['old_rev'], $a['new_rev']);
2095 if ($r == -1) {
2096 rg_git_fatal($a['refname'] . "\n" . rg_git_error());
2097 } else if ($r == 1) {
2034 2098 rg_git_fatal($a['refname'] rg_git_fatal($a['refname']
2035 . "\nYou have no rights to push merges.");
2099 . "\nYou have no rights to push merges."
2100 . ' Do a rebase.');
2101 }
2036 2102 } }
2037 2103
2038 2104 // Check for bad whitespace // Check for bad whitespace
 
... ... function rg_git_update_branch($db, $a)
2106 2172 rg_log("DEBUG: We are allowed to push."); rg_log("DEBUG: We are allowed to push.");
2107 2173
2108 2174 $ev = $a; $ev = $a;
2109 $ev['category'] = 3007;
2175 $ev['category'] = 'repo_event_push';
2110 2176 $ev['prio'] = 50; $ev['prio'] = 50;
2111 2177 $ev['ri'] = array( $ev['ri'] = array(
2112 2178 'repo_id' => $a['repo_id'], 'repo_id' => $a['repo_id'],
 
... ... function rg_git_content_by_file($treeish, $file)
2335 2401 } }
2336 2402
2337 2403 /* /*
2338 * High level function that shows commits between two points
2404 * High level function that shows commits between two points.
2339 2405 * Input is the array returned by rg_git_log() * Input is the array returned by rg_git_log()
2340 2406 * @commit_table - TRUE if you want commit table to show (FALSE for log/commit) * @commit_table - TRUE if you want commit table to show (FALSE for log/commit)
2341 2407 */ */
 
... ... function rg_git_log2listing($log, $rg, $commit_table)
2343 2409 { {
2344 2410 rg_log_enter('git_log2listing'); rg_log_enter('git_log2listing');
2345 2411
2412 $ret = '';
2346 2413 while (1) { while (1) {
2347 2414 if ($log === FALSE) { if ($log === FALSE) {
2348 $ret = rg_template('repo/not_init.html', $rg, TRUE /*xss*/);
2415 $ret = rg_template('repo/err/not_init.html', $rg, TRUE /*xss*/);
2349 2416 break; break;
2350 2417 } }
2351 2418
2352 $ret = '';
2353
2354 2419 if ($commit_table) { if ($commit_table) {
2355 2420 // Show a short list of commits // Show a short list of commits
2356 2421 // Set 'url' // Set 'url'
 
... ... function rg_git_log2listing($log, $rg, $commit_table)
2358 2423 $log[$index]['vars']['commit_url'] = $log[$index]['vars']['commit_url'] =
2359 2424 rg_xss_safe($rg['mr']['id']) rg_xss_safe($rg['mr']['id'])
2360 2425 . "#sha1-" . rg_xss_safe($i['vars']['sha1']); . "#sha1-" . rg_xss_safe($i['vars']['sha1']);
2361 $ret .= rg_git_log_template($log, 'repo/log', $rg);
2426 $rg['HTML:commit_table'] = rg_git_log_template($log,
2427 'repo/log', $rg);
2428 } else {
2429 $rg['HTML:commit_table'] = '';
2362 2430 } }
2363 2431
2364 // TODO: move this into a template!
2365 $ret .= '<div style="margin-top: 8pt; margin-left: 8pt">' . "\n";
2366 foreach ($log as $junk => $i) {
2432 foreach ($log as $junk => &$i) {
2367 2433 //rg_log_ml('DEBUG: i=' . print_r($i, TRUE)); //rg_log_ml('DEBUG: i=' . print_r($i, TRUE));
2368 2434
2369 2435 // Some info about commit // Some info about commit
2370 $ret .= "<b>"
2371 . "<a name=\"sha1-" . rg_xss_safe($i['vars']['sha1']) . "\">"
2372 . "Commit " . rg_xss_safe($i['vars']['sha1'])
2373 . "</a></b> - " . rg_xss_safe($i['vars']['subject']) . "\n";
2374
2375 2436 if (!empty($i['vars']['body'])) if (!empty($i['vars']['body']))
2376 $ret .= "<br />\n"
2377 . nl2br(rg_xss_safe($i['vars']['body']));
2378
2379 $ret .= "<br /><b>Author</b>: " . rg_xss_safe($i['vars']['author name']);
2437 $i['vars']['HTML:x_body']
2438 = '<div class="commit_body">'
2439 . nl2br(rg_xss_safe(trim($i['vars']['body'])))
2440 . '</div>';
2441 else
2442 $i['vars']['HTML:x_body'] = '';
2380 2443
2381 $ret .= "<br /><b>Author date (UTC)</b>: "
2382 . gmdate("Y-m-d H:i", $i['vars']['author date']);
2444 $i['vars']['HTML:x_author date']
2445 = gmdate("Y-m-d H:i", $i['vars']['author date']);
2383 2446
2384 2447 if (!empty($i['vars']['committer name'])) if (!empty($i['vars']['committer name']))
2385 $ret .= "<br /><b>Committer</b>: "
2386 . rg_xss_safe($i['vars']['committer name']);
2387
2388 $ret .= '<br /><b>Commit date (UTC)</b>: '
2389 . gmdate("Y-m-d H:i", $i['vars']['committer date']);
2390
2391 $ret .= '<br /><b>Tree</b>: ' . $i['vars']['tree'];
2392
2393 if (!empty($i['vars']['parents']))
2394 $ret .= '<br /><b>Parents</b>: '
2395 . $i['vars']['parents'];
2448 $i['vars']['x_committer name']
2449 = $i['vars']['committer name'];
2450 else
2451 $i['vars']['HTML:x_committer name'] = '?';
2396 2452
2397 if (!empty($i['vars']['sign_key']))
2398 $ret .= '<br /><b>Signing key</b>: '
2399 . $i['vars']['sign_key'];
2453 $i['vars']['HTML:x_committer date']
2454 = gmdate("Y-m-d H:i", $i['vars']['committer date']);
2400 2455
2401 2456 // stats // stats
2402 2457 $r = rg_git_files_stats($i['vars']['sha1'], $i['files'], $r = rg_git_files_stats($i['vars']['sha1'], $i['files'],
2403 2458 'repo/fstat'); 'repo/fstat');
2404 if ($r === FALSE) {
2405 $ret = FALSE;
2406 break;
2407 }
2408 $ret .= $r;
2459 if ($r === FALSE)
2460 $i['HTML:x_stats'] = rg_template('repo/err/stats.html', $rg, TRUE /*xss*/);
2461 else
2462 $i['HTML:x_stats'] = $r;
2409 2463
2410 2464 // diff // diff
2411 2465 //rg_log_ml("DEBUG: i[files]=" . print_r($i['files'], TRUE)); //rg_log_ml("DEBUG: i[files]=" . print_r($i['files'], TRUE));
2412 2466 $r = rg_git_diff($i['vars']['sha1'], $i['files'], $r = rg_git_diff($i['vars']['sha1'], $i['files'],
2413 2467 'repo/diff.html'); 'repo/diff.html');
2414 if ($r === FALSE) {
2415 $ret = FALSE;
2416 break;
2417 }
2418 $ret .= $r;
2468 if ($r === FALSE)
2469 $i['HTML:x_diff'] = rg_template('repo/err/diff.html', $rg, TRUE /*xss*/);
2470 else
2471 $i['HTML:x_diff'] = $r;
2419 2472 } }
2420 2473 break; break;
2421 2474 } }
2422
2423 if (!empty($rg['HTML:commit_labels']))
2424 $ret .= '<br />' . $rg['HTML:commit_labels'];
2425 $ret .= '</div>' . "\n";
2475 $ret .= rg_template_table('repo/commits', $log, $rg);
2426 2476
2427 2477 rg_log_exit(); rg_log_exit();
2428 2478 return $ret; return $ret;
 
... ... function rg_git_merge_tree($repo_path, $base, $a, $b)
2496 2546
2497 2547 $ret = FALSE; $ret = FALSE;
2498 2548 while (1) { while (1) {
2499 if (rg_git_repo_is_empty($repo_path))
2549 $r = rg_git_repo_is_empty($repo_path);
2550 if ($r === -1)
2551 break;
2552
2553 if ($r === 1)
2500 2554 $a = $rg_git_empty; $a = $rg_git_empty;
2501 2555
2502 2556 $head = rg_git_load_ref($repo_path, $a); $head = rg_git_load_ref($repo_path, $a);
2503 2557 if ($head === FALSE) if ($head === FALSE)
2504 2558 break; break;
2505 2559
2506 $key = 'git'
2507 . '::' . sha1($repo_path)
2508 . '::' . 'merge-tree'
2509 . '::' . $head . '::' . $b;
2510 $r = rg_cache_get($key);
2511 if ($r !== FALSE) {
2512 $ret = $r;
2513 break;
2560 if (!empty($repo_path)) {
2561 $key = 'git'
2562 . '::' . sha1($repo_path)
2563 . '::' . 'merge-tree'
2564 . '::' . $head . '::' . $b;
2565 $r = rg_cache_get($key);
2566 if ($r !== FALSE) {
2567 $ret = $r;
2568 break;
2569 }
2514 2570 } }
2515 2571
2516 2572 $cmd = RG_GIT_CMD . ' --git-dir=' . escapeshellarg($repo_path) $cmd = RG_GIT_CMD . ' --git-dir=' . escapeshellarg($repo_path)
 
... ... function rg_git_merge_tree($repo_path, $base, $a, $b)
2525 2581 break; break;
2526 2582 } }
2527 2583
2528 $ret = trim($a['data']);
2529 rg_cache_set($key, $ret, RG_SOCKET_NO_WAIT);
2584 if (!empty($repo_path)) {
2585 $ret = trim($a['data']);
2586 rg_cache_set($key, $ret, RG_SOCKET_NO_WAIT);
2587 }
2530 2588 rg_log_ml('DEBUG: merge-tree: ' . $ret); rg_log_ml('DEBUG: merge-tree: ' . $ret);
2531 2589 break; break;
2532 2590 } }
 
... ... function rg_git_merge($repo_path, $ref_name, $new, $ff, $msg)
2593 2651
2594 2652 rg_prof_start('git_merge'); rg_prof_start('git_merge');
2595 2653 rg_log_enter('git_merge' . ' ref_name=' . $ref_name rg_log_enter('git_merge' . ' ref_name=' . $ref_name
2596 . ' new=' . $new . ' ff=' . $ff . ' msg=' . $msg);
2654 . ' new=' . $new . ' ff=' . $ff . ' msg=[' . $msg . ']');
2597 2655
2598 2656 $ret = FALSE; $ret = FALSE;
2599 2657 while (1) { while (1) {
2600 if (rg_git_repo_is_empty($repo_path))
2658 $r = rg_git_repo_is_empty($repo_path);
2659 if ($r === -1)
2660 break;
2661
2662 if ($r === 1)
2601 2663 $ref_name_tmp = $rg_git_empty; $ref_name_tmp = $rg_git_empty;
2602 2664 else else
2603 2665 $ref_name_tmp = $ref_name; $ref_name_tmp = $ref_name;
2604 2666
2605 // TODO: this must go away - the cache will malfunction?
2606 if (empty($repo_path))
2607 $add = '';
2608 else
2609 $add = ' --git-dir=' . escapeshellarg($repo_path);
2610
2611 2667 $r = rg_git_lock($repo_path, 60); $r = rg_git_lock($repo_path, 60);
2612 2668 if ($r === FALSE) if ($r === FALSE)
2613 2669 break; break;
 
... ... function rg_git_merge($repo_path, $ref_name, $new, $ff, $msg)
2629 2685 rg_log('DEBUG: ref_name points to ' . $cur); rg_log('DEBUG: ref_name points to ' . $cur);
2630 2686
2631 2687 // If repo was empty, we are forced to do a ff // If repo was empty, we are forced to do a ff
2632 if (strcmp($mb, $rg_git_empty) == 0)
2688 if (strcmp($mb, $rg_git_empty) == 0) {
2689 rg_log('DEBUG: merge base is empty, allow fast-forward.');
2633 2690 $ff = 1; $ff = 1;
2691 }
2634 2692
2635 2693 if (($ff == 1) && (strcmp($mb, $cur) == 0)) { if (($ff == 1) && (strcmp($mb, $cur) == 0)) {
2636 2694 rg_log('DEBUG: we can do a fast forward...'); rg_log('DEBUG: we can do a fast forward...');
 
... ... function rg_git_merge($repo_path, $ref_name, $new, $ff, $msg)
2641 2699 $e_ref_name_tmp = escapeshellarg($ref_name_tmp); $e_ref_name_tmp = escapeshellarg($ref_name_tmp);
2642 2700 $e_new = escapeshellarg($new); $e_new = escapeshellarg($new);
2643 2701
2702 // TODO: this must go away - the cache will malfunction?
2703 if (empty($repo_path))
2704 $add = '';
2705 else
2706 $add = ' --git-dir=' . escapeshellarg($repo_path);
2707
2644 2708 $cmd = RG_GIT_CMD $cmd = RG_GIT_CMD
2645 2709 . $add . ' read-tree -i -m ' . $add . ' read-tree -i -m '
2646 2710 . $e_mb . ' ' . $e_ref_name_tmp . ' ' . $e_new; . $e_mb . ' ' . $e_ref_name_tmp . ' ' . $e_new;
File inc/keys.inc.php changed (mode: 100644) (index 44f519f..58918a0)
... ... $rg_keys_functions = array(
33 33 1002 => "rg_keys_event_regen", 1002 => "rg_keys_event_regen",
34 34 1003 => "rg_keys_event_notify_user", 1003 => "rg_keys_event_notify_user",
35 35 // new style // new style
36 'rg_keys_event_regen' => 'rg_keys_event_regen'
36 'rg_keys_event_regen' => 'rg_keys_event_regen',
37 // new new style
38 'keys_event_new' => 'rg_keys_event_new',
39 'keys_event_del' => 'rg_keys_event_del',
40 'keys_event_regen' => 'rg_keys_event_regen',
41 'keys_event_notify_user' => 'rg_keys_event_notify_user'
37 42 ); );
38 43 rg_event_register_functions($rg_keys_functions); rg_event_register_functions($rg_keys_functions);
39 44
 
... ... function rg_keys_event_new($db, $event)
53 58 ); );
54 59
55 60 // notify user // notify user
56 $ret[] = array_merge($event, array("category" => 1003, "prio" => 100));
61 $ret[] = array_merge($event,
62 array('category' => 'keys_event_notify_user', 'prio' => 100));
57 63
58 64 return $ret; return $ret;
59 65 } }
 
... ... function rg_keys_event_del($db, $event)
74 80 ); );
75 81
76 82 // notify user // notify user
77 $ret[] = array_merge($event, array("category" => 1003, "prio" => 100));
83 $ret[] = array_merge($event,
84 array('category' => 'keys_event_notify_user', 'prio' => 100));
78 85
79 86 return $ret; return $ret;
80 87 } }
 
... ... function rg_keys_weak($db, $ki)
140 147 $ret = array('ok' => 0, 'weak' => 1); $ret = array('ok' => 0, 'weak' => 1);
141 148
142 149 if (strcmp($ki['type'], 'ssh-rsa') == 0) { if (strcmp($ki['type'], 'ssh-rsa') == 0) {
143 $min = rg_state_get($db, 'ssh_key_min_bits_rsa');
150 $min = rg_state_get_uint($db, 'ssh_key_min_bits_rsa');
144 151 if ($min === FALSE) { if ($min === FALSE) {
145 152 rg_keys_set_error('cannot lookup state'); rg_keys_set_error('cannot lookup state');
146 153 return $ret; return $ret;
 
... ... function rg_keys_weak($db, $ki)
152 159 return $ret; return $ret;
153 160 } }
154 161 } else if (strcmp($ki['type'], 'ssh-dss') == 0) { } else if (strcmp($ki['type'], 'ssh-dss') == 0) {
155 $r = rg_state_get($db, 'ssh_key_allow_dsa');
162 $r = rg_state_get_uint($db, 'ssh_key_allow_dsa');
156 163 if ($r === FALSE) { if ($r === FALSE) {
157 164 rg_keys_set_error('cannot lookup state'); rg_keys_set_error('cannot lookup state');
158 165 return $ret; return $ret;
 
... ... function rg_keys_weak($db, $ki)
163 170 return $ret; return $ret;
164 171 } }
165 172 } else if (strncmp($ki['type'], 'ecdsa-', 6) == 0) { } else if (strncmp($ki['type'], 'ecdsa-', 6) == 0) {
166 $min = rg_state_get($db, 'ssh_key_min_bits_ecdsa');
173 $min = rg_state_get_uint($db, 'ssh_key_min_bits_ecdsa');
167 174 if ($min === FALSE) { if ($min === FALSE) {
168 175 rg_keys_set_error('cannot lookup state'); rg_keys_set_error('cannot lookup state');
169 176 return $ret; return $ret;
 
... ... function rg_keys_remove($db, $ui, $list)
386 393 rg_sql_free_result($res); rg_sql_free_result($res);
387 394
388 395 $event = array( $event = array(
389 'category' => 1001,
396 'category' => 'keys_event_del',
390 397 'prio' => 50, 'prio' => 50,
391 398 'ui' => $ui, 'ui' => $ui,
392 399 'keys' => implode(',', $my_list)); 'keys' => implode(',', $my_list));
 
... ... function rg_keys_max($db)
451 458 if (($r === FALSE) || empty($r)) if (($r === FALSE) || empty($r))
452 459 return $rg_max_ssh_keys; return $rg_max_ssh_keys;
453 460
454 return $r;
461 return intval($r);
455 462 } }
456 463
457 464 /* /*
 
... ... function rg_keys_add($db, $ui, $key)
522 529 rg_sql_free_result($res); rg_sql_free_result($res);
523 530
524 531 $event = array( $event = array(
525 'category' => 1000,
532 'category' => 'keys_event_new',
526 533 'prio' => 50, 'prio' => 50,
527 534 'ui' => $ui, 'ui' => $ui,
528 535 'ki' => $ki, 'ki' => $ki,
 
... ... function rg_keys_regen($db)
693 700 rg_keys_set_error('cannot get state of AuthorizedKeysCommand'); rg_keys_set_error('cannot get state of AuthorizedKeysCommand');
694 701 break; break;
695 702 } }
696
703 $akp = intval($akp);
697 704 if ($akp == 1) { if ($akp == 1) {
698 705 if (file_exists($rg_keys_file)) if (file_exists($rg_keys_file))
699 706 unlink($rg_keys_file); unlink($rg_keys_file);
File inc/ldap.inc.php changed (mode: 100644) (index 99b8f91..b67e57d)
... ... function rg_ldap_cosmetic_row($db, &$row)
45 45 /* /*
46 46 * Some cosmetics applied to a LDAP server (array) * Some cosmetics applied to a LDAP server (array)
47 47 */ */
48 function rg_ldap_cosmetic($db, &$a)
48 function rg_ldap_cosmetic_list($db, &$a)
49 49 { {
50 foreach ($a as $k => &$i)
51 rg_ldap_cosmetic_row($db, $i);
50 foreach ($a as $k => &$row)
51 rg_ldap_cosmetic_row($db, $row);
52 52 } }
53 53
54 54 /* /*
 
... ... function rg_ldap_list($db)
102 102 $ret['ok'] = 1; $ret['ok'] = 1;
103 103 break; break;
104 104 } }
105 uasort($ret['list'], 'rg_ldap_sort_helper');
105 if ($ret['ok'] == 1) {
106 rg_ldap_cosmetic_list($db, $ret['list']);
107 uasort($ret['list'], 'rg_ldap_sort_helper');
108 }
106 109
107 110 rg_log_exit(); rg_log_exit();
108 111 rg_prof_end('ldap_list'); rg_prof_end('ldap_list');
 
... ... function rg_ldap_list_high_level($db, $rg, $paras)
540 543 $ret .= rg_template('admin/ldap/list_err.html', $ret .= rg_template('admin/ldap/list_err.html',
541 544 $rg, TRUE /*xss*/); $rg, TRUE /*xss*/);
542 545 } else { } else {
543 rg_ldap_cosmetic($db, $r['list']);
546 rg_ldap_cosmetic_list($db, $r['list']);
544 547 $rg['rg_form_token'] = rg_token_get($db, $rg, 'ldap_list'); $rg['rg_form_token'] = rg_token_get($db, $rg, 'ldap_list');
545 548 $ret .= rg_template_table('admin/ldap/list', $r['list'], $rg); $ret .= rg_template_table('admin/ldap/list', $r['list'], $rg);
546 549 } }
File inc/log.inc.php changed (mode: 100644) (index 4de5c52..615ff5a)
... ... if (!isset($rg_log_file))
9 9 $rg_log_file = $rg_log_dir . "/err-fallback.log"; $rg_log_file = $rg_log_dir . "/err-fallback.log";
10 10
11 11 $rg_log_fd = FALSE; $rg_log_fd = FALSE;
12 $rg_log_sid = rg_id(6);
12 if (empty($rg_log_sid))
13 $rg_log_sid = rg_id(6);
13 14 $rg_log_last_date = ""; $rg_log_last_date = "";
14 15 $rg_log_level = 0; $rg_log_level = 0;
15 16
File inc/mr.inc.php changed (mode: 100644) (index 8123f2f..8672fbb)
... ... function rg_mr_event_merge($db, $ev)
55 55 if ($r === FALSE) { if ($r === FALSE) {
56 56 rg_log('Merge failed: ' . rg_git_error()); rg_log('Merge failed: ' . rg_git_error());
57 57 // TODO: notify ui['uid'] that the merge failed // TODO: notify ui['uid'] that the merge failed
58 $ev['mail'] = array();
59 $ev['mail']['subject'] = 'Merge failed';
58 60 rg_mail_template('repo/mail/merge_failed', $ev); rg_mail_template('repo/mail/merge_failed', $ev);
59 61 return $ret; return $ret;
60 62 } }
 
... ... function rg_mr_event_merge($db, $ev)
65 67 return FALSE; return FALSE;
66 68
67 69 // notify the requester (if not anonymous) // notify the requester (if not anonymous)
68 // TODO: notify the watchers?
70 // TODO: notify the watchers of the project?
69 71 // TODO: notify the users who commented on the pull request? // TODO: notify the users who commented on the pull request?
70 72 // TODO: notify users who watch the pull request? // TODO: notify users who watch the pull request?
71 73
 
... ... function rg_mr_high_level($db, &$rg, $paras)
390 392 $ret = ''; $ret = '';
391 393 while (1) { while (1) {
392 394 if ($rg['ri']['git_dir_done'] == 0) { if ($rg['ri']['git_dir_done'] == 0) {
393 $ret .= rg_template('repo/no_git_dir.html',
395 $ret .= rg_template('repo/err/no_git_dir.html',
394 396 $rg, TRUE /*xss*/); $rg, TRUE /*xss*/);
395 397 break; break;
396 398 } }
 
... ... function rg_mr_high_level($db, &$rg, $paras)
424 426 } }
425 427 break; break;
426 428 } else if (strcmp($op, 'create') == 0) { } else if (strcmp($op, 'create') == 0) {
427 $ret .= rg_warning('not yet implemented');
429 $ret .= rg_warning('not yet implemented'); // TODO
428 430 break; break;
429 431 } }
430 432
 
... ... function rg_mr_high_level($db, &$rg, $paras)
496 498 . ' (' . rg_git_error() . ').'); . ' (' . rg_git_error() . ').');
497 499 break; break;
498 500 } }
499 rg_log('DEBUG: cmwc=' . $r);
501 rg_log('DEBUG: can merge without conflict:' . ($r == 1 ? 'yes' : 'no'));
500 502 $mri['can_merge_without_conflicts'] = $r; $mri['can_merge_without_conflicts'] = $r;
501 503
502 504 if ($mri['can_merge_without_conflicts'] == 0) { if ($mri['can_merge_without_conflicts'] == 0) {
File inc/plan.inc.php changed (mode: 100644) (index 9f8fa06..b2cea78)
... ... function rg_plan_remove($db, $list)
126 126 return $ret; return $ret;
127 127 } }
128 128
129 /*
130 *
131 */
132 function rg_plan_cosmetic(&$row)
133 {
134 $_a = rg_xss_safe(trim($row['description']));
135 $row['HTML:description_nlbr'] = nl2br($_a);
136
137 $row['exists'] = 1;
138 }
139
140 /*
141 *
142 */
143 function rg_plan_cosmetic_list(&$a)
144 {
145 foreach ($a as $id => &$row)
146 rg_plan_cosmetic($row);
147 }
148
129 149 /* /*
130 150 * Return the list of plans * Return the list of plans
131 151 */ */
 
... ... function rg_plan_list($db)
137 157 $ret = FALSE; $ret = FALSE;
138 158 while (1) { while (1) {
139 159 $ret = rg_cache_get("plan::list"); $ret = rg_cache_get("plan::list");
140 if ($ret !== FALSE)
160 if ($ret !== FALSE) {
161 rg_plan_cosmetic_list($ret);
141 162 break; break;
163 }
142 164
143 165 $sql = "SELECT * FROM plans ORDER BY position"; $sql = "SELECT * FROM plans ORDER BY position";
144 166 $res = rg_sql_query($db, $sql); $res = rg_sql_query($db, $sql);
 
... ... function rg_plan_list($db)
149 171
150 172 $ret = array(); $ret = array();
151 173 while (($row = rg_sql_fetch_array($res))) { while (($row = rg_sql_fetch_array($res))) {
152 $row['exists'] = 1;
153 174 $id = $row['id']; $id = $row['id'];
154
155 // fixes
156 $_a = rg_xss_safe(trim($row['description']));
157 $row['HTML:description_nlbr'] = nl2br($_a);
158
159 175 $ret[$id] = $row; $ret[$id] = $row;
160 176 } }
161 177 rg_sql_free_result($res); rg_sql_free_result($res);
162 178
163 179 rg_cache_set("plan::list", $ret, RG_SOCKET_NO_WAIT); rg_cache_set("plan::list", $ret, RG_SOCKET_NO_WAIT);
180 rg_plan_cosmetic_list($ret);
164 181 break; break;
165 182 } }
166 183
File inc/prof.inc.php changed (mode: 100644) (index 751d651..65fdff0)
... ... function rg_prof_text()
167 167
168 168 $add = ""; $add = "";
169 169 foreach ($rg_prof_main as $label => $per_label) { foreach ($rg_prof_main as $label => $per_label) {
170 if (($per_label['time_ms'] < 5) && ($per_label['mem'] < 20))
170 if (($per_label['time_ms'] == 0) && ($per_label['mem'] < 20))
171 171 continue; continue;
172 172
173 173 $ret .= $add; $ret .= $add;
File inc/repo.inc.php changed (mode: 100644) (index 774c84f..9f2f761)
... ... $rg_repo_functions = array(
461 461 3004 => "rg_repo_event_symlink_by_name", 3004 => "rg_repo_event_symlink_by_name",
462 462 3005 => "rg_repo_event_storage_create", 3005 => "rg_repo_event_storage_create",
463 463 3006 => "rg_repo_history_insert", 3006 => "rg_repo_history_insert",
464 3007 => 'rg_repo_event_push'
464 3007 => 'rg_repo_event_push',
465 // new new style
466 'repo_event_new' => 'rg_repo_event_new',
467 'repo_event_del' => 'rg_repo_event_del',
468 'repo_event_update' => 'rg_repo_event_update',
469 'repo_event_notify_user' => 'rg_repo_event_notify_user',
470 'repo_event_symlink_by_name' => 'rg_repo_event_symlink_by_name',
471 'repo_event_storage_create' => 'rg_repo_event_storage_create',
472 'repo_history_insert' => 'rg_repo_history_insert',
473 'repo_event_push' => 'rg_repo_event_push'
465 474 ); );
466 475 rg_event_register_functions($rg_repo_functions); rg_event_register_functions($rg_repo_functions);
467 476
 
... ... function rg_repo_event_new($db, $event)
474 483
475 484 $event['op'] = "new"; $event['op'] = "new";
476 485
477 // Create git dir
478 486 $x = $event; $x = $event;
479 $x['category'] = 3005;
487 $x['category'] = 'repo_event_storage_create';
480 488 $x['prio'] = 20; $x['prio'] = 20;
481 489 $x['notification'] .= "-git"; $x['notification'] .= "-git";
482 490 $ret[] = $x; $ret[] = $x;
483 491
484 // make symlink by name
485 492 $x = $event; $x = $event;
486 $x['category'] = 3004;
493 $x['category'] = 'repo_event_symlink_by_name';
487 494 $x['prio'] = 200; $x['prio'] = 200;
488 495 $x['notification'] .= "-symlink"; $x['notification'] .= "-symlink";
489 496 $ret[] = $x; $ret[] = $x;
490 497
491 // notify user
492 498 $x = $event; $x = $event;
493 $x['category'] = 3003;
499 $x['category'] = 'repo_event_notify_user';
494 500 $x['prio'] = 100; $x['prio'] = 100;
495 501 $x['notification'] .= "-notify"; $x['notification'] .= "-notify";
496 502 $ret[] = $x; $ret[] = $x;
 
... ... function rg_repo_event_new($db, $event)
504 510
505 511 // add a history entry // add a history entry
506 512 $x = $event; $x = $event;
507 $x['category'] = 3006;
513 $x['category'] = 'repo_history_insert';
508 514 $x['prio'] = 50; $x['prio'] = 50;
509 515 $ret[] = $x; $ret[] = $x;
510 516
 
... ... function rg_repo_event_del($db, $event)
522 528
523 529 $event['op'] = "del"; $event['op'] = "del";
524 530 // notify user // notify user
525 $ret[] = array_merge($event, array("category" => 3003, "prio" => 100));
531 $ret[] = array_merge($event,
532 array('category' => 'repo_event_notify_user', 'prio' => 100));
526 533
527 534 // TODO: notify watchers // TODO: notify watchers
528 535
 
... ... function rg_repo_event_update($db, $event)
669 676 $event['op'] = "update"; $event['op'] = "update";
670 677
671 678 // make symlink by name // make symlink by name
672 $ret[] = array_merge($event, array("category" => 3004, "prio" => 200));
679 $ret[] = array_merge($event,
680 array('category' => 'repo_event_symlink_by_name', 'prio' => 200));
673 681
674 682 // notify user // notify user
675 $ret[] = array_merge($event, array("category" => 3003, "prio" => 100));
683 $ret[] = array_merge($event,
684 array('category' => 'repo_event_notify_user', 'prio' => 100));
676 685
677 686 // TODO: notify watchers // TODO: notify watchers
678 687
 
... ... function rg_repo_event_notify_user($db, $event)
702 711
703 712 /* /*
704 713 * Inserts an event into repo_history table * Inserts an event into repo_history table
714 * TODO: we do not know yet if update-ref succeded.
705 715 */ */
706 716 function rg_repo_history_insert($db, $event) function rg_repo_history_insert($db, $event)
707 717 { {
 
... ... function rg_repo_event_push($db, $event)
745 755
746 756 // TODO: we must be sure here that the update-ref finished with success // TODO: we must be sure here that the update-ref finished with success
747 757 // TODO: load references and check them? // TODO: load references and check them?
758 // 'post-update' hook knows if it succeeded or not. How to use it?
748 759
749 760 // notify user // notify user
750 761 if (0) { // TODO if (0) { // TODO
751 762 $x = $event; $x = $event;
752 $x['category'] = 3003;
763 $x['category'] = 'repo_event_notify_user';
753 764 $x['prio'] = 100; $x['prio'] = 100;
754 765 $x['notification'] .= "-notify"; $x['notification'] .= "-notify";
755 766 $ret[] = $x; $ret[] = $x;
 
... ... function rg_repo_delete($db, $repo_id, $ui)
940 951 rg_sql_free_result($res); rg_sql_free_result($res);
941 952
942 953 $event = array( $event = array(
943 'category' => 3001,
954 'category' => 'repo_event_del',
944 955 'prio' => 50, 'prio' => 50,
945 956 'ui' => $ui, 'ui' => $ui,
946 957 'ri' => array( 'ri' => array(
 
... ... function rg_repo_edit($db, $login_ui, &$new)
1167 1178 rg_sql_free_result($res); rg_sql_free_result($res);
1168 1179
1169 1180 if ($new['repo_id'] == 0) { if ($new['repo_id'] == 0) {
1170 $cat = 3000;
1181 $cat = 'repo_event_new';
1171 1182 $hcat = REPO_CAT_CREATE; $hcat = REPO_CAT_CREATE;
1172 1183 $hmess = "Repository has been created"; $hmess = "Repository has been created";
1173 1184 $notification = "repo_create-" . $login_ui['uid'] $notification = "repo_create-" . $login_ui['uid']
 
... ... function rg_repo_edit($db, $login_ui, &$new)
1175 1186 $old_description = ""; $old_description = "";
1176 1187 $new['repo_id'] = $row['repo_id']; $new['repo_id'] = $row['repo_id'];
1177 1188 } else { } else {
1178 $cat = 3002;
1189 $cat = 'repo_event_update';
1179 1190 $hcat = REPO_CAT_UPDATE; $hcat = REPO_CAT_UPDATE;
1180 1191 $hmess = "Repository has been updated"; $hmess = "Repository has been updated";
1181 1192 $notification = ""; $notification = "";
 
... ... function rg_repo_stats($rg)
2179 2190
2180 2191 while (1) { while (1) {
2181 2192 if ($rg['ri']['git_dir_done'] == 0) { if ($rg['ri']['git_dir_done'] == 0) {
2182 $ret = rg_template('repo/no_git_dir.html', $rg, TRUE /*xss*/);
2193 $ret = rg_template('repo/err/no_git_dir.html', $rg, TRUE /*xss*/);
2183 2194 break; break;
2184 2195 } }
2185 2196
 
... ... function rg_repo_api($db, $a)
2460 2471 function rg_repo_fetch_push_helper($db, $host, $ip, $login_ui, $prefix, $user, function rg_repo_fetch_push_helper($db, $host, $ip, $login_ui, $prefix, $user,
2461 2472 $repo, $cmd) $repo, $cmd)
2462 2473 { {
2474 global $rg_log_sid;
2475
2463 2476 rg_prof_start('repo_fetch_push_helper'); rg_prof_start('repo_fetch_push_helper');
2464 2477 rg_log_enter('repo_fetch_push_helper: host=' . $host rg_log_enter('repo_fetch_push_helper: host=' . $host
2465 . ' prefix=' . $prefix . ' user=' . $user
2466 . ' repo=' . $repo . ' cmd=' . $cmd);
2478 . ' ip=' . $ip . ' prefix=' . $prefix . ' user=[' . $user . ']'
2479 . ' repo=[' . $repo . '] cmd=[' . $cmd . ']');
2467 2480
2468 2481 $ret = array('ok' => 0, 'allow' => 0, 'push_allowed' => 0); $ret = array('ok' => 0, 'allow' => 0, 'push_allowed' => 0);
2469 2482 while (1) { while (1) {
 
... ... function rg_repo_fetch_push_helper($db, $host, $ip, $login_ui, $prefix, $user,
2502 2515
2503 2516 // Loading info about the repository // Loading info about the repository
2504 2517 if (rg_repo_ok($repo) !== TRUE) { if (rg_repo_ok($repo) !== TRUE) {
2505 $ret['errmsg'] = 'repository is invalid ('
2506 . rg_repo_error() . ')';
2518 $ret['errmsg'] = rg_repo_error();
2507 2519 break; break;
2508 2520 } }
2509 2521 $ret['ri'] = rg_repo_info($db, 0, $ret['owner_ui']['uid'], $repo); $ret['ri'] = rg_repo_info($db, 0, $ret['owner_ui']['uid'], $repo);
 
... ... function rg_repo_fetch_push_helper($db, $host, $ip, $login_ui, $prefix, $user,
2622 2634 putenv('ROCKETGIT_IP=' . $ip); putenv('ROCKETGIT_IP=' . $ip);
2623 2635 putenv('ROCKETGIT_ITIME=' . microtime(TRUE)); putenv('ROCKETGIT_ITIME=' . microtime(TRUE));
2624 2636 putenv('ROCKETGIT_HOST=' . $host); putenv('ROCKETGIT_HOST=' . $host);
2637 putenv('ROCKETGIT_LOG_SID=' . $rg_log_sid);
2625 2638 if (($ret['push'] == 1) && ($ret['push_allowed'] == 0)) { if (($ret['push'] == 1) && ($ret['push_allowed'] == 0)) {
2626 2639 rg_log('DEBUG: We need to clone the namespace...'); rg_log('DEBUG: We need to clone the namespace...');
2627 2640 $namespace = 'rg_' . rg_id(8); $namespace = 'rg_' . rg_id(8);
File inc/sql.inc.php changed (mode: 100644) (index 2b95172..8c0faeb)
... ... function rg_sql_open_nodelay($h)
83 83
84 84 $str = $rg_sql_conn[$h]['str']; $str = $rg_sql_conn[$h]['str'];
85 85 if ($rg_sql_debug > 0) if ($rg_sql_debug > 0)
86 rg_log("DB: opening [$str]...");
86 rg_log("DB: openning [$str]...");
87 87
88 88 rg_prof_set(array('db_conn' => 1)); rg_prof_set(array('db_conn' => 1));
89 89
File inc/state.inc.php changed (mode: 100644) (index e80b7ab..7ec4254)
... ... function rg_state_get_uint($db, $var)
96 96 if ($r === FALSE) if ($r === FALSE)
97 97 return FALSE; return FALSE;
98 98
99 if (empty($r))
100 return 0;
101
99 102 return intval($r); return intval($r);
100 103 } }
101 104
File inc/struct.inc.php changed (mode: 100644) (index 1ecbf75..dbb96d7)
... ... function rg_sql_struct_get_current_ver($db)
738 738 { {
739 739 rg_log_enter('sql_struct_get_current_ver'); rg_log_enter('sql_struct_get_current_ver');
740 740
741 $ret = FALSE;
742 while (1) {
743 $ret = rg_state_get($db, "schema_version");
744 if ($ret === FALSE)
745 break;
746
747 if (empty($ret))
748 $ret = 0;
749
750 break;
751 }
741 $ret = rg_state_get_uint($db, "schema_version");
752 742
753 743 rg_log_exit(); rg_log_exit();
754 744 return $ret; return $ret;
 
... ... function rg_sql_struct_slaves_update($db)
880 870 break; break;
881 871 $locked = TRUE; $locked = TRUE;
882 872
883 $last_ts = rg_state_get($db, "slaves_create_last_ts");
873 $last_ts = rg_state_get_uint($db, "slaves_create_last_ts");
884 874 if ($last_ts === FALSE) if ($last_ts === FALSE)
885 875 break; break;
886
887 $last_ts = sprintf("%u", $last_ts);
888 876 if ($last_ts == 0) if ($last_ts == 0)
889 877 $last_ts = gmmktime(0, 0, 0, gmdate("m") - 1, 1, gmdate("Y")); $last_ts = gmmktime(0, 0, 0, gmdate("m") - 1, 1, gmdate("Y"));
890 878 rg_log("last_ts=$last_ts (" . gmdate("Y-m-d", $last_ts) . ")"); rg_log("last_ts=$last_ts (" . gmdate("Y-m-d", $last_ts) . ")");
File inc/totp.inc.php changed (mode: 100644) (index 733c5cf..e3d9e15)
... ... function rg_totp_text($secret)
185 185 /* /*
186 186 * Cosmetic fixes for a login token row * Cosmetic fixes for a login token row
187 187 */ */
188 function rg_totp_cosmetic(&$row)
188 function rg_totp_cosmetic_row(&$row)
189 189 { {
190 190 if (isset($row['itime'])) if (isset($row['itime']))
191 191 $row['itime_nice'] = gmdate('Y-m-d H:i', $row['itime']); $row['itime_nice'] = gmdate('Y-m-d H:i', $row['itime']);
 
... ... function rg_totp_cosmetic(&$row)
206 206 } }
207 207 } }
208 208
209 /*
210 * Cosmetic fixes for a login token array
211 */
212 function rg_totp_cosmetic_list(&$a)
213 {
214 foreach ($a as $junk => &$row)
215 rg_totp_cosmetic_row($row);
216 }
217
209 218 /* /*
210 219 * Cosmetic fixes for a scratch token row * Cosmetic fixes for a scratch token row
211 220 */ */
212 function rg_totp_sc_cosmetic(&$row)
221 function rg_totp_sc_cosmetic_row(&$row)
213 222 { {
214 223 if (isset($row['itime'])) if (isset($row['itime']))
215 224 $row['itime_nice'] = gmdate('Y-m-d H:i', $row['itime']); $row['itime_nice'] = gmdate('Y-m-d H:i', $row['itime']);
216 225 } }
217 226
227 /*
228 * Cosmetic fixes for a login token array
229 */
230 function rg_totp_sc_cosmetic_list(&$a)
231 {
232 foreach ($a as $junk => &$row)
233 rg_totp_sc_cosmetic_row($row);
234 }
235
218 236 /* /*
219 237 * Returns if the user is enrolled or not * Returns if the user is enrolled or not
220 238 */ */
 
... ... function rg_totp_set_last_use($db, $uid, $id, $tc, $ts)
282 300 $key = 'user' . '::' . $uid . '::' . 'login_tokens' $key = 'user' . '::' . $uid . '::' . 'login_tokens'
283 301 . '::' . 'device' . '::' . $id; . '::' . 'device' . '::' . $id;
284 302 $a = array('used' => $ts, 'last_used_tc' => $tc, 'conf' => 't'); $a = array('used' => $ts, 'last_used_tc' => $tc, 'conf' => 't');
285 rg_totp_cosmetic($a);
286 303 rg_cache_merge($key, $a, RG_SOCKET_NO_WAIT); rg_cache_merge($key, $a, RG_SOCKET_NO_WAIT);
287 304
288 305 $ret = TRUE; $ret = TRUE;
 
... ... function rg_totp_device_list($db, $uid)
327 344 $ret['list'] = array(); $ret['list'] = array();
328 345 while (($row = rg_sql_fetch_array($res))) { while (($row = rg_sql_fetch_array($res))) {
329 346 $id = $row['id']; $id = $row['id'];
330
331 rg_totp_cosmetic($row);
332
333 347 $ret['list'][$id] = $row; $ret['list'][$id] = $row;
334 348 } }
335 349 rg_sql_free_result($res); rg_sql_free_result($res);
336 350
337 351 rg_cache_set($key, $ret['list'], RG_SOCKET_NO_WAIT); rg_cache_set($key, $ret['list'], RG_SOCKET_NO_WAIT);
352
338 353 $ret['ok'] = 1; $ret['ok'] = 1;
339 354 break; break;
340 355 } }
356 if ($ret['ok'] == 1)
357 rg_totp_cosmetic_list($ret['list']);
341 358
342 359 rg_log_exit(); rg_log_exit();
343 360 rg_prof_end('totp_device_list'); rg_prof_end('totp_device_list');
 
... ... function rg_totp_enroll($db, $uid, $name, $secret, $ip, $conf)
446 463 rg_sql_free_result($res); rg_sql_free_result($res);
447 464
448 465 $params['id'] = $row['id']; $params['id'] = $row['id'];
449 rg_totp_cosmetic($params);
450 466 $key = 'user' . '::' . $uid . '::' . 'login_tokens' $key = 'user' . '::' . $uid . '::' . 'login_tokens'
451 467 . '::' . 'device' . '::' . $params['id']; . '::' . 'device' . '::' . $params['id'];
452 468 rg_cache_set($key, $params, RG_SOCKET_NO_WAIT); rg_cache_set($key, $params, RG_SOCKET_NO_WAIT);
 
... ... function rg_totp_sc_list($db, $uid)
836 852 $ret['ok'] = 1; $ret['ok'] = 1;
837 853 break; break;
838 854 } }
855 if ($ret['ok'] == 1)
856 rg_totp_sc_cosmetic_list($ret['list']);
839 857
840 858 //rg_log_ml('DEBUG: sc_list ret[list]: ' . print_r($ret['list'], TRUE)); //rg_log_ml('DEBUG: sc_list ret[list]: ' . print_r($ret['list'], TRUE));
841 859
 
... ... function rg_totp_sc_generate($db, $uid, $count)
894 912 } }
895 913 rg_sql_free_result($res); rg_sql_free_result($res);
896 914
897 rg_totp_cosmetic($params);
898 915 $key = 'user' . '::' . $uid . '::' . 'login_tokens' $key = 'user' . '::' . $uid . '::' . 'login_tokens'
899 916 . '::' . 'sc' . '::' . $now; . '::' . 'sc' . '::' . $now;
900 917 rg_cache_set($key, $ret['list'], RG_SOCKET_NO_WAIT); rg_cache_set($key, $ret['list'], RG_SOCKET_NO_WAIT);
 
... ... function rg_totp_sc_high_level($db, $rg, $paras)
1192 1209 $_list[$itime] = array( $_list[$itime] = array(
1193 1210 'itime' => $itime, 'itime' => $itime,
1194 1211 'sc_count' => 1); 'sc_count' => 1);
1195 rg_totp_sc_cosmetic($_list[$itime]);
1212 rg_totp_sc_cosmetic_row($_list[$itime]);
1196 1213 } else { } else {
1197 1214 $_list[$itime]['sc_count']++; $_list[$itime]['sc_count']++;
1198 1215 } }
File inc/user.inc.php changed (mode: 100644) (index f3ab0bc..2bf94e1)
... ... $rg_user_functions = array(
50 50 2002 => "rg_user_event_notify_user", 2002 => "rg_user_event_notify_user",
51 51 2005 => "rg_user_event_rename", 2005 => "rg_user_event_rename",
52 52 2006 => "rg_user_link_by_name", 2006 => "rg_user_link_by_name",
53 'ask-email-confirmation' => 'rg_user_event_ask_email_confirmation'
53 'ask-email-confirmation' => 'rg_user_event_ask_email_confirmation',
54 // new new style
55 'user_event_new' => 'rg_user_event_new',
56 'user_event_login' => 'rg_user_event_login',
57 'user_event_notify_user' => 'rg_user_event_notify_user',
58 'user_event_rename' => 'rg_user_event_rename',
59 'user_link_by_name' => 'rg_user_link_by_name'
54 60 ); );
55 61 rg_event_register_functions($rg_user_functions); rg_event_register_functions($rg_user_functions);
56 62
 
... ... function rg_user_event_new($db, $event)
85 91 $event['op'] = 'new'; $event['op'] = 'new';
86 92
87 93 // create link by name // create link by name
88 $ret[] = array_merge($event, array("category" => 2006, "prio" => 500));
94 $ret[] = array_merge($event,
95 array('category' => 'user_link_by_name', 'prio' => 500));
89 96
90 97 // notify user // notify user
91 $ret[] = array_merge($event, array("category" => 2002, "prio" => 200));
98 $ret[] = array_merge($event,
99 array('category' => 'user_event_notify_user', 'prio' => 200));
92 100
93 101 return $ret; return $ret;
94 102 } }
 
... ... function rg_user_event_rename($db, $event)
138 146
139 147 $event['op'] = "rename"; $event['op'] = "rename";
140 148 // notify user // notify user
141 $ret[] = array_merge($event, array("category" => 2002, "prio" => 100));
149 $ret[] = array_merge($event,
150 array('category' => 'user_event_notify_user', 'prio' => 100));
142 151 // TODO: notify watchers // TODO: notify watchers
143 152
144 153 return $ret; return $ret;
 
... ... function rg_user_rename($db, $ui, $new_name)
484 493
485 494 // TODO: Check if all parameters are used. // TODO: Check if all parameters are used.
486 495 $event = array( $event = array(
487 'category' => 2005,
496 'category' => 'user_event_rename',
488 497 'prio' => 50, 'prio' => 50,
489 498 'ui' => $ui, 'ui' => $ui,
490 499 'rename_from' => $ui['username'], 'rename_from' => $ui['username'],
 
... ... function rg_user_info($db, $uid, $user, $email)
761 770 && (isset($c['info'])) && (isset($c['info']))
762 771 && (isset($c['info']['itime']))) { && (isset($c['info']['itime']))) {
763 772 $ret = $c['info']; $ret = $c['info'];
773 $ret['ok'] = 1;
764 774 $ret['exists'] = 1; $ret['exists'] = 1;
765 775 rg_user_cosmetic($ret); rg_user_cosmetic($ret);
766 776 break; break;
 
... ... function rg_user_list_to_full_info($db, $list)
2178 2188 * Please note that if the webserver was configured without an input filter * Please note that if the webserver was configured without an input filter
2179 2189 * (like apache's SetInputFilter DEFLATE), this function will * (like apache's SetInputFilter DEFLATE), this function will
2180 2190 * take care of it. * take care of it.
2191 * TE is alway empty and CL>0 using the current nginx configuration.
2192 * content_encoding may be gzip or empty.
2181 2193 * Returns the uncompressed stream. * Returns the uncompressed stream.
2182 2194 */ */
2183 2195 function rg_process_input($content_length, $content_encoding, &$err) function rg_process_input($content_length, $content_encoding, &$err)
 
... ... function rg_process_input($content_length, $content_encoding, &$err)
2185 2197 $te = isset($_SERVER['HTTP_TRANSFER_ENCODING']) ? $te = isset($_SERVER['HTTP_TRANSFER_ENCODING']) ?
2186 2198 $_SERVER['HTTP_TRANSFER_ENCODING'] : ''; $_SERVER['HTTP_TRANSFER_ENCODING'] : '';
2187 2199
2188 rg_log_enter('DEBUG: process_input: cl=' . $content_length
2200 rg_log_enter('DEBUG: process_input: content_length=' . $content_length
2189 2201 . ' content_encoding=' . $content_encoding . ' content_encoding=' . $content_encoding
2190 2202 . ' te=' . $te); . ' te=' . $te);
2191 2203
 
... ... function rg_process_input($content_length, $content_encoding, &$err)
2200 2212 . ' (' . $max_nice . ').' . "\n" . ' (' . $max_nice . ').' . "\n"
2201 2213 . 'You may want to ask the admin to raise' . 'You may want to ask the admin to raise'
2202 2214 . ' the limits (post_max_size).'; . ' the limits (post_max_size).';
2215 rg_internal_error($err);
2203 2216 break; break;
2204 2217 } }
2205 2218
 
... ... function rg_process_input($content_length, $content_encoding, &$err)
2213 2226 break; break;
2214 2227 } }
2215 2228
2229 if (!empty($te)) {
2230 $err = 'Unknown Transfer-Encoding: ' . $te;
2231 rg_internal_error($err);
2232 break;
2233 }
2234
2216 2235 // TODO: Sadly, we are not able to do the streaming! // TODO: Sadly, we are not able to do the streaming!
2217 2236 // It is not available to php-fpm! // It is not available to php-fpm!
2218 2237
 
... ... function rg_process_input($content_length, $content_encoding, &$err)
2225 2244 . ' \'git config http.postBuffer 200000000\'.' . "\n" . ' \'git config http.postBuffer 200000000\'.' . "\n"
2226 2245 . ' The value must be bigger than what you' . ' The value must be bigger than what you'
2227 2246 . ' want to push.'; . ' want to push.';
2247 rg_internal_error($err);
2228 2248 break; break;
2229
2230 rg_log('DEBUG: have to read data from php://stdin');
2231 $f = @fopen('php://stdin', 'rb');
2232 if ($f === FALSE) {
2233 rg_log('Cannot open stdin!');
2234 break;
2235 }
2236 rg_log('DEBUG: start reading from php://stdin');
2237 while (1) {
2238 $x = @fread($f, 65536);
2239 rg_log('DEBUG: x=');
2240 if ($x === FALSE) {
2241 rg_log('DEBUG: cannot read!');
2242 break;
2243 }
2244 rg_log('DEBUG: BLOCK: ' . $x);
2245 $ret = $x;
2246 break;
2247 }
2248 fclose($f);
2249 2249 } else { // Content-Length > 0 } else { // Content-Length > 0
2250 // TODO: we should just pass the file descriptor
2251 // (with stream filter gzip if needed)
2252 // and not buffer the whole content.
2253 $ret = @file_get_contents('php://input');
2254 if (empty($ret)) {
2255 $err = 'No input provided. Please let us know.';
2256 rg_internal_error($err);
2257 $ret = FALSE;
2258 break;
2259 }
2260 rg_log('DEBUG: php://input returned ' . strlen($ret) . ' bytes');
2261 2250 } }
2262 2251
2263 rg_log('DEBUG: data_in[0-31]: ' . substr($ret, 0, 32));
2264 2252 if (strcmp($content_encoding, 'gzip') == 0) { if (strcmp($content_encoding, 'gzip') == 0) {
2265 $ret = @gzdecode($ret);
2266 if ($ret === FALSE) {
2267 $err = 'Cannot decompress!';
2268 rg_internal_error($err);
2269 break;
2270 }
2271 rg_log('DEBUG: after decompress[0-31]: '
2272 . substr($ret, 0, 32));
2253 // ok, we are dealing with it
2254 } else if (!empty($content_encoding)) {
2255 $err = 'Unknown Content-Encoding: ' . $content_encoding;
2256 rg_internal_error($err);
2257 break;
2273 2258 } }
2274 2259
2260 $ret = TRUE;
2275 2261 break; break;
2276 2262 } }
2277 2263
2264 rg_log_exit();
2278 2265 return $ret; return $ret;
2279 2266 } }
2280 2267
2268 /*
2269 * Helper for rg_user_http_git
2270 */
2271 function rg_user_http_git_cb_input($index, &$a, $stream)
2272 {
2273 rg_log_enter('rg_user_http_git_cb_input');
2274
2275 switch ($stream) {
2276 case 1: // stdout
2277 echo $a['in_buf'];
2278 $a['in_buf'] = '';
2279 break;
2280
2281 case 2: // stderr
2282 $a['cb_input_stderr_func']($a['err_buf']);
2283 $a['err_buf'] = '';
2284 break;
2285 }
2286
2287 rg_log_exit();
2288 }
2289
2281 2290 /* /*
2282 2291 * Deals with push/fetch by HTTP(S) * Deals with push/fetch by HTTP(S)
2283 2292 */ */
 
... ... function rg_user_http_git($db, $rg, $paras)
2459 2468 $_SERVER['HTTP_CONTENT_ENCODING'] : ''; $_SERVER['HTTP_CONTENT_ENCODING'] : '';
2460 2469 rg_log('DEBUG: cl=' . $content_length . ' ce=' . $content_encoding . '.'); rg_log('DEBUG: cl=' . $content_length . ' ce=' . $content_encoding . '.');
2461 2470
2471 $input_fd = @fopen('php://input', 'r');
2472 if ($input_fd === FALSE) {
2473 $err = 'cannot open php://input: '. rg_php_err();
2474 rg_internal_error($err);
2475 break;
2476 }
2477
2478 $cmd = array(
2479 'cmds' => array(
2480 'cmd1' => array(
2481 'cb_output' => 'rg_exec2_helper_read_fd',
2482 'cb_output_fd' => $input_fd,
2483 //TODO 'out_buf_done' => 0,
2484 'cb_input' => 'rg_user_http_git_cb_input'
2485 )
2486 )
2487 );
2488
2489 if (strcasecmp($content_encoding, 'gzip') == 0)
2490 $cmd['cmds']['cmd1']['out_buf_helper'] = 'rg_exec2_helper_gzip_in';
2491
2462 2492 if (strcmp($file, 'info/refs') == 0) { if (strcmp($file, 'info/refs') == 0) {
2463 2493 rg_log('DEBUG: info/refs'); rg_log('DEBUG: info/refs');
2464 2494 // TODO: we should allow this only if the connecting // TODO: we should allow this only if the connecting
 
... ... function rg_user_http_git($db, $rg, $paras)
2469 2499 echo rg_git_pack('# service=' . $service . "\n"); echo rg_git_pack('# service=' . $service . "\n");
2470 2500 echo rg_git_flush(); echo rg_git_flush();
2471 2501
2472 $run = '/usr/libexec/git-core/' . $service
2502 $cmd['cmds']['cmd1']['cmd'] = '/usr/libexec/git-core/' . $service
2473 2503 . ' --stateless-rpc --advertise-refs' . ' --stateless-rpc --advertise-refs'
2474 2504 . ' ' . escapeshellarg($repo_path); . ' ' . escapeshellarg($repo_path);
2475 $e = rg_exec($run, '', 0 /*use stdin*/, 'rg_echo', 'rg_git_band_2');
2476 if ($e['code'] != 0)
2477 rg_log('Error executing command: ' . $e['errmsg']);
2505 $cmd['cmds']['cmd1']['cb_input_stderr_func'] = 'rg_git_band_2';
2506 $e = rg_exec2($cmd);
2507 rg_log_ml('XDEBUG: e: ' . print_r($e, TRUE));
2508 if (!isset($e['code']))
2509 exit(1);
2510 if ($e['ok'] != 1) {
2511 $err = 'error executing command: ' . $e['errmsg'];
2512 rg_internal_error($err);
2513 break;
2514 }
2478 2515 rg_log('Done!'); rg_log('Done!');
2479 } else if (strcasecmp($rg['ct'], 'application/x-git-upload-pack-request') == 0) {
2516 break;
2517 }
2518
2519 if (strcasecmp($rg['ct'], 'application/x-git-upload-pack-request') == 0) {
2480 2520 rg_log('DEBUG: git-upload-pack...'); rg_log('DEBUG: git-upload-pack...');
2481 2521
2482 2522 header('Content-Type: application/x-git-upload-pack-result'); header('Content-Type: application/x-git-upload-pack-result');
 
... ... function rg_user_http_git($db, $rg, $paras)
2498 2538 putenv('ROCKETGIT_SHOW_INFO=0'); putenv('ROCKETGIT_SHOW_INFO=0');
2499 2539 */ */
2500 2540
2501 $data_in = rg_process_input($content_length,
2502 $content_encoding, $err);
2503 if ($data_in === FALSE)
2541 $r = rg_process_input($content_length, $content_encoding, $err);
2542 if ($r === FALSE)
2504 2543 break; break;
2505 2544
2506 $run = '/usr/libexec/git-core/git-upload-pack'
2545 $cmd['cmds']['cmd1']['cmd'] = '/usr/libexec/git-core/git-upload-pack'
2507 2546 . ' --stateless-rpc' . ' --stateless-rpc'
2508 2547 . ' ' . escapeshellarg($repo_path); . ' ' . escapeshellarg($repo_path);
2509 $e = rg_exec($run, $data_in, 0 /*use stdin*/,
2510 'rg_echo', 'rg_git_band_2');
2511 if ($e['code'] != 0)
2512 rg_log('Error executing command: ' . $e['errmsg']);
2548 $cmd['cmds']['cmd1']['cb_input_stderr_func'] = 'rg_git_band_2';
2549 $e = rg_exec2($cmd);
2550 if ($e['ok'] != 1) {
2551 $err = 'error executing command: ' . $e['errmsg'];
2552 rg_internal_error($err);
2553 break;
2554 }
2555
2513 2556 rg_log('Done!'); rg_log('Done!');
2514 2557 } else if (strcasecmp($rg['ct'], 'application/x-git-receive-pack-request') == 0) { } else if (strcasecmp($rg['ct'], 'application/x-git-receive-pack-request') == 0) {
2515 2558 rg_log('DEBUG: git-receive-pack...'); rg_log('DEBUG: git-receive-pack...');
 
... ... function rg_user_http_git($db, $rg, $paras)
2527 2570 . ' instead of ' . $host . '.'); . ' instead of ' . $host . '.');
2528 2571 putenv('ROCKETGIT_SHOW_INFO=0'); putenv('ROCKETGIT_SHOW_INFO=0');
2529 2572
2530 $data_in = rg_process_input($content_length,
2531 $content_encoding, $err);
2532 if ($data_in === FALSE) {
2573 $r = rg_process_input($content_length, $content_encoding, $err);
2574 if ($r === FALSE) {
2533 2575 // We have to send '200'. // We have to send '200'.
2534 2576 // Else, we cannot send the hints // Else, we cannot send the hints
2535 2577 header($protocol . ' 200 Service unavailable'); header($protocol . ' 200 Service unavailable');
 
... ... function rg_user_http_git($db, $rg, $paras)
2538 2580 break; break;
2539 2581 } }
2540 2582
2541 $run = '/usr/libexec/git-core/git-receive-pack'
2583 $cmd['cmds']['cmd1']['cmd'] = '/usr/libexec/git-core/git-receive-pack'
2542 2584 . ' --stateless-rpc' . ' --stateless-rpc'
2543 2585 . ' ' . escapeshellarg($repo_path); . ' ' . escapeshellarg($repo_path);
2544 $e = rg_exec($run, $data_in, 0 /*use stdin*/, 'rg_echo', 'rg_echo');
2545 if ($e['code'] != 0)
2546 rg_log('Error executing command: ' . $e['errmsg']);
2586
2587 $cmd['cmds']['cmd1']['cb_input_stderr_func'] = 'rg_echo';
2588 $e = rg_exec2($cmd);
2589 if ($e['ok'] != 1) {
2590 $err = 'error executing command: ' . $e['errmsg'];
2591 rg_internal_error($err);
2592 break;
2593 }
2594
2547 2595 rg_log('Done!'); rg_log('Done!');
2548 2596 } else { } else {
2549 2597 rg_log('Unknown service!'); rg_log('Unknown service!');
File inc/user/repo-page.php changed (mode: 100644) (index 0914729..311a4ba)
... ... if ($rg['page_ui']['exists'] != 1) {
18 18 } }
19 19
20 20 if (rg_repo_ok($repo) !== TRUE) { if (rg_repo_ok($repo) !== TRUE) {
21 $_repo_page .= rg_template("repo/invalid.html", $rg, TRUE /* xss */);
21 $_repo_page .= rg_template('repo/err/invalid.html', $rg, TRUE /*xss*/);
22 22 return; return;
23 23 } }
24 24 $rg['ri'] = rg_repo_info($db, 0, $rg['page_ui']['uid'], $repo); $rg['ri'] = rg_repo_info($db, 0, $rg['page_ui']['uid'], $repo);
 
... ... if (strcmp($_subop, "history") == 0) {
172 172
173 173 rg_log("DEBUG: _subsubop=[$_subsubop]"); rg_log("DEBUG: _subsubop=[$_subsubop]");
174 174 if ($rg['ri']['git_dir_done'] == 0) { if ($rg['ri']['git_dir_done'] == 0) {
175 $_repo_body .= rg_template("repo/no_git_dir.html", $rg, TRUE /* xss */);
175 $_repo_body .= rg_template('repo/err/no_git_dir.html', $rg, TRUE /* xss */);
176 176 } else if (strcmp($_subsubop, "tree") == 0) { } else if (strcmp($_subsubop, "tree") == 0) {
177 177 $type = array_shift($paras); $type = array_shift($paras);
178 178 rg_log("DEBUG: tree: type=$type"); rg_log("DEBUG: tree: type=$type");
 
... ... if (strcmp($_subop, "history") == 0) {
188 188 $_hash = $_tree[0]['ref']; $_hash = $_tree[0]['ref'];
189 189 $size = $_tree[0]['size']; $size = $_tree[0]['size'];
190 190 if ($size > 400000) { if ($size > 400000) {
191 $_repo_body .= rg_template('repo/file_too_big.html',
191 $_repo_body .= rg_template('repo/err/file_too_big.html',
192 192 $rg, FALSE /*xss*/); $rg, FALSE /*xss*/);
193 193 } else { } else {
194 194 $c = rg_git_content($_hash); $c = rg_git_content($_hash);
 
... ... if (strcmp($_subop, "history") == 0) {
234 234 // TODO: improve the error report (error or empty?) // TODO: improve the error report (error or empty?)
235 235 $log = rg_git_log($rg['repo_path'], 10, '', $ref, FALSE, 0); $log = rg_git_log($rg['repo_path'], 10, '', $ref, FALSE, 0);
236 236 if ($log === FALSE) { if ($log === FALSE) {
237 $_repo_body .= rg_template("repo/not_init.html", $rg,
237 $_repo_body .= rg_template('repo/err/not_init.html', $rg,
238 238 TRUE /*xss*/); TRUE /*xss*/);
239 239 $go_on = FALSE; $go_on = FALSE;
240 240 } else { } else {
File inc/util.inc.php changed (mode: 100644) (index b6e07f1..91c9689)
... ... define('RG_SOCKET_NO_WAIT', 0x01);
9 9
10 10 if (!isset($rg_util_debug)) if (!isset($rg_util_debug))
11 11 $rg_util_debug = FALSE; $rg_util_debug = FALSE;
12 if (strcmp(getenv('ROCKETGIT_UTIL_DEBUG'), '1') == 0)
13 $rg_util_debug = TRUE;
12 14
13 15 $rg_util_error = ""; $rg_util_error = "";
14 16
 
... ... function rg_mega2bytes($s)
105 107 */ */
106 108 function rg_random_bytes($len) function rg_random_bytes($len)
107 109 { {
110 static $buf = '';
111 static $buf_len = 0;
112
108 113 rg_prof_start('random_bytes'); rg_prof_start('random_bytes');
109 114
110 115 $ret = FALSE; $ret = FALSE;
111 116
112 $f = @fopen('/dev/urandom', 'r');
113 if ($f !== NULL) {
114 $ret = @fread($f, $len);
117 if ($len > $buf_len) {
118 $f = @fopen('/dev/urandom', 'r');
119 if ($f === NULL)
120 rg_fatal('cannot open urandom');
121
122 while ($len > $buf_len) {
123 $r = @fread($f, max(512, $len));
124 if ($r === FALSE)
125 rg_fatal('cannot read from urandom');
126
127 $buf .= $r;
128 $buf_len += strlen($r);
129 }
130
115 131 fclose($f); fclose($f);
116 132 } }
117 133
118 if ($ret === FALSE) {
119 $ret = '';
120 for ($i = 0; $i < $len; $i++)
121 $ret .= rand(0, 255);
122 }
134 $ret = substr($buf, $len);
135 $buf = substr($buf, $len);
136 $buf_len -= $len;
123 137
124 138 rg_prof_end('random_bytes'); rg_prof_end('random_bytes');
125 139 return $ret; return $ret;
 
... ... function rg_ok($msg)
1121 1135 return rg_template("ok.html", $x, TRUE /* xss */); return rg_template("ok.html", $x, TRUE /* xss */);
1122 1136 } }
1123 1137
1138 /*
1139 * Helper for reading input from a fd for rg_exec2.
1140 * Used as a 'cb_output' function.
1141 */
1142 function rg_exec2_helper_read_fd($index, &$info)
1143 {
1144 $ret = -1;
1145 while (1) {
1146 $r = @fread($info['cb_output_fd'], 16 * 4096);
1147 if ($r === FALSE) {
1148 $err = 'cannot read from cb_output_fd: ' . rg_php_err();
1149 rg_internal_error($err);
1150 break;
1151 }
1152
1153 $len = strlen($r);
1154 if ($len === 0) {
1155 fclose($info['cb_output_fd']);
1156 $ret = 0;
1157 break;
1158 }
1159
1160 $info['out_buf'] .= $r;
1161 $ret = $len;
1162 break;
1163 }
1164
1165 return $ret;
1166 }
1167
1168 /*
1169 * Helper for decompressing input for rg_exec2.
1170 * On error, it returns FALSE and $err contains the error message.
1171 */
1172 function rg_exec2_helper_gzip_in(&$info)
1173 {
1174 global $rg_util_debug;
1175
1176 $rg_util_debug &&
1177 rg_log('exec2_helper_gzip_in...');
1178
1179 if (empty($info['out_buf']))
1180 return TRUE;
1181
1182 if (!isset($info['gzip_in_ctx'])) {
1183 $info['gzip_in_ctx'] = inflate_init(ZLIB_ENCODING_GZIP);
1184 if ($info['gzip_in_ctx'] === FALSE) {
1185 $err = 'cannot initialize context';
1186 return FALSE;
1187 }
1188
1189 $info['gzip_in_bytes'] = 0;
1190 }
1191
1192 $do_exit = FALSE;
1193 do {
1194 $rg_util_debug &&
1195 rg_log(' calling inflate_add with buf[0-31]=' . substr($info['out_buf'], 0, 32) . (!empty($info['out_buf']) ? '' : ' and ZLIB_FINISH'));
1196 if (!empty($info['out_buf']))
1197 $r = inflate_add($info['gzip_in_ctx'], $info['out_buf']);
1198 else
1199 $r = inflate_add($info['gzip_in_ctx'], $info['out_buf'], ZLIB_FINISH);
1200 if ($r === FALSE) {
1201 $err = 'error in decompression: ' . rg_php_err();
1202 rg_internal_error($err);
1203 return FALSE;
1204 }
1205
1206 $s = inflate_get_status($info['gzip_in_ctx']);
1207 if ($s === ZLIB_STREAM_END) {
1208 $rg_util_debug && rg_log(' Got ZLIB_STREAM_END; set out_buf_done to 1 and do_exit to TRUE');
1209 $info['out_buf'] = ''; // because zlib may finish before consuming all input
1210 $info['out_buf_done'] = 1;
1211 unset($info['gzip_in_ctx']);
1212 $do_exit = TRUE;
1213 } else if ($s === ZLIB_OK) {
1214 $rg_util_debug && rg_log(' Got ZLIB_OK');
1215
1216 $rl = inflate_get_read_len($info['gzip_in_ctx']);
1217 if ($rl === FALSE) {
1218 $err = 'cannot retrieve read_len';
1219 return FALSE;
1220 }
1221 $rg_util_debug &&
1222 rg_log(' gzip_in_bytes=' . $info['gzip_in_bytes'] . ' read_len=' . $rl);
1223
1224 $diff = $rl - $info['gzip_in_bytes'];
1225 $info['gzip_in_bytes'] = $rl;
1226 $info['out_buf'] = substr($info['out_buf'], $diff);
1227
1228 if (!empty($r))
1229 $do_exit = TRUE;
1230 } else {
1231 unset($info['gzip_in_ctx']);
1232 if ($s === FALSE)
1233 rg_log(' status is FALSE');
1234 else if ($s === ZLIB_BUF_ERROR)
1235 rg_log(' status is ZLIB_BUF_ERROR');
1236 else
1237 rg_log(' status is unknown [' . $s . ']');
1238 return FALSE;
1239 }
1240
1241 $rg_util_debug &&
1242 rg_log(' decompression produced: [' . $r . '] out_buf=' . $info['out_buf']);
1243 } while (!$do_exit);
1244
1245 $info['out_buf_real'] .= $r;
1246
1247 return TRUE;
1248 }
1249
1124 1250 /* /*
1125 1251 * Helper for rg_exec to init the structure * Helper for rg_exec to init the structure
1126 1252 */ */
 
... ... function rg_exec2_helper_init(&$info)
1132 1258 $info['last_failure'] = 0; $info['last_failure'] = 0;
1133 1259 if (!isset($info['out_buf'])) if (!isset($info['out_buf']))
1134 1260 $info['out_buf'] = ''; $info['out_buf'] = '';
1261 $info['out_buf_real'] = '';
1135 1262 $info['in_buf'] = ''; $info['in_buf'] = '';
1136 1263 $info['err_buf'] = ''; $info['err_buf'] = '';
1137 1264 $info['done'] = FALSE; $info['done'] = FALSE;
 
... ... function rg_exec2_helper_init(&$info)
1145 1272 else else
1146 1273 $info['input_fd_done'] = 1; $info['input_fd_done'] = 1;
1147 1274
1148 if (!isset($info['output_done']))
1149 $info['output_done'] = 1;
1275 if (isset($info['cb_output']))
1276 $info['cb_output_done'] = 0;
1277 else
1278 $info['cb_output_done'] = 1;
1279
1280 // TODO: what this is doing, rename it to something better
1281 if (!isset($info['out_buf_done']))
1282 $info['out_buf_done'] = 1;
1283
1284 // m2p = 'me' to 'program'
1285 $info['m2p_bytes'] = 0;
1286
1287 // w2m = 'web' to 'me'
1288 $info['w2m_bytes'] = 0;
1150 1289 } }
1151 1290
1152 1291 /* /*
 
... ... function rg_exec2_helper_close_stream($index, $fd, &$info, $stream)
1182 1321 rg_log_exit(); rg_log_exit();
1183 1322 } }
1184 1323
1324 /*
1325 * Tries to procude data to be sent to the peer process
1326 */
1327 function rg_exec2_helper_populate_out_buf($index, &$info)
1328 {
1329 global $rg_util_debug;
1330
1331 $rg_util_debug &&
1332 rg_log_enter($index . ': exec2_helper_populate_out_buf');
1333
1334 // cb_output can populate $info['out_buf']
1335 if ($info['cb_output_done'] == 0) {
1336 $r = $info['cb_output']($index, $info);
1337 if ($r == -1) {
1338 // TODO
1339 } else if ($r == 0) {
1340 $info['cb_output_done'] = 1;
1341 } else {
1342 $info['w2m_bytes'] += $r;
1343 }
1344 }
1345
1346 if (!isset($info['out_buf_helper'])) {
1347 $info['out_buf_real'] .= $info['out_buf'];
1348 $info['out_buf'] = '';
1349 } else {
1350 $info['out_buf_helper']($info);
1351 }
1352
1353 rg_log_exit();
1354 }
1355
1185 1356 /* /*
1186 1357 * This will replace rg_exec function * This will replace rg_exec function
1187 1358 * Returns the array of the commands with the last status. * Returns the array of the commands with the last status.
 
... ... function rg_exec2($a)
1190 1361 { {
1191 1362 global $rg_util_debug; global $rg_util_debug;
1192 1363
1193 rg_prof_start('exec2');
1194 rg_log_enter('exec2');
1364 $_id = ''; $_add = '';
1365 foreach ($a['cmds'] as $_junk => $_i) {
1366 $_id .= $_add . '[' . $_i['cmd'] . ']';
1367 $_add = ' ';
1368 }
1369
1370 rg_prof_start('exec2 ' . $_id);
1371 rg_log_enter('exec2 ' . $_id);
1195 1372
1196 1373 $rg_util_debug && $rg_util_debug &&
1197 1374 rg_log_ml('DEBUG: a: ' . print_r($a, TRUE)); rg_log_ml('DEBUG: a: ' . print_r($a, TRUE));
 
... ... function rg_exec2($a)
1319 1496
1320 1497 $info['stopped'] = FALSE; $info['stopped'] = FALSE;
1321 1498 $info['started'] = time(); $info['started'] = time();
1322
1323 // cb_output can populate $info['out_buf']
1324 if (isset($info['cb_output'])) {
1325 $rg_util_debug &&
1326 rg_log($index . ' DEBUG: calling cb_output (first)...');
1327 $info['cb_output']($index, $info);
1328 }
1329 1499 } }
1330 1500
1331 1501 if ($info['stopped']) { if ($info['stopped']) {
 
... ... function rg_exec2($a)
1334 1504 continue; continue;
1335 1505 } }
1336 1506
1507 rg_exec2_helper_populate_out_buf($index, $info);
1508
1337 1509 // Check idle // Check idle
1338 1510 if (isset($info['cb_idle']) if (isset($info['cb_idle'])
1339 1511 && ($info['idle_time'] > 0) && ($info['idle_time'] > 0)
 
... ... function rg_exec2($a)
1346 1518 $info['cb_idle']($index, $info); $info['cb_idle']($index, $info);
1347 1519 } }
1348 1520
1349 if (!empty($info['out_buf'])) {
1521 if (!empty($info['out_buf_real'])) {
1350 1522 $rg_util_debug && $rg_util_debug &&
1351 rg_log($index . ' DEBUG: out_buf not empty =>'
1523 rg_log($index . ' DEBUG: out_buf_real not empty =>'
1352 1524 . ' enable write notification!'); . ' enable write notification!');
1353 1525
1354 1526 $wx[] = $info['pipes'][0]; $wx[] = $info['pipes'][0];
1355 1527 } else if (($info['input_fd_done'] == 1) } else if (($info['input_fd_done'] == 1)
1356 && ($info['output_done'] == 1)
1528 && ($info['out_buf_done'] == 1)
1357 1529 && (isset($info['pipes'][0]))) { && (isset($info['pipes'][0]))) {
1358 1530 $rg_util_debug && $rg_util_debug &&
1359 rg_log($index . ' DEBUG: empty(out_buf)'
1531 rg_log($index . ' DEBUG: empty(out_buf_real)'
1360 1532 . ' && input_fd_done == 1' . ' && input_fd_done == 1'
1361 . ' && output_done == 1'
1533 . ' && out_buf_done == 1'
1362 1534 . ': close output ' . $info['pipes'][0]); . ': close output ' . $info['pipes'][0]);
1363 1535 rg_exec2_helper_close_stream($index, rg_exec2_helper_close_stream($index,
1364 1536 $info['pipes'][0], $info, 0); $info['pipes'][0], $info, 0);
 
... ... function rg_exec2($a)
1426 1598
1427 1599 $info = &$ret['cmds'][$index]; $info = &$ret['cmds'][$index];
1428 1600
1429 $rg_util_debug &&
1430 rg_log($index . ' DEBUG: out_buf before cb: ' . $info['out_buf']);
1601 rg_exec2_helper_populate_out_buf($index, $info);
1431 1602
1432 // cb_output can populate $info['out_buf']
1433 if (isset($info['cb_output'])) {
1603 if (empty($info['out_buf_real'])) {
1434 1604 $rg_util_debug && $rg_util_debug &&
1435 rg_log($index . ' DEBUG: calling cb_output...');
1436 $info['cb_output']($index, $info);
1437 }
1438
1439 if (empty($info['out_buf'])) {
1440 $rg_util_debug &&
1441 rg_log_ml($index . ' DEBUG: out_buf is empty!'
1605 rg_log_ml($index . ' DEBUG: out_buf_real is empty!'
1442 1606 . ' info: ' . print_r($info, TRUE)); . ' info: ' . print_r($info, TRUE));
1443 1607 continue; continue;
1444 1608 } }
1445 1609
1446 $rg_util_debug &&
1447 rg_log($index . ' DEBUG: send: [' . $info['out_buf'] . ']');
1448 $r = @fwrite($fd, $info['out_buf']);
1610 //$rg_util_debug &&
1611 //rg_log($index . ' DEBUG: sending: [' . $info['out_buf_real'] . ']');
1612 $r = @fwrite($fd, $info['out_buf_real']);
1449 1613 if ($r === FALSE) { if ($r === FALSE) {
1450 1614 $info['last_errmsg'] = 'cannot write'; $info['last_errmsg'] = 'cannot write';
1451 1615 if (isset($info['cb_error'])) if (isset($info['cb_error']))
 
... ... function rg_exec2($a)
1455 1619 $info['wait_for_stop'] = TRUE; $info['wait_for_stop'] = TRUE;
1456 1620 continue; continue;
1457 1621 } }
1458 $rg_util_debug &&
1459 rg_log($index . ' DEBUG: fwrite returned ' . $r . '.');
1460 $info['out_buf'] = substr($info['out_buf'], $r);
1622 $info['out_buf_real'] = substr($info['out_buf_real'], $r);
1623 $info['m2p_bytes'] += $r;
1461 1624 } }
1462 1625
1463 1626 foreach ($revents as $fd) { foreach ($revents as $fd) {
 
... ... function rg_exec2($a)
1516 1679 } }
1517 1680
1518 1681 rg_log_exit(); rg_log_exit();
1519 rg_prof_end('exec2');
1682 rg_prof_end('exec2 ' . $_id);
1520 1683 return $ret; return $ret;
1521 1684 } }
1522 1685
 
... ... function rg_exec($cmd, $input, $cb_stdin, $cb_stdout, $cb_stderr)
1570 1733 if ($cb_stdin === 0) { if ($cb_stdin === 0) {
1571 1734 $a['cmds']['cmd1']['input_fd'] = @fopen('php://stdin', 'rb'); $a['cmds']['cmd1']['input_fd'] = @fopen('php://stdin', 'rb');
1572 1735 if ($a['cmds']['cmd1']['input_fd'] === FALSE) { if ($a['cmds']['cmd1']['input_fd'] === FALSE) {
1573 $ret['errmsg'] = 'cannot open stdin';
1736 $ret['errmsg'] = 'cannot open stdin: ' . rg_php_err();
1574 1737 break; break;
1575 1738 } }
1576 1739 } else if ($cb_stdin !== FALSE) { } else if ($cb_stdin !== FALSE) {
 
... ... function rg_unserialize($s)
2453 2616 $r = @json_decode($s, TRUE); $r = @json_decode($s, TRUE);
2454 2617 if ($r !== NULL) if ($r !== NULL)
2455 2618 return $r; return $r;
2619
2620 $m = 'cannot decode json: ' . json_last_error_msg();
2621 rg_internal_error($m);
2622 rg_util_set_error($m);
2623 return FALSE;
2456 2624 } }
2457 2625
2458 if (strncmp($s, 'a:', 2) == 0) {
2626 $x = substr($s, 1, 1);
2627 if (strcmp($x, ':') == 0) {
2459 2628 $r = @unserialize($s); $r = @unserialize($s);
2460 2629 if ($r !== FALSE) if ($r !== FALSE)
2461 2630 return $r; return $r;
2462 2631 } }
2463 2632
2464 return FALSE;
2633 if (strcmp($s, '[]') == 0)
2634 return array();
2635
2636 if (strncmp($s, '"', 1) == 0)
2637 return substr($s, 1, -1);
2638
2639 return $s;
2465 2640 } }
2466 2641
2467 2642 /* /*
 
... ... function rg_unserialize($s)
2469 2644 */ */
2470 2645 function rg_serialize($a) function rg_serialize($a)
2471 2646 { {
2472 return @json_encode($a, TRUE);
2647 if (!is_array($a))
2648 return $a;
2649
2650 $r = @json_encode($a, TRUE);
2651 if ($r === FALSE) {
2652 $m = 'error encoding json: ' . json_last_error_msg();
2653 rg_internal_error($m);
2654 rg_util_set_error($m);
2655 return FALSE;
2656 }
2657
2658 return $r;
2473 2659 } }
2660
2661 /*
2662 * Compress data for web
2663 */
2664 function rg_gzencode($c, &$orig_len, &$comp_len)
2665 {
2666 rg_prof_start('gzencode');
2667 $ret = @gzencode($c, 6);
2668 if ($ret === FALSE)
2669 rg_fatal('cannot gzencode');
2670
2671 $orig_len = strlen($c);
2672 $comp_len = strlen($ret);
2673 rg_log('COMPRESSION: orig=' . $orig_len
2674 . ' comp=' . $comp_len
2675 . ' ratio=' . sprintf('%.3f', $orig_len / $comp_len));
2676
2677 rg_prof_end('gzencode');
2678 return $ret;
2679 }
2680
2681 /*
2682 * Output data to client
2683 */
2684 function rg_web_output($c)
2685 {
2686 $acc = @$_SERVER['HTTP_ACCEPT_ENCODING'];
2687 rg_log('DEBUG: client supports: ' . $acc);
2688 if (stristr($acc, 'gzip')) {
2689 header('Content-Encoding: gzip');
2690 $c = rg_gzencode($c, $orig_len, $comp_len);
2691 header('Content-Length: ' . $comp_len);
2692 }
2693
2694 echo $c;
2695 }
2696
File inc/wh/cloud.inc.php changed (mode: 100644) (index 4fc6f0d..87bf56f)
... ... require_once($INC . "/wh/amazon.inc.php");
9 9
10 10 $rg_wh_cloud_functions = array( $rg_wh_cloud_functions = array(
11 11 'wh_cloud_send' => 'rg_wh_cloud_send', 'wh_cloud_send' => 'rg_wh_cloud_send',
12 'rg_wh_cloud_send_one' => 'rg_wh_cloud_send_one'
12 'rg_wh_cloud_send_one' => 'rg_wh_cloud_send_one', // obsolete
13 'wh_cloud_send_one' => 'rg_wh_cloud_send_one'
13 14 ); );
14 15 rg_event_register_functions($rg_wh_cloud_functions); rg_event_register_functions($rg_wh_cloud_functions);
15 16
 
... ... function rg_wh_cloud_send($db, $event)
135 136 } }
136 137
137 138 $x = $event; $x = $event;
138 $x['category'] = 'rg_wh_cloud_send_one';
139 $x['category'] = 'wh_cloud_send_one';
139 140 $x['wh'] = $wh; $x['wh'] = $wh;
140 141 $x['debug'] = $wh['idata']['debug']; $x['debug'] = $wh['idata']['debug'];
141 142 $ret[] = $x; $ret[] = $x;
File inc/wh/core.inc.php changed (mode: 100644) (index 11f92e3..eca4d86)
... ... function rg_wh_list($db, $uid)
248 248 //rg_log_ml('DEBUG: wh_list: row: ' . print_r($row, TRUE)); //rg_log_ml('DEBUG: wh_list: row: ' . print_r($row, TRUE));
249 249 $id = $row['id']; $id = $row['id'];
250 250 if (strcmp($row['idata'], "") != 0) { if (strcmp($row['idata'], "") != 0) {
251 $row['idata'] = unserialize($row['idata']);
251 $row['idata'] = rg_unserialize($row['idata']);
252 252 if ($row['idata'] === FALSE) { if ($row['idata'] === FALSE) {
253 rg_internal_error('cannot unserialize data');
254 // we try to continue
253 // TODO: we try to continue
255 254 $row['idata'] = array(); $row['idata'] = array();
256 255 } }
257 256 } else { } else {
 
... ... function rg_wh_add($db, $uid, $data)
287 286 $data['uid'] = $uid; $data['uid'] = $uid;
288 287 $data['itime'] = time(); $data['itime'] = time();
289 288 $params = $data; $params = $data;
290 $params['idata'] = serialize($params['idata']);
289 $params['idata'] = rg_serialize($params['idata']);
291 290
292 291 if ($data['id'] == 0) { if ($data['id'] == 0) {
293 292 $data['last_output'] = ''; $data['last_output'] = '';
File inc/wh/http.inc.php changed (mode: 100644) (index 69a2353..2f42168)
... ... function rg_wh_http_send_one($db, $event)
113 113 $_info = @curl_getinfo($c); $_info = @curl_getinfo($c);
114 114 rg_log_ml('curl_getinfo: ' . print_r($_info, TRUE)); rg_log_ml('curl_getinfo: ' . print_r($_info, TRUE));
115 115
116 if ($wh['idata']['debug'] == 1)
117 rg_cache_set('DEBUG::' . $event['ui']['uid']
118 . '::webhooks::' . $wh['idata']['opaque']
119 . '::' . $wh['id'],
120 'BAD', RG_SOCKET_NO_WAIT);
116 $debug_value = 'BAD';
121 117 break; break;
122 118 } }
123 119
124 120 rg_log_ml('Answer: ' . print_r($r, TRUE)); rg_log_ml('Answer: ' . print_r($r, TRUE));
125 121 $xerr .= $r; $xerr .= $r;
126 122
127 if ($wh['idata']['debug'] == 1)
128 rg_cache_set('DEBUG::' . $event['ui']['uid']
129 . '::webhooks::' . $wh['idata']['opaque']
130 . '::' . $wh['id'],
131 'OK', RG_SOCKET_NO_WAIT);
132
123 $debug_value = 'OK';
133 124 $ret = array(); $ret = array();
134 125 break; break;
135 126 } }
 
... ... function rg_wh_http_send_one($db, $event)
143 134
144 135 rg_wh_set_last_output($db, $event['ui']['uid'], $wh['id'], $xerr); rg_wh_set_last_output($db, $event['ui']['uid'], $wh['id'], $xerr);
145 136
137 if ($wh['idata']['debug'] == 1)
138 rg_cache_set('DEBUG::' . $event['ui']['uid']
139 . '::webhooks::' . $wh['idata']['opaque']
140 . '::' . $wh['id'],
141 $debug_value, RG_SOCKET_NO_WAIT);
142
146 143 rg_prof_end('wh_http_send_helper'); rg_prof_end('wh_http_send_helper');
147 144 return $ret; return $ret;
148 145 } }
 
... ... function rg_wh_http_send($db, $event)
210 207 break; break;
211 208
212 209 case 1: // php serialize case 1: // php serialize
213 $cache[$itype] = serialize($event['ri']);
210 $cache[$itype] = rg_serialize($event['ri']);
214 211 break; break;
215 212
216 213 case 2: // custom body case 2: // custom body
File inc/workers.inc.php changed (mode: 100644) (index c342192..5cf3603)
... ... function rg_worker_cosmetic_one(&$row)
84 84 if (empty($row['env'])) { if (empty($row['env'])) {
85 85 $row['HTML:envs_nice'] = 'n/a'; $row['HTML:envs_nice'] = 'n/a';
86 86 } else { } else {
87 $list = @unserialize($row['env']);
87 $list = rg_unserialize($row['env']);
88 88 $t = array(); $t = array();
89 89 foreach ($list as $env => $env_info) foreach ($list as $env => $env_info)
90 90 $t[] = rg_xss_safe($env); $t[] = rg_xss_safe($env);
 
... ... function rg_worker_update($db, $uid, $id, $a)
346 346 $params['uid'] = $uid; $params['uid'] = $uid;
347 347 $params['id'] = $id; $params['id'] = $id;
348 348 $params['last_connect'] = time(); $params['last_connect'] = time();
349 $params['env'] = serialize($a['env']);
349 $params['env'] = rg_serialize($a['env']);
350 350
351 351 $sql = 'UPDATE workers SET' $sql = 'UPDATE workers SET'
352 352 . ' name = @@name@@' . ' name = @@name@@'
 
... ... function rg_worker_environments($db, $uid)
405 405 $r = array_merge($user_envs, $global_envs); $r = array_merge($user_envs, $global_envs);
406 406 $ret = array(); $ret = array();
407 407 foreach ($r as $id => $i) { foreach ($r as $id => $i) {
408 $list = @unserialize($i['env']);
408 $list = rg_unserialize($i['env']);
409 409 if ($list === FALSE) if ($list === FALSE)
410 410 continue; continue;
411 411
File root/index.php changed (mode: 100644) (index 546f9ea..7085307)
... ... $rg['ri'] = array("repo_id" => 0, "uid" => 0);
59 59 $rg['bug'] = array("bug_id" => 0); $rg['bug'] = array("bug_id" => 0);
60 60 $rg['debug'] = isset($rg_allow_debug) ? $rg['debug'] = isset($rg_allow_debug) ?
61 61 rg_var_uint('rg_debug') | intval(rg_var_cookie_re('rg_debug', '/[^0-9]/')) : 0; rg_var_uint('rg_debug') | intval(rg_var_cookie_re('rg_debug', '/[^0-9]/')) : 0;
62 if ($rg['debug'] == 1)
63 setcookie('rg_debug', '1', 0, '/', $rg['hostname'],
64 FALSE /*secure*/, FALSE /*httponly*/);
65 62 $rg['https'] = strcmp(rg_var_str('HTTPS'), 'on') == 0 ? 1 : 0; $rg['https'] = strcmp(rg_var_str('HTTPS'), 'on') == 0 ? 1 : 0;
66 63
67 64 $sparas = rg_var_str('SCRIPT_NAME'); $sparas = rg_var_str('SCRIPT_NAME');
 
... ... $rg['http_allow'] = $http_allow;
174 171 $rg['https_allow'] = $https_allow; $rg['https_allow'] = $https_allow;
175 172 $rg['base_url'] = rg_base_url(); $rg['base_url'] = rg_base_url();
176 173
174 if ($rg['debug'] == 1)
175 setcookie('rg_debug', '1', 0, '/', $rg['hostname'],
176 FALSE /*secure*/, FALSE /*httponly*/);
177 177
178 178 // Is it a http push/fetch? // Is it a http push/fetch?
179 179 $r = rg_user_http_git($db, $rg, $paras); $r = rg_user_http_git($db, $rg, $paras);
 
... ... if (($rg['https'] == 0)
292 292
293 293
294 294 $rg['HTML:rg_body'] = $body; $rg['HTML:rg_body'] = $body;
295 $_c = rg_template("index.html", $rg, TRUE /* xss */);
295 $_c = rg_template('index.html', $rg, TRUE /*xss*/);
296 296
297 297 // TODO: really?! // TODO: really?!
298 298 header('Cache-Control: private, no-cache'); header('Cache-Control: private, no-cache');
 
... ... header('Cache-Control: private, no-cache');
300 300 // Caching // Caching
301 301 $proto = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : ''; $proto = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : '';
302 302 if ((strcmp($proto, 'HTTP/1.1') == 0) || (strcmp($proto, 'HTTP/2.0') == 0)) { if ((strcmp($proto, 'HTTP/1.1') == 0) || (strcmp($proto, 'HTTP/2.0') == 0)) {
303 $we_have = sha1($_c);
304 if (isset($_SERVER['HTTP_IF_NONE_MATCH']))
305 $client_have = $_SERVER['HTTP_IF_NONE_MATCH'];
306 else
307 $client_have = '';
303 while (1) {
304 $we_have = sha1($_c);
305 if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
306 $client_have = $_SERVER['HTTP_IF_NONE_MATCH'];
307
308 if (strcmp($client_have, $we_have) == 0) {
309 rg_log('CACHE: Client has the latest version; no need to resend');
310 header($proto . ' 304 Not modified');
311 break;
312 }
313 }
308 314
309 if (strcmp($client_have, $we_have) == 0) {
310 rg_log('CACHE: Client has the latest version; no need to resend');
311 header($proto . ' 304 Not modified');
312 } else {
313 315 header('ETag: ' . $we_have); header('ETag: ' . $we_have);
314 echo $_c;
316 rg_web_output($_c);
317 break;
315 318 } }
316 319 } else { } else {
317 320 rg_log('WARN: Un-handled protocol [' . $proto . ']'); rg_log('WARN: Un-handled protocol [' . $proto . ']');
318 echo $_c;
321 rg_web_output($_c);
319 322 } }
320 323
321 324 rg_prof_end("MAIN"); rg_prof_end("MAIN");
322 325 rg_prof_log(); rg_prof_log();
323 ?>
326
File root/themes/default/admin/ldap/list/nodata.html changed (mode: 100644) (index c13be03..76ad64a)
1 <div class="mess warning">
1 <div class="mess ok">
2 2 No LDAP servers defined yet. No LDAP servers defined yet.
3 3 </div> </div>
File root/themes/default/admin/plans/list/nodata.html changed (mode: 100644) (index adc3941..c244dee)
1 <div class="mess warning">
1 <div class="mess ok">
2 2 No plans defined yet. No plans defined yet.
3 3 </div> </div>
File root/themes/default/builder/cmds/nodata.html changed (mode: 100644) (index d07767a..14144b1)
1 <div class="mess warning">
1 <div class="mess ok">
2 2 No commands present. No commands present.
3 3 </div> </div>
File root/themes/default/builder/queue/nodata.html changed (mode: 100644) (index abe6ca0..8f55511)
1 <div class="mess warning">
1 <div class="mess ok">
2 2 No build jobs in queue. No build jobs in queue.
3 3 </div> </div>
File root/themes/default/features.html changed (mode: 100644) (index c9543b8..b7402c1)
101 101 in Amazon, or call a in Amazon, or call a
102 102 <a href="https://aws.amazon.com/lambda/" target="_blank">Lambda</a> <a href="https://aws.amazon.com/lambda/" target="_blank">Lambda</a>
103 103 function. function.
104 Be notified in <a href="https://slack.com" target="_blank">Slack</a>.
104 Be notified in <a href="https://matrix.org" target="_blank">Matrix</a> or
105 <a href="https://slack.com" target="_blank">Slack</a>.
105 106 Or call a PHP script on your server. Or call a PHP script on your server.
106 107 You can filter by repository/branch name (regex). You can filter by repository/branch name (regex).
107 108 </div> </div>
File root/themes/default/main.css changed (mode: 100644) (index 8022819..ea98f7f)
... ... table {
21 21 background-color: #eee; background-color: #eee;
22 22 color: #000; color: #000;
23 23 padding: 1px; padding: 1px;
24 width: 100%;
25 24 } }
26 25
27 26 th, td { th, td {
 
... ... legend { padding: 0px 2pt; }
268 267 margin-top: 3pt; margin-top: 3pt;
269 268 } }
270 269
271 .diff {}
270 .diff {
271 margin-top: 2pt;
272 }
272 273
273 274 .chunk { .chunk {
274 275 width: 100%; width: 100%;
 
... ... legend { padding: 0px 2pt; }
554 555 } }
555 556
556 557 .table_log {} .table_log {}
557 .table_log:not(:first-child) {
558 margin-top: 6pt;
559 }
560 558
561 559 .conflicts { .conflicts {
562 560 padding: 2pt; padding: 2pt;
 
... ... legend { padding: 0px 2pt; }
616 614 padding: 5px; padding: 5px;
617 615 height: auto; height: auto;
618 616 } }
617
618 .commit_body {
619 padding: 3pt;
620 margin-left: 3pt;
621 background-color: #eee;
622 display: table;
623 }
624
625 .list_of_commits {
626 margin-top: 8pt;
627 }
628
629 .list_of_commits_details {
630 margin-top: 8pt;
631 }
632
633 .commit_details {
634 padding: 3pt;
635 background-color: #ddd;
636 }
637 .commit_details:not(:first-child) {
638 margin-top: 8pt;
639 }
File root/themes/default/repo/commit.html added (mode: 100644) (index 0000000..1a44a8a)
1 <hr>
2 <br />
3 <hr>
4
5 @@commit_table@@
6
7
8 @@commit_labels@@
File root/themes/default/repo/commits/footer.html added (mode: 100644) (index 0000000..5ed7600)
1
2 @@commit_labels@@
3
4 </div>
File root/themes/default/repo/commits/header.html added (mode: 100644) (index 0000000..e60290a)
1 @@commit_table@@
2
3 <div class="list_of_commits_details">
4
File root/themes/default/repo/commits/line.html added (mode: 100644) (index 0000000..2eb6a17)
1 <div class="commit_details">
2 <b><a name="sha1-@@vars::sha1@@">Commit @@vars::sha1@@</a></b>
3 - @@vars::subject@@<br />
4
5 @@vars::x_body@@
6
7 <b>Author</b>: @@vars::author name@@<br />
8 <b>Author date (UTC)</b>: @@vars::x_author date@@<br >
9 <b>Committer name</b>: @@vars::committer name@@<br />
10 <b>Committer date (UTC)</b>: @@vars::x_committer date@@<br />
11 <b>Parent(s)</b>: @@vars::parents@@<br />
12 <b>Signing key</b>: @@vars::sign_key@@<br />
13 <b>Tree</b>: @@vars::tree@@<br />
14
15 @@x_stats@@
16
17 @@x_diff@@
18 </div>
19
File root/themes/default/repo/commits/nodata.html copied from file root/themes/default/repo/log/nodata.html (similarity 100%)
File root/themes/default/repo/err/diff.html copied from file root/themes/default/builder/cmds/nodata.html (similarity 60%) (mode: 100644) (index d07767a..e699594)
1 1 <div class="mess warning"> <div class="mess warning">
2 No commands present.
2 Cannot generate diff.
3 3 </div> </div>
File root/themes/default/repo/err/stats.html copied from file root/themes/default/builder/cmds/nodata.html (similarity 59%) (mode: 100644) (index d07767a..58a3e84)
1 1 <div class="mess warning"> <div class="mess warning">
2 No commands present.
2 Cannot generate stats.
3 3 </div> </div>
File root/themes/default/repo/log/footer.html changed (mode: 100644) (index 000ca4b..4518f02)
1 </table>
1 </table>
2 </div>
3
File root/themes/default/repo/log/header.html changed (mode: 100644) (index 058cc9d..78672e9)
1 <table class="table_log">
2 <tr>
3 <th>Subject</th>
4 <th>SHA-1</th>
5 <th>Author</th>
6 <th>Date</th>
7 </tr>
1 <div class="list_of_commits">
2
3 <span><b>List of commits</b>:</span>
4 <table class="table_log">
5 <tr>
6 <th>Subject</th>
7 <th>SHA-1 (click to jump to commit)</th>
8 <th>Author</th>
9 <th>Date</th>
10 </tr>
11
File root/themes/default/repo/log/line.html changed (mode: 100644) (index efcf769..cb19dbd)
1 <tr>
2 <td>@@subject@@</td>
3 <td><a href="@@if("@@commit_url@@" != ""){{@@commit_url@@}}{{@@url_repo@@/source/log/commit/@@sha1@@}}">@@sha1@@</a></td>
4 <td>@@author name@@</td>
5 <td>@@author date UTC@@</td>
6 </tr>
1 <tr>
2 <td>@@subject@@</td>
3 <td><a href="@@if("@@commit_url@@" != ""){{@@commit_url@@}}{{@@url_repo@@/source/log/commit/@@sha1@@}}">@@sha1@@</a></td>
4 <td>@@author name@@</td>
5 <td>@@author date UTC@@</td>
6 </tr>
File root/themes/default/repo/mr/page.html changed (mode: 100644) (index df3a7ff..f0f3edf)
9 9 @@if(@@mr::merge_in_progress@@ == 1){{ @@if(@@mr::merge_in_progress@@ == 1){{
10 10 @@if(@@mr::already_merged@@ == 1){{ @@if(@@mr::already_merged@@ == 1){{
11 11 <div class="merge_status merge_status_ok"> <div class="merge_status merge_status_ok">
12 Already merged at @mr::done_nice@@.
12 Already merged at @@mr::done_nice@@.
13 13 </div> </div>
14 14 }} }}
15 15 }}{{ }}{{
 
39 39 </div> </div>
40 40 }}{{ }}{{
41 41 <div class="merge_status merge_status_nok"> <div class="merge_status merge_status_nok">
42 This pull request cannot be merged without conflicts.<br />
42 This merge request cannot be merged without conflicts.<br />
43 43 </div> </div>
44 44 }} }}
45 45 }} }}
File samples/nginx.conf changed (mode: 100644) (index 2fec745..a941e89)
... ... server {
17 17 # timeouts # timeouts
18 18 client_body_timeout 10; client_body_timeout 10;
19 19 client_header_timeout 10; client_header_timeout 10;
20 keepalive_timeout 10;
20 keepalive_timeout 30;
21 21 send_timeout 10; send_timeout 10;
22 22
23 23 # Security (ClickJacking) # Security (ClickJacking)
 
... ... server {
83 83 # timeouts # timeouts
84 84 client_body_timeout 10; client_body_timeout 10;
85 85 client_header_timeout 10; client_header_timeout 10;
86 keepalive_timeout 10;
86 keepalive_timeout 30;
87 87 send_timeout 10; send_timeout 10;
88 88
89 89 # Security (ClickJacking) # Security (ClickJacking)
File scripts/cache.php changed (mode: 100644) (index 9e8b40a..48d9884)
... ... require_once($INC . "/ver.php");
30 30
31 31 function rg_destroy($k, &$conn_table) function rg_destroy($k, &$conn_table)
32 32 { {
33 rg_log("Destroying key $k...");
33 rg_log($k . ": Destroying");
34 34 if (isset($conn_table['r'][$k])) if (isset($conn_table['r'][$k]))
35 35 unset($conn_table['r'][$k]); unset($conn_table['r'][$k]);
36 36 if (isset($conn_table['w'][$k])) if (isset($conn_table['w'][$k]))
 
... ... function rg_destroy($k, &$conn_table)
44 44
45 45 function rg_handle_command($k, &$conn_table, $cmd) function rg_handle_command($k, &$conn_table, $cmd)
46 46 { {
47 //rg_log("rg_handle_command: k=$k, cmd=$cmd");
47 //rg_log($k . ": handle_command: cmd=$cmd");
48 48
49 49 $s = &$conn_table['conns'][$k]; $s = &$conn_table['conns'][$k];
50 50
 
... ... function rg_handle_command($k, &$conn_table, $cmd)
60 60
61 61 $flags = trim($a[1]); $flags = trim($a[1]);
62 62 if (strncmp($flags, 'F=', 2) != 0) { if (strncmp($flags, 'F=', 2) != 0) {
63 rg_log('Invalid command (no flags): $cmd');
63 rg_log($k . ': Invalid command (no flags): $cmd');
64 64 break; break;
65 65 } }
66 66 $flags = substr($flags, 2); $flags = substr($flags, 2);
 
... ... function rg_handle_command($k, &$conn_table, $cmd)
69 69
70 70 $id = trim($a[2]); $id = trim($a[2]);
71 71 if (strncmp($id, 'I=', 2) != 0) { if (strncmp($id, 'I=', 2) != 0) {
72 rg_log('Invalid command (no id): $cmd');
72 rg_log($k . ': Invalid command (no id): $cmd');
73 73 break; break;
74 74 } }
75 75 $id = substr($id, 2); $id = substr($id, 2);
 
... ... function rg_handle_command($k, &$conn_table, $cmd)
88 88 break; break;
89 89 $ns_var = trim($ns_var_value[0]); $ns_var = trim($ns_var_value[0]);
90 90 $value = trim($ns_var_value[1]); $value = trim($ns_var_value[1]);
91 $value = unserialize(stripcslashes($value));
91 $value = rg_unserialize($value);
92 92 if ($value !== FALSE) { if ($value !== FALSE) {
93 93 rg_cache_core_set("normal::" . $ns_var, $value); rg_cache_core_set("normal::" . $ns_var, $value);
94 94 $buf = 'OK ' . $id . "\n"; $buf = 'OK ' . $id . "\n";
 
... ... function rg_handle_command($k, &$conn_table, $cmd)
104 104 break; break;
105 105 $ns_var = trim($ns_var_value[0]); $ns_var = trim($ns_var_value[0]);
106 106 $value = trim($ns_var_value[1]); $value = trim($ns_var_value[1]);
107 $value = unserialize(stripcslashes($value));
107 $value = rg_unserialize($value);
108 108 if ($value !== FALSE) { if ($value !== FALSE) {
109 109 $ret = rg_cache_core_merge("normal::" . $ns_var, $ret = rg_cache_core_merge("normal::" . $ns_var,
110 110 $value); $value);
 
... ... function rg_handle_command($k, &$conn_table, $cmd)
157 157 break; break;
158 158 $ns_var = trim($ns_var_value[0]); $ns_var = trim($ns_var_value[0]);
159 159 $value = trim($ns_var_value[1]); $value = trim($ns_var_value[1]);
160 $value = unserialize(stripcslashes($value));
160 $value = rg_unserialize($value);
161 161 if ($value !== FALSE) { if ($value !== FALSE) {
162 162 rg_cache_core_apush("normal::" . $ns_var, $value); rg_cache_core_apush("normal::" . $ns_var, $value);
163 163 $buf = 'OK ' . $id . "\n"; $buf = 'OK ' . $id . "\n";
 
... ... function rg_handle_command($k, &$conn_table, $cmd)
186 186 } }
187 187
188 188 if (strcmp($cmd, "SHUTDOWN") == 0) { if (strcmp($cmd, "SHUTDOWN") == 0) {
189 rg_log('Shutting down...');
189 rg_log($k . ': Shutting down...');
190 190 exit(0); exit(0);
191 191 } }
192 192
193 193 if (strcmp($cmd, "SLEEP") == 0) { if (strcmp($cmd, "SLEEP") == 0) {
194 rg_log('Sleeping...');
194 rg_log($k . ': Sleeping...');
195 195 $buf = 'OK ' . $id . "\n"; $buf = 'OK ' . $id . "\n";
196 196 sleep(3); sleep(3);
197 197 } }
 
... ... function rg_handle_command($k, &$conn_table, $cmd)
200 200 } }
201 201
202 202 if ($no_wait === FALSE) { if ($no_wait === FALSE) {
203 rg_log($k . ':DEBUG: enqueue: ' . $buf);
203 rg_log($k . ': DEBUG: enqueue: ' . $buf);
204 204 $s['send'] .= $buf; $s['send'] .= $buf;
205 205 $conn_table['w'][$k] = $s['socket']; $conn_table['w'][$k] = $s['socket'];
206 206 } }
 
... ... function rg_handle_command($k, &$conn_table, $cmd)
208 208
209 209 function rg_handle_recv($k, &$conn_table) function rg_handle_recv($k, &$conn_table)
210 210 { {
211 //rg_log("handle_recv on key $k...");
211 //rg_log($k . ": handle_recv");
212 212 $s = &$conn_table['conns'][$k]; $s = &$conn_table['conns'][$k];
213 213
214 214 $ret = @socket_recv($s['socket'], $buf, 32 * 4096, 0); $ret = @socket_recv($s['socket'], $buf, 32 * 4096, 0);
215 215 if ($ret === FALSE) { if ($ret === FALSE) {
216 rg_log("Error in recv (" . socket_strerror(socket_last_error()) . ")");
216 rg_log($k . ": Error in recv (" . socket_strerror(socket_last_error()) . ")");
217 217 rg_destroy($k, $conn_table); rg_destroy($k, $conn_table);
218 218 return; return;
219 219 } }
220 220 if ($ret === 0) { if ($ret === 0) {
221 rg_log("Remote closed the connection (received 0).");
221 rg_log($k . ": Remote closed the connection (received 0).");
222 222 rg_destroy($k, $conn_table); rg_destroy($k, $conn_table);
223 223 return; return;
224 224 } }
225 225
226 rg_log($k . ':DEBUG: received: ' . $buf);
226 rg_log($k . ': DEBUG: received: ' . $buf);
227 227
228 228 $s['recv'] .= $buf; $s['recv'] .= $buf;
229 229 $s['close_at'] = time() + 30; $s['close_at'] = time() + 30;
 
... ... function rg_handle_recv($k, &$conn_table)
242 242
243 243 function rg_handle_send($k, &$conn_table) function rg_handle_send($k, &$conn_table)
244 244 { {
245 //rg_log("Sending on key $k...");
245 //rg_log($k . ": Sending...");
246 246 $s = &$conn_table['conns'][$k]; $s = &$conn_table['conns'][$k];
247 247
248 248 $ret = @socket_send($s['socket'], $s['send'], strlen($s['send']), 0); $ret = @socket_send($s['socket'], $s['send'], strlen($s['send']), 0);
249 249 if ($ret === FALSE) { if ($ret === FALSE) {
250 rg_log("Cannot send (" . socket_strerror(socket_last_error()) . ")");
250 rg_log($k . ": Cannot send (" . socket_strerror(socket_last_error()) . ")");
251 251 rg_destroy($k, $conn_table); rg_destroy($k, $conn_table);
252 252 return; return;
253 253 } }
 
... ... function rg_handle_new($client, &$conn_table)
269 269 "close_at" => time() + 30 "close_at" => time() + 30
270 270 ); );
271 271 $conn_table['r'][$key] = $client; $conn_table['r'][$key] = $client;
272 //rg_log("Added client with key $key.");
272 //rg_log($key . ": Added client");
273 273
274 274 /* This way I can enforce the connecting user to be apache/rocketgit /* This way I can enforce the connecting user to be apache/rocketgit
275 275 but is seems it does not work correctly in PHP... but is seems it does not work correctly in PHP...
 
... ... function rg_handle_idle(&$conn_table)
288 288 continue; continue;
289 289 } }
290 290 if ($info['close_at'] < $now) { if ($info['close_at'] < $now) {
291 rg_log("Destroy $key because has been too much time idle.");
291 rg_log($key . ": Destroy key because has been too much time idle.");
292 292 rg_destroy($key, $conn_table); rg_destroy($key, $conn_table);
293 293 } }
294 294 } }
File scripts/events.php changed (mode: 100644) (index 4b168ee..a15352c)
... ... do {
113 113 // will restart. // will restart.
114 114 clearstatcache(); clearstatcache();
115 115 $mtime = @filemtime(__FILE__); $mtime = @filemtime(__FILE__);
116 rg_log("mtime=$mtime, original_mtime=$original_mtime");
117 116 if ($mtime != $original_mtime) { if ($mtime != $original_mtime) {
117 rg_log("mtime=$mtime, original_mtime=$original_mtime");
118 118 rg_log("File changed. Exiting..."); rg_log("File changed. Exiting...");
119 119 break; break;
120 120 } }
 
... ... do {
123 123 do { do {
124 124 // check machine load - if too big we will delay // check machine load - if too big we will delay
125 125 $load = rg_load(); $load = rg_load();
126 if ($load > 100) {
126 if ($load > 200) {
127 127 rg_log("Load too big! Skip queue processing."); rg_log("Load too big! Skip queue processing.");
128 128 break; break;
129 129 } }
 
... ... do {
168 168
169 169 $r = @socket_recv($sock, $buf, 1024, 0); $r = @socket_recv($sock, $buf, 1024, 0);
170 170 if ($r === FALSE) { if ($r === FALSE) {
171 rg_log('Error in recv: '
171 rg_log($key . ': Error in recv: '
172 172 . socket_strerror(socket_last_error())); . socket_strerror(socket_last_error()));
173 173 rg_destroy($key); rg_destroy($key);
174 174 continue; continue;
175 175 } }
176 176 if ($r === 0) { // remote close the connection if ($r === 0) { // remote close the connection
177 rg_log("Remote closed the connection (received 0).");
177 rg_log($key . ": Remote closed the connection (received 0).");
178 178 rg_destroy($key); rg_destroy($key);
179 179 continue; continue;
180 180 } }
 
... ... do {
183 183 $s['recv'] .= $buf; $s['recv'] .= $buf;
184 184 if (!strstr($buf, "\n")) if (!strstr($buf, "\n"))
185 185 continue; continue;
186 rg_log('RECEIVED: ' . $s['recv']);
186 rg_log($key . ': RECEIVED: ' . $s['recv']);
187 187 if (strncmp($s['recv'], 'NOTIFY ', 7) == 0) { if (strncmp($s['recv'], 'NOTIFY ', 7) == 0) {
188 188 $ev_id = trim(substr($s['recv'], 7)); $ev_id = trim(substr($s['recv'], 7));
189 189 $notify_list[$ev_id][] = array( $notify_list[$ev_id][] = array(
 
... ... do {
200 200 $s = &$conn_table['conns'][$key]; $s = &$conn_table['conns'][$key];
201 201 $ret = @socket_send($s['socket'], $s['send'], strlen($s['send']), 0); $ret = @socket_send($s['socket'], $s['send'], strlen($s['send']), 0);
202 202 if ($ret === FALSE) { if ($ret === FALSE) {
203 rg_log("Cannot send: " . socket_strerror(socket_last_error()));
203 rg_log($key . ": Cannot send: " . socket_strerror(socket_last_error()));
204 204 rg_destroy($key); rg_destroy($key);
205 205 continue; continue;
206 206 } }
File scripts/remote.php changed (mode: 100644) (index 5a46ced..9efc131)
... ... if (isset($_SERVER['SSH_CONNECTION'])) {
156 156 } }
157 157 } else { } else {
158 158 rg_log("git-daemon connection..."); rg_log("git-daemon connection...");
159 rg_log_ml('_SERVER: ' . print_r($_SERVER, true));
159 160
160 161 // we have no client info // we have no client info
161 162 $login_uid = 0; $login_uid = 0;
 
... ... if (strcmp($_t[0], "user") == 0) {
206 207 $repo = isset($_t[1]) ? $_t[1] : ""; $repo = isset($_t[1]) ? $_t[1] : "";
207 208 } }
208 209
209 rg_log("host=[$host] cmd=[$cmd] prefix=[$prefix] user=[$user] repo=[$repo].");
210 rg_log("ip=[$ip] host=[$host] cmd=[$cmd] prefix=[$prefix] user=[$user] repo=[$repo].");
210 211
211 212 if (strstr($flags, 'W')) { if (strstr($flags, 'W')) {
212 213 // We are a worker, the command may be only for cloning! // We are a worker, the command may be only for cloning!
File scripts/worker.TODO changed (mode: 100644) (index 0d3ded3..5638070)
15 15 And, then, for streaming logs. Maybe for abrupt abort? And, then, for streaming logs. Maybe for abrupt abort?
16 16 [ ] In case of errors, seems the error is not stored in Settings/Workers/List. [ ] In case of errors, seems the error is not stored in Settings/Workers/List.
17 17 Instead, it seems that everything was ok. :( Instead, it seems that everything was ok. :(
18 [ ] 'status' per cmd seems to not be set.
18 19 [ ] Log repo/branch/etc. which triggered the webhook. [ ] Log repo/branch/etc. which triggered the webhook.
19 20 [ ] We need to be able to restart/reload_the_conf at any time. [ ] We need to be able to restart/reload_the_conf at any time.
20 21 Think about raising the number of machines in the pool. Think about raising the number of machines in the pool.
 
23 24 [ ] Activate AppArmor with a custom profile. [ ] Activate AppArmor with a custom profile.
24 25 [ ] About resources availability: who is able to set them? [ ] About resources availability: who is able to set them?
25 26 The web interface of the worker? I think the worker. The web interface of the worker? I think the worker.
26 [ ] Log what project and what branch triggered the build.
27 27 [ ] Add notification channels to be able to notify if the build was ok/bad. [ ] Add notification channels to be able to notify if the build was ok/bad.
28 28 At least notify the project owner. At least notify the project owner.
29 29 [ ] Take load in consideration? [ ] Take load in consideration?
 
31 31 [ ] Specify a global max pool size? [ ] Specify a global max pool size?
32 32 [ ] When strting, load all $conf['state'] . '/job-*.ser' files and send a DON [ ] When strting, load all $conf['state'] . '/job-*.ser' files and send a DON
33 33 command to the server. command to the server.
34 [ ]
34 [ ]
File scripts/worker.php changed (mode: 100644) (index 7238259..fad4cd7)
... ... function save_job($job)
152 152 while (1) { while (1) {
153 153 $j_job = @json_encode($job); $j_job = @json_encode($job);
154 154 if ($j_job === FALSE) { if ($j_job === FALSE) {
155 $ret['errstr'] = 'cannot encode json: ' . json_last_error();
155 $ret['errstr'] = 'cannot encode json: ' . json_last_error_msg();
156 156 break; break;
157 157 } }
158 158
File selinux/build.sh changed (mode: 100755) (index b01eeb8..0a8a2e7)
... ... for type in ${selinux_variants}; do
48 48 done done
49 49
50 50 # Hard link identical policies (thanks, crossfire) # Hard link identical policies (thanks, crossfire)
51 /usr/sbin/hardlink -cv out
51 /usr/bin/hardlink -cv out
52 52
53 53 touch out/done touch out/done
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