Skip to content
This repository has been archived by the owner on Sep 3, 2018. It is now read-only.

Commit

Permalink
Merge pull request #58 from STNS/fix-18-futatabi
Browse files Browse the repository at this point in the history
systemdからの問い合わせも無視する
  • Loading branch information
pyama86 authored Jun 13, 2018
2 parents bb54d09 + 6e1e287 commit 87c870d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
_gocache "github.com/pyama86/go-cache"
)

var attrStore = _gocache.New(time.Second*settings.CACHE_TIME, 60*time.Second)
var lockStore = _gocache.New(time.Second*settings.LOCK_TIME, 60*time.Second)
var attrStore = _gocache.New(time.Second*settings.CACHE_TIME, 0*time.Second)
var lockStore = _gocache.New(time.Second*settings.LOCK_TIME, 0*time.Second)

var workDir = settings.WORK_DIR

Expand Down
19 changes: 17 additions & 2 deletions nss/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@ func init() {
orgInit()
}

func ignoreProcess(process string) bool {
ignore := []string{
"/sbin/init",
"dbus-daemon",
"(resolved)",
"(systemd)",
}

for _, i := range ignore {
if strings.HasSuffix(process, i) {
return true
}
}
return false
}

func orgInit() int {
if pwdNss == nil || grpNss == nil || spwdNss == nil {
if _, err := os.FindProcess(1); err != nil {
Expand All @@ -40,10 +56,9 @@ func orgInit() int {
return libstns.NSS_STATUS_UNAVAIL
}

if host.PlatformFamily == "debian" && (strings.HasSuffix(os.Args[0], "/sbin/init") || strings.HasSuffix(os.Args[0], "dbus-daemon") || strings.HasSuffix(os.Args[0], "systemd-resolved")) {
if host.PlatformFamily == "debian" && ignoreProcess(os.Args[0]) {
return libstns.NSS_STATUS_NOTFOUND
}

libstns.Setlog()

config, err := libstns.LoadConfig("/etc/stns/libnss_stns.conf")
Expand Down

0 comments on commit 87c870d

Please sign in to comment.