Skip to content

Commit 52faafb

Browse files
authored
Merge pull request #322 from jolavillette/fix/sslonly-friend-default-perms
fix(peermgr): default SSL-only friends to RS_NODE_PERM_NONE
2 parents 2ed36b6 + 9465e20 commit 52faafb

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/pqi/p3peermgr.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,19 @@ bool p3PeerMgrIMPL::addSslOnlyFriend( const RsPeerId& sslId, const RsPgpId& pgp_
11851185
{ RS_STACK_MUTEX(mPeerMtx);
11861186
mFriendList[sslId] = pstate;
11871187
mStatusChanged = true;
1188+
1189+
/* Establish default (empty) service permissions for this PGP id if none
1190+
* exist yet. This is essential: addSslOnlyFriend() is the entry point
1191+
* used by short invites (webui, mobile, QR code...) and, unlike
1192+
* addFriend(), it would otherwise leave mFriendsPermissionFlags without
1193+
* an entry for this friend. Later on, gossip discovery and loadList call
1194+
* addFriend() with the RS_NODE_PERM_ALL "keep the existing flags" mask,
1195+
* relying on the per-friend entry to reduce it (service_flags &= entry).
1196+
* With no entry that mask is written verbatim, silently granting the peer
1197+
* DIRECT_DL | ALLOW_PUSH | REQUIRE_WL. Registering RS_NODE_PERM_NONE here
1198+
* makes the mask a no-op and matches the default of GUI-added friends. */
1199+
if(mFriendsPermissionFlags.find(pgp_id) == mFriendsPermissionFlags.end())
1200+
mFriendsPermissionFlags[pgp_id] = RS_NODE_PERM_NONE;
11881201
} // RS_STACK_MUTEX(mPeerMtx);
11891202

11901203
IndicateConfigChanged(RsConfigMgr::CheckPriority::SAVE_NOW);

0 commit comments

Comments
 (0)