File inc/repo.inc.php changed (mode: 100644) (index 8f66464..d464841) |
... |
... |
function rg_repo_fetch_push_helper($db, $host, $ip, $login_ui, $prefix, $user, |
2428 |
2428 |
$needed_rights = 'P|H'; |
$needed_rights = 'P|H'; |
2429 |
2429 |
$ret['push'] = 1; |
$ret['push'] = 1; |
2430 |
2430 |
} else { |
} else { |
2431 |
|
$ret['error'] = 'Unknown command'; |
|
|
2431 |
|
$ret['error'] = 'unknown command'; |
2432 |
2432 |
break; |
break; |
2433 |
2433 |
} |
} |
2434 |
2434 |
|
|
2435 |
2435 |
// Validity/security checks |
// Validity/security checks |
2436 |
2436 |
// Load info about the owner |
// Load info about the owner |
2437 |
2437 |
if (rg_user_ok($user) !== TRUE) { |
if (rg_user_ok($user) !== TRUE) { |
2438 |
|
$ret['error'] = 'User is invalid (' . rg_user_error() . ')'; |
|
|
2438 |
|
$ret['error'] = 'user is invalid (' . rg_user_error() . ')'; |
2439 |
2439 |
break; |
break; |
2440 |
2440 |
} |
} |
2441 |
2441 |
$ret['owner_ui'] = rg_user_info($db, 0, $user, ''); |
$ret['owner_ui'] = rg_user_info($db, 0, $user, ''); |
2442 |
2442 |
if ($ret['owner_ui']['ok'] != 1) { |
if ($ret['owner_ui']['ok'] != 1) { |
2443 |
|
$ret['error'] = 'Internal problems; try again later, please'; |
|
|
2443 |
|
$ret['error'] = 'internal problems; try again later, please'; |
2444 |
2444 |
break; |
break; |
2445 |
2445 |
} |
} |
2446 |
2446 |
if ($ret['owner_ui']['exists'] != 1) { |
if ($ret['owner_ui']['exists'] != 1) { |
2447 |
|
$ret['error'] = 'User does not exists'; |
|
|
2447 |
|
$ret['error'] = 'user does not exists'; |
2448 |
2448 |
break; |
break; |
2449 |
2449 |
} |
} |
2450 |
2450 |
|
|
|
... |
... |
function rg_repo_fetch_push_helper($db, $host, $ip, $login_ui, $prefix, $user, |
2452 |
2452 |
|
|
2453 |
2453 |
// Loading info about the repository |
// Loading info about the repository |
2454 |
2454 |
if (rg_repo_ok($repo) !== TRUE) { |
if (rg_repo_ok($repo) !== TRUE) { |
2455 |
|
$ret['error'] = 'Repository is invalid (' |
|
|
2455 |
|
$ret['error'] = 'repository is invalid (' |
2456 |
2456 |
. rg_repo_error() . ')'; |
. rg_repo_error() . ')'; |
2457 |
2457 |
break; |
break; |
2458 |
2458 |
} |
} |
2459 |
2459 |
$ret['ri'] = rg_repo_info($db, 0, $ret['owner_ui']['uid'], $repo); |
$ret['ri'] = rg_repo_info($db, 0, $ret['owner_ui']['uid'], $repo); |
2460 |
2460 |
if ($ret['ri']['ok'] != 1) { |
if ($ret['ri']['ok'] != 1) { |
2461 |
|
$ret['error'] = 'Internal problems; try again later, please'; |
|
|
2461 |
|
$ret['error'] = 'internal problems; try again later, please'; |
2462 |
2462 |
break; |
break; |
2463 |
2463 |
} |
} |
2464 |
2464 |
if ($ret['ri']['exists'] != 1) { |
if ($ret['ri']['exists'] != 1) { |
2465 |
|
$ret['error'] = 'Repository does not exists'; |
|
|
2465 |
|
$ret['error'] = 'repository does not exists'; |
2466 |
2466 |
break; |
break; |
2467 |
2467 |
} |
} |
2468 |
2468 |
if ($ret['ri']['deleted'] == 1) { |
if ($ret['ri']['deleted'] == 1) { |
2469 |
|
$ret['error'] = 'Repository has been deleted'; |
|
|
2469 |
|
$ret['error'] = 'repository has been deleted'; |
2470 |
2470 |
break; |
break; |
2471 |
2471 |
} |
} |
2472 |
2472 |
|
|
2473 |
2473 |
$ls = rg_repo_lock_status($db, $ret['ri']['repo_id']); |
$ls = rg_repo_lock_status($db, $ret['ri']['repo_id']); |
2474 |
2474 |
if ($ls['ok'] != 1) { |
if ($ls['ok'] != 1) { |
2475 |
|
$ret['error'] = 'Could not get lock status: ' . rg_repo_error(); |
|
|
2475 |
|
$ret['error'] = 'could not get lock status: ' . rg_repo_error(); |
2476 |
2476 |
break; |
break; |
2477 |
2477 |
} |
} |
2478 |
2478 |
if (($ls['status'] == 1) && ($login_ui['uid'] != $ls['uid'])) { |
if (($ls['status'] == 1) && ($login_ui['uid'] != $ls['uid'])) { |
|
... |
... |
function rg_repo_fetch_push_helper($db, $host, $ip, $login_ui, $prefix, $user, |
2481 |
2481 |
$_user = $_u['username']; |
$_user = $_u['username']; |
2482 |
2482 |
else |
else |
2483 |
2483 |
$_user = '?'; |
$_user = '?'; |
2484 |
|
$ret['error'] = 'Repository has been locked user ' . $_user |
|
2485 |
|
. ' at ' . gmdate('Y-m-d H:i', $ls['itime']) . ' UTC.' |
|
2486 |
|
. ' Reason: ' . $ls['reason']; |
|
|
2484 |
|
$ret['error'] = 'repository has been locked user ' . $_user |
|
2485 |
|
. ' at ' . gmdate('Y-m-d H:i', $ls['itime']) . ' UTC;' |
|
2486 |
|
. ' reason: ' . $ls['reason']; |
2487 |
2487 |
break; |
break; |
2488 |
2488 |
} |
} |
2489 |
2489 |
|
|
|
... |
... |
function rg_repo_fetch_push_helper($db, $host, $ip, $login_ui, $prefix, $user, |
2507 |
2507 |
$r = rg_rights_allow($db, $x); |
$r = rg_rights_allow($db, $x); |
2508 |
2508 |
// TODO: what if an error occured? How we signal this?! |
// TODO: what if an error occured? How we signal this?! |
2509 |
2509 |
if ($r !== TRUE) { |
if ($r !== TRUE) { |
2510 |
|
$ret['error'] = 'You have no rights to access this repo'; |
|
|
2510 |
|
$ret['error'] = 'non existing repo or you are not allowed to push'; |
2511 |
2511 |
break; |
break; |
2512 |
2512 |
} |
} |
2513 |
2513 |
|
|
|
... |
... |
function rg_repo_fetch_push_helper($db, $host, $ip, $login_ui, $prefix, $user, |
2552 |
2552 |
// free space?! |
// free space?! |
2553 |
2553 |
// We should mark the repo over limit when we compute |
// We should mark the repo over limit when we compute |
2554 |
2554 |
// the disk space - same problem |
// the disk space - same problem |
2555 |
|
$ret['error'] = 'Cannot push: user is over limit' |
|
|
2555 |
|
$ret['error'] = 'cannot push: user is over limit' |
2556 |
2556 |
. ' (' . $ret['owner_ui']['disk_used_mb'] . 'MiB >= ' |
. ' (' . $ret['owner_ui']['disk_used_mb'] . 'MiB >= ' |
2557 |
2557 |
. $max . 'MiB)'; |
. $max . 'MiB)'; |
2558 |
2558 |
break; |
break; |
|
... |
... |
function rg_repo_fetch_push_helper($db, $host, $ip, $login_ui, $prefix, $user, |
2584 |
2584 |
$dst = $repo_path . '/refs/namespaces/' . $namespace . '/refs'; |
$dst = $repo_path . '/refs/namespaces/' . $namespace . '/refs'; |
2585 |
2585 |
$r = rg_copy_tree($repo_path . '/refs/heads', $dst . '/heads/', 0700); |
$r = rg_copy_tree($repo_path . '/refs/heads', $dst . '/heads/', 0700); |
2586 |
2586 |
if ($r !== TRUE) { |
if ($r !== TRUE) { |
2587 |
|
$ret['error'] = 'Internal error (cannot copy heads)'; |
|
|
2587 |
|
$ret['error'] = 'internal error (cannot copy heads refs)'; |
2588 |
2588 |
break; |
break; |
2589 |
2589 |
} |
} |
2590 |
2590 |
$r = rg_copy_tree($repo_path . '/refs/tags', |
$r = rg_copy_tree($repo_path . '/refs/tags', |
2591 |
2591 |
$dst . '/tags/', 0700); |
$dst . '/tags/', 0700); |
2592 |
2592 |
if ($r !== TRUE) { |
if ($r !== TRUE) { |
2593 |
2593 |
$ret['error'] = |
$ret['error'] = |
2594 |
|
'Internal error (cannot copy tags)'; |
|
|
2594 |
|
'internal error (cannot copy tags refs)'; |
2595 |
2595 |
break; |
break; |
2596 |
2596 |
} |
} |
2597 |
2597 |
} |
} |