id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c20900
err == nil { return caps.Get(capability.EFFECTIVE, capability.CAP_SYS_CHROOT) } else { return os.Geteuid() == 0 } }
c20901
group, ok := groups[groupName] if !ok { return -1, fmt.Errorf("%q group not found", groupName) } return group.Gid, nil }
c20902
createAndLock(lockDir, key, keyLockExclusive|keyLockNonBlocking) }
c20903
createAndLock(lockDir, key, keyLockExclusive) }
c20904
nil { return err } return nil }
c20905
continue } if err != nil { return err } err = os.Remove(filename) if err != nil { keyLock.Close() return errwrap.Wrap(errors.New("error removing lock file"), err) } keyLock.Close() } return nil }
c20906
if err != nil { return nil, errwrap.Wrap(errors.New("prefix meta discovery error"), err) } if len(kls) == 0 { return nil, fmt.Errorf("meta discovery on %s resulted in no keys", prefix) } return kls, nil }
c20907
the following:", prefix) log.Printf(" - call rkt with --trust-keys-from-https") log.Printf(" - run: rkt trust --prefix %q", prefix) return fmt.Errorf("error reviewing key: unable to ask user to review fingerprint due to lack of tty") } accepted, err := reviewKey() if err != nil { return errwra...
c20908
insecure | discovery.InsecureTLS } keys, attempts, err := discovery.DiscoverPublicKeys(*app, hostHeaders, insecure, 0) if err != nil && m.Debug { for _, a := range attempts { log.PrintE(fmt.Sprintf("meta tag 'ac-discovery-pubkeys' not found on %s", a.Prefix), a.Error) } } return keys, err }
c20909
errwrap.Wrap(errors.New("error getting key"), err) } defer res.Body.Close() if res.StatusCode != http.StatusOK { return nil, fmt.Errorf("bad HTTP status code: %d", res.StatusCode) } if _, err := io.Copy(tf, res.Body); err != nil { return nil, errwrap.Wrap(errors.New("error copying key"), err) } if _, err...
c20910
%s", fingerToString(k.PrimaryKey.Fingerprint)) for _, sk := range k.Subkeys { stdout.Printf(" Subkey fingerprint: %s", fingerToString(sk.PublicKey.Fingerprint)) } for n := range k.Identities { stdout.Printf("\t%s", n) } } return nil }
c20911
} switch input { case "yes\n": return true, nil case "no\n": return false, nil default: stdout.Printf("Please enter 'yes' or 'no'") } } }
c20912
if err != nil { return nil, errwrap.Wrap(errors.New("tuntap persist"), err) } link, err := netlink.LinkByName(ifName) if err != nil { return nil, errwrap.Wrap(fmt.Errorf("cannot find link %q", ifName), err) } if err := netlink.LinkSetUp(link); err != nil { return nil, errwrap.Wrap(fmt.Errorf("cannot set l...
c20913
err := netlink.LinkAdd(link); err != nil { return nil, errwrap.Wrap(errors.New("cannot create macvtap interface"), err) } // TODO: duplicate following lines for ipv6 support, when it will be added in other places ipv4SysctlValueName := fmt.Sprintf(IPv4InterfaceArpProxySysctlTemplate, interfaceName) if _, err :=...
c20914
err != nil { stderr.PrintE("error removing forwarded ports (kvm)", err) } n.teardownKvmNets() }
c20915
for %q", aciPath), err) } aciPath = absPath aciFile, err := f.getFile(aciPath, a) if err != nil { return "", err } defer aciFile.Close() key, err := f.S.WriteACI(aciFile, imagestore.ACIFetchInfo{ Latest: false, }) if err != nil { return "", err } return key, nil }
c20916
aciFile.Close() } }() validator, errClose := newValidator(aciFile) if errClose != nil { return nil, errClose } entity, errClose := validator.ValidateWithSignature(f.Ks, ascFile) if errClose != nil { return nil, errwrap.Wrap(fmt.Errorf("image %q verification failed", validator.ImageName()), errClose) }...
c20917
...interface{})) MountUnmounter { return &loggingMounter{m, um, logf} }
c20918
connection.Extend(15, 0x1000, nil, description) return err }
c20919
filepath.Join(Stage1ImagePath(root), aci.RootfsDir) }
c20920
filepath.Join(Stage1ImagePath(root), aci.ManifestFile) }
c20921
{ return filepath.Join(AppsStatusesPath(root), appName) }
c20922
filepath.Join(AppsStatusesPathFromStage1Rootfs(rootfs), appName) }
c20923
filepath.Join(AppsPath(root), appName.String()) }
c20924
filepath.Join(AppPath(root, appName), aci.RootfsDir) }
c20925
{ return filepath.Join(stage2Dir, appName.String()) }
c20926
{ return filepath.Join(RelAppPath(appName), aci.RootfsDir) }
c20927
filepath.Join(AppPath(root, appName), aci.ManifestFile) }
c20928
filepath.Join(AppsInfoPath(root), appName.String()) }
c20929
filepath.Join(AppInfoPath(root, appName), AppTreeStoreIDFilename) }
c20930
filepath.Join(AppInfoPath(root, appName), aci.ManifestFile) }
c20931
err) } // In case it already existed and we didn't make it, ensure permissions are // what the caller expects them to be. if err := os.Chmod(sharedVolPath, SharedVolumePerm); err != nil { return "", errwrap.Wrap(fmt.Errorf("could not change permissions of %q", sharedVolPath), err) } return sharedVolPath, nil ...
c20932
fmt.Sprintf("http://%v:%v/%v", ip, MetadataServicePort, token) }
c20933
absolute path for %s", binPath) } if fileutil.IsExecutable(binAbsPath) { return binAbsPath, nil } } return "", fmt.Errorf("unable to find %q in %q", bin, paths) }
c20934
n, err := fmt.Sscanf(versionStr, "systemd %d", &version) if err != nil || n != 1 { return -1, fmt.Errorf("cannot parse version: %q", versionStr) } return version, nil }
c20935
ErrOverlayUnsupported return ErrOverlayUnsupported(fmt.Sprintf("cannot open /proc/filesystems: %v", err)) } defer f.Close() s := bufio.NewScanner(f) for s.Scan() { if s.Text() == "nodev\toverlay" { return nil } } return ErrOverlayUnsupported("overlay entry not present in /proc/filesystems") }
c20936
if len(v) > 0 { lines = append(lines, v) } } return lines }
c20937
status, ok := exiterr.Sys().(syscall.WaitStatus); ok { return status.ExitStatus(), nil } } return -1, err }
c20938
:= types.SanitizeACName(last) if err != nil { return nil, err } return types.MustACName(sn), nil }
c20939
n.GetActiveNetworks() { nds = append(nds, an) } return nds }
c20940
:= fmt.Sprintf("mode=tap,tapif=%s,host_ip=%s,guest_ip=%s", nd.IfName(), nd.Gateway(), nd.GuestIP()) lkvmArgs = append(lkvmArgs, lkvmArg) } return lkvmArgs, nil }
c20941
err := rand.Read(mac[3:6]) if err != nil { return nil, errwrap.Wrap(errors.New("cannot generate random mac address"), err) } return mac, nil }
c20942
strings.Replace(str, "!!!"+ph+"!!!", value, -1) } return str }
c20943
:= f.String("target", "", "Make target (example: $(FOO_BINARY))") return f, target }
c20944
%q result", n.conf.Name), err) } if pr.IP4 == nil { return nil // TODO(casey) should this be an error? } // All is well - mutate the runtime n.runtime.MergeCNIResult(pr) return nil }
c20945
Name: app.Name, Image: app.Image, Annotations: app.Annotations, }) } return p }
c20946
img.Name, Version: img.Version, ImportTimestamp: img.ImportTimestamp, Manifest: img.Manifest, Size: img.Size, Annotations: img.Annotations, Labels: img.Labels, } }
c20947
globalFlags.SystemConfigDir, LocalConfigDir: globalFlags.LocalConfigDir, UserConfigDir: globalFlags.UserConfigDir, InsecureFlags: globalFlags.InsecureFlags.String(), TrustKeysFromHttps: globalFlags.TrustKeysFromHTTPS, }, }, }, nil }
c20948
findInKeyValues(actualKVs, requiredKV.Key) if !ok || actualValue != requiredKV.Value { return false } } return true }
c20949
} if !s.HasAll(filter.NetworkNames...) { return false } } // Filter according to the annotations. if len(filter.Annotations) > 0 { if !containsAllKeyValues(pod.Annotations, filter.Annotations) { return false } } // Filter according to the cgroup. if len(filter.Cgroups) > 0 { s := set.NewString...
c20950
:= range filters { if satisfiesPodFilter(*pod, *filter) { return true } } return false }
c20951
returned in 'ListPods()'. } apps = append(apps, &v1alpha.App{ Name: app.Name.String(), Image: img, Annotations: convertAnnotationsToKeyValue(app.Annotations), State: v1alpha.AppState_APP_STATE_UNDEFINED, ExitCode: -1, }) } return apps }
c20952
append(networks, &v1alpha.Network{ Name: n.NetName, // There will be IPv6 support soon so distinguish between v4 and v6 Ipv4: n.IP.String(), }) } return networks }
c20953
Version: schema.AppContainerVersion.String(), }, Id: app.Image.Id, // Other information are not available because they require the image // info from store. Some of it is filled in below if possible. } im, err := pod.AppImageManifest(app.Name) if err != nil { stderr.PrintE(fmt.Sprintf("failed to ...
c20954
err := s.getBasicPodFromDisk(p) if mtimeErr != nil || err != nil { // If any error happens or the mtime is unknown, // returns the raw pod directly without adding it to the cache. return pod } cacheItem := &podCacheItem{pod, mtime} s.podCache.Add(p.UUID.String(), cacheItem) // Return a copy of the pod, so...
c20955
aciInfo.BlobKey, Name: im.Name.String(), Version: version, ImportTimestamp: aciInfo.ImportTime.Unix(), Manifest: manifest, Size: aciInfo.Size + aciInfo.TreeStoreSize, Annotations: convertAnnotationsToKeyValue(im.Annotations), Labels: convertLabel...
c20956
if filter.ImportedAfter > 0 { if image.ImportTimestamp <= filter.ImportedAfter { return false } } if filter.ImportedBefore > 0 { if image.ImportTimestamp >= filter.ImportedBefore { return false } } // Filter according to the image labels. if len(filter.Labels) > 0 { if !containsAllKeyValues(imag...
c20957
range filters { if satisfiesImageFilter(*image, *filter) { return true } } return false }
c20958
option. v1AlphaAPIServer, err := newV1AlphaAPIServer() if err != nil { stderr.PrintE("failed to create API service", err) return 254 } v1alpha.RegisterPublicAPIServer(publicServer, v1AlphaAPIServer) for _, l := range listeners { defer l.Close() go publicServer.Serve(l) } stderr.Printf("API service r...
c20959
err != nil { uw.err = errwrap.Wrap(errors.New(errmsg), err) return } if err := user.ShiftFiles([]string{path}, &uw.p.UidRange); err != nil { uw.err = errwrap.Wrap(errors.New(errmsg), err) return } }
c20960
unit.NewUnitOption("Service", "StandardError", "null"), }...) shutdownVerb := "exit" // systemd <v227 doesn't allow the "exit" verb when running as PID 1, so // use "halt". // If systemdVersion is 0 it means it couldn't be guessed, assume it's new // enough for "systemctl exit". // This can happen, for example...
c20961
unit), wantPath); err != nil && !os.IsExist(err) { uw.err = errwrap.Wrap(errors.New("failed to link service want"), err) } }
c20962
ra.Name.String()) { opts = append(opts, unit.NewUnitOption("Service", "Type", "notify")) } // Some pre-start jobs take a long time, set the timeout to 0 opts = append(opts, unit.NewUnitOption("Service", "TimeoutStartSec", "0")) opts = append(opts, unit.NewUnitOption("Unit", "Requires", "sysusers.service")) op...
c20963
unit.NewUnitOption("Service", "RemainAfterExit", "yes"), unit.NewUnitOption("Service", "ExecStop", fmt.Sprintf( "/reaper.sh \"%s\" \"%s\" \"%s\"", appName, common.RelAppRootfsPath(appName), binPath, )), }...) uw.WriteUnit( ServiceUnitPath(uw.p.Root, types.ACName(fmt.Sprintf("reaper-%s", appName)))...
c20964
unit.NewUnitOption("Socket", "Service", fmt.Sprintf("%s.service", appName)), unit.NewUnitOption("Socket", "FileDescriptorName", streamName), unit.NewUnitOption("Socket", "ListenFIFO", filepath.Join("/rkt/iottymux", appName.String(), "stage2-"+streamName)), }...) uw.WriteUnit( TypedUnitPath(uw.p.Root, appName....
c20965
opts = append(opts, unit.NewUnitOption(section, property, fmt.Sprintf("%s%s", prefix, v))) } return opts }
c20966
if err != nil { return nil, err } defer p.Close() return appsForPod(p, appName, appStateInMutablePod) }
c20967
hostPath = podVolsByName[mnt.Volume].Source if ro := podVolsByName[mnt.Volume].ReadOnly; ro != nil { readOnly = *ro } } app.Mounts = append(app.Mounts, &v1.Mount{ Name: mnt.Volume.String(), ContainerPath: mnt.Path, HostPath: hostPath, ReadOnly: readOnly, }) } // Gene...
c20968
if !start.IsZero() { startedAt := start.UnixNano() app.StartedAt = &startedAt } // the best we can guess for immutable pods finish, err := pod.GCMarkedTime() if err != nil { return err } if !finish.IsZero() { finishedAt := finish.UnixNano() app.FinishedAt = &finishedAt } return nil }
c20969
nil { return err } return ioutil.WriteFile(path, buf, 0644) }
c20970
pod manifest"), err) } pm := &schema.PodManifest{} if err := json.Unmarshal(buf, pm); err != nil { return nil, errwrap.Wrap(errors.New("failed unmarshalling pod manifest"), err) } return pm, nil }
c20971
err := f.FetchImage(d, app.Image, app.Asc) if err != nil { return err } app.ImageID = *h return nil }) }
c20972
the system supports OverlayFS // 2) check if we're root if common.SupportsOverlay() == nil && os.Geteuid() == 0 { if _, _, err := f.Ts.Render(hash, false); err != nil { return nil, errwrap.Wrap(errors.New("error rendering tree store"), err) } } h, err := types.NewHash(hash) if err != nil { // should neve...
c20973
= el.Next() { a := &asc{} d := el.Value.(*dist.Appc) str := d.String() db := &distBundle{ dist: d, image: str, } hash, err := f.fetchSingleImage(db, a) if err != nil { return err } f.addImageDeps(hash, imgsl, seen) } return nil }
c20974
Logger: log.New(out, prefix, 0), } l.SetFlags(0) return l }
c20975
l.Print(l.formatErr(e, "")) }
c20976
l.Print(l.formatErr(fmt.Errorf(format, a...), "")) }
c20977
l.Panic(l.formatErr(e, msg)) }
c20978
fmt.Sprintf("%s%c", format, '\n'), values...) }
c20979
a directory %q: %v\n", dir, err)) } return filepath.Clean(absDir) }
c20980
!= nil: return time.ParseDuration(s) case b: return time.Duration(-1), nil } return time.Duration(0), nil }
c20981
ctx, _ = context.WithTimeout(ctx, t) } return ctx }
c20982
make(map[string]int) for _, app := range manifest.Apps { exitCode, err := p.AppExitCode(app.Name.String()) if err != nil { continue } stats[app.Name.String()] = exitCode } return stats, nil }
c20983
!(state == pkgPod.Running || state == pkgPod.Deleting || state == pkgPod.ExitedDeleting || state == pkgPod.Exited || state == pkgPod.ExitedGarbage) { return nil } if pid, err := p.Pid(); err == nil { // the pid file might not be written yet when the state changes to 'Running' // it may also never be written i...
c20984
= ascPathFromImgPath(copy.Path) return &copy }
c20985
lines = append(lines, fmt.Sprintf(" %s", v.Name)) } log.Print(strings.Join(lines, "\n")) }
c20986
a file:// image string, call this function again to return an ACI distribution return DistFromImageString(is) default: return nil, fmt.Errorf("invalid image string type %q", appImageType) } case "file", "http", "https": // An ACI archive with any transport type (file, http, s3 etc...) and final aci extens...
c20987
nil { return nil, fmt.Errorf("malformed distribution version: %s", parts[1]) } return &cimd{ Type: Type(parts[0]), Version: uint32(version), Data: parts[2], }, nil }
c20988
fmt.Sprintf("%s:%s:v=%d:%s", Scheme, typ, version, data) }
c20989
} for _, ra := range apps { if *exportAppName == ra.Name { return &ra, nil } } return nil, fmt.Errorf("app %s is not present in pod", flagExportAppName) } switch len(apps) { case 0: return nil, fmt.Errorf("pod contains zero apps") case 1: return &apps[0], nil default: } stderr.Print("pod c...
c20990
} upper := filepath.Join(imgDir, "upper", app.Name.String()) if _, err := os.Stat(upper); err != nil { return err } work := filepath.Join(imgDir, "work", app.Name.String()) if _, err := os.Stat(work); err != nil { return err } if err := overlay.Mount(&overlay.MountCfg{lower, upper, work, dest, ""}); err !...
c20991
pod was started with --private-user (user namespace) var walkerCb aci.TarHeaderWalkFunc = func(hdr *tar.Header) bool { if uidRange != nil { uid, gid, err := uidRange.UnshiftRange(uint32(hdr.Uid), uint32(hdr.Gid)) if err != nil { stderr.PrintE("error unshifting gid and uid", err) return false } h...
c20992
0 { stderr.Print("cannot run as unprivileged user") cmdExitCode = 254 return } cf(cmd, args) } }
c20993
sf.mode = ModeWhitelist sf.syscalls, flag, err = parseLinuxSeccompSet(p, seccomp) if err != nil { return nil, err } if flag == "all" { // Opt-out seccomp filtering return nil, nil } } sf.errno = string(seccomp.Errno()) } } // If unset, use rkt default whitelist if seen...
c20994
filterPrefix = sdWhitelistPrefix case ModeBlacklist: filterPrefix = sdBlacklistPrefix default: return nil, fmt.Errorf("unknown filter mode %v", sf.mode) } // SystemCallFilter options are written down one entry per line, because // filtering sets may be quite large and overlong lines break unit serialization....
c20995
case "default-blacklist": syscallFilter = append(syscallFilter, RktDefaultSeccompBlacklist...) case "default-whitelist": syscallFilter = append(syscallFilter, RktDefaultSeccompWhitelist...) } case "@systemd": // Custom systemd wildcards (systemd >= 231) _, systemdVersion, err := GetFlav...
c20996
err = cleanupStage1(appName, enterCmd) default: // unknown step err = fmt.Errorf("unsupported cleaning step %d", flagStage) } if err != nil { log.FatalE("cleanup error", err) } os.Exit(0) }
c20997
syscall.Mount("", m.MountPoint, "", syscall.MS_PRIVATE|syscall.MS_REC, "") // simple unmount, it may fail if the target is busy (eg. overlapping children) if e := syscall.Unmount(m.MountPoint, 0); e != nil { // if busy, just detach here and let the kernel clean it once free _ = syscall.Unmount(m.MountPoint, ...
c20998
&& err != os.ErrNotExist { stderr.PrintE("rename error", err) } } }); err != nil { return err } return nil }
c20999
err != nil && err != os.ErrNotExist { stderr.PrintE("rename error", err) } } }); err != nil { return err } return nil }