File TODO changed (mode: 100644) (index 5977031..14b15a7) |
1 |
1 |
== Where I stopped last time == |
== Where I stopped last time == |
2 |
2 |
[ ] Add "Spread the word!" on website. |
[ ] Add "Spread the word!" on website. |
3 |
3 |
|
|
|
4 |
|
[ ] https access before first launch? |
4 |
5 |
[ ] Check 'description_nice' and apply this everywhere. Maybe we should unset |
[ ] Check 'description_nice' and apply this everywhere. Maybe we should unset |
5 |
6 |
'description', so people will not be tempted to use it. |
'description', so people will not be tempted to use it. |
6 |
7 |
Maybe just overwrite 'description'. |
Maybe just overwrite 'description'. |
|
11 |
12 |
Nu e OK. Trebuie doar pentru anumite cazuri: la o descriere pe pagina |
Nu e OK. Trebuie doar pentru anumite cazuri: la o descriere pe pagina |
12 |
13 |
proiectului, e nevoie. Dar intr-un form, in textarea, nu e nevoie. |
proiectului, e nevoie. Dar intr-un form, in textarea, nu e nevoie. |
13 |
14 |
Apoi as putea elimina description_nice. |
Apoi as putea elimina description_nice. |
|
15 |
|
Deci, cred ca trebuie sa auditez peste tot folosirea lui description. |
14 |
16 |
[ ] Upload kvm image to downloads.rocketgit.com. Sign it? sha256 it? |
[ ] Upload kvm image to downloads.rocketgit.com. Sign it? sha256 it? |
15 |
17 |
[ ] Security: validate sparas! |
[ ] Security: validate sparas! |
16 |
18 |
[ ] Menus - change color for selected items, not the background color. |
[ ] Menus - change color for selected items, not the background color. |
|
20 |
22 |
Probabil socket-ul nu mai e deschis pentru ca cache-ul s-a restartat? |
Probabil socket-ul nu mai e deschis pentru ca cache-ul s-a restartat? |
21 |
23 |
[ ] I can do a select before write to be sure socket is open. |
[ ] I can do a select before write to be sure socket is open. |
22 |
24 |
If I get a error signal from select, reopen the socket. |
If I get a error signal from select, reopen the socket. |
|
25 |
|
[ ] Check search. |
23 |
26 |
[ ] SPF? mail-ul ajunge in spam! |
[ ] SPF? mail-ul ajunge in spam! |
24 |
27 |
[ ] Release virtual machine. |
[ ] Release virtual machine. |
25 |
28 |
[ ] |
[ ] |
26 |
29 |
|
|
27 |
30 |
== BEFORE NEXT RELEASE == |
== BEFORE NEXT RELEASE == |
|
31 |
|
[ ] When getting another IP, allow ssh on port 443(https)? |
|
32 |
|
[ ] Investigate --decorate/--word-diff for git log. |
|
33 |
|
[ ] client_win.html hint is not used. |
|
34 |
|
[ ] merge.html hint is not used. |
|
35 |
|
[ ] On create repo form if somebody puts a space, the message does not tell |
|
36 |
|
what chars are invalid/permited (reported by Ionut). |
28 |
37 |
[ ] Avoid alst two err- files at install time. Check if table state exists? |
[ ] Avoid alst two err- files at install time. Check if table state exists? |
29 |
38 |
And cache this info? |
And cache this info? |
30 |
39 |
[ ] Security: Link-uri + xss (Ionut) |
[ ] Security: Link-uri + xss (Ionut) |
|
... |
... |
them after processing is done. |
732 |
741 |
[ ] Internal mailing list? Or internal mail? |
[ ] Internal mailing list? Or internal mail? |
733 |
742 |
[ ] We should have a cron/q/remote for every config file! |
[ ] We should have a cron/q/remote for every config file! |
734 |
743 |
Or, at least, to be host aware. |
Or, at least, to be host aware. |
735 |
|
[ ] It may be needed to use preg_quote! |
|
736 |
744 |
[ ] Install text files in /usr/share/doc |
[ ] Install text files in /usr/share/doc |
737 |
745 |
[ ] JUNK1/JUNK2: http://rg.embedromix.ro:8000/user/catab/rocketgit/commit/afd1df2..f919c9b |
[ ] JUNK1/JUNK2: http://rg.embedromix.ro:8000/user/catab/rocketgit/commit/afd1df2..f919c9b |
738 |
746 |
[ ] rg_log: why the fd is NULL?! |
[ ] rg_log: why the fd is NULL?! |
File inc/git.inc.php changed (mode: 100644) (index f524c9d..02ffd73) |
... |
... |
function rg_git_rev($rev) |
259 |
259 |
function rg_git_reference($refname) |
function rg_git_reference($refname) |
260 |
260 |
{ |
{ |
261 |
261 |
$pattern = "[a-zA-Z0-9^~\/_]"; |
$pattern = "[a-zA-Z0-9^~\/_]"; |
262 |
|
if (preg_match('/^' . $pattern . '$/uD', $refname) === FALSE) { |
|
|
262 |
|
if (preg_match('/^' . $pattern . '$/uD', $refname) !== 1) { |
263 |
263 |
$chars = preg_replace('/' . $pattern . '/', '', $refname); |
$chars = preg_replace('/' . $pattern . '/', '', $refname); |
264 |
264 |
rg_log("git_reference: ref [$refname] contains invalid chars ($chars)"); |
rg_log("git_reference: ref [$refname] contains invalid chars ($chars)"); |
265 |
265 |
return ""; |
return ""; |
|
... |
... |
function rg_git_update_tag($db, $a) |
1021 |
1021 |
rg_prof_start("git_update_tag"); |
rg_prof_start("git_update_tag"); |
1022 |
1022 |
rg_log_enter("git_update_tag: " . rg_array2string($a)); |
rg_log_enter("git_update_tag: " . rg_array2string($a)); |
1023 |
1023 |
|
|
1024 |
|
$ip = $a['ip']; |
|
1025 |
|
$uid = $a['login_uid']; |
|
|
1024 |
|
$x = array(); |
|
1025 |
|
$x['obj_id'] = $a['repo_id']; |
|
1026 |
|
$x['type'] = 'repo_refs'; |
|
1027 |
|
$x['owner'] = $a['repo::uid']; |
|
1028 |
|
$x['uid'] = $a['login_uid']; |
|
1029 |
|
$x['username'] = $a['login_username']; |
|
1030 |
|
$x['needed_rights'] = ''; |
|
1031 |
|
$x['ip'] = $a['ip']; |
|
1032 |
|
$x['misc'] = $a['refname']; |
1026 |
1033 |
|
|
1027 |
1034 |
$history = array(); |
$history = array(); |
1028 |
1035 |
$history['ri::repo_id'] = $a['repo_id']; |
$history['ri::repo_id'] = $a['repo_id']; |
1029 |
|
$history['ui::uid'] = $uid; |
|
|
1036 |
|
$history['ui::uid'] = $a['login_uid']; |
1030 |
1037 |
|
|
1031 |
1038 |
if (strcmp($a['new_rev_type'], "tag") == 0) { // Annotated |
if (strcmp($a['new_rev_type'], "tag") == 0) { // Annotated |
1032 |
1039 |
if (strcmp($a['old_rev'], $rg_git_zero) == 0) { // create |
if (strcmp($a['old_rev'], $rg_git_zero) == 0) { // create |
1033 |
|
if (!rg_rights_allow($db, $a['repo_id'], "repo_refs", $a['repo::uid'], $uid, "S", $ip, $a['refname'])) |
|
|
1040 |
|
$x['needed_rights'] = 'S'; |
|
1041 |
|
if (rg_rights_allow($db, $x) !== TRUE) |
1034 |
1042 |
rg_git_fatal($a['refname'] . "\nNo rights to" |
rg_git_fatal($a['refname'] . "\nNo rights to" |
1035 |
1043 |
. " create an annotated tag."); |
. " create an annotated tag."); |
1036 |
1044 |
$history['history_category'] = REPO_CAT_GIT_ATAG_CREATE; |
$history['history_category'] = REPO_CAT_GIT_ATAG_CREATE; |
|
... |
... |
function rg_git_update_tag($db, $a) |
1038 |
1046 |
rg_repo_history_insert($db, $history); |
rg_repo_history_insert($db, $history); |
1039 |
1047 |
} else if (strcmp($a['new_rev'], $rg_git_zero) == 0) { // delete |
} else if (strcmp($a['new_rev'], $rg_git_zero) == 0) { // delete |
1040 |
1048 |
rg_log("delete ann tag"); |
rg_log("delete ann tag"); |
1041 |
|
if (!rg_rights_allow($db, $a['repo_id'], "repo_refs", $a['repo::uid'], $uid, "n", $ip, $a['refname'])) |
|
|
1049 |
|
$x['needed_rights'] = 'n'; |
|
1050 |
|
if (rg_rights_allow($db, $x) !== TRUE) |
1042 |
1051 |
rg_git_fatal($a['refname'] . "\nNo rights to" |
rg_git_fatal($a['refname'] . "\nNo rights to" |
1043 |
1052 |
. " delete an annotated tag."); |
. " delete an annotated tag."); |
1044 |
1053 |
$history['history_category'] = REPO_CAT_GIT_ATAG_DELETE; |
$history['history_category'] = REPO_CAT_GIT_ATAG_DELETE; |
|
... |
... |
function rg_git_update_tag($db, $a) |
1046 |
1055 |
rg_repo_history_insert($db, $history); |
rg_repo_history_insert($db, $history); |
1047 |
1056 |
} else { // change |
} else { // change |
1048 |
1057 |
rg_log("This seems it cannot happen in recent git."); |
rg_log("This seems it cannot happen in recent git."); |
1049 |
|
if (!rg_rights_allow($db, $a['repo_id'], "repo_refs", $a['repo::uid'], $uid, "S", $ip, $a['refname'])) |
|
|
1058 |
|
$x['needed_rights'] = 'S'; |
|
1059 |
|
if (rg_rights_allow($db, $x) !== TRUE) |
1050 |
1060 |
rg_git_fatal($a['refname'] . "\nNo rights to" |
rg_git_fatal($a['refname'] . "\nNo rights to" |
1051 |
1061 |
. " change an annotated tag."); |
. " change an annotated tag."); |
1052 |
1062 |
$history['history_category'] = REPO_CAT_GIT_ATAG_UPDATE; |
$history['history_category'] = REPO_CAT_GIT_ATAG_UPDATE; |
|
... |
... |
function rg_git_update_tag($db, $a) |
1055 |
1065 |
} |
} |
1056 |
1066 |
} else { // Un-annotated |
} else { // Un-annotated |
1057 |
1067 |
if (strcmp($a['old_rev'], $rg_git_zero) == 0) { // create |
if (strcmp($a['old_rev'], $rg_git_zero) == 0) { // create |
1058 |
|
if (!rg_rights_allow($db, $a['repo_id'], "repo_refs", $a['repo::uid'], $uid, "Y", $ip, $a['refname'])) |
|
|
1068 |
|
$x['needed_rights'] = 'Y'; |
|
1069 |
|
if (rg_rights_allow($db, $x) !== TRUE) |
1059 |
1070 |
rg_git_fatal($a['refname'] . "\nNo rights to" |
rg_git_fatal($a['refname'] . "\nNo rights to" |
1060 |
1071 |
. " create an un-annotated tag."); |
. " create an un-annotated tag."); |
1061 |
1072 |
$history['history_category'] = REPO_CAT_GIT_UTAG_CREATE; |
$history['history_category'] = REPO_CAT_GIT_UTAG_CREATE; |
1062 |
1073 |
$history['history_message'] = 'Un-annotated tag ' . $a['refname'] . ' created (' . $a['new_rev'] . ').'; |
$history['history_message'] = 'Un-annotated tag ' . $a['refname'] . ' created (' . $a['new_rev'] . ').'; |
1063 |
1074 |
rg_repo_history_insert($db, $history); |
rg_repo_history_insert($db, $history); |
1064 |
1075 |
} else if (strcmp($a['new_rev'], $rg_git_zero) == 0) { // delete |
} else if (strcmp($a['new_rev'], $rg_git_zero) == 0) { // delete |
1065 |
|
if (!rg_rights_allow($db, $a['repo_id'], "repo_refs", $a['repo::uid'], $uid, "u", $ip, $a['refname'])) |
|
|
1076 |
|
$x['needed_rights'] = 'u'; |
|
1077 |
|
if (rg_rights_allow($db, $x) !== TRUE) |
1066 |
1078 |
rg_git_fatal($a['refname'] . "\nNo rights to" |
rg_git_fatal($a['refname'] . "\nNo rights to" |
1067 |
1079 |
. " delete an un-annotated tag."); |
. " delete an un-annotated tag."); |
1068 |
1080 |
$history['history_category'] = REPO_CAT_GIT_UTAG_DELETE; |
$history['history_category'] = REPO_CAT_GIT_UTAG_DELETE; |
1069 |
1081 |
$history['history_message'] = 'Un-annotated tag ' . $a['refname'] . ' deleted (' . $a['old_rev'] . ').'; |
$history['history_message'] = 'Un-annotated tag ' . $a['refname'] . ' deleted (' . $a['old_rev'] . ').'; |
1070 |
1082 |
rg_repo_history_insert($db, $history); |
rg_repo_history_insert($db, $history); |
1071 |
1083 |
} else { // change |
} else { // change |
1072 |
|
if (!rg_rights_allow($db, $a['repo_id'], "repo_refs", $a['repo::uid'], $uid, "U", $ip, $a['refname'])) |
|
|
1084 |
|
$x['needed_rights'] = 'U'; |
|
1085 |
|
if (rg_rights_allow($db, $x) !== TRUE) |
1073 |
1086 |
rg_git_fatal($a['refname'] . "\nNo rights to" |
rg_git_fatal($a['refname'] . "\nNo rights to" |
1074 |
1087 |
. " change an un-annotated tag."); |
. " change an un-annotated tag."); |
1075 |
1088 |
$history['history_category'] = REPO_CAT_GIT_UTAG_UPDATE; |
$history['history_category'] = REPO_CAT_GIT_UTAG_UPDATE; |
|
... |
... |
function rg_git_update_branch($db, $a) |
1106 |
1119 |
rg_prof_start("git_update_branch"); |
rg_prof_start("git_update_branch"); |
1107 |
1120 |
rg_log("git_update_branch: " . rg_array2string($a)); |
rg_log("git_update_branch: " . rg_array2string($a)); |
1108 |
1121 |
|
|
1109 |
|
$ip = $a['ip']; |
|
1110 |
|
$uid = $a['login_uid']; |
|
|
1122 |
|
$_x = array(); |
|
1123 |
|
$_x['obj_id'] = $a['repo_id']; |
|
1124 |
|
$_x['type'] = 'repo_refs'; |
|
1125 |
|
$_x['owner'] = $a['repo::uid']; |
|
1126 |
|
$_x['uid'] = $a['login_uid']; |
|
1127 |
|
$_x['username'] = $a['login_username']; |
|
1128 |
|
$_x['needed_rights'] = ''; |
|
1129 |
|
$_x['ip'] = $a['ip']; |
|
1130 |
|
$_x['misc'] = $a['refname']; |
1111 |
1131 |
|
|
1112 |
1132 |
$history = array(); |
$history = array(); |
1113 |
1133 |
$history['ri::repo_id'] = $a['repo_id']; |
$history['ri::repo_id'] = $a['repo_id']; |
1114 |
|
$history['ui::uid'] = $uid; |
|
|
1134 |
|
$history['ui::uid'] = $a['login_uid']; |
1115 |
1135 |
|
|
1116 |
1136 |
if (strcmp($a['new_rev'], $rg_git_zero) == 0) { // delete |
if (strcmp($a['new_rev'], $rg_git_zero) == 0) { // delete |
1117 |
|
if (!rg_rights_allow($db, $a['repo_id'], "repo_refs", $a['repo::uid'], $uid, "D", $ip, $a['refname'])) |
|
|
1137 |
|
$x = $_x; |
|
1138 |
|
$x['needed_rights'] = 'D'; |
|
1139 |
|
if (rg_rights_allow($db, $x) !== TRUE) |
1118 |
1140 |
rg_git_fatal($a['refname'] . "\nNo rights to delete" |
rg_git_fatal($a['refname'] . "\nNo rights to delete" |
1119 |
1141 |
. " a branch."); |
. " a branch."); |
1120 |
1142 |
$history['history_category'] = REPO_CAT_GIT_BRANCH_DELETE; |
$history['history_category'] = REPO_CAT_GIT_BRANCH_DELETE; |
|
... |
... |
function rg_git_update_branch($db, $a) |
1126 |
1148 |
// If we have 'H' (anonymous push), we have also create branch |
// If we have 'H' (anonymous push), we have also create branch |
1127 |
1149 |
$check_fast_forward = 1; |
$check_fast_forward = 1; |
1128 |
1150 |
if (strcmp($a['old_rev'], $rg_git_zero) == 0) { // create |
if (strcmp($a['old_rev'], $rg_git_zero) == 0) { // create |
1129 |
|
if (!rg_rights_allow($db, $a['repo_id'], "repo_refs", $a['repo::uid'], $uid, "H|C", $ip, $a['refname'])) |
|
|
1151 |
|
$x = $_x; |
|
1152 |
|
$x['needed_rights'] = 'H|C'; |
|
1153 |
|
if (rg_rights_allow($db, $x) !== TRUE) |
1130 |
1154 |
rg_git_fatal($a['refname'] . "\nYou have no rights" |
rg_git_fatal($a['refname'] . "\nYou have no rights" |
1131 |
1155 |
. " to create a branch."); |
. " to create a branch."); |
1132 |
1156 |
$check_fast_forward = 0; |
$check_fast_forward = 0; |
|
... |
... |
function rg_git_update_branch($db, $a) |
1134 |
1158 |
|
|
1135 |
1159 |
// Create or change |
// Create or change |
1136 |
1160 |
// Check for non fast-forward update |
// Check for non fast-forward update |
1137 |
|
if (!rg_rights_allow($db, $a['repo_id'], "repo_refs", $a['repo::uid'], $uid, "O", $ip, $a['refname']) |
|
1138 |
|
&& ($check_fast_forward == 1)) { |
|
|
1161 |
|
$x = $_x; |
|
1162 |
|
$x['needed_rights'] = 'O'; |
|
1163 |
|
if ((rg_rights_allow($db, $x) !== TRUE) && ($check_fast_forward == 1)) { |
1139 |
1164 |
$merge_base = rg_git_merge_base($a['old_rev'], $a['new_rev']); |
$merge_base = rg_git_merge_base($a['old_rev'], $a['new_rev']); |
1140 |
1165 |
if ($merge_base === FALSE) { |
if ($merge_base === FALSE) { |
1141 |
1166 |
rg_log("Error in merge_base: " . rg_git_error()); |
rg_log("Error in merge_base: " . rg_git_error()); |
|
... |
... |
function rg_git_update_branch($db, $a) |
1150 |
1175 |
|
|
1151 |
1176 |
// Check if user pushes a merge commit |
// Check if user pushes a merge commit |
1152 |
1177 |
// TODO: Check all commits, not only the last one! |
// TODO: Check all commits, not only the last one! |
1153 |
|
if (!rg_rights_allow($db, $a['repo_id'], "repo_refs", $a['repo::uid'], $uid, "M", $ip, $a['refname'])) { |
|
|
1178 |
|
$x = $_x; |
|
1179 |
|
$x['needed_rights'] = 'M'; |
|
1180 |
|
if (rg_rights_allow($db, $x) !== TRUE) { |
1154 |
1181 |
if (rg_git_rev_ok($a['new_rev'] . "^2")) |
if (rg_git_rev_ok($a['new_rev'] . "^2")) |
1155 |
1182 |
rg_git_fatal($a['refname'] . "\nNo rights to push merges."); |
rg_git_fatal($a['refname'] . "\nNo rights to push merges."); |
1156 |
1183 |
} |
} |
1157 |
1184 |
|
|
1158 |
1185 |
// Check for bad whitespace |
// Check for bad whitespace |
1159 |
|
if (!rg_rights_allow($db, $a['repo_id'], "repo_refs", $a['repo::uid'], $uid, "W", $ip, $a['refname'])) { |
|
|
1186 |
|
$x = $_x; |
|
1187 |
|
$x['needed_rights'] = 'W'; |
|
1188 |
|
if (rg_rights_allow($db, $x) !== TRUE) { |
1160 |
1189 |
// TODO: add caching because we may check again below |
// TODO: add caching because we may check again below |
1161 |
1190 |
$w = rg_git_whitespace_ok($a['old_rev'], $a['new_rev']); |
$w = rg_git_whitespace_ok($a['old_rev'], $a['new_rev']); |
1162 |
1191 |
if ($w !== TRUE) |
if ($w !== TRUE) |
|
... |
... |
function rg_git_update_branch($db, $a) |
1169 |
1198 |
$r = rg_git_files($a['old_rev'], $a['new_rev']); |
$r = rg_git_files($a['old_rev'], $a['new_rev']); |
1170 |
1199 |
if ($r === FALSE) |
if ($r === FALSE) |
1171 |
1200 |
rg_git_fatal($a['refname'] . "\nInternal error, try again later\n"); |
rg_git_fatal($a['refname'] . "\nInternal error, try again later\n"); |
|
1201 |
|
$x = $_x; |
|
1202 |
|
$x['type'] = 'repo_path'; |
1172 |
1203 |
foreach ($r as $file) { |
foreach ($r as $file) { |
1173 |
|
if (rg_rights_allow($db, $a['repo_id'], "repo_path", |
|
1174 |
|
$a['repo::uid'], $uid, "P", $ip, $file) !== TRUE) { |
|
|
1204 |
|
$x['needed_rights'] = 'P'; |
|
1205 |
|
$x['misc'] = $file; |
|
1206 |
|
if (rg_rights_allow($db, $x) !== TRUE) { |
1175 |
1207 |
rg_git_fatal($a['refname'] |
rg_git_fatal($a['refname'] |
1176 |
1208 |
. "\nNo rights to push file [$file]\n"); |
. "\nNo rights to push file [$file]\n"); |
1177 |
1209 |
} |
} |
1178 |
1210 |
|
|
1179 |
|
if (!rg_rights_allow($db, $a['repo_id'], "repo_path", |
|
1180 |
|
$a['repo::uid'], $uid, "W", $ip, $a['refname'])) { |
|
|
1211 |
|
$x['needed_rights'] = 'W'; |
|
1212 |
|
if (rg_rights_allow($db, $x) !== TRUE) { |
1181 |
1213 |
$w = rg_git_whitespace_ok($a['old_rev'], $a['new_rev']); |
$w = rg_git_whitespace_ok($a['old_rev'], $a['new_rev']); |
1182 |
1214 |
if ($w !== TRUE) { |
if ($w !== TRUE) { |
1183 |
1215 |
rg_git_fatal($a['refname'] |
rg_git_fatal($a['refname'] |
|
... |
... |
function rg_git_update_branch($db, $a) |
1187 |
1219 |
} |
} |
1188 |
1220 |
} |
} |
1189 |
1221 |
|
|
1190 |
|
if (rg_rights_allow($db, $a['repo_id'], "repo_refs", $a['repo::uid'], $uid, "P", $ip, $a['refname']) !== TRUE) { |
|
|
1222 |
|
$x = $_x; |
|
1223 |
|
$x['type'] = 'repo_refs'; |
|
1224 |
|
$x['needed_rights'] = 'P'; |
|
1225 |
|
$x['misc'] = $a['refname']; |
|
1226 |
|
if (rg_rights_allow($db, $x) !== TRUE) { |
1191 |
1227 |
rg_log("\tPush is not allowed, let's see the anon one"); |
rg_log("\tPush is not allowed, let's see the anon one"); |
1192 |
|
if (rg_rights_allow($db, $a['repo_id'], "repo_refs", $a['repo::uid'], $uid, "H", $ip, $a['refname']) === FALSE) { |
|
1193 |
|
$_x = array(); |
|
1194 |
|
$msg = rg_template("msg/push_not_allowed.txt", $_x); |
|
|
1228 |
|
$x['needed_rights'] = 'H'; |
|
1229 |
|
if (rg_rights_allow($db, $x) !== TRUE) { |
|
1230 |
|
$_z = array(); |
|
1231 |
|
$msg = rg_template("msg/push_not_allowed.txt", $_z); |
1195 |
1232 |
rg_git_fatal($a['refname']. "\n" . $msg); |
rg_git_fatal($a['refname']. "\n" . $msg); |
1196 |
1233 |
} |
} |
1197 |
1234 |
|
|
File inc/repo.inc.php changed (mode: 100644) (index 8781f22..d83dd62) |
... |
... |
function rg_repo_compare_refs($misc, $ref) |
158 |
158 |
$misc = rg_repo_ref_canon($misc); |
$misc = rg_repo_ref_canon($misc); |
159 |
159 |
$ref = rg_repo_ref_canon($ref); |
$ref = rg_repo_ref_canon($ref); |
160 |
160 |
|
|
161 |
|
$ret = preg_match('/^' . $misc . '/uD', $ref); |
|
162 |
|
rg_log("repo_compare_refs: misc=$misc ref=$ref => " . ($ret ? "T" : "F")); |
|
|
161 |
|
$qmisc = preg_quote($misc, '/'); |
|
162 |
|
|
|
163 |
|
$ret = preg_match('/^' . $qmisc . '/uD', $ref); |
|
164 |
|
rg_log("repo_compare_refs: misc=$misc ref=$ref => " |
|
165 |
|
. ($ret === 1 ? "match" : "no match")); |
163 |
166 |
|
|
164 |
167 |
rg_prof_end("repo_compare_refs"); |
rg_prof_end("repo_compare_refs"); |
165 |
|
return $ret; |
|
|
168 |
|
return $ret === 1; |
166 |
169 |
} |
} |
167 |
170 |
|
|
168 |
171 |
/* |
/* |
|
... |
... |
function rg_repo_compare_paths($misc, $path) |
172 |
175 |
{ |
{ |
173 |
176 |
rg_prof_start("repo_compare_paths"); |
rg_prof_start("repo_compare_paths"); |
174 |
177 |
|
|
175 |
|
$ret = preg_match('/' . $misc . '/uD', $path); |
|
176 |
|
rg_log("repo_compare_paths: misc=$misc path=$path => " . ($ret ? "T" : "F")); |
|
|
178 |
|
$qmisc = preg_quote($misc, '/'); |
|
179 |
|
|
|
180 |
|
$ret = preg_match('/' . $qmisc . '/uD', $path); |
|
181 |
|
rg_log("repo_compare_paths: misc=$misc path=$path => " . ($ret === 1 ? "T" : "F")); |
177 |
182 |
|
|
178 |
183 |
rg_prof_end("repo_compare_paths"); |
rg_prof_end("repo_compare_paths"); |
179 |
|
return $ret; |
|
|
184 |
|
return $ret === 1; |
180 |
185 |
} |
} |
181 |
186 |
|
|
182 |
187 |
/* |
/* |
|
... |
... |
function rg_repo_ok($repo) |
569 |
574 |
return FALSE; |
return FALSE; |
570 |
575 |
} |
} |
571 |
576 |
|
|
572 |
|
if (preg_match('/\.\./', $repo) > 0) { |
|
|
577 |
|
if (preg_match('/\.\./', $repo) !== 0) { |
573 |
578 |
rg_repo_set_error("invalid repository name (..)"); |
rg_repo_set_error("invalid repository name (..)"); |
574 |
579 |
return FALSE; |
return FALSE; |
575 |
580 |
} |
} |
|
... |
... |
function rg_repo_info($db, $repo_id, $uid, $repo_name) |
690 |
695 |
} else { |
} else { |
691 |
696 |
$ret['exists'] = 0; |
$ret['exists'] = 0; |
692 |
697 |
} |
} |
693 |
|
rg_log_ml("CHECK: ret=" . print_r($ret, TRUE)); |
|
|
698 |
|
//rg_log_ml("CHECK: ret=" . print_r($ret, TRUE)); |
694 |
699 |
|
|
695 |
700 |
rg_cache_set("repo_by_id::$repo_id", $ret); |
rg_cache_set("repo_by_id::$repo_id", $ret); |
696 |
701 |
|
|
|
... |
... |
function rg_repo_list_query($db, $url, $sql, $params) |
1024 |
1029 |
|
|
1025 |
1030 |
$_ui = rg_user_info($db, $row['uid'], "", ""); |
$_ui = rg_user_info($db, $row['uid'], "", ""); |
1026 |
1031 |
if ($_ui['exists'] != 1) { |
if ($_ui['exists'] != 1) { |
1027 |
|
rg_repo_set_error("user associated with this repo not found"); |
|
1028 |
|
return FALSE; |
|
|
1032 |
|
rg_log("uid " . $row['uid'] |
|
1033 |
|
. " associated with this repo not found"); |
|
1034 |
|
continue; |
1029 |
1035 |
} |
} |
1030 |
1036 |
|
|
1031 |
1037 |
$_line['owner'] = $_ui['username']; |
$_line['owner'] = $_ui['username']; |
|
... |
... |
function rg_repo_admin_rights($db, $rg, $type) |
1209 |
1215 |
rg_log("rg_repo_admin_rights type=$type"); |
rg_log("rg_repo_admin_rights type=$type"); |
1210 |
1216 |
|
|
1211 |
1217 |
/* 'repo' is correct here, we test for granting rights on repo */ |
/* 'repo' is correct here, we test for granting rights on repo */ |
1212 |
|
if (rg_rights_allow($db, $rg['ri']['repo_id'], "repo", $rg['ri']['uid'], |
|
1213 |
|
$rg['login_ui']['uid'], "G", $rg['ip'], "") !== TRUE) |
|
|
1218 |
|
$x = array(); |
|
1219 |
|
$x['obj_id'] = $rg['ri']['repo_id']; |
|
1220 |
|
$x['type'] = 'repo'; |
|
1221 |
|
$x['owner'] = $rg['ri']['uid']; |
|
1222 |
|
$x['uid'] = $rg['login_ui']['uid']; |
|
1223 |
|
$x['username'] = $rg['login_ui']['username']; |
|
1224 |
|
$x['needed_rights'] = 'G'; |
|
1225 |
|
$x['ip'] = $rg['ip']; |
|
1226 |
|
$x['misc'] = ""; |
|
1227 |
|
if (rg_rights_allow($db, $x) !== TRUE) |
1214 |
1228 |
return rg_template("user/repo/rights/deny.html", $rg); |
return rg_template("user/repo/rights/deny.html", $rg); |
1215 |
1229 |
|
|
1216 |
1230 |
$ret = ""; |
$ret = ""; |
|
... |
... |
function rg_repo_admin_delete($db, $rg) |
1361 |
1375 |
{ |
{ |
1362 |
1376 |
$ret = ""; |
$ret = ""; |
1363 |
1377 |
|
|
1364 |
|
if (rg_rights_allow($db, $rg['ri']['repo_id'], "repo", $rg['ri']['uid'], |
|
1365 |
|
$rg['login_ui']['uid'], "D", $rg['ip'], "") !== TRUE) |
|
|
1378 |
|
$x = array(); |
|
1379 |
|
$x['obj_id'] = $rg['ri']['repo_id']; |
|
1380 |
|
$x['type'] = 'repo'; |
|
1381 |
|
$x['owner'] = $rg['ri']['uid']; |
|
1382 |
|
$x['uid'] = $rg['login_ui']['uid']; |
|
1383 |
|
$x['username'] = $rg['login_ui']['username']; |
|
1384 |
|
$x['needed_rights'] = 'D'; |
|
1385 |
|
$x['ip'] = $rg['ip']; |
|
1386 |
|
$x['misc'] = ""; |
|
1387 |
|
if (rg_rights_allow($db, $x) !== TRUE) |
1366 |
1388 |
return rg_template("user/repo/delete/deny.html", $rg); |
return rg_template("user/repo/delete/deny.html", $rg); |
1367 |
1389 |
|
|
1368 |
1390 |
$are_you_sure = rg_var_uint("are_you_sure"); |
$are_you_sure = rg_var_uint("are_you_sure"); |
|
... |
... |
function rg_repo_edit_high_level($db, &$rg) |
1431 |
1453 |
else |
else |
1432 |
1454 |
$edit = FALSE; |
$edit = FALSE; |
1433 |
1455 |
|
|
1434 |
|
if ($edit && (rg_rights_allow($db, $rg['ri']['repo_id'], "repo", $rg['ri']['uid'], |
|
1435 |
|
$rg['login_ui']['uid'], "E", $rg['ip'], "") !== TRUE)) { |
|
1436 |
|
$ret .= rg_template("user/repo/deny_edit.html", $rg); |
|
|
1456 |
|
// User is not logged in? |
|
1457 |
|
if (!$edit && ($rg['login_ui']['uid'] == 0)) { |
|
1458 |
|
$ret .= rg_template("user/repo/deny_create.html", $rg); |
1437 |
1459 |
$load_form = FALSE; |
$load_form = FALSE; |
1438 |
1460 |
break; |
break; |
1439 |
1461 |
} |
} |
1440 |
1462 |
|
|
|
1463 |
|
if ($edit) { |
|
1464 |
|
$x = array(); |
|
1465 |
|
$x['obj_id'] = $rg['ri']['repo_id']; |
|
1466 |
|
$x['type'] = 'repo'; |
|
1467 |
|
$x['owner'] = $rg['ri']['uid']; |
|
1468 |
|
$x['uid'] = $rg['login_ui']['uid']; |
|
1469 |
|
$x['username'] = $rg['login_ui']['username']; |
|
1470 |
|
$x['needed_rights'] = 'E'; |
|
1471 |
|
$x['ip'] = $rg['ip']; |
|
1472 |
|
$x['misc'] = ""; |
|
1473 |
|
if (rg_rights_allow($db, $x) !== TRUE) { |
|
1474 |
|
$ret .= rg_template("user/repo/deny_edit.html", $rg); |
|
1475 |
|
$load_form = FALSE; |
|
1476 |
|
break; |
|
1477 |
|
} |
|
1478 |
|
} |
|
1479 |
|
|
1441 |
1480 |
if ($rg['doit'] != 1) { |
if ($rg['doit'] != 1) { |
1442 |
1481 |
if (!$edit) { |
if (!$edit) { |
1443 |
1482 |
// Defaults |
// Defaults |
File inc/rights.inc.php changed (mode: 100644) (index 8b1eab4..f45d8b0) |
... |
... |
function rg_rights_split_ip($ip) |
443 |
443 |
if (strncasecmp($ip2, "::ffff:", 7) == 0) |
if (strncasecmp($ip2, "::ffff:", 7) == 0) |
444 |
444 |
$ip2 = substr($ip2, 7); |
$ip2 = substr($ip2, 7); |
445 |
445 |
|
|
446 |
|
if (preg_match('/^[a-fA-F0-9:]*$/D', $ip2)) { /* ipv6 */ |
|
|
446 |
|
if (preg_match('/^[a-fA-F0-9:]*$/D', $ip2) === 1) { /* ipv6 */ |
447 |
447 |
if ($ret['prefix_len'] == -1) { |
if ($ret['prefix_len'] == -1) { |
448 |
448 |
$ret['prefix_len'] = 128; |
$ret['prefix_len'] = 128; |
449 |
449 |
} else if (($ret['prefix_len'] < 0) || ($ret['prefix_len'] > 128)) { |
} else if (($ret['prefix_len'] < 0) || ($ret['prefix_len'] > 128)) { |
|
... |
... |
function rg_rights_split_ip($ip) |
511 |
511 |
$new[$k] = sprintf("%x", $p); |
$new[$k] = sprintf("%x", $p); |
512 |
512 |
$ret['ip'] = implode(":", $new); |
$ret['ip'] = implode(":", $new); |
513 |
513 |
$ret['type'] = "ipv6"; |
$ret['type'] = "ipv6"; |
514 |
|
} else if (preg_match('/^[0-9\.]*$/D', $ip2)) { /* ipv4 */ |
|
|
514 |
|
} else if (preg_match('/^[0-9\.]*$/D', $ip2) === 1) { /* ipv4 */ |
515 |
515 |
if ($ret['prefix_len'] == -1) { |
if ($ret['prefix_len'] == -1) { |
516 |
516 |
$ret['prefix_len'] = 32; |
$ret['prefix_len'] = 32; |
517 |
517 |
} else if (($ret['prefix_len'] < 0) || ($ret['prefix_len'] > 32)) { |
} else if (($ret['prefix_len'] < 0) || ($ret['prefix_len'] > 32)) { |
|
... |
... |
function rg_rights_test($list, $needed_rights, $ip, $misc) |
657 |
657 |
} |
} |
658 |
658 |
|
|
659 |
659 |
// Test rights |
// Test rights |
|
660 |
|
$have_a_match = FALSE; |
660 |
661 |
foreach ($needed as $needed1) { |
foreach ($needed as $needed1) { |
661 |
662 |
$r = rg_rights_mask($v['rights'], $needed1); |
$r = rg_rights_mask($v['rights'], $needed1); |
662 |
663 |
if (strcmp($r, $needed1) != 0) { |
if (strcmp($r, $needed1) != 0) { |
663 |
|
rg_log("rights_allow: [$r] != [$needed1]! Continue."); |
|
|
664 |
|
rg_log("rights_test: [$r] != [$needed1]! Continue."); |
664 |
665 |
continue; |
continue; |
665 |
666 |
} |
} |
666 |
|
rg_log("rights_allow: [$r] = [$needed1]! Allow."); |
|
667 |
|
$ret = TRUE; |
|
|
667 |
|
rg_log("rights_test: [$r] = [$needed1]! Allow."); |
|
668 |
|
$have_a_match = TRUE; |
668 |
669 |
break; |
break; |
669 |
670 |
} |
} |
670 |
|
if ($ret === FALSE) |
|
|
671 |
|
if ($have_a_match === FALSE) |
671 |
672 |
continue; |
continue; |
672 |
673 |
|
|
673 |
674 |
// Test 'misc' match |
// Test 'misc' match |
|
... |
... |
function rg_rights_test($list, $needed_rights, $ip, $misc) |
677 |
678 |
|
|
678 |
679 |
$cmp_func = $rg_rights_cmp_func[$v['type']]; |
$cmp_func = $rg_rights_cmp_func[$v['type']]; |
679 |
680 |
$r = $cmp_func($v['misc'], $misc); |
$r = $cmp_func($v['misc'], $misc); |
680 |
|
if (!$r) |
|
|
681 |
|
if ($r !== TRUE) { |
|
682 |
|
rg_log("DEBUG: cmp function returned !TRUE"); |
681 |
683 |
continue; |
continue; |
|
684 |
|
} |
682 |
685 |
} |
} |
683 |
686 |
|
|
|
687 |
|
$ret = TRUE; |
684 |
688 |
break; |
break; |
685 |
689 |
} |
} |
686 |
690 |
|
|
687 |
691 |
break; |
break; |
688 |
692 |
} |
} |
|
693 |
|
rg_log("DEBUG: rights_test returns " . ($ret === FALSE ? "!allow" : "allow")); |
689 |
694 |
|
|
690 |
695 |
rg_log_exit(); |
rg_log_exit(); |
691 |
696 |
return $ret; |
return $ret; |
|
... |
... |
function rg_rights_test($list, $needed_rights, $ip, $misc) |
695 |
700 |
* Returns TRUE if all 'needed_rights' are included in 'rights' |
* Returns TRUE if all 'needed_rights' are included in 'rights' |
696 |
701 |
* needed_rights: rights letters; you can use "ab|cd" = (a AND B) OR (C AND d) |
* needed_rights: rights letters; you can use "ab|cd" = (a AND B) OR (C AND d) |
697 |
702 |
*/ |
*/ |
698 |
|
function rg_rights_allow($db, $obj_id, $type, $owner, $uid, $needed_rights, |
|
699 |
|
$ip, $misc) |
|
|
703 |
|
function rg_rights_allow($db, $a) |
700 |
704 |
{ |
{ |
|
705 |
|
$obj_id = $a['obj_id']; |
|
706 |
|
$type = $a['type']; |
|
707 |
|
$owner = $a['owner']; |
|
708 |
|
$uid = $a['uid']; |
|
709 |
|
$username = $a['username']; |
|
710 |
|
$needed_rights = $a['needed_rights']; |
|
711 |
|
$ip = $a['ip']; |
|
712 |
|
$misc = $a['misc']; |
|
713 |
|
|
701 |
714 |
$right_id = 0; |
$right_id = 0; |
|
715 |
|
// TODO: we may pass $a? |
702 |
716 |
$r = rg_rights_get($db, $obj_id, $type, $owner, $uid, $right_id); |
$r = rg_rights_get($db, $obj_id, $type, $owner, $uid, $right_id); |
703 |
717 |
if ($r['ok'] != 1) |
if ($r['ok'] != 1) |
704 |
718 |
return FALSE; |
return FALSE; |
705 |
719 |
|
|
|
720 |
|
// We must replace @USER@ with the logged-in user |
|
721 |
|
if ($uid > 0) { |
|
722 |
|
foreach ($r['list'] as $index => &$e) { |
|
723 |
|
if (!strstr($e['misc'], '@USER@')) |
|
724 |
|
continue; |
|
725 |
|
|
|
726 |
|
$_old = $e['misc']; |
|
727 |
|
$e['misc'] = preg_replace('/@USER@/', $username, $e['misc']); |
|
728 |
|
rg_log("DEBUG [" . $_old . "] -> [" . $e['misc'] . "]"); |
|
729 |
|
} |
|
730 |
|
rg_log_ml("DEBUG: r[list]=" . print_r($r['list'], TRUE)); |
|
731 |
|
} |
|
732 |
|
|
706 |
733 |
return rg_rights_test($r['list'], $needed_rights, $ip, $misc); |
return rg_rights_test($r['list'], $needed_rights, $ip, $misc); |
707 |
734 |
} |
} |
708 |
735 |
|
|
File inc/user/repo-page.php changed (mode: 100644) (index 489ae5b..641bbdf) |
... |
... |
if ($rg['ri']['ok'] != 1) { |
27 |
27 |
return; |
return; |
28 |
28 |
} |
} |
29 |
29 |
|
|
30 |
|
if (($rg['ri']['exists'] != 1) |
|
31 |
|
|| rg_rights_allow($db, $rg['ri']['repo_id'], "repo", $rg['ri']['uid'], |
|
32 |
|
$rg['login_ui']['uid'], "A", $rg['ip'], "") !== TRUE) { |
|
|
30 |
|
$x = array(); |
|
31 |
|
$x['obj_id'] = $rg['ri']['repo_id']; |
|
32 |
|
$x['type'] = 'repo'; |
|
33 |
|
$x['owner'] = $rg['ri']['uid']; |
|
34 |
|
$x['uid'] = $rg['login_ui']['uid']; |
|
35 |
|
$x['username'] = $rg['login_ui']['username']; |
|
36 |
|
$x['needed_rights'] = 'A'; |
|
37 |
|
$x['ip'] = $rg['ip']; |
|
38 |
|
$x['misc'] = ""; |
|
39 |
|
if (($rg['ri']['exists'] != 1) || (rg_rights_allow($db, $x) !== TRUE)) { |
33 |
40 |
$_repo_page .= rg_template("user/repo/deny.html", $rg); |
$_repo_page .= rg_template("user/repo/deny.html", $rg); |
34 |
41 |
return; |
return; |
35 |
42 |
} |
} |
|
... |
... |
if (($rg['ri']['exists'] != 1) |
37 |
44 |
if (!isset($rg['ri']['git_dir_done'])) |
if (!isset($rg['ri']['git_dir_done'])) |
38 |
45 |
$rg['ri']['git_dir_done'] = 0; |
$rg['ri']['git_dir_done'] = 0; |
39 |
46 |
|
|
40 |
|
$can_admin = rg_rights_allow($db, $rg['ri']['repo_id'], "repo", |
|
41 |
|
$rg['ri']['uid'], $rg['login_ui']['uid'], "E", $rg['ip'], "") === TRUE ? 1 : 0; |
|
|
47 |
|
$x['needed_rights'] = 'E'; |
|
48 |
|
$can_admin = rg_rights_allow($db, $x) === TRUE ? 1 : 0; |
42 |
49 |
|
|
43 |
50 |
$rg['url_user'] = rg_re_userpage($rg['page_ui']); |
$rg['url_user'] = rg_re_userpage($rg['page_ui']); |
44 |
51 |
$rg['url_repo'] = rg_re_repopage($rg['page_ui'], $repo); |
$rg['url_repo'] = rg_re_repopage($rg['page_ui'], $repo); |
|
... |
... |
if ($rg_git_port != 0) |
64 |
71 |
$urls[]['HTML:url'] = '<a href="' . $rg['git'] . '">' . $rg['git'] . '</a>'; |
$urls[]['HTML:url'] = '<a href="' . $rg['git'] . '">' . $rg['git'] . '</a>'; |
65 |
72 |
$rg['HTML:urls'] = rg_template_table("repo/urls", $urls, $rg); |
$rg['HTML:urls'] = rg_template_table("repo/urls", $urls, $rg); |
66 |
73 |
|
|
|
74 |
|
function rg_add_clone_hints($db, &$rg) |
|
75 |
|
{ |
|
76 |
|
global $rg_ssh_port; |
|
77 |
|
global $rg_git_port; |
|
78 |
|
|
|
79 |
|
$hints = array(); |
|
80 |
|
|
|
81 |
|
$hints[]['HTML:hint'] = rg_template("hints/repo/git_setup.html", $rg); |
|
82 |
|
|
|
83 |
|
if ($rg['ri']['uid'] == $rg['login_ui']['uid']) { |
|
84 |
|
$hints[]['HTML:hint'] = rg_template("hints/repo/clone_owner.html", $rg); |
|
85 |
|
} else { |
|
86 |
|
if ($rg_ssh_port != 0) |
|
87 |
|
$hints[]['HTML:hint'] = rg_template("hints/repo/clone_ssh.html", $rg); |
|
88 |
|
|
|
89 |
|
if ($rg_git_port != 0) |
|
90 |
|
$hints[]['HTML:hint'] = rg_template("hints/repo/clone_git.html", $rg); |
|
91 |
|
|
|
92 |
|
$x = array(); |
|
93 |
|
$x['obj_id'] = $rg['ri']['repo_id']; |
|
94 |
|
$x['type'] = 'repo_refs'; |
|
95 |
|
$x['owner'] = $rg['ri']['uid']; |
|
96 |
|
$x['uid'] = $rg['login_ui']['uid']; |
|
97 |
|
$x['username'] = $rg['login_ui']['username']; |
|
98 |
|
$x['needed_rights'] = 'H'; /* anon push */ |
|
99 |
|
$x['ip'] = $rg['ip']; |
|
100 |
|
$x['misc'] = FALSE; |
|
101 |
|
if (rg_rights_allow($db, $x) === TRUE) |
|
102 |
|
$hints[]['HTML:hint'] = rg_template("hints/repo/anon_push.html", $rg); |
|
103 |
|
} |
|
104 |
|
|
|
105 |
|
$rg['HTML:hints'] = rg_template_table("hints/list", $hints, $rg); |
|
106 |
|
} |
|
107 |
|
|
67 |
108 |
// default tab |
// default tab |
68 |
109 |
$_subop = empty($paras) ? "history" : array_shift($paras); |
$_subop = empty($paras) ? "history" : array_shift($paras); |
69 |
110 |
|
|
70 |
111 |
if (strcmp($_subop, "history") == 0) { |
if (strcmp($_subop, "history") == 0) { |
|
112 |
|
rg_add_clone_hints($db, $rg); |
|
113 |
|
|
71 |
114 |
$hist = rg_repo_history_load($db, $rg['ri']['repo_id'], 0, 20, 0); |
$hist = rg_repo_history_load($db, $rg['ri']['repo_id'], 0, 20, 0); |
72 |
115 |
if ($hist === FALSE) |
if ($hist === FALSE) |
73 |
116 |
$_repo_body .= rg_warning("Cannot load history. Try again later."); |
$_repo_body .= rg_warning("Cannot load history. Try again later."); |
|
... |
... |
if (strcmp($_subop, "history") == 0) { |
86 |
129 |
$type_ref['ref_url']); |
$type_ref['ref_url']); |
87 |
130 |
$rg = array_merge($rg, $bt); |
$rg = array_merge($rg, $bt); |
88 |
131 |
|
|
89 |
|
$hints = array(); |
|
90 |
|
if ($rg_ssh_port != 0) |
|
91 |
|
$hints[]['HTML:hint'] = rg_template("hints/repo/clone_ssh.html", $rg); |
|
92 |
|
if ($rg_git_port != 0) |
|
93 |
|
$hints[]['HTML:hint'] = rg_template("hints/repo/clone_git.html", $rg); |
|
94 |
|
if (rg_rights_allow($db, $rg['ri']['repo_id'], "repo_refs", |
|
95 |
|
$rg['ri']['uid'], $rg['login_ui']['uid'], "H", $rg['ip'], FALSE)) /* H = anon push */ |
|
96 |
|
$hints[]['HTML:hint'] = rg_template("hints/repo/anon_push.html", $rg); |
|
97 |
|
$rg['HTML:hints'] = rg_template_table("hints/list", $hints, $rg); |
|
|
132 |
|
rg_add_clone_hints($db, $rg); |
98 |
133 |
|
|
99 |
134 |
$_repo_body .= rg_template("repo/source.html", $rg); |
$_repo_body .= rg_template("repo/source.html", $rg); |
100 |
135 |
|
|
File tests/rights.php changed (mode: 100644) (index 87dc084..b1f853a) |
... |
... |
$rg_sql_debug = 1; |
16 |
16 |
// Defaults |
// Defaults |
17 |
17 |
$rg_admin_email = "rg@embedromix.ro"; |
$rg_admin_email = "rg@embedromix.ro"; |
18 |
18 |
|
|
|
19 |
|
$type1_rights = array('d' => 'Delete', 'x' => 'XXX', 'y' => 'YYY', |
|
20 |
|
'a' => 'AAA', 'b' => 'BBB', 'c' => 'CCC', |
|
21 |
|
'A' => 'aaa', 'B' => 'bbb', 'C' => 'ccc'); |
|
22 |
|
rg_rights_register('type1', $type1_rights, "", "rg_repo_compare_refs", FALSE); |
19 |
23 |
|
|
20 |
24 |
$sql = "DELETE FROM rights"; |
$sql = "DELETE FROM rights"; |
21 |
25 |
$res = rg_sql_query($db, $sql); |
$res = rg_sql_query($db, $sql); |
|
... |
... |
$a['who'] = 90; |
71 |
75 |
$a['obj_id'] = 333; |
$a['obj_id'] = 333; |
72 |
76 |
$a['uid'] = 200; |
$a['uid'] = 200; |
73 |
77 |
$a['rights'] = "abc"; |
$a['rights'] = "abc"; |
74 |
|
$a['misc'] = "misc1"; |
|
|
78 |
|
$a['misc'] = "misc1/@USER@/"; |
75 |
79 |
$a['ip'] = "1.1.1.1 2.2.2.2 10.0.0.0/8"; |
$a['ip'] = "1.1.1.1 2.2.2.2 10.0.0.0/8"; |
76 |
80 |
$a['prio'] = 13; |
$a['prio'] = 13; |
77 |
81 |
$a['description'] = "desc1"; |
$a['description'] = "desc1"; |
|
... |
... |
if ($r !== TRUE) { |
80 |
84 |
rg_log("Seems I cannot set rights 1 (" . rg_rights_error() . ")"); |
rg_log("Seems I cannot set rights 1 (" . rg_rights_error() . ")"); |
81 |
85 |
exit(1); |
exit(1); |
82 |
86 |
} |
} |
83 |
|
$a['rights'] = "d"; $a['misc'] = "misc2"; $a['prio'] = 14; |
|
84 |
|
$r = rg_rights_set($db, "type1", $a); |
|
|
87 |
|
$b = $a; |
|
88 |
|
$b['rights'] = "d"; $b['misc'] = "some_misc"; $b['prio'] = 14; |
|
89 |
|
$r = rg_rights_set($db, "type1", $b); |
85 |
90 |
if ($r !== TRUE) { |
if ($r !== TRUE) { |
86 |
91 |
rg_log("Seems I cannot set rights 2 (" . rg_rights_error() . ")"); |
rg_log("Seems I cannot set rights 2 (" . rg_rights_error() . ")"); |
87 |
92 |
exit(1); |
exit(1); |
88 |
93 |
} |
} |
89 |
|
$a['rights'] = "E"; $a['misc'] = "misc3"; $a['prio'] = 14; |
|
90 |
|
$r = rg_rights_set($db, "type2", $a); |
|
|
94 |
|
$b['rights'] = "E"; $b['misc'] = "some_other_misc"; $b['prio'] = 14; |
|
95 |
|
$r = rg_rights_set($db, "type2", $b); |
91 |
96 |
if ($r !== TRUE) { |
if ($r !== TRUE) { |
92 |
|
rg_log("Seems I cannot set rights 2 (" . rg_rights_error() . ")"); |
|
|
97 |
|
rg_log("Seems I cannot set rights 3 (" . rg_rights_error() . ")"); |
93 |
98 |
exit(1); |
exit(1); |
94 |
99 |
} |
} |
95 |
100 |
|
|
|
... |
... |
$right_id = 0; |
98 |
103 |
$r = rg_rights_get($db, $a['obj_id'], "type1", $a['who'], $a['uid'], $right_id); |
$r = rg_rights_get($db, $a['obj_id'], "type1", $a['who'], $a['uid'], $right_id); |
99 |
104 |
if (($r['ok'] !== 1) || (strcmp($r['list'][1]['rights'], "d") != 0)) { |
if (($r['ok'] !== 1) || (strcmp($r['list'][1]['rights'], "d") != 0)) { |
100 |
105 |
rg_log("Seems I cannot get rights (" . rg_rights_error() . ")"); |
rg_log("Seems I cannot get rights (" . rg_rights_error() . ")"); |
101 |
|
print_r($r); |
|
|
106 |
|
rg_log_ml("r: " . print_r($r, TRUE)); |
102 |
107 |
exit (1); |
exit (1); |
103 |
108 |
} |
} |
104 |
109 |
// 'get' again, to see if cache works |
// 'get' again, to see if cache works |
105 |
110 |
$r = rg_rights_get($db, $a['obj_id'], "type1", $a['who'], $a['uid'], $right_id); |
$r = rg_rights_get($db, $a['obj_id'], "type1", $a['who'], $a['uid'], $right_id); |
106 |
111 |
if (($r['ok'] !== 1) || (strcmp($r['list'][1]['rights'], "d") != 0)) { |
if (($r['ok'] !== 1) || (strcmp($r['list'][1]['rights'], "d") != 0)) { |
107 |
112 |
rg_log("Seems I cannot get rights (" . rg_rights_error() . ")"); |
rg_log("Seems I cannot get rights (" . rg_rights_error() . ")"); |
108 |
|
print_r($r); |
|
109 |
|
exit (1); |
|
|
113 |
|
rg_log_ml("r: " . print_r($r, TRUE)); |
|
114 |
|
exit(1); |
|
115 |
|
} |
|
116 |
|
$for_delete_list = $r['list']; |
|
117 |
|
|
|
118 |
|
rg_log("Testing allow with @USER@ token..."); |
|
119 |
|
$x = array(); |
|
120 |
|
$x['obj_id'] = $a['obj_id']; |
|
121 |
|
$x['type'] = 'type1'; |
|
122 |
|
$x['owner'] = 90; |
|
123 |
|
$x['uid'] = 200; |
|
124 |
|
$x['username'] = 'user_gen'; |
|
125 |
|
$x['needed_rights'] = 'a'; |
|
126 |
|
$x['ip'] = '10.2.3.4'; |
|
127 |
|
$x['misc'] = 'misc1/user_gen/a'; |
|
128 |
|
$r = rg_rights_allow($db, $x); |
|
129 |
|
if ($r === FALSE) { |
|
130 |
|
rg_log("We should have access because of @USER@"); |
|
131 |
|
exit(1); |
110 |
132 |
} |
} |
111 |
133 |
|
|
112 |
134 |
rg_log("Testing delete_list..."); |
rg_log("Testing delete_list..."); |
113 |
135 |
$list = array(); |
$list = array(); |
114 |
|
foreach ($r['list'] as $junk => $i) |
|
|
136 |
|
foreach ($for_delete_list as $junk => $i) |
115 |
137 |
$list[] = $i['right_id']; |
$list[] = $i['right_id']; |
116 |
138 |
$r = rg_rights_delete_list($db, "type1", $a['obj_id'], $list); |
$r = rg_rights_delete_list($db, "type1", $a['obj_id'], $list); |
117 |
139 |
if ($r !== TRUE) { |
if ($r !== TRUE) { |
|
... |
... |
if ($r !== TRUE) { |
166 |
188 |
exit(1); |
exit(1); |
167 |
189 |
} |
} |
168 |
190 |
|
|
|
191 |
|
|
169 |
192 |
rg_log("Finish"); |
rg_log("Finish"); |
170 |
193 |
|
|
171 |
194 |
// TODO: test if a user can read other rights |
// TODO: test if a user can read other rights |