-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from SimonRichardson/acquire-root
#6 The following commit attempts to detect if you're executing with sudo and to assign the lock file with the correct permissions, to prevent cryptic error messages. The code detects sudo using environment variables and correctly parses the UID and GID from those values, before chown'ing the file. If at any point there is an error whilst changing the owner, it will continue as root and on the next run, it will give information about the file in question. This should then aid diagnosing the problem without changing the underlying existing flow. CC: @howbazaar Background information: https://bugs.launchpad.net/juju/+bug/1758369
- Loading branch information
Showing
6 changed files
with
221 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,20 @@ | ||
default: check | ||
PROJECT := github.com/juju/mutex | ||
|
||
check: | ||
go test | ||
.PHONY: check-licence check-go check | ||
|
||
docs: | ||
godoc2md github.com/juju/mutex > README.md | ||
sed -i 's|\[godoc-link-here\]|[![GoDoc](https://godoc.org/github.com/juju/mutex?status.svg)](https://godoc.org/github.com/juju/mutex)|' README.md | ||
check: check-licence check-go | ||
go test $(PROJECT)/... | ||
|
||
check-licence: | ||
@(fgrep -rl "Licensed under the LGPLv3" .;\ | ||
fgrep -rl "MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT" .;\ | ||
find . -name "*.go") | sed -e 's,\./,,' | sort | uniq -u | \ | ||
xargs -I {} echo FAIL: licence missed: {} | ||
|
||
.PHONY: default check docs | ||
check-go: | ||
$(eval GOFMT := $(strip $(shell gofmt -l .| sed -e "s/^/ /g"))) | ||
@(if [ x$(GOFMT) != x"" ]; then \ | ||
echo go fmt is sad: $(GOFMT); \ | ||
exit 1; \ | ||
fi ) | ||
@(go tool vet -all -composites=false -copylocks=false .) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
github.com/golang/mock git 69521b3833175dfcfb1cc1fdb0c9be92e66faa81 2018-04-03T23:54:22Z | ||
github.com/juju/errors git 1b5e39b83d1835fa480e0c2ddefb040ee82d58b3 2015-09-16T12:56:42Z | ||
github.com/juju/loggo git 8232ab8918d91c72af1a9fb94d3edbe31d88b790 2017-06-05T01:46:07Z | ||
github.com/juju/retry git 62c62032529169c7ec02fa48f93349604c345e1f 2015-10-29T02:48:21Z | ||
github.com/juju/testing git 72703b1e95eb8ce4737fd8a3d8496c6b0be280a6 2018-05-17T13:41:05Z | ||
github.com/juju/utils git 2000ea4ff0431598aec2b7e1d11d5d49b5384d63 2018-04-24T09:41:59Z | ||
github.com/juju/version git 1f41e27e54f21acccf9b2dddae063a782a8a7ceb 2016-10-31T05:19:06Z | ||
golang.org/x/crypto git 650f4a345ab4e5b245a3034b110ebc7299e68186 2018-02-14T00:00:28Z | ||
golang.org/x/net git 61147c48b25b599e5b561d2e9c4f3e1ef489ca41 2018-04-06T21:48:16Z | ||
gopkg.in/check.v1 git 4f90aeace3a26ad7021961c297b22c42160c7b25 2016-01-05T16:49:36Z | ||
gopkg.in/mgo.v2 git f2b6f6c918c452ad107eec89615f074e3bd80e33 2016-08-18T01:52:18Z | ||
gopkg.in/yaml.v2 git 1be3d31502d6eabc0dd7ce5b0daab022e14a5538 2017-07-12T05:45:46Z |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright 2016-2017 Canonical Ltd. | ||
// Licensed under the LGPLv3, see LICENCE file for details. | ||
|
||
package mutex | ||
|
||
var ( | ||
// Export the Envars so we can test it via mocks | ||
Envars = &envars | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters