admin.c revision bdb611d182e5e7e1eca7b08aae735f8e5ac3995b
/**
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2014 - 2015 ForgeRock AS.
*/
#include "platform.h"
#include "am.h"
#include "utility.h"
#include "net_client.h"
#include "list.h"
#include "version.h"
#include "zip.h"
#ifdef _WIN32
#include <shlobj.h>
#define LIB_FILE_EXT "dll"
#define APACHE_DEFAULT_CONF_FILE "c:\\Apache\\conf\\httpd.conf"
#else
#define LIB_FILE_EXT "so"
#define APACHE_DEFAULT_CONF_FILE "/opt/apache/conf/httpd.conf"
#define VARNISH_DEFAULT_VMODS_DIR "/usr/lib64/varnish/vmods"
#endif
#ifdef AM_BINARY_LICENSE
#else
#endif
/* configuration template patterns */
#define AM_INSTALL_OPENAMURL "AM_OPENAM_URL"
#define AM_INSTALL_REALM "AM_AGENT_REALM"
#define AM_INSTALL_AGENTURL "AM_AGENT_URL"
#define AM_INSTALL_AGENT "AM_AGENT_NAME"
#define AM_INSTALL_PASSWORD "AM_AGENT_PASSWORD"
#define AM_INSTALL_KEY "AM_AGENT_KEY"
#define AM_INSTALL_DEBUGPATH "AM_DEBUG_FILE_PATH"
#define AM_INSTALL_AUDITPATH "AM_AUDIT_FILE_PATH"
#define AM_INSTALL_AGENT_FQDN "AM_AGENT_FQDN"
#define AM_INSTALL_CONF_PATH "AM_AGENT_CONF_PATH"
#define AM_INSTALL_PDP_PATH "AM_PDP_TEMP_PATH"
#define AM_INSTALL_SSL_KEY "AM_SSL_KEY"
#define AM_INSTALL_SSL_CERT "AM_SSL_CERT"
#define AM_INSTALL_SSL_CA "AM_SSL_CA"
#define AM_INSTALL_SSL_CIPHERS "AM_SSL_CIPHERS"
#define AM_INSTALL_SSL_OPTIONS "AM_SSL_OPTIONS"
#define AM_INSTALL_SSL_KEY_PASSWORD "AM_SSL_PASSWORD"
typedef void (*param_handler)(int, char **);
struct command_line {
const char* option;
};
struct am_conf_entry {
char name[AM_PATH_SIZE];
char path[AM_PATH_SIZE];
char web[AM_PATH_SIZE];
struct am_conf_entry *next;
};
enum {
AM_I_UNKNOWN = 0,
};
/* forward declarations (IIS specific) */
void list_iis_sites(int, char **);
int enable_module(const char *, const char *);
int disable_module(const char *, const char *);
int test_module(const char *);
int install_module(const char *, const char *);
int remove_module();
static const char *am_container_str(int v) {
switch (v) {
case AM_I_APACHE: return "Apache";
case AM_I_IIS: return "IIS";
case AM_I_VARNISH: return "Varnish";
default: return "Unknown";
}
}
static int instance_type = AM_I_UNKNOWN;
static char app_path[AM_URI_SIZE];
static char log_path[AM_URI_SIZE];
static char log_path_dir[AM_URI_SIZE];
static char license_tracker_path[AM_URI_SIZE];
static char instance_path[AM_URI_SIZE];
static char instance_config[AM_URI_SIZE];
static char config_template[AM_URI_SIZE];
static char instance_config_template[AM_URI_SIZE];
static am_net_options_t net_options;
static const char* agent_4x_obsolete_properties [] =
{
"com.forgerock.agents.nss.shutdown",
"com.sun.identity.agents.config.debug.file",
"com.sun.identity.agents.config.sslcert.dir",
"com.sun.identity.agents.config.certdb.prefix",
"com.sun.identity.agents.config.certdb.password",
"com.sun.identity.agents.config.certificate.alias",
"com.sun.identity.agents.config.tcp.nodelay.enable",
"com.sun.identity.agents.config.forward.proxy.port",
"com.sun.identity.agents.config.forward.proxy.user",
"com.sun.identity.agents.config.forward.proxy.password",
"com.sun.identity.agents.config.profilename",
0
};
static const char *ssl_variables[] = {
};
static void install_log(const char *format, ...) {
char ts[64];
#ifdef _WIN32
#else
#endif
if (f != NULL) {
fprintf(f, "\n");
fclose(f);
}
}
#ifdef _WIN32
static HANDLE cons_handle;
#else
static void exit_handler(int s)
#endif
{
install_log("installation aborted");
#ifdef _WIN32
switch (s) {
case CTRL_BREAK_EVENT:
case CTRL_C_EVENT:
{
ExitProcess(-1);
}
default: break;
}
return TRUE;
#else
exit(1);
#endif
}
static char *prompt_and_read(const char *p) {
char *r;
printf("%s ", p);
#define USER_INPUT_BUFFER_SIZE 256
exit(1);
}
free(r);
return NULL;
}
trim(r, '\n');
trim(r, '\r');
trim(r, ' ');
return r;
}
if (argc == 4) {
}
}
}
if (argc == 4) {
} else {
}
}
}
}
static am_bool_t validate_os_version() {
#ifdef _WIN32
OSVERSIONINFOEXA osvi = {
sizeof (osvi), 0, 0, 0, 0, { 0 }, 0, 0
};
osvi.wServicePackMajor = 0;
return VerifyVersionInfoA(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, mask) != FALSE;
#else
return AM_TRUE;
#endif
}
static const char *server_version =
#ifdef SERVER_VERSION
#else
"";
#endif
}
int ret = 0;
continue;
}
AM_LIST_INSERT(*list, e);
ret++;
}
}
} else {
ret = AM_FILE_ERROR;
}
return ret;
}
char key[AM_PATH_SIZE];
return AM_ENOMEM;
}
/* configuration line begins with an instance name followed by a space */
}
}
} else {
ret = AM_FILE_ERROR;
}
}
} else {
ret = AM_FILE_ERROR;
}
}
return ret;
}
const char** p;
for (p = agent_4x_obsolete_properties; *p; p++) {
if (property_map_remove_key(property_map, *p)) {
install_log("removing obsolete property %s", *p);
}
}
}
/**
* @param status For IIS
* @param web_conf_path The path of the conf.d file (in the case of Apache)
* @param openam_url The URL of OpenAM
* @param agent_realm The realm of the agent
* @param agent_url The URL of the agent
* @param agent_user The user the agent runs as
* @param agent_password The password of the agent
* @param uid The uid of the user specified by "User" in the conf.d file in the case of Apache
* @param gid The gid of the group specified by "Group" in the conf.d file in the case of Apache
*/
static int create_agent_instance(int status,
const char* web_conf_path,
const char* openam_url,
const char* agent_realm,
const char* agent_url,
const char* agent_user,
const char* agent_password,
char* created_name_path = NULL;
char* created_name_simple = NULL;
char* agent_conf_template = NULL;
char* agent_conf_content = NULL;
size_t agent_conf_sz = 0;
install_log("failed to create agent instance configuration directories");
return rv;
}
install_log("agent instance configuration directories created");
/* create agent configuration file (from a template) */
if (agent_conf_template != NULL) {
char* audit_log_path = NULL;
char* conf_file_path = NULL;
rv = AM_SUCCESS;
am_asprintf(&conf_file_path, "%s"FILE_PATH_SEP"config"FILE_PATH_SEP"agent.conf", created_name_path);
am_asprintf(&log_path, "%s"FILE_PATH_SEP"logs"FILE_PATH_SEP"debug"FILE_PATH_SEP, created_name_path);
am_asprintf(&audit_log_path, "%s"FILE_PATH_SEP"logs"FILE_PATH_SEP"audit"FILE_PATH_SEP, created_name_path);
do {
struct url u;
char* encoded;
char* password;
char* tmp;
char key[37];
install_log("log_path, audit_log_path or conf_file_path is NULL");
break;
}
/* do a search-n-replace (in memory) */
rv = string_replace(&agent_conf_template, AM_INSTALL_OPENAMURL, openam_url, &agent_conf_template_sz);
if (rv != AM_SUCCESS) {
break;
}
if (rv != AM_SUCCESS) {
break;
}
if (rv != AM_SUCCESS) {
break;
}
if (rv != AM_SUCCESS) {
break;
}
if (rv != AM_SUCCESS) {
break;
}
if (rv != AM_SUCCESS) {
break;
}
if (rv != AM_SUCCESS) {
break;
}
break;
}
if (rv != AM_SUCCESS) {
}
}
if (rv != AM_SUCCESS) {
break;
}
if (rv != AM_SUCCESS) {
break;
}
rv = string_replace(&agent_conf_template, AM_INSTALL_AUDITPATH, audit_log_path, &agent_conf_template_sz);
if (rv != AM_SUCCESS) {
install_log("failed to update agent configuration template file %s (%s)",
break;
}
rv = string_replace(&agent_conf_template, AM_INSTALL_PDP_PATH, log_path_dir, &agent_conf_template_sz);
if (rv != AM_SUCCESS) {
break;
}
} else {
tmp = AM_SPACE_CHAR;
}
if (rv != AM_SUCCESS) {
break;
}
} else {
tmp = AM_SPACE_CHAR;
}
if (rv != AM_SUCCESS) {
break;
}
} else {
tmp = AM_SPACE_CHAR;
}
if (rv != AM_SUCCESS) {
break;
}
} else {
tmp = AM_SPACE_CHAR;
}
if (rv != AM_SUCCESS) {
break;
}
} else {
tmp = AM_SPACE_CHAR;
}
if (rv != AM_SUCCESS) {
break;
}
break;
}
rv = string_replace(&agent_conf_template, AM_INSTALL_SSL_KEY_PASSWORD, password, &agent_conf_template_sz);
if (rv != AM_SUCCESS) {
}
}
if (rv != AM_SUCCESS) {
break;
}
} else {
rv = string_replace(&agent_conf_template, AM_INSTALL_SSL_KEY_PASSWORD, AM_SPACE_CHAR, &agent_conf_template_sz);
if (rv != AM_SUCCESS) {
break;
}
}
/* remove obsolete properties */
/* add updated template to the property map */
property_map_parse(property_map, "agent 4.0 config", AM_FALSE, install_log, agent_conf_template, agent_conf_template_sz);
/* generate file content from resulting map */
if (!ISVALID(agent_conf_content)) {
install_log("failed to build agent configuration file content %s (%s)");
break;
}
/* write an updated template to the agent configuration file */
#ifndef _WIN32
/* update agent instance configuration file owner */
install_log("failed to change file %s owner to %d:%d (error: %d)",
}
/* update global log folder owner */
install_log("failed to change directory %s owner to %d:%d (error: %d)",
}
}
#endif
rv = AM_SUCCESS;
} else {
rv = AM_FILE_ERROR;
}
} while (0);
} else {
}
if (rv == AM_SUCCESS) {
/* update installer (instance) configuration */
if (f != NULL) {
fclose(f);
install_log("agent instance configuration updated");
} else {
rv = AM_FILE_ERROR;
}
}
/* container specific updates */
switch (instance_type) {
case AM_I_APACHE: {
/* update Apache httpd.conf (global context only) */
if (f != NULL) {
fprintf(f, "\n\nLoadModule amagent_module %s.."FILE_PATH_SEP"lib"FILE_PATH_SEP"mod_openam."LIB_FILE_EXT"\n"
"AmAgent On\n"
fclose(f);
}
} else {
rv = AM_FILE_ERROR;
}
break;
}
case AM_I_IIS: {
char schema_file[AM_URI_SIZE];
char lib_file[AM_URI_SIZE];
app_path);
app_path);
/* need to add module to global configuration first */
} else {
install_log("webserver site global configuration updated");
}
} else {
}
if (rv == AM_SUCCESS) {
}
if (rv == AM_SUCCESS) {
char iis_instc_file[AM_URI_SIZE];
/* module is already loaded in global configuration */
} else {
}
}
break;
}
case AM_I_VARNISH: {
#ifndef _WIN32
if (rv == AM_SUCCESS) {
char vmod_path[AM_URI_SIZE];
char instance_type_mod[AM_URI_SIZE];
char instance_conf_file[AM_URI_SIZE];
/* cleanup existing vmods directory */
}
/* add agent (softlink) to vmods directory */
if (rv == 0) {
} else {
}
if (rv == AM_SUCCESS) {
size_t vcl_template_sz = 0;
/* load instance vcl template */
if (vcl_template != NULL) {
/* update instance vcl template */
if (rv != AM_SUCCESS) {
install_log("failed to update instance vcl template %s (error: %s)",
} else {
char vcl_file[AM_URI_SIZE];
/* save instance vcl template to a file */
rv = AM_SUCCESS;
} else {
}
}
}
}
}
#else
install_log("unsupported platform");
#endif
break;
}
default: {
break;
}
}
/* delete agent configuration directory in case of an error */
if (rv != AM_SUCCESS) {
}
return rv;
}
/**
* Check if the user wants to quit and if so, let them quit.
*/
static void check_if_quit_wanted(char* input) {
install_log("installation exit because user typed \"q\" for input");
exit(1);
}
}
} else {
}
return valid_response;
}
/**
* Get confirmation of a property setting
*/
do {
if (!valid_response) {
printf("Please answer yes or no\n");
}
} while (!valid_response);
return response;
}
/**
* Find the word after the specified text in the httpd conf file, read it into
* buff and null terminate it.
*
* @param httpd_conf_file The entire contents of the conf file, read into a string.
* @param target The word we're looking for.
* @param buff The buffer we're writing into.
* @param size Number of bytes available in buff.
*/
size_t i = 0;
/* Skip initial spacing */
user++;
}
/* read into buffer, until space, newline or comment */
}
}
buff[i] = '\0';
}
/**
* Find the line saying:
*
* User daemon
*
* (or whatever) in the httpd conf file and return the user id and group id information
* corresponding to the user specified (if valid). Note that httpd allows the user to be
* specified as an integer.
*
* @param httpd_conf_file The entirety of the conf file, copied into a null terminated buffer
* @param uid change where pointer points to NULL if not found, or to dynamic memory if found
* @param gid change where pointer points to NULL if not found, or dynamic memory if found
*/
#ifndef _WIN32
char *p;
char buff[AM_PATH_SIZE];
struct passwd *password_entry;
if (*buff == '\0') {
return;
}
/* does the buffer contain a number */
for (p = buff; *p != '\0'; p++) {
if (!isdigit(*p)) {
break;
}
}
if (is_numeric) {
} else {
}
if (password_entry == NULL) {
return;
}
return;
}
return;
}
#endif /* _WIN32 */
}
/**
* Find the line saying:
*
* Group daemon
*
* (or whatever) in the httpd conf file and return the group id information.
*
* @param httpd_conf_file The entirety of the conf file, copied into a null terminated buffer
* @param pointer to gid_t pointer which will change if the user is found and valid
*/
#ifdef _WIN32
}
#else
char *p;
char buff[AM_PATH_SIZE];
struct group *group_entry;
if (*buff == '\0') {
install_log("Unable to find the \"Group\" entry in the httpd.conf file");
return;
}
/* does the buffer contain a number */
for (p = buff; *p != '\0'; p++) {
if (!isdigit(*p)) {
break;
}
}
if (!is_numeric) {
} else {
}
if (group_entry == NULL) {
return;
}
return;
}
**gid = 0;
}
if (**gid == 0) {
}
#endif /* _WIN32 */
}
/****************************************************************************************************************/
int rv;
int iis_status = 0;
char* agent_token = NULL;
char lic_file_path[AM_URI_SIZE];
char server_conf[AM_URI_SIZE];
char* openam_url = NULL;
char* agent_realm = NULL;
char* agent_user = NULL;
char* agent_password = NULL;
char* agent_password_source = NULL;
/* set up console signal handler */
#ifdef _WIN32
if (cons_handle == INVALID_HANDLE_VALUE) {
return;
}
return;
}
return;
}
#else
#endif
if (!file_exists(license_tracker_path)) {
/* display a license */
}
install_log("license accepted");
}
} else {
install_log("license was accepted earlier");
}
if (!lic_accepted) {
install_log("license was not accepted");
exit(1);
}
do {
switch (instance_type) {
case AM_I_APACHE: {
/* Apache HTTP Server specific */
input = prompt_and_read("\nEnter the complete path to the httpd.conf file which is used by Apache HTTP\n"
"Server to store its configuration.\n"
"[ q or 'ctrl+c' to exit ]\n"
install_log("installation exit (memory allocation error)");
exit(1);
}
}
if (strstr(conf, "LoadModule amagent_module") != NULL && strstr(conf, "#LoadModule amagent_module") == NULL) {
fprintf(stdout, "\nError: this server instance is already configured with %s module.\nPlease try again.\n\n", DESCRIPTION);
install_log("server instance %s is already configured with %s",
input, DESCRIPTION);
input);
} else {
}
} else {
input);
}
#ifdef _WIN32
#else
/**
* If not running as root, we cannot offer to chown directories.
*/
if (getuid() != 0) {
}
/**
* If we have a uid and gid by this stage, actually ask the user if they want us to chown the
* directories we create. This saves a lot of guesswork looking at "Listen" values in the
* httpd.conf file.
*/
input = prompt_and_read("\nChange ownership of created directories using User and Group settings in httpd.conf\n"
"[ q or 'ctrl+c' to exit ]\n"
}
}
#endif
break; /* avoid fall through into IIS */
}
case AM_I_IIS: {
iis_status = 0;
/* IIS specific */
"[ q or 'ctrl+c' to exit ]\n"
"Site id:");
install_log("installation exit");
exit(1);
}
if (iis_status == ADMIN_IIS_MOD_LOCAL) {
fprintf(stdout, "\nError: this server site is already configured with %s module.\nPlease try again.\n\n", DESCRIPTION);
} else {
install_log("IIS server site %s is not yet configured with %s (status: %d)",
}
break; /* avoid fall through into varnish */
}
case AM_I_VARNISH: {
#ifndef _WIN32
"[ q or 'ctrl+c' to exit ]\n"
install_log("installation exit (memory allocation error)");
exit(1);
}
}
if (file_exists(input)) {
} else {
input);
}
break;
#endif
}
default: {
install_log("unknown installation type");
exit(1);
}
}
am_net_init();
do {
if (property_map == NULL) {
install_log("unable to allocate property map");
break;
}
/*
* Get values parameters from existing configuration
*/
do {
char *data;
"[ q or 'ctrl+c' to exit, return to ignore ]\n"
"Existing OpenSSOAgentBootstrap.properties file:");
break;
}
if (data) {
}
if (data) {
char* v;
/*
* get installer parameters from exiting configuration
*/
/* update naming service URLs */
/* we are going to tokenise the property value v in situ, then replace it with dst */
const char* s, * e;
char* brkt;
int c = 0;
install_log("unable to allocate memory for naming URL list");
break;
}
/* reset any user input */
if (c) {
}
if (e == NULL) {
e = s + strlen(s);
}
ofs += e - s;
if (c++ == 0) {
}
}
/* replace the tokenized value with the modified result */
if (*addr) {
}
}
/* agent url */
if ( (v = property_map_get_value(property_map, "com.sun.identity.agents.config.agenturi.prefix")) ) {
char* e;
if ( (e = strstr(v, "/amagent")) ) {
} else {
}
}
/* realm */
if ( (v = property_map_get_value(property_map, "com.sun.identity.agents.config.organization.name")) ) {
agent_realm = strdup(v);
}
/* user */
agent_user = strdup(v);
}
/* password cannot be preserved because the cypher is not compatible */
break;
}
} while (1);
/**
* Get the URL of OpenAM and try to verify it.
*/
do {
int httpcode = 0;
struct url parsed_url;
} else {
/* user answered "Yes" - will use openam_url value entered earlier, which might also mean
* that user wants to continue despite the fact that OpenAM is not accessible */
break;
}
}
while (!ISVALID(openam_url)) {
"deployment URI also as shown below:\n"
"[ q or 'ctrl+c' to exit ]\n"
"OpenAM server URL:");
}
}
/* ensure that the OpenAM URL is syntactically valid */
/* should be able to connect to OpenAM server during installation */
} else if (am_url_validate(0, openam_url, &net_options, &httpcode) == AM_SUCCESS && httpcode != 0) {
break;
} else {
fprintf(stdout, "\nCannot connect to OpenAM at URI %s, please make sure OpenAM is started\n", openam_url);
}
if (upgrade) {
while (!get_yes_or_no("\nPlease make sure OpenAM is started and the OpenAM URL is correct.\n"
"Continue upgrade (Yes/No, q to quit) [Yes]: ", &continue_upgrade)) {
printf("Please answer yes or no\n");
}
if (!continue_upgrade) {
install_log("installation exit because OpenAM is not running");
exit(1);
}
}
} while (1);
/**
* Get the URL of the Agent and try to verify it is not running (if it is an Apache agent).
*/
do {
struct url parsed_url;
int httpcode = 0;
}
}
"[ q or 'ctrl+c' to exit ]\n"
"Agent URL:");
}
}
/* ensure the URL is syntactically valid */
continue;
}
/* only Apache needs to be shut down before installation */
if (instance_type != AM_I_APACHE) {
break;
}
/* hopefully we cannot contact because the agent is not running,
* rather than because the URI is complete rubbish
*/
break;
}
if (upgrade) {
/* we must suspend the installation until the agent is shut down */
while (!get_yes_or_no("\nPlease shut down the Apache HTTP Server to continue upgrade.\n"
"Continue upgrade (Yes/No, q to quit) [Yes]: ", &continue_upgrade)) {
printf("Please answer yes or no\n");
}
if (!continue_upgrade) {
install_log("installation exit because apache is running");
exit(1);
}
}
} while (1);
/**
* The agent profile name. There is no way to verify this, unless we can contact OpenAM,
* and we haven't connected in a meaningful way yet.
*/
}
}
if (!ISVALID(agent_user)) {
"[ q or 'ctrl+c' to exit ]\n"
"Agent Profile name:");
}
}
/**
* The realm. Again no way to verify without connecting to OpenAM.
*/
}
}
if (!ISVALID(agent_realm)) {
"[ q or 'ctrl+c' to exit ]\n"
"Agent realm/organization name: [/]:");
} else {
}
}
/**
* Prompt for the file containing the agent password. This we can verify -
* the file must exist, and be readable.
*/
if (ISVALID(agent_password_source)) {
}
}
while (!ISVALID(agent_password_source)) {
"for identifying the Agent\n"
"[ q or 'ctrl+c' to exit ]\n"
"The path to the password file:");
if (password_data != NULL) {
} else {
}
}
}
" OpenAM URL: %s\n"
" Agent URL: %s\n"
" Agent Profile name: %s\n"
" Agent realm/organization name: %s\n"
" Agent Profile password source: %s\n\n",
} else {
install_log("installation restarted");
}
} while (outer_loop == AM_TRUE);
if (am_validation_skipped) {
install_log("configuration parameter validation skipped");
} else {
install_log("validating configuration parameters...");
if (rv != AM_SUCCESS) {
"See installation log %s file for more details. Exiting.\n", log_path);
install_log("error validating OpenAM agent configuration");
} else {
install_log("validating configuration parameters... success");
}
if (agent_token != NULL) {
agent_token = NULL;
}
}
if (validated) {
/* create agent instance and modify the server configuration */
} else {
}
if (rv == AM_SUCCESS) {
install_log("installation complete");
} else {
"See installation log %s file for more details. Exiting.\n", log_path);
}
} else {
"See installation log %s file for more details. Exiting.\n", log_path);
install_log("installation error");
}
if (property_map) {
}
#ifdef _WIN32
#endif
install_log("installation exit");
}
/*******************************************************************************************************************/
/**
* The important thing to know about the way this function works is that the arguments are:
*
* argv[1] == --s
* argv[2] = Apache: path to httpd.conf file; IIS: SiteId; Varnish: path to VMODS directory
* argv[3] = OpenAM URL
* argv[4] = Agent URL
* argv[5] = Realm
* argv[6] = Agent name
* argv[7] = File containing the agent password
* argv[8] = OPTIONAL "--changeOwner" argument saying whether to change instance directory/file ownership data
* argv[9] = OPTIONAL "--acceptLicence" argument
* argv[10] = OPTIONAL "--forceInstall" argument.
*/
char lic_file_path[AM_URI_SIZE];
install_log("license accepted with --acceptLicence option");
}
install_log("installer run with --forceInstall option");
}
if (!file_exists(license_tracker_path)) {
/* display a license */
}
install_log("license accepted");
}
} else {
install_log("license was accepted earlier");
}
if (!lic_accepted) {
install_log("license was not accepted");
exit(1);
}
if (argc >= 8) {
char *agent_token = NULL;
char *agent_password;
char *conf;
if (instance_type == AM_I_APACHE) {
} else {
exit(1);
}
#if !defined(_WIN32)
/**
* If not running as root, we cannot offer to chown directories.
*/
if (getuid() != 0) {
}
#endif
}
}
if (agent_password == NULL) {
install_log("installation exit");
exit(1);
}
am_net_init();
if (am_validation_skipped) {
install_log("configuration parameter validation skipped");
} else {
install_log("validating configuration parameters...");
if (rv != AM_SUCCESS) {
install_log("error validating OpenAM agent configuration");
} else {
install_log("validating configuration parameters... success");
}
if (agent_token != NULL) {
agent_token = NULL;
}
}
if (validated) {
} else {
}
if (rv == AM_SUCCESS) {
install_log("installation complete");
} else {
"See installation log %s file for more details. Exiting.\n", log_path);
}
if (property_map != NULL) {
}
} else {
"See installation log %s file for more details. Exiting.\n", log_path);
install_log("installation error");
}
} else {
}
install_log("installation exit");
}
struct am_conf_entry *t = *list;
if (t != NULL) {
delete_conf_entry_list(&t->next);
free(t);
t = NULL;
}
}
if (rv <= 0) {
return;
}
AM_LIST_FOR_EACH(list, e, t) {
" id: %s\n"
" configuration: %s\n"
}
}
int rv;
char prompt[AM_PATH_SIZE];
if (argc != 3) {
return;
}
if (rv <= 0) {
return;
}
rv = AM_NOT_FOUND;
AM_LIST_FOR_EACH(list, e, t) {
switch (instance_type) {
case AM_I_APACHE:
{
char *input = prompt_and_read("\nWarning! This procedure will remove all "DESCRIPTION" references from \nWeb server configuration."
" In case you are running "DESCRIPTION" in a\nmulti-virtualhost mode, an uninstallation must be carried out manually.\n\nContinue (yes/no): [no]:");
rv = AM_SUCCESS;
break;
}
/* remove LoadModule line */
/* remove AmAgentConf line */
/* remove AmAgentId line */
/* delete agent instance configuration directory */
am_delete_directory(e->path);
/* remove agent instance configuration */
break;
}
case AM_I_IIS:
{
char iis_instc_file[AM_URI_SIZE];
snprintf(prompt, sizeof (prompt), "\nWarning! This procedure will remove %s configuration from IIS Site %s."
rv = AM_SUCCESS;
break;
}
e->path);
/* remove IIS module in the site (global module configuration remains) */
/* delete agent instance configuration directory */
am_delete_directory(e->path);
/* remove agent instance configuration */
break;
}
case AM_I_VARNISH:
{
char vmod_path[AM_URI_SIZE];
char *input = prompt_and_read("\nWarning! This procedure will remove all "DESCRIPTION" references from \nWeb server configuration."
rv = AM_SUCCESS;
break;
}
/* delete agent instance configuration directory */
am_delete_directory(e->path);
/* remove agent instance configuration */
break;
}
}
}
}
if (rv == AM_NOT_FOUND) {
}
}
int rv;
char *input = prompt_and_read("\nWarning! This procedure will remove all "DESCRIPTION" references from \nIIS Server configuration."
return;
}
if (rv > 0) {
AM_LIST_FOR_EACH(list, e, t) {
char iis_instc_file[AM_URI_SIZE];
e->path);
/* disable agent module in the Site */
/* delete agent instance configuration directory */
am_delete_directory(e->path);
/* remove agent instance configuration */
}
}
}
}
int rv;
if (argc != 3) {
return;
}
if (rv <= 0) {
return;
}
AM_LIST_FOR_EACH(list, e, t) {
if (instance_type == AM_I_IIS) {
char iis_instc_file[AM_URI_SIZE];
e->path);
}
}
}
}
int rv;
if (argc == 3) {
return;
}
if (rv <= 0) {
return;
}
AM_LIST_FOR_EACH(list, e, t) {
if (instance_type == AM_I_IIS) {
char iis_instc_file[AM_URI_SIZE];
e->path);
}
}
}
}
int i;
if (argc < 4) return;
return;
}
for (i = 3; i < argc; i++) {
}
}
AM_LIST_FOR_EACH(all, e, t) {
/* fix path prefixes */
if (e->n[0] == '/') {
off = 1;
}
#ifdef _WIN32
{
char fname[AM_URI_SIZE];
char dir[AM_URI_SIZE];
char drive[AM_PATH_SIZE];
char ext[AM_PATH_SIZE];
if (_splitpath_s(e->n,
continue;
}
if (dir[0] == '\\') {
off = 1;
}
off = 2;
}
}
#endif
#ifndef _WIN32
if (e->ns == 1) {
/* a directory */
} else {
/* a file */
} else {
}
}
#endif
if (e->ns == 1) {
/* a directory */
} else {
/* a file */
if (f != NULL) {
int rb;
unsigned char b[1024];
while (!feof(f)) {
}
fclose(f);
}
}
}
}
int rv;
if (argc == 4) {
}
}
int i;
char tm[64];
char instance_type_mod[AM_URI_SIZE];
struct command_line params[] = {
{ "--i", install_interactive },
{ "--s", install_silent },
{ "--l", list_instances },
{ "--r", remove_instance },
#ifdef _WIN32
{ "--n", list_iis_sites },
{ "--g", remove_global },
{ "--e", enable_iis_mod },
{ "--d", disable_iis_mod },
{ "--o", modify_ownership },
#endif
{ "--v", show_version },
{ "--k", generate_key },
{ "--p", password_encrypt },
{ "--d", password_decrypt },
{ "--a", archive_files },
{ NULL }
};
if (!validate_os_version()) {
#ifdef _WIN32
DESCRIPTION" supports Microsoft Windows 2008R2 or newer.\n\n");
#endif
exit(1);
}
#ifdef _WIN32
&& !IsUserAnAdmin()) {
exit(1);
}
#endif
if (argc > 1) {
/* get agentadmin path */
}
/* instances directory */
app_path);
/* agent configuration template */
app_path);
/* instances configuration file (internal) */
app_path);
/* and add a license tracker path */
app_path);
/* determine installer type */
if (file_exists(instance_type_mod)) {
}
if (file_exists(instance_type_mod)) {
}
if (file_exists(instance_type_mod)) {
app_path);
}
/* read environment variables and create am_net_options */
for (i = 0; i < ARRAY_SIZE(ssl_variables); i++) {
}
}
}
}
}
}
}
}
}
/* run through the cli options */
return 0;
}
}
}
"Usage: agentadmin <option> [<arguments>]\n\n"
"The available options are:\n\n"
"Install agent instance (interactive):\n"
" agentadmin --i\n\n"
"Install agent instance (silent):\n"
" agentadmin --s \"web-server configuration file, directory or site parameter\" \\\n"
" \"OpenAM URL\" \"Agent URL\" \"realm\" \"agent user id\" \\\n"
" \"path to the agent password file\" [--changeOwner] [--acceptLicence] [--forceInstall]\n\n"
"List configured agent instances:\n"
" agentadmin --l\n\n"
#ifdef _WIN32
"List IIS Server Sites:\n"
" agentadmin --n\n\n"
"Remove agent module from IIS Server:\n"
" agentadmin --g\n\n"
"Enable agent module in IIS Server site:\n"
" agentadmin --e agent_1\n\n"
"Disable agent module in IIS Server site:\n"
" agentadmin --d agent_1\n\n"
"Modify Access Control Lists (ACLs) for files and folders:\n"
" agentadmin --o \"IIS APPPOOL\\AgentSite\" \"C:\\web_agents\\iis_agent\\instances\"\n\n"
#endif
"Uninstall agent instance:\n"
" agentadmin --r agent_1\n\n"
"Generate encryption key:\n"
" agentadmin --k\n\n"
"Encrypt password:\n"
" agentadmin --p \"key\" \"password\"\n\n"
"Archive directories/files:\n"
" agentadmin --a archive.zip directory_or_file [directory_or_file]\n\n"
"Build and version information:\n"
" agentadmin --v\n\n", DESCRIPTION);
return 0;
}