perfectly under saber C. Worth saving a copy I think...
* see the file mit-copyright.h
*/
-#include "mit-copyright.h"
-#include "allmaint.h"
-#include "globals.h"
-#include "infodefs.h"
-
#include <stdio.h>
#include <strings.h>
#include <sms.h>
#include <menu.h>
+#include "mit-copyright.h"
+#include "allmaint.h"
+#include "allmaint_funcs.h"
+#include "globals.h"
+#include "infodefs.h"
+
#define FS_ALIAS_TYPE "FILESYS"
-#define FS_NAME 0
-#define FS_TYPE 1
-#define FS_MACHINE 2
-#define FS_PACK 3
-#define FS_M_POINT 4
-#define FS_ACCESS 5
-#define FS_COMMENTS 6
-#define FS_OWNER 7
-#define FS_OWNERS 8
-#define FS_CREATE 9
-#define FS_L_TYPE 10
-#define FS_MODTIME 11
-#define FS_MODBY 12
-#define FS_MODWITH 13
-
-#define FS_LABEL 14
-/* FS_MACHINE already defined, this is okay, as there is no overlap. */
-#define FS_GROUP 15
+#define LABEL 0
+#define MACHINE 1
+#define GROUP 2
+#define ALIAS 3
/* Function Name: GetFSInfo
* Description: Stores the info in a queue.
char * args[2];
switch (type) {
- case FS_LABEL:
+ case LABEL:
if ( (stat = sms_query("get_filesys_by_label", 1, &name,
StoreInfo, &elem)) != 0) {
- com_err(whoami, stat, NULL);
+ com_err(program_name, stat, NULL);
return(NULL);
}
break;
- case FS_MACHINE:
- if ( (stat = sms_query("get_filesys_by_label", 1, &name,
+ case MACHINE:
+ if ( (stat = sms_query("get_filesys_by_machine", 1, &name,
StoreInfo, &elem)) != 0) {
- com_err(whoami, stat, NULL);
+ com_err(program_name, stat, NULL);
return(NULL);
}
break;
- case FS_GROUP:
- if ( (stat = sms_query("get_filesys_by_label", 1, &name,
+ case GROUP:
+ if ( (stat = sms_query("get_filesys_by_group", 1, &name,
StoreInfo, &elem)) != 0) {
- com_err(whoami, stat, NULL);
+ com_err(program_name, stat, NULL);
return(NULL);
}
break;
- case FS_ALIAS:
+ case ALIAS:
args[0] = name;
args[1] = FS_ALIAS_TYPE;
if ( (stat = sms_query("get_alias", 2, args, StoreInfo, &elem)) != 0) {
- com_err(whoami, stat, " in get_alias.");
+ com_err(program_name, stat, " in get_alias.");
return(NULL);
}
}
* Returns: none.
*/
-PrintFSInfo(info);
+void
+PrintFSInfo(info)
char ** info;
{
char print_buf[BUFSIZ];
struct qelem * local = elem;
while(local != NULL) {
- char ** info = (char **) local->q_date;
+ char ** info = (char **) local->q_data;
PrintFSInfo(info);
- local = local->next;
+ local = local->q_forw;
}
}
* Returns: none.
*/
-void
-AskFSInfo(info, flags);
+char **
+AskFSInfo(info, name)
char ** info;
Bool name;
{
- char * temp_buf, *newname;
- char *ret_args[100];
- int counter;
+ char temp_buf[BUFSIZ], *newname;
- sprintf(temp_buf,"\nChanging Attributes of user %s.\n",info[NAME]);
+ sprintf(temp_buf, "\nChanging Attributes of user %s.\n", info[FS_NAME]);
Put_message(temp_buf);
if (name) {
{
struct qelem *elem;
- elem = GetFSInfo(); /* get info. */
+ elem = GetFSInfo(LABEL, argv[1]); /* get info. */
PrintAllFSInfo(elem); /* print it all. */
FreeQueue(elem); /* clean the queue. */
return (DM_NORMAL);
int argc;
char **argv;
{
- int stat, answer, delete, number;
+ int stat, answer, delete;
+ Bool one_filsys;
struct qelem *elem, *temp_elem;
- if ( (temp_elem = elem = GetFSInfo(FS_LABEL, argv[1],
- (char *) NULL) ) == NULL ) /* get info. */
+ if ( (temp_elem = elem = GetFSInfo(LABEL, argv[1])) ==
+ (struct qelem *) NULL )
return(DM_NORMAL);
/*
* 1) If there is no (zero) match then we exit immediately.
* about each one, and delete on yes only, and about if the user hits
* quit.
*/
- number = QueueCount(elem);
+ one_filsys = (QueueCount(elem) == 1);
while (temp_elem != NULL) {
char **info = (char **) temp_elem->q_data;
- if (number != 1) {
+ if (one_filsys) {
PrintFSInfo(info);
answer = YesNoQuitQuestion("\nDelete this filesys?", FALSE);
}
else
delete =
- Confirm("Are you sure that you want to delete this filsystem."))
+ Confirm("Are you sure that you want to delete this filsystem.");
/*
* Deletetions are performed if the user hits 'y' on a list of multiple
* filesystem, or if the user confirms on a unique alias.
*/
if (delete) {
- if ( (status = sms_query("delete_filesys", 1,
- &name, NullFunc, NULL)) != 0)
- com_err(whoami, stat, " filesystem not deleted.");
+ if ( (stat = sms_query("delete_filesys", 1,
+ &info[FS_NAME], Scream, NULL)) != 0)
+ com_err(program_name, stat, " filesystem not deleted.");
else
Put_message("Filesystem deleted.");
}
else
Put_message("Filesystem not deleted.");
- temp_elem = temp_elem->next;
+ temp_elem = temp_elem->q_forw;
}
FreeQueue(elem); /* free all members of the queue. */
char **argv;
int argc;
{
- FS_info *info;
- struct qelem * elem, temp_elem;
+ struct qelem *elem, *temp_elem;
int update, stat, answer;
+ Bool one_filsys;
+ char buf[BUFSIZ];
- elem = temp_elem = GetFSInfo(FS_LABEL, argv[1], (char *) NULL);
+ elem = temp_elem = GetFSInfo(LABEL, argv[1]);
/*
* This uses the same basic method as the deletion routine above.
*/
- number = QueueCount(elem);
+ one_filsys = (QueueCount(elem) == 1);
while (temp_elem != NULL) {
char ** info = (char **) temp_elem->q_data;
- if (number != 1) {
+ if (one_filsys) {
sprintf(buf, "%s %s %s (y/n/q)? ", "Would you like to change the",
"information about the filesystem:",
info[FS_NAME]);
answer = YesNoQuitQuestion(buf, FALSE);
switch(answer) {
case TRUE:
- update = TRUE
+ update = TRUE;
break;
case FALSE:
- upadate = FALSE;
+ update = FALSE;
break;
default:
Put_message("Aborting Operation.");
update = TRUE;
if (update) {
- char * args;
- args = AskFSInfo(info, TRUE);
- if ( (stat = sms_query("update_filesys", num_args,
+ char ** args = AskFSInfo(info, TRUE);
+ if ( (stat = sms_query("update_filesys", CountArgs(args),
args, NullFunc, NULL)) != 0)
- com_err(whoami, stat, " in filesystem not updated");
+ com_err(program_name, stat, " in filesystem not updated");
else
Put_message("filesystem sucessfully updated.");
}
NullFunc, NULL)) == 0) {
Put_message ("A Filesystem by that name already exists.");
return(DM_NORMAL);
- } else if (status != SMS_NOMATCH) {
- com_err(whoami, stat, " in AddFS");
+ } else if (stat != SMS_NO_MATCH) {
+ com_err(program_name, stat, " in AddFS");
return(DM_NORMAL);
}
- while (count = 0; count < 100; count++)
+ for (count = 0; count < 100; count++)
info[count] = NULL;
args = AskFSInfo(info, FALSE );
-
+
if (stat = sms_query("add_filesys", CountArgs(args), args,
NullFunc, NULL) != 0)
- com_err(whoami, stat, " in AddFS");
+ com_err(program_name, stat, " in AddFS");
FreeInfo(info);
return (DM_NORMAL);
int argc;
char **argv;
{
- register int stat = 0;
char **info, buf[BUFSIZ];
struct qelem *top, *elem;
- top = elem = GetFSInfo(FS_ALIAS, argv[1]);
+ top = elem = GetFSInfo(ALIAS, argv[1]);
while (elem != NULL) {
info = (char **) elem->q_data;
- sprintf(buf,"Alias: %s\tFilesystem: %s",info[NAME], info[ALIAS_TRANS]);
- putmessage(buf);
+ sprintf(buf,"Alias: %s\tFilesystem: %s",info[ALIAS_NAME],
+ info[ALIAS_TRANS]);
+ Put_message(buf);
elem = elem->q_forw;
}
int argc;
char **argv;
{
- register int stat = 0;
+ register int stat;
struct qelem *elem, *top;
- char *args[3], buf[BUFSIZ], **info;
- int num_args;
+ char *args[MAX_ARGS_SIZE], buf[BUFSIZ], **info;
elem = NULL;
if (!ValidName(argv[1]))
return(DM_NORMAL);
- args[0] = argv[1];
- args[1] = FS_ALIAS_TYPE;
+ args[ALIAS_NAME] = Strsave(argv[1]);
+ args[ALIAS_TYPE] = Strsave(FS_ALIAS_TYPE);
/*
* Check to see if this alias already exists in the database, if so then
while (elem != NULL) {
info = (char **) elem->q_data;
sprintf(buf,"The alias: %s\tcurrently describes the filesystem %s",
- info[NAME], info[ALIAS_TRANS]);
+ info[ALIAS_NAME], info[ALIAS_TRANS]);
Put_message(buf);
elem = elem->q_forw;
}
return(DM_NORMAL);
}
else if ( stat != SMS_NO_MATCH) {
- com_err(whoami, stat, " in CreateFSAlias.");
+ com_err(program_name, stat, " in CreateFSAlias.");
return(DM_NORMAL);
}
- args[ALIAS_TRANS] = NULL; /* set to zero */
+ args[ALIAS_TRANS]= args[ALIAS_END] = NULL; /* set to NULL initially. */
GetValueFromUser("Which filesystem will this alias point to?",
- args[ALIAS_TRANS]);
+ &args[ALIAS_TRANS]);
if ( (stat = sms_query("add_alias", 3, args, NullFunc, NULL)) != 0)
- com_err(whoami, stat, " in CreateFSAlias.");
+ com_err(program_name, stat, " in CreateFSAlias.");
- free(args[ALIAS_TRANS]);
+ FreeInfo(args);
return (DM_NORMAL);
}
char **argv;
{
register int stat;
- char *args[3], buf[BUFSIZ], **info;
- int num_args, delete;
+ char buf[BUFSIZ];
struct qelem *elem, *top;
+ Bool one_alias, delete;
if (!ValidName(argv[1]))
return(DM_NORMAL);
- top = elem = GetFSInfo(FS_ALIAS, argv[1]);
+ top = elem = GetFSInfo(ALIAS, argv[1]);
/*
* 1) If there are no (zero) match in elements then we exit immediately.
* about each one, and delete on yes only, and about if the user hits
* quit.
*/
- number = QueueCount(top);
+ one_alias = ( QueueCount(top) == 1 );
while (elem != NULL) {
char **info = (char **) elem->q_data;
- if (number != 1) {
- sprintf(buf, "%s %s for the filesystem %s.",
+ if (one_alias) {
+ int answer;
+
+ sprintf(buf, "%s %s for the filesystem %s? (y/n)",
"Confirm that you want to delete\n the alias",
- info[NAME], info[ALIAS_TRANS]);
+ info[ALIAS_NAME], info[ALIAS_TRANS]);
Put_message(buf);
- answer = YesNoQuitQuestion("\nDelete this filesystem alias?",
- FALSE);
+ answer = YesNoQuitQuestion(buf, FALSE);
switch(answer) {
case TRUE:
delete = TRUE;
* filesystem aliases, or if the user confirms on a unique alias.
*/
if (delete) {
- if ( (status = sms_query("delete_filesys", 1,
- &name, NullFunc, NULL)) != 0)
- com_err(whoami, stat, " filesystem alias not deleted.");
+ if ( (stat = sms_query("delete_filesys", 1,
+ &info[ALIAS_NAME], Scream, NULL)) != 0)
+ com_err(program_name, stat, " filesystem alias not deleted.");
else
Put_message("Filesystem alias deleted.");
}
elem = elem->q_forw;
}
- FreeQueue(Top);
+ FreeQueue(top);
return (DM_NORMAL);
}
/* BTW: for anyone who cares MCD is short for Machine, Cluster, Data. */
-#include "mit-copyright.h"
-#include "allmaint.h"
-#include "globals.h"
-#include "infodefs.h"
-
#include <stdio.h>
#include <strings.h>
#include <sms.h>
#include <menu.h>
-#define MCD_MACHINE 0
-#define MCD_CLUSTER 1
-#define MCD_DATA 2
-#define MCD_MAP 3
+#include "mit-copyright.h"
+#include "allmaint.h"
+#include "allmaint_funcs.h"
+#include "globals.h"
+#include "infodefs.h"
-extern char *whoami;
-extern char * CanonicalizeHostname();
+#define MACHINE 0
+#define CLUSTER 1
+#define DATA 2
+#define MAP 3
/* Function Name: PrintMachInfo
* Description: This function Prints out the Machine info in
char buf[BUFSIZ];
sprintf(buf, "Cluster: %s", info[C_NAME]);
- Put_Message(buf);
+ Put_message(buf);
sprintf(buf,"Description: %-20s, Location: %-20s", info[C_DESCRIPT],
info[C_LOCATION]);
Put_message(buf);
char ** info;
{
char buf[BUFSIZ];
- sprintf(buf, "Cluster: %-30s, Label: %-20s, Data: %-20s",
+ sprintf(buf, "Cluster: %-30s Label: %-20s Data: %-20s",
info[CD_NAME], info[CD_LABEL], info[CD_DATA]);
Put_message(buf);
}
+/* Function Name: PrintMCMap
+ * Description: Prints the data about a machine to cluster mapping.
+ * Arguments: info a pointer to the data array.
+ * Returns: none
+ */
+
+void
+PrintMCMap(info)
+char ** info;
+{
+ char buf[BUFSIZ];
+ sprintf(buf, "Cluster: %-30s Machine: %-20s",
+ info[MAP_CLUSTER], info[MAP_MACHINE]);
+ Put_message(buf);
+}
+
/* Function Name: GetMCInfo.
* Description: This function stores info about a machine.
* type - type of data we are trying to retrieve.
*/
struct qelem *
-StoreMCInfo(type, name1, name2)
+GetMCInfo(type, name1, name2)
int type;
char * name1, *name2;
{
char * args[2];
switch (type) {
- case MCD_MACHINE:
+ case MACHINE:
if ( (stat = sms_query("get_machine", 1, &name1,
StoreInfo, &elem)) != 0) {
- com_err(whoami, stat, " in get_machine.");
+ com_err(program_name, stat, " in get_machine.");
return(NULL);
}
break;
- case MCD_CLUSTER:
+ case CLUSTER:
if ( (stat = sms_query("get_cluster", 1, &name1,
StoreInfo, &elem)) != 0) {
- com_err(whoami, stat, " in get_cluster.");
+ com_err(program_name, stat, " in get_cluster.");
return(NULL);
}
break;
- case MCD_MAP:
- args[0] = name1;
- args[1] = name2;
+ case MAP:
+ args[MAP_MACHINE] = name1;
+ args[MAP_CLUSTER] = name2;
if ( (stat = sms_query("get_machine_to_cluster_map", 2, args,
StoreInfo, &elem)) != 0) {
- com_err(whoami, stat, " in get_machine_to_cluster_map.");
+ com_err(program_name, stat, " in get_machine_to_cluster_map.");
return(NULL);
}
break;
- case MCD_DATA:
- args[0] = name1;
- args[1] = name2;
+ case DATA:
+ args[CD_NAME] = name1;
+ args[CD_LABEL] = name2;
if ( (stat = sms_query("get_cluster_data", 2, args,
StoreInfo, &elem)) != 0) {
- com_err(whoami, stat, " in get_cluster_data.");
+ com_err(program_name, stat, " in get_cluster_data.");
return(NULL);
}
}
return(QueueTop(elem));
}
-/* Function Name: AskInfo.
+/* Function Name: AskMCDInfo.
* Description: This function askes the user for information about a
* machine and saves it into a structure.
* Arguments: info - a pointer the information to ask about
- * type - type of information - MCD_MACHINE
- * MCD_CLUSTER
- * MCD_DATA
+ * type - type of information - MACHINE
+ * CLUSTER
+ * DATA
* name - T/F : change the name of this type.
* Returns: none.
*/
-void
-AskInfo(mcs_info, type, name);
-char ** mcs_info;
+char **
+AskMCDInfo(info, type, name)
+char ** info;
int type;
Bool name;
{
- char * temp_buf;
+ char temp_buf[BUFSIZ], *newname;
switch (type) {
- case MCD_MACHINE:
+ case MACHINE:
sprintf(temp_buf, "Changing the information for the Machine %s.",
name);
break;
- case MCD_CLUSTER:
+ case CLUSTER:
sprintf(temp_buf, "Changing the information for the Cluster %s.",
name);
break;
- case MCD_DATA:
+ case DATA:
sprintf(temp_buf, "Changing the Data for the Cluster %s.",
name);
break;
Put_message(temp_buf);
if (name) {
- info[NEWNAME] = Strsave(info->name);
switch (type) {
- case MCD_MACHINE:
+ case MACHINE:
+ newname = Strsave(info[M_NAME]);
GetValueFromUser("The new name for this machine? ",
- info[M_NEWNAME]);
+ &newname);
break;
- case MCD_CLUSTER:
+ case CLUSTER:
+ newname = Strsave(info[C_NAME]);
GetValueFromUser("The new name for this cluster? ",
- info[C_NEWNAME]);
+ &newname);
break;
default:
- Put_message("Unknown type in AskInfo, programmer botch");
- return;
+ Put_message("Unknown type in AskMCDInfo, programmer botch");
+ return(NULL);
}
}
switch(type) {
- case MCD_MACHINE:
- GetValueFromUser("Machine's Type:",info[M_TYPE]);
+ case MACHINE:
+ GetValueFromUser("Machine's Type:", &info[M_TYPE]);
FreeAndClear(&info[M_MODTIME], TRUE);
FreeAndClear(&info[M_MODBY], TRUE);
FreeAndClear(&info[M_MODWITH], TRUE);
break;
- case MCD_CLUSTER:
- GetValueFromUser("Cluster's Description:",info[C_DESCRIPT]);
- GetValueFromUser("Cluster's Location:",info[C_LOCATION]);
+ case CLUSTER:
+ GetValueFromUser("Cluster's Description:", &info[C_DESCRIPT]);
+ GetValueFromUser("Cluster's Location:", &info[C_LOCATION]);
FreeAndClear(&info[C_MODTIME], TRUE);
FreeAndClear(&info[C_MODBY], TRUE);
FreeAndClear(&info[C_MODWITH], TRUE);
break;
- case MCD_DATA:
- GetValueFromUser("Label defining this data?",info[CD_LABEL]);
- GetValueFromUser("The data itself ? ",info[CD_DATA]);
+ case DATA:
+ GetValueFromUser("Label defining this data?", &info[CD_LABEL]);
+ GetValueFromUser("The data itself ? ", &info[CD_DATA]);
break;
}
char **info;
struct qelem *elem, *top;
- top = elem = GetMCInfo( CanonicalizeHostname(argv[1]), MCD_MACHINE);
+ top = elem = GetMCInfo(MACHINE, CanonicalizeHostname(argv[1]),
+ (char *) NULL);
while (elem != NULL) {
info = (char **) elem->q_data;
Put_message("This machine already exists.");
return(DM_NORMAL);
}
- else if (stat != SMS_NOMATCH) {
- com_err(whoami, status, " in AddMachine.");
+ else if (stat != SMS_NO_MATCH) {
+ com_err(program_name, stat, " in AddMachine.");
return(DM_NORMAL);
}
info[0] = name;
- args = AskMCDInfo(info, MCD_MACHINE, FALSE);
+ args = AskMCDInfo(info, MACHINE, FALSE);
/*
* Actually create the new Machine.
*/
if ( (stat = sms_query("add_machine", CountArgs(args),
- args, NullFunc, NULL)) != 0)
- com_err(whoami, status, " in AddMachine.");
+ args, Scream, NULL)) != 0)
+ com_err(program_name, stat, " in AddMachine.");
FreeInfo(info);
return(DM_NORMAL);
int argc;
char **argv;
{
- char **args, **info;
+ struct qelem *elem, *top;
int stat;
- elem = top = GetMCDInfo( MCD_MACHINE, CanonicalizeHostname(argv[1]) );
+ elem = top = GetMCInfo( MACHINE, CanonicalizeHostname(argv[1]),
+ (char *) NULL);
while (elem != NULL) {
- info = (char **) elem->q_data;
- args = AskMCDInfo(info, MCD_MACHINE, TRUE);
+ char ** args;
+ char ** info = (char **) elem->q_data;
+ args = AskMCDInfo(info, MACHINE, TRUE);
if ( (stat = sms_query("update_machine", CountArgs(args),
args, Scream, NULL)) != 0)
- com_err(whoami, status, " in UpdateMachine.");
+ com_err(program_name, stat, " in UpdateMachine.");
elem = elem->q_forw;
}
/* ARGSUSED */
int
-DeleteMachine(argc,argv)
+DeleteMachine(argc, argv)
int argc;
char **argv;
{
int stat;
- char * args[2], *name;
+ char * args[2], *name, temp_buf[BUFSIZ];
+ struct qelem *top, *elem = NULL;
name = CanonicalizeHostname(argv[1]);
/* Should probabally check for wildcards, none allowed. */
/* Perhaps we should remove the cluster if it has no machine now. */
- args[0] = argv[1];
+ args[0] = name;
args[1] = "*";
- stat = sms_query("get_machine_to_cluster_map", 2, args, Null, NULL);
- if (stat != SMS_NO_MATCH) {
- sprintf(temp_buf, "%s is assigned to cluster %s.",args[0], args[1]);
- Put_message(temp_buf);
- if ( YesNoQuestion("Would you like to remove it from this cluster?",
- FALSE)) {
- if ( (stat = sms_query( "delete_machine_from_cluster",
- 1, args, Null, NULL)) != 0)
- com_err(whoami, status, " in DeleteMachine.");
- }
- else {
- Put_message("Aborting...");
- return(DM_NORMAL);
+ stat = sms_query("get_machine_to_cluster_map", 2, args, StoreInfo, &elem);
+ if (stat && stat != SMS_NO_MATCH) {
+ com_err(program_name, stat, " in DeleteMachine.");
+ return(DM_NORMAL);
+ }
+ if (stat == 0) {
+ top = elem;
+ while (elem != NULL) {
+ sprintf(temp_buf, "%s is assigned to cluster %s.",
+ args[0], args[1]);
+ Put_message(temp_buf);
+ if ( YesNoQuestion(
+ "Would you like to remove it from this cluster?", FALSE)) {
+ if ( (stat = sms_query( "delete_machine_from_cluster",
+ 1, args, Scream, NULL)) != 0)
+ com_err(program_name, stat,
+ " in delete_machine_from_cluster.");
+ else {
+ Put_message("Aborting...");
+ FreeQueue(top);
+ return(DM_NORMAL);
+ }
+ }
+ elem = elem->q_forw;
}
}
if(Confirm("Are you sure that you want to delete this machine?")) {
- if ( (stat = sms_query("delete_machine", 1, &name, Null, NULL)) != 0)
- com_err(whoami, status, " in DeleteMachine.");
+ if ( (stat = sms_query("delete_machine", 1, &name, Scream, NULL)) != 0)
+ com_err(program_name, stat, " in DeleteMachine.");
}
else
Put_message("Operation aborted.");
{
int stat;
- if ( (stat = sms_query("add_machine_to_cluster", 2, args + 1,
+ if ( (stat = sms_query("add_machine_to_cluster", 2, argv + 1,
Scream, NULL) != 0))
- com_err(whoami, status, " in AddMachineToCluster.");
+ com_err(program_name, stat, " in AddMachineToCluster.");
return(DM_NORMAL);
}
{
int stat, ans;
struct qelem *elem, *top;
- char ** info;
+ char ** info, buf[BUFSIZ];
- elem = top = GetMCDInfo(MCD_CLUSTER, CanonicalizeHostname(argv[1]), "*");
+ elem = top = GetMCInfo(CLUSTER, CanonicalizeHostname(argv[1]), "*");
Put_message("This machine is the following clusters:");
while (elem != NULL) {
- info = (char *) elem->q_data;
+ info = (char **) elem->q_data;
Put_message(info[MAP_CLUSTER]);
elem = elem->q_forw;
}
if ( Confirm("Remove this machine from ** ALL ** these clusters?") ) {
while (elem != NULL) { /* delete all */
- info = (char *) elem->q_data;
+ info = (char **) elem->q_data;
if ( (stat =sms_query("delete_machine_from_cluster", 2,
info, Scream, NULL)) != 0 )
- com_err(whoami, stat, " in delete_machine_from_cluster");
+ com_err(program_name, stat, " in delete_machine_from_cluster");
elem = elem->q_forw;
}
}
else
while (elem != NULL) { /* query delete. */
- info = (char *) elem->q_data;
+ info = (char **) elem->q_data;
sprintf(buf, "Remove %13s from the cluster %30s? (y/n/q)",
info[MAP_MACHINE], info[MAP_CLUSTER]);
ans = YesNoQuitQuestion(buf, FALSE);
if (ans == TRUE)
if ( (stat =sms_query("delete_machine_from_cluster", 2,
info, Scream, NULL)) != 0 )
- com_err(whoami, stat, " in delete_machine_from_cluster");
+ com_err(program_name, stat, " in delete_machine_from_cluster");
else if (ans != FALSE) /* quit. or ^C */
break;
elem = elem->q_forw;
/* ARGSUSED */
int
-ShowClusterInfo(argc, argv);
+ShowClusterInfo(argc, argv)
int argc;
char ** argv;
{
char **info;
struct qelem *elem, *top;
- top = elem = GetMCInfo(argv[1], MCD_MACHINE);
+ top = elem = GetMCInfo( MACHINE, CanonicalizeHostname(argv[1]),
+ (char *) NULL);
while (elem != NULL) {
info = (char **) elem->q_data;
PrintClusterInfo(info);
Put_message("This cluster already exists.");
return(DM_NORMAL);
}
- else if (stat != SMS_NOMATCH) {
- com_err(whoami, status, " in AddCluster.");
+ else if (stat != SMS_NO_MATCH) {
+ com_err(program_name, stat, " in AddCluster.");
return(DM_NORMAL);
}
info[0] = name;
- args = AskMCDInfo(info, MCD_CLUSTER, FALSE);
+ args = AskMCDInfo(info, CLUSTER, FALSE);
/*
* Actually create the new Cluster.
if ( (stat = sms_query("add_cluster", CountArgs(args),
args, Scream, NULL)) != 0)
- com_err(whoami, status, " in AddCluster.");
+ com_err(program_name, stat, " in AddCluster.");
FreeInfo(info);
return(DM_NORMAL);
char **args, **info;
int stat;
- elem = top = GetMCDInfo( MCD_Cluster, argv[1], (char *) NULL );
+ elem = top = GetMCInfo( CLUSTER, argv[1], (char *) NULL );
while (elem != NULL) {
info = (char **) elem->q_data;
- args = AskMCDInfo(info, MCD_CLUSTER, TRUE);
+ args = AskMCDInfo(info, CLUSTER, TRUE);
if ( (stat = sms_query("update_cluter", CountArgs(args),
args, Scream, NULL)) != 0)
- com_err(whoami, status, " in UpdateCluster.");
+ com_err(program_name, stat, " in UpdateCluster.");
elem = elem->q_forw;
}
/* ARGSUSED */
int
-DeleteCluster(argc, argv);
+DeleteCluster(argc, argv)
int argc;
char ** argv;
{
- char * args[3];
+ char * args[3], temp_buf[BUFSIZ];
+ int stat;
/* Should probabally check for wildcards, none allowed. */
args[MAP_MACHINE] = "*";
args[MAP_CLUSTER] = argv[1];
- stat = sms_query("get_machine_to_cluster_map", 2, args, NullFunc, NULL);
+ stat = sms_query("get_machine_to_cluster_map", 2, args,
+ NullFunc, (char *) NULL);
+ if (stat & stat != SMS_NO_MATCH) {
+ com_err(program_name, stat, " in DeleteCluster.");
+ return(DM_NORMAL);
+ }
if (stat != SMS_NO_MATCH) {
- sprintf(temp_buf, "Cluster %s still has machines in it.",args[0]);
+ sprintf(temp_buf, "Cluster %s still has machines in it.",argv[1]);
Put_message(temp_buf);
- if ( YesNoQuestion("Would you like a list? (y/n)") == TRUE ) {
+ if ( YesNoQuestion("Would you like a list? (y/n)", TRUE) == TRUE ) {
args[0] = "foo"; /* not used. */
args[1] = "*";
args[2] = argv[1];
if(Confirm("Are you sure that you want to delete this cluster? ")) {
if ( (stat = sms_query("delete_cluster",
1, &args[MAP_CLUSTER], Scream, NULL)) != 0)
- com_err(whoami, status, " in DeleteCluster.");
+ com_err(program_name, stat, " in DeleteCluster.");
}
else
Put_message("Operation aborted.");
/* Function Name: ShowClusterData
* Description: This function shows the services for one cluster.
* Arguments: argc, argv - The name of the cluster is argv[1].
- * The name of the data in argv[2].
+ * The label of the data in argv[2].
* Returns: DM_NORMAL.
*/
struct qelem *elem, *top;
char **info;
- top = elem = GetMCDInfo(MCD_DATA, argv[1], argv[2]);
+ top = elem = GetMCInfo(DATA, argv[1], argv[2]);
while (elem != NULL) {
info = (char **) elem->q_data;
PrintClusterData(info);
- elem = elem->data;
+ elem = elem->q_forw;
}
FreeQueue(top);
return(DM_NORMAL);
int argc;
char ** argv;
{
+ int stat;
+
if( (stat = sms_query("add_cluster_data", 3, argv + 1,
Scream, (char *) NULL)) != 0)
- com_err(whoami, status, " in AddClusterData.");
+ com_err(program_name, stat, " in AddClusterData.");
}
-/* Function Name: DeleteClusterData
- * Description: This function deletes a service
+/* Function Name: RemoveClusterData
+ * Description: This function removes data on a given cluster.
* Arguments: argv, argc: argv[1] - the name of the cluster.
* argv[2] - the label of the data.
* argv[3] - the data.
*/
/* ARGSUSED */
-int DeleteClusterData(argc, argv)
+int
+RemoveClusterData(argc, argv)
int argc;
char ** argv;
{
if(Confirm("Do you really want to delete this data?")) {
if( (stat = sms_query("delete_cluster_data", 3, argv + 1,
Scream, (char *) NULL)) != 0)
- com_err(whoami, status, " in DeleteClusterData.");
+ com_err(program_name, stat, " in DeleteClusterData.");
} else
Put_message("Operation aborted.\n");
int argc;
char **argv;
{
- int stat;
+ struct qelem *elem, *top;
- argv[1] = CanonicalizeHostname(argv[1]);
+ top = elem = GetMCInfo(MAP, CanonicalizeHostname(argv[1]), argv[2]);
- if (stat = sms_query("get_machine_to_cluster_map",
- argc-1, argv+1, Print, NULL) != 0)
- com_err(whoami, qstat, NULL);
+ while (elem != NULL) {
+ char ** info = (char **) elem->q_data;
+ PrintMCMap(info);
+ elem = elem->q_forw;
+ }
+
+ FreeQueue(top);
+ return(DM_NORMAL);
+}
- return(DM_NORMAL);
+/* Function Name: MachinesInCluster
+ * Description: Shows all machines in a give cluster.
+ * Arguments: argv, argc - name of cluster in argv[1].
+ * Returns: DM_NORMAL;
+ */
+
+/* ARGSUSED */
+int
+MachinesInCluster(argv,argc)
+int argc;
+char **argv;
+{
+ char *info[10];
+ info[0] = argv[0];
+ info[2] = argv[1];
+ info[1] = "*";
+ return(MachineToClusterMap(3, info));
}
/*
* see the file mit-copyright.h
*/
-#include "mit-copyright.h"
-#include "allmaint.h"
-#include "globals.h"
-#include "infodefs.h"
-
#include <stdio.h>
#include <strings.h>
#include <sms.h>
#include <menu.h>
-int DeleteList(), DeleteUser();
-static int RealDeleteList() RealDeleteUser();
+#include "mit-copyright.h"
+#include "allmaint.h"
+#include "allmaint_funcs.h"
+#include "globals.h"
+#include "infodefs.h"
+
+static int RealDeleteList(), RealDeleteUser();
/* Function Name: CheckListForDeletion
* Description: Check one of the lists in which we just removed a member.
char * name;
Bool verbose;
{
- qelem *elem = NULL;
- int status;
- char *args[2], buf[BUFSIZ];
+ struct qelem *elem = NULL;
+ int status, ans;
+ char *args[2], buf[BUFSIZ], **info;
if ( (status = sms_query("count_members_of_list", 1, &name, StoreInfo,
(char *) &elem)) != 0) {
- com_err(whoami, status, " in DeleteList (count_members_of_list).");
- return();
+ com_err(program_name, status,
+ " in DeleteList (count_members_of_list).");
+ return;
}
- if (verbose) {
- sprintf(buf, "Delete the empty list %s? ",name);
- ans = YesNoQuestion(buf, TRUE);
- if (ans != TRUE) {
- Put_message("Aborting Deletion!");
- return();
+ info = (char **) elem->q_data;
+ if (info[0] == 0) {
+ if (verbose) {
+ sprintf(buf, "Delete the empty list %s? ", name);
+ ans = YesNoQuestion(buf, TRUE);
+ if (ans != TRUE) {
+ Put_message("Aborting Deletion!");
+ FreeQueue(elem);
+ return;
+ }
}
+ args[0] = "foo"; /* not used. */
+ args[1] = name;
+ DeleteList(2, args);
}
- args[0] = "foo"; /* not used. */
- args[1] = name;
- DeleteList(2, args);
+ FreeQueue(elem);
}
/* Function Name: CheckAcl
Bool verbose;
{
char *args[2], buf[BUFSIZ];
+ int status, ans;
- if ( strcmp(type,"LIST") != 0 )
- return(); /* If the acl is not a list the ignore it. */
+ if ( strcmp(type, "LIST") != 0 )
+ return; /* If the acl is not a list the ignore it. */
args[0] = type;
args[1] = name;
status = sms_query("get_acl_use", 2, args, NullFunc, (char *) NULL);
if (status != SMS_NO_MATCH)
- return(); /* if this query fails the acl will
- not be deleted even if it is empty. */
+ return; /* If this query fails the acl will
+ not be deleted even if it is empty. */
if (verbose) {
sprintf(buf, "Delete the unused Access Control List (ACL) %s? ", name);
ans = YesNoQuestion(buf, TRUE);
if (ans != TRUE) {
- Put_message("Aborting Deletion!");
- return();
+ Put_message("Aborting Deletion!");
+ return;
+ }
}
/*
* Delete the ACL.
int
CheckIfAcl(name, type, verbose)
-char * name, type;
+char * name, * type;
Bool verbose;
{
char * args[2], buf[BUFSIZ];
- qelem *elem, *local;
+ struct qelem *elem, *local;
+ int status;
elem = NULL;
args[0] = type;
return(SUB_NORMAL);
if (status != 0) {
- com_err(whoami, status, " in CheckIfAcl (get_acl_use).");
+ com_err(program_name, status, " in CheckIfAcl (get_acl_use).");
return(SUB_ERROR);
}
if (verbose) {
- sprintf(buf, "%s %s %s %s", type, list_name,
+ sprintf(buf, "%s %s %s %s", type, name,
"is the Access Control List (ACL) for the following data",
"objects:\n");
Put_message(buf);
local = elem;
while (local != NULL) {
- info = (char **) local->q_data;
+ char ** info = (char **) local->q_data;
Print( QueueCount(elem), info, NULL);
local = local->q_forw;
}
}
FreeQueue(elem);
return(SUB_ERROR);
- }
}
/* Function Name: RemoveItemFromLists
*/
int
-RemoveItemFromLists(name, type, elem, verbose);
-char * name, type;
-qelem ** elem;
+RemoveItemFromLists(name, type, elem, verbose)
+char * name, *type;
+struct qelem ** elem;
int verbose;
{
- char *args[2];
+ struct qelem *local;
+ char *args[2], temp_buf[BUFSIZ];
+ int status, ans;
args[0] = type;
args[1] = name;
return(SUB_NORMAL);
if (status != 0) {
- com_err(whoami, status, " in DeleteList (get_lists_of_member).");
+ com_err(program_name, status, " in DeleteList (get_lists_of_member).");
return(SUB_ERROR);
}
if (verbose) {
sprintf(temp_buf, "%s %s is a member of %d other list(s).\n", type,
- name, QueueCount(member_of) );
- Put_message(buf);
+ name, QueueCount(*elem) );
+ Put_message(temp_buf);
local = *elem;
while (local != NULL) {
- info = (char **) local->q_data;
+ char ** info = (char **) local->q_data;
Print( CountArgs(info), info, NULL);
local = local->q_forw;
}
- sprintf(buf,"Remove %s %s from these lists? ", type, name);
- ans = YesNoQuestion(buf, TRUE);
- if (ans < 0 || answer == FALSE) {
+ sprintf(temp_buf,"Remove %s %s from these lists? ", type, name);
+ ans = YesNoQuestion(temp_buf, TRUE);
+ if (ans < 0 || ans == FALSE) {
Put_message("Aborting...");
FreeQueue(*elem);
return(SUB_ERROR);
args[1] = name;
args[2] = type;
while (local != NULL) {
- info = (char **) local->q_data;
+ char ** info = (char **) local->q_data;
args[0] = info[0];
if ( (status = sms_query("delete_member_from_list",
3, args, Scream, NULL)) != 0) {
- com_err(whoami, status, " in delete_member\nAborting\n");
+ com_err(program_name, status, " in delete_member\nAborting\n");
FreeQueue(*elem);
return(SUB_ERROR);
}
*/
int
-RemoveMembersOfList(name, verbose);
+RemoveMembersOfList(name, verbose)
char * name;
Bool verbose;
{
- char buf[BUFSIZ], **info;
- qelem *local, *elem;
+ char buf[BUFSIZ], *args[10];
+ struct qelem *local, *elem = NULL;
+ int status, ans;
/*
* Get the members of this list.
*/
- *elem = NULL;
status = sms_query("get_members_of_list", 1, &name, StoreInfo,
(char *) &elem);
- if (status == SMS_NOMATCH)
- return(SUB_NORM);
+ if (status == SMS_NO_MATCH)
+ return(SUB_NORMAL);
if (status != 0) {
- com_err(whoami, status, " in DeleteList (get_members_of_list).");
+ com_err(program_name, status, " in DeleteList (get_members_of_list).");
return(SUB_ERROR);
}
*/
if (verbose) {
- sprintf(buf, "List %s has %d member(s):", name, QueueCount(members) );
+ sprintf(buf, "List %s has %d member(s):", name, QueueCount(elem) );
Put_message(buf);
local = elem;
while (local != NULL) {
- info = (char **) local->q_data;
+ char ** info = (char **) local->q_data;
Print( CountArgs(info), info, NULL);
local = local->q_forw;
}
sprintf(buf, "Remove these member(s) from list %s? ", name);
- ans = YesNoQuestion(temp_buf, TRUE);
- if (ans < 0 || answer == FALSE) {
+ ans = YesNoQuestion(buf, TRUE);
+ if (ans < 0 || ans == FALSE) {
Put_message("Aborting...");
- FreeQueue(elem)
+ FreeQueue(elem);
return(SUB_ERROR);
}
}
local = elem;
args[0] = name;
while (local != NULL) {
- info = (char **) local->q_data;
+ char ** info = (char **) local->q_data;
args[1] = info[0];
args[2] = info[1];
if ( (status = sms_query("delete_member_from_list",
3, args, Scream, NULL)) != 0) {
- com_err(whoami, status, " in delete_member\nAborting\n");
+ com_err(program_name, status, " in delete_member\nAborting\n");
FreeQueue(elem);
return(SUB_ERROR);
}
Bool verbose;
{
int status, ans;
- char buf[BUFSIZ];
+ char buf[BUFSIZ], *args[10];
status = sms_query("get_list_info", 1, &name, NullFunc, (char *) NULL);
if (status == 0) {
ans = YesNoQuestion(buf, TRUE);
if (ans == FALSE) {
Put_message("Leaving group alone.");
- return(SBU_NORMAL);
+ return(SUB_NORMAL);
}
if (ans < 0) {
Put_message("Aborting...\n");
DeleteList(2, args);
}
else if (status != SMS_NO_MATCH) {
- com_err(whoami, status, " Aborting Delete User.");
+ com_err(program_name, status, " Aborting Delete User.");
return(SUB_ERROR);
}
+ return(SUB_NORMAL);
}
/* Function Name: DeleteHomeFilesys
status = sms_query("get_filesystem_by_label", 1, &name, NullFunc,
(char *) NULL);
- if (status == SMS_NOMATCH)
+ if (status == SMS_NO_MATCH)
return(SUB_NORMAL);
if (status == 0) {
if (verbose) {
ans = YesNoQuestion(buf, TRUE);
if (ans != TRUE) {
Put_message("Filesystem Not Deleted, aborting...\n\n");
- return(SMS_ERROR);
+ return(SUB_ERROR);
}
}
if ( (status = sms_query("delete_filesystem", 1, &name, Scream,
(char *) NULL) ) != 0) {
- com_err(whoami, status, " in delete_filesystem).");
+ com_err(program_name, status, " in delete_filesystem).");
return(SUB_ERROR);
}
return(SUB_NORMAL);
}
- com_err(whoami, status, " in get_filesystem_by_label).");
+ com_err(program_name, status, " in get_filesystem_by_label).");
return(SUB_ERROR);
}
int verbose;
{
int status, ans;
- char buf[BUFSIZ];
- struct qelem *;
+ char buf[BUFSIZ], *args[10];
+ struct qelem *local, *elem = NULL;
status = sms_query("get_nfs_quotas_by_user", 1, &name, StoreInfo,
(char *) &elem);
if (status == SMS_NO_MATCH)
return(SUB_NORMAL);
if (status != 0) {
- com_err(whoami, status, " in delete_filesystem.");
+ com_err(program_name, status, " in delete_filesystem.");
return(SUB_ERROR);
}
if (verbose) {
Put_message(buf);
local = elem;
while (local != NULL) {
- info = (char **) local->q_data;
+ char ** info = (char **) local->q_data;
sprintf(buf, "Filesystem:\t%s\t\tQuota(in Kb):\t%s",
info[0], info[4]);
Put_message(buf);
local = elem;
args[1] = name;
while (local != elem) {
- info = (char **) local->q_data;
+ char ** info = (char **) local->q_data;
args[0] = info[0];
status = sms_query("delete_nfs_quota", 2, args, Scream, (char *) NULL);
if (status != 0 && status != SMS_NO_MATCH) {
"Could not remove quota on filesystem %s. ** ABORTING **",
args[0]);
Put_message(buf);
- com_err(whoami, status, (char *) NULL);
+ com_err(program_name, status, (char *) NULL);
FreeQueue(elem);
return(SUB_ERROR);
}
- local = local->normal;
+ local = local->q_forw;
}
FreeQueue(elem);
return(SUB_NORMAL);
int argc;
char *argv[];
{
- char buf[BUFSIZ], *args[2], *list;
- struct qelem *elem, *local, *member_of, *list_info;
- int ans, status;
+ char *list, **info;
+ struct qelem *local, *member_of, *list_info;
+ int status;
member_of = list_info = NULL;
*/
if ( (status = sms_query("get_list_info", 1, &list, StoreInfo,
(char *) &list_info)) != 0) {
- com_err(whoami, status, " in DeleteList (delete_list).");
+ com_err(program_name, status, " in DeleteList (delete_list).");
return(DM_NORMAL);
}
status = sms_query("delete_list", 1, &list, Scream, (char *) NULL);
if (status != SMS_IN_USE && status != 0) {
- com_err(whoami, status, " in DeleteList (delete_list).");
+ com_err(program_name, status, " in DeleteList (delete_list).");
return(DM_NORMAL);
}
if (status == 0) {
}
info = (char **) list_info->q_data;
- CheckAcl(info[ACL_TYPE], info[ACL_NAME], TRUE);
+ CheckAcl(info[L_ACL_TYPE], info[L_ACL_NAME], TRUE);
local = member_of;
while (local != NULL) {
info = (char **) local->q_data;
- CheckListForDeletion(info[0], TRUE);
+ CheckListForDeletion(info[LM_LIST], TRUE);
local = local->q_forw;
}
*/
static int
-RealDeleteList(name);
+RealDeleteList(name)
char * name;
{
char buf[BUFSIZ];
if ( (status = sms_query("delete_list", 1, &name, Scream,
(char *) NULL)) == NULL) {
- com_err(whoami, status, ": list not deleted");
+ com_err(program_name, status, ": list not deleted");
return(SUB_ERROR);
}
(void) sprintf(buf, "List %s deleted./n", name);
Put_message(buf);
- return(SUB_NORM);
+ return(SUB_NORMAL);
}
/* Function Name: DeleteUser
int status;
char buf[BUFSIZ];
char * name = argv[1]; /* name of the user we are deleting. */
- qelem *local, *member_of = NULL;
+ struct qelem *local, *member_of = NULL;
if (!Confirm("Are you sure that you want to delete this user?"))
return(DM_NORMAL);
- status = sms_query("delete_user", 1, &name, NullFunc, (char *) NULL);
+ status = sms_query("delete_user", 1, &name, Scream, (char *) NULL);
if (status != SMS_IN_USE && status != 0) {
- com_err(whoami, status, ": list not deleted");
+ com_err(program_name, status, ": list not deleted");
return(DM_NORMAL);
}
if (status == 0) {
* If all these have been accomplished, then attempt to delete the user again.
*/
if ( (CheckIfAcl(name, "user", TRUE) == SUB_ERROR) ||
- (DeleteHomeFilsys(name, TRUE) == SUB_ERROR) ||
- (DeleteQuotas(name, TRUE) == SUB_ERROR) ||
+ (DeleteHomeFilesys(name, TRUE) == SUB_ERROR) ||
+ (DeleteAllUserQuotas(name, TRUE) == SUB_ERROR) ||
(RemoveItemFromLists(name, "user",
&member_of, TRUE) == SUB_ERROR) ||
(RealDeleteUser(name) == SUB_ERROR) ) {
* Query - Delete all empty lists created by removing this user from them.
*/
- if (DeleteUserGroup(name) == SUB_ERROR) {
+ if (DeleteUserGroup(name, TRUE) == SUB_ERROR) {
FreeQueue(member_of);
return(DM_NORMAL);
}
local = member_of;
while (local != NULL) {
- info = (char **) local->q_data;
+ char ** info = (char **) local->q_data;
CheckListForDeletion(info[0], TRUE);
- local->local->q_forw;
+ local = local->q_forw;
}
FreeQueue(member_of); /* Free memory and return. */
*/
static int
-RealDeleteUser(name);
+RealDeleteUser(name)
char * name;
{
char buf[BUFSIZ];
if ( (status = sms_query("delete_user", 1, &name, Scream,
(char *) NULL)) == NULL) {
- com_err(whoami, status, ": user not deleted");
+ com_err(program_name, status, ": user not deleted");
return(SUB_ERROR);
}
(void) sprintf(buf, "User %s deleted./n", name);
Put_message(buf);
- return(SUB_NORM);
+ return(SUB_NORMAL);
}
#include "mit-copyright.h"
#include "allmaint.h"
-char *user /* The name of the user executing allmaint. */
+Bool verbose; /* TRUE if verbose mode is active (default). */
+Bool found_some; /* used by lists.c for determining if there
+ are any members of a given type. */
+char *user; /* The name of the user executing allmaint. */
char *program_name; /* The name of this instance of the program. */
#ifndef _allmaint_globals_
#define _allmaint_globals_
-extern char *user /* The name of the user executing allmaint. */
+extern Bool verbose; /* TRUE if verbose mode is active (default). */
+extern Bool found_some; /* used by lists.c for determining if there
+ are any members of a given type. */
+extern char *user; /* The name of the user executing allmaint. */
extern char *program_name; /* The name of this instance of the program. */
#endif _allmaint_globals_ /* Do Not Add Anything After This Line */
#include "mit-copyright.h"
#include "allmaint.h"
+#include "allmaint_funcs.h"
#include "globals.h"
#include "infodefs.h"
#define GLOM 2
#define ACL_USE 3
+/* globals only for this file. */
+
+static char * current_list;
+
/* Function Name: PrintListInfo
* Description: This function Prints out the List info in a coherent form.
* Arguments: info - the List info.
Put_message("This list has no Administrator, how strange?!");
else {
sprintf(buf, "The List Administrator of this list is the %s: %s",
- info[L_ACL_TYPE], info[ACL_NAME]);
+ info[L_ACL_TYPE], info[L_ACL_NAME]);
Put_message(buf);
}
struct qelem *
GetListInfo(type, name1, name2)
int type;
-char * name;
+char * name1, *name2;
{
char *args[2];
- struct quelem * elem = NULL;
+ struct qelem * elem = NULL;
+ register int status;
switch(type) {
case LIST:
args[0] = name1;
if ( (status = sms_query("get_list_info", 1, args,
StoreInfo, (char *) &elem)) != 0) {
- com_err(whoami, status, " in get_nfs_quotas_by_user");
+ com_err(program_name, status, " in get_nfs_quotas_by_user");
return (NULL);
}
break;
args[0] = name1;
if ( (status = sms_query("get_members_of_list", 1, args,
StoreInfo, (char *) &elem)) != 0) {
- com_err(whoami, status, " in get_nfs_quotas_by_user");
+ com_err(program_name, status, " in get_nfs_quotas_by_user");
return (NULL);
}
break;
args[1] = name2;
if ( (status = sms_query("get_list_of_member", 2, args,
StoreInfo, (char *) &elem)) != 0) {
- com_err(whoami, status, " in get_nfs_quotas_by_user");
+ com_err(program_name, status, " in get_nfs_quotas_by_user");
return (NULL);
}
break;
args[1] = name2;
if ( (status = sms_query("get_acl_use", 2, args,
StoreInfo, (char *) &elem)) != 0) {
- com_err(whoami, status, " in get_nfs_quotas_by_user");
+ com_err(program_name, status, " in get_nfs_quotas_by_user");
return (NULL);
}
break;
*/
char **
-AskListInfo(info, name);
+AskListInfo(info, name)
char ** info;
Bool name;
{
- char * temp_buf, *newname;
- char *ret_args[100];
- int counter;
+ char temp_buf[BUFSIZ], *newname;
sprintf(temp_buf,"\nChanging Attributes of list %s.\n",info[L_NAME]);
Put_message(temp_buf);
GetValueFromUser("Is this list hidden (1/0): ", &info[L_HIDDEN]);
GetValueFromUser("Is this a maillist (1/0): ", &info[L_MAILLIST]);
GetValueFromUser("is this a group (1/0): ", &info[L_GROUP]);
- if (atoi(info[L_GROUP]))
- GetValueFromUser("What is the Gid for this group '#' get unique gid:".
- &info[L_GID]);
+ if (atoi(info[L_GROUP])) {
+ sprintf(temp_buf, "What is the Gid for this group, %s",
+ "'#' gets unique gid:");
+ GetValueFromUser(temp_buf, &info[L_GID]);
+ }
GetValueFromUser("What Type of Administrator (none, user, list): ",
&info[L_ACL_TYPE]);
- if ( strcmp(info[L_ACL_TYPE],"USER") == 0)
+ if ( (strcmp(info[L_ACL_TYPE], "USER") == 0) ||
+ (strcmp(info[L_ACL_TYPE], "user") == 0) )
GetValueFromUser("Who will be the administrator of this list: ",
&info[L_ACL_NAME]);
- if ( strcmp(info[L_ACL_TYPE],"USER") == 0)
+ if ( (strcmp(info[L_ACL_TYPE], "LIST") == 0) ||
+ (strcmp(info[L_ACL_TYPE], "list") == 0) )
GetValueFromUser("Which group will be the administrator of this list: ",
&info[L_ACL_NAME]);
GetValueFromUser("Description: ", &info[L_DESC]);
/* Function Name: ShowListInfo.
* Description: shows info on a list.
- * Arguments: argc, argv - standard SMS argc and argv.
+ * Arguments: argc, argv - name of list in argv[1].
* Returns: DM status code.
*/
{
struct qelem *top, *list;
- top = list = StoreListInfo(LIST, argv[1], (char *) NULL);
+ top = list = GetListInfo(LIST, argv[1], (char *) NULL);
while (list != NULL) {
PrintListInfo( (char **) list->q_data);
list = list->q_forw;
up_args = AskListInfo(info, TRUE);
if ( (status = sms_query("update_list", CountArgs(up_args), up_args,
Scream, (char *) NULL)) != 0) {
- com_err(whoami, status, " in UpdateList.");
+ com_err(program_name, status, " in UpdateList.");
Put_message("List Not Updated.");
list = list->q_forw;
}
char **argv;
{
static char *info[MAX_ARGS_SIZE], **add_args;
- struct qelem *top, *list;
int status;
if (!ValidName(argv[1])) /* Check if list name is valid. */
return(DM_QUIT);
status = sms_query("get_list_info", 1, argv + 1, NullFunc,
- (caddr_t) NULL);
+ (char *) NULL);
if (status != SMS_NO_MATCH) {
if (status == 0)
Put_message("This list already exists.");
else
- com_err(whoami, status, " in AddList.");
+ com_err(program_name, status, " in AddList.");
return(DM_QUIT);
}
if ( (status = sms_query("add_list", CountArgs(add_args), add_args,
Scream, (char *) NULL)) != 0) {
- com_err(whoami, status, " in AddList.");
+ com_err(program_name, status, " in AddList.");
Put_message("List Not Created.");
- list = list->q_forw;
}
FreeInfo(info);
*/
int
-Instructions()
+ListHelp()
{
static char * message[] = {
"Listmaint handles the creation, deletion, and updating of lists.\n",
"A list can be a mailing list, a group list, or both.\n",
"The concept behind lists is that a list has an owner",
- "- administrator - and members.\n";
+ "- administrator - and members.\n",
"The administrator of a list may be another list.\n",
"The members of a list can be users (login names), other lists,",
"or address strings.\n",
" Escape from a function - Type ctrl-C.\n",
" Suspend the program (temporarily) - Type ctrl-Z.\n",
NULL,
- }
+ };
return(PrintHelp(message));
}
int argc;
char **argv;
{
- char buf[BUFSIZ], temp_buf[BUFSIZ];
+ char temp_buf[BUFSIZ];
char *list_name = argv[1];
if (*argv[0] == 'a') { /* add_list */
*/
void
-ListMembersByType(type);
+ListMembersByType(type)
char * type;
{
char temp_buf[BUFSIZ];
+ register int status;
found_some = FALSE;
- if (status = sms_query("get_members_of_list", 1, ¤t_list,
- PrintByType, type))
- com_err(whoami, status, " in ListMembersByType\n");
+ if ( (status = sms_query("get_members_of_list", 1, ¤t_list,
+ PrintByType, type)) != 0)
+ com_err(program_name, status, " in ListMembersByType\n");
if (!found_some) {
if (type == NULL)
Put_message("List is empty (no members).");
char *action, **ret_argv;
{
char temp_buf[BUFSIZ], ret_buf[BUFSIZ];
+ register int status;
ret_argv[LM_LIST] = Strsave(current_list);
ret_argv[LM_MEMBER] = "nobody";
Put_message("\"type\" must be one of 'STRING', 'LIST', or 'USER'.");
return(SUB_ERROR);
} else if (status) {
- com_err(whoami, status, NULL);
+ com_err(program_name, status, NULL);
}
sprintf(temp_buf,"Name of member to %s", action);
PromptWithDefault(temp_buf, ret_buf, BUFSIZ, user);
ret_argv[LM_MEMBER] = Strsave(ret_buf);
- ret-args[LM_END] = NULL; /* null terminat this list. */
+ ret_argv[LM_END] = NULL; /* null terminat this list. */
return(SUB_NORMAL);
}
AddMember()
{
char *args[10];
+ register int status;
if( GetMemberInfo("add", args) == SUB_ERROR )
return(DM_NORMAL);
if (status = sms_query("add_member_to_list", CountArgs(args), args,
Scream, NULL) != 0)
- com_err(whoami, status, " in AddMember\n");
+ com_err(program_name, status, " in AddMember\n");
FreeInfo(args);
return (DM_NORMAL);
DeleteMember()
{
char *args[10];
+ register int status;
if( GetMemberInfo("delete", args) == SUB_ERROR )
return(DM_NORMAL);
if (Confirm("Are you sure you want to delete this member?") ) {
if (status = sms_query("delete_member_from_list", CountArgs(args),
args, Scream, NULL))
- com_err(whoami, status, " in DeleteMember\n");
+ com_err(program_name, status, " in DeleteMember\n");
else
Put_message("Deletion Completed.");
}
int
InterRemoveItemFromLists()
{
- char type[BUFSIZ], name[BUFSIZ], args[10];
- qelem *top, *elem;
+ register int status;
+ char type[BUFSIZ], name[BUFSIZ], *args[10];
+ struct qelem *top, *elem;
if ( !(PromptWithDefault("Type of member (user, list, string)? ", type,
BUFSIZ, "user")) )
top = elem = GetListInfo(GLOM, type, name);
while(elem != NULL) {
- info = (char **) elem->q_data;
+ char line[BUFSIZ], buf[BUFSIZ];
+ char ** info = (char **) elem->q_data;
sprintf(line, "Delete %s from the list \"%s\" [Y/N/Q]? ", name,
info[0]);
PromptWithDefault(line, buf, BUFSIZ, "N" );
if (buf[0] == 'y' || buf[0] == 'Y') {
Put_message("deleting...");
- args[DM_LIST] = info[0];
+ args[DM_LIST] = info[GLOM_NAME];
args[DM_TYPE] = type;
args[DM_MEMBER] = name;
if ( (status = sms_query("delete_member_from_list", 3, args,
Scream, (char *) NULL)) != 0)
/* should check to delete list. */
- com_err(whoami, status, " in delete_member");
+ com_err(program_name, status, " in delete_member");
}
else if (buf[0] == 'q' || buf[0] == 'Q') {
Put_message("Quitting.");
/* Function Name: ListByMember
* Description: This gets all lists that a given member is a member of.
- * Arguments: argc, argv - agrv[1] contains the type.
- * argv[2] contains the name of the member.
+ * Arguments: none.
* Returns: DM_NORMAL.
*/
int
-ListByMember(argc, argv)
-int argc;
-char **argv;
+ListByMember()
{
char buf[BUFSIZ], *type, *name, **info;
+ Bool maillist, group;
+ struct qelem *top, *elem;
if ( !(PromptWithDefault("Type of member (user, list, string)? ", buf,
BUFSIZ, "user")) )
/* Function Name: ListByAdministrator
* Description: This function prints all lists which a given user or
* group administers.
- * Arguments: argc, argv - type of the acl in argc[1].
- * name of the acl in argc[2].
+ * Arguments: none.
* Returns: DM_NORMAL.
*/
int
-ListByAdministrator(argc, argv)
-int argc;
-char **argv;
+ListByAdministrator()
{
- char buf[BUFSIZ], *type, *name, **info;
+ char buf[BUFSIZ], *type, *name;
+ struct qelem *top, *elem;
if ( !(PromptWithDefault("Type of member (user, list, string)? ", buf,
BUFSIZ, "user")) )
top = elem = GetListInfo(ACL_USE, type, name);
while (elem != NULL) {
- info = (char **) elem->q_data;
+ char ** info = (char **) elem->q_data;
sprintf(buf, "Type: %s,\tName: %s", info[0], info[1]);
Put_message(buf);
elem = elem->q_forw;
ListAllGroups()
{
+ register int status;
static char * args[] = {
"TRUE", /* active */
"DONTCARE", /* public */
"FALSE", /* hidden */
"DONTCARE", /* maillist */
"TRUE", /* group. */
- }
+ };
if (YesNoQuestion("This query will take a while, Do you wish to continue?",
- TRUE) )
+ TRUE) == TRUE )
if (status = sms_query("qualified_get_lists", 5, args,
Print, (char *) NULL) != 0)
- com_err(whoami, status, " in ListAllGroups\n");
+ com_err(program_name, status, " in ListAllGroups\n");
return (DM_NORMAL);
}
ListAllMailLists()
{
+ register int status;
static char * args[] = {
"TRUE", /* active */
"DONTCARE", /* public */
"FALSE", /* hidden */
"TRUE", /* maillist */
"DONTCARE", /* group. */
- }
+ };
if (YesNoQuestion("This query will take a while. Do you wish to continue?",
- TRUE) )
+ TRUE) == TRUE )
if (status = sms_query("qualified_get_lists", 5, args,
Print, (char *) NULL) != 0)
- com_err(whoami, status, " in ListAllGroups\n");
+ com_err(program_name, status, " in ListAllGroups\n");
return (DM_NORMAL);
}
ListAllPublicMailLists()
{
+ register int status;
static char * args[] = {
"TRUE", /* active */
"TRUE", /* public */
"FALSE", /* hidden */
"TRUE", /* maillist */
"DONTCARE", /* group. */
- }
+ };
if (YesNoQuestion("This query will take a while. Do you wish to continue?",
- TRUE) )
+ TRUE) == TRUE )
if (status = sms_query("qualified_get_lists", 5, args,
Print, (char *) NULL) != 0)
- com_err(whoami, status, " in ListAllGroups\n");
+ com_err(program_name, status, " in ListAllGroups\n");
return (DM_NORMAL);
}
#include <signal.h>
#include <stdio.h>
#include <strings.h>
+#include <sys/types.h>
#include <sms.h>
#include <menu.h>
#include "mit-copyright.h"
#include "allmaint.h"
+#include "allmaint_funcs.h"
#include "globals.h"
-static void init_listmaint(), error_exit(), usage();
-void Put_message();
+extern Menu allmaint_top_menu;
+static void ErrorExit(), Usage(), SignalHandler();
char *getlogin();
uid_t getuid();
struct passwd *getpwuid();
int argc;
char ** argv;
{
- char buf[BUFSIZ];
+ int status;
if ((user = getlogin()) == NULL)
user = getpwuid((int) getuid())->pw_name;
init_sms_err_tbl();
init_krb_err_tbl();
+ verbose = TRUE;
switch (argc) {
case 2:
if (strcmp(argv[1], "-nomenu") == 0)
use_menu = FALSE;
- else
- usage();
+ else
+ Usage();
/* Fall Through. */
case 1:
if ((program_name = rindex(argv[0], '/')) == NULL)
program_name++;
break;
default:
- usage();
+ Usage();
break;
}
if ( status = sms_connect() )
- error_exit("\nConnection to SMS server failed", status);
+ ErrorExit("\nConnection to SMS server failed", status);
- if ( status = sms_auth(argv[0]) )
- error_exit("\nAuthorization failed -- please run kinit", status);
+ if ( status = sms_auth(program_name) )
+ ErrorExit("\nAuthorization failed -- please run kinit", status);
/*
* These signals should not be set until just before we fire up the menu
* system.
*/
- (void) signal(SIGHUP, signal_handler);
- (void) signal(SIGINT, signal_handler);
- (void) signal(SIGQUIT, signal_handler);
+ (void) signal(SIGHUP, SignalHandler);
+ (void) signal(SIGINT, SignalHandler);
+ (void) signal(SIGQUIT, SignalHandler);
if (use_menu) { /* Start menus that execute program */
Start_paging();
exit(0);
}
-/* Function Name: error_exit
+/* Function Name: ErrorExit
* Description: This function does the error handling and exits.
* Arguments: buf - the error message to print.
* status - the error code.
*/
static void
-error_exit(buf,status);
+ErrorExit(buf,status)
int status;
-char * whoami, *buf;
+char * buf;
{
com_err(program_name, status, buf);
sms_disconnect();
*/
static void
-usage()
+Usage()
{
fprintf(stderr, "Usage: %s [-nomenu]\n", program_name);
exit(1);
}
-/* Function Name: signal_handler
+/* Function Name: SignalHandler
* Description: This function cleans up from a signal interrupt.
* Arguments: none.
* Returns: doesn't
*/
-static int *
-signal_handler()
+void
+SignalHandler()
{
Put_message("Signal caught - exiting");
if (use_menu)
#include <stdio.h>
#include <menu.h>
+
#include "mit-copyright.h"
#include "allmaint.h"
+#include "allmaint_funcs.h"
+#include "globals.h"
/*
* Attachmaint Menus
NULLFUNC,
NULLFUNC,
"Filesystem Maintenance",
- 5,
+ 4,
{
{ GetFS, NULLMENU, 2, {
{"get", "Get Filesystem Name Information"},
{"change", "Update Filesystem Information"},
{"name", "name: "},
} },
- { RenameFS, NULLMENU, 2, {
- {"rename", "Rename Filesystem"},
- {"name", "Current (Old) Name: "},
- } },
{ DeleteFS, NULLMENU, 2, {
{"delete", "Delete Filesystem"},
{"name", "Filesystem Name: "}
"Attach/Filesystem Maintenance",
7,
{
- SUBMENU("filesystem", "Filesystem Work", &filemenu),
+ SUBMENU("filesystem", "Filesystem Work", &attachmaint_filemenu),
{ GetFSAlias, NULLMENU, 2, {
{"check", "Check An Association."},
{"name", "name (user/group/course): "}
NULLFUNC,
NULLFUNC,
"Machine Maintenence",
- 7,
+ 6,
{
{ ShowMachineInfo, NULLMENU, 2, {
- {"ShowMachineInfo","Get machine information."},
+ {"Show","Get machine information."},
{"name","Machine's Name: "}
} },
{ AddMachine, NULLMENU, 2, {
- {"AddMachine","Add a new machine."},
+ {"Add","Add a new machine."},
{"name","Machine's Name: "},
} },
{ UpdateMachine, NULLMENU, 2, {
- {"UpdateMachine","Update machine information."},
+ {"Update","Update machine information."},
{"name","Machine's Name: "},
} },
- { ChangeMachineName, NULLMENU, 2, {
- {"ChangeMachineName", "Change the name of machine"},
- {"old", "Current (old) Machine's Name: "},
- } },
{ DeleteMachine, NULLMENU, 2, {
- {"DeleteMachine","Delete this machine."},
+ {"Delete","Delete this machine."},
{"name","Machine's Name: "}
} },
+ { MachineToClusterMap, NULLMENU, 3, {
+ {"Map", "Show Machine to cluster mapping."},
+ {"name", "Machine's Name:"},
+ {"cluster", "Cluster's Name:"},
+ } },
{ AddMachineToCluster, NULLMENU, 3, {
- {"AddMachineToCluster","Add this machine to a cluster."},
+ {"AddCluster","Add this machine to a cluster."},
{"name","Machine's Name: "},
- {"cluster","Name of the Cluster: "}
+ {"cluster", "Cluster's Name:"},
} },
- { DeleteMachineFromAllClusters, NULLMENU, 2, {
- {"DeleteMachineFromAllClusters",
- "Delete this machine from all clusters."},
+ { RemoveMachineFromCluster, NULLMENU, 2, {
+ {"RemoveCluster", "Remove this machine from a cluster."},
{"name","Machine's Name: "},
} },
}
NULLFUNC,
NULLFUNC,
"Cluster Information",
- 6,
+ 5,
{
{ ShowClusterInfo, NULLMENU, 2, {
- {"info", "Get cluster information."},
+ {"Show", "Get cluster information."},
{"name", "Cluster's Name: "}
} },
{ MachinesInCluster, NULLMENU, 2, {
- {"machines", "List all machines in this cluster."},
+ {"Machines", "List all machines in a cluster."},
{"clus", "Cluster's Name: "}
- } }
+ } },
{ AddCluster, NULLMENU, 2, {
{"add", "Add a new cluster."},
{"name","Cluster's Name: "},
{"update", "Update cluster information."},
{"name","Cluster's Name: "},
} },
- { ChangeClusterName, NULLMENU, 2, {
- {"cname", "Change the name of this cluster."},
- {"old", "Current (old) Cluster's Name: "},
- } },
{ DeleteCluster, NULLMENU, 2, {
{"delete", "Delete this cluster."},
{"name", "Cluster's Name: "}
}
};
-Menu clustermaint_service_menu= {
+Menu clustermaint_data_menu= {
NULLFUNC,
NULLFUNC,
- "Service Cluster Maintenence",
+ "Cluster Data Maintenence",
3,
{
- { ShowServicesForCluster, NULLMENU, 2, {
- {"show_one", "Show a Service Cluster"},
- {"clus", "Cluster's Name: "}
+ { ShowClusterData, NULLMENU, 3, {
+ {"show_one", "Show Data on a given Cluster"},
+ {"clus", "Cluster's Name: "},
+ {"label", "Label Identifing the data"},
} },
- { AddService, NULLMENU, 2, {
- {"add", "Add a Service to a Cluster"},
+ { AddClusterData, NULLMENU, 4, {
+ {"add", "Add Data to a given Cluster"},
{"clus", "Cluster Name: "},
+ {"label", "Label Identifing the data"},
+ {"data", "The data to be added"},
} },
- { DeleteService, NULLMENU, 2, {
- {"delete", "Delete a Service from a Cluster"},
+ { RemoveClusterData, NULLMENU, 4, {
+ {"delete", "Remove Data to a given Cluster"},
{"clus", "Cluster's Name: "},
+ {"label", "Label Identifing the data"},
+ {"data", "The data to be removed"},
} }
}
};
-Menu clusetermaint_top_menu = {
+Menu clustermaint_top_menu = {
NULLFUNC,
NULLFUNC,
"Cluster Maintenence",
{
SUBMENU("machine", "Work on Machines", &clustermaint_machine_menu),
SUBMENU("cluster", "Work on Clusters", &clustermaint_cluster_menu),
- SUBMENU("service", "Service Clusters", &clustermaint_service_menu),
+ SUBMENU("service", "Service Clusters", &clustermaint_data_menu),
{MachineToClusterMap, NULLMENU, 3, {
{"map", "Machine to Cluster Mapping"},
{"machine", "Machine Name: "},
};
Menu listmaint_member_menu = {
- MemberMenuEntry,
- MemberMenuExit,
+ ListmaintMemberMenuEntry,
+ ListmaintMemberMenuExit,
NULL,
6,
{
SIMPLEFUNC("delete", "Delete a member from the list",
DeleteMember),
SIMPLEFUNC("all", "Show the members of the list",
- ListMembers),
+ ListAllMembers),
SIMPLEFUNC("user", "Show the members of type USER",
ListUserMembers),
SIMPLEFUNC("list", "Show the members of type LIST",
{"show", "Display information about a list"},
{"list name", "Name of list: "}
} },
- { UpdateListInfo, NULLMENU, 2, {
+ { UpdateList, NULLMENU, 2, {
{"update", "Update characteristics of a list"},
{"list name", "Name of list: "}
} },
{"members", "Change/Display the membership of a list"},
{"list name", "Name of list: "}
} },
- { DeleteUserFromLists, NULLMENU, 2, {
- { "deluser", "Interactively query/delete user from all lists"},
- { "user name", "Login name of user: "}
- } },
+ SIMPLEFUNC("query_remove",
+ "Interactively remove an item from all lists",
+ InterRemoveItemFromLists),
SUBMENU("list_lists", "Display inventory of lists",
&listmaint_list_menu),
- SIMPLEFUNC("help", "How to use this program", Instructions)
+ SIMPLEFUNC("help", "How to use this program", ListHelp)
}
};
NULLFUNC,
NULLFUNC,
"NFS Maintenence",
- 6,
+ 5,
{
{ ShowNFSService, NULLMENU, 3, {
{ "show", "Show an NFS server " },
{ "machine", "Machine Name: "},
- { "device", "Device: "}
+ { "device", "Directory: "}
} },
{ AddNFSService, NULLMENU, 3, {
{ "add", "Add NFS server" },
{ "machine", "Machine Name: "},
- { "device", "Device: "}
+ { "device", "Directory: "}
} },
{ UpdateNFSService, NULLMENU, 3, {
{ "update", "Update NFS server"},
{ "machine", "Machine Name: "},
- { "device", "Device: "}
+ { "device", "Directory: "}
} },
{ DeleteNFSService, NULLMENU, 3, {
{ "delete", "Delete NFS server"},
{"machine", "Machine Name: "},
- {"device", "Device: "}
+ {"device", "Directory: "}
} },
SIMPLEFUNC("verbose", "Toggle Verbosity of Delete", ToggleVerboseMode),
- SIMPLEFUNC("help", "Help", NFSHelp),
+/* SIMPLEFUNC("help", "Help", NFSHelp), */
}
};
{"create", "Create a quota & locker for a user"},
{"login", "User's login name: "},
{"machine", "Server host name: "},
- {"device", "Physical device on host: "},
+ {"device", "Directory on host: /[dir]/[login] "},
{"quota", "Quota in KB: "}
} },
{DeleteUserLocker, NULLMENU, 2, {
- {"del", "Delete a user's quota & locker"},
+ {"del", "Delete a user's quota & locker - BROKEN 6/10/88 CDP"},
{"login", "User's login: "}
} }
}
{"login name", "Desired login name: "}
} },
{ShowUserByName, NULLMENU, 3, {
- {"full", "Show user information by name (use * for wildcard)."},
+ {"full", "Show user information by name."},
{"first", "First name: "},
{"last", "Last name: "}
} },
{ShowUserByClass, NULLMENU, 2, {
- {"login", "Show names of users in a give class."},
+ {"login", "Show names of users in a given class."},
{"login name", "Desired class: "}
} },
{ModifyUser, NULLMENU, 2, {
* see the file mit-copyright.h
*/
-#include "mit-copyright.h"
-#include "allmaint.h"
-#include "globals.h"
-#include "infodefs.h"
-
#include <stdio.h>
#include <strings.h>
#include <sms.h>
#include <menu.h>
+#include "mit-copyright.h"
+#include "allmaint.h"
+#include "allmaint_funcs.h"
+#include "globals.h"
+#include "infodefs.h"
+
/* #include <sys/types.h> */
#define TYPE_NFS "NFS"
status ? "Active" : "Inactive", info[NFS_ALLOC], info[NFS_SIZE]);
Put_message(temp_buf);
sprintf(temp_buf, "Last Modification by %s at %s with %s.",
- answer[U_MODBY], answer[U_MODTIME], answer[U_MODWITH]);
+ info[U_MODBY], info[U_MODTIME], info[U_MODWITH]);
Put_message(temp_buf);
}
/* Function Name: AskNFSInfo.
*/
char **
-AskNFSInfo(info);
+AskNFSInfo(info)
char ** info;
{
/* Also need name of the machine in this structure. */
FreeAndClear(&info[NFS_MODBY], TRUE);
FreeAndClear(&info[NFS_MODWITH], TRUE);
- return(info)
+ return(info);
}
/* Function Name: ShowNFSService
* Description: This function prints all exported partitions.
- * Arguments: argc, argv - argv[1] - name of filesysytem.
- * argv[2] - name of filesystem device.
+ * Arguments: argc, argv - argv[1] - name of machine.
+ * argv[2] - name of directroy.
* Returns: DM_NORMAL.
*/
if ( (stat = sms_query("get_nfsphys", 2, argv + 1,
StoreInfo, (char *) &elem)) != 0)
- com_err(whoami, stat, " in ShowNFSServices.");
+ com_err(program_name, stat, " in ShowNFSServices.");
top = elem;
while (elem != NULL) {
- info = (char **) elem->q_data;
+ char ** info = (char **) elem->q_data;
PrintNFSInfo(info);
elem = elem->q_forw;
}
* Description: Adds a new partition to the nfsphys relation
* Arguments: arc, argv -
* argv[1] - machine name.
- * argv[2] - device
+ * argv[2] - directory.
* Returns: DM_NORMAL.
*/
NullFunc, (char *) NULL)) == 0) {
Put_message("This service already exists.");
if (stat != SMS_NO_MATCH)
- com_err(whoami, stat, " in get_nfsphys.");
+ com_err(program_name, stat, " in get_nfsphys.");
}
if ( (info[NFS_NAME] = CanonicalizeHostname(argv[1])) == NULL) {
if ((stat = sms_query("add_nfsphys", CountArgs(args), args,
Scream, (char *) NULL)) != 0)
- com_err(whoami, stat, " in AdsNFSService");
+ com_err(program_name, stat, " in AdsNFSService");
FreeInfo(info);
return (DM_NORMAL);
* Description: Update the values for an nfsphys entry.
* Arguments: argc, argv -
* argv[1] - machine name.
- * argv[2] - device
+ * argv[2] - directory.
* Returns: DM_NORMAL.
*/
if ( (stat = sms_query("get_nfsphys", 2, argv + 1,
StoreInfo, (char *) &elem)) != 0) {
- com_err(whoami, stat, " in UpdateNFSService.");
+ com_err(program_name, stat, " in UpdateNFSService.");
return (DM_NORMAL);
}
case FALSE:
update = FALSE;
break;
- case QUIT:
+ default:
FreeQueue(top);
Put_message("Aborting update.");
- Return(DM_NORMAL);
- break;
+ return(DM_NORMAL);
}
}
else
if (update) { /* actually perform update */
args = AskNFSInfo(info);
- if ((stat = sms_query("update_nfsphys", num_args, args,
- abort, (char *)NULL)) != 0)
- com_err(whoami, stat, (char *) NULL);
+ if ((stat = sms_query("update_nfsphys", CountArgs(args), args,
+ Scream, (char *)NULL)) != 0)
+ com_err(program_name, stat, (char *) NULL);
}
- elem = elem->q_next;
+ elem = elem->q_forw;
}
FreeQueue(top);
return (DM_NORMAL);
}
-/* stop CDP 6/7/88 */
-
-/* Function Name: DeleteCheck
- * Description: This checks to see if we should delete this nfs
- * Arguments: argc, argv -
- * argv[0] - name of file system.
- * argv[1] - type of file system.
- * argv[3] - packname of fulsys
- * data - a filled info structure.
- * Returns: SMS_CONT.
- */
-
-DeleteCheck(argc, argv, date)
-int argc;
-char **argv, *data;
-{
- char buf[BUFSIZ];
- NFS_info *info = (NFS_info *) data;
-
- return(SMS_CONT);
-}
-
/* Function Name: DeleteNFSService
* Description: Delete an nfsphys entry.
* Arguments: argc, argv - name of file system in argv[1].
char **argv;
{
register int stat;
- struct qelem *elem, *top;
+ struct qelem *top, *elem = NULL;
char * dir = argv[2];
int length;
Bool delete_ok = TRUE;
- elem = NULL;
argv[1] = CanonicalizeHostname(argv[1]);
stat = sms_query("get_nfsphys", 2, argv + 1, NullFunc, (char *) NULL);
return(DM_NORMAL);
}
if (stat) {
- com_err(whoami, stat, " in DeleteNFSService");
+ com_err(program_name, stat, " in DeleteNFSService");
return(DM_NORMAL);
}
stat = sms_query("get_filesys_by_machine", 1, argv + 1, StoreInfo,
&elem);
if (stat && stat != SMS_NO_MATCH)
- com_err(whoami, stat, " while checking usage of partition");
+ com_err(program_name, stat, " while checking usage of partition");
length = strlen( dir );
top = elem;
while (elem != NULL) {
- info = (char ** ) elem->q_data;
+ char buf[BUFSIZ];
+ char ** info = (char ** ) elem->q_data;
if ( (strcmp(info[FS_TYPE], TYPE_NFS) == 0) &&
(strcmp(info[FS_PACK], dir, length) == 0) ) {
sprintf(buf, "Filesystem %s uses that partition", info[FS_NAME]);
Confirm("Do you really want to delete this Filesystem? (y/n) ")) {
if ( (stat = sms_query("delete_nfsphys", 2, argv + 1,
Scream, (char *) NULL )) !=0 )
- com_err(whoami, stat, " in DeleteNFSService");
+ com_err(program_name, stat, " in DeleteNFSService");
}
else
Put_message("Operation Aborted.\n");
-ifndef lint
+#ifndef lint
static char rcsid_module_c[] = "$Header$";
#endif lint
* see the file mit-copyright.h
*/
-#include "mit-copyright.h"
-#include "allmaint.h"
-#include "infodefs.h"
-
#include <stdio.h>
#include <strings.h>
#include <ctype.h>
-
-/* SMS includes */
-
#include <sms.h>
-#include <sms_app.h>
#include <menu.h>
+#include "mit-copyright.h"
+#include "allmaint.h"
+#include "allmaint_funcs.h"
+#include "globals.h"
+#include "infodefs.h"
+
#define LOGIN 0
#define UID 1
#define NAME 2
#define QUOTA 3
#define CLASS 4
+static void PrintQuota(); /* prints Quota info. */
+static void PrintUserInfo(); /* prints User info. */
+static int PrintPOBoxes(); /* prints PO Box information. */
+
/* Function Name: AskUserInfo.
* Description: This function askes the user for information about a
* machine and saves it into a structure.
* use the #defined names (e.g args[UID] is not the uid anymore).
*/
-void
-AskUserInfo(info, name);
+char **
+AskUserInfo(info, name)
char ** info;
Bool name;
{
- char * temp_buf, *newname;
-
- int counter;
+ char temp_buf[BUFSIZ], *newname;
sprintf(temp_buf,"\nChanging Attributes of user %s.\n",info[NAME]);
Put_message(temp_buf);
*/
struct qelem *
-GetUserInfo(type, name1, name2);
+GetUserInfo(type, name1, name2)
int type;
char *name1, *name2;
{
char * args[2];
- struct quelem * elem = NULL;
+ register int status;
+ struct qelem * elem = NULL;
switch(type) {
case LOGIN:
args[0] = name1;
if ( (status = sms_query("get_user_by_login", 1, args,
- StoreInfo, (caddr_t) &elem)) != 0) {
- com_err(whoami, status, " when attempting to get_use_by_login.");
+ StoreInfo, (char *) &elem)) != 0) {
+ com_err(program_name, status, " when attempting to get_use_by_login.");
return (NULL);
}
break;
case UID:
args[0] = name1;
if ( (status = sms_query("get_user_by_uid", 1, args,
- StoreInfo, (caddr_t) &elem)) != 0) {
- com_err(whoami, status, " when attempting to get_use_by_uid.");
+ StoreInfo, (char *) &elem)) != 0) {
+ com_err(program_name, status,
+ " when attempting to get_use_by_uid.");
return (NULL);
}
break;
args[0] = name1;
args[1] = name2;
if ( (status = sms_query("get_user_by_name", 1, args,
- StoreInfo, (caddr_t) &elem)) != 0) {
- com_err(whoami, status, " when attempting to get_use_by_name.");
+ StoreInfo, (char *) &elem)) != 0) {
+ com_err(program_name, status,
+ " when attempting to get_use_by_name.");
return (NULL);
}
break;
case CLASS:
args[0] = name1;
if ( (status = sms_query("get_user_by_class", 1, args,
- StoreInfo, (caddr_t) &elem)) != 0) {
- com_err(whoami, status, " when attempting to get_use_by_class.");
+ StoreInfo, (char *) &elem)) != 0) {
+ com_err(program_name, status,
+ " when attempting to get_use_by_class.");
return (NULL);
}
break;
args[0] = name1;
if ( (status = sms_query("get_nquotas_by_user", 1, args,
StoreInfo, (char *) &elem)) != 0) {
- com_err(whoami, status, " in get_nfs_quotas_by_user");
+ com_err(program_name, status, " in get_nfs_quotas_by_user");
return (DM_NORMAL);
}
break;
int argc;
char **argv;
{
- int num_args;
- char ** info;
- char *temp_buf;
- struct qelem * user, * local;
+ int status;
+ char *temp_buf, error_buf[BUFSIZ];
+ struct qelem * elem, * local;
- user = GetUserInfo(LOGIN, argv[1], (char *) NULL);
+ local = elem = GetUserInfo(LOGIN, argv[1], (char *) NULL);
- local = user;
while (local != NULL) {
- info = (char **) local->q_data;
- info = AskUserInfo(info, TRUE);
- num_args = CountArgs(info);
+ char ** info = (char **) local->q_data;
+ char ** args = AskUserInfo(info, TRUE);
- if ( (status = sms_query("update_user",
- num_args, info, Scream, NULL)) != 0) {
- com_err(whoami, status, " in ModifyFields");
- if (local->next == NULL)
+ if ( (status = sms_query("update_user", CountArgs(args),
+ args, Scream, NULL)) != 0) {
+ com_err(program_name, status, " in ModifyFields");
+ if (local->q_forw == NULL)
temp_buf = "";
else
temp_buf = ", Continuing to next user";
info[NAME], temp_buf);
Put_message(error_buf);
}
- local = local->next;
+ local = local->q_forw;
}
- FreeQueue(user);
+ FreeQueue(elem);
return(DM_NORMAL);
}
char * type;
struct qelem *top, *elem = NULL;
- match = 0;
type = "pop";
status = sms_query("get_server_locations", 1, &type,
StoreInfo, &elem);
if (status && (status != SMS_NO_MATCH)) {
- com_err(whoami, status, (char *) NULL);
+ com_err(program_name, status, (char *) NULL);
return( (char *) NULL);
}
top = elem;
while (elem != NULL) {
- info = (char **) elem->q_data;
+ char ** info = (char **) elem->q_data;
if (strcmp (info[1], machine) == 0) {
FreeQueue(top);
return( Strsave("POP") );
int argc;
char **argv;
{
+ register int status;
struct qelem * poqueue, *local;
- char *type, buf[BUFSIZ];
- extern int po_callbk(), PrintPOBoxes();
+ char *type, buf[BUFSIZ], *pohost;
static char *po[4];
poqueue = NULL;
Put_message(buf);
status = sms_query("get_pobox", 1, argv + 1, PrintPOBoxes, NULL);
if (status != SMS_NO_MATCH && status != 0) {
- com_err(whoami, status, "in ChangeUserPOBox.");
+ com_err(program_name, status, "in ChangeUserPOBox.");
return(DM_NORMAL);
}
else if (status == SMS_NO_MATCH)
if (YesNoQuestion("Shall we use the least loaded Post Office?", TRUE)) {
po[0] = "pop";
po[1] = "*";
- post_office.host = NULL;
- post_office.least_full = -1;
if ( status = sms_query ("get_server_host_info", 2, po,
- StoreInfo, (caddr_t) &poqueue) != 0) {
- com_err(whoami, status,
+ StoreInfo, (char *) &poqueue) != 0) {
+ com_err(program_name, status,
" in ChangeUserPOBox (get_server_host_info).");
return(DM_NORMAL);
}
local = poqueue;
while (local != NULL) {
- if ( !isdigit(*argv[6]) || !isdigit(*argv[7]) )
- put_message(
- "non-digit value in server_host_info, this is a bug");
+ char ** args = (char **) local->q_data;
+ int new_space, old_space = -1 ;
+ if ( !isdigit(*args[6]) || !isdigit(*args[7]) )
+ Put_message(
+ "non-digit value in server_host_info, this is a bug.");
else {
- new_space = atoi(argv[7]) - atoi(argv[6]);
- if ( new_space < old_space ) {
+ new_space = atoi(argv[7]) - atoi(args[6]);
+ if ( (new_space < old_space) || (old_space == -1) ) {
old_space = new_space;
- pohost = argv[1];
+ strcpy(buf, args[1]);
}
}
- local = local->next;
+ local = local->q_forw;
}
+ pohost = Strsave(buf);
FreeQueue(poqueue);
type = "POP";
(void) sprintf(buf, "The Post Office %s was chosen.",
po[2] = pohost;
po[3] = po[0];
if (status = sms_query("set_pobox", 4, po, Scream, NULL) != 0 )
- com_err(whoami, status, " in ChangeUserPOBox");
+ com_err(program_name, status, " in ChangeUserPOBox");
} else
- PutMessage("Operation Aborted.");
+ Put_message("Operation Aborted.");
return (DM_NORMAL);
}
int argc;
char **argv;
{
+ int status;
+
if (Confirm("Are you sure you want to remove this user"))
if ( (status = sms_query("delete_user_by_uid", 1, argv+1, Scream,
(char * ) NULL)) != 0)
- com_err(whoami, status, " in DeleteUserByUid");
+ com_err(program_name, status, " in DeleteUserByUid");
return(DM_NORMAL);
}
int
ShowDefaultQuota()
{
- extern int printit();
+ int status;
static char *val[] = {"def_quota"};
if (status = sms_query("get_value", 1, val, Print, (char *) NULL) != 0)
- com_err(whoami, status, " in ShowDefaultQuota");
+ com_err(program_name, status, " in ShowDefaultQuota");
return (DM_NORMAL);
}
int argc;
char **argv;
{
- extern int PrintQuota();
-
- if (status = sms_query("get_nfs_quotas_by_user", 1, argv+1, PrintQuota,
- (char *) NULL) != 0)
- com_err(whoami, status, " in ShowUserQuota);
-
+ struct qelem *elem, *top;
+ top = elem = GetUserInfo(QUOTA, argv[1], (char *) NULL);
+
+ while (elem != NULL) {
+ char ** info = (char **) elem->q_data;
+ PrintQuota(info);
+ elem = elem->q_forw;
+ }
+ FreeQueue(top);
return (DM_NORMAL);
}
int argc;
char *argv[];
{
+ char buf[BUFSIZ];
+ int status;
static char *newval[] = {
"update_value", "def_quota", NULL,
};
sprintf(buf,"%s%s",
"Are you sure that you want to change the default quota\n"
- "for all new users");
+ "for all new users? (y/n) ");
if(!Confirm(buf)) {
newval[2] = argv[1];
if (status = sms_query("update_value", 3, newval, Scream, NULL) != 0)
- com_err(whoami, status, " in update_value");
+ com_err(program_name, status, " in update_value");
}
else
Put_message("Quota not changed.");
* Arguments: arc, argv -
* argv[1] login name of user.
* argv[2] server host name.
- * argv[3] physical device on host.
+ * argv[3] Directory on host.
* argv[4] quota in Kb.
* Returns: DM_NORMAL.
*/
int argc;
char **argv;
{
- extern char *CanonicalizeHostname();
- char *tuple[4];
+ int status;
+ char *args[4];
args[0] = argv[1];
args[2] = argv[3];
}
if (status = sms_query("add_locker", 4, args, Scream, NULL) != 0)
- com_err(whoami, status, " in add_user_locker");
+ com_err(program_name, status, " in add_user_locker");
return(DM_NORMAL);
}
+/* needs to be fixed - CDP 6/10/88 */
+
/* Function Name: DeleteUserLocker
* Description: Deletes a locker - BOOM.
* Arguments: arc, argv - the name of the locker in argv[1]/
int argc;
char **argv;
{
+ int status;
if (status = sms_query("delete_locker", 1, argv + 1,
- scream, (char *)NULL) != 0)
- com_err(whoami, status, " in delete_locker");
+ Scream, (char *)NULL) != 0)
+ com_err(program_name, status, " in delete_locker");
return(DM_NORMAL);
}
int argc;
char *argv[];
{
- int i;
+ int status;
+ char error_buf[BUFSIZ];
struct qelem *elem, *local;
elem = GetUserInfo(QUOTA, argv[1], (char *) NULL);
local = elem;
while (local != NULL) {
- char *info[4], buf[BUFSIZ];
+ char **info;
info = (char **) local->q_data;
PrintQuota(info);
- if( !PromptWithDefault("New quota (in KB): ", buf, sizeof(buf),
- quot_array[2]) )
- return(DM_NORMAL);
+ GetValueFromUser("New quota (in KB): ", &info[Q_QUOTA]);
- /* Reorganize for update nfs_quota. */
- info[3] = info[2];
- info[2] = argv[1];
-
- if (status = sms_query("update_nfs_quota", 4, info,
+ if (status = sms_query("update_nfs_quota", 3, info,
Scream, (char *) NULL) != 0) {
- com_err(whoami, status, " in update_nfs_quota");
- sprintf(error_buf,"Could not perform quota change on %s",info[0]);
+ com_err(program_name, status, " in update_nfs_quota");
+ sprintf(error_buf,"Could not perform quota change on %s",
+ info[Q_FILESYS]);
Put_message(error_buf);
}
local = local->q_forw;
char *argv[];
{
struct qelem *top, *elem;
- char buf, temp_buf[BUFSIZ];
+ char buf;
elem = top = GetUserInfo(NAME, argv[1], argv[2]);
break;
case 'N':
case 'n':
- break;
PrintUserInfo( (char **) elem->q_data, TRUE);
+ break;
}
- elem = elem->q_next;
+ elem = elem->q_forw;
}
FreeQueue(top);
char **argv;
{
struct qelem *top, *elem;
- char buf, temp_buf[BUFSIZ];
elem = top = GetUserInfo(CLASS, argv[1], (char *) NULL);
while (elem != NULL) {
PrintUserInfo( (char **) elem->q_data, TRUE);
- elem = elem->q_next;
+ elem = elem->q_forw;
}
FreeQueue(top);
PrintQuota(info)
char ** info;
{
- sprintf(buf, "Machine: %s\t\tDevice: %s\t\tQuota: %s",
- info[Q_MACHINE], info[Q_DEVICE], info[Q_QUOTA]);
+ char buf[BUFSIZ];
+
+ sprintf(buf, "Machine: %s\t\tDirectory: %s\t\tQuota: %s",
+ info[Q_MACHINE], info[Q_DIRECTORY], info[Q_QUOTA]);
Put_message(buf);
}
PrintPOBoxes(argc, argv, junk)
int argc;
char **argv;
-caddr_t junk;
+char * junk;
{
+ char buf[BUFSIZ];
/* no newline 'cause Put_message adds one */
(void) sprintf(buf, "Address: %s@%s\t\tType: %s", argv[PO_BOX],
/* Function Name: PrintUserInfo
* Description: Prints Information about a user.
- * Arguments: answer - an argument list with the user information
+ * Arguments: info - an argument list with the user information
* in it.
* name_only - if TRUE then print only the users name.
* Returns: none
*/
void
-PrintUserInfo(answer, name_only)
-char ** answer;
+PrintUserInfo(info, name_only)
+char ** info;
Bool name_only;
{
+ char buf[BUFSIZ];
+
if (name_only) {
- sprintf(temp_buf, "%s, %s %s", info[U_LAST],
+ sprintf(buf, "%s, %s %s", info[U_LAST],
info[U_FIRST], info[U_MIDDLE]);
- sprintf(temp_buf, "%-40s/tUser Name: %s", temp_buf, info[U_NAME]);
- Put_message(temp_buf);
+ sprintf(buf, "%-40s/tUser Name: %s", buf, info[U_NAME]);
+ Put_message(buf);
}
else {
- (void) sprintf(temp_buf,
+ (void) sprintf(buf,
"Login name: %-10s/tUser id: %-10s\tLogin shell %s",
- answer[U_NAME], answer[U_UID], answer[U_SHELL]);
- (void) Put_message(temp_buf);
- (void) sprintf(temp_buf, "Full name: %s %s %s\tClass: %s",
- answer[U_FIRST], answer[U_MIDDLE],
- answer[U_LAST], answer[U_CLASS]);
- (void) Put_message(temp_buf);
- (void) sprintf(temp_buf,
- "Account status: %2s\tEncrypted MIT ID number: %s",
- answer[U_STATUS], answer[U_MITID]);
- (void) Put_message(temp_buf);
- (void) sprintf(temp_buf, "Last Modification by %s at %s with %s.",
- answer[U_MODBY], answer[U_MODTIME], answer[U_MODWITH]);
- (void) Put_message(temp_buf);
+ info[U_NAME], info[U_UID], info[U_SHELL]);
+ (void) Put_message(buf);
+ (void) sprintf(buf, "Full name: %s %s %s\tClass: %s",
+ info[U_FIRST], info[U_MIDDLE],
+ info[U_LAST], info[U_CLASS]);
+ (void) Put_message(buf);
+ (void) sprintf(buf,
+ "Account status: %s\tEncrypted MIT ID number: %s",
+ atoi(info[U_STATE]) ? "active" : "inactive",
+ info[U_MITID]);
+ (void) Put_message(buf);
+ (void) sprintf(buf, "Last Modification by %s at %s with %s.",
+ info[U_MODBY], info[U_MODTIME], info[U_MODWITH]);
+ (void) Put_message(buf);
}
}
#include "mit-copyright.h"
#include "allmaint.h"
+#include "allmaint_funcs.h"
#include "globals.h"
#include "infodefs.h"
free(pointer++);
}
+/* Function Name: FreeAndClear - I couldn't resist the name.
+ * Description: Clears pointer and optionially frees it.
+ * Arguments: pointer - pointer to work with.
+ * free_it - if TRUE then free pointer.
+ * Returns: none.
+ */
+
+void
+FreeAndClear(pointer, free_it)
+char ** pointer;
+Bool free_it;
+{
+ if (*pointer == NULL)
+ return;
+ else if (free_it)
+ free(*pointer);
+ *pointer = NULL;
+}
+
+/* Function Name: QueueTop
+ * Description: returns a qelem pointer that points to the top of
+ * a queue.
+ * Arguments: elem - any element of a queue.
+ * Returns: top element of a queue.
+ */
+
+struct qelem *
+QueueTop(elem)
+struct qelem * elem;
+{
+ if (elem == NULL) /* NULL returns NULL. */
+ return(NULL);
+ while (elem->q_back != NULL)
+ elem = elem->q_back;
+ return(elem);
+}
+
/* Function Name: FreeQueueElem
* Description: Frees one element of the queue.
* Arguments: elem - the elem to free.
void
FreeQueueElem(elem)
-struct queue * elem;
+struct qelem * elem;
{
- if (elem->q_data != (char *) NULL) {
- FreeInfo( (char **) elem->q_data); /* free info fields */
+ char ** info = (char **) elem->q_data;
+
+ if (info != (char **) NULL) {
+ FreeInfo( info ); /* free info fields */
free(elem->q_data); /* free info array itself. */
}
- rmqueue(elem); /* remove this element from the queue */
+ remque(elem); /* remove this element from the queue */
free(elem); /* free its space. */
}
void
FreeQueue(elem)
-struct queue * elem;
+struct qelem * elem;
{
- struct queue *temp, *local = QueueTop(elem);
+ struct qelem *temp, *local = QueueTop(elem);
while(local != NULL) {
temp = local->q_forw;
return(count);
}
-/* Function Name: QueueTop
- * Description: returns a qelem pointer that points to the top of
- * a queue.
- * Arguments: elem - any element of a queue.
- * Returns: top element of a queue.
- */
-
-struct qelem *
-QueueTop(elem)
-struct qelem * elem;
-{
- if (elem == NULL) /* NULL returns NULL. */
- return(NULL);
- while (elem->q_back != NULL)
- elem = elem->q_back;
- return(elem);
-}
-
/* ARGSUSED */
int
StoreInfo(argc, argv, data)
int argc;
char ** argv;
-caddr_t data;
+char * data;
{
char ** info = (char **) malloc( MAX_ARGS_SIZE * sizeof(char *) );
struct qelem ** old_elem = (struct qelem **) data;
info[count] = Strsave(argv[count]);
info[count] = NULL; /* NULL terminate this sucker. */
- if (* old_elem == (struct qelem **) NULL) { /* first elem. */
+ if (*old_elem == (struct qelem *) NULL) { /* first elem. */
new_elem->q_data = (char *) info;
new_elem->q_forw = new_elem->q_back = (struct qelem *) NULL;
}
*/
int
-CountArgs(info);
+CountArgs(info)
char ** info;
{
int number = 0;
- while (*info != NULL)
+ while (*info != NULL) {
number++;
+ info++;
+ }
return(number);
}
* Returns: doesn't exit.
*/
-static int
+int
Scream()
{
- com_err(whoami, status,
+ com_err(program_name, 0,
"\nAn SMS update returned a value -- programmer botch\n");
sms_disconnect();
exit(1);
}
-/* Function Name: BoolAnswer
- * Description: returns TRUE or FALSE in arg, depending upon
- * the value of the string in argv[0].
- * Arguments: argc, argv - argv[0] contains "true" or "false".
- * Returns: SMS_CONT.
- */
-
-/*ARGSUSED*/
-static int
-BoolAnswer(argc, argv, arg)
-int argc;
-char *argv[];
-caddr_t arg;
-
-{
- int *result = (int *) arg;
-
- if (strcmp(argv[0], "true") == 0)
- *result = TRUE;
- else
- *result = FALSE;
- return(SMS_CONT);
-}
-
-/* Function Name: BoolQuery
- * Description: This function makes the query, but returns TRUE or FALSE
- * instead of SMS_CONT or SMS_QUIT.
- * Arguments: name - name of query
- * argc, argv - args to pass to query.
- * Returns: TRUE or FALSE.
- */
-
-Bool
-BoolQuery(name, argc, argv)
-char *name;
-int argc;
-char *argv[];
-{
- sms_query(name, argc, argv, BoolAnswer, (caddr_t) & result);
- return(result);
-}
-
/* Function Name: PromptWithDefault
* Description: allows a user to be prompted for input, and given a
* default choice.
case 'n':
case 'N':
return(FALSE);
- break;
case 'y':
case 'Y':
return(TRUE);
- break;
default:
Put_message("Please answer 'y' or 'n'.");
break;
*/
Bool
-YesNoQuestion(prompt, bool_def)
+YesNoQuitQuestion(prompt, bool_def)
char *prompt;
int bool_def;
{
case 'n':
case 'N':
return(FALSE);
- break;
case 'y':
case 'Y':
return(TRUE);
- break;
case 'q':
case 'Q':
return(-1);
- break;
default:
Put_message("Please answer 'y', 'n' or 'q'.");
break;
* Returns: TRUE/FALSE - wether or not the confirmation occured.
*/
-static int
+int
Confirm(prompt)
char * prompt;
{
ToggleVerboseMode()
{
- if(verbose)
- Put_message("Delete functions will be silent\n");
- else {
- Put_message("Delete functions will first confirm\n");
-
- verbose ~= verbose;
+ verbose = ~verbose;
+ if (verbose)
+ Put_message("Delete functions will first confirm\n");
+ else
+ Put_message("Delete functions will be silent\n");
+
return(DM_NORMAL);
}
* big way.
*/
-SlipInNewName(info, name);
+SlipInNewName(info, name)
char ** info;
-
char * name;
{
register int i;
info[1] = Strsave(name); /* now slip in the name. */
}
-/* Function Name: FreeAndClear - I couldn't resist the name.
- * Description: Clears pointer and optionially frees it.
- * Arguments: pointer - pointer to work with.
- * free - if TRUE then free pointer.
- * Returns: none.
- */
-
-FreeAndClear(pointer, free)
-caddr_t pointer;
-Bool free;
-{
- if (pointer == NULL)
- return();
- else if (free)
- free(pointer);
-
- pointer = NULL;
-}
-
/* Function Name: GetValueFromUser
* Description: This function gets a value from a user for the field
* specified.
void
GetValueFromUser(prompt, pointer)
-char * prompt, * pointer;
+char * prompt, ** pointer;
{
char buf[BUFSIZ];
- PromptWithDefault(prompt, buf, BUFSIZ, pointer);
+ PromptWithDefault(prompt, buf, BUFSIZ, *pointer);
if ( pointer != NULL)
- free(pointer);
- pointer = Strsave(buf);
+ free(*pointer);
+ *pointer = Strsave(buf);
}
/* Function Name: CanonicalizeHostname
char **argv, *callback;
{
char buf[BUFSIZ];
+ register int i;
found_some = TRUE;
(void) strcpy(buf,argv[0]); /* no newline 'cause Put_message adds one */
*/
int
-PrintHelp(message);
+PrintHelp(message)
char ** message;
{
Print(CountArgs(message), message, (char *) NULL);
#include "mit-copyright.h"
+/* alias queries. */
-/* Machine information queries */
-
-#define M_NAME 0
-#define M_TYPE 1
-#define M_MODTIME 2
-#define M_MODBY 3
-#define M_MODWITH 4
-#define M_END 5
-
-/* Machine to Cluster mapping */
-
-#define MAP_MACHINE 0
-#define MAP_CLUSTER 1
-#define MAP_END 2
+#define ALIAS_NAME 0
+#define ALIAS_TYPE 1
+#define ALIAS_TRANS 2
+#define ALIAS_END 3
/* Cluster information queries */
#define CD_DATA 2
#define CD_END 3
+/* Delete Member from list queries. */
+
+#define DM_LIST 0
+#define DM_TYPE 1
+#define DM_MEMBER 2
+#define DM_END 3
+
+/* Filesys queries (attachmaint) */
+
+#define FS_NAME 0
+#define FS_TYPE 1
+#define FS_MACHINE 2
+#define FS_PACK 3
+#define FS_M_POINT 4
+#define FS_ACCESS 5
+#define FS_COMMENTS 6
+#define FS_OWNER 7
+#define FS_OWNERS 8
+#define FS_CREATE 9
+#define FS_L_TYPE 10
+#define FS_MODTIME 11
+#define FS_MODBY 12
+#define FS_MODWITH 13
+#define FS_END 14
+
+/* Get List Of Member queries. */
+
+#define GLOM_NAME 0
+#define GLOM_ACTIVE 1
+#define GLOM_PUBLIC 2
+#define GLOM_HIDDEN 3
+#define GLOM_MAILLIST 4
+#define GLOM_GROUP 5
+#define GLOM_END 6
+
/* General List information Queries. */
#define L_NAME 0
#define L_ACL_NAME 8
#define L_DESC 9
#define L_MODTIME 10
-#define L_MODWHO 11
+#define L_MODBY 11
#define L_MODWITH 12
#define L_END 13
-/* Get List Of Member queries. */
-
-#define GLOM_NAME 0
-#define GLOM_ACTIVE 1
-#define GLOM_PUBLIC 2
-#define GLOM_HIDDEN 3
-#define GLOM_MAILLIST 4
-#define GLOM_GROUP 5
-#define GLOM_END 6
-
/* List Member information queries. */
#define LM_LIST 0
#define LM_TYPE 1
#define LM_MEMBER 2
#define LM_END 3
-#define LM_END 4
+
+/* Machine information queries */
+
+#define M_NAME 0
+#define M_TYPE 1
+#define M_MODTIME 2
+#define M_MODBY 3
+#define M_MODWITH 4
+#define M_END 5
+
+/* Machine to Cluster mapping */
+
+#define MAP_MACHINE 0
+#define MAP_CLUSTER 1
+#define MAP_END 2
/* NFS phys. queries. */
#define NFS_MODWITH 8
#define NFS_END 9
-/* Quota queries */
-
-#define Q_MACHINE 0
-#define Q_DEVICE 1
-#define Q_QUOTA 2
-#define Q_END 3
-
/* PO box infomarion queries */
#define PO_NAME 0
#define PO_BOX 3
#define PO_END 4
+/* Quota queries */
+
+#define Q_FILESYS 0
+#define Q_LOGIN 1
+#define Q_QUOTA 2
+#define Q_DIRECTORY 3
+#define Q_MACHINE 4
+#define Q_MODTIME 5
+#define Q_MODBY 6
+#define Q_MODWITH 7
+#define Q_END 8
+
/* User Information queries */
#define U_NAME 0