Skip to content

Commit

Permalink
Use new name of the U2F marker file (now official)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximbaz committed May 15, 2018
1 parent 61ff29a commit ad6b08c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ _See also: [FAQ: How do I configure my YubiKey to require a physical touch?](#fa

In order to detect when `pam-u2f` requests a touch on YubiKey, make sure you use `pam-u2f` of at least `v1.0.7`.

With that in place, `pam-u2f` will open `/var/run/$UID/pam-u2f-touch` when it starts waiting for a user to touch the device, and close it when it stops waiting for a touch.
With that in place, `pam-u2f` will open `/var/run/$UID/pam-u2f-authpending` when it starts waiting for a user to touch the device, and close it when it stops waiting for a touch.

> If the path to your lock file differs, provide it via `--u2f-lock-path` CLI argument.
> If the path to your authpending file differs, provide it via `--u2f-auth-pending-path` CLI argument.
This app will thus watch for `OPEN` events on that file, and when event occurs will toggle the touch indicator.

Expand Down
8 changes: 4 additions & 4 deletions detector/u2f.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ import (
)

// WatchU2F watches when YubiKey is waiting for a touch on a U2F request
func WatchU2F(u2fLockPath string, notifiers map[string]chan notifier.Message) {
func WatchU2F(u2fAuthPendingPath string, notifiers map[string]chan notifier.Message) {
// It's important to not miss a single event, so have a small buffer
events := make(chan notify.EventInfo, 10)
openCounter := 0

initWatcher := func() {
// Ensure the file exists (pam-u2f doesn't create it beforehand)
os.Create(u2fLockPath)
os.Create(u2fAuthPendingPath)

// Setup the watcher
openCounter = 0
if err := notify.Watch(u2fLockPath, events, notify.InOpen, notify.InCloseWrite, notify.InCloseNowrite, notify.InDeleteSelf, notify.InMoveSelf); err != nil {
log.Errorf("Cannot establish a watch on u2f lock file '%v': %v", u2fLockPath, err)
if err := notify.Watch(u2fAuthPendingPath, events, notify.InOpen, notify.InCloseWrite, notify.InCloseNowrite, notify.InDeleteSelf, notify.InMoveSelf); err != nil {
log.Errorf("Cannot establish a watch on pam-u2f-authpending file '%v': %v", u2fAuthPendingPath, err)
return
}
log.Debug("U2F watcher is successfully established")
Expand Down
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ func main() {
defaultGpgPubringPath := "$GNUPGHOME/pubring.kbx or $HOME/.gnupg/pubring.kbx"

var verbose bool
var u2fLockPath string
var u2fAuthPendingPath string
var gpgPubringPath string
flag.BoolVar(&verbose, "v", false, "print verbose output")
flag.StringVar(&u2fLockPath, "u2f-lock-path", "/var/run/user/1000/pam-u2f-touch", "path to pam-u2f lock file")
flag.StringVar(&u2fAuthPendingPath, "u2f-authpending-path", "/var/run/user/1000/pam-u2f-authpending", "path to pam-u2f-authpending file")
flag.StringVar(&gpgPubringPath, "gpg-pubring-path", defaultGpgPubringPath, "path to gpg's pubring.kbx file")
flag.Parse()

Expand All @@ -36,7 +36,7 @@ func main() {
}
}

u2fLockPath = os.ExpandEnv(u2fLockPath)
u2fAuthPendingPath = os.ExpandEnv(u2fAuthPendingPath)
gpgPubringPath = os.ExpandEnv(gpgPubringPath)

log.SetFormatter(&log.TextFormatter{FullTimestamp: true})
Expand All @@ -52,7 +52,7 @@ func main() {
requestGPGCheck := make(chan bool)
go detector.CheckGPGOnRequest(requestGPGCheck, notifiers)

go detector.WatchU2F(u2fLockPath, notifiers)
go detector.WatchU2F(u2fAuthPendingPath, notifiers)
go detector.WatchGPG(gpgPubringPath, requestGPGCheck)
go detector.WatchSSH(requestGPGCheck, exits)

Expand Down

0 comments on commit ad6b08c

Please sign in to comment.