<commit_before>package main

import (
	"errors"
	"fmt"
	"os"
	"os/exec"
	"os/user"
	"path/filepath"

	"github.com/concourse/atc"
	"github.com/tedsuo/ifrit"
	"github.com/tedsuo/ifrit/grouper"
	"github.com/tedsuo/ifrit/sigmon"
	"github.com/vito/concourse-bin/bindata"
)

var ErrNotRoot = errors.New("worker must be run as root")

func (cmd *WorkerCommand) Execute(args []string) error {
	currentUser, err := user.Current()
	if err != nil {
		return err
	}

	if currentUser.Uid != "0" {
		return ErrNotRoot
	}

	err = bindata.RestoreAssets(cmd.WorkDir, "linux")
	if err != nil {
		return err
	}

	linux := filepath.Join(cmd.WorkDir, "linux")

	gardenBin := filepath.Join(linux, "garden-linux")
	binDir := filepath.Join(linux, "bin")
	depotDir := filepath.Join(linux, "depot")
	graphDir := filepath.Join(linux, "graph")
	snapshotsDir := filepath.Join(linux, "snapshots")
	stateDir := filepath.Join(linux, "state")

	err = os.MkdirAll(depotDir, 0700)
	if err != nil {
		return err
	}

	err = os.MkdirAll(graphDir, 0700)
	if err != nil {
		return err
	}

	gardenAddr := fmt.Sprintf("%s:%d", cmd.BindIP, cmd.BindPort)

	gardenArgs := []string{
		"-listenNetwork", "tcp",
		"-listenAddr", gardenAddr,
		"-bin", binDir,
		"-depot", depotDir,
		"-graph", graphDir,
		"-snapshots", snapshotsDir,
		"-stateDir", stateDir,
		"-allowHostAccess",
	}
<commit_msg>fix permissions of depot dir<commit_after>package main

import (
	"errors"
	"fmt"
	"os"
	"os/exec"
	"os/user"
	"path/filepath"

	"github.com/concourse/atc"
	"github.com/tedsuo/ifrit"
	"github.com/tedsuo/ifrit/grouper"
	"github.com/tedsuo/ifrit/sigmon"
	"github.com/vito/concourse-bin/bindata"
)

var ErrNotRoot = errors.New("worker must be run as root")

func (cmd *WorkerCommand) Execute(args []string) error {
	currentUser, err := user.Current()
	if err != nil {
		return err
	}

	if currentUser.Uid != "0" {
		return ErrNotRoot
	}

	err = bindata.RestoreAssets(cmd.WorkDir, "linux")
	if err != nil {
		return err
	}

	linux := filepath.Join(cmd.WorkDir, "linux")

	gardenBin := filepath.Join(linux, "garden-linux")
	binDir := filepath.Join(linux, "bin")
	depotDir := filepath.Join(linux, "depot")
	graphDir := filepath.Join(linux, "graph")
	snapshotsDir := filepath.Join(linux, "snapshots")
	stateDir := filepath.Join(linux, "state")

	// must be readable by other users so unprivileged containers can run their
	// own `initc' process
	err = os.MkdirAll(depotDir, 0755)
	if err != nil {
		return err
	}

	err = os.MkdirAll(graphDir, 0700)
	if err != nil {
		return err
	}

	gardenAddr := fmt.Sprintf("%s:%d", cmd.BindIP, cmd.BindPort)

	gardenArgs := []string{
		"-listenNetwork", "tcp",
		"-listenAddr", gardenAddr,
		"-bin", binDir,
		"-depot", depotDir,
		"-graph", graphDir,
		"-snapshots", snapshotsDir,
		"-stateDir", stateDir,
		"-allowHostAccess",
	}

{'fraction_non_alphanumeric': 0.16512455516014235, 'fraction_numerical': 0.006405693950177936, 'mean_word_length': 4.092391304347826, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7194379', 'n_tokens_mistral': 1176, 'n_tokens_neox': 1102, 'n_words': 233}