diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 33cb5ee..3a01db3 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -4,8 +4,8 @@ "Deps": [ { "ImportPath": "github.com/STNS/STNS/attribute", - "Comment": "v0.0.1-45-g8d23181", - "Rev": "8d23181a70ad508ab126192177f85ecb622a7173" + "Comment": "v0.0.1-56-gddf0757", + "Rev": "ddf07572ee059179511babea80c1c7598242694a" }, { "ImportPath": "github.com/pyama86/toml", diff --git a/package/RPM/SPECS/libnss_stns.spec b/package/RPM/SPECS/libnss_stns.spec index bd73750..db1e8d0 100644 --- a/package/RPM/SPECS/libnss_stns.spec +++ b/package/RPM/SPECS/libnss_stns.spec @@ -5,7 +5,7 @@ Name: libnss-stns Group: SipmleTomlNameService URL: https://github.com/pyama86/libnss_stns Version: 0.0 -Release: 1 +Release: 2 License: MIT Source0: libnss_stns.conf Packager: libnss-stns @@ -38,7 +38,7 @@ rm -rf %{buildroot} %config(noreplace) %{_sysconfdir}/stns/libnss_stns.conf %post -ln -s /usr/%{_lib}/libnss_stns.so /usr/%{_lib}/libnss_stns.so.2 +ln -fs /usr/%{_lib}/libnss_stns.so /usr/%{_lib}/libnss_stns.so.2 %postun rm -f /usr/%{_lib}/libnss_stns.so.2 diff --git a/package/deb/debian/changelog b/package/deb/debian/changelog index c1e1b6d..0e6f05a 100644 --- a/package/deb/debian/changelog +++ b/package/deb/debian/changelog @@ -1,3 +1,9 @@ +libnss-stns (0.0.2) STABLE; urgency=low + + * fix https://github.com/STNS/libnss_stns/pull/3 + + -- pyama86 Sat, 09 Jan 2016 10:43:05 +0000 + libnss-stns (0.0.1) UNSTABLE; urgency=low * Initial release. diff --git a/package/deb/debian/postinst b/package/deb/debian/postinst index 4e20fa8..4198d43 100644 --- a/package/deb/debian/postinst +++ b/package/deb/debian/postinst @@ -6,7 +6,7 @@ DEB_HOST_MULTIARCH=`dpkg-architecture -qDEB_HOST_MULTIARCH` case "$1" in configure) - ln -s /usr/lib/$DEB_HOST_MULTIARCH/libnss_stns.so /lib/$DEB_HOST_MULTIARCH/libnss_stns.so.2 + ln -sf /usr/lib/$DEB_HOST_MULTIARCH/libnss_stns.so /lib/$DEB_HOST_MULTIARCH/libnss_stns.so.2 ;; abort-upgrade|abort-remove|abort-deconfigure|failed-upgrade) diff --git a/request/request.go b/request/request.go index fc9ddd7..1fa7dfb 100644 --- a/request/request.go +++ b/request/request.go @@ -23,6 +23,8 @@ var ConfigFileName = "/etc/stns/libnss_stns.conf" var Loaded *config.Config var Cache map[string]*CacheObject +var Pid int + type CacheObject struct { userGroup *attribute.UserGroups err error @@ -45,6 +47,12 @@ func NewRequest(resource string, column string, value string) (*Request, error) } r.ApiPath = strings.Join(urls, "/") + + if Pid != 0 && Pid != os.Getpid() { + return nil, errors.New("unsupported fork process") + } + + Pid = os.Getpid() return &r, nil } @@ -67,25 +75,23 @@ func (r *Request) Get() (attribute.UserGroups, error) { // default negative cache Cache[r.ApiPath] = &CacheObject{nil, errors.New(r.ApiPath + " is not fond")} - client := &http.Client{} - - transport := &http.Transport{ - TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, - } - - if r.Config.SslVerify == false { - client.Transport = transport - } + http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: !r.Config.SslVerify} for _, v := range perm { endPoint := r.Config.ApiEndPoint[v] url := endPoint + "/" + r.ApiPath req, err := http.NewRequest("GET", url, nil) + + if err != nil { + lastError = err + continue + } + if r.Config.User != "" && r.Config.Password != "" { req.SetBasicAuth(r.Config.User, r.Config.Password) } - res, err := client.Do(req) + res, err := http.DefaultClient.Do(req) if err != nil { lastError = err diff --git a/resource.go b/resource.go index 99df67f..9cefb36 100644 --- a/resource.go +++ b/resource.go @@ -68,6 +68,7 @@ func setList(resource_type string, list attribute.UserGroups, position *int) { resource, err := get(resource_type, "list", "") if err != nil { *position = NSS_STATUS_TRYAGAIN + return } if len(resource) > 0 { @@ -75,7 +76,6 @@ func setList(resource_type string, list attribute.UserGroups, position *int) { list[k] = v } } - return } func resetList(list attribute.UserGroups, position *int) {