8 Commits

Author SHA1 Message Date
7483e131ef Merge pull request 'fix(perms): never write a never-seen player into Carbon's shared blank record' (#47) from fix/carbon-blank-user into main
All checks were successful
Release plugin / release (push) Successful in 43s
Reviewed-on: #47
2026-10-30 09:31:54 +00:00
59db88d006 fix(perms): never write a never-seen player into Carbon's shared blank record
Some checks failed
PR Checks / plugin-checks (pull_request) Failing after -14s
Carbon 2.0.262 answers GetUserData for a Steam id it has no record for with
one shared, static blank record, and GrantUserPermission and AddUserGroup
write into it. A grant or membership for one never-seen player was then held
by every Steam id Carbon had no record for, until the server restarted, and
UserHasGroup read the membership back as a success, so the sync reported it
applied and later syncs saw nothing to fix.

On Carbon the sync now checks permission.UserExists before either write. A
never-seen player's grant is reported notLanded and their membership pending,
without touching the store; both land at the first audit sync after they
join, as PLAN.md section 29.8 and section 12.2 rule 4 already describe. Oxide
creates a real record and is unchanged.

Proven on the Carbon rig (Rust 26139947, Carbon 2.0.262): before, three
random never-seen ids each held autodoors.use after one admin grant; after,
a known id got its grant and membership, the never-seen id was reported
notLanded + pending, and random ids held nothing. Found in the account
deletion walk (docs/website/ACCOUNT_DELETION.md step 6, W3).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
2026-10-30 04:23:31 -05:00
19ad9279fa Merge pull request 'docs(bridge): bring EventsEnabled's comment to main' (#46) from edge into main
All checks were successful
Release plugin / release (push) Successful in 15s
Reviewed-on: #46
2026-10-23 07:07:09 +00:00
22da0026ca Merge pull request 'docs(bridge): EventsEnabled's comment says what it gates today' (#45) from fix/eventsenabled-comment into edge
All checks were successful
PR Checks / plugin-checks (pull_request) Successful in 22s
Reviewed-on: #45
2026-10-22 20:32:36 +00:00
ef9596ce67 docs(bridge): EventsEnabled's comment says what it gates today
All checks were successful
PR Checks / plugin-checks (pull_request) Successful in 9s
The doc comment on PluginConfig.EventsEnabled still said it "gates
taking a lease only", which stopped being true at protocol 9 when it
began gating every world write (D94). It now lists what the switch
gates as of protocol 14 - a lease, every world write (zones, crates,
NPCs, world calls, Dangerous Treasures, Guarded Crate, raid bases,
console commands), a tally and a run's chat line, and paying coins -
what always works with it off, and that the website can set it without
a reload. Comment only; no behaviour change.

