mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Do not allow for overwriting arbitrary packages
A package should only be overwritten if it already belongs to the package base that is trying to overwrite it. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
This commit is contained in:
parent
afb02a10c6
commit
8921e4deb9
2 changed files with 42 additions and 21 deletions
|
@ -312,6 +312,25 @@ function can_submit_pkgbase($name="", $sid="") {
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a package can be overwritten by some package base
|
||||
*
|
||||
* @param string $name Name of the package to be submitted
|
||||
* @param int $base_id The ID of the package base
|
||||
*
|
||||
* @return bool True if the package can be overwritten, false if not
|
||||
*/
|
||||
function can_submit_pkg($name, $base_id) {
|
||||
$dbh = DB::connect();
|
||||
$q = "SELECT COUNT(*) FROM Packages WHERE ";
|
||||
$q.= "Name = " . $dbh->quote($name) . " AND ";
|
||||
$q.= "PackageBaseID <> " . intval($base_id);
|
||||
$result = $dbh->query($q);
|
||||
|
||||
if (!$result) return false;
|
||||
return ($result->fetchColumn() == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively delete a directory
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue