Skip to content

Commit

Permalink
Merge pull request yuanxingyang#4 from xuqi2024/jfrog_upload_feature_…
Browse files Browse the repository at this point in the history
…taiji

Jfrog upload feature taiji
  • Loading branch information
yuanxingyang authored Apr 26, 2024
2 parents 11179dd + a03424e commit 3b8a743
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 80 deletions.
14 changes: 0 additions & 14 deletions pym/bob/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,11 +687,6 @@ def __init__(self, coreStep, env, enabled, spec):
}
self.user = recipeSet.getSandboxUser() or spec.get('user', "nobody")

self.user = {
k : env.substitute(v, "providedSandbox::user")
for (k, v) in spec.get('user', {}).items()
}

# Calculate a "resultId" so that only identical sandboxes match
h = hashlib.sha1()
h.update(self.coreStep.variantId)
Expand All @@ -708,7 +703,6 @@ def __init__(self, coreStep, env, enabled, spec):
h.update(struct.pack("<II", len(key), len(val)))
h.update((key+val).encode('utf8'))
h.update(self.user.encode('utf8'))

self.resultId = h.digest()

def __eq__(self, other):
Expand Down Expand Up @@ -770,7 +764,6 @@ def getUser(self):
"""Get user identity in sandbox.
Returns one of 'nobody', 'root' or '$USER'.
"""
return self.coreSandbox.user

Expand Down Expand Up @@ -2871,12 +2864,6 @@ def validate(self, data):

raise schema.SchemaError(None, "Mount entry must be a string or a two/three items list!")

class UserValidator:
def validate(self, data):
if isinstance(data, dict):
return ({data[0]:data[1]})
raise schema.SchemaError(None, "User entry must be a dictionary type list!")

