id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1
value |
|---|---|---|
c28700 | if err := x.secring.Set(k); err != nil {
return errors.Wrapf(err, "failed to set %v to secring: %s", k, err)
}
return x.secring.Save()
} | |
c28701 | context.WithValue(ctx, ctxKeyAlwaysTrust, at)
} | |
c28702 | PublicKeys: make([]*xcpb.PublicKey, 0, 10),
},
secring: sec,
}
} | |
c28703 | return nil, err
}
if err := proto.Unmarshal(buf, pr.data); err != nil {
return nil, err
}
return pr, nil
} | |
c28704 |
if p.secring == nil {
return false
}
return p.secring.Contains(fp)
} | |
c28705 | pk := range p.data.PublicKeys {
ids = append(ids, pk.Fingerprint)
}
if p.secring != nil {
ids = append(ids, p.secring.KeyIDs()...)
}
sort.Strings(ids)
return ids
} | |
c28706 | }
return nil, fmt.Errorf("key not found")
}
return proto.Marshal(xpk)
} | |
c28707 |
if err := proto.Unmarshal(buf, pk); err != nil {
return err
}
p.insert(pk)
return nil
} | |
c28708 |
p.Lock()
defer p.Unlock()
p.insert(pubKRToPB(pk))
return nil
} | |
c28709 |
match = i
break
}
}
if match < 0 || match > len(p.data.PublicKeys) {
return fmt.Errorf("not found")
}
p.data.PublicKeys = append(p.data.PublicKeys[:match], p.data.PublicKeys[match+1:]...)
return nil
} | |
c28710 | = fmt.Sprintf("%d", f.Int())
case reflect.Ptr:
switch bup := f.Interface().(type) {
case *backend.URL:
if bup == nil {
continue
}
strVal = bup.String()
}
default:
continue
}
m[jsonArg] = strVal
}
return m
} | |
c28711 | is not initialized", alias)
}
delete(r.mounts, alias)
delete(r.cfg.Mounts, alias)
return nil
} | |
c28712 | len(r.mounts))
for alias, sub := range r.mounts {
m[alias] = sub.Path()
}
return m
} | |
c28713 | for k := range r.mounts {
mps = append(mps, k)
}
sort.Sort(sort.Reverse(store.ByPathLen(mps)))
return mps
} | |
c28714 | if strings.HasPrefix(name+"/", mp+"/") {
return mp
}
}
return ""
} | |
c28715 | found {
return r.cfg.Mounts[mp].WithContext(ctx), sub, strings.TrimPrefix(name, sub.Alias())
}
return r.cfg.Root.WithContext(ctx), r.store, name
} | |
c28716 |
mp := r.MountPoint(name)
if _, found := r.mounts[mp]; found {
return r.cfg.Mounts[mp].WithContext(ctx)
}
return r.cfg.Root.WithContext(ctx)
} | |
c28717 |
}
if sub, found := r.mounts[name]; found {
return sub, nil
}
return nil, errors.Errorf("no such mount point '%s'", name)
} | |
c28718 | {
return errors.Errorf("Doubly mounted path at %s: %s", v.Path(), k)
}
paths[v.Path()] = k
}
return nil
} | |
c28719 | := versionInfo(ctx, s.Store.Crypto(ctx, mp))
rv := versionInfo(ctx, s.Store.RCS(ctx, mp))
sv := versionInfo(ctx, s.Store.Storage(ctx, mp))
if cv != cryptoVer || rv != rcsVer || sv != storageVer {
fmt.Fprintf(stdout, tpl, mp, cv, rv, sv)
}
}
fmt.Fprintf(stdout, "Available Crypto Backends: %s\n", strings.... | |
c28720 | nil {
return err
}
for _, proc := range procs {
walkFn(proc.Pid(), killProc)
}
return nil
} | |
c28721 | err != nil {
return []byte{}, err
}
buff := &bytes.Buffer{}
if err := tmpl.Execute(buff, pl); err != nil {
return []byte{}, err
}
return buff.Bytes(), nil
} | |
c28722 | return "", store.ErrYAMLNoMark
}
if err := s.decode(); err != nil {
return "", err
}
}
if v, found := s.data[key]; found {
return fmt.Sprintf("%v", v), nil
}
return "", store.ErrYAMLNoKey
} | |
c28723 | nil {
s.data = make(map[string]interface{}, 1)
}
if s.data == nil {
return store.ErrYAMLNoMark
}
s.data[key] = value
return s.encode()
} | |
c28724 | return store.ErrYAMLNoMark
}
delete(s.data, key)
return s.encode()
} | |
c28725 |
err := yaml.Unmarshal([]byte(s.body), &d)
if err != nil {
return true, err
}
s.data = d
return true, nil
} | |
c28726 |
if g.secring != nil {
ids = append(ids, listKeyIDs(g.secring)...)
}
return ids, nil
} | |
c28727 | requiredUsage), g.pubring.KeysByIdUsage(id, requiredUsage)...)
} | |
c28728 | subKey.Sig.FlagSign) {
keys = append(keys, openpgp.Key{
Entity: e,
PublicKey: subKey.PublicKey,
PrivateKey: subKey.PrivateKey,
SelfSignature: subKey.Sig,
})
}
}
}
return keys
} | |
c28729 | publicsuffix.PublicSuffix(host)
return host == suffix
} | |
c28730 | out.Error(ctx, "failed to read recipient list: %s", err)
}
return rs
} | |
c28731 | in store")
}
}
rs = append(rs, id)
if err := s.saveRecipients(ctx, rs, "Added Recipient "+id, true); err != nil {
return errors.Wrapf(err, "failed to save recipients")
}
out.Cyan(ctx, "Reencrypting existing secrets. This may take some time ...")
return s.reencrypt(WithReason(ctx, "Added Recipient "+id))
} | |
c28732 | return errors.Wrapf(err, "failed to get recipients")
}
return s.saveRecipients(ctx, rs, "Save Recipients", true)
} | |
c28733 | return s.saveRecipients(ctx, rs, "Set Recipients", true)
} | |
c28734 |
nk = append(nk, k)
}
if len(rs) == len(nk) {
return errors.Errorf("recipient not in store")
}
if err := s.saveRecipients(ctx, nk, "Removed Recipient "+id, true); err != nil {
return errors.Wrapf(err, "failed to save recipients")
}
return s.reencrypt(WithReason(ctx, "Removed Recipient "+id))
} | |
c28735 | s.rcs.Commit(ctx, fmt.Sprintf("Exported Public Keys %s", r)); err != nil && err != store.ErrGitNothingToCommit {
ok = false
out.Error(ctx, "Failed to git commit: %s", err)
continue
}
}
if !ok {
return exported, errors.New("some keys failed")
}
return exported, nil
} | |
c28736 | line := strings.TrimSpace(scanner.Text())
if line != "" {
// deduplicate
m[line] = struct{}{}
}
}
lst := make([]string, 0, len(m))
for k := range m {
lst = append(lst, k)
}
// sort
sort.Strings(lst)
return lst
} | |
c28737 | fmt.Fprintf(Stdout, Prefix(ctx)+format+newline(ctx), args...)
} | |
c28738 | fmt.Sprintf("%s:%d ", file, line)
}
fmt.Fprintf(Stdout, Prefix(ctx)+"[DEBUG] "+loc+format+newline(ctx), args...)
} | |
c28739 | fmt.Fprint(Stdout, color.BlackString(Prefix(ctx)+format+newline(ctx), args...))
} | |
c28740 | fmt.Fprint(Stdout, color.BlueString(Prefix(ctx)+format+newline(ctx), args...))
} | |
c28741 | fmt.Fprint(Stdout, color.CyanString(Prefix(ctx)+format+newline(ctx), args...))
} | |
c28742 | fmt.Fprint(Stdout, color.GreenString(Prefix(ctx)+format+newline(ctx), args...))
} | |
c28743 | fmt.Fprint(Stdout, color.MagentaString(Prefix(ctx)+format+newline(ctx), args...))
} | |
c28744 | fmt.Fprint(Stdout, color.RedString(Prefix(ctx)+format+newline(ctx), args...))
} | |
c28745 | fmt.Fprint(Stderr, color.RedString(Prefix(ctx)+format+newline(ctx), args...))
} | |
c28746 | fmt.Fprint(Stdout, color.WhiteString(Prefix(ctx)+format+newline(ctx), args...))
} | |
c28747 | fmt.Fprint(Stdout, color.YellowString(Prefix(ctx)+format+newline(ctx), args...))
} | |
c28748 | := range f.Folders {
l += f.Len()
}
return l
} | |
c28749 | f.format("", true, maxDepth, 0)
} | |
c28750 | return f.addFile(strings.Split(name, sep), contentType)
} | |
c28751 | f.addTemplate(strings.Split(name, sep))
} | |
c28752 | Folders: make(map[string]*Folder, 10),
Files: make(map[string]*File, 10),
}
} | |
c28753 | next := newFolder(name)
f.Folders[name] = next
return next
} | |
c28754 | return nil, errors.Errorf("Entry not found")
}
return sub, nil
} | |
c28755 | next, found := f.Folders[name]; found {
return next.findFolder(path[1:])
}
return nil
} | |
c28756 | = &File{
Name: name,
Metadata: map[string]string{
"Content-Type": contentType,
},
}
return nil
}
next := f.getFolder(name)
return next.addFile(path[1:], contentType)
} | |
c28757 | nil || err != nil {
return err
}
return api.respondMessage(silentCtx, message)
} | |
c28758 |
response.Error = err.Error()
return sendSerializedJSONMessage(response, api.Writer)
} | |
c28759 | return nil, err
}
if !bytes.HasPrefix(banner, []byte("OK")) {
return nil, fmt.Errorf("wrong banner: %s", banner)
}
cl := &Client{
cmd: cmd,
in: stdin,
out: br,
}
return cl, nil
} | |
c28760 | nil {
return true
}
return false
} | |
c28761 |
}
line, _, _ := c.out.ReadLine()
if string(line) != "OK" {
return errors.Errorf("error: %s", line)
}
return nil
} | |
c28762 | fmt.Errorf("unexpected response: %s", pin)
}
ok, _, err := c.out.ReadLine()
if err != nil {
return nil, err
}
if !bytes.HasPrefix(ok, []byte("OK")) {
return nil, fmt.Errorf("unexpected response: %s", ok)
}
return pin[2:], nil
} | |
c28763 | return nil
}
if len(c.Args()) > 2 {
return ExitError(ctx, ExitUsage, nil, "Usage: %s config key value", s.Name)
}
if err := s.setConfigValue(ctx, c.String("store"), c.Args()[0], c.Args()[1]); err != nil {
return ExitError(ctx, ExitUnknown, err, "Error setting config value")
}
return nil
} | |
c28764 | sort.Strings(keys)
for _, k := range keys {
fmt.Fprintln(stdout, k)
}
} | |
c28765 | != "" {
if iv, err := strconv.ParseInt(um, 8, 32); err == nil && iv >= 0 && iv <= 0777 {
return int(iv)
}
}
}
return 077
} | |
c28766 | sub-stores")
if err := r.initialize(ctx); err != nil {
return false, errors.Wrapf(err, "failed to initialized stores: %s", err)
}
}
return r.store.Initialized(ctx), nil
} | |
c28767 | {
line = strings.TrimSpace(line)
if len(line) < 37 {
continue
}
if line[:35] != suffix {
continue
}
if iv, err := strconv.ParseUint(line[36:], 10, 64); err == nil {
count = iv
return nil
}
}
return nil
}
bo := backoff.NewExponentialBackOff()
bo.MaxElapsedTime = 10 * time.Se... | |
c28768 | }
if err := s.rcsInit(ctx, store, un, ue); err != nil {
return ExitError(ctx, ExitGit, err, "failed to initialize git: %s", err)
}
return nil
} | |
c28769 | nil, "Usage: %s git remote add <REMOTE> <URL>", s.Name)
}
return s.Store.GitAddRemote(ctx, store, remote, url)
} | |
c28770 |
if branch == "" {
branch = "master"
}
return s.Store.GitPull(ctx, store, origin, branch)
} | |
c28771 | nil, "Usage: %s git push <ORIGIN> <BRANCH>", s.Name)
}
return s.Store.GitPush(ctx, store, origin, branch)
} | |
c28772 | s.url.Crypto = backend.GetCryptoBackend(ctx)
out.Debug(ctx, "sub.New - Using Crypto backend from ctx: %s", backend.CryptoBackendName(s.url.Crypto))
}
if err := s.initCryptoBackend(ctx); err != nil {
return nil, errors.Wrapf(err, "failed to init crypto backend: %s", err)
}
out.Debug(ctx, "sub.New - initialized... | |
c28773 |
}
gfn := filepath.Join(fn, s.crypto.IDFile())
if s.storage.Exists(ctx, gfn) {
return gfn
}
fn = filepath.Dir(fn)
}
return s.crypto.IDFile()
} | |
c28774 | false
}
return s.URL() == other.URL()
} | |
c28775 |
return s.storage.IsDir(ctx, name)
} | |
c28776 | s.url == nil {
return ""
}
return s.url.Path
} | |
c28777 | keys")
}
out.Print(ctx, "XC Private Keys:")
for _, key := range kl {
out.Print(ctx, "%s - %s", key, crypto.FormatKey(ctx, key))
}
return nil
} | |
c28778 | err = termio.AskForPassword(ctx, "")
if err != nil || pw == "" {
return action.ExitError(ctx, action.ExitIO, err, "failed to ask for password: %s", err)
}
}
if err := crypto.CreatePrivateKeyBatch(ctx, name, email, pw); err != nil {
return action.ExitError(ctx, action.ExitUnknown, err, "failed to create pri... | |
c28779 | if err != nil {
return action.ExitError(ctx, action.ExitUnknown, err, "failed to export key: %s", err)
}
if err := ioutil.WriteFile(file, pk, 0600); err != nil {
return action.ExitError(ctx, action.ExitIO, err, "failed to write file")
}
return nil
} | |
c28780 | "input file not found")
}
buf, err := ioutil.ReadFile(file)
if err != nil {
return action.ExitError(ctx, action.ExitIO, err, "failed to read file")
}
return crypto.ImportPrivateKey(ctx, buf)
} | |
c28781 | if err != nil {
return action.ExitError(ctx, action.ExitIO, err, "failed to read file")
}
ciphertext, err := crypto.Encrypt(ctx, plaintext, recipients)
if err != nil {
return action.ExitError(ctx, action.ExitUnknown, err, "failed to encrypt file: %s", err)
}
if err := ioutil.WriteFile(outFile, ciphertext, 060... | |
c28782 |
ciphertext, err := ioutil.ReadFile(inFile)
if err != nil {
return action.ExitError(ctx, action.ExitIO, err, "failed to read file")
}
plaintext, err := crypto.Decrypt(ctx, ciphertext)
if err != nil {
return action.ExitError(ctx, action.ExitUnknown, err, "failed to decrypt file: %s", err)
}
if err := iouti... | |
c28783 | "failed to open file")
}
defer func() { _ = plaintext.Close() }()
ciphertext, err := os.OpenFile(outFile, os.O_CREATE|os.O_WRONLY, 0600)
if err != nil {
return action.ExitError(ctx, action.ExitIO, err, "failed to open file")
}
defer func() { _ = ciphertext.Close() }()
if err := crypto.EncryptStream(ctx, pla... | |
c28784 | {
return action.ExitError(ctx, action.ExitIO, err, "failed to read file")
}
defer func() { _ = ciphertext.Close() }()
plaintext, err := os.OpenFile(outFile, os.O_CREATE|os.O_WRONLY, 0600)
if err != nil {
return action.ExitError(ctx, action.ExitIO, err, "failed to read file")
}
defer func() { _ = plaintext.C... | |
c28785 | != nil {
return n, err
}
}
if c.Username != "" {
i, err := io.WriteString(w, "username="+c.Username+"\n")
n += int64(i)
if err != nil {
return n, err
}
}
if c.Password != "" {
i, err := io.WriteString(w, "password="+c.Password+"\n")
n += int64(i)
if err != nil {
return n, err
}
}
retur... | |
c28786 | return ExitError(ctx, ExitUsage, nil, "missing stdin from git")
}
return nil
} | |
c28787 | nil
}
entries := sub.List(0)
if len(entries) != 1 {
fmt.Fprintln(os.Stderr, "gopass error: too many entries")
return nil
}
path = "git/" + entries[0]
}
secret, err := s.Store.Get(ctx, path)
if err != nil {
return ExitError(ctx, ExitDecrypt, err, "")
}
cred.Password = secret.Password()
username,... | |
c28788 | it, delete it first by doing: "+
"\"gopass rm %s\"\n",
path, path,
)
return nil
}
secret := secret.New(cred.Password, "")
if cred.Username != "" {
_ = secret.SetValue("login", cred.Username)
}
err = s.Store.Set(ctx, path, secret)
if err != nil {
fmt.Fprintf(os.Stderr, "gopass error: error while wri... | |
c28789 | %v while parsing git-credential", err)
}
path := "git/" + fsutil.CleanFilename(cred.Host) + "/" + fsutil.CleanFilename(cred.Username)
err = s.Store.Delete(ctx, path)
if err != nil {
fmt.Fprintln(os.Stderr, "gopass error: error while writing to store")
}
return nil
} | |
c28790 | log.Println("No target given, assuming --global.")
}
cmd := exec.Command("git", "config", flag, "credential.helper", `"!gopass git-credential $@"`)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd.Run()
} | |
c28791 | colBin("(binary)")
case "text/yaml":
ft = " " + colYaml("(yaml)")
}
}
return prefix + sym + f.Name + ft + "\n"
} | |
c28792 | {
keys = append(keys, a.Name)
}
return keys
} | |
c28793 | }
if ca[i].Fn == nil {
return errors.New("action invalid")
}
return ca[i].Fn(ctx, c)
} | |
c28794 | if len(ok) < 1 {
return nil, fmt.Errorf("no valid dumps given")
}
return &Scanner{
dumps: ok,
}, nil
} | |
c28795 | := make(chan string, len(in))
done := make(chan struct{}, len(s.dumps))
for _, fn := range s.dumps {
go s.scanFile(ctx, fn, in, results, done)
}
go func() {
for result := range results {
out = append(out, result)
}
done <- struct{}{}
}()
for range s.dumps {
<-done
}
close(results)
<-done
retur... | |
c28796 | args ...string) error {
return nil
} | |
c28797 | msg string) error {
return nil
} | |
c28798 | string) error {
return nil
} | |
c28799 | name string, args ...string) error {
return nil
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.