mm_mmp_sql.c revision d1d2228c6cf3ec632d28262810ab7902932a5d33
/*
* CDDL HEADER START
*
* 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 usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <pthread.h>
#include <syslog.h>
#include <unistd.h>
#include <libscf.h>
#include <mms_list.h>
#include <mms_parser.h>
#include <mms_par_impl.h>
#include <libpq-fe.h>
#include <mms_trace.h>
#include <mms_strapp.h>
#include "mm_db.h"
#include "mm.h"
#include "mm_util.h"
#include "mm_commands.h"
#include "mm_sql.h"
#include "mm_sql_impl.h"
#include "mm_task.h"
#include "mm_path.h"
#include "mms_sock.h"
#include "net_cfg_service.h"
#include "mms_cfg.h"
#include "mms_cat.h"
/*
* Macros with a %s that create a function
* need to be dropped before each use
*/
/* Need to drop GET_TYPE_SQL */
#define GET_TYPE_SQL "CREATE FUNCTION gettype() RETURNS " \
"SETOF \"%s\" AS $$ SELECT * FROM \"%s\" %s; " \
"$$ LANGUAGE SQL;"
#define GET_ID_SQL "select distinct \"CartridgeID\" " \
"from getcart() where \"CartridgeGroupName\" in " \
"(select distinct \"CartridgeGroupName\" " \
"from \"CARTRIDGEGROUPAPPLICATION\" " \
"where \"ApplicationName\" = '%s');"
#define SELECT_CAP_GROUP "select distinct " \
"\"DMCapabilityGroupName\" from " \
"\"DMCAPABILITYGROUPTOKEN\" where " \
"\"DriveName\" = '%s';"
#define SELECT_CAP_TOK "select \"DMCapabilityToken\" " \
"from \"DMCAPABILITYGROUPTOKEN\" where " \
"\"DMCapabilityGroupName\" = '%s' and " \
"\"DriveName\" = '%s' and \"DMCapabilityToken\" = '%s' " \
"and \"DMName\" " \
"in (select \"DMName\" from \"DM\" " \
"where pg_host_ident(\"DMTargetHost\") = pg_host_ident('%s'));"
#define SELECT_DEFAULT_TOK "select \"DMCapabilityGroupDefaultName\" " \
"from \"DMCAPABILITYGROUP\" " \
"where \"DriveName\" = '%s' " \
"and \"DMCapabilityGroupName\" = '%s';"
int match_off);
extern int mm_exiting;
void
char *text;
return;
}
return;
}
int
if (type == 1) {
/* activate enable */
} else if (type == 2) {
/* activate disable */
} else {
return (1);
}
"Unable to malloc mm_command_t: %s",
return (1);
}
return (1);
}
if (type == 1) {
/* activate enable */
"in add cmd");
return (1);
}
} else if (type == 2) {
/* activate disable */
"in add cmd");
return (1);
}
}
return (0);
}
int
{
int print_message = 1;
int rc;
int online = 0;
int offline = 0;
int lib_broken = 0;
char *response_message = NULL;
int found = 0;
/* An activate command has completed */
/* Check for errors */
"msg_rsp", response_message,
NULL);
rc = MM_CMD_ERROR;
goto end;
}
/* The sql command should still be cmd->cmd_buf */
/* send it to the data base */
goto db_error;
}
/* Send Success */
rc = MM_CMD_DONE;
goto end;
}
/* Online clause */
MMS_PN_CLAUSE, &work);
if (print_message)
/* Get Library Name */
if ((value =
/* Missing a Library Name */
goto not_found;
} else {
/* Have a library Name */
online = 1;
if (print_message)
}
/* Try to get LMName */
if ((value =
/* Should never hit here... */
/* Missing a LM Name */
goto not_found;
} else {
/* Have a lm Name */
if (print_message)
}
} else {
/* Didn't find a online clause */
if (print_message)
}
/* Offline clause */
MMS_PN_CLAUSE, &work);
if (print_message)
/* Get Drive Name */
if ((value =
goto not_found;
} else {
/* Have the library name */
offline = 1;
if (print_message)
}
} else {
/* Didn't find a offline clause */
if (print_message)
}
/* Shouldn't ever get here */
"online and offline clause");
/* ECLASS_LANGUAGE, ELIBRARYNOEXIST */
NULL);
/* Create new error codes */
rc = MM_CMD_ERROR;
goto not_found;
}
/* Check Priv, library ownership */
/* Check if library exists */
/* Determine if the library is broken or not */
"select \"LibraryName\",\"LibraryBroken\" "
"from \"LIBRARY\" where "
"\"LibraryName\" = '%s';",
lib_name) != MM_DB_DATA) {
goto db_error;
} else {
/* No library exists */
/* ECLASS_EXIST, ELIBRARYNOEXIST */
NULL);
/* Create new error codes */
rc = MM_CMD_ERROR;
goto end;
} else {
0, 1), "t") == 0) {
lib_name);
lib_broken = 1;
}
}
}
if (online) {
/* If library is broken, error */
if (lib_broken) {
/* Library is broken */
"ELIBBROKEN",
NULL);
/* Create new error codes */
rc = MM_CMD_ERROR;
goto end;
}
/* Is the library already online */
"select \"LibraryName\" "
"from \"LIBRARY\" where "
"\"LibraryName\" = '%s'"
"and \"LibraryOnline\" = 'true';",
lib_name) != MM_DB_DATA) {
goto db_error;
} else {
/* Library already online */
/* ECLASS_PREMPRIV, ELIBALREADYONLINE */
"ELIBALREADYONLINE",
"lib",
NULL);
/* Create new error codes */
rc = MM_CMD_ERROR;
goto end;
}
}
/* Check if LM exists */
"select \"LMName\" "
"from \"LM\" where "
"\"LMName\" = '%s';",
lm_name) != MM_DB_DATA) {
goto db_error;
} else {
/* No lm exists */
/* ECLASS_EXIST, ELMNOEXIST */
NULL);
/* Create new error codes */
rc = MM_CMD_ERROR;
goto end;
}
}
/* Do online specific checks */
/* Do online */
"update \"LIBRARY\" set "
"\"LMName\" = '%s', "
"\"LibraryOnline\" = 'true', "
"\"LibraryDisabled\" = 'false', "
"\"LibraryBroken\" = 'f' "
"where \"LibraryName\" = '%s';",
lib_name);
} else if (offline) {
/* Do offline specific checks */
/* Is the library already offline */
"select \"LibraryName\" "
"from \"LIBRARY\" where "
"\"LibraryName\" = '%s'"
"and \"LibraryOnline\" = 'false';",
lib_name) != MM_DB_DATA) {
goto db_error;
} else {
/* Library already offline */
/* ECLASS_PREMPRIV, ELIBALREADYOFFLINE */
"ELIBALREADYOFFLINE",
"lib",
NULL);
/* Create new error codes */
rc = MM_CMD_ERROR;
goto end;
}
}
/* Find the controlling LM's name */
"select \"LMName\" "
"from \"LIBRARY\" where "
"\"LibraryName\" = '%s';",
lib_name) != MM_DB_DATA) {
goto db_error;
} else {
lm_name =
0, 0));
}
/* Do offline */
"update \"LIBRARY\" set "
"\"LMName\" = NULL, "
"\"LibraryOnline\" = 'false', "
"\"LibraryBroken\" = 'false' "
"where \"LibraryName\" = '%s';",
lib_name);
/* Update states */
" delete from \"SLOT\" where"
"\"LMName\" = '%s'; "
" delete from \"BAY\" where"
"\"LMName\" = '%s'; "
" delete from \"SLOTGROUP\" where"
"\"LMName\" = '%s'; "
"update \"DRIVE\" "
"set \"BayName\" = DEFAULT "
"where \"LibraryName\" = '%s';",
lib_name);
} else {
/* Shouldn't ever get here */
goto not_found;
}
/* Send cmd_buf to data base */
if (print_message)
cmd_buf);
/* if no lm is connected, return success */
lib_name) == 0) &&
lm_name) == 0)) {
found = 1;
break;
}
}
/* If this is an offline and the library is broken */
/* skip the activate disable */
if (!found) {
} else if (!lib_broken) {
if (online) {
"mm_libonline_cmd_func: "
"could not add "
"lm activate enable");
"could not add "
"lm activate enable");
return (MM_CMD_ERROR);
}
/* Copy local cmd_buf into cmd->cmd_buf */
"%s", cmd_buf);
goto end;
} else if (offline) {
"mm_libonline_cmd_func: "
"could not add "
"lm activate disable");
"could not add "
"lm activate disable");
return (MM_CMD_ERROR);
}
"%s", cmd_buf);
goto end;
}
} else {
"skipping activate");
}
/* Send success for non-connected LM's */
goto db_error;
}
/* Send Success */
rc = MM_CMD_DONE;
goto end;
rc = MM_CMD_ERROR;
goto end;
return (MM_CMD_ERROR);
NULL);
rc = MM_CMD_ERROR;
goto end;
end:
if (cmd_buf)
if (lib_name)
if (lm_name)
return (rc);
}
int
{
int print_message = 1;
int rc;
char *drive_name = NULL;
int online = 0;
int offline = 0;
/*
* NOTES: May need to issue a scan command to LM to
* determine the current state of the drive.
* What to do in error cases?
*/
/* Online clause */
MMS_PN_CLAUSE, &work);
if (print_message)
/* Get Drive Name */
if ((value =
goto not_found;
} else {
/* Have the drive name */
online = 1;
if (print_message)
}
} else {
/* Didn't find a online clause */
if (print_message)
}
/* Offline clause */
MMS_PN_CLAUSE, &work);
if (print_message)
/* Get Drive Name */
if ((value =
goto not_found;
} else {
/* Have the drive name */
offline = 1;
if (print_message)
}
} else {
/* Didn't find a offline clause */
if (print_message)
}
/* Shouldn't ever get here */
"online and offline clause");
goto not_found;
}
/* Check if drive exists */
"select \"DriveName\" "
"from \"DRIVE\" where "
"\"DriveName\" = '%s';",
drive_name) != MM_DB_DATA) {
goto db_error;
} else {
/* No drive exists */
/* ECLASS_EXIST, EDRIVENOEXIST */
NULL);
/* Create new error codes */
rc = MM_CMD_ERROR;
goto end;
}
}
/* Check Priv, drive group ownership */
if (online) {
/* Do online specific checks */
/* Is drive already online? */
"select \"DriveName\" "
"from \"DRIVE\" where "
"\"DriveName\" = '%s'"
" and \"DriveOnline\" = 'true';",
drive_name) != MM_DB_DATA) {
goto db_error;
} else {
/* Drive Already online */
/* ECLASS_PREMPRIV, EDRIVEONLINE */
"EDRIVEALREADYONLINE",
"drive",
NULL);
/* Create new error codes */
rc = MM_CMD_ERROR;
goto end;
}
}
/* Do online */
/* clear DriveDisabled DriveBroken */
/* don't clear DriveLibraryAccess or DriveNeedsCleaning */
"update \"DRIVE\" set "
"\"DriveOnline\" = 't', "
"\"DriveDisabled\" = 'false', "
"\"DriveBroken\" = 'f' where "
"\"DriveName\" = '%s';",
} else if (offline) {
/* Do offline specific checks */
/* Check if drive has a tape currently mounted */
" select \"DriveName\" "
"from \"DRIVE\" where "
"\"CartridgePCL\" ISNULL "
"and \"DriveStateHard\" "
"= 'unloaded' and "
"\"DriveName\" = '%s';",
drive_name) != MM_DB_DATA) {
goto db_error;
} else {
/* Drive Already online */
"EMNTCARTPRES",
"drive",
NULL);
/* Create new error codes */
rc = MM_CMD_ERROR;
goto end;
}
}
"select \"DriveName\" "
"from \"DRIVE\" where "
"\"DriveName\" = '%s'"
" and \"DriveOnline\" = 'false';",
drive_name) != MM_DB_DATA) {
goto db_error;
} else {
/* Drive Already offline */
/* ECLASS_PREMPRIV, EDRIVEOFFLINE */
"EDRIVEALREADYOFFLINE",
"drive",
NULL);
/* Create new error codes */
rc = MM_CMD_ERROR;
goto end;
}
}
/*
* Don't allow offline if drive
* has cartridge mounted?
*/
/* Do offline */
"update \"DRIVE\" set \"DriveOnline\" = "
"'false' where \"DRIVE\".\"DriveName\" = '%s';",
} else {
/* Shouldn't ever get here */
goto not_found;
}
/* Send cmd_buf to data base */
if (print_message)
cmd_buf);
/* Add events */
if (online) {
"mm_drvonline_cmd_func: "
"error adding drive online event");
}
}
if (offline) {
"mm_drvonline_cmd_func: "
"error adding drive offline event");
}
}
goto db_error;
}
/* Add any activate enables for DM's */
/* These will run as independent commands */
drive_name) == 0) {
if (online) {
/* Found the wka of dm for this drive */
== NULL) {
"Failed to add activate enable");
} else {
"added activate enable for %s %s",
}
} else {
if (mm_drive_dm_activate_disable(dm_wka)) {
"Failed to add activate enable");
} else {
"added activate enable for %s %s",
}
}
}
}
/* Send Success */
rc = MM_CMD_DONE;
goto end;
rc = MM_CMD_ERROR;
goto end;
return (MM_CMD_ERROR);
NULL);
rc = MM_CMD_ERROR;
goto end;
end:
if (cmd_buf)
if (drive_name)
return (rc);
}
#define NOTIFY_NEW "INSERT"
#define NOTIFY_DELETE "DELETE"
#define NOTIFY_CHANGE "UPDATE"
#define NOTIFY_NEW_OBJ "NEW"
#define NOTIFY_DELETE_OBJ "OLD"
int
char *joined[100];
int joined_count = 0;
int skip = 0;
int wrote_one = 0;
int y;
int j;
int k;
int x;
int l;
int p;
char *source_buf;
char *dest_buf;
int print_message = 0;
char *sql_action;
char *sql_object;
/* map action string to the correct sql thingys */
}
}
}
for (y = 0; y < 100; y ++) {
}
/* sohuld be only 1 source */
"from \"%s\" ",
joined_count = 0;
joined_count ++;
for (j = 0; j < cmd->cmd_dest_num; j ++) {
dest_buf =
if (print_message) {
j, dest_buf);
}
source_buf)) == NULL) {
} else {
for (k = 0; k < path->mm_node_num; k++) {
skip = 0;
for (x = 0; x < joined_count; x++) {
/* same so skip */
skip = 1;
}
}
if (!skip) {
"\ncross join \"%s\" ",
joined_count ++;
}
}
}
}
for (j = 0; j < cmd->cmd_dest_num; j ++) {
/* j cmd_dest_num */
if (j == 0) {
"\nwhere \n(\n");
}
dest_buf =
if (print_message) {
j, dest_buf);
}
source_buf)) == NULL) {
source_buf) == 0) {
/* same object */
wrote_one = 1;
} else {
/* no path between */
wrote_one = 1;
}
} else {
/* node[%d] has %d edges, k, */
/* path->mm_node[k]->mm_edge_num */
for (l = 0;
l++) {
/*
* if (path->mm_node[k]->
* mm_edge[l]->mm_ref_att != NULL) {
*
* }
*/
/* add this edge constraint */
wrote_one = 1;
"(\"%s\".",
} else {
"(\"%s\".",
[k+1]->mm_obj);
}
"\"%s\" = ",
} else {
"\"%s\" = ",
mm_edge[l]->mm_ref_att);
}
"\"%s\".\"%s\")\n",
mm_edge_num) {
}
}
if (k - 1 >= 0) {
}
}
}
}
/* Add all constraints here */
for (p = 0;
p < cmd->cmd_const_num;
p ++) {
if (p == 0) {
if (wrote_one)
"and\n(\n");
}
(char *)
cmd_const_list, p));
buf =
"and\n");
}
if (p + 1 ==
cmd->cmd_const_num) {
/* parenn for constraints */
}
}
/* paren for where ( */
if (wrote_one) {
")\n");
} else {
"\n");
}
}
}
for (y = 0; y < joined_count; y ++) {
}
/* now build the ru1le buf, we use buf for each pkey in source */
"CREATE RULE \"%s\" AS ON %s TO \"%s\" "
for (j = 0; j < source_pkey->mm_att_num; j ++) {
/* p_key->mm_att[j] */
if (j != 0) {
}
"(%s.\"%s\" in "
"(select distinct \"%s\".\"%s\" %s))",
source_pkey->mm_att[j],
source_pkey->mm_att[j],
buf);
}
if (data_clause == NULL) {
") DO INSERT INTO \"EVENTRULES\" VALUES ('%s', '%s');",
} else {
") DO INSERT INTO \"EVENTRULES\" VALUES ('%s', '%s'",
/* Determine if data needs to be cast */
"select \"%s\""
" from \"%s\" limit 1;",
source_buf) != MM_DB_DATA) {
"error checking type "
"of data attribute");
return (1);
}
/* column is a bool */
", bool_to_text(%s.\"%s\")",
} else {
/* Column is not a bool */
/* int, timestamp etc work w/o cast */
", %s.\"%s\"",
}
}
}
return (1);
}
/* Free char buf */
return (0);
}
int
{
/* Receive clause */
int data_count = 0;
int i;
char *attr_buf;
/* Cancel clause */
/* Parse cmd */
/* Check to see if this is a new or old format notfiy cmd */
/* every new format notify cmd has either a tag or object clause */
MMS_PN_CLAUSE, 0)) == NULL) {
/* check for tag clause */
MMS_PN_CLAUSE, 0)) == NULL) {
" Try processing as old notify cmd");
}
}
/* Recieve clause */
receive_work = NULL;
if (db_buf)
/* Get object */
MMS_PN_CLAUSE, 0)) == NULL) {
" object clause");
"ECLAUSENEEDSARG",
"text",
"reveive clause missing"
" object clause",
NULL);
return (MM_CMD_ERROR);
}
NULL, MMS_PN_OBJ, 0);
if (receive_string == NULL) {
" object string");
"ECLAUSENEEDSARG",
"text",
"reveive clause missing"
" object string",
NULL);
return (MM_CMD_ERROR);
}
"object -> %s", object);
if (mm_add_char(object,
&cmd->cmd_source_list)) {
"mm_notify_chg_cmd_func: "
"out of mem creating source list");
"out of mem creating source list");
return (MM_CMD_ERROR);
}
if (mm_add_char(object,
&cmd->cmd_dest_list)) {
"mm_notify_chg_cmd_func: "
"out of mem creating dest list");
"out of mem creating dest list");
return (MM_CMD_ERROR);
}
cmd->cmd_const_num = 0;
/* Add the constrants in the attribute clause */
/* Check that this is actally an attribute */
"select \"%s\" from "
"\"%s\" limit 1;",
object) != MM_DB_DATA) {
"attribute %s in object clause "
"is not in object %s",
object);
"attribute %s in object clause "
"is not in object %s",
object);
return (MM_CMD_ERROR);
}
"(\"%s\".\"%s\" != NEW.\"%s\")",
"mm_notify_chg_cmd_func: "
"out of mem creating const list");
"out of mem creating const list");
return (MM_CMD_ERROR);
}
cmd->cmd_const_num ++;
}
"const list after additions, %d",
cmd->cmd_const_num);
/* Get tag */
MMS_PN_CLAUSE, 0)) == NULL) {
" tag clause");
"ECLAUSENEEDSARG",
"text",
"reveive clause missing"
" tag clause",
NULL);
return (MM_CMD_ERROR);
}
NULL, MMS_PN_STRING, 0);
if (receive_string == NULL) {
" tag string");
"ECLAUSENEEDSARG",
"text",
"reveive clause missing"
" tag string",
NULL);
return (MM_CMD_ERROR);
}
/* Confirm tag does not exist for this client */
"tag -> %s", tag);
"select \"NotifyID\" from "
"\"NOTIFYRULES\" where \"ConnectionID\" = "
"'%s' and "
"\"NotifyTag\" = '%s';",
tag) != MM_DB_DATA) {
return (MM_CMD_ERROR);
}
"Tag %s already in use",
tag);
"Tag %s already in use",
tag);
return (MM_CMD_ERROR);
}
/* Get action */
MMS_PN_CLAUSE, 0)) == NULL) {
" action clause");
"ECLAUSENEEDSARG",
"text",
"reveive clause missing"
" action clause",
NULL);
return (MM_CMD_ERROR);
}
NULL, MMS_PN_KEYWORD, 0);
if (receive_string == NULL) {
" action string");
"ECLAUSENEEDSARG",
"text",
"reveive clause missing"
" action string",
NULL);
return (MM_CMD_ERROR);
}
"action -> %s", action);
/* Match clause */
/* If this action is add or delete */
/* Look up match in receive */
/* set cmd->cmd_notify_to = 1 */
/* before calling add_const */
/* reset to 0 after */
/* Get to clause and add constrants to const list */
MMS_PN_CLAUSE, 0);
if (receive_to_clause != NULL) {
"match",
MMS_PN_CLAUSE, 0);
cmd->cmd_notify_to = 0;
} else {
"didn't see a to clause");
}
/* set receive clause to match inside from */
MMS_PN_CLAUSE, 0);
if (receive_from_clause == NULL) {
"found from clause but "
"could not find match");
} else {
"didn't see a match clause");
}
} else {
MMS_PN_CLAUSE, 0);
}
if (receive_clause != NULL) {
"Unable build match clause "
"from receive clause");
"Unable build match clause "
"from receive clause");
return (MM_CMD_ERROR);
}
/* Get notifyID */
/* insert this into notify */
"insert into \"NOTIFYRULES\" (\"ConnectionID\","
"\"NotifyTag\",\"NotifyObject\","
"\"NotifyAction\",\"NotifyScope\","
"\"NotifyID\")"
"VALUES('%s', '%s',"
"'%s', '%s', $$%s$$, '%s');",
} else {
/* Get notifyID */
/* insert this into notify */
"insert into \"NOTIFYRULES\" (\"ConnectionID\","
"\"NotifyTag\",\"NotifyObject\","
"\"NotifyAction\", \"NotifyID\")"
"VALUES('%s', '%s',"
"'%s', '%s', '%s');",
}
return (MM_CMD_ERROR);
}
"add non-priv constraints");
/* Need to check source list and */
/* add constraints as necessary */
"error adding non-priv "
"client constraints");
}
"const list after additions, %d",
cmd->cmd_const_num);
} else {
"skip constraints forpriv client");
}
/* Data clause */
MMS_PN_CLAUSE, 0)) == NULL) {
} else {
/* Verify these attributes */
data_count ++;
if (data_count > 5) {
/* 6th data string */
/* only 5 allowed */
"only 5 attributes are allowed in"
"a data clause");
"only 5 attributes are allowed in"
"a data clause");
return (MM_CMD_ERROR);
}
/* Verify that this data string is */
/* an attribute of object */
"select \"%s\" from "
"\"%s\" limit 1;",
object) != MM_DB_DATA) {
"attribute %s in data clause"
" is not in object %s",
object);
"attribute %s in data clause"
" is not in object %s",
object);
return (MM_CMD_ERROR);
}
}
}
/* create rule */
/* insert rule into rule table */
/* write new func based on mm_sql_report_func( */
/* to generate the path matching part of the event rule */
action, data_clause)) {
"Unable build event rule from receive clause");
return (MM_CMD_ERROR);
}
if (db_buf)
/* end of recieve clause */
}
/* Cancel clause */
cancel_work = NULL;
if (db_buf)
/* Get object */
MMS_PN_CLAUSE, 0)) != NULL) {
NULL, MMS_PN_OBJ, 0);
if (cancel_string == NULL) {
" object string");
"ECLAUSENEEDSARG",
"text",
"reveive clause missing"
" object string",
NULL);
return (MM_CMD_ERROR);
}
"drop all event rules for obj %s, conn %s",
"select \"NotifyID\" from \"NOTIFYRULES\" where "
"\"ConnectionID\" = '%s' "
"and \"NotifyObject\" = '%s';",
return (MM_CMD_ERROR);
}
for (i = 0; i < PQntuples(notifyid_results); i ++) {
/* Drop event rules for these id's */
"drop rule \"%s\" on \"%s\";",
PQgetvalue(notifyid_results, i, 0),
return (MM_CMD_ERROR);
}
/* Delete rules for this tag from NOTIFYRULES */
"delete "
" from \"NOTIFYRULES\" where "
"\"ConnectionID\" = '%s' and "
"\"NotifyObject\" = '%s';",
return (MM_CMD_ERROR);
}
}
/* Go to next cancel clause */
continue;
} else {
" object clause");
}
/* Get tag */
MMS_PN_CLAUSE, 0)) != NULL) {
NULL, MMS_PN_STRING, 0);
if (cancel_string == NULL) {
" tag string");
"ECLAUSENEEDSARG",
"text",
"reveive clause missing"
" tag string",
NULL);
return (MM_CMD_ERROR);
}
"drop all event rules for tag %s, conn %s",
"select \"NotifyID\",\"NotifyObject\""
" from \"NOTIFYRULES\" where "
"\"ConnectionID\" = '%s' and \"NotifyTag\" = '%s';",
return (MM_CMD_ERROR);
}
for (i = 0; i < PQntuples(notifyid_results); i ++) {
/* Drop event rules for these id's */
"drop rule \"%s\" on \"%s\";",
PQgetvalue(notifyid_results, i, 0),
MM_DB_OK) {
return (MM_CMD_ERROR);
}
}
/* Delete rules for this tag from NOTIFYRULES */
"delete "
" from \"NOTIFYRULES\" where "
"\"ConnectionID\" = '%s' and \"NotifyTag\" = '%s';",
return (MM_CMD_ERROR);
}
} else {
/* Missing tag and obj clause */
/* parser should prevent this situation */
return (MM_CMD_ERROR);
}
}
if (db_buf)
return (MM_CMD_DONE);
}
int
{
int print_message = 1;
int go;
int wrote_one = 0;
/* This is the function to process the */
/* old format notfiy commands */
"update \"NOTIFY\" set ");
/* Recieve clause */
receive_work = NULL;
if (print_message)
"ECLAUSENEEDSARG",
"text",
"reveive clause missing event arg",
NULL);
return (MM_CMD_ERROR);
}
"ECLAUSENEEDSARG",
"text",
"reveive clause missing scope arg",
NULL);
return (MM_CMD_ERROR);
}
if (wrote_one)
",");
" \"%s\" = '%s'",
wrote_one = 1;
"Receive %s, scope, %s",
}
/* Cancel clause */
MMS_PN_CLAUSE, &work);
if (print_message)
/* Set each value to 'yes' */
go = 1;
while (go) {
if ((value =
go = 0;
} else {
if (wrote_one)
",");
" \"%s\" = 'off'",
wrote_one = 1;
if (print_message)
}
}
} else {
/* Didn't find a cancel clause */
if (print_message)
}
/* add where clause */
if (print_message)
} else {
if (print_message)
}
/* Send cmd_buf to data base */
if (print_message)
cmd_buf);
return (MM_CMD_ERROR);
}
/* Send Success */
if (cmd_buf)
return (MM_CMD_DONE);
return (MM_CMD_ERROR);
if (cmd_buf)
NULL);
return (MM_CMD_ERROR);
}
int
{
int rows;
char *query;
char *library;
char *lm;
char *constraint;
return (MM_CMD_ERROR);
}
"mm_inject_cmd_func: "
"out of mem creating source list");
"out of mem creating source list");
return (MM_CMD_ERROR);
}
"mm_inject_cmd_func: "
"out of mem creating source list");
"out of mem creating source list");
return (MM_CMD_ERROR);
}
query = "select distinct "
"\"LM\".\"LibraryName\",\"LM\".\"LMName\" from ";
"mm_inject_cmd_func: "
"db error creating helper functions");
return (MM_CMD_ERROR);
}
constraint = "and ((\"LIBRARY\".\"LibraryName\" = "
"\"LM\".\"LibraryName\") and "
"(\"LIBRARY\".\"LibraryOnline\" = 'true'))";
return (MM_CMD_ERROR);
}
if (rows == 0) {
return (MM_CMD_ERROR);
} else if (rows > 1) {
"user constaints selected more than "
"one library");
return (MM_CMD_ERROR);
}
/* find cap */
MMS_PN_CLAUSE, NULL)) {
return (MM_CMD_ERROR);
}
/*
* Report clause, query before data model changed.
* Actually, this should be about the context of command
* and report what was injected.
*/
/*
* LMP inject command
*/
"Unable to malloc mm_command_t: %s",
"unable to allocate memory for lmp inject");
return (MM_CMD_ERROR);
}
/* create task */
"mm_inject_cmd_func: "
"error inserting new task");
"error inserting new task");
return (MM_CMD_ERROR);
}
if (mm_set_tm_library(db,
"mm_inject_cmd_func: "
"error updating TASKLIBRARY");
"error updating TASKLIBRARY");
return (MM_CMD_ERROR);
}
return (MM_DISPATCH_DEPEND);
char *response_message = NULL;
/* remove completed task */
"msg_rsp", response_message,
NULL);
return (MM_CMD_ERROR);
}
/*
* Report clause (previously generated).
*/
return (MM_CMD_DONE);
}
return (MM_CMD_ERROR);
NULL);
return (MM_CMD_ERROR);
}
int
{
int rows;
int row;
int rc;
char *cartid;
char *cartpcl;
char *slottype;
char *query;
return (MM_CMD_ERROR);
}
sizeof (cmd_eject_t))) == NULL) {
}
sizeof (eject_cart_t),
/* get cart(s) by id */
MMS_PN_CLAUSE, &work);
MMS_PN_CLAUSE, &work)) {
"\"SlotTypeName\","
"\"LibraryName\","
"\"SlotName\" "
"FROM \"SLOT\" "
"WHERE \"CartridgeID\" = '%s';",
cartid) != MM_DB_DATA) {
return (MM_CMD_ERROR);
}
"cartid %s not found", cartid);
NULL);
return (MM_CMD_ERROR);
}
/* add cartridge to list of ejectable cartridges */
sizeof (eject_cart_t))) == NULL) {
}
}
/* get cart(s) by pcl and slottype */
MMS_PN_CLAUSE, &work);
MMS_PN_CLAUSE, &work)) {
"get cartridge by pcl and slottype");
index = 0;
MMS_PN_STRING, &index);
MMS_PN_STRING, &index);
"\"LibraryName\","
"\"SlotName\" "
"FROM \"SLOT\" "
"WHERE (\"CartridgePCL\" = '%s') "
"AND (\"SlotTypeName\" = '%s');",
return (MM_CMD_ERROR);
}
NULL);
return (MM_CMD_ERROR);
}
sizeof (eject_cart_t))) == NULL) {
}
}
/* get cart(s) by match */
MMS_PN_CLAUSE, NULL)) {
"mm_eject_cmd_func: "
"out of mem creating source list");
"out of mem creating source list");
return (MM_CMD_ERROR);
}
"mm_eject_cmd_func: "
"out of mem creating source list");
"out of mem creating source list");
return (MM_CMD_ERROR);
}
query = "select distinct "
"\"CARTRIDGE\".\"CartridgeID\","
"\"CARTRIDGE\".\"CartridgePCL\","
"\"SLOT\".\"SlotTypeName\","
"\"CARTRIDGE\".\"LibraryName\","
"\"SLOT\".\"SlotName\" "
"from ";
"mm_eject_cmd_func: "
"db error creating helper functions");
return (MM_CMD_ERROR);
}
return (MM_CMD_ERROR);
}
NULL);
return (MM_CMD_ERROR);
}
rows);
sizeof (eject_cart_t))) == NULL) {
}
row, 0));
row, 1));
row, 2));
row, 3));
row, 4));
}
}
/* check for at least one cart */
NULL);
return (MM_CMD_ERROR);
}
/* check cartridge state */
"check cartridge state for %s",
/* cartridge is not mount candidate */
"\"TaskID\" "
"FROM \"TASKCARTRIDGE\" "
"WHERE (\"CartridgeID\" = '%s');",
return (MM_CMD_ERROR);
}
"FROM \"TASK\" "
"WHERE (\"TaskID\" = '%s');",
!= MM_DB_DATA) {
return (MM_CMD_ERROR);
}
PQgetvalue(taskcart_results, 0, 0));
if (rc == 0) {
"mount candidate");
MM_5006_MSG, "cartid",
NULL);
return (MM_CMD_ERROR);
}
}
}
/* check for cart in slot */
"from \"SLOT\" where \"CartridgeID\" = '%s';",
return (MM_CMD_ERROR);
}
MM_5010_MSG, "cartid",
NULL);
return (MM_CMD_ERROR);
}
"true") != 0 &&
"t") != 0) {
MM_5011_MSG, "cartid",
NULL);
return (MM_CMD_ERROR);
}
/* check for carts in same library */
eject_cart->cart_library) != 0) {
NULL);
return (MM_CMD_ERROR);
}
}
/* get lm */
"WHERE \"LibraryName\" = '%s'",
return (MM_CMD_ERROR);
}
NULL);
return (MM_CMD_ERROR);
}
NULL);
return (MM_CMD_ERROR);
}
/* check for configured, connected, and ready library */
return (MM_CMD_ERROR);
}
/* find cap */
MMS_PN_CLAUSE, NULL)) {
return (MM_CMD_ERROR);
}
/*
* Report clause, get before data model changes.
*/
/*
* LMP eject command
*/
"Unable to malloc mm_command_t: %s",
"unable to allocate memory "
"for eject cmd");
return (MM_CMD_ERROR);
}
"mm_eject_cmd_func: "
"error inserting new task");
"error inserting new task");
return (MM_CMD_ERROR);
}
"mm_eject_cmd_func: "
"error updating TASKLIBRARY");
"error updating TASKLIBRARY");
return (MM_CMD_ERROR);
}
"mm_eject_cmd_func: "
"db error inserting TASKCARTRIDGE");
}
}
return (MM_DISPATCH_DEPEND);
char *response_message = NULL;
/* remove completed task */
"msg_rsp", response_message,
NULL);
return (MM_CMD_ERROR);
}
/*
* Report clause (previously generated).
*/
return (MM_CMD_DONE);
}
return (MM_CMD_ERROR);
NULL);
return (MM_CMD_ERROR);
}
int
{
int off;
char *objname;
int get_once = 0;
int rc;
int error = 0;
char *notify_obj = NULL;
int col;
int cols;
char date[24];
int datasize = 0;
char *id;
char *name;
char *val;
char *query;
int responsesize = 0;
int i;
int len;
/*
* Get all values in a single query
*/
off = 0;
MMS_PN_CLAUSE, &work);
MMS_PN_CLAUSE, &work)) {
MMS_PN_OBJ, &item);
MMS_PN_OBJ, &item)) {
/* gather sql query constraints */
lang == MM_LANG_DMP) {
seen_id[0] = "DRIVE";
seen_name[0] = "DriveName";
lang == MM_LANG_DMP) {
lang == MM_LANG_LMP) {
seen_id[0] = "LIBRARY";
seen_name[0] = "LibraryName";
lang == MM_LANG_LMP) {
} else {
/* invalid object */
&cmd->cmd_bufsize,
return (MM_CMD_ERROR);
}
/* initialize query buffer */
if (!get_once) {
get_once = 1;
}
/* add which sql query table and field */
&itemcnt);
}
}
if (get_once) {
off--; /* overwrite the last comma */
/* add query constraints */
"\"%s\".\"%s\" = '%s' AND "
"\"%s\".\"%s\" = '%s'",
conn->cci_instance);
"\"%s\".\"DriveName\" = '%s'",
conn->cci_client);
"\"%s\".\"LibraryName\" = '%s'",
conn->cci_client);
} else {
"\"%s\" = '%s'",
conn->cci_instance);
}
datasize = 0;
return (MM_CMD_ERROR);
}
/* query the database */
if (rc != MM_DB_DATA) {
return (MM_CMD_ERROR);
}
return (MM_CMD_ERROR);
}
/* convert strings from postgres to mms */
off = 0;
if (val[0] == '\0') {
/* empty object attribute string */
val = "none";
}
/* database data types to mms string conversions */
val = "true";
val = "false";
}
/* mms time not set */
val = "0000 00 00 00 00 00 000";
} else {
sizeof (date));
/* mms localtime format */
}
for (i = len; i < 23; i++) {
val[i] = '0';
}
}
}
}
if (data) {
/* build successful response with text */
datasize = 0;
}
}
}
/*
* Set values one at a time
*/
MMS_PN_CLAUSE, &work);
MMS_PN_CLAUSE, &work)) {
MMS_PN_STRING, &itemcnt);
MMS_PN_STRING, &itemcnt);
/* check for name changes and flag change event */
lang == MM_LANG_DMP) {
id = "DriveName";
lang == MM_LANG_DMP) {
id = "DMName";
notify_obj = "DM";
lang == MM_LANG_LMP) {
id = "LibraryName";
lang == MM_LANG_LMP) {
id = "LMName";
notify_obj = "LM";
} else {
}
/* name change not allowed or invalid object */
&cmd->cmd_bufsize,
return (MM_CMD_ERROR);
}
"UPDATE \"%s\" SET ", objname);
&cmd->cmd_bufsize,
"\"%s\" = default "
"WHERE \"%s\" = '%s'",
} else {
&cmd->cmd_bufsize,
"\"%s\" = '%s' "
"WHERE \"%s\" = '%s'",
}
/* create the attribute if needed */
return (MM_CMD_ERROR);
}
/* change the attribute value */
return (MM_CMD_ERROR);
}
}
}
/*
* Unset values one at a time
*/
MMS_PN_CLAUSE, &work);
MMS_PN_CLAUSE, &work)) {
&item)) {
MMS_PN_STRING, &itemcnt);
/* check for name changes and flag change event */
lang == MM_LANG_DMP) {
id = "DriveName";
lang == MM_LANG_DMP) {
id = "DMName";
notify_obj = "DM";
lang == MM_LANG_LMP) {
id = "LibraryName";
lang == MM_LANG_LMP) {
id = "LMName";
notify_obj = "LM";
} else {
}
/* name change not allowed or invalid object */
&cmd->cmd_bufsize,
return (MM_CMD_ERROR);
}
/* remove device manager created attributes */
continue; /* object attribute removed */
} else if (rc == MM_DB_ERROR) {
return (MM_CMD_ERROR);
}
/* set the attribute to its default */
"UPDATE \"%s\" SET ", objname);
"\"%s\" = DEFAULT WHERE \"%s\" = '%s'",
/* set attribute to default */
return (MM_CMD_ERROR);
}
}
}
/*
* Notify clients
*/
if (notify_obj) {
cmd,
"change", notify_obj,
"mm_private_cmd_func: "
"error adding config change event");
}
}
/*
* Return the get report
*/
cmd->cmd_bufsize = 0;
}
return (MM_CMD_DONE);
return (MM_CMD_ERROR);
NULL);
return (MM_CMD_ERROR);
}
int
char *buf;
/*
* Add change tracing private command to command queue
*/
"select \"SystemDiskMountTimeout\" "
"from \"SYSTEM\";") != MM_DB_DATA) {
"error getting SystemDiskMountTimeout");
return (1);
}
"\"TraceLevel\",\"TraceFileSize\" from \"LM\" where "
return (1);
}
return (1);
}
"set[\"LMMessageLevel\" \"%s\" "
"\"TraceLevel\" \"%s\" "
"\"TraceFileSize\" \"%s\" "
"\"SystemDiskMountTimeout\" \"%s\"];",
task,
PQgetvalue(system_results, 0, 0));
"\"TraceLevel\",\"TraceFileSize\" from \"DM\" where "
return (1);
}
return (1);
}
"set[\"DMMessageLevel\" \"%s\" "
"\"TraceLevel\" \"%s\" "
"\"TraceFileSize\" \"%s\" "
"\"SystemDiskMountTimeout\" \"%s\"];",
task,
PQgetvalue(system_results, 0, 0));
}
return (0);
}
int
{
int row = 0;
int rows = 0;
int error = 0;
int found = 0;
char *mm_password = NULL;
#ifdef MMS_OPENSSL
char *certificate = NULL;
char *auth_message = NULL;
char ebuf[MMS_EBUF_LEN];
#endif /* MMS_OPENSSL */
int configured;
int rc;
goto unsupported;
}
/* get client connection info */
"mm_hello_cmd_func: "
"missing client clause");
goto unsupported;
}
/* client clause is present */
"mm_hello_cmd_func: "
"missing client clause string");
goto unsupported;
}
goto unsupported;
}
/* get instance info */
"mm_hello_cmd_func: "
"missing instance clause");
goto unsupported;
}
/* instance clause is present */
"mm_hello_cmd_func: "
"missing instance clause string");
goto unsupported;
}
goto unsupported;
}
/* Get optional tag arg */
/* tag clause is present */
"session tag will be %s",
tag);
}
/* get language info */
"mm_hello_cmd_func: "
"missing language clause");
goto unsupported;
}
/* language clause is present */
"mm_hello_cmd_func: "
"missing language clause keyword");
goto unsupported;
}
}
} else {
"mm_hello_cmd_func: "
"unknown language in hello");
return (MM_CMD_DONE);
}
goto unsupported;
}
"mm_hello_cmd_func: "
"missing version clause");
goto unsupported;
}
found = 0;
conn->cci_version =
"null connection version");
goto unsupported;
}
found = 1;
}
}
if (!found) {
goto unsupported;
}
switch (cmd->cmd_language) {
case MM_LANG_MMP:
"select \"Password\" "
"from \"MMPASSWORD\" "
"where \"ApplicationName\" = '%s';",
conn->cci_client);
break;
case MM_LANG_LMP:
case MM_LANG_DMP:
/* lm and dm use watcher's password */
"select \"Password\" "
"from \"MMPASSWORD\" "
"where \"ApplicationName\" = '%s';",
MM_APP);
break;
}
if (rc != MM_DB_DATA ||
goto denied;
}
/* verify hello password or cert clause */
}
#ifdef MMS_OPENSSL
MMS_PN_STRING, &index);
MMS_PN_STRING, &index);
"certificate/auth\n%s\n%s",
/* get password from encrypted data */
&password)) {
ebuf, MMS_EBUF_LEN);
"invalid cert clause %s", ebuf);
goto denied;
}
}
#endif /* MMS_OPENSSL */
goto denied;
}
/* get password hash */
"select mm_func_getpassword('%s');",
password);
goto denied;
}
/* compare password hashes */
if (rc == 0) {
} else {
goto denied;
}
error = 0;
configured = 0;
switch (cmd->cmd_language) {
case MM_LANG_MMP:
"SELECT "\
"\"APPLICATION\".\"ApplicationName\","
"\"AI\".\"AIName\", "\
"\"AI\".\"ApplicationName\","
"\"AI\".\"SessionsAllowed\" FROM "
"\"APPLICATION\",\"AI\" WHERE "
"(\"APPLICATION\".\"ApplicationName\" "\
"= '%s' AND "
"\"AI\".\"AIName\" = '%s') AND "
"\"AI\".\"ApplicationName\" = '%s'",
error = 1;
conn->cci_client) == 0 &&
conn->cci_instance) == 0 &&
conn->cci_client) == 0) {
configured = 1;
}
}
break;
case MM_LANG_DMP:
/*
* Drive.DMName is only set when DM is activate enable.
*/
"SELECT \"DRIVE\".\"DriveName\","
"\"DM\".\"DMName\",\"DM\"."\
"\"DriveName\" "
"FROM \"DRIVE\",\"DM\" WHERE "
"(\"DRIVE\".\"DriveName\" = '%s' AND "
"\"DM\".\"DMName\" = '%s' AND "
"\"DM\".\"DriveName\" = '%s')",
error = 1;
conn->cci_client) == 0 &&
conn->cci_instance) == 0 &&
conn->cci_client) == 0) {
configured = 1;
}
}
break;
case MM_LANG_LMP:
/*
* LIBRARY.LMName is set by the user.
*/
"SELECT \"LIBRARY\".\"LibraryName\","
"\"LM\".\"LMName\",\"LM\"."\
"\"LibraryName\" "
"FROM \"LIBRARY\",\"LM\" WHERE "
"(\"LIBRARY\".\"LibraryName\" "\
"= '%s' AND "
"\"LM\".\"LMName\" = '%s' AND "
"\"LM\".\"LibraryName\" = '%s')",
error = 1;
conn->cci_client) == 0 &&
conn->cci_instance) == 0 &&
conn->cci_client) == 0) {
configured = 1;
}
}
break;
}
if (error)
if (!configured)
"not configured",
goto denied;
}
/* check for duplicate device managers on same host */
"\"ConnectionClientInstance\", "\
"\"ConnectionClientHost\" "
"FROM \"CONNECTION\"") != MM_DB_DATA) {
"mm_hello_cmd_func: "
"db error getting connection info,"
"return unwelcome");
goto denied;
}
switch (cmd->cmd_language) {
case MM_LANG_DMP:
case MM_LANG_LMP:
row, 0),
conn->cci_client) == 0 &&
row, 1),
conn->cci_instance) == 0 &&
row, 2),
mm_cci_host_ident(conn)) == 0) {
"mm_hello_cmd_func: "
"duplicate session found, "
"return unwelcome");
&cmd->cmd_bufsize,
return (MM_CMD_DONE);
}
break;
}
}
/* For MMP clients, check that Ai.SessionsAllowed */
/* allows them to conect */
"SELECT \"CONNECTION\".\"ConnectionID\","
"\"AI\".\"SessionsAllowed\" FROM"
"\"CONNECTION\" cross join \"AI\""
"where"
"("
"(\"CONNECTION\"."
"\"ConnectionClientInstance\" = "
"\"AI\".\"AIName\")"
"and"
"(\"CONNECTION\"."
"\"ConnectionClientName\" = "
"\"AI\".\"ApplicationName\")"
"and"
"(\"AI\".\"AIName\" = '%s')"
"and"
"(\"AI\".\"ApplicationName\" = '%s')"
");",
goto denied;
}
"single") == 0)) {
/* This is a duplicate session */
/* with single session allowed */
"multiple sessions not allowed for %s, %s",
conn->cci_instance);
&cmd->cmd_bufsize,
return (MM_CMD_DONE);
}
}
"(\"Language\",\"ConnectionClientName\","
"\"ConnectionClientInstance\", "\
"\"ConnectionClientHost\","
"\"ConnectionClientPort\", "\
"\"ConnectionID\") "
"VALUES('%s','%s','%s','%s','%d','%s')",
!= MM_DB_OK) {
goto denied;
}
"(\"ConnectionClientName\", "
"\"ConnectionClientInstance\","
"\"ConnectionID\") "
"VALUES ('%s','%s','%s')",
goto denied;
}
/* add session */
"INSERT INTO \"SESSION\" "
"(\"SessionID\", "
"\"ApplicationName\", "
"\"AIName\","
"\"SessionClientHost\", "
"\"SessionClientPort\", "
"\"ConnectionID\") "
"VALUES ('%s','%s','%s',"
"'%s','%d','%s')",
!= MM_DB_OK) {
"db error inserting session obj");
goto denied;
}
/* Set the session tag */
"update \"SESSION\" set "
"\"SessionTag\" = '%s'"
" where \"SessionID\" = '%s';",
"db error setting session tag");
goto denied;
}
}
/* update dm host */
"set \"DMHost\" = '%s' "
"where \"DriveName\" = '%s' "
"and \"DMName\" = '%s';",
goto denied;
}
/* update lm host */
"set \"LMHost\" = '%s' "
"where \"LibraryName\" = '%s' "
"and \"LMName\" = '%s';",
goto denied;
}
}
/* welcome new client */
if (mm_password == NULL) {
#ifdef MMS_OPENSSL
} else if (mms_ssl_has_cert_clause(mm_wka->
mm_wka->mm_wka_conn)) {
&auth_message)) {
ebuf);
goto denied;
}
"certificate/auth\n%s\n%s",
#endif /* MMS_OPENSSL */
} else {
}
conn->cci_language);
}
/* Send device manager private cmd */
if (mm_startup_private(mm_wka)) {
"error sending "
"private command");
}
}
/* Add LM Activate */
/* activate enable library lm */
if (mm_library_lm_connect(mm_wka)) {
return (MM_CMD_ERROR);
} else if (mm_library_lm_activate_enable(mm_wka) == 0) {
"for %s",
return (MM_DISPATCH_AGAIN);
}
}
/* Add DM Activate */
/* activate enable */
"DMStateSoft",
"present", "DMName",
"for %s",
return (MM_DISPATCH_AGAIN);
}
}
/* hello complete */
return (MM_CMD_DONE);
}
return (MM_CMD_ERROR);
return (MM_CMD_ERROR);
return (MM_CMD_DONE);
return (MM_CMD_DONE);
}
int
{
char *toslot;
int rows;
int rc;
char taskid[UUID_PRINTF_SIZE];
char *libname;
char *lmname;
char *cartid;
char *sidename;
char *cartpcl;
char *slottype;
const char *query;
char *slotname;
char *state;
rc = MM_CMD_ERROR;
goto end;
}
/* slot */
/* constraints */
MMS_PN_CLAUSE, &work)) {
"move command cartid clause");
}
"already in dest list");
} else {
cmd->cmd_dest_num ++;
}
"(\"SIDE\".\"CartridgeID\" = '%s' AND ",
cartid);
"\"SIDE\".\"SideName\" = '%s') ",
sidename);
"already in const list");
} else {
cmd->cmd_const_num ++;
}
}
MMS_PN_CLAUSE, &work)) {
"move command cart clause");
}
if (mm_add_match_list("SIDE",
&cmd->cmd_dest_list)) {
"already in dest list");
} else {
cmd->cmd_dest_num ++;
}
if (mm_add_match_list("CARTRIDGE",
&cmd->cmd_dest_list)) {
"already in dest list");
} else {
cmd->cmd_dest_num ++;
}
if (mm_add_match_list("SLOTTYPE",
&cmd->cmd_dest_list)) {
"already in dest list");
} else {
cmd->cmd_dest_num ++;
}
"(\"CARTRIDGE\".\"CartridgePCL\" = '%s' AND "
"\"SLOTTYPE\".\"SlotTypeName\" = '%s' AND "
"\"SIDE\".\"SideName\" = '%s') ",
"already in const list");
} else {
cmd->cmd_const_num ++;
}
} else {
"move command match clause");
} else {
/* TEMP - Trace out our dest info */
}
} else {
/* TEMP - Trace out our const info */
}
}
/* cartridge */
query = "SELECT \"SLOT\".\"SlotName\",\"CARTRIDGE\".\"CartridgePCL\","
"\"SIDE\".\"SideName\",\"CARTRIDGE\".\"LibraryName\","
"\"CARTRIDGE\".\"CartridgeState\" FROM ";
} else {
cmd->cmd_source_num ++;
}
} else {
cmd->cmd_source_num ++;
}
} else {
cmd->cmd_source_num ++;
}
"mm_move_cmd_func: "
"db error creating helper functions");
rc = MM_CMD_ERROR;
goto end;
}
goto db_error;
}
if (rows == 0) {
if (cart) {
NULL);
} else {
NULL);
}
rc = MM_CMD_ERROR;
goto end;
} else if (rows > 1) {
NULL);
rc = MM_CMD_ERROR;
goto end;
}
"pcl",
NULL);
rc = MM_CMD_ERROR;
goto end;
}
goto db_error;
}
if (rows == 0) {
"lib",
NULL);
rc = MM_CMD_ERROR;
goto end;
} else if (rows > 1) {
"row number mismatch, "
"to many device manager rows returned");
rc = MM_CMD_ERROR;
goto end;
}
/* check for online library */
"\"LIBRARY\".\"LibraryStateSoft\",\"LM\".\"LMStateSoft\" "
"FROM \"LIBRARY\",\"LM\" "
"WHERE (\"LIBRARY\".\"LibraryName\" = '%s' AND "
"\"LIBRARY\".\"LMName\" = '%s') AND "
"(\"LM\".\"LibraryName\" = '%s' AND "
"\"LM\".\"LMName\" = '%s')",
goto db_error;
}
"ready") != 0 ||
"ready") != 0) {
"lm",
NULL);
rc = MM_CMD_ERROR;
goto end;
}
/* issue lm move command */
/* build lm scan cmd */
query = "move task[\"%s\"] from[\"%s\" \"%s\" \"%s\"] "
"to[\"%s\" \"%s\"]";
rc = MM_CMD_DONE;
goto end;
rc = MM_CMD_ERROR;
goto end;
return (MM_CMD_ERROR);
"move command not_found");
NULL);
rc = MM_CMD_ERROR;
goto end;
end:
return (rc);
}
int
{
return (MM_CMD_ERROR);
}
} else {
}
} else {
}
}
MMS_PN_KEYWORD, NULL)) {
}
if (type)
if (restart)
/*
* TBD: Args: nonewapps, nonewmounts, abortqueue, force, restart.
* Send device managers activate disable
*/
mm_exiting = 1;
return (MM_CMD_DONE);
return (MM_CMD_ERROR);
NULL);
return (MM_CMD_ERROR);
}
int
{
int row;
int rows;
int count;
int index;
int i;
/*
* Get volume names.
*/
count = 0;
count++;
}
return (MM_CMD_ERROR);
}
index = 0;
}
/* check for duplicate volumes */
for (i = 0; i < count; i++) {
if (i != index &&
&cmd->cmd_bufsize,
return (MM_CMD_ERROR);
}
}
}
/*
* Find distinct volumes to rename.
*/
/* Add the VOLUME constraint */
"(\"VOLUME\".\"ApplicationName\" = '%s') ",
conn->cci_client);
cmd->cmd_const_num ++;
}
cmd->cmd_dest_num ++;
}
query = "SELECT DISTINCT \"VOLUME\".\"CartridgeID\", "
"\"VOLUME\".\"VolumeName\" FROM ";
cmd->cmd_source_num ++;
}
"mm_rename_cmd_func: "
"db error creating helper functions");
return (MM_CMD_ERROR);
}
return (MM_CMD_ERROR);
}
/*
* Check for mounted or stale volumes.
*/
"\"VolumeName\" FROM \"MOUNTLOGICAL\" WHERE "
"\"CartridgeID\" = '%s'",
return (MM_CMD_ERROR);
}
return (MM_CMD_ERROR);
}
"\"VolumeName\" FROM \"STALEHANDLE\" WHERE "
"\"CartridgeID\" = '%s'",
return (MM_CMD_ERROR);
}
return (MM_CMD_ERROR);
}
}
/*
* Rename volumes.
*/
/* check for unique volume name in apps namespace. */
"\"VOLUME\" WHERE \"ApplicationName\" = '%s' AND "
"\"VolumeName\" = '%s'",
return (MM_CMD_ERROR);
}
return (MM_CMD_ERROR);
}
"\"VolumeName\" = '%s' WHERE \"CartridgeID\" = '%s'",
return (MM_CMD_ERROR);
}
}
/*
* Generate report.
*/
return (MM_CMD_DONE);
return (MM_CMD_ERROR);
NULL);
return (MM_CMD_ERROR);
}
int
{
int row;
int rows;
int count;
int index;
char *report_buf = NULL;
char *query;
/*
* Generate report and save it before the delete.
*/
return (MM_CMD_ERROR);
}
/*
* Get volume names from the command.
*/
count = 0;
MMS_PN_CLAUSE, NULL)) {
count++;
}
return (MM_CMD_ERROR);
}
index = 0;
}
}
}
/*
* Get the volumes cartridge ids.
*/
/* Add the VOLUME constraint */
"(\"VOLUME\".\"ApplicationName\" = '%s') ",
conn->cci_client);
cmd->cmd_const_num ++;
}
cmd->cmd_dest_num ++;
}
query = "SELECT DISTINCT \"VOLUME\".\"CartridgeID\" "
"FROM ";
cmd->cmd_source_num ++;
}
"mm_deallocate_cmd_func: "
"db error creating helper functions");
return (MM_CMD_ERROR);
}
/* delete volumes, mountlogical foreign key prevents mounted delete */
return (MM_CMD_ERROR);
}
/*
* Delete volumes.
*/
"WHERE \"CartridgeID\" = '%s'",
return (MM_CMD_ERROR);
}
"\"PartitionAllocatable\" = 'true' WHERE "
"\"CartridgeID\" = '%s'",
return (MM_CMD_ERROR);
}
}
cmd,
db)) {
"mm_deallocate_cmd_func: "
"error adding volume delete event");
}
"VOLUME, %s deallocated by %s %s",
conn->cci_instance);
}
cmd->cmd_bufsize = 0;
return (MM_CMD_DONE);
return (MM_CMD_ERROR);
NULL);
return (MM_CMD_ERROR);
}
int
{
int row;
int rows;
int count;
int index;
int num;
int i;
char *query;
char *constraint;
/* Get who clause */
/* who clause */
NULL,
app_name);
/* for standard priv, */
/* check that app_name is the client's */
"appcliation name in who does"
" not match client application");
"ECLAUSENOPRIVILEGE",
NULL);
return (MM_CMD_ERROR);
}
}
}
NULL,
ai_name);
/* for standard priv, */
/* check that app_name is the client's */
"instace name in who does"
" not match client instance'");
"ECLAUSENOPRIVILEGE",
NULL);
return (MM_CMD_ERROR);
}
}
} else {
}
} else {
app_name);
}
/*
* Get volume names.
*/
count = 0;
count++;
}
return (MM_CMD_ERROR);
}
index = 0;
}
/* check command for unique volnames */
for (i = 0; i < count; i++) {
if (i != index &&
&cmd->cmd_bufsize,
return (MM_CMD_ERROR);
}
}
}
/* check number-clause and newvolname-clause counts */
NULL);
return (MM_CMD_ERROR);
}
"type %d range %d %d count %d error",
count);
NULL);
return (MM_CMD_ERROR);
}
/*
* Find distinct suitable volume partitions.
*/
} else {
/* TEMP - Trace out our dest info */
}
} else {
/* TEMP - Trace out our const info */
}
} else {
cmd->cmd_dest_num ++;
}
constraint = "(\"PARTITION\".\"PartitionAllocatable\" = 'true')";
"already in constraint list");
} else {
cmd->cmd_const_num ++;
}
"Privileged app, skip "
"CARTRIDGEGROUPAPPLICATION constraint");
} else {
/* if this is not a privilaged app */
/* Enforce CARTRIDGEGROUPAPPLICATION */
"Non-Privileged app, add CARTRIDGEGROUPAPPLICATION");
if (mm_add_match_list("CARTRIDGEGROUPAPPLICATION",
&cmd->cmd_dest_list)) {
"in dest list");
} else {
cmd->cmd_dest_num ++;
}
"already in constraint list");
} else {
cmd->cmd_const_num ++;
}
}
"mm_allocate_cmd_func: "
"out of mem creating source list");
"out of mem creating source list");
return (MM_CMD_ERROR);
}
query = "select distinct \"PARTITION\".\"CartridgeID\","
"\"PARTITION\".\"SideName\","
"\"PARTITION\".\"PartitionName\" from ";
"mm_allocate_cmd_func: "
"db error creating helper functions");
return (MM_CMD_ERROR);
}
return (MM_CMD_ERROR);
}
/* each volname needs a partition */
/* general error, this means the resource is already used */
"partitions found %d, partitions needed %d",
NULL);
return (MM_CMD_ERROR);
}
/*
* Allocate one volume per partition.
*/
/* check for unique volume name in apps namespace. */
"\"VOLUME\" WHERE \"ApplicationName\" = '%s' AND "
"\"VolumeName\" = '%s';",
return (MM_CMD_ERROR);
}
for (i = 0; i < num; i++) {
}
return (MM_CMD_ERROR);
}
"INSERT INTO \"VOLUME\" "
"(\"ApplicationName\", "
"\"VolumeName\", \"CartridgeID\", "
"\"SideName\", "
"\"PartitionName\") VALUES "
"('%s', '%s', '%s', '%s', '%s')",
} else {
"INSERT INTO \"VOLUME\" "
"(\"ApplicationName\", "
"\"VolumeName\", \"CartridgeID\", "
"\"SideName\", \"PartitionName\", "
"\"AIName\") VALUES "
"('%s', '%s', '%s', '%s', '%s', '%s')",
ai_name);
}
return (MM_CMD_ERROR);
}
"\"PartitionAllocatable\" = 'false' WHERE "
"\"CartridgeID\" = '%s' and "
"\"PARTITION\".\"PartitionName\" = '%s';",
return (MM_CMD_ERROR);
}
return (MM_CMD_ERROR);
}
"\"ApplicationName\" = '%s' WHERE "
"\"CARTRIDGE\".\"CartridgeID\" = '%s';",
return (MM_CMD_ERROR);
}
return (MM_CMD_ERROR);
}
}
db)) {
"mm_allocate_cmd_func: "
"error adding volume add event");
}
"VOLUME, %s allocated by %s %s",
conn->cci_instance);
}
/*
* Generate report.
*/
return (MM_CMD_DONE);
return (MM_CMD_ERROR);
NULL);
return (MM_CMD_ERROR);
}
int
{
"FROM \"AI\" WHERE \"ApplicationName\" = '%s' AND "
return (MM_CMD_ERROR);
}
return (MM_CMD_ERROR);
}
return (MM_CMD_ERROR);
}
/* only mms admin can become system level privileged */
return (MM_CMD_ERROR);
}
} else {
}
return (MM_CMD_DONE);
return (MM_CMD_ERROR);
NULL);
return (MM_CMD_ERROR);
}
int
{
return (MM_CMD_ERROR);
}
return (MM_CMD_ERROR);
}
MMS_PN_CLAUSE, &work);
MMS_PN_CLAUSE, &work)) {
return (MM_CMD_ERROR);
}
}
return (MM_CMD_DONE);
return (MM_CMD_ERROR);
NULL);
return (MM_CMD_ERROR);
}
int
int priv = 0;
int i;
/*
* Find the prvilege of this client
* system -> priv = 2
* administrator -> priv = 1
* standard -> priv = 0
*/
/* level is system */
priv = 2;
/* level is administrator */
priv = 1;
} else {
/* level is standard */
priv = 0;
}
/* Check Status Objects if not system priv */
if (priv < 2) {
for (i = 0; i < MM_NUM_STATUS_OBJS; i ++) {
"status object, %s", object);
"object", object,
"attribute", attribute,
NULL);
goto return_error;
}
}
/* Check Status Attributes if not system priv */
for (i = 0; i < MM_NUM_STATUS_ATTS; i ++) {
"status attribute, %s", buf);
"object", object,
"attribute", attribute,
NULL);
goto return_error;
}
}
}
/* Restrict control attributes if this is non-privileged */
if (priv < 1) {
"may not modify the SYSTEM object");
"object", object,
"attribute", attribute,
NULL);
goto return_error;
}
for (i = 0; i < MM_NUM_CONTROL_ATTS; i ++) {
"control attribute, %s", buf);
"object", object,
"attribute", attribute,
NULL);
goto return_error;
}
}
}
goto return_ok;
return (1);
return (0);
return (1);
}
int
if (mm_set_struct == NULL) {
"Unable to malloc cmd_set_t: %s",
return (1);
}
switch (type) {
case MM_SET:
break;
case MM_UNSET:
break;
}
return (0);
}
void
switch (cur_set->cmd_set_type) {
case MM_SET:
/* This node is for a set clause */
break;
case MM_UNSET:
/* This node is for an unset clause */
break;
}
}
}
int
return (1);
}
}
return (0);
}
int
{
int rc;
int error;
/* For Set and Unset Lists */
/* Char list for OBJECT types */
/* Create the Set and Unset Struct Lists */
/* Build the lists after parsing the clauses */
if (mm_get_set_clause(cmd,
"mm_attribute_cmd_func: "
"error building structs from set clause");
"error building structs from set clause");
rc = MM_CMD_ERROR;
goto end;
}
/* Get Dest Objects */
} else {
/* TEMP - Trace out our dest info */
}
/* Get constraint Objects */
} else {
/* TEMP - Trace out our const info */
}
/* Do attribute check */
/* Only for MMP clients */
/* Check if the creating attribtues is allowed */
/* Check if the attributes may be created */
if (mm_db_create_attribute(db,
cur_set->cmd_set_attr) !=
MM_DB_OK) {
"failed for %s.%s",
rc = MM_CMD_ERROR;
goto end;
}
/* Check if the attributes may be modified */
cur_set->cmd_set_attr)) {
/* check_helper sets the correct error */
/* Send and remove */
rc = MM_CMD_ERROR;
goto end;
}
}
} else {
"Skipping attribute check for non-MMP client");
}
/*
* All attributes have passed attribute restricted
* check and creation check
* For each MM object construct the sql command
* to perform the set operation
* unset's are simply a set using DEFAULT as value
*/
int first = 1;
if (cmd_buf) {
}
/* Clear the source list, and add cur_obj as the only source */
"mm_attribute_cmd_func: "
"out of mem creating source list");
"out of mem creating source list");
rc = MM_CMD_ERROR;
goto end;
}
/* Begin constructin the SQL command */
/* For every set where obj = cur_obj */
/* add to the sql command */
/* Obj matches */
if (first) {
/* Frist attr doesn't need a comma */
first = 0;
} else {
/* add a comma */
}
switch (cur_set->cmd_set_type) {
case (MM_SET):
"\"%s\" = '%s'",
break;
case (MM_UNSET):
"\"%s\" = DEFAULT",
break;
}
}
}
/* Copy local cmd_buf into cmd->cmd_buf */
if (cmd_buf) {
}
if (mm_sql_report_func_attr(cmd)) {
"mm_attribute_cmd_func: "
"error creating helper sql functions");
"error creating helper sql functions");
rc = MM_CMD_ERROR;
goto end;
}
rc = MM_CMD_ERROR;
goto end;
}
/* Function has been created */
/* cmd->cmd_buf contains the command */
/* Send cmd->cmd_buf to the data base */
rc = MM_CMD_ERROR;
goto end;
}
db->mm_db_count);
}
/* Triggers */
error = 0;
if (error == 0 &&
}
}
if (error == 0 &&
}
}
if (error == 0 &&
}
}
if (error == 0 &&
}
}
if (error == 0 &&
}
}
if (error == 0 &&
}
}
if (error == 0 &&
}
}
if (error == 0 &&
}
}
if (error == 0 &&
}
}
if (error == 0 &&
}
}
if (error == 0 &&
}
}
if (error == 0 &&
}
}
if (error == 0 &&
}
}
if (error == 0 &&
}
}
if (error == 0 &&
}
}
if (error == 0 &&
}
}
if (error) {
"info", info,
NULL);
rc = MM_CMD_ERROR;
goto end;
}
/* Create the report and send success */
rc = MM_CMD_DONE;
goto end;
return (MM_CMD_ERROR);
end:
/* Destroy the lists */
/* Set List */
if (cur_set->cmd_set_obj)
if (cur_set->cmd_set_attr)
if (cur_set->cmd_set_value)
cur_set);
}
/* Destroy the Object list */
cur_obj);
}
return (rc);
}
char *
return (cur_set->cmd_set_value);
}
}
return (NULL);
}
/*
* mm_get_set_clause:
* and creates lists that hold all the relevant information
*/
int
{
int rc;
/* For Set and Unset Lists */
/* For the Parse */
/* TEMP create the lists within this function */
/* and destroy them when we are finished */
MMS_PN_CLAUSE, &work);
MMS_PN_CLAUSE, &work)) {
/* Get the Object */
/* Get the Attribute */
/* Get the Value */
/* Add this to the set list */
if (mm_add_set_list(set_list,
"DEFAULT")) {
"mm_get_set_clause: "
"unable to allocate "
"memory for this set");
return (MM_CMD_ERROR);
}
} else {
/* Add this to the set list */
if (mm_add_set_list(set_list,
"mm_get_set_clause: "
"unable to allocate "
"memory for this set");
return (MM_CMD_ERROR);
}
}
/* Add this to the obj list */
(void) mm_add_obj_list(obj_list,
}
}
MMS_PN_CLAUSE, &work);
MMS_PN_CLAUSE, &work)) {
/* Get the Object */
/* Get the Attribute */
/* Add this to the set list */
if (mm_add_set_list(set_list,
NULL)) {
"mm_get_set_clause: "
"unable to allocate "
"memory for this set");
return (MM_CMD_ERROR);
}
/* Add this to the obj list */
(void) mm_add_obj_list(obj_list,
}
}
/* Print both the Set and Unset lists */
rc = 0;
goto end;
rc = 1;
goto end;
end:
return (rc);
}
int
{
cmd->cmd_source_num = 0;
cmd->cmd_dest_num = 0;
return (MM_CMD_DONE);
}
int
{
char *objname;
int rc;
int row;
int rows;
int j;
char *notify_obj = NULL;
int match_off;
char *source_buf_0;
/* Get Dest and Constraints */
} else {
/* TEMP - Trace out our dest info */
}
} else {
/* TEMP - Trace out our const info */
}
/* Look up the type */
/* Set notify object */
}
/* Prepare source[0] */
if (mm_add_char(objname,
&cmd->cmd_source_list)) {
"mm_delete_cmd_func: "
"out of mem creating source list");
"out of mem creating source list");
return (MM_CMD_ERROR);
}
/* Clear cmd_buf */
cmd->cmd_bufsize = 0;
}
/* Generate the final report where sql */
"mm_delete_cmd_func: "
"db error creating helper functions");
return (MM_CMD_ERROR);
}
/* Make path sql for delete */
for (j = 0; j < p_key->mm_att_num; j ++) {
"(\"%s\".\"%s\" in "
"( select \"%s\".\"%s\" from ",
}
}
/* Delete SIDE and SLOT before deleteing CARTRIDGE */
"FROM \"CARTRIDGE\" %s",
goto db_error;
}
"WHERE \"CartridgeID\" = '%s'",
if (path_buf)
goto db_error;
}
"WHERE \"CartridgeID\" = '%s'",
if (path_buf)
goto db_error;
}
}
}
/* Do the notification */
if (notify_obj) {
return (MM_CMD_ERROR);
}
}
/* Get the lirbarynames for delete before */
/* the sql is run */
}
/* do delete in sql */
goto db_error;
}
/* Finish */
int count;
"\"MESSAGE\";") != MM_DB_DATA) {
goto db_error;
}
goto db_error;
}
int count;
"\"REQUEST\" where \"RequestState\" = 'responded';")
!= MM_DB_DATA) {
goto db_error;
}
goto db_error;
}
}
/* Clear cmd_buf */
cmd->cmd_bufsize = 0;
}
return (MM_CMD_DONE);
return (MM_CMD_ERROR);
NULL);
return (MM_CMD_ERROR);
return (MM_CMD_ERROR);
}
/* Check the command's accessmode vs drive capability */
int
{
int count = 0;
int number = 0;
int i;
/* copy accessmodes over */
number = 0;
for (i = 0; i < mode->cmi_num_accessmode; i ++) {
count ++;
number ++;
}
/* append with first mount */
for (i = 0; i < cmd->cmd_mount_info.
cmi_num_firstmount; i ++) {
cmi_firstmount[i]);
number ++;
}
return (number);
}
char *
/* LINTED: mm_wka may be used in the future */
int number_toks = 0;
char *tok_union[CMI_NUM_ACCESSMODE];
int num_default_toks;
int total_toks;
char *tok_group[CMI_NUM_ACCESSMODE];
int tok_group_count = 0;
int i;
int j;
char *return_ptr = NULL;
"mm_check_mode");
number_toks = 0;
} else {
mode);
}
/* Add the bit format tokens to tok_union */
/* If the token already exists, skip */
"select distinct \"DMBITFORMATTOKEN\"."
"\"DMCapabilityToken\" from \"DMBITFORMATTOKEN\" "
"cross join \"DM\" "
"cross join \"PARTITION\" "
"where ("
"(\"DMBITFORMATTOKEN\".\"DriveName\" "
"= \"DM\".\"DriveName\") and "
"(\"DMBITFORMATTOKEN\".\"DMName\" "
"= \"DM\".\"DMName\") and "
"(\"DMBITFORMATTOKEN\".\"DMBitFormatName\" "
"= \"PARTITION\".\"PartitionBitFormat\") and "
"((\"DMBITFORMATTOKEN\".\"DriveName\" = '%s') "
"AND (pg_host_ident(\"DM\".\"DMTargetHost\")"
" = pg_host_ident('%s')) "
"and (\"PARTITION\".\"CartridgeID\" = '%s')));",
cart_id) != MM_DB_DATA) {
"error getting tokens from db");
return_ptr = NULL;
goto end;
}
int write = 1;
for (i = 0; i < number_toks; i ++) {
write = 0;
}
}
if (write) {
number_toks ++;
total_toks ++;
}
}
/* Validate that this drive contains the given tokens */
for (i = 0; i < number_toks; i ++) {
"select distinct \"DMCapabilityToken\" " \
"from good_tok('%s', '%s', '%s');",
return_ptr = NULL;
goto end;
}
if (check_buf)
/* Drive doesn't support this token */
return_ptr = NULL;
goto end;
}
/* Validate that there are not 2 tokens from the same group */
"select distinct \"DMCAPABILITYGROUP\"."
"\"DMCapabilityGroupName\" "
"from \"DMCAPABILITYGROUP\" "
"cross join \"DM\" "
"cross join \"DMCAPABILITYGROUPTOKEN\" "
"cross join \"DRIVE\" "
"where ( "
"(\"DMCAPABILITYGROUP\".\"DMName\" = "
"\"DM\".\"DMName\") "
"and "
"(\"DMCAPABILITYGROUP\".\"DriveName\" = "
"\"DMCAPABILITYGROUPTOKEN\".\"DriveName\") "
"and "
"(\"DMCAPABILITYGROUP\".\"DMName\" = "
"\"DMCAPABILITYGROUPTOKEN\".\"DMName\") "
"and "
"(\"DMCAPABILITYGROUP\"."
"\"DMCapabilityGroupName\" = "
"\"DMCAPABILITYGROUPTOKEN\"."
"\"DMCapabilityGroupName\") "
"and "
"(\"DMCAPABILITYGROUP\".\"DMName\" = "
"\"DM\".\"DMName\") "
"and "
"(\"DM\".\"DriveName\" = \"DRIVE\".\"DriveName\") "
"and "
"( "
"(pg_host_ident(\"DM\".\"DMTargetHost\") "
"= pg_host_ident('%s')) "
"AND (\"DMCAPABILITYGROUPTOKEN\"."
"\"DMCapabilityToken\" = '%s') AND "
"(\"DRIVE\".\"DriveName\" = '%s')));",
tok_union[i],
drive) != MM_DB_DATA) {
return_ptr = NULL;
goto end;
}
tok_union[i]);
goto bad_group;
}
for (j = 0; j < tok_group_count; j ++) {
tok_group[j]) == 0) {
/* already have this group */
"Duplication token %s for group %s",
tok_union[i],
tok_group[j]);
goto bad_group;
}
}
tok_group_count ++;
}
for (j = 0; j < tok_group_count; j ++) {
if (tok_group[j])
}
tok_group_count = 0;
"select distinct \"DMCapabilityGroupDefaultName\" "\
"from \"DMCAPABILITYGROUP\" "\
"where \"DriveName\" = '%s'",
drive);
for (i = 0; i < number_toks; i ++) {
"and \"DMCapabilityGroupName\" not in " \
"(select \"DMCapabilityGroupName\" " \
"from \"DMCAPABILITYGROUPTOKEN\" " \
" where \"DriveName\" = '%s' and " \
"\"DMCapabilityToken\" = '%s')",
}
/* Error */
return_ptr = NULL;
goto end;
}
for (i = 0; i < num_default_toks; i++) {
total_toks ++;
}
/* Now Check the access mode */
"select distinct \"DMCapabilityName\" "
"from \"DMCAPABILITYTOKEN\" "
"where \"DriveName\" "
"in (select \"DriveName\" from \"DM\" where "
"pg_host_ident(\"DMTargetHost\") = "
"pg_host_ident('%s') and \"DriveName\" = '%s') "
"and \"DMCapabilityName\" in ",
drive);
for (i = 0; i < total_toks - 2; i ++) {
"(select \"DMCapabilityName\" "\
"from \"DMCAPABILITYTOKEN\" " \
" where \"DMCapabilityName\" in ");
}
"(select \"DMCapabilityName\" "\
"from \"DMCAPABILITYTOKEN\" where "\
"\"DMCapabilityToken\" = '%s')",
tok_union[0]);
"and \"DMCapabilityToken\" = '%s')",
tok_union[i]);
}
"and \"DMCapabilityToken\" = '%s';",
/* Error */
return_ptr = NULL;
goto end;
}
"GET DEFAULT TOKENS FAILED!! "
}
/* Drive Doesn't support this mode */
return_ptr = NULL;
goto end;
/* Bad DMConfig */
return_ptr = NULL;
goto end;
}
/* Set cmid_capability */
}
mm_db_results, 0, 0));
for (i = 0; i < total_toks; i ++) {
}
goto end;
return (NULL);
for (j = 0; j < tok_group_count; j ++) {
if (tok_group[j])
}
for (int j = 0; j < tok_group_count; j ++) {
if (tok_group[j])
}
return (NULL);
end:
for (int j = 0; j < tok_group_count; j ++) {
if (tok_group[j])
}
for (int j = 0; j < total_toks; j ++) {
if (tok_union[j])
}
return (return_ptr);
}
int
{
/* Make sure there are no outstanding commands */
/* If the command is ablocked mount, cancel the mount */
/* Delay dispatch of the final success until all commands */
/* have completed */
/* Dont accept any more commands from this wka */
/* lock queue and run thorugh the list */
(cur_cmd->cmd_remove == 0)) {
/* If this command is a blocked mount, then cancel */
/* is blocked, cancel it */
/* If not, wait for it to finish */
"select \"TaskState\" from \"TASK\" where"
" \"TaskID\" = '%s';",
"Error determining "
continue;
}
"row mismatch getting task info");
continue;
}
/* send a cancel and set this */
/* command for remove */
"blocked") == 0) {
/* This task is blocked, */
/* cancel it now */
"this task is blocked, "
"sending cancel");
"delete from \"TASK\" where"
"\"TaskID\" = '%s';",
"Error removing "
"TASK object");
}
}
}
}
}
"Check outstanding commands");
/* lock queue and run thorugh the list */
(cur_cmd->cmd_remove == 0)) {
/* Same wka && */
/* not this command && */
/* The command is not being removed */
"this client has outstanding commands "
"which must finish before goodbye");
return (MM_WORK_TODO);
}
}
/* Send Success */
return (MM_CMD_DONE);
return (MM_CMD_ERROR);
}
{
}
return (mm_wka->wka_privilege);
return (mm_wka->wka_privilege);
}
int
char *cartridge_type;
int side;
int sides;
if (cartridge_id == NULL) {
"mm_create_side passed null cartridge_id");
return (MM_CMD_ERROR);
}
"\"CartridgeTypeName\" FROM "\
"\"CARTRIDGE\" WHERE "
"\"CartridgeID\" = '%s'",
cartridge_id) != MM_DB_DATA ||
NULL) {
return (MM_CMD_ERROR);
}
"\"CartridgeTypeNumberSides\" "
"FROM \"CARTRIDGETYPE\" WHERE "\
"\"CartridgeTypeName\" = '%s'",
cartridge_type) != MM_DB_DATA ||
return (MM_CMD_ERROR);
}
"\"Side%dName\" FROM "
"\"CARTRIDGETYPE\" WHERE "
"\"CartridgeTypeName\" = '%s'",
MM_DB_DATA &&
return (MM_CMD_ERROR);
}
"\"SIDE\" (\"CartridgeID\", "
"\"SideName\") VALUES "
"('%s', '%s')", cartridge_id,
PQgetvalue(results, 0, 0)) !=
MM_DB_OK) {
return (MM_CMD_ERROR);
}
}
return (MM_CMD_DONE);
}
int
{
"select \"SlotTypeName\" "
"from \"SLOTTYPE\" where "
"\"SlotTypeName\" = '%s';",
library_type) != MM_DB_DATA) {
goto db_error;
}
/* A slot type for this library already exists */
return (MM_CMD_DONE);
}
"insert into \"SLOTTYPE\" "
"(\"SlotTypeName\", "
"\"CartridgeShapeName\") "
"values('%s', '%s%s');",
"-generic") != MM_DB_OK) {
goto db_error;
}
return (MM_CMD_DONE);
return (MM_CMD_ERROR);
}
int
{
int side;
int sides;
char sidename[20];
"SELECT \"CartridgeTypeNumberSides\" " \
"FROM "
"\"CARTRIDGETYPE\" WHERE " \
"\"CartridgeTypeName\" = '%s'",
cartridge_type) != MM_DB_DATA) {
return (MM_CMD_ERROR);
}
sidename) !=
MM_DB_OK) {
return (MM_CMD_ERROR);
}
"SET \"%s\" = 'side %d' WHERE "
"\"CartridgeTypeName\" = '%s'",
MM_DB_OK) {
return (MM_CMD_ERROR);
}
}
return (MM_CMD_DONE);
}
int
{
int rc;
char *part_cart_id = NULL;
/* Type Clause */
/* For Set and Unset Lists */
int command_added = 0;
int first = 1;
/* First get the type clause */
/* Create the Set and Unset Struct Lists */
/* Build the lists after parsing the clauses */
"mm_create_cmd_func: "
"error building structs from set clause");
"error building structs from set clause");
rc = MM_CMD_ERROR;
goto end;
}
/* Check if the creating attribtues is allowed */
/* Check if the attributes may be created */
if (mm_db_create_attribute(db,
cur_set->cmd_set_attr) !=
MM_DB_OK) {
"failed for %s.%s",
rc = MM_CMD_ERROR;
goto end;
}
/* Check if the attributes may be modified */
cur_set->cmd_set_attr)) {
/* check_helper sets the correct error */
/* Send and remove */
rc = MM_CMD_ERROR;
goto end;
}
}
/* Do any special permission checks here */
char *LibraryName = NULL;
/* For PARTITION get CartridgeID using libname and pcl */
char *CartridgePCL = NULL;
"CartridgePCL");
if (CartridgePCL == NULL) {
"a CartridgePCL");
"invalid",
"EOBJCREATESYSATTRREQUIRED",
NULL);
rc = MM_CMD_ERROR;
goto end;
}
"LibraryName");
if (LibraryName == NULL) {
"a LibraryName");
"invalid",
"EOBJCREATESYSATTRREQUIRED",
NULL);
rc = MM_CMD_ERROR;
goto end;
}
/* For a non-priv client, */
/* check the user's CARTRIDGEGROUPAPPLICATION */
"select distinct "
"\"CARTRIDGEGROUPAPPLICATION\".* "
"from \"CARTRIDGEGROUPAPPLICATION\" "
"cross join \"CARTRIDGE\" where ("
"(\"CARTRIDGEGROUPAPPLICATION\"."
"\"CartridgeGroupName\" = "
"\"CARTRIDGE\".\"CartridgeGroupName\") "
"and ("
"(\"CARTRIDGE\".\"CartridgePCL\" "
"= '%s') AND "
"(\"CARTRIDGEGROUPAPPLICATION\"."
"\"ApplicationName\" = '%s') AND "
"(\"CARTRIDGE\".\"LibraryName\" = '%s')));",
mm_wka->
LibraryName) != MM_DB_DATA) {
rc = MM_CMD_ERROR;
goto end;
}
"Missing a CARTRIDGEGROUPAPPLICATION, "
"%s",
mm_wka->
"explicit",
"EAPPCARTNOACC",
"client",
"pcl",
NULL);
rc = MM_CMD_ERROR;
goto end;
}
}
/* Get the cartridgeID */
"select \"CartridgeID\" from "
"\"CARTRIDGE\" where "
"(\"CARTRIDGE\".\"CartridgePCL\" "
" = '%s') and "
"(\"CARTRIDGE\".\"LibraryName\" "
" = '%s');",
LibraryName) != MM_DB_DATA) {
rc = MM_CMD_ERROR;
goto end;
}
"Error getting CartridgeID from DB");
"Error getting CartridgeID from DB");
rc = MM_CMD_ERROR;
goto end;
}
}
/* Construct the SQL command */
/* List the attributes */
if (first) {
/* Skip comma on first */
first = 0;
} else {
/* need commma */
}
}
"CARTRIDGE") == 0) ||
"PARTITION") == 0)) {
/* Obj is cartridge, add CartridgeID */
}
/* List the values */
first = 1;
if (first) {
/* Skip comma on first */
first = 0;
} else {
/* need commma */
}
}
"CARTRIDGE") == 0) {
/* Obj is cartridge, add CartridgeID */
"PARTITION") == 0) {
/* cartridge_id should be set above */
if (part_cart_id != NULL) {
", \'%s'", part_cart_id);
} else {
"Error finding part_cart_id");
"Error finding part_cart_id");
rc = MM_CMD_ERROR;
goto end;
}
}
/* Copy local cmd_buf into cmd->cmd_buf */
if (cmd_buf) {
}
/* Send cmd->cmd_buf to the data base */
rc = MM_CMD_ERROR;
goto end;
}
/* Create any additional objects */
/* New Cartridge */
cartridge_id) == MM_CMD_ERROR) {
rc = MM_CMD_ERROR;
goto end;
}
"CARTRIDGETYPE") == 0) {
char *cartridge_type = NULL;
/* New Cartridge Type */
"CartridgeTypeName");
if (cartridge_type == NULL) {
rc = MM_CMD_ERROR;
goto end;
}
cartridge_type) == MM_CMD_ERROR) {
rc = MM_CMD_ERROR;
goto end;
}
}
/* Do event notification */
char *DMTargetHost = NULL;
/* Notification for new DM */
"DMName");
rc = MM_CMD_ERROR;
/* New Error codes for this?? */
goto not_found;
}
"DMTargetHost");
rc = MM_CMD_ERROR;
/* New Error codes for this?? */
goto not_found;
}
"DM",
DMTargetHost)) {
"mm_create_cmd_func: "
"error adding config event");
}
char *LMTargetHost = NULL;
/* Notification for new LM */
"LMName");
rc = MM_CMD_ERROR;
/* New Error codes for this?? */
goto not_found;
}
"LMTargetHost");
rc = MM_CMD_ERROR;
/* New Error codes for this?? */
goto not_found;
}
"LM",
LMTargetHost)) {
"mm_create_cmd_func: "
"error adding config event");
}
char *LibraryName = NULL;
"DriveName");
rc = MM_CMD_ERROR;
/* New Error codes for this?? */
goto not_found;
}
"LibraryName");
if (LibraryName == NULL) {
rc = MM_CMD_ERROR;
/* New Error codes for this?? */
goto not_found;
}
/* Notification for new DRIVE */
cmd,
/* Add LMP scan command for this drive */
NULL, LibraryName)) {
"Error adding LMP scan, LM may not be connected");
} else {
"Added a LMP scan");
command_added = 1;
}
char *CartridgePCL = NULL;
char *LibraryName = NULL;
"CartridgePCL");
if (CartridgePCL == NULL) {
rc = MM_CMD_ERROR;
/* New Error codes for this?? */
goto not_found;
}
"LibraryName");
if (LibraryName == NULL) {
rc = MM_CMD_ERROR;
/* New Error codes for this?? */
goto not_found;
}
/* Notification for new CARTRIDGE */
cmd,
/* Add LMP scan command for this cartridge */
CartridgePCL, LibraryName)) {
"Error adding LMP scan");
} else {
"Added a LMP scan");
command_added = 1;
}
char *LibraryName = NULL;
"LibraryName");
if (LibraryName == NULL) {
rc = MM_CMD_ERROR;
/* New Error codes for this?? */
goto not_found;
}
cmd,
}
/* Trace a info summary */
"%s created by %s %s",
conn->cci_instance);
}
/* Create the report and send success */
if (command_added) {
} else {
rc = MM_CMD_DONE;
}
goto end;
return (MM_CMD_ERROR);
NULL);
rc = MM_CMD_ERROR;
goto end;
end:
/* Destroy the lists */
/* Set List */
if (cur_set->cmd_set_obj)
if (cur_set->cmd_set_attr)
if (cur_set->cmd_set_value)
cur_set);
}
if (part_cart_id != NULL)
return (rc);
}
/*
* mm_get_task:
* returns allocated char*, caller must free
*/
char *
{
char *task;
"mm_get_task couldn't find a task clause");
return (NULL);
}
"mm_get_task couldn't find the task string");
return (NULL);
}
"mm_get_task, task sting is null");
return (NULL);
}
return (task);
}
int
{
char *reqid;
int messageid = 1001;
char *text = "unattened";
char *buf;
int rc;
int i;
/*
* SYSTEM.AttendanceMode was changed, respond to requests
* if unattended mode.
*/
/* get mm operator attandance mode */
"from \"SYSTEM\";") != MM_DB_DATA) {
return (1);
}
return (1);
}
if (rc == 0) {
return (0);
}
/* respond to all outstanding requests */
"where \"RequestState\" != 'responded';") != MM_DB_DATA) {
return (1);
}
return (0); /* zero unfinished requests */
}
/* set requests to responded */
"\"RequestState\" = 'responded',"
"\"RequestTimeResponded\" = now(),"
"\"ResponseManufacturer\" = '%s',"
"\"ResponseModel\" = '%s',"
"\"ResponseNumber\" = '%d',"
"\"ResponseText\" = $$%s$$,"
"\"AcceptingClient\" = '%s',"
"\"AcceptingInstance\" = '%s',"
"\"AcceptingSessionID\" = default,"
"\"RequestTimeAccepted\" = now() "
"where \"RequestID\" = '%s';",
return (1);
}
continue;
}
/* respond to request commands with unattended */
break;
}
}
/* mm will clean this req up at client disconnect */
continue;
}
"text[\"%d\" \"reply\" \"%s\"];",
if (mm_has_depend(cmd_p)) {
}
/*
* Command queue tick so cmd_depend is valid.
*/
rc = 0;
} else {
}
}
/* resize request history */
if (mm_request_history_limit(db)) {
return (1);
}
return (0);
return (1);
}
int
{
int messageid = 1001;
char *text = "unattened";
char *buf;
int rc;
/*
* Attendance mode for mm request
*/
/* get mm operator attandance mode */
"from \"SYSTEM\";") != MM_DB_DATA) {
return (-1);
}
"text",
"no results in attendance mode query",
NULL);
return (-1);
}
if (rc == 0) {
return (0);
}
/* set request to responded */
"\"RequestState\" = 'responded',"
"\"RequestTimeResponded\" = now(),"
"\"ResponseManufacturer\" = '%s',"
"\"ResponseModel\" = '%s',"
"\"ResponseNumber\" = '%d',"
"\"ResponseText\" = $$%s$$,"
"\"AcceptingClient\" = '%s',"
"\"AcceptingInstance\" = '%s',"
"\"AcceptingSessionID\" = default,"
"\"RequestTimeAccepted\" = now() "
"where \"RequestID\" = '%s';",
return (-1);
}
"text",
"set request unattended count not 1",
NULL);
return (-1);
}
/* resize request history */
if (mm_request_history_limit(db)) {
NULL);
return (-1);
}
/* tell mm we're unattened */
"text[\"%d\" \"reply\" \"%s\"];",
return (1);
return (-1);
}
int
int messageid, ...)
{
char *text;
char *task_taskid = NULL;
int rows;
int rc;
/*
* The mm is requesting operator intervention
*/
"\"task\" \"%s\" \"priority\" \"%d\" "
"\"messageid\" \"%d\" \"locstr\" \"%s\";",
/* get requestid */
/* set command reqid */
/*
* Make internal mm request entry
*/
/* mm can have but does not need a valid task.taskid */
if (task == MM_NO_TASK) {
/* no task.taskid */
} else {
/* validate task.taskid */
cmd->cmd_response =
return (1);
}
if (rows != 1) {
if (rows == 0) {
NULL);
} else {
NULL);
}
cmd->cmd_response =
return (1);
}
}
"(\"RequestID\",\"RequestingTaskID\","
"\"RequestingClient\",\"RequestingInstance\","
"\"RequestingClientType\",\"RequestPriority\","
"\"RequestManufacturer\",\"RequestModel\","
"\"RequestNumber\",\"RequestText\",\"RequestHost\") "
"values ('%s',%s,'%s','%s','%s','%d',"
"'%s','%s','%d',$$%s$$,'%s');",
text,
data->mm_host_name);
return (1);
}
/* mm operator attendance mode */
/*
* Command queue tick so cmd_depend is valid.
*/
if (rc == 1) {
rc = 0; /* unattended */
} else {
}
return (rc);
}
return (0);
}
int
{
if (reqid[0] == (char)0) {
return (0); /* no request */
}
"\"RequestID\" = '%s' and \"RequestState\" != 'responded';",
return (1);
}
return (0);
}
int
{
int messageid = 1001;
char *text = "unattened";
char *buf;
int rc;
/*
* Attendance mode for device manager request
*/
/* get mm operator attandance mode */
"from \"SYSTEM\";") != MM_DB_DATA) {
return (MM_CMD_ERROR);
}
"too many rows returned "
"getting SYSTEM.AttendanveMode");
return (MM_CMD_ERROR);
}
if (rc == 0) {
return (MM_WORK_TODO);
}
/* set request to responded */
"\"RequestState\" = 'responded',"
"\"RequestTimeResponded\" = now(),"
"\"ResponseManufacturer\" = '%s',"
"\"ResponseModel\" = '%s',"
"\"ResponseNumber\" = '%d',"
"\"ResponseText\" = $$%s$$,"
"\"AcceptingClient\" = '%s',"
"\"AcceptingInstance\" = '%s',"
"\"AcceptingSessionID\" = default,"
"\"RequestTimeAccepted\" = now() "
"where \"RequestID\" = '%s';",
return (MM_CMD_ERROR);
}
"failed to correctly "
"update request object");
return (MM_CMD_ERROR);
}
/* resize request history */
if (mm_request_history_limit(db)) {
NULL);
return (MM_CMD_ERROR);
}
/* tell device manager we're unattened */
"text[\"%d\" \"reply\" \"%s\"];",
return (MM_CMD_DONE);
return (MM_CMD_ERROR);
}
void
{
/*
* taskid is mm command which cause the request,
* find the mm command in the command queue which
* contains the mm task.taskid.
*/
continue;
/* find parent command */
/* this maybe be our task.taskid */
}
break;
}
}
return;
}
return;
}
return;
}
}
int
{
int priority;
char *obj;
char *attr;
int rc;
/*
* Device manager or mmp client is requesting operator intervention
*/
/*
* find optional task.taskid for device manager
*/
"text",
"mission task.taskid for device manager",
NULL);
return (MM_CMD_ERROR);
}
"find task.taskid by message-clause argument");
/*
* reserved request message-clause arg-key word:
* tasktaskid - mm command taskid
*/
&taskid);
break;
}
}
}
/*
* If one and only one task for a device manager exists then
* assign it to the request object.
*/
obj = "TASKDRIVE";
attr = "DriveName";
} else {
obj = "TASKLIBRARY";
attr = "LibraryName";
}
"from \"TASK\",\"%s\" where "
"\"TASK\".\"TaskID\" = \"%s\".\"TaskID\" and "
return (MM_CMD_ERROR);
}
}
}
}
if (taskid) {
"'%s'", taskid);
} else {
}
/*
* Make request entry
*/
"(\"RequestID\",\"RequestingTaskID\","
"\"RequestingClient\",\"RequestingInstance\","
"\"RequestingConnectionID\",\"RequestingClientType\","
"\"RequestPriority\",\"RequestManufacturer\","
"\"RequestModel\",\"RequestNumber\","
"\"RequestText\",\"RequestHost\") "
"values ('%s',%s,'%s','%s','%s','%s','%d',"
"'%s','%s','%d',$$%s$$,'%s');",
return (MM_CMD_ERROR);
}
/* set command reqid */
/* mm operator attendance mode */
return (rc);
}
return (MM_WORK_TODO);
NULL);
return (MM_CMD_ERROR);
return (MM_CMD_ERROR);
}
int
{
/*
* Cleanup disconnected client requests
*/
/*
* Release all requests accepted by this operator
*/
"\"AcceptingClient\" = default,"
"\"AcceptingInstance\" = default,"
"\"AcceptingSessionID\" = default,"
"\"RequestTimeAccepted\" = default,"
"\"RequestState\" = 'pending' "
"where \"AcceptingSessionID\" = '%s' "
"and \"RequestState\" != 'responded';",
return (1);
}
}
/*
* Remove all requests generated by this device manager
* or mmp client.
*/
"\"RequestingClient\" = '%s' and "
"\"RequestingInstance\" = '%s' and "
"\"RequestState\" != 'responded' and "
"\"RequestingConnectionID\" = '%s';",
return (1);
}
return (0);
}
int
{
char *buf;
const char *query;
/*
* Find requests state info for the accept and release commands
*/
/* get requests */
"mm_get_requests: "
"out of mem creating source list");
"out of mem creating source list");
return (MM_CMD_ERROR);
}
query = "select \"REQUEST\".\"RequestID\","
"\"REQUEST\".\"RequestState\","
"\"REQUEST\".\"AcceptingSessionID\" from ";
"mm_get_requests: "
"db error creating helper functions");
return (MM_CMD_ERROR);
}
MMS_PN_CLAUSE, NULL)) {
query = "(\"REQUEST\".\"RequestID\" = '%s')";
}
}
query = "select \"REQUEST\".\"RequestID\","
"\"REQUEST\".\"RequestState\","
"\"REQUEST\".\"AcceptingSessionID\" from "
"\"REQUEST\" where (%s) ";
} else {
NULL);
return (MM_CMD_ERROR);
}
return (MM_CMD_ERROR);
}
/* check request count */
MMS_PN_CLAUSE, NULL)) {
NULL);
} else {
NULL);
}
return (MM_CMD_ERROR);
}
/* caller frees tuples */
return (0);
NULL);
return (MM_CMD_ERROR);
return (MM_CMD_ERROR);
}
int
{
int rc;
int error;
int i;
char *state;
char *buf;
char *more;
return (MM_CMD_ERROR);
}
/*
* Operator wants to work on device manager or mm requests
*/
return (rc);
}
/* check for pending requests */
error = 0;
error = 1;
error = 1;
}
if (error) {
return (MM_CMD_ERROR);
}
}
/* accept selected requests */
"\"AcceptingClient\" = '%s',"
"\"AcceptingInstance\" = '%s',"
"\"AcceptingSessionID\" = '%s',"
"\"RequestState\" = 'accepted',"
"\"RequestTimeAccepted\" = now() where ",
more = "or ";
more = ";";
}
}
NULL);
return (MM_CMD_ERROR);
}
/* get report */
return (MM_CMD_DONE);
NULL);
return (MM_CMD_ERROR);
return (MM_CMD_ERROR);
}
int
{
char *reqid;
char *state;
char *session;
int messageid = 1000;
char *buf;
/*
* Operator finished device manager, mm or app request
*/
/* get request response message */
"failed to parse request response");
return (MM_CMD_ERROR);
}
/* validate client request response */
"\"AcceptingSessionID\" from \"REQUEST\" where "
return (MM_CMD_ERROR);
}
NULL);
return (MM_CMD_ERROR);
}
return (MM_CMD_ERROR);
}
return (MM_CMD_ERROR);
}
return (MM_CMD_ERROR);
}
/* set request to responded */
"\"RequestState\" = 'responded',"
"\"RequestTimeResponded\" = now(),"
"\"ResponseManufacturer\" = '%s',"
"\"ResponseModel\" = '%s',"
"\"ResponseNumber\" = '%d',"
"\"ResponseText\" = $$%s$$,"
"\"AcceptingSessionID\" = default where "
"\"RequestID\" = '%s' and "
"\"AcceptingSessionID\" = '%s';",
NULL);
return (MM_CMD_ERROR);
}
/* resize request history */
if (mm_request_history_limit(db)) {
NULL);
return (MM_CMD_ERROR);
}
/* find device manager command that generated request */
break;
}
}
if (cmd_p) {
/* send device manager, mm or app request response */
"text[\"%d\" \"reply\" \"%s\"];",
if (mm_has_depend(cmd_p)) {
}
} else {
}
}
NULL);
return (MM_CMD_ERROR);
}
return (MM_CMD_DONE);
NULL);
return (MM_CMD_ERROR);
return (MM_CMD_ERROR);
}
/* Change request history size and do repairs if required. */
int
{
int limit;
int count;
int actual_count;
"\"SystemRequestCount\" from \"SYSTEM\";") != MM_DB_DATA) {
return (1);
}
"from \"REQUEST\" "
"where \"RequestState\" = 'responded';") != MM_DB_DATA) {
return (1);
}
if (count != actual_count) {
}
/* limit could be zero which means the request history is off */
/* delete oldest responded to request from request history */
"where \"RequestID\" = (select \"RequestID\" "
"from \"REQUEST\" where \"RequestState\" = 'responded' "
"order by \"RequestTimeResponded\" "
"limit 1);") != MM_DB_OK) {
return (1);
}
return (1);
}
count--;
}
if (count < 0) {
count = 0;
}
return (1);
}
return (0);
}
int
{
int rc;
int error;
int i;
char *state;
char *session;
char *buf;
char *more;
/*
* Release requests accepted by this operator
*/
return (rc);
}
/* check for this session's accepted requests */
error = 0;
/*
* A system privileged client can release any
* request accepted by any client.
*/
/*
* An admin privileged client can only
* release their accepeted requests.
*/
session) != 0) {
error = 1;
}
}
} else {
error = 1;
}
if (error) {
return (MM_CMD_ERROR);
}
}
/* set request state to pending */
"\"AcceptingClient\" = default,"
"\"AcceptingInstance\" = default,"
"\"AcceptingSessionID\" = default,"
"\"RequestState\" = 'pending',"
"\"RequestTimeAccepted\" = default where ");
more = "or ";
more = ";";
}
}
NULL);
return (MM_CMD_ERROR);
}
/* get report */
return (MM_CMD_DONE);
NULL);
return (MM_CMD_ERROR);
return (MM_CMD_ERROR);
}
int
{
char *reqid;
char *req_cid;
char *reqstate;
char *query;
char *constraint;
"mm_cancel_cmd_func: "
"out of mem creating source list");
"out of mem creating source list");
return (MM_CMD_ERROR);
}
query = "select distinct \"REQUEST\".\"RequestID\","
"\"REQUEST\".\"RequestingConnectionID\","
"\"REQUEST\".\"RequestState\" from ";
"mm_cancel_cmd_func: "
"db error creating helper functions");
return (MM_CMD_ERROR);
}
constraint = "and (\"REQUEST\".\"RequestingClientType\" = 'AI')";
return (MM_CMD_ERROR);
}
return (MM_CMD_ERROR);
return (MM_CMD_ERROR);
}
return (MM_CMD_ERROR);
return (MM_CMD_ERROR);
}
}
/* is this a command we know how to cancel */
"request") == 0) {
}
break;
}
}
/* command not found */
return (MM_CMD_ERROR);
}
/* cancel command */
return (MM_CMD_ERROR);
}
} else {
return (MM_CMD_ERROR);
}
/* send cancelled command's final-command response */
/* send cancelled command response */
break;
}
}
/* same command not found or error sending cancelled response */
"same command not found or "
"error sending cancelled response");
return (MM_CMD_ERROR);
}
return (MM_CMD_DONE);
NULL);
return (MM_CMD_ERROR);
return (MM_CMD_ERROR);
}
int
{
const char *response;
response = "response task[\"%s\"] success "
"text [\"ConnectionID\" \"%s\" "
"\"SessionID\" \"%s\"];";
return (MM_CMD_DONE);
return (MM_CMD_ERROR);
}
int
{
char *to;
}
/* to wka found */
break;
}
}
NULL);
return (MM_CMD_ERROR);
}
" from %s - %s %s\n"
" to %s - %s %s",
return (MM_CMD_DONE);
NULL);
return (MM_CMD_ERROR);
return (MM_CMD_ERROR);
}
int
{
char *oldpassword = NULL;
char *clientname = NULL;
char *pass;
int error;
MMS_PN_CLAUSE, NULL)) {
"select \"Password\" from \"MMPASSWORD\" where "
"\"ApplicationName\" = '%s';",
clientname) != MM_DB_DATA) {
return (MM_CMD_ERROR);
}
return (MM_CMD_ERROR);
}
"select mm_func_getpassword('%s');",
oldpassword) != MM_DB_DATA) {
return (MM_CMD_ERROR);
}
return (MM_CMD_ERROR);
}
/* compare password hashes */
NULL);
return (MM_CMD_ERROR);
}
MMS_PN_CLAUSE, NULL)) {
return (MM_CMD_ERROR);
}
} else {
goto not_found;
}
"update \"MMPASSWORD\" set \"Password\" = '%s' "
"where \"ApplicationName\" = '%s';",
return (MM_CMD_ERROR);
}
return (MM_CMD_ERROR);
}
error = 0;
error = 1;
password)) {
error = 1;
} else {
(void) smf_refresh_instance(MMS_CFG_WCR_INST);
}
}
if (pass)
if (error) {
"file", MMS_NET_CFG_HELLO_FILE,
NULL);
return (MM_CMD_ERROR);
}
}
return (MM_CMD_DONE);
NULL);
return (MM_CMD_ERROR);
return (MM_CMD_ERROR);
}