class RecipeSet:
"""The RecipeSet corresponds to the project root directory.
Expand Down Expand Up @@ -3102,7 +3089,6 @@ def removeWhiteList(x):
schema.Schema({
schema.Optional('mount') : schema.Schema([ MountValidator() ]),
schema.Optional('paths') : [str],

schema.Optional('user') : schema.Or("nobody", "root", "$USER"),
}),
lambda x: updateDicRecursive(self.__sandboxOpts, x),
Expand Down
11 changes: 1 addition & 10 deletions pym/bob/intermediate.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,7 @@ def getAllDepSteps(self):
return [ self.mungeStep(dep) for dep in self.__data['allDepSteps'] ]

def getEnv(self):
envs = dict(self.__data['env'])
for (name, tool) in sorted(self.getTools().items()):
for(key, value) in tool.getEnv().items():
if (key in envs) and (value.startswith(("./", "../"))):
envs[key] = os.path.join(tool.getStep().getExecPath(self), value)
return envs
return self.__data['env']

def getPaths(self):
# FIXME: rename to getToolPaths
Expand Down Expand Up @@ -485,7 +480,6 @@ def fromTool(cls, tool, graph):
self.__data['step'] = graph.addStep(tool.getStep(), True)
self.__data['path'] = tool.getPath()
self.__data['libs'] = tool.getLibs()
self.__data['envs'] = tool.getEnvironment()
return self

@classmethod
Expand All @@ -506,9 +500,6 @@ def getPath(self):
def getLibs(self):
return self.__data['libs']

def getEnv(self):
return self.__data['envs']

class RecipeIR(AbstractIR):
@classmethod
def fromRecipe(cls, recipe, graph):
Expand Down
19 changes: 0 additions & 19 deletions pym/bob/invoker.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,20 +267,6 @@ async def __runCommand(self, args, cwd, stdout=None, stderr=None,

return FinishedProcess(ret, stdoutBuf, stderrBuf)

# UID is not in the environment variables
def __get_uid_value(self, variable_name):
if variable_name.isdigit():
return str(variable_name)
else:
return str(os.getuid())

# GID is not in the environment variables
def __get_gid_value(self, variable_name):
if variable_name.isdigit():
return str(variable_name)
else:
return str(os.getgid())

def __getSandboxCmds(self, tmpDir):
if sys.platform != "linux":
self.fail("Sandbox builds are only supported on Linux!")
Expand All @@ -307,11 +293,6 @@ def __getSandboxCmds(self, tmpDir):
cmdArgs.extend(["-w", sndbxPath])
elif hostPath != sndbxPath:
cmdArgs.extend(["-m", sndbxPath])
if 'uid' in self.__spec.sandboxUser:
cmdArgs.extend(["-U", self.__get_uid_value(self.__spec.sandboxUser['uid'])])

if 'gid' in self.__spec.sandboxUser:
cmdArgs.extend(["-G", self.__get_gid_value(self.__spec.sandboxUser['gid'])])

if self.__spec.sandboxUser == "root":
cmdArgs.append("-r")
Expand Down
37 changes: 0 additions & 37 deletions src/namespace-sandbox/namespace-sandbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,8 @@ struct Options {
int num_mounts; // How many mounts were specified
char **create_dirs; // empty dirs to create (-d)
int num_create_dirs; // How many empty dirs to create were specified

uid_t uid; // User id in namespace
uid_t gid; // Group id in namespace

int create_netns; // If 1, create a new network namespace.
const char *host_name; // Host name (-H)
};
Expand Down Expand Up @@ -142,8 +140,6 @@ static void Usage(int argc, char *const *argv, const char *fmt, ...) {
" -i if set, keep the uid/gid\n"
" -r if set, make the uid/gid be root, otherwise use nobody\n"
" -H <name> set host name\n"
" -U <uid> set custom uid\n"
" -G <gid> set custom gid\n"
" -D if set, debug info will be printed\n"
" -l <file> redirect stdout to a file\n"
" -L <file> redirect stderr to a file\n"
Expand Down Expand Up @@ -246,20 +242,6 @@ static void ParseOptionsFile(const char *filename, struct Options *opt) {
ParseCommandLine(sub_argc, sub_argv, opt);
}

// Function to check if a string is a numeric string
bool IsNumeric(const char *str) {
if (str == NULL || *str == '\0') {
return false;
}
while (*str) {
if (*str < '0' || *str > '9') {
return false;
}
str++;
}
return true;
}

// Parse the command line flags and return the result in an Options structure
// passed as argument.
static void ParseCommandLine(int argc, char *const *argv, struct Options *opt) {
Expand All @@ -268,7 +250,6 @@ static void ParseCommandLine(int argc, char *const *argv, struct Options *opt) {
int c;

while ((c = getopt(argc, argv, ":CDd:il:L:m:M:nrS:W:w:H:")) != -1) {

switch (c) {
case 'C':
// Shortcut for the "does this system support sandboxing" check.
Expand Down Expand Up @@ -350,20 +331,6 @@ static void ParseCommandLine(int argc, char *const *argv, struct Options *opt) {
case 'H':
opt->host_name = optarg;
break;
case 'U':
if (IsNumeric(optarg)) {
opt->custom_uid = atoi(optarg);
} else {
Usage(argc, argv, "The -U option must be a numeric string.");
}
break;
case 'G':
if (IsNumeric(optarg)) {
opt->custom_gid = atoi(optarg);
} else {
Usage(argc, argv, "The -G option must be a numeric string.");
}
break;
case 'D':
global_debug = true;
break;
Expand Down Expand Up @@ -719,8 +686,6 @@ static void ExecCommand(char *const *argv) {

int main(int argc, char *const argv[]) {
struct Options opt;
opt.custom_uid = kNobodyUid;
opt.custom_gid = kNobodyGid;
memset(&opt, 0, sizeof(opt));
opt.uid = kNobodyUid;
opt.gid = kNobodyGid;
Expand Down Expand Up @@ -759,10 +724,8 @@ int main(int argc, char *const argv[]) {
// outside environment.
CHECK_CALL(mount("none", "/", NULL, MS_REC | MS_PRIVATE, NULL));


SetupDirectories(&opt, opt.uid);
SetupUserNamespace(uid, gid, opt.uid, opt.gid);

if (opt.host_name) {
CHECK_CALL(sethostname(opt.host_name, strlen(opt.host_name)));
}
Expand Down

0 comments on commit 3b8a743

Please sign in to comment.