blob: 18bb86ac223f6ce042f3bb4301a57ae37768dc8d [file] [log] [blame]
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <pwd.h>
#include <assert.h>
#include <getopt.h>
#include <grp.h>
/*
* List of possible error codes.
*/
enum errorcodes {
INVALID_ARGUMENT_NUMER = 1,
INVALID_USER_NAME, //2
SUPER_USER_NOT_ALLOWED_TO_RUN_COMMANDS, //3
INITGROUPS_FAILED, //4
SETUID_OPER_FAILED, //5
INVALID_COMMAND_PASSED, //6
};
#undef HADOOP_HOME
#define SSH_COMMAND "ssh"
#define SCRIPT_DIR_PATTERN "%s/bin/hadoop-daemon.sh %s" //%s to be substituded
#define STRLEN strlen(SCRIPT_DIR_PATTERN) + strlen(HADOOP_HOME)
/*
* Function to get the user details populated given a user name.
*/
int getuserdetails(char *user, struct passwd *user_detail);
/*
* Process cluster controller command the API exposed to the
* main in order to execute the cluster commands.
*/
int process_controller_command(char *user, char *node, char *command);