kfirewall: fix inbound traffic rules generation

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-05-07 00:05:54 +03:00
parent 328f3e0943
commit 9646435134

View file

@ -35,9 +35,11 @@ static QByteArray rulesForParameters(const QVariantMap &parameters, const bool a
const QByteArray actionvalue = rulesettingsmap.value(QString::fromLatin1("action")).toByteArray(); const QByteArray actionvalue = rulesettingsmap.value(QString::fromLatin1("action")).toByteArray();
// qDebug() << Q_FUNC_INFO << trafficvalue << addressvalue << portvalue << actionvalue; // qDebug() << Q_FUNC_INFO << trafficvalue << addressvalue << portvalue << actionvalue;
bool isinbound = false;
QByteArray iptablestraffic = trafficvalue.toUpper(); QByteArray iptablestraffic = trafficvalue.toUpper();
if (iptablestraffic == "INBOUND") { if (iptablestraffic == "INBOUND") {
iptablestraffic = "INPUT"; iptablestraffic = "INPUT";
isinbound = true;
} else { } else {
iptablestraffic = "OUTPUT"; iptablestraffic = "OUTPUT";
} }
@ -56,8 +58,11 @@ static QByteArray rulesForParameters(const QVariantMap &parameters, const bool a
iptablesruledata.append(" -p tcp --dport "); iptablesruledata.append(" -p tcp --dport ");
iptablesruledata.append(QByteArray::number(portvalue)); iptablesruledata.append(QByteArray::number(portvalue));
} }
iptablesruledata.append(" -m owner --uid-owner "); if (!isinbound) {
iptablesruledata.append(uservalue); // NOTE: only output can be user-bound
iptablesruledata.append(" -m owner --uid-owner ");
iptablesruledata.append(uservalue);
}
iptablesruledata.append(" -j "); iptablesruledata.append(" -j ");
iptablesruledata.append(actionvalue.toUpper()); iptablesruledata.append(actionvalue.toUpper());
iptablesruledata.append("\n"); iptablesruledata.append("\n");