Skip to content
Snippets Groups Projects
Commit 20c59d22 authored by Eric Cano's avatar Eric Cano
Browse files

Added a command line utility allowing bootstrapping of admin users.

parent 369c71f9
No related branches found
No related tags found
No related merge requests found
......@@ -6,3 +6,11 @@ include_directories (${XROOTD_INCLUDE_DIR} ${XROOTD_PRIVATE_INCLUDE_DIR} ${CMAKE
add_executable (cta CTACmdMain.cpp CTACmd.cpp)
target_link_libraries (cta ${XROOTD_XRDCL_LIB} ctacommon cryptopp)
include_directories (${CMAKE_SOURCE_DIR}/tapeserver/)
add_executable (ctaAddAdminUser CTAAddAdminUser.cpp )
target_link_libraries (ctaAddAdminUser castorcommon castorserver castorlog
CTAObjectStore ctaOStoreSchedulerDB ctacommon castorutils protobuf ctascheduler
ctanameserver)
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 CERN
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include <exception>
#include "objectstore/BackendVFS.hpp"
#include "tapeserver/castor/common/CastorConfiguration.hpp"
#include "tapeserver/castor/log/DummyLogger.hpp"
#include "scheduler/OStoreDB/OStoreDB.hpp"
#include "common/SecurityIdentity.hpp"
#include <iostream>
int main(int argc, char ** argv) {
try{
if (argc != 3)
throw std::runtime_error("In ctaAddAdminUser: expected 2 arguments (uid, gid)");
uid_t uid = atol(argv[1]);
gid_t gid = atol(argv[2]);
castor::common::CastorConfiguration &castorConf =
castor::common::CastorConfiguration::getConfig();
castor::log::DummyLogger log("ctaAddAdminUser");
cta::objectstore::BackendVFS be(castorConf.getConfEntString("TapeServer", "ObjectStoreBackendPath", &log));
be.noDeleteOnExit();
cta::OStoreDB db(be);
db.createAdminUser(cta::SecurityIdentity(cta::UserIdentity(getuid(), getgid()),
castor::utils::getHostName()),
cta::UserIdentity(uid, gid), "");
} catch (std::exception & e) {
std::cerr << "In ctaAddAdminUser: got an exception: " << e.what() << std::endl;
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment