github.com/godbus/dbus/v5 v5.2.4, patched for lys-lib
A copy of github.com/godbus/dbus/v5 v5.2.4 (4e46d5e, BSD 2-Clause, LICENSE; the descriptor decoding bugs are unfixed there and on master, which is v5.2.4 as of 2026-10-28), its non-test sources and lys-lib's own tests, carried as packages of the lys-lib module and imported as github.com/stubbedev/lys/lib/third_party/godbus (package dbus), .../godbus/introspect and .../godbus/prop. Every lys process on D-Bus talks to it through this copy, directly or through dbusx.
Why it lives inside the module
As with third_party/oksvg: Go ignores a dependency's replace directives, so a patched godbus wired in through go.mod (lys-shell's third_party/godbus-dbus, which this copy replaces) reached only that module's own builds, and anything importing its packages built against upstream. As packages of the lys-lib module, the patches reach every application importing lys-lib, with no replace.
Patches
Drop the copy once upstream carries every fix below.
lys_received_fds.go(withdecoder.go,sig.go'stypeWithFDs): with the message's descriptors at hand everyhdecodes to itsUnixFD, and the containers around it are built for that type, at any depth. Upstream resolved anhas it met one but built arrays and dicts forUnixFDIndex: anah(xdg-desktop-portal's Emailattachment_fds) arrived with an empty body up to v5.2.2, and since v5.2.3, which re-panics what is not an error, the reflect panic crashed the read loop and the process. A first patch fixed the bareahonly; a dict or a nested array of descriptors (a{sh},a{sah},aah,a{hs}) still did it, and any bus peer can send one. An index past the descriptors is an InvalidMessageError. A body naming one descriptor twice decodes to that descriptor and a duplicate (F_DUPFD_CLOEXEC, -1 when the process has no room), where upstream decoded one descriptor held twice, which its receiver closed twice. Without descriptors (DecodeMessage) anhstays aUnixFDIndex, in every container alike. Pinned bylys_fd_array_test.go,TestDescriptorsDecodeInsideEveryContainer,TestADescriptorNamedTwiceIsDecodedAsTwoDescriptors,TestDescriptorsStayIndicesWithoutTheMessagesDescriptorsandTestADictOfDescriptorsArrives.lys_received_fds_unix.go(withtransport_unix.go'sreadMessage,conn.go's read loop and call tracker,export.go'shandleCall): every descriptor that comes with a message is the decoded body's or is closed. Upstream closed none: those a body did not name, those of a message that failed to decode or was invalid, those attached to a message declaring none, those of a reply nobody waits for, of a message for a name the connection does not own, and of a call no method is run for (no such object, interface or method, arguments of other types) stayed open, so a peer could fill a process's descriptor table. A message that comes with another number of descriptors than its header declares is an InvalidMessageError; upstream indexed the descriptors it had received by the count the header promised and panicked when there were fewer. Control data received by a read that then failed or was truncated is kept so that its descriptors are closed too. Pinned byTestTheDescriptorsOfAReadMessageAreTheBodysOrClosedandTestTheDescriptorsOfACallNoMethodRunsForAreClosed.decoder.go,Decode, andlys_received_fds.go'sdecodeFailure: no panic leavesDecode. One that is not the decoder's own error or its reader's (a reflect panic, a runtime error) is an InvalidMessageError, for which the read loop drops the message and keeps the connection; upstream re-panicked it, so a decoder defect met on a message a peer chose took the process down. A header that does not decode is never an InvalidMessageError (headerError): its body is unread, and reading on would take the body for the next message. Pinned byTestAPanicWhileDecodingIsThatMessagesError,TestAnUndecodableHeaderIsNotASkippedMessageandFuzzDecodeBodyWithDescriptors, which decodes bodies with descriptors attached and stores, re-encodes and closes what they decode to.sig.go,validSingle, anddbus.go,isKeyType: an empty struct is no signature, and a dict entry's key is a basic type, any of them. Upstream accepted(), and decoding ana()never ended, since no element takes a byte of the array's length; it accepted a variant as a key, a dict type nothing can encode or name the signature of (SignatureOfpanicked on the decoded value); and it refused boolean and signature keys, so a peer'sa{bs}ended the connection. Pinned byTestAnEmptyStructIsNoSignatureandTestEveryBasicTypeKeysADict.transport_unix.goandmessage.go: the header and body lengths are summed in 64 bits. A header length near 2^32 wrapped below the 128 MiB message limit, and the unix transport then read up to 4 GiB of header into memory. Pinned byTestTheTransportRefusesLengthsNearTheWrapandTestLengthsNearTheWrapAreTooLong.conn.go,handleSignal: aNameLostorNameAcquiredwithout its name is ignored. Upstream panicked on one, and on a connection to a peer rather than a bus the peer chooses the sender and the body. Pinned byTestAnOwnershipSignalWithoutItsNameIsIgnored.conn.go,getSessionBusAddress: an address found in the runtime directory is returned, not also written intoDBUS_SESSION_BUS_ADDRESS. Upstream set the variable, so connecting to the session bus changed the environment of the whole process and of every child it started afterwards. Pinned byTestFindingTheSessionBusLeavesTheEnvironmentAsItWas.lys_close.go(withconn.go,auth.go,export.go,lys_ordered.go):Closereturns once the goroutines the connection runs its own code on have ended: the read loop, the watcher of its context, the watcher of each pending call's context (which now ends with the connection too, where upstream's stayed until the call's context ended), each dispatched method call and each ordered lane. Upstream'sClosereturned with all of them winding down, so a closed connection's goroutines were still running in the next test of a program that counts them. A goroutine is not counted while it runs the application's code (an exported method, an interceptor, a signal handler other than this package's two), so that code may take its time and may itself close the connection; the connection's own goroutines close it through the non-waitingclose. Pinned byTestCloseWaitsForTheGoroutinesOfTheConnection,TestAMethodMayCloseItsOwnConnectionandTestAConnectionClosedByItsContextLeavesNoGoroutine, by goroutine id.- No initialisation: importing the package runs no code. Upstream built maps (
sigToType,varTypeMap, the variant parser's signature sets,transports, which each transport's file filled from aninit), a table of header field types, a variable for the reflect type of each D-Bus type (reflect.TypeForwhere one is used now, which costs a load) and the machine's byte order when the package was imported. They are switches (basicTypeOf,varTypeSig,fieldType,transportFor, withlys_transport_absent_*.gonaming the transports a build leaves out) and functions called on use (nativeEndian, the signature sets). Pinned byTestImportingCostsNothing. encoder.go, casevariantType, andlys_encode_as.go: a Variant's value is encoded by the Variant's signature.decodereturns a struct as[]any, which the Go-type encoder wrote as an array of variants under the struct signature: a malformed message, which dbus-daemon answers by disconnecting the sender. Echoing a decoded GIcon (DynamicLauncher's PrepareInstall) killed the portal's bus connection. Pinned byTestDecodedStructsReencode.lys_file_reply.go(withsig.go,encoder.go,dbus.go,export.go):*os.Filemarshals ash, and the files an exported method replies are closed once the reply is sent. A method returning a bare UnixFD had no safe moment to close its copy, since the reply goes out after it returns. The portal's clipboard pipes and PipeWire remote ride on this. Pinned byTestAFileReplyIsSentThenClosed.lys_ordered.go(withconn.go's read loop):DispatchInOrderruns an interface's named methods one at a time in arrival order on one goroutine, through a queue bounded at 256 that holds back the read loop when full; every other call still runs on a goroutine of its own. Upstream dispatches each call on its own goroutine, so calls a sender does not wait on race: xdg-desktop-portal forwards RemoteDesktop input that way, and a click could land before the motion that placed it. Pinned byTestOrderedCallsRunInArrivalOrder.prop/prop.go,set: a new value is stored into a fresh allocation that replaces the property's, not into the existing one.GetandGetAllhand out the stored value (a slice shares its backing array) and the reply is encoded after the read lock is released, so storing in place raced with that encode and could rewrite a reply mid-flight; the race detector caught it on a fake NetworkManager'sActiveConnections. Pinned byprop/lys_set_test.go.default_handler.goandexport.go: the handler's object table is read and changed only under its lock.PathExists,introspectPathandunexportread it unlocked, andexportadded a path's object and then its interface in two separate steps, so exporting and unexporting from several goroutines (lys-secrets' prompts and sessions) raced, and a call could find an object between the steps.addInterfaceanddeleteInterfacenow do each change in one locked step. Pinned byTestConcurrentExportsAndCalls.lys_signal_fds.go(withconn.go'shandleSignal,default_handler.goandsequential_handler.go): each channel a signal is delivered to owns the descriptors in theSignalit receives. Upstream hands oneSignal, and so the sameUnixFDvalues, to every channel registered withConn.Signal: two readers of logind'sResumeDeviceon one connection closed one descriptor twice, or one used it after the other had closed it. A signal that came with descriptors now reaches the last channel as it was read and every other channel as a copy holding duplicates (F_DUPFD_CLOEXEC) of them, at any depth of the body; one that cannot be duplicated arrives as -1. The descriptors of a signal no channel takes (none registered, the channel removed with the signal undelivered, the connection closed) are closed, where upstream leaked them. A reader that does not take a signal's descriptors over closes them withSignal.CloseFDs(CloseFDsfor a reply's body), which costs nothing for a signal that came without any. A signal without descriptors is still oneSignalshared by every channel. Pinned byTestEachSignalChannelOwnsItsDescriptors,TestDescriptorsOfASignalNoChannelTakesAreClosedandTestMapFDsReachesEveryDescriptorOfADecodedBody.conn_other.go,getRuntimeDirectory: withDBUS_SESSION_BUS_ADDRESSunset the session bus is looked for at$XDG_RUNTIME_DIR/bus, as libdbus and sd-bus do. Upstream looks in/run/user/<uid>whateverXDG_RUNTIME_DIRsays, so a process given a runtime directory of its own (a test, a nested session) joined the bus of the user's login session and missed the one in its own directory./run/user/<uid>remains the guess only whereXDG_RUNTIME_DIRnames no absolute path. Pinned byTestTheSessionBusIsFoundInTheRuntimeDirectoryandTestARuntimeDirectoryWithoutABusHasNoSessionBus.auth.go,Auth: BEGIN goes out in one write withNEGOTIATE_UNIX_FD, before its answer is read, as sd-bus sends it. Upstream wrote BEGIN after reading the answer, right before the first message, so a server could read both at once; sd-bus, serving a systemd manager's private socket, then keeps that message in its buffer unparsed until more bytes arrive, and a connection's loneThawUnit(lys-power resuming a user's unit) never got its reply. A transport without descriptors still sends BEGIN after OK. Pinned byTestBeginGoesOutWithTheUnixFDNegotiation.- Import path: every source imports
github.com/stubbedev/lys/lib/third_party/godbusin place ofgithub.com/godbus/dbus/v5, and the copy has no go.mod of its own. Upstream's tests, CI files and fuzz corpus are not carried; the tests named above pin the patches, the bus-dependent ones (lys_bus_test.go) on a private bus fromdbustest.
The copy follows lys-lib's Go version, with golangci-lint's modernize fixes applied to the v5.2.2 sources: reflect.TypeFor and TypeAssert, strings.SplitSeq and CutLast, range over ints and over Fields/Methods, slices.Backward and strings.Builder where upstream predates them. No behaviour changes; upstream's tests passed under -race on a private session bus when they were applied, in lys-shell. The v5.2.2..v5.2.4 changes are carried as upstream wrote them.
No dbus-launch
getSessionBusPlatformAddress returns ErrNoSessionBus where upstream runs dbus-launch. That forked a session bus nothing ever stopped, once per call: test runs without a bus left 596 daemons behind, which used up the host's inotify instances, and a program joined a bus no other program was on.