Skip to content

Commit

Permalink
many: do not use nss when looking up for users/groups from snapd snap
Browse files Browse the repository at this point in the history
  • Loading branch information
valentindavid committed Apr 2, 2024
1 parent 348e115 commit 7b51d5b
Show file tree
Hide file tree
Showing 51 changed files with 288 additions and 53 deletions.
6 changes: 2 additions & 4 deletions build-aux/snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ parts:
- squashfs-tools
- xdelta3
- zlib1g
# This is needed for using os/user on Ubuntu Core
# TODO: do not use os/user, but io.systemd.NameServiceSwitch through dbus
- libnss-extrausers
stage:
- -usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/ld*.so*
- -lib32
Expand All @@ -108,9 +105,9 @@ parts:
- -usr/share/man
- -usr/share/lintian
- -usr/share/lintian/**
- -usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/libnss_*.so.2
override-build: |
craftctl default
mv "${CRAFT_PART_INSTALL}/usr/lib/libnss_extrausers.so.2" "${CRAFT_PART_INSTALL}/usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}/"
cp -rT "${CRAFT_PART_INSTALL}/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}" "${CRAFT_PART_INSTALL}/usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}"
rm -rf "${CRAFT_PART_INSTALL}/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}"
find "${CRAFT_PART_INSTALL}/usr/share/doc" \( -not -type d -not -name "copyright" -delete \) -o \( -type d -empty -delete \)
Expand Down Expand Up @@ -274,6 +271,7 @@ parts:
esac
;;
esac
TAGS+=(snap osusergo)
output="${CRAFT_PART_INSTALL}/usr/${cmd}"
go build -mod=vendor -tags "${TAGS[*]}" "${GO_LD_FLAGS[@]}" ${EXTRA_GO_FLAGS-} -o "${output}" "github.com/snapcore/snapd/cmd/$(basename ${cmd})"
Expand Down
2 changes: 1 addition & 1 deletion client/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ import (
"errors"
"fmt"
"net/url"
"os/user"
"strconv"
"strings"
"time"

"github.com/snapcore/snapd/osutil/user"
"github.com/snapcore/snapd/snap"
)

Expand Down
2 changes: 1 addition & 1 deletion client/apps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ package client_test
import (
"encoding/json"
"fmt"
"os/user"
"strconv"
"strings"

"gopkg.in/check.v1"

"github.com/snapcore/snapd/client"
"github.com/snapcore/snapd/osutil/user"
)

func mksvc(snap, app string) *client.AppInfo {
Expand Down
2 changes: 1 addition & 1 deletion client/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import (
"encoding/json"
"fmt"
"os"
"os/user"
"path/filepath"

"github.com/snapcore/snapd/osutil"
"github.com/snapcore/snapd/osutil/sys"
"github.com/snapcore/snapd/osutil/user"
)

// User holds logged in user information.
Expand Down
2 changes: 1 addition & 1 deletion cmd/snap/cmd_routine_file_access_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ import (
"fmt"
"net/http"
"net/url"
"os/user"
"path/filepath"
"strings"

. "gopkg.in/check.v1"

"github.com/snapcore/snapd/client"
snap "github.com/snapcore/snapd/cmd/snap"
"github.com/snapcore/snapd/osutil/user"
)

type SnapRoutineFileAccessSuite struct {
Expand Down
2 changes: 1 addition & 1 deletion cmd/snap/cmd_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"net"
"os"
"os/exec"
"os/user"
"path/filepath"
"regexp"
"strconv"
Expand All @@ -49,6 +48,7 @@ import (
"github.com/snapcore/snapd/logger"
"github.com/snapcore/snapd/osutil"
"github.com/snapcore/snapd/osutil/strace"
"github.com/snapcore/snapd/osutil/user"
"github.com/snapcore/snapd/sandbox/cgroup"
"github.com/snapcore/snapd/sandbox/selinux"
"github.com/snapcore/snapd/snap"
Expand Down
2 changes: 1 addition & 1 deletion cmd/snap/cmd_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"fmt"
"net/http"
"os"
"os/user"
"path/filepath"
"strings"
"time"
Expand All @@ -43,6 +42,7 @@ import (
"github.com/snapcore/snapd/logger"
"github.com/snapcore/snapd/osutil"
"github.com/snapcore/snapd/osutil/strace"
"github.com/snapcore/snapd/osutil/user"
"github.com/snapcore/snapd/progress"
"github.com/snapcore/snapd/progress/progresstest"
"github.com/snapcore/snapd/sandbox/cgroup"
Expand Down
2 changes: 1 addition & 1 deletion cmd/snap/cmd_userd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"net"
"net/http"
"os"
"os/user"
"path"
"path/filepath"
"strings"
Expand All @@ -38,6 +37,7 @@ import (
"github.com/snapcore/snapd/dirs"
"github.com/snapcore/snapd/logger"
"github.com/snapcore/snapd/osutil"
"github.com/snapcore/snapd/osutil/user"
"github.com/snapcore/snapd/testutil"
"github.com/snapcore/snapd/usersession/autostart"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/snap/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"fmt"
"go/doc"
"os"
"os/user"
"strings"
"text/tabwriter"

Expand All @@ -35,6 +34,7 @@ import (
"github.com/snapcore/snapd/i18n"
"github.com/snapcore/snapd/logger"
"github.com/snapcore/snapd/osutil"
"github.com/snapcore/snapd/osutil/user"
"github.com/snapcore/snapd/snap/channel"
"github.com/snapcore/snapd/strutil"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/snap/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ package main
import (
"context"
"os"
"os/user"
"time"

"github.com/jessevdk/go-flags"
Expand All @@ -31,6 +30,7 @@ import (
"github.com/snapcore/snapd/cmd/snaplock/runinhibit"
"github.com/snapcore/snapd/image"
"github.com/snapcore/snapd/osutil"
"github.com/snapcore/snapd/osutil/user"
"github.com/snapcore/snapd/sandbox/cgroup"
"github.com/snapcore/snapd/sandbox/selinux"
"github.com/snapcore/snapd/seed/seedwriter"
Expand Down
2 changes: 1 addition & 1 deletion daemon/api_apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ import (
"fmt"
"io"
"net/http"
"os/user"
"sort"
"strconv"
"strings"

"github.com/snapcore/snapd/client/clientutil"
"github.com/snapcore/snapd/osutil/user"
"github.com/snapcore/snapd/overlord/auth"
"github.com/snapcore/snapd/overlord/servicestate"
"github.com/snapcore/snapd/overlord/state"
Expand Down
2 changes: 1 addition & 1 deletion daemon/api_apps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"math"
"net/http"
"net/http/httptest"
"os/user"
"sort"
"strconv"
"strings"
Expand All @@ -38,6 +37,7 @@ import (

"github.com/snapcore/snapd/client"
"github.com/snapcore/snapd/daemon"
"github.com/snapcore/snapd/osutil/user"
"github.com/snapcore/snapd/overlord/hookstate"
"github.com/snapcore/snapd/overlord/servicestate"
"github.com/snapcore/snapd/overlord/snapstate"
Expand Down
2 changes: 1 addition & 1 deletion daemon/api_base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"io/ioutil"
"net/http"
"os"
"os/user"
"path/filepath"
"time"

Expand All @@ -41,6 +40,7 @@ import (
"github.com/snapcore/snapd/daemon"
"github.com/snapcore/snapd/dirs"
"github.com/snapcore/snapd/osutil"
"github.com/snapcore/snapd/osutil/user"
"github.com/snapcore/snapd/overlord"
"github.com/snapcore/snapd/overlord/assertstate"
"github.com/snapcore/snapd/overlord/assertstate/assertstatetest"
Expand Down
2 changes: 1 addition & 1 deletion daemon/api_users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"bytes"
"fmt"
"net/http"
"os/user"
"time"

"gopkg.in/check.v1"
Expand All @@ -32,6 +31,7 @@ import (
"github.com/snapcore/snapd/asserts/assertstest"
"github.com/snapcore/snapd/client"
"github.com/snapcore/snapd/daemon"
"github.com/snapcore/snapd/osutil/user"
"github.com/snapcore/snapd/overlord/assertstate/assertstatetest"
"github.com/snapcore/snapd/overlord/auth"
"github.com/snapcore/snapd/overlord/configstate/config"
Expand Down
3 changes: 1 addition & 2 deletions daemon/export_api_apps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
package daemon

import (
"os/user"

"github.com/snapcore/snapd/osutil/user"
"github.com/snapcore/snapd/overlord/hookstate"
"github.com/snapcore/snapd/overlord/servicestate"
"github.com/snapcore/snapd/overlord/state"
Expand Down
2 changes: 1 addition & 1 deletion daemon/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ package daemon
import (
"context"
"net/http"
"os/user"
"time"

"github.com/gorilla/mux"

"github.com/snapcore/snapd/asserts/snapasserts"
"github.com/snapcore/snapd/boot"
"github.com/snapcore/snapd/osutil/user"
"github.com/snapcore/snapd/overlord"
"github.com/snapcore/snapd/overlord/assertstate"
"github.com/snapcore/snapd/overlord/restart"
Expand Down
2 changes: 1 addition & 1 deletion desktop/portal/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ package portal

import (
"fmt"
"os/user"
"path/filepath"
"strings"

"github.com/snapcore/snapd/dbusutil"
"github.com/snapcore/snapd/dirs"
"github.com/snapcore/snapd/i18n"
"github.com/snapcore/snapd/osutil/user"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion desktop/portal/document_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ package portal_test
import (
"errors"
"os"
"os/user"
"path/filepath"

"github.com/godbus/dbus"
. "gopkg.in/check.v1"

"github.com/snapcore/snapd/osutil/user"
"github.com/snapcore/snapd/desktop/portal"
"github.com/snapcore/snapd/testutil"
)
Expand Down
2 changes: 1 addition & 1 deletion desktop/portal/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
package portal

import (
"os/user"
"time"

"github.com/snapcore/snapd/dirs"
"github.com/snapcore/snapd/osutil/user"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion osutil/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ import (
"io/ioutil"
"os"
"os/exec"
"os/user"
"syscall"
"time"

"github.com/snapcore/snapd/osutil/sys"
"github.com/snapcore/snapd/osutil/user"
"github.com/snapcore/snapd/strutil"
"github.com/snapcore/snapd/testutil"
)
Expand Down
3 changes: 2 additions & 1 deletion osutil/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ package osutil
import (
"bytes"
"fmt"
"os/user"
"strconv"

"github.com/snapcore/snapd/osutil/user"
)

// FindUid returns the identifier of the given UNIX user name. It will
Expand Down
2 changes: 1 addition & 1 deletion osutil/group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ package osutil_test

import (
"fmt"
"os/user"

"gopkg.in/check.v1"

"github.com/snapcore/snapd/osutil"
"github.com/snapcore/snapd/osutil/user"
"github.com/snapcore/snapd/testutil"
)

Expand Down
2 changes: 1 addition & 1 deletion osutil/strace/strace.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ package strace
import (
"fmt"
"os/exec"
"os/user"
"path/filepath"
"runtime"

"github.com/snapcore/snapd/dirs"
"github.com/snapcore/snapd/osutil"
"github.com/snapcore/snapd/osutil/user"
)

// These syscalls are excluded because they make strace hang on all or
Expand Down
2 changes: 1 addition & 1 deletion osutil/strace/strace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ package strace_test

import (
"os"
"os/user"
"path/filepath"
"testing"

. "gopkg.in/check.v1"

"github.com/snapcore/snapd/dirs"
"github.com/snapcore/snapd/osutil/user"
"github.com/snapcore/snapd/osutil/strace"
"github.com/snapcore/snapd/testutil"
)
Expand Down
2 changes: 1 addition & 1 deletion osutil/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ import (
"fmt"
"os"
"os/exec"
"os/user"
"path/filepath"
"regexp"
"strconv"
"strings"
"syscall"

"github.com/snapcore/snapd/osutil/sys"
"github.com/snapcore/snapd/osutil/user"
)

var (
Expand Down
Loading

0 comments on commit 7b51d5b

Please sign in to comment.