Skip to content

Commit f1d64f6

Browse files
committed
CONSOLE: don't read the current working directory in batch mode - fixes EOS-6169
1 parent 833c6a2 commit f1d64f6

1 file changed

Lines changed: 26 additions & 3 deletions

File tree

console/ConsoleMain.cc

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
#include <readline/readline.h>
4747
#include <readline/history.h>
4848
#include <list>
49+
#include <sys/time.h>
50+
#include <sys/resource.h>
4951
#include <XrdCl/XrdClPostMaster.hh>
5052

5153
#ifdef __APPLE__
@@ -92,6 +94,7 @@ extern int com_license(char*);
9294
extern int com_ln(char*);
9395
extern int com_ls(char*);
9496
extern int com_map(char*);
97+
extern int com_mdcopy(char*);
9598
extern int com_member(char*);
9699
extern int com_mkdir(char*);
97100
extern int com_motd(char*);
@@ -136,7 +139,7 @@ extern int com_accounting(char*);
136139
extern int com_quota(char*);
137140
extern int com_daemon(char*);
138141
extern int com_proto_sched(char*);
139-
142+
extern int com_zip(char*);
140143

141144
//------------------------------------------------------------------------------
142145
// Command mapping array
@@ -184,6 +187,7 @@ COMMAND commands[] = {
184187
{ (char*) "ls", com_ls, (char*) "List a directory"},
185188
{ (char*) "ln", com_ln, (char*) "Create a symbolic link"},
186189
{ (char*) "map", com_map, (char*) "Path mapping interface"},
190+
{ (char*) "mdcopy", com_mdcopy, (char*) "Meta-data copy toole"},
187191
{ (char*) "member", com_member, (char*) "Check Egroup membership"},
188192
{ (char*) "mkdir", com_mkdir, (char*) "Create a directory"},
189193
{ (char*) "motd", com_motd, (char*) "Message of the day"},
@@ -222,6 +226,7 @@ COMMAND commands[] = {
222226
{ (char*) "vid", com_vid, (char*) "Virtual ID System Configuration"},
223227
{ (char*) "whoami", com_whoami, (char*) "Determine how we are mapped on server side"},
224228
{ (char*) "who", com_who, (char*) "Statistics about connected users"},
229+
{ (char*) "zip", com_zip, (char*) "Remote Zip Tools"},
225230
{ (char*) "?", com_help, (char*) "Synonym for 'help'"},
226231
{ (char*) ".q", com_quit, (char*) "Exit from EOS console"},
227232
{ (char*) 0, (int (*)(char*))0, (char*) 0}
@@ -1164,6 +1169,19 @@ Run(int argc, char* argv[])
11641169
execute_line((char*) "version");
11651170
}
11661171

1172+
// bump up the filedescriptor limits
1173+
{
1174+
int fdlimit = 4096;
1175+
struct rlimit newrlimit;
1176+
newrlimit.rlim_cur = fdlimit;
1177+
newrlimit.rlim_max = fdlimit;
1178+
if ((setrlimit(RLIMIT_NOFILE, &newrlimit) != 0) && (!geteuid())) {
1179+
fprintf(stderr, "warning: unable to set fd limit to %d - errno %d\n",
1180+
fdlimit, errno);
1181+
}
1182+
}
1183+
1184+
11671185
char prompt[4096];
11681186

11691187
if (pipemode) {
@@ -1198,8 +1216,11 @@ Run(int argc, char* argv[])
11981216
}
11991217

12001218
read_history(historyfile.c_str());
1219+
12011220
// load the last used current working directory
1202-
read_pwdfile();
1221+
if (interactive) {
1222+
read_pwdfile();
1223+
}
12031224

12041225
// Loop reading and executing lines until the user quits.
12051226
for (; done == 0;) {
@@ -1547,7 +1568,9 @@ bool RequiresMgm(const std::string& name, const std::string& args)
15471568
(name == "exit") || (name == "help") || (name == "json") ||
15481569
(name == "pwd") || (name == "quit") || (name == "role") ||
15491570
(name == "silent") || (name == "timing") || (name == "?") ||
1550-
(name == ".q") || (name == "daemon") || (name == "scitoken")) {
1571+
(name == ".q") || (name == "daemon") || (name == "scitoken") ||
1572+
(name == "mdcopy"))
1573+
{
15511574
return false;
15521575
}
15531576

0 commit comments

Comments
 (0)