id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c28900
// display selected entry fmt.Fprintln(stdout, choices[sel]) return cb(WithClip(ctx, false), c, choices[sel], "", false) case "sync": // run sync and re-run show/find workflow if err := s.Sync(ctx, c); err != nil { return err } return cb(ctx, c, needle, "", true) case "edit": // edit selected entry ...
c28901
_, _ = buf.WriteString(white) } else { return "", errors.Errorf("Unexpected color at (%d,%d): %+v", x, y, col) } } _, _ = buf.WriteString("\n") } return buf.String(), nil }
c28902
store, name := r.getStore(ctx, name) sec, err := store.Get(ctx, name) return sec, ctx, err }
c28903
f.Root = true return f }
c28904
fmt.Errorf("use go get -u to update binary in GOPATH") } // check file fi, err := os.Stat(fn) if err != nil { return err } if !fi.Mode().IsRegular() { return fmt.Errorf("not a regular file") } if err := unix.Access(fn, unix.W_OK); err != nil { return err } // check dir fdir := filepath.Dir(fn) retu...
c28905
:= homedir.Dir() if err != nil { if debug { fmt.Printf("[DEBUG] Failed to get homedir: %s\n", err) } return "" } return hd }
c28906
filepath.Join(Homedir(), ".config", "gopass", "config.yml")) l = append(l, filepath.Join(Homedir(), ".gopass.yml")) return l }
c28907
== "" { binPath = gopassPath(global) } wrap, err := getWrapperContent(binPath) if err != nil { return nil, nil, err } return wrap, mf, nil }
c28908
name) return store.GitInit(ctx, userName, userEmail) }
c28909
name) return store.RCS().InitConfig(ctx, userName, userEmail) }
c28910
semver.Version { return r.store.RCS().Version(ctx) }
c28911
error { ctx, store, _ := r.getStore(ctx, name) return store.RCS().AddRemote(ctx, remote, url) }
c28912
error { ctx, store, _ := r.getStore(ctx, name) return store.RCS().RemoveRemote(ctx, remote) }
c28913
error { ctx, store, _ := r.getStore(ctx, name) return store.RCS().Pull(ctx, origin, remote) }
c28914
error { ctx, store, _ := r.getStore(ctx, name) return store.RCS().Push(ctx, origin, remote) }
c28915
error) { ctx, store, name := r.getStore(ctx, name) return store.ListRevisions(ctx, name) }
c28916
error) { ctx, store, name := r.getStore(ctx, name) return store.GetRevision(ctx, name, revision) }
c28917
(backend.RCS, error) { return Init(ctx, path) }
c28918
== "" { return ExitError(ctx, ExitNoName, nil, "Usage: %s insert name", s.Name) } return s.insert(ctx, c, name, key, echo, multiline, force, append, kvps) }
c28919
return cfg } cfg := New() cfg.Root.Path = backend.FromPath(PwStoreDir("")) _ = cfg.checkDefaults() if debug { fmt.Printf("[DEBUG] config.Load(): %+v\n", cfg) } return cfg }
c28920
buf, 0600); err != nil { return errors.Wrapf(err, "failed to write config file to '%s'", cfgLoc) } if debug { fmt.Printf("[DEBUG] Saved config to %s: %+v\n", cfgLoc, c) } return nil }
c28921
:= s.Store.Prune(ctx, name); err != nil { return ExitError(ctx, ExitUnknown, err, "failed to prune '%s': %s", name, err) } return nil } // deletes a single key from a YAML doc if key != "" { return s.deleteKeyFromYAML(ctx, name, key) } if err := s.Store.Delete(ctx, name); err != nil { return ExitErro...
c28922
err := sec.DeleteKey(key); err != nil { return ExitError(ctx, ExitIO, err, "Can not delete key '%s' from '%s': %s", key, name, err) } if err := s.Store.Set(sub.WithReason(ctx, "Updated Key in YAML"), name, sec); err != nil { return ExitError(ctx, ExitIO, err, "Can not delete key '%s' from '%s': %s", key, name, e...
c28923
return nil, err } return &Git{ path: path, repo: r, wt: w, }, nil }
c28924
URL: repo, Progress: Stdout, }) if err != nil { return nil, err } w, err := r.Worktree() if err != nil { return nil, err } return &Git{ path: path, repo: r, wt: w, }, nil }
c28925
} g.wt = wt } if !ctxutil.IsGitInit(ctx) { return g, nil } // add current content of the store if err := g.Add(ctx, g.path); err != nil { return g, errors.Wrapf(err, "failed to add '%s' to git", g.path) } // commit if there is something to commit if !g.HasStagedChanges(ctx) { out.Debug(ctx, "No stag...
c28926
git.PlainOpen(g.path) return err == nil }
c28927
_, err := g.wt.Add(file) if err != nil { return errors.Wrapf(err, "failed to add file '%s': %s", file, err) } } return nil }
c28928
"Error: Unable to get status: %s", err) return false } return !st.IsClean() }
c28929
g.wt.Commit(msg, &git.CommitOptions{ All: true, Author: &object.Signature{ Name: os.Getenv("GIT_AUTHOR_NAME"), Email: os.Getenv("GIT_AUTHOR_EMAIL"), When: time.Now(), }, }) return err }
c28930
out.Yellow(ctx, "Failed to pull before git push: %s", err) } if op == "pull" { return nil } return g.Push(ctx, remote, branch) }
c28931
if err != nil { return errors.Wrapf(err, "Failed to get git config: %s", err) } if _, found := cfg.Remotes[remote]; !found { return store.ErrGitNoRemote } return g.wt.PullContext(ctx, &git.PullOptions{ RemoteName: remote, ReferenceName: plumbing.ReferenceName(branch), Progress: Stdout, }) }
c28932
} if _, found := cfg.Remotes[remote]; !found { return store.ErrGitNoRemote } return g.repo.PushContext(ctx, &git.PushOptions{ RemoteName: remote, Progress: Stdout, }) }
c28933
return fmt.Errorf("not supported") }
c28934
not found for %s. Returning nil crypto backend", name) return nil } return sub.Crypto() }
c28935
err, "failed to find subtree: %s", err) } t = subtree } list := t.List(0) if len(list) < 1 { out.Yellow(ctx, "No secrets found") return nil } return audit.Batch(ctx, list, s.Store) }
c28936
args: append(defaultArgs, cfg.Args...), } cache, err := lru.New2Q(1024) if err != nil { return nil, err } g.listCache = cache bin, err := Binary(ctx, cfg.Binary) if err != nil { return nil, err } g.binary = bin return g, nil }
c28937
out.Debug(ctx, "gpg Output: %s", line) if !strings.HasPrefix(line, ":pubkey enc packet:") { continue } m := splitPacket(line) if keyid, found := m["keyid"]; found { kl, err := g.listKeys(ctx, "public", keyid) if err != nil || len(kl) < 1 { continue } recp = append(recp, kl[0].Fingerprint) ...
c28938
g.binary, args...) cmd.Stdin = bytes.NewReader(ciphertext) cmd.Stderr = os.Stderr out.Debug(ctx, "gpg.Decrypt: %s %+v", cmd.Path, cmd.Args) return cmd.Output() }
c28939
secKey, err := sec.Value("totp") if err != nil { secKey = sec.Password() } if strings.HasPrefix(secKey, "otpauth://") { return twofactor.FromURL(secKey) } otp, err := twofactor.NewGoogleTOTP(secKey) return otp, label, err }
c28940
return errors.Wrapf(err, "%s", err) } if err := ioutil.WriteFile(file, qr, 0600); err != nil { return errors.Wrapf(err, "failed to write QR code: %s", err) } return nil }
c28941
[]string { ctx, sub, _ := r.getStore(ctx, store) return sub.Recipients(ctx) }
c28942
string) error { ctx, sub, _ := r.getStore(ctx, store) return sub.RemoveRecipient(ctx, rec) }
c28943
if err := sub.ImportMissingPublicKeys(ctx); err != nil { out.Error(ctx, "[%s] Failed to import missing public keys: %s", alias, err) } } return r.store.ImportMissingPublicKeys(ctx) }
c28944
err != nil { return nil, errors.Errorf("failed to add mount: %s", err) } for _, recp := range substore.Recipients(ctx) { if err := r.addRecipient(ctx, alias+"/", root, recp, pretty); err != nil { out.Debug(ctx, "Failed to add recipient to tree %s: %s", recp, err) } } } return root, nil }
c28945
get homedir: %s", err) return "" } return filepath.Join(hd, ".gnupg") }
c28946
context.WithValue(ctx, ctxKeyFsckCheck, check) }
c28947
:= ctx.Value(ctxKeyFsckCheck).(bool) return ok }
c28948
:= ctx.Value(ctxKeyFsckCheck).(bool) if !ok { return false } return bv }
c28949
context.WithValue(ctx, ctxKeyFsckForce, force) }
c28950
:= ctx.Value(ctxKeyFsckForce).(bool) return ok }
c28951
:= ctx.Value(ctxKeyFsckForce).(bool) if !ok { return false } return bv }
c28952
context.WithValue(ctx, ctxKeyAutoSync, sync) }
c28953
:= ctx.Value(ctxKeyAutoSync).(bool) return ok }
c28954
:= ctx.Value(ctxKeyAutoSync).(bool) if !ok { return true } return bv }
c28955
:= ctx.Value(ctxKeyReason).(string) return ok }
c28956
if !ok { return "" } return sv }
c28957
context.WithValue(ctx, ctxKeyImportFunc, imf) }
c28958
:= ctx.Value(ctxKeyImportFunc).(store.ImportCallback) return ok && imf != nil }
c28959
context.WithValue(ctx, ctxKeyRecipientFunc, imf) }
c28960
:= ctx.Value(ctxKeyRecipientFunc).(store.RecipientCallback) return ok && imf != nil }
c28961
context.WithValue(ctx, ctxKeyFsckFunc, imf) }
c28962
:= ctx.Value(ctxKeyFsckFunc).(store.FsckCallback) return ok && imf != nil }
c28963
context.WithValue(ctx, ctxKeyCheckRecipients, cr) }
c28964
:= ctx.Value(ctxKeyCheckRecipients).(bool) return ok }
c28965
err := tf.mount(ctx); err != nil { _ = os.RemoveAll(tf.dir) return nil, err } fn := filepath.Join(tf.dir, "secret") fh, err := os.OpenFile(fn, os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0600) if err != nil { return nil, errors.Errorf("Failed to open file %s: %s", fn, err) } tf.fh = fh return tf, nil }
c28966
t.fh == nil { return "" } return t.fh.Name() }
c28967
== nil { return 0, errors.Errorf("not initialized") } return t.fh.Write(p) }
c28968
t.fh == nil { return nil } return t.fh.Close() }
c28969
%s: %s", t.dev, t.dir, err) } if t.dir == "" { return nil } return os.RemoveAll(t.dir) }
c28970
%s on %s is currently not supported", browser, runtime.GOOS) } return path, nil }
c28971
err) } sort.Strings(names) for _, name := range names { pcb() if strings.HasPrefix(name, s.alias+"/") { name = strings.TrimPrefix(name, s.alias+"/") } out.Debug(ctx, "sub.Fsck(%s) - Checking %s", path, name) if err := s.fsckCheckEntry(ctx, name); err != nil { return errors.Wrapf(err, "failed to chec...
c28972
{ ctx = ctxutil.WithNoConfirm(ctx, c.NoConfirm) } if !ctxutil.HasNoPager(ctx) { ctx = ctxutil.WithNoPager(ctx, c.NoPager) } if !ctxutil.HasShowSafeContent(ctx) { ctx = ctxutil.WithShowSafeContent(ctx, c.SafeContent) } if !ctxutil.HasUseSymbols(ctx) { ctx = ctxutil.WithUseSymbols(ctx, c.UseSymbols) } re...
c28973
manifestPath[runtime.GOOS][name] return found }
c28974
homedir.Expand(location) if err != nil { return "", err } return filepath.Join(expanded, Name+".json"), nil }
c28975
path, found := pm[browser] if !found { return "", fmt.Errorf("browser %s on %s is currently not supported", browser, runtime.GOOS) } return path, nil }
c28976
r.url == nil { return "" } return r.url.Path }
c28977
== nil { return "" } return r.url.String() }
c28978
if sub == nil || !sub.Valid() { return nil } return sub.Storage() }
c28979
Datacenter: datacenter, Token: token, }) if err != nil { return nil, err } return &Store{ api: client, prefix: prefix, }, nil }
c28980
p, _, err := s.api.KV().Get(name, nil) if err != nil { return nil, err } if p == nil || p.Value == nil { return nil, nil } return p.Value, nil }
c28981
Key: name, Value: value, } _, err := s.api.KV().Put(p, nil) return err }
c28982
if err == nil && v != nil { return true } return false }
c28983
res := make([]string, len(pairs)) for _, kvp := range pairs { res = append(res, strings.TrimPrefix(kvp.Key, s.prefix)) } return res, nil }
c28984
return false } for _, e := range ls { if strings.HasPrefix(e, name) { count++ } } return count > 1 }
c28985
out.Debug(ctx, "consul.Prune(%s)", prefix) return s.Delete(ctx, prefix) }
c28986
semver.Version { return semver.Version{Major: 1} }
c28987
entry) dirs[filepath.Dir(filename)] = struct{}{} if err := s.fsckCheckFile(ctx, filename); err != nil { return err } } for dir := range dirs { if err := s.fsckCheckDir(ctx, dir); err != nil { return err } } return nil }
c28988
NoPager: c.NoPager, Notifications: c.Notifications, Path: c.Path, RecipientHash: c.RecipientHash, SafeContent: c.SafeContent, UseSymbols: c.UseSymbols, } return sc }
c28989
password: password, body: body, } }
c28990
{ s.body = string(bytes.TrimSpace(lines[1])) } if err := s.decode(); err != nil { return s, err } return s, nil }
c28991
_ = buf.WriteString("\n") _, _ = buf.WriteString(s.body) } return buf.Bytes(), nil }
c28992
_, _ = buf.WriteString("\n") _, _ = buf.WriteString(s.body) } return buf.String() }
c28993
defer s.Unlock() return s.password }
c28994
s.Unlock() return s.body }
c28995
defer s.Unlock() return s.data }
c28996
s.data = nil err := s.decode() return err }
c28997
s.Unlock() if s.password != other.Password() { return false } if s.body != other.Body() { return false } return true }
c28998
return RandomLengthDelim(length, " ", lang) }
c28999
:= g.UseLangWordlist(lang); err != nil { return "", err } return string(g.GeneratePassword()), nil }