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 #3 from STNS/fix-ubuntu-error
Browse files Browse the repository at this point in the history
Fix ubuntu error
  • Loading branch information
pyama86 committed Feb 14, 2016
2 parents 1f0c6de + f4c90c5 commit 791cf46
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package/RPM/SPECS/libnss_stns.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
6 changes: 6 additions & 0 deletions package/deb/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
libnss-stns (0.0.2) STABLE; urgency=low

* fix https://github.com/STNS/libnss_stns/pull/3

-- pyama86 <[email protected]> Sat, 09 Jan 2016 10:43:05 +0000

libnss-stns (0.0.1) UNSTABLE; urgency=low

* Initial release.
Expand Down
2 changes: 1 addition & 1 deletion package/deb/debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
26 changes: 16 additions & 10 deletions request/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ 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 {
for k, v := range resource {
list[k] = v
}
}
return
}

func resetList(list attribute.UserGroups, position *int) {
Expand Down

0 comments on commit 791cf46

Please sign in to comment.