id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c171500
err != nil { return err } return token.Claims(key, values...) }
c171501
NewJWKClientWithCache(options, extractor, nil) }
c171502
== nil { options.Client = http.DefaultClient } return &JWKClient{ keyCacher: keyCacher, options: options, extractor: extractor, } }
c171503
} addedKey, err := j.keyCacher.Add(ID, keys) if err != nil { return jose.JSONWebKey{}, err } return *addedKey, nil } return *searchedKey, nil }
c171504
{ return nil, ErrNoJWTHeaders } header := token.Headers[0] return j.GetKey(header.KeyID) }
c171505
if err == ErrTokenNotFound { continue } else if err != nil { return nil, err } return token, nil } return nil, ErrTokenNotFound }) }
c171506
raw == "" { return nil, ErrTokenNotFound } return jwt.ParseSigned(raw) }
c171507
map[string]keyCacherEntry{}, maxKeyAge: maxKeyAge, maxCacheSize: maxCacheSize, } }
c171508
{ return &searchKey.JSONWebKey, nil } return nil, ErrKeyExpired } return nil, ErrNoKeyFound }
c171509
!= nil { if mkc.maxCacheSize != -1 { mkc.entries[addingKey.KeyID] = keyCacherEntry{ addedAt: time.Now(), JSONWebKey: addingKey, } mkc.handleOverflow() } return &addingKey, nil } return nil, ErrNoKeyFound }
c171510
{ delete(mkc.entries, keyID) return true } return false }
c171511
latestAddedTime = entry.addedAt oldestEntryKeyID = entryKeyID } } delete(mkc.entries, oldestEntryKeyID) } }
c171512
} nbuf := make([]byte, hdr.NewSize) var oldpos, newpos int64 for newpos < hdr.NewSize { var ctrl struct{ Add, Copy, Seek int64 } err = binary.Read(cpfbz2, signMagLittleEndian{}, &ctrl) if err != nil { return err } // Sanity-check if newpos+ctrl.Add > hdr.NewSize { return ErrCorrupt } // Read diff string _, err = io.ReadFull(dpfbz2, nbuf[newpos:newpos+ctrl.Add]) if err != nil { return ErrCorrupt } // Add old data to diff string for i := int64(0); i < ctrl.Add; i++ { if oldpos+i >= 0 && oldpos+i < int64(len(obuf)) { nbuf[newpos+i] += obuf[oldpos+i] } } // Adjust pointers newpos += ctrl.Add oldpos += ctrl.Add // Sanity-check if newpos+ctrl.Copy > hdr.NewSize { return ErrCorrupt } // Read extra string _, err = io.ReadFull(epfbz2, nbuf[newpos:newpos+ctrl.Copy]) if err != nil { return ErrCorrupt } // Adjust pointers newpos += ctrl.Copy oldpos += ctrl.Seek } // Write the new file for len(nbuf) > 0 { n, err := new.Write(nbuf) if err != nil { return err } nbuf = nbuf[n:] } return nil }
c171513
pbuf, err := diffBytes(obuf, nbuf) if err != nil { return err } _, err = patch.Write(pbuf) return err }
c171514
false if validColors[c] { valid = true } return valid }
c171515
false, stopChan: make(chan struct{}, 1), } for _, option := range options { option(s) } return s }
c171516
{ outColor = fmt.Sprintf("%s%s%s ", s.Prefix, s.color(s.chars[i]), s.Suffix) } outPlain := fmt.Sprintf("%s%s%s ", s.Prefix, s.chars[i], s.Suffix) fmt.Fprint(s.Writer, outColor) s.lastOutput = outPlain delay := s.Delay s.lock.Unlock() time.Sleep(delay) } } } }() }
c171517
s.erase() if s.FinalMSG != "" { fmt.Fprintf(s.Writer, s.FinalMSG) } s.stopChan <- struct{}{} } }
c171518
j := 0, len(s.chars)-1; i < j; i, j = i+1, j-1 { s.chars[i], s.chars[j] = s.chars[j], s.chars[i] } }
c171519
return errInvalidColor } colorAttributes[index] = colorAttributeMap[c] } s.lock.Lock() s.color = color.New(colorAttributes...).SprintFunc() s.lock.Unlock() s.Restart() return nil }
c171520
defer s.lock.Unlock() s.Delay = d }
c171521
defer s.lock.Unlock() s.chars = cs }
c171522
:= range []string{ "\b", string(del), "\b", "\033[K", // for macOS Terminal } { for i := 0; i < n; i++ { fmt.Fprintf(s.Writer, c) } } s.lastOutput = "" }
c171523
i++ { numSeq[i] = strconv.Itoa(i) } return numSeq }
c171524
if !id.initiator { header-- } return header }
c171525
wrTkn: make(chan struct{}, 1), nstreams: make(chan *Stream, 16), } go mp.handleIncoming() mp.wrTkn <- struct{}{} return mp }
c171526
if !ok { return nil, errors.New("multiplex closed") } return s, nil case <-m.closed: return nil, m.shutdownErr } }
c171527
sid, initiator: true, }, name) mp.channels[s.id] = s mp.chLock.Unlock() err := mp.sendMsg(context.Background(), header, []byte(name)) if err != nil { return nil, err } return s, nil }
c171528
encodeRange(lng, 180) return interleave(latInt, lngInt) }
c171529
(b.MinLat + b.MaxLat) / 2.0 lng = (b.MinLng + b.MaxLng) / 2.0 return }
c171530
maxDecimalPower(b.MaxLng - b.MinLng) lng = math.Ceil(b.MinLng/x) * x return }
c171531
return BoundingBoxIntWithPrecision(inthash, bits) }
c171532
180) latErr, lngErr := errorWithPrecision(bits) return Box{ MinLat: lat, MaxLat: lat + latErr, MinLng: lng, MaxLng: lng + lngErr, } }
c171533
:= BoundingBox(hash) return box.Center() }
c171534
lng+lngDelta, precision), // S, EncodeWithPrecision(lat-latDelta, lng, precision), // SW, EncodeWithPrecision(lat-latDelta, lng-lngDelta, precision), // W, EncodeWithPrecision(lat, lng-lngDelta, precision), // NW EncodeWithPrecision(lat+latDelta, lng-lngDelta, precision), } }
c171535
EncodeIntWithPrecision(lat-latDelta, lng+lngDelta, bits), // S, EncodeIntWithPrecision(lat-latDelta, lng, bits), // SW, EncodeIntWithPrecision(lat-latDelta, lng-lngDelta, bits), // W, EncodeIntWithPrecision(lat, lng-lngDelta, bits), // NW EncodeIntWithPrecision(lat+latDelta, lng-lngDelta, bits), } }
c171536
return NeighborsIntWithPrecision(hash, bits)[direction] }
c171537
<< 2)) & 0x3333333333333333 X = (X | (X << 1)) & 0x5555555555555555 return X }
c171538
i < len(encoder); i++ { e.decode[encoder[i]] = byte(i) } return e }
c171539
{ b[11-i] = e.encode[x&0x1f] x >>= 5 } return string(b[:]) }
c171540
name = lp } } l.InitPath = name l.InitArgs = append([]string{name}, args[1:]...) return nil } }
c171541
l.InitPath = path l.InitArgs = args return nil } }
c171542
if we have an error during the initialization of the container's init then send it back to the // parent process in the form of an initError. if err != nil { // ensure that any data sent from the parent is consumed so it doesn't // receive ECONNRESET when the child writes to the pipe. ioutil.ReadAll(pipe) if err := json.NewEncoder(pipe).Encode(newSystemError(err)); err != nil { panic(err) } } // ensure that this pipe is always closed pipe.Close() }() i, err := newContainerInit(it, pipe) if err != nil { return err } return i.Init() }
c171543
!= nil { return nil, err } if err := os.Chown(console, uid, gid); err != nil { return nil, err } return &linuxConsole{ slavePath: console, master: master, }, nil }
c171544
err := os.Create(dest) if err != nil && !os.IsExist(err) { return err } if f != nil { f.Close() } return syscall.Mount(c.slavePath, dest, "bind", syscall.MS_BIND, "") }
c171545
if err := syscall.Dup3(fd, i, 0); err != nil { return err } } return nil }
c171546
Path: c.slavePath, Err: e, } } return os.NewFile(uintptr(r), c.slavePath), nil }
c171547
uintptr(unsafe.Pointer(&n))); err != nil { return "", err } return fmt.Sprintf("/dev/pts/%d", n), nil }
c171548
nil { return err } // drop capabilities in bounding set before changing user if err := w.dropBoundingSet(); err != nil { return err } // preserve existing capabilities while we change users if err := system.SetKeepCaps(); err != nil { return err } if err := setupUser(config); err != nil { return err } if err := system.ClearKeepCaps(); err != nil { return err } // drop all other capabilities if err := w.drop(); err != nil { return err } if config.Cwd != "" { if err := syscall.Chdir(config.Cwd); err != nil { return err } } return nil }
c171549
} err = system.Setns(f.Fd(), uintptr(ns.Syscall())) f.Close() if err != nil { return err } } } return nil }
c171550
append(execUser.Sgids, addGroups...) if err := syscall.Setgroups(suppGroups); err != nil { return err } if err := system.Setgid(execUser.Gid); err != nil { return err } if err := system.Setuid(execUser.Uid); err != nil { return err } // if we didn't get HOME already, set it based on the user's HOME if envHome := os.Getenv("HOME"); envHome == "" { if err := os.Setenv("HOME", execUser.Home); err != nil { return err } } return nil }
c171551
{ logrus.Warn(err) } } } if err := m.Freeze(configs.Thawed); err != nil { logrus.Warn(err) } for _, p := range procs { if _, err := p.Wait(); err != nil { logrus.Warn(err) } } return nil }
c171552
if c.config.GidMappings != nil { sys.GidMappings = make([]syscall.SysProcIDMap, len(c.config.GidMappings)) for i, gm := range c.config.GidMappings { sys.GidMappings[i].ContainerID = gm.ContainerID sys.GidMappings[i].HostID = gm.HostID sys.GidMappings[i].Size = gm.Size } } return nil }
c171553
w.keep...) return w.pid.Apply(capability.BOUNDS) }
c171554
w.keep...) return w.pid.Apply(allCapabilityTypes) }
c171555
} if err := os.MkdirAll(current, 0755); err != nil && !os.IsExist(err) { return err } return s.copyIfNeeded(current, parent) }
c171556
{ return math.MinInt32, newGenericError(fmt.Errorf("invalid process"), ProcessNotExecuted) } return p.ops.pid(), nil }
c171557
newGenericError(fmt.Errorf("invalid process"), ProcessNotExecuted) } return p.ops.signal(sig) }
c171558
return nil, err } p.consolePath = console.Path() return console, nil }
c171559
newSystemError(err) } if config.NoPivotRoot { err = msMoveRoot(config.Rootfs) } else { err = pivotRoot(config.Rootfs, config.PivotDir) } if err != nil { return newSystemError(err) } if err := reOpenDevNull(config.Rootfs); err != nil { return newSystemError(err) } if config.Readonlyfs { if err := setReadonly(); err != nil { return newSystemError(err) } } syscall.Umask(0022) return nil }
c171560
if err := createDeviceNode(config.Rootfs, node, config.Namespaces.Contains(configs.NEWUSER)); err != nil { syscall.Umask(oldMask) return err } } syscall.Umask(oldMask) return nil }
c171561
} return syscall.Mount(node.Path, dest, "bind", syscall.MS_BIND, "") } if err := mknodDevice(dest, node); err != nil { if os.IsExist(err) { return nil } return err } return nil }
c171562
} return syscall.Mount(path, path, "", syscall.MS_BIND|syscall.MS_REMOUNT|syscall.MS_RDONLY|syscall.MS_REC|defaultMountFlags, "") case syscall.EBUSY: time.Sleep(100 * time.Millisecond) continue default: return err } } return nil } return fmt.Errorf("unable to mount %s as readonly max retries reached", path) }
c171563
return err } s := &fs.CpusetGroup{} return s.ApplyDir(path, c, pid) }
c171564
err } } if c.BlkioThrottleReadIOpsDevice != "" { if err := writeFile(path, "blkio.throttle.read_iops_device", c.BlkioThrottleReadIOpsDevice); err != nil { return err } } if c.BlkioThrottleWriteIOpsDevice != "" { if err := writeFile(path, "blkio.throttle.write_iops_device", c.BlkioThrottleWriteIOpsDevice); err != nil { return err } } return nil }
c171565
*pid if err := json.NewDecoder(p.parentPipe).Decode(&pid); err != nil { p.cmd.Wait() return newSystemError(err) } process, err := os.FindProcess(pid.Pid) if err != nil { return err } p.cmd.Process = process return nil }
c171566
parts := strings.Fields(text) if len(parts) >= 4 && parts[3] != "0" { subsystems = append(subsystems, parts[0]) } } } return subsystems, nil }
c171567
"", err } defer f.Close() return ParseCgroupFile(subsystem, f) }
c171568
{ break } frames = append(frames, NewFrame(pc, file, line)) } return Stacktrace{ Frames: frames, } }
c171569
return 0, err } return parseUint(strings.TrimSpace(string(contents)), 10, 64) }
c171570
gidMap[g.Gid] = struct{}{} found = true break } } } // we asked for a group but didn't find it. let's check to see // if we wanted a numeric group if !found { gid, err := strconv.Atoi(ag) if err != nil { return nil, fmt.Errorf("Unable to find group %s", ag) } // Ensure gid is inside gid range. if gid < minId || gid > maxId { return nil, ErrRange } gidMap[gid] = struct{}{} } } gids := []int{} for gid := range gidMap { gids = append(gids, gid) } return gids, nil }
c171571
{ for _, f := range strings.Fields(e) { *args = append(*args, f) } } fmt.Printf(">>> criu %v\n", *args) }
c171572
-1 { return "", "", fmt.Errorf("Bad SELinux Option") } con := strings.SplitN(opt, ":", 2) pcon[con[0]] = con[1] if con[0] == "level" || con[0] == "user" { mcon[con[0]] = con[1] } } processLabel = pcon.Get() mountLabel = mcon.Get() } return processLabel, mountLabel, nil }
c171573
&& fileLabel != "" { return selinux.Setfilecon(path, fileLabel) } return nil }
c171574
selinux.Setfscreatecon(fileLabel) } return nil }
c171575
return fmt.Errorf("Relabeling of %s is not allowed", path) } } if strings.Contains(relabel, "z") && strings.Contains(relabel, "Z") { return fmt.Errorf("Bad SELinux option z and Z can not be used together") } if strings.Contains(relabel, "z") { c := selinux.NewContext(fileLabel) c["level"] = "s0" fileLabel = c.Get() } return selinux.Chcon(path, fileLabel, true) }
c171576
} var r Route msg := (*RtMsg)(unsafe.Pointer(&m.Data[0:syscall.SizeofRtMsg][0])) if msg.Flags&syscall.RTM_F_CLONED != 0 { // Ignore cloned routes continue } if msg.Table != syscall.RT_TABLE_MAIN { // Ignore non-main tables continue } if msg.Family != syscall.AF_INET { // Ignore non-ipv4 routes continue } if msg.Dst_len == 0 { // Default routes r.Default = true } attrs, err := syscall.ParseNetlinkRouteAttr(&m) if err != nil { return nil, err } for _, attr := range attrs { switch attr.Attr.Type { case syscall.RTA_DST: ip := attr.Value r.IPNet = &net.IPNet{ IP: ip, Mask: net.CIDRMask(int(msg.Dst_len), 8*len(ip)), } case syscall.RTA_OIF: index := int(native.Uint32(attr.Value[0:4])) r.Iface, _ = net.InterfaceByIndex(index) } } if r.Default || r.IPNet != nil { res = append(res, r) } } } return res, nil }
c171577
if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(s), SIOC_BRADDBR, uintptr(unsafe.Pointer(nameBytePtr))); err != 0 { return err } if setMacAddr { return SetMacAddress(name, randMacAddr()) } return nil }
c171578
if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(s), syscall.SIOCSIFFLAGS, uintptr(unsafe.Pointer(&ifr))); err != 0 { return err } if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(s), SIOC_BRDELBR, uintptr(unsafe.Pointer(nameBytePtr))); err != 0 { return err } return nil }
c171579
ifIoctBridge(iface, master, SIOC_BRADDIF) }
c171580
ifIoctBridge(iface, master, SIOC_BRDELIF) }
c171581
return id } } *labels = append(*labels, bpfLabel{lb, 0xffffffff}) return id }
c171582
var buf syscall.Statfs_t syscall.Statfs(selinuxfs, &buf) if (buf.Flags & stRdOnly) == 1 { selinuxfs = "" } } return selinuxfs }
c171583
true if fs := getSelinuxMountPoint(); fs != "" { if con, _ := Getcon(); con != "kernel" { selinuxEnabled = true } } return selinuxEnabled }
c171584
xattrNameSelinux, []byte(scon), 0) }
c171585
// Trim the NUL byte at the end of the byte buffer, if present. if con[len(con)-1] == '\x00' { con = con[:len(con)-1] } return string(con), err }
c171586
return fmt.Errorf("Relabeling content in %s is not allowed.", prefix) } } return nil }
c171587
Setfilecon(p, scon) } if recurse { return filepath.Walk(fpath, callback) } return Setfilecon(fpath, scon) }
c171588
} return []string{"label:user:" + con["user"], "label:role:" + con["role"], "label:type:" + con["type"], "label:level:" + con["level"]} }
c171589
:= netlink.AddToBridge(host, bridge); err != nil { return err } if err := netlink.NetworkSetMTU(host, n.Mtu); err != nil { return err } if n.HairpinMode { if err := netlink.SetHairpinMode(host, true); err != nil { return err } } if err := netlink.NetworkLinkUp(host); err != nil { return err } return nil }
c171590
c.syscalls[s.Value] = s }
c171591
0, 0); err != nil { return err } prog := newSockFprog(filter) return prog.set() }
c171592
nodeToTargets: make(map[ID]map[ID]float64), // // without this // panic: assignment to entry in nil map } }
c171593
members forests.mu.Lock() defer forests.mu.Unlock() forests.data[newDS] = struct{}{} }
c171594
} for k := range data.members { if k == name { return data } } } return nil }
c171595
forests.mu.Unlock() forests.data[newDS] = struct{}{} delete(forests.data, ds1) delete(forests.data, ds2) }
c171596
c.request("GET", "me", user, nil, nil) if err != nil { return nil, err } return user, nil }
c171597
_, project := range projects { if err := cleanupProject(project); err != nil { return nil, err } } return projects, nil }
c171598
c.request("DELETE", fmt.Sprintf("project/%s/%s/enable", account, repo), nil, nil, nil) }
c171599
repo), project, nil, nil) if err != nil { return nil, err } if err := cleanupProject(project); err != nil { return nil, err } return project, nil }