// ----------------------------------------------------------------------
// File: com_chown.cc
// Author: Andreas-Joachim Peters - CERN
// ----------------------------------------------------------------------
/************************************************************************
* EOS - the CERN Disk Storage System *
* Copyright (C) 2011 CERN/Switzerland *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see .*
************************************************************************/
/*----------------------------------------------------------------------------*/
#include "common/StringTokenizer.hh"
#include "console/ConsoleMain.hh"
/*----------------------------------------------------------------------------*/
/* Owner Interface */
int
com_chown(char* arg1)
{
eos::common::StringTokenizer subtokenizer(arg1);
subtokenizer.GetLine();
XrdOucString owner;
XrdOucString option = "";
XrdOucString in = "mgm.cmd=chown";
XrdOucString arg = "";
bool bypasshelp = false;
while ((owner = subtokenizer.GetToken()).length() && owner.length()) {
if (owner.beginswith("-")) {
XrdOucString loption = owner;
if (loption == "--nodereference") {
loption = "h";
}
loption.erase(0, 1);
option += loption;
bypasshelp = true;
} else {
break;
}
}
XrdOucString path = subtokenizer.GetToken();
if (option.length()) {
in += "&mgm.chown.option=";
in += option;
}
if (!bypasshelp && wants_help(arg1)) {
goto com_chown_usage;
}
if (!path.length() || !owner.length()) {
goto com_chown_usage;
}
path = abspath(path.c_str());
in += "&mgm.path=";
in += path;
in += "&mgm.chown.owner=";
in += owner;
global_retc = output_result(client_command(in));
return (0);
com_chown_usage:
fprintf(stdout,
"Usage: chown [-r] [-h --nodereference] [:] \n");
fprintf(stdout, " chown [-r] : \n");
fprintf(stdout,
"'[eos] chown ..' provides the change owner interface of EOS.\n");
fprintf(stdout,
" is the file/directory to modify, has to be a user id or user name. is optional and has to be a group id or group name.\n");
fprintf(stdout, "To modify only the group use : as identifier!\n");
fprintf(stdout,
"Remark: if you use the -r -h option and path points to a link the owner of the link parent will also be updated!");
fprintf(stdout, "Options:\n");
fprintf(stdout, " -r : recursive\n");
global_retc = EINVAL;
return (0);
}