--- freem/src/fmadm.c 2025/04/02 14:37:57 1.26
+++ freem/src/fmadm.c 2025/04/15 02:24:43 1.38
@@ -1,5 +1,5 @@
/*
- * $Id: fmadm.c,v 1.26 2025/04/02 14:37:57 snw Exp $
+ * $Id: fmadm.c,v 1.38 2025/04/15 02:24:43 snw Exp $
* FreeM Administration Tool
*
*
@@ -24,6 +24,42 @@
* along with FreeM. If not, see .
*
* $Log: fmadm.c,v $
+ * Revision 1.38 2025/04/15 02:24:43 snw
+ * Improve FreeM logging capabilities
+ *
+ * Revision 1.37 2025/04/14 19:20:20 snw
+ * Create LOCALSTATEDIR during fmadm configure if needed
+ *
+ * Revision 1.36 2025/04/13 15:12:21 snw
+ * Fix transaction checkpoints on OS/2 [CLOSES #34]
+ *
+ * Revision 1.35 2025/04/13 04:22:43 snw
+ * Fix snprintf calls
+ *
+ * Revision 1.34 2025/04/10 15:31:25 snw
+ * Attempt to fix DosCopy calls for OS/2
+ *
+ * Revision 1.33 2025/04/10 01:24:38 snw
+ * Remove C++ style comments
+ *
+ * Revision 1.32 2025/04/09 19:52:02 snw
+ * Eliminate as many warnings as possible while building with -Wall
+ *
+ * Revision 1.31 2025/04/04 19:43:18 snw
+ * Switch to using environment catalog to determine user and group for environment, and remove -u and -g flags from freem
+ *
+ * Revision 1.30 2025/04/03 20:48:14 snw
+ * Improve daemon error diagnostics and bump to 0.63.0-rc3
+ *
+ * Revision 1.29 2025/04/03 01:41:02 snw
+ * New features frozen; prepare 0.63.0-rc1
+ *
+ * Revision 1.28 2025/04/02 19:59:38 snw
+ * Automatically modify env.conf from fmadm reconfigure
+ *
+ * Revision 1.27 2025/04/02 15:36:25 snw
+ * Do extensive result checking for environment stop/start/restart in fmadm
+ *
* Revision 1.26 2025/04/02 14:37:57 snw
* Improve environment control parts of fmadm
*
@@ -101,15 +137,14 @@
#include
#include
#include
+#if defined(__OS2__)
+# include
+#endif
#include "config.h"
#include "transact.h"
#include "namespace.h"
#include "fs.h"
-#if defined(__OS2__)
-# include
-#endif
-
#ifdef HAVE_LIBREADLINE
# if defined(HAVE_READLINE_READLINE_H)
# include
@@ -168,6 +203,7 @@ extern char config_file[4096];
extern char env_config_file[4096];
extern char env_user[255];
extern char env_group[255];
+extern char env_enabled[10];
int fm_shell(void);
void fm_checkperms(void);
@@ -177,6 +213,7 @@ int fm_daemonctl (short action, short ob
void fm_write (FILE *file, char *buf);
int fma_jobs_remove (int optc, char **opts);
void set_permissions(char *path, char *user, char *grp, int mode);
+int fm_environment_running (char *env);
extern int read_profile_string(char *file, char *section, char *key, char *value);
int main (int argc, char **argv)
@@ -197,6 +234,7 @@ int main (int argc, char **argv)
short got_action = FALSE;
short got_object = FALSE;
+ strcpy (env_enabled, "true");
/* snprintf (config_file, 4096, "%s/freem.conf", SYSCONFDIR); */
@@ -283,6 +321,31 @@ int main (int argc, char **argv)
base_arg++;
break;
+
+ case 'E':
+ if (argv[i][2] != '=') {
+ fprintf (stderr, "fmadm: missing equals sign in flag -%c\n", argv[i][1]);
+ fmadm_usage ();
+ exit (1);
+ }
+
+ k = 0;
+
+ for (j = 3; j < strlen (argv[i]); j++) {
+ env_enabled[k++] = argv[i][j];
+ }
+ env_enabled[k] = '\0';
+
+ if ((strcmp (env_enabled, "true") != 0) && (strcmp (env_enabled, "false") != 0)) {
+ fprintf (stderr, "fmadm: -E (environment enabled) option must be either 'true' or 'false'\n");
+ fmadm_usage ();
+ exit (1);
+ }
+
+ base_arg++;
+
+ break;
+
case 'n':
if (argv[i][2] != '=') {
@@ -308,21 +371,21 @@ int main (int argc, char **argv)
if (obj != OBJ_DAEMON) {
if (strlen (env_user) == 0) {
- snprintf (env_user, 6, "freem");
+ snprintf (env_user, sizeof (env_user) - 1, "freem");
}
if (strlen (env_group) == 0) {
- snprintf (env_group, 6, "freem");
+ snprintf (env_group, sizeof (env_group) - 1, "freem");
}
- if (!fma_explicit_environment) snprintf (fma_environment, 4096, "DEFAULT");
- if (!fma_explicit_namespace) snprintf (fma_namespace, 4096, "SYSTEM");
+ if (!fma_explicit_environment) snprintf (fma_environment, sizeof (fma_environment) - 1, "DEFAULT");
+ if (!fma_explicit_namespace) snprintf (fma_namespace, sizeof (fma_namespace) - 1, "SYSTEM");
- snprintf (config_file, 4096, "%s/freem/%s/freem.conf", SYSCONFDIR, fma_environment);
+ snprintf (config_file, sizeof (config_file) - 1, "%s/freem/%s/freem.conf", SYSCONFDIR, fma_environment);
}
- snprintf (env_config_file, 4096, "%s/freem/env.conf", SYSCONFDIR);
+ snprintf (env_config_file, sizeof (env_config_file) - 1, "%s/freem/env.conf", SYSCONFDIR);
/*
printf ("action = '%s' object = '%s' environment = '%s' namespace = '%s' config_file = '%s' base_arg = '%d' next argument = '%s'\n", action, obj_str, fma_environment, fma_namespace, config_file, base_arg, argv[base_arg]);
@@ -560,10 +623,7 @@ int fm_shell (void)
char *cmdt = (char *) malloc (65535 * sizeof (char));
char *result = (char *) malloc (65535 * sizeof (char));
- /*
- strcpy (fma_namespace, "SYSTEM");
- set_namespace (fma_namespace, FALSE);
- */
+ obj = 0;
snprintf (fma_prompt, STRLEN - 1, "fmadm [%s]> ", fma_namespace);
@@ -668,7 +728,6 @@ int fm_shell (void)
i = 0;
while ((result = strtok (NULL, " ")) != NULL) {
- // printf ("%d = %s\n", i, result);
strcpy (args[i++], result);
}
@@ -878,15 +937,14 @@ void fmadm_exit (int retval)
int fmadm_usage (void)
{
- fprintf (stdout, "\nusage: fmadm