Found while writing the runicgateway.com Rust docs (its PLAN.md §16,
phase 15).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
2026-10-22 15:29:34 -05:00
25a698e86e Merge pull request 'chore(release): cut edge over to main — protocol 14' (#44) from edge into main
All checks were successful
Release plugin / release (push) Successful in 30s
Reviewed-on: #44
2026-10-22 10:22:46 +00:00
3c0fcb0003 Merge pull request 'fix(bridge): the last fixes' bridge half (W3, W9, W12)' (#43) from fix/last-fixes-bridge into edge
All checks were successful
PR Checks / plugin-checks (pull_request) Successful in 13s
Reviewed-on: #43
2026-10-22 00:35:42 +00:00
38f854d580 fix(bridge): the last fixes' bridge half (W3, W9, W12)
All checks were successful
PR Checks / plugin-checks (pull_request) Successful in 14s
Stage 3 of docs/modules/rust/PLAN_LAST_FIXES.md.

- W3: a Travelling Vendor call while one is on the map answers world.error
  reason `already-out` instead of "called 1" with nothing spawned. Not
  counted against the run's budget and not kept under its key, so a retry
  looks again. Module-Rust#55 reads it as called 0.
- W9: a rolled-back RaidableBases profile write carries RaidableBases' own
  log entry for the file (its path and the exception's message, without the
  stack), read from the log since the write began, instead of the last 8 KB
  of the server log. Its other entries since the write stand in when none
  names the profile, and nothing when it said nothing.
- W12: raid.ended carries the base's id, and its runId and key, when a run
  made it, as PROTOCOL §20.12 says. A teardown takes the base off the record
  before its despawn raises Ended, so the live base keeps its run and key too.

No protocol change: W3's reason is a new value of an existing field, and W12
sends the fields PROTOCOL already lists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
2026-10-21 13:59:10 -05:00

View File

@@ -445,12 +445,20 @@ namespace Oxide.Plugins
public string ServerId = "main"; public string ServerId = "main";
/// <summary> /// <summary>
/// Whether the website may borrow values on this server for events (protocol 8, /// Whether the website may run events on this server at all (protocol 8, D76).
/// D76). <b>Off until an operator turns it on.</b> Letting staff moderate from a /// <b>Off until an operator turns it on.</b> Letting staff moderate from a screen
/// screen they are looking at, and letting a schedule change the world at four in /// they are looking at, and letting a schedule change the world at four in the
/// the morning, are different consents, and one switch cannot honestly express /// morning, are different consents, and one switch cannot honestly express both.
/// both. It gates taking a lease only: listing and giving back always work, so /// <para>
/// turning it off never strands a value somebody already borrowed. /// It began as the lease switch and grew with the protocol. It now gates taking a
/// lease (protocol 8), every world write (protocol 9, D94: zones, placed crates and
/// NPCs, and from protocol 14 world calls, Dangerous Treasures, Guarded Crate,
/// raid bases and console commands — <see cref="WorldWritesAllowed"/>), opening a
/// tally and a run's chat line (protocol 10, D107), and paying coins (protocol 14).
/// Listing, giving back, reverting and every read always work, so turning it off
/// never strands anything an event already holds. An admin can set it from the
/// website's config editor, and it takes effect without a reload.
/// </para>
/// </summary> /// </summary>
public bool EventsEnabled = false; public bool EventsEnabled = false;
@@ -4770,6 +4778,15 @@ namespace Oxide.Plugins
break; break;
case PermOpKind.EnsureMember: case PermOpKind.EnsureMember:
// Before the read, because on Carbon the read is the thing that lies: a
// never-seen player's UserHasGroup reads the shared blank record (see
// HasNoCarbonRecord), so it can say "already a member" of nobody.
if (HasNoCarbonRecord(op.Subject))
{
job.Pending.Add(op.Subject + ":" + op.Object);
break;
}
if (permission.UserHasGroup(op.Subject, op.Object)) if (permission.UserHasGroup(op.Subject, op.Object))
{ {
job.AlreadyCorrect++; job.AlreadyCorrect++;
@@ -4792,6 +4809,15 @@ namespace Oxide.Plugins
if (!Registered(job, op.Object)) if (!Registered(job, op.Object))
break; break;
// Never-seen on Carbon: the grant would land in the shared blank record and be
// held by every Steam id Carbon has no record for. It lands at the first sync
// after they join, as PLAN.md §29.8 already says of Carbon.
if (HasNoCarbonRecord(op.Subject))
{
job.NotLanded.Add(op.Subject + ":" + op.Object);
break;
}
if (HoldsDirectly(op.Subject, op.Object)) if (HoldsDirectly(op.Subject, op.Object))
{ {
job.AlreadyCorrect++; job.AlreadyCorrect++;
@@ -4934,6 +4960,24 @@ namespace Oxide.Plugins
return false; return false;
} }
/// <summary>
/// Whether this is Carbon and Carbon has no user record for the player.
///
/// <para>
/// Carbon (2.0.262) answers <c>GetUserData</c> for a Steam id it has never seen with ONE
/// shared, static blank record, and <c>AddUserGroup</c> and <c>GrantUserPermission</c>
/// write into whatever it returns. So a membership or grant for one never-seen player
/// goes to that shared record and is then held by every Steam id Carbon has no record
/// for, until the server restarts — and <c>UserHasGroup</c> reads it back as a success.
/// Oxide creates a real record instead, so this is never true there and Oxide's
/// behaviour is unchanged. Found in the account deletion walk (W3).
/// </para>
/// </summary>
private bool HasNoCarbonRecord(string steamId)
{
return IsCarbon() && !permission.UserExists(steamId);
}
/// <summary> /// <summary>
/// Whether a player holds a permission through a grant of their own, as opposed to /// Whether a player holds a permission through a grant of their own, as opposed to
/// through a group. /// through a group.
@@ -6792,6 +6836,10 @@ namespace Oxide.Plugins
ReloadsBefore = helper.Call("ReloadsFinished") is int done ? done : 0 ReloadsBefore = helper.Call("ReloadsFinished") is int done ? done : 0
}; };
// RaidableBases' own words on a profile it cannot read are logged during the reload,
// so the log is read from here when it is rolled back (W9).
MarkLogPosition(job);
if (!(helper.Call("ReloadProfiles") is bool asked) || !asked) if (!(helper.Call("ReloadProfiles") is bool asked) || !asked)
{ {
RestoreConfig(staged); RestoreConfig(staged);
@@ -6847,7 +6895,7 @@ namespace Oxide.Plugins
if (failed.Count == 0) if (failed.Count == 0)
SettleConfigJob(job, true, false, null, null, null); SettleConfigJob(job, true, false, null, null, null);
else else
RollBackRaidProfiles(job, $"RaidableBases did not load profile {string.Join(", ", failed.ToArray())}", LogTail()); RollBackRaidProfiles(job, $"RaidableBases did not load profile {string.Join(", ", failed.ToArray())}", RaidProfileErrors(job, failed));
} }
else else
{ {
@@ -6863,7 +6911,7 @@ namespace Oxide.Plugins
return; return;
if (job.Phase == ConfigPhase.Edit) if (job.Phase == ConfigPhase.Edit)
RollBackRaidProfiles(job, $"RaidableBases' profile reload did not finish within {ConfigReloadCeilingSeconds:0}s", LogTail()); RollBackRaidProfiles(job, $"RaidableBases' profile reload did not finish within {ConfigReloadCeilingSeconds:0}s", RaidProfileErrors(job, null));
else else
SettleConfigJob(job, false, true, false, $"{job.RollbackReason}; the restored profiles did not finish reloading either", job.RollbackLog); SettleConfigJob(job, false, true, false, $"{job.RollbackReason}; the restored profiles did not finish reloading either", job.RollbackLog);
} }
@@ -6884,6 +6932,148 @@ namespace Oxide.Plugins
SettleConfigJob(job, false, true, false, $"{reason}; the files are back, but RaidableBases would not reload them", log); SettleConfigJob(job, false, true, false, $"{reason}; the files are back, but RaidableBases would not reload them", log);
} }
/// <summary>The most lines of one of RaidableBases' entries a rollback carries: its file, the exception, its message.</summary>
private const int RaidProfileErrorLinesMax = 6;
/// <summary>
/// A log line that begins an entry: Oxide's <c>06:50 [Info] </c> or Carbon's
/// <c>[2026.10.21 18:45:45] [INFO] </c>. Anything else continues the entry above it.
/// </summary>
private static readonly System.Text.RegularExpressions.Regex LogEntryStart =
new System.Text.RegularExpressions.Regex(@"^(\d{2}:\d{2} |\[\d{4}\.\d{2}\.\d{2} \d{2}:\d{2}:\d{2}\] )\[", System.Text.RegularExpressions.RegexOptions.CultureInvariant);
/// <summary>
/// Main thread. What RaidableBases itself logged since the profile write began (W9), for
/// a rollback: an unreadable profile is one entry, the file's path and then the exception
/// (<c>Could not convert string to integer: not a number. Path 'Difficulty Level', line 3</c>),
/// and that much is carried, without the stack. With <paramref name="failed"/>, only the
/// entries naming one of those profiles; with none of those, or none asked for, every
/// entry of its own since the write. Null when it said nothing: the reason line stands
/// alone rather than borrowing the server log's tail, which is other plugins' lines.
/// </summary>
private string RaidProfileErrors(ConfigWriteJob job, List<string> failed)
{
string text = LogSinceMark(job);
if (string.IsNullOrEmpty(text))
return null;
Plugin rb = RaidableBasesPlugin();
var tags = new List<string> { "[RaidableBases]" };
if (rb != null && !string.IsNullOrEmpty(rb.Title))
tags.Add("[" + rb.Title + "]");
var named = new StringBuilder();
var all = new StringBuilder();
StringBuilder entry = null;
bool namesFailed = false;
int kept = 0;
Action close = () =>
{
if (entry == null)
return;
all.Append(entry);
if (namesFailed)
named.Append(entry);
entry = null;
};
foreach (string raw in text.Split('\n'))
{
string line = raw.TrimEnd('\r');
if (LogEntryStart.IsMatch(line))
{
close();
if (!tags.Exists(t => line.IndexOf(t, StringComparison.OrdinalIgnoreCase) >= 0))
continue;
entry = new StringBuilder(line).Append('\n');
kept = 1;
namesFailed = failed != null && failed.Exists(n => line.IndexOf(n + ".json", StringComparison.OrdinalIgnoreCase) >= 0);
continue;
}
// The stack is the plugin's, not the operator's: the message above it is the error.
if (entry == null || kept >= RaidProfileErrorLinesMax || line.TrimStart().StartsWith("at ", StringComparison.Ordinal))
{
if (entry != null)
kept = RaidProfileErrorLinesMax;
continue;
}
if (line.Trim().Length == 0)
continue;
entry.Append(line).Append('\n');
kept++;
}
close();
string found = (named.Length > 0 ? named : all).ToString().TrimEnd('\n');
if (found.Length == 0)
return null;
return found.Length > ConfigLogTailBytes ? found.Substring(0, ConfigLogTailBytes) : found;
}
/// <summary>
/// Main thread. The log written since <see cref="MarkLogPosition"/>, at most
/// <c>ConfigLogPollMaxBytes</c>, without moving the job's own reading place. A log that
/// rotated since is read on from its mark and then from the new file's start.
/// </summary>
private string LogSinceMark(ConfigWriteJob job)
{
var text = new StringBuilder();
try
{
string newest = NewestLogFile();
if (!string.IsNullOrEmpty(job.LogPath) && File.Exists(job.LogPath))
text.Append(ReadLogFrom(job.LogPath, job.LogOffset, ConfigLogPollMaxBytes));
if (newest != null && !string.Equals(newest, job.LogPath, StringComparison.OrdinalIgnoreCase) && text.Length < ConfigLogPollMaxBytes)
text.Append(ReadLogFrom(newest, 0, ConfigLogPollMaxBytes - text.Length));
}
catch (Exception)
{
// A log that cannot be read leaves the rollback its reason line.
}
return text.ToString();
}
private static string ReadLogFrom(string path, long offset, int max)
{
using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
// A log shorter than the mark was truncated: read it from the top.
if (stream.Length < offset)
offset = 0;
int take = (int)Math.Min(stream.Length - offset, max);
if (take <= 0)
return string.Empty;
stream.Seek(offset, SeekOrigin.Begin);
var buffer = new byte[take];
int read = stream.Read(buffer, 0, take);
return Encoding.UTF8.GetString(buffer, 0, read);
}
}
/// <summary> /// <summary>
/// Main thread. If a write touched this plugin's own config, take the one setting that /// Main thread. If a write touched this plugin's own config, take the one setting that
/// is safe to change live — <c>EventsEnabled</c> — from what was written. Returns /// is safe to change live — <c>EventsEnabled</c> — from what was written. Returns
@@ -10525,6 +10715,13 @@ namespace Oxide.Plugins
/// <summary>The run's id for it (a world registry id), or null for a base no run made.</summary> /// <summary>The run's id for it (a world registry id), or null for a base no run made.</summary>
public string Id; public string Id;
/// <summary>
/// The run and step key behind <see cref="Id"/>, kept here too: a teardown takes the
/// base off the record before its despawn raises <c>Ended</c> (W12).
/// </summary>
public string RunId;
public string Key;
} }
private readonly List<LiveRaid> _raids = new List<LiveRaid>(); private readonly List<LiveRaid> _raids = new List<LiveRaid>();
@@ -10782,6 +10979,8 @@ namespace Oxide.Plugins
entry.Started = true; entry.Started = true;
entry.Name = baseName; entry.Name = baseName;
entry.Difficulty = live.Difficulty; entry.Difficulty = live.Difficulty;
live.RunId = entry.RunId;
live.Key = entry.Key;
SaveWorld(); SaveWorld();
} }
@@ -10873,11 +11072,11 @@ namespace Oxide.Plugins
_raids.Remove(live); _raids.Remove(live);
string ours = RaidTagAt(location) ?? live?.Id; string ours = RaidTagAt(location) ?? live?.Id;
WorldEntry entry; WorldEntry entry = null;
// A run's base the plugin ended first, on its own timer or because it was raided: the // A run's base the plugin ended first, on its own timer or because it was raided: the
// run's resource is marked expired (D170). One the run's teardown despawned is already // run's resource is marked expired (D170). One the run's teardown despawned is already
// off the record. // off the record, and its id, run and key come from the live base instead.
if (ours != null && _world.TryGetValue(ours, out entry)) if (ours != null && _world.TryGetValue(ours, out entry))
{ {
_world.Remove(ours); _world.Remove(ours);
@@ -10888,8 +11087,9 @@ namespace Oxide.Plugins
if (!WorldEventsLive()) if (!WorldEventsLive())
return; return;
LiveRaid told = live ?? new LiveRaid { At = location, Level = level, Difficulty = RaidDifficultyName(level), Pvp = allowPvp, Base = baseName, Id = ours }; LiveRaid told = live ?? new LiveRaid { At = location, Level = level, Difficulty = RaidDifficultyName(level), Pvp = allowPvp, Base = baseName };
EmitFrame(RaidFrame(RaidEndedKind, told, null)); told.Id = ours;
EmitFrame(RaidFrame(RaidEndedKind, told, entry));
} }
private void OnRaidableBasePurchased(string userId, UnityEngine.Vector3 location, string grid, int level, bool allowPvp, string baseName, private void OnRaidableBasePurchased(string userId, UnityEngine.Vector3 location, string grid, int level, bool allowPvp, string baseName,
@@ -10948,6 +11148,17 @@ namespace Oxide.Plugins
frame["runId"] = entry.RunId; frame["runId"] = entry.RunId;
frame["key"] = entry.Key; frame["key"] = entry.Key;
} }
else if (!string.IsNullOrEmpty(live.Id))
{
// A run's base no longer on the record: a teardown's despawn (W12).
frame["id"] = live.Id;
if (!string.IsNullOrEmpty(live.RunId))
frame["runId"] = live.RunId;
if (!string.IsNullOrEmpty(live.Key))
frame["key"] = live.Key;
}
return frame; return frame;
} }
@@ -11027,7 +11238,7 @@ namespace Oxide.Plugins
continue; continue;
int level = TupleItem(row, 3) is int l ? l : 0; int level = TupleItem(row, 3) is int l ? l : 0;
_raids.Add(new LiveRaid var live = new LiveRaid
{ {
At = at, At = at,
Level = level, Level = level,
@@ -11036,7 +11247,16 @@ namespace Oxide.Plugins
Base = TupleItem(row, 14) as string, Base = TupleItem(row, 14) as string,
DespawnAtMs = TupleItem(row, 16) is DateTime d ? RaidMs(d) : 0L, DespawnAtMs = TupleItem(row, 16) is DateTime d ? RaidMs(d) : 0L,
Id = RaidTagAt(at) Id = RaidTagAt(at)
}); };
WorldEntry entry;
if (live.Id != null && _world.TryGetValue(live.Id, out entry))
{
live.RunId = entry.RunId;
live.Key = entry.Key;
}
_raids.Add(live);
} }
} }
catch (Exception ex) catch (Exception ex)
@@ -19475,6 +19695,14 @@ namespace Oxide.Plugins
} }
} }
// The game runs one Travelling Vendor at a time, and its event quietly starts nothing
// while one is out (W3). Said, not counted, and not kept: a retry looks again.
if (ev == "travelling_vendor" && TravellingVendorOut())
{
EmitWorldError(reqId, "already-out", "a Travelling Vendor is already out, and the game runs one at a time; nothing was called");
return;
}
int used = 0; int used = 0;
foreach (WorldCall c in _worldCalls.Values) foreach (WorldCall c in _worldCalls.Values)
@@ -19527,6 +19755,16 @@ namespace Oxide.Plugins
EmitFrame(frame); EmitFrame(frame);
} }
/// <summary>Main thread. Whether a Travelling Vendor is on the map now.</summary>
private static bool TravellingVendorOut()
{
foreach (TravellingVendor v in UnityEngine.Object.FindObjectsOfType<TravellingVendor>())
if (v != null && !v.IsDestroyed)
return true;
return false;
}
/// <summary>The game's own schedule for an event, enabled or not: an operator who switched one off may still call it.</summary> /// <summary>The game's own schedule for an event, enabled or not: an operator who switched one off may still call it.</summary>
private static EventSchedule ScheduleFor(string key) private static EventSchedule ScheduleFor(string key)
{ {