37 lines
1.3 KiB
JavaScript
37 lines
1.3 KiB
JavaScript
"use strict";
|
|
exports.__esModule = true;
|
|
exports.exec = void 0;
|
|
var commands_1 = require("./commands");
|
|
function exec(args, curdir, socket, buffer, sessions, filesystem, curdirx) {
|
|
var buf = "";
|
|
if (args.length == 0) {
|
|
buf += "exec: missing operand\n";
|
|
}
|
|
else {
|
|
var file = args[0];
|
|
if (curdir[socket.id][file] == undefined) {
|
|
buf += "exec: " + file + ": No such file or directory\n";
|
|
}
|
|
else if (typeof curdir[socket.id][file] == "string") {
|
|
var commands = curdir[socket.id][file].split("\n");
|
|
for (var i = 0; i < commands.length; i++) {
|
|
var exploded = commands[i].split(" ");
|
|
var commandx = exploded[0];
|
|
var bannedcommands = ["exec", "exit"];
|
|
if (!bannedcommands.includes(commandx)) {
|
|
var argsx = exploded.slice(1);
|
|
(0, commands_1.resolveCommand)(commandx, socket, argsx, buffer, sessions, filesystem, curdir, curdirx);
|
|
}
|
|
else {
|
|
buf += "Error: " + commandx + " is a restricted command\n";
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
buf += "exec: " + file + ": Is not a file\n";
|
|
}
|
|
}
|
|
return buf;
|
|
}
|
|
exports.exec = exec;
|
|
//# sourceMappingURL=exec.js.map
|