Sha256: a4c0d37ca8649782a6d47ddb7faa37c49ecfc1a8fe2dc47ef011bd98a581ccf4

Contents?: true

Size: 617 Bytes

Versions: 16

Compression:

Stored size: 617 Bytes

Contents

// +build static_build

package dbus

import (
	"bufio"
	"os"
	"strconv"
	"strings"
)

func lookupHomeDir() string {
	myUid := os.Getuid()

	f, err := os.Open("/etc/passwd")
	if err != nil {
		return "/"
	}
	defer f.Close()

	s := bufio.NewScanner(f)

	for s.Scan() {
		if err := s.Err(); err != nil {
			break
		}

		line := strings.TrimSpace(s.Text())
		if line == "" {
			continue
		}

		parts := strings.Split(line, ":")

		if len(parts) >= 6 {
			uid, err := strconv.Atoi(parts[2])
			if err == nil && uid == myUid {
				return parts[5]
			}
		}
	}

	// Default to / if we can't get a better value
	return "/"
}

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ruby_snowflake_client-1.3.7 ext/vendor/github.com/godbus/dbus/homedir_static.go
ruby_snowflake_client-1.3.6 ext/vendor/github.com/godbus/dbus/homedir_static.go
ruby_snowflake_client-1.3.5 ext/vendor/github.com/godbus/dbus/homedir_static.go
ruby_snowflake_client-1.3.4 ext/vendor/github.com/godbus/dbus/homedir_static.go
ruby_snowflake_client-1.3.4.pre.debug ext/vendor/github.com/godbus/dbus/homedir_static.go
ruby_snowflake_client-1.3.3.pre.debug ext/vendor/github.com/godbus/dbus/homedir_static.go
ruby_snowflake_client-1.3.2 ext/vendor/github.com/godbus/dbus/homedir_static.go
ruby_snowflake_client-1.3.1 ext/vendor/github.com/godbus/dbus/homedir_static.go
ruby_snowflake_client-1.3.0 ext/vendor/github.com/godbus/dbus/homedir_static.go
ruby_snowflake_client-1.2.1 ext/vendor/github.com/godbus/dbus/homedir_static.go
ruby_snowflake_client-1.2.0 ext/vendor/github.com/godbus/dbus/homedir_static.go
ruby_snowflake_client-1.1.1 ext/vendor/github.com/godbus/dbus/homedir_static.go
ruby_snowflake_client-1.1.0 ext/vendor/github.com/godbus/dbus/homedir_static.go
ruby_snowflake_client-1.0.2 ext/vendor/github.com/godbus/dbus/homedir_static.go
ruby_snowflake_client-1.0.1 ext/vendor/github.com/godbus/dbus/homedir_static.go
ruby_snowflake_client-1.0.0 ext/vendor/github.com/godbus/dbus/homedir_static.go