File inc/user.inc.php changed (mode: 100644) (index ca0aaa6..bb4f4ac) |
... |
... |
function rg_user_http_git($db, $rg, $paras) |
2406 |
2406 |
. ' realm="Use user \'guest\' if you have no account"'); |
. ' realm="Use user \'guest\' if you have no account"'); |
2407 |
2407 |
echo 'RocketGit: Info: == Welcome to RocketGit! ==' . "\n"; |
echo 'RocketGit: Info: == Welcome to RocketGit! ==' . "\n"; |
2408 |
2408 |
echo 'RocketGit: Info: you are connecting from IP ' . $rg['ip'] . '.' . "\n"; |
echo 'RocketGit: Info: you are connecting from IP ' . $rg['ip'] . '.' . "\n"; |
2409 |
|
echo 'RocketGit: Info: debug id ' . $rg_log_sid . '.' . "\n"; |
|
|
2409 |
|
echo 'RocketGit: Info: date/time: ' . gmdate('Y-m-d H:i:s') |
|
2410 |
|
. ', debug id ' . $rg_log_sid . '.' . "\n"; |
2410 |
2411 |
echo 'RocketGit: Info: Use user \'guest\' with any' |
echo 'RocketGit: Info: Use user \'guest\' with any' |
2411 |
2412 |
. ' password if you want to push anonymously.' . "\n"; |
. ' password if you want to push anonymously.' . "\n"; |
2412 |
2413 |
echo 'RocketGit: Info: Append the login token or the' |
echo 'RocketGit: Info: Append the login token or the' |
|
... |
... |
function rg_user_http_git($db, $rg, $paras) |
2419 |
2420 |
intval($_SERVER['CONTENT_LENGTH']) : 0; |
intval($_SERVER['CONTENT_LENGTH']) : 0; |
2420 |
2421 |
$content_encoding = isset($_SERVER['HTTP_CONTENT_ENCODING']) ? |
$content_encoding = isset($_SERVER['HTTP_CONTENT_ENCODING']) ? |
2421 |
2422 |
$_SERVER['HTTP_CONTENT_ENCODING'] : ''; |
$_SERVER['HTTP_CONTENT_ENCODING'] : ''; |
2422 |
|
rg_log('DEBUG: cl=' . $content_length . ' ce=' . $content_encoding); |
|
|
2423 |
|
rg_log('DEBUG: cl=' . $content_length . ' ce=' . $content_encoding . '.'); |
2423 |
2424 |
|
|
2424 |
2425 |
if (strcmp($file, 'info/refs') == 0) { |
if (strcmp($file, 'info/refs') == 0) { |
2425 |
2426 |
rg_log('DEBUG: info/refs'); |
rg_log('DEBUG: info/refs'); |
|
... |
... |
function rg_user_http_git($db, $rg, $paras) |
2451 |
2452 |
rg_git_info_pack("\x02", '== Welcome to RocketGit! =='); |
rg_git_info_pack("\x02", '== Welcome to RocketGit! =='); |
2452 |
2453 |
rg_git_info_pack("\x02", 'you are connecting from IP ' |
rg_git_info_pack("\x02", 'you are connecting from IP ' |
2453 |
2454 |
. $rg['ip'] . '.'); |
. $rg['ip'] . '.'); |
2454 |
|
rg_git_info_pack("\x02", 'debug id ' . $rg_log_sid . '.'); |
|
|
2455 |
|
rg_git_info_pack("\x02", 'date/time: ' . gmdate('Y-m-d H:i:s') |
|
2456 |
|
. ', debug id ' . $rg_log_sid . '.'); |
2455 |
2457 |
// If user does not connect to the correct URL, correct them |
// If user does not connect to the correct URL, correct them |
2456 |
2458 |
if (!empty($host) && (strcasecmp($host, $rg['hostname']) != 0)) |
if (!empty($host) && (strcasecmp($host, $rg['hostname']) != 0)) |
2457 |
2459 |
rg_git_info_pack("\x02", 'Please use ' . $rg['hostname'] |
rg_git_info_pack("\x02", 'Please use ' . $rg['hostname'] |
|
... |
... |
function rg_user_http_git($db, $rg, $paras) |
2479 |
2481 |
rg_git_info_pack("\x02", '== Welcome to RocketGit! =='); |
rg_git_info_pack("\x02", '== Welcome to RocketGit! =='); |
2480 |
2482 |
rg_git_info_pack("\x02", 'you are connecting from IP ' |
rg_git_info_pack("\x02", 'you are connecting from IP ' |
2481 |
2483 |
. $rg['ip'] . '.'); |
. $rg['ip'] . '.'); |
2482 |
|
rg_git_info_pack("\x02", 'debug id ' . $rg_log_sid . '.'); |
|
|
2484 |
|
rg_git_info_pack("\x02", 'date/time: ' . gmdate('Y-m-d H:i:s') |
|
2485 |
|
. ', debug id ' . $rg_log_sid . '.'); |
2483 |
2486 |
// If user does not connect to the correct URL, correct them |
// If user does not connect to the correct URL, correct them |
2484 |
2487 |
if (!empty($host) && (strcasecmp($host, $rg['hostname']) != 0)) |
if (!empty($host) && (strcasecmp($host, $rg['hostname']) != 0)) |
2485 |
2488 |
rg_git_info_pack("\x02", 'Please use ' . $rg['hostname'] |
rg_git_info_pack("\x02", 'Please use ' . $rg['hostname'] |
File scripts/remote.php changed (mode: 100644) (index 94c82cc..efda942) |
... |
... |
function fatal($str) |
61 |
61 |
|
|
62 |
62 |
|
|
63 |
63 |
rg_log("Start ($rocketgit_version)..."); |
rg_log("Start ($rocketgit_version)..."); |
64 |
|
rg_log("_SERVER: " . rg_array2string($_SERVER)); |
|
65 |
64 |
// DEBUG SELinux |
// DEBUG SELinux |
66 |
65 |
$label = @file_get_contents("/proc/self/attr/current"); |
$label = @file_get_contents("/proc/self/attr/current"); |
67 |
66 |
rg_log("SELINUX: " . $label); |
rg_log("SELINUX: " . $label); |
|
... |
... |
if (isset($_SERVER['SSH_CONNECTION'])) { |
119 |
118 |
|
|
120 |
119 |
info('== Welcome to RocketGit! =='); |
info('== Welcome to RocketGit! =='); |
121 |
120 |
info('you are connecting from IP ' . $ip . '.'); |
info('you are connecting from IP ' . $ip . '.'); |
122 |
|
info('debug id ' . $rg_log_sid . '.'); |
|
|
121 |
|
info('date/time: ' . gmdate('Y-m-d H:i:s') |
|
122 |
|
. ', debug id ' . $rg_log_sid . '.'); |
123 |
123 |
|
|
124 |
124 |
if (strstr($flags, 'N')) { |
if (strstr($flags, 'N')) { |
125 |
125 |
$login_ui = rg_user_info($db, $login_uid, '', ''); |
$login_ui = rg_user_info($db, $login_uid, '', ''); |
|
... |
... |
if (isset($_SERVER['SSH_CONNECTION'])) { |
171 |
171 |
fatal("Too less data ($line_len/$len) received!"); |
fatal("Too less data ($line_len/$len) received!"); |
172 |
172 |
|
|
173 |
173 |
// parse something like: 002bgit-upload-pack /aa.git[0x00]host=localhost:9418[0x00] |
// parse something like: 002bgit-upload-pack /aa.git[0x00]host=localhost:9418[0x00] |
174 |
|
$line = substr($line, 4); |
|
|
174 |
|
$line = substr($line, 4); // skip length |
175 |
175 |
$v = explode("\0", $line); |
$v = explode("\0", $line); |
176 |
176 |
$cmd_repo = trim($v[0]); |
$cmd_repo = trim($v[0]); |
177 |
177 |
$host_port = isset($v[1]) ? trim(substr($v[1], 5)) : ''; |
$host_port = isset($v[1]) ? trim(substr($v[1], 5)) : ''; |
|
... |
... |
if (strncasecmp($cmd_repo, 'git-upload-pack', 15) == 0) { |
190 |
190 |
} |
} |
191 |
191 |
|
|
192 |
192 |
// extract repository name |
// extract repository name |
193 |
|
$_t = substr($cmd_repo, strlen($cmd)); |
|
|
193 |
|
$_t = substr($cmd_repo, strlen($cmd)); // skip cmd |
194 |
194 |
$_t = trim($_t, "' "); |
$_t = trim($_t, "' "); |
195 |
195 |
$_t = ltrim($_t, "/"); |
$_t = ltrim($_t, "/"); |
196 |
196 |
$_t = preg_replace('/\.git$/' , '', $_t); |
$_t = preg_replace('/\.git$/' , '', $_t); |
|
... |
... |
if (strcmp($_t[0], "user") == 0) { |
208 |
208 |
rg_log("host=[$host] cmd=[$cmd] prefix=[$prefix] user=[$user] repo=[$repo]."); |
rg_log("host=[$host] cmd=[$cmd] prefix=[$prefix] user=[$user] repo=[$repo]."); |
209 |
209 |
|
|
210 |
210 |
if (strstr($flags, 'W')) { |
if (strstr($flags, 'W')) { |
211 |
|
// We are a worker, the command may be only for clonning! |
|
|
211 |
|
// We are a worker, the command may be only for cloning! |
212 |
212 |
if (strcmp($cmd, 'git-upload-pack') != 0) |
if (strcmp($cmd, 'git-upload-pack') != 0) |
213 |
213 |
fatal('A worker can only clone!'); |
fatal('A worker can only clone!'); |
214 |
214 |
} |
} |