Skip to content

Commit 3ed39b2

Browse files
committed
service/pipewire: fix metadata permission checks
1 parent fbaec14 commit 3ed39b2

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/services/pipewire/defaults.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,13 @@ bool PwDefaultTracker::setConfiguredDefault(const char* key, const QString& valu
193193
return false;
194194
}
195195

196+
if (!meta->hasSetPermission()) {
197+
qCCritical(logDefaults
198+
) << "Cannot set default node as write+execute permissions are missing for"
199+
<< meta;
200+
return false;
201+
}
202+
196203
if (value.isEmpty()) {
197204
meta->setProperty(key, "Spa:String:JSON", nullptr);
198205
} else {

src/services/pipewire/metadata.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
#include <pipewire/core.h>
44
#include <pipewire/extensions/metadata.h>
5+
#include <pipewire/permission.h>
56
#include <qlogging.h>
67
#include <qloggingcategory.h>
78
#include <qobject.h>
89
#include <qstringview.h>
910
#include <qtmetamacros.h>
1011
#include <qtypes.h>
11-
#include <spa/param/param.h>
1212
#include <spa/utils/dict.h>
1313

1414
#include "registry.hpp"
@@ -54,7 +54,7 @@ int PwMetadata::onProperty(
5454
}
5555

5656
bool PwMetadata::hasSetPermission() const {
57-
return (this->perms & SPA_PARAM_INFO_WRITE) == SPA_PARAM_INFO_WRITE;
57+
return (this->perms & (PW_PERM_W | PW_PERM_X)) == (PW_PERM_W | PW_PERM_X);
5858
}
5959

6060
void PwMetadata::setProperty(const char* key, const char* type, const char* value) {
@@ -64,7 +64,8 @@ void PwMetadata::setProperty(const char* key, const char* type, const char* valu
6464
}
6565

6666
if (!this->hasSetPermission()) {
67-
qCCritical(logMeta) << "Tried to change property of" << this << "which is read-only.";
67+
qCCritical(logMeta) << "Tried to change property of" << this
68+
<< "which is missing write+execute permissions.";
6869
}
6970

7071
pw_metadata_set_property(this->proxy(), PW_ID_CORE, key, type, value);

0 commit comments

Comments
 (0)