all: remove deprecated packages
All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 2m19s
Test / Hakurei (push) Successful in 3m15s
Test / ShareFS (push) Successful in 3m42s
Test / Sandbox (race detector) (push) Successful in 5m8s
Test / Hakurei (race detector) (push) Successful in 5m44s
Test / Flake checks (push) Successful in 1m23s
All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 2m19s
Test / Hakurei (push) Successful in 3m15s
Test / ShareFS (push) Successful in 3m42s
Test / Sandbox (race detector) (push) Successful in 5m8s
Test / Hakurei (race detector) (push) Successful in 5m44s
Test / Flake checks (push) Successful in 1m23s
Closes #24. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
package container
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
"hakurei.app/message"
|
||||
)
|
||||
|
||||
var (
|
||||
executable string
|
||||
executableOnce sync.Once
|
||||
)
|
||||
|
||||
func copyExecutable(msg message.Msg) {
|
||||
if name, err := os.Executable(); err != nil {
|
||||
m := fmt.Sprintf("cannot read executable path: %v", err)
|
||||
if msg != nil {
|
||||
msg.BeforeExit()
|
||||
msg.GetLogger().Fatal(m)
|
||||
} else {
|
||||
log.Fatal(m)
|
||||
}
|
||||
} else {
|
||||
executable = name
|
||||
}
|
||||
}
|
||||
|
||||
// MustExecutable calls [os.Executable] and terminates the process on error.
|
||||
//
|
||||
// Deprecated: This is no longer used and will be removed in 0.4.
|
||||
func MustExecutable(msg message.Msg) string {
|
||||
executableOnce.Do(func() { copyExecutable(msg) })
|
||||
return executable
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package container_test
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"hakurei.app/container"
|
||||
"hakurei.app/message"
|
||||
)
|
||||
|
||||
func TestExecutable(t *testing.T) {
|
||||
t.Parallel()
|
||||
for i := 0; i < 16; i++ {
|
||||
if got := container.MustExecutable(message.New(nil)); got != os.Args[0] {
|
||||
t.Errorf("MustExecutable: %q, want %q", got, os.Args[0])
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
// Package helper exposes the internal/helper package.
|
||||
//
|
||||
// Deprecated: This package will be removed in 0.4.
|
||||
package helper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"time"
|
||||
_ "unsafe" // for go:linkname
|
||||
|
||||
"hakurei.app/container"
|
||||
"hakurei.app/container/check"
|
||||
"hakurei.app/internal/helper"
|
||||
"hakurei.app/message"
|
||||
)
|
||||
|
||||
//go:linkname WaitDelay hakurei.app/internal/helper.WaitDelay
|
||||
var WaitDelay time.Duration
|
||||
|
||||
const (
|
||||
// HakureiHelper is set to 1 when args fd is enabled and 0 otherwise.
|
||||
HakureiHelper = helper.HakureiHelper
|
||||
// HakureiStatus is set to 1 when stat fd is enabled and 0 otherwise.
|
||||
HakureiStatus = helper.HakureiStatus
|
||||
)
|
||||
|
||||
type Helper = helper.Helper
|
||||
|
||||
// NewCheckedArgs returns a checked null-terminated argument writer for a copy of args.
|
||||
//
|
||||
//go:linkname NewCheckedArgs hakurei.app/internal/helper.NewCheckedArgs
|
||||
func NewCheckedArgs(args ...string) (wt io.WriterTo, err error)
|
||||
|
||||
// MustNewCheckedArgs returns a checked null-terminated argument writer for a copy of args.
|
||||
// If s contains a NUL byte this function panics instead of returning an error.
|
||||
//
|
||||
//go:linkname MustNewCheckedArgs hakurei.app/internal/helper.MustNewCheckedArgs
|
||||
func MustNewCheckedArgs(args ...string) io.WriterTo
|
||||
|
||||
// NewDirect initialises a new direct Helper instance with wt as the null-terminated argument writer.
|
||||
// Function argF returns an array of arguments passed directly to the child process.
|
||||
//
|
||||
//go:linkname NewDirect hakurei.app/internal/helper.NewDirect
|
||||
func NewDirect(
|
||||
ctx context.Context,
|
||||
name string,
|
||||
wt io.WriterTo,
|
||||
stat bool,
|
||||
argF func(argsFd, statFd int) []string,
|
||||
cmdF func(cmd *exec.Cmd),
|
||||
extraFiles []*os.File,
|
||||
) Helper
|
||||
|
||||
// New initialises a Helper instance with wt as the null-terminated argument writer.
|
||||
//
|
||||
//go:linkname New hakurei.app/internal/helper.New
|
||||
func New(
|
||||
ctx context.Context,
|
||||
msg message.Msg,
|
||||
pathname *check.Absolute, name string,
|
||||
wt io.WriterTo,
|
||||
stat bool,
|
||||
argF func(argsFd, statFd int) []string,
|
||||
cmdF func(z *container.Container),
|
||||
extraFiles []*os.File,
|
||||
) Helper
|
||||
|
||||
// InternalHelperStub is an internal function but exported because it is cross-package;
|
||||
// it is part of the implementation of the helper stub.
|
||||
func InternalHelperStub() { helper.InternalHelperStub() }
|
||||
@@ -1,63 +0,0 @@
|
||||
// Deprecated: This package will be removed in 0.4.
|
||||
package proc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"time"
|
||||
_ "unsafe" // for go:linkname
|
||||
|
||||
"hakurei.app/internal/helper/proc"
|
||||
)
|
||||
|
||||
//go:linkname FulfillmentTimeout hakurei.app/internal/helper/proc.FulfillmentTimeout
|
||||
var FulfillmentTimeout time.Duration
|
||||
|
||||
// A File is an extra file with deferred initialisation.
|
||||
type File = proc.File
|
||||
|
||||
// ExtraFilesPre is a linked list storing addresses of [os.File].
|
||||
type ExtraFilesPre = proc.ExtraFilesPre
|
||||
|
||||
// Fulfill calls the [File.Fulfill] method on all files, starts cmd and blocks until all fulfillment completes.
|
||||
//
|
||||
//go:linkname Fulfill hakurei.app/internal/helper/proc.Fulfill
|
||||
func Fulfill(ctx context.Context,
|
||||
v *[]*os.File, start func() error,
|
||||
files []File, extraFiles *ExtraFilesPre,
|
||||
) (err error)
|
||||
|
||||
// InitFile initialises f as part of the slice extraFiles points to,
|
||||
// and returns its final fd value.
|
||||
//
|
||||
//go:linkname InitFile hakurei.app/internal/helper/proc.InitFile
|
||||
func InitFile(f File, extraFiles *ExtraFilesPre) (fd uintptr)
|
||||
|
||||
// BaseFile implements the Init method of the File interface and provides indirect access to extra file state.
|
||||
type BaseFile = proc.BaseFile
|
||||
|
||||
//go:linkname ExtraFile hakurei.app/internal/helper/proc.ExtraFile
|
||||
func ExtraFile(cmd *exec.Cmd, f *os.File) (fd uintptr)
|
||||
|
||||
//go:linkname ExtraFileSlice hakurei.app/internal/helper/proc.ExtraFileSlice
|
||||
func ExtraFileSlice(extraFiles *[]*os.File, f *os.File) (fd uintptr)
|
||||
|
||||
// NewWriterTo returns a [File] that receives content from wt on fulfillment.
|
||||
//
|
||||
//go:linkname NewWriterTo hakurei.app/internal/helper/proc.NewWriterTo
|
||||
func NewWriterTo(wt io.WriterTo) File
|
||||
|
||||
// NewStat returns a [File] implementing the behaviour
|
||||
// of the receiving end of xdg-dbus-proxy stat fd.
|
||||
//
|
||||
//go:linkname NewStat hakurei.app/internal/helper/proc.NewStat
|
||||
func NewStat(s *io.Closer) File
|
||||
|
||||
var (
|
||||
//go:linkname ErrStatFault hakurei.app/internal/helper/proc.ErrStatFault
|
||||
ErrStatFault error
|
||||
//go:linkname ErrStatRead hakurei.app/internal/helper/proc.ErrStatRead
|
||||
ErrStatRead error
|
||||
)
|
||||
@@ -1,25 +0,0 @@
|
||||
// Package acl exposes the internal/acl package.
|
||||
//
|
||||
// Deprecated: This package will be removed in 0.4.
|
||||
package acl
|
||||
|
||||
import (
|
||||
_ "unsafe" // for go:linkname
|
||||
|
||||
"hakurei.app/internal/acl"
|
||||
)
|
||||
|
||||
type Perm = acl.Perm
|
||||
|
||||
const (
|
||||
Read = acl.Read
|
||||
Write = acl.Write
|
||||
Execute = acl.Execute
|
||||
)
|
||||
|
||||
// Update replaces ACL_USER entry with qualifier uid.
|
||||
//
|
||||
//go:linkname Update hakurei.app/internal/acl.Update
|
||||
func Update(name string, uid int, perms ...Perm) error
|
||||
|
||||
type Perms = acl.Perms
|
||||
@@ -1,115 +0,0 @@
|
||||
// Package dbus exposes the internal/dbus package.
|
||||
//
|
||||
// Deprecated: This package will be removed in 0.4.
|
||||
package dbus
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
_ "unsafe" // for go:linkname
|
||||
|
||||
"hakurei.app/hst"
|
||||
"hakurei.app/internal/dbus"
|
||||
"hakurei.app/message"
|
||||
)
|
||||
|
||||
type AddrEntry = dbus.AddrEntry
|
||||
|
||||
// EqualAddrEntries returns whether two slices of [AddrEntry] are equal.
|
||||
//
|
||||
//go:linkname EqualAddrEntries hakurei.app/internal/dbus.EqualAddrEntries
|
||||
func EqualAddrEntries(entries, target []AddrEntry) bool
|
||||
|
||||
// Parse parses D-Bus address according to
|
||||
// https://dbus.freedesktop.org/doc/dbus-specification.html#addresses
|
||||
//
|
||||
//go:linkname Parse hakurei.app/internal/dbus.Parse
|
||||
func Parse(addr []byte) ([]AddrEntry, error)
|
||||
|
||||
type ParseError = dbus.ParseError
|
||||
|
||||
const (
|
||||
ErrNoColon = dbus.ErrNoColon
|
||||
ErrBadPairSep = dbus.ErrBadPairSep
|
||||
ErrBadPairKey = dbus.ErrBadPairKey
|
||||
ErrBadPairVal = dbus.ErrBadPairVal
|
||||
ErrBadValLength = dbus.ErrBadValLength
|
||||
ErrBadValByte = dbus.ErrBadValByte
|
||||
ErrBadValHexLength = dbus.ErrBadValHexLength
|
||||
ErrBadValHexByte = dbus.ErrBadValHexByte
|
||||
)
|
||||
|
||||
type BadAddressError = dbus.BadAddressError
|
||||
|
||||
// ProxyPair is an upstream dbus address and a downstream socket path.
|
||||
type ProxyPair = dbus.ProxyPair
|
||||
|
||||
// Args returns the xdg-dbus-proxy arguments equivalent of [hst.BusConfig].
|
||||
//
|
||||
//go:linkname Args hakurei.app/internal/dbus.Args
|
||||
func Args(c *hst.BusConfig, bus ProxyPair) (args []string)
|
||||
|
||||
// NewConfig returns the address of a new [hst.BusConfig] with optional defaults.
|
||||
//
|
||||
//go:linkname NewConfig hakurei.app/internal/dbus.NewConfig
|
||||
func NewConfig(id string, defaults, mpris bool) *hst.BusConfig
|
||||
|
||||
const (
|
||||
/*
|
||||
SessionBusAddress is the name of the environment variable where the address of the login session message bus is given in.
|
||||
|
||||
If that variable is not set, applications may also try to read the address from the X Window System root window property _DBUS_SESSION_BUS_ADDRESS.
|
||||
The root window property must have type STRING. The environment variable should have precedence over the root window property.
|
||||
|
||||
The address of the login session message bus is given in the DBUS_SESSION_BUS_ADDRESS environment variable.
|
||||
If DBUS_SESSION_BUS_ADDRESS is not set, or if it's set to the string "autolaunch:",
|
||||
the system should use platform-specific methods of locating a running D-Bus session server,
|
||||
or starting one if a running instance cannot be found.
|
||||
Note that this mechanism is not recommended for attempting to determine if a daemon is running.
|
||||
It is inherently racy to attempt to make this determination, since the bus daemon may be started just before or just after the determination is made.
|
||||
Therefore, it is recommended that applications do not try to make this determination for their functionality purposes, and instead they should attempt to start the server.
|
||||
|
||||
This package diverges from the specification, as the caller is unlikely to be an X client, or be in a position to autolaunch a dbus server.
|
||||
So a fallback address with a socket located in the well-known default XDG_RUNTIME_DIR formatting is used.
|
||||
*/
|
||||
SessionBusAddress = dbus.SessionBusAddress
|
||||
|
||||
/*
|
||||
SystemBusAddress is the name of the environment variable where the address of the system message bus is given in.
|
||||
|
||||
If that variable is not set, applications should try to connect to the well-known address unix:path=/var/run/dbus/system_bus_socket.
|
||||
Implementations of the well-known system bus should listen on an address that will result in that connection being successful.
|
||||
*/
|
||||
SystemBusAddress = dbus.SystemBusAddress
|
||||
|
||||
// FallbackSystemBusAddress is used when [SystemBusAddress] is not set.
|
||||
FallbackSystemBusAddress = dbus.FallbackSystemBusAddress
|
||||
)
|
||||
|
||||
// Address returns the session and system bus addresses copied from environment,
|
||||
// or appropriate fallback values if they are not set.
|
||||
//
|
||||
//go:linkname Address hakurei.app/internal/dbus.Address
|
||||
func Address() (session, system string)
|
||||
|
||||
// ProxyName is the file name or path to the proxy program.
|
||||
// Overriding ProxyName will only affect Proxy instance created after the change.
|
||||
//
|
||||
//go:linkname ProxyName hakurei.app/internal/dbus.ProxyName
|
||||
var ProxyName string
|
||||
|
||||
// Proxy holds the state of a xdg-dbus-proxy process, and should never be copied.
|
||||
type Proxy = dbus.Proxy
|
||||
|
||||
// Final describes the outcome of a proxy configuration.
|
||||
type Final = dbus.Final
|
||||
|
||||
// Finalise creates a checked argument writer for [Proxy].
|
||||
//
|
||||
//go:linkname Finalise hakurei.app/internal/dbus.Finalise
|
||||
func Finalise(sessionBus, systemBus ProxyPair, session, system *hst.BusConfig) (final *Final, err error)
|
||||
|
||||
// New returns a new instance of [Proxy].
|
||||
//
|
||||
//go:linkname New hakurei.app/internal/dbus.New
|
||||
func New(ctx context.Context, msg message.Msg, final *Final, output io.Writer) *Proxy
|
||||
@@ -1,50 +0,0 @@
|
||||
// Package system exposes the internal/system package.
|
||||
//
|
||||
// Deprecated: This package will be removed in 0.4.
|
||||
package system
|
||||
|
||||
import (
|
||||
"context"
|
||||
_ "unsafe" // for go:linkname
|
||||
|
||||
"hakurei.app/hst"
|
||||
"hakurei.app/internal/system"
|
||||
"hakurei.app/message"
|
||||
)
|
||||
|
||||
// ErrDBusConfig is returned when a required hst.BusConfig argument is nil.
|
||||
//
|
||||
//go:linkname ErrDBusConfig hakurei.app/internal/system.ErrDBusConfig
|
||||
var ErrDBusConfig error
|
||||
|
||||
// OpError is returned by [I.Commit] and [I.Revert].
|
||||
type OpError = system.OpError
|
||||
|
||||
const (
|
||||
// User type is reverted at final instance exit.
|
||||
User = system.User
|
||||
// Process type is unconditionally reverted on exit.
|
||||
Process = system.Process
|
||||
|
||||
CM = system.CM
|
||||
)
|
||||
|
||||
// Criteria specifies types of Op to revert.
|
||||
type Criteria = system.Criteria
|
||||
|
||||
// Op is a reversible system operation.
|
||||
type Op = system.Op
|
||||
|
||||
// TypeString extends [Enablement.String] to support [User] and [Process].
|
||||
//
|
||||
//go:linkname TypeString hakurei.app/internal/system.TypeString
|
||||
func TypeString(e hst.Enablement) string
|
||||
|
||||
// New returns the address of a new [I] targeting uid.
|
||||
//
|
||||
//go:linkname New hakurei.app/internal/system.New
|
||||
func New(ctx context.Context, msg message.Msg, uid int) (sys *I)
|
||||
|
||||
// An I provides deferred operating system interaction. [I] must not be copied.
|
||||
// Methods of [I] must not be used concurrently.
|
||||
type I = system.I
|
||||
@@ -1,144 +0,0 @@
|
||||
// Package wayland exposes the internal/wayland package.
|
||||
//
|
||||
// Deprecated: This package will be removed in 0.4.
|
||||
package wayland
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net"
|
||||
"os"
|
||||
"runtime"
|
||||
"sync"
|
||||
"syscall"
|
||||
_ "unsafe" // for go:linkname
|
||||
|
||||
"hakurei.app/internal/wayland"
|
||||
)
|
||||
|
||||
//go:linkname bindWaylandFd hakurei.app/internal/wayland.bindWaylandFd
|
||||
func bindWaylandFd(socketPath string, fd uintptr, appID, instanceID string, syncFd uintptr) error
|
||||
|
||||
// Conn represents a connection to the wayland display server.
|
||||
//
|
||||
// Deprecated: this interface is being replaced.
|
||||
// Additionally, the package it belongs to will be removed in 0.4.
|
||||
type Conn struct {
|
||||
conn *net.UnixConn
|
||||
|
||||
done chan struct{}
|
||||
doneOnce sync.Once
|
||||
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
// Attach connects Conn to a wayland socket.
|
||||
func (c *Conn) Attach(p string) (err error) {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
|
||||
if c.conn != nil {
|
||||
return errors.New("socket already attached")
|
||||
}
|
||||
|
||||
c.conn, err = net.DialUnix("unix", nil, &net.UnixAddr{Name: p, Net: "unix"})
|
||||
return
|
||||
}
|
||||
|
||||
// Close releases resources and closes the connection to the wayland compositor.
|
||||
func (c *Conn) Close() error {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
|
||||
if c.done == nil {
|
||||
return errors.New("no socket bound")
|
||||
}
|
||||
|
||||
c.doneOnce.Do(func() {
|
||||
c.done <- struct{}{}
|
||||
<-c.done
|
||||
})
|
||||
|
||||
// closed by wayland
|
||||
runtime.SetFinalizer(c.conn, nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Bind binds the new socket to pathname.
|
||||
func (c *Conn) Bind(pathname, appID, instanceID string) (*os.File, error) {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
|
||||
if c.conn == nil {
|
||||
return nil, errors.New("socket not attached")
|
||||
}
|
||||
if c.done != nil {
|
||||
return nil, errors.New("socket already bound")
|
||||
}
|
||||
|
||||
if rc, err := c.conn.SyscallConn(); err != nil {
|
||||
// unreachable
|
||||
return nil, err
|
||||
} else {
|
||||
c.done = make(chan struct{})
|
||||
if closeFds, err := bindRawConn(c.done, rc, pathname, appID, instanceID); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return os.NewFile(uintptr(closeFds[1]), "close_fd"), nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func bindRawConn(done chan struct{}, rc syscall.RawConn, p, appID, instanceID string) ([2]int, error) {
|
||||
var closeFds [2]int
|
||||
if err := syscall.Pipe2(closeFds[0:], syscall.O_CLOEXEC); err != nil {
|
||||
return closeFds, err
|
||||
}
|
||||
|
||||
setupDone := make(chan error, 1) // does not block with c.done
|
||||
|
||||
go func() {
|
||||
if err := rc.Control(func(fd uintptr) {
|
||||
// allow the Bind method to return after setup
|
||||
setupDone <- bind(fd, p, appID, instanceID, uintptr(closeFds[1]))
|
||||
close(setupDone)
|
||||
|
||||
// keep socket alive until done is requested
|
||||
<-done
|
||||
}); err != nil {
|
||||
setupDone <- err
|
||||
}
|
||||
|
||||
// notify Close that rc.Control has returned
|
||||
close(done)
|
||||
}()
|
||||
|
||||
// return write end of the pipe
|
||||
return closeFds, <-setupDone
|
||||
}
|
||||
|
||||
func bind(fd uintptr, p, appID, instanceID string, syncFd uintptr) error {
|
||||
// ensure p is available
|
||||
if f, err := os.Create(p); err != nil {
|
||||
return err
|
||||
} else if err = f.Close(); err != nil {
|
||||
return err
|
||||
} else if err = os.Remove(p); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return bindWaylandFd(p, fd, appID, instanceID, syncFd)
|
||||
}
|
||||
|
||||
const (
|
||||
// WaylandDisplay contains the name of the server socket
|
||||
// (https://gitlab.freedesktop.org/wayland/wayland/-/blob/1.23.1/src/wayland-client.c#L1147)
|
||||
// which is concatenated with XDG_RUNTIME_DIR
|
||||
// (https://gitlab.freedesktop.org/wayland/wayland/-/blob/1.23.1/src/wayland-client.c#L1171)
|
||||
// or used as-is if absolute
|
||||
// (https://gitlab.freedesktop.org/wayland/wayland/-/blob/1.23.1/src/wayland-client.c#L1176).
|
||||
WaylandDisplay = wayland.Display
|
||||
|
||||
// FallbackName is used as the wayland socket name if WAYLAND_DISPLAY is unset
|
||||
// (https://gitlab.freedesktop.org/wayland/wayland/-/blob/1.23.1/src/wayland-client.c#L1149).
|
||||
FallbackName = wayland.FallbackName
|
||||
)
|
||||
Reference in New Issue
Block a user