--- freem/src/fmadm.c 2025/04/13 04:22:43 1.35 +++ freem/src/fmadm.c 2025/04/15 18:19:40 1.40 @@ -1,5 +1,5 @@ /* - * $Id: fmadm.c,v 1.35 2025/04/13 04:22:43 snw Exp $ + * $Id: fmadm.c,v 1.40 2025/04/15 18:19:40 snw Exp $ * FreeM Administration Tool * * @@ -24,6 +24,21 @@ * along with FreeM. If not, see . * * $Log: fmadm.c,v $ + * Revision 1.40 2025/04/15 18:19:40 snw + * Further attempts to fix FreeBSD + * + * Revision 1.39 2025/04/15 16:49:36 snw + * Make use of logprintf throughout codebase + * + * 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 * @@ -128,14 +143,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 +#include "log.h" #ifdef HAVE_LIBREADLINE # if defined(HAVE_READLINE_READLINE_H) @@ -196,6 +211,7 @@ extern char env_config_file[4096]; extern char env_user[255]; extern char env_group[255]; extern char env_enabled[10]; +extern char shm_env[255]; int fm_shell(void); void fm_checkperms(void); @@ -383,6 +399,8 @@ int main (int argc, char **argv) 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]); exit(1); */ + strncpy (shm_env, fma_environment, sizeof (shm_env) - 1); + init_log (); /* override for fmadm configure and daemon stuff */ if (got_action) { @@ -1520,6 +1538,7 @@ void fm_configure (void) { char rundir[4096]; char varbase[4096]; + char vardir[4096]; char sysrtn[4096]; char sysgbl[4096]; char usrrtn[4096]; @@ -1531,7 +1550,8 @@ void fm_configure (void) char jnlhostid[4096]; char jnlcut[4096]; char hostid[4096]; - + char logdir[4096]; + char confbase[4096]; char envbase[4096]; @@ -1570,7 +1590,9 @@ void fm_configure (void) exit (1); } #endif - + + snprintf (logdir, sizeof (logdir) - 1, "/var/log/freem"); + snprintf (vardir, sizeof (vardir) - 1, "%s", LOCALSTATEDIR); snprintf (varbase, sizeof (varbase) - 1, "%s/freem", LOCALSTATEDIR); snprintf (rundir, sizeof (rundir) - 1, "%s/freem/run", LOCALSTATEDIR); snprintf (sysrtn, sizeof (sysrtn) - 1, "%s/freem/%s/SYSTEM/routines", LOCALSTATEDIR, fma_environment); @@ -1637,6 +1659,12 @@ void fm_configure (void) } /* check for existence of needed directories */ + if (stat (logdir, &etcstat) == -1) { + fprintf (stderr, "fmadm: creating %s [logdir]\n", logdir); + mkdir (logdir, 0775); + set_permissions (logdir, username, groupname, 0775); + } + if (stat (SYSCONFDIR, &etcstat) == -1) { fprintf (stderr, "fmadm: creating %s [SYSCONFDIR]\n", SYSCONFDIR); mkdir (SYSCONFDIR, 0775); @@ -1649,6 +1677,12 @@ void fm_configure (void) set_permissions (confbase, username, groupname, 0775); } + if (stat (vardir, &etcstat) == -1) { + fprintf (stderr, "fmadm: creating %s [vardir]\n", vardir); + mkdir (vardir, 0775); + set_permissions (vardir, username, groupname, 0775); + } + if (stat (varbase, &etcstat) == -1) { fprintf (stderr, "fmadm: creating %s [varbase]\n", varbase); mkdir (varbase, 0775); @@ -1772,6 +1806,15 @@ void fm_configure (void) snprintf (buf, sizeof (buf) - 1, "env_path=%s/freem/%s", LOCALSTATEDIR, fma_environment); fm_write (fp, buf); + + snprintf (buf, sizeof (buf) - 1, "log_threshold_file=info"); + fm_write (fp, buf); + + snprintf (buf, sizeof (buf) - 1, "log_threshold_syslog=info"); + fm_write (fp, buf); + + snprintf (buf, sizeof (buf) - 1, "log_threshold_stderr=warning"); + fm_write (fp, buf); fclose (fp); fprintf (stderr, "[OK]\n"); @@ -1782,6 +1825,9 @@ void fm_configure (void) update_conf (env_config_file, fma_environment, "user", env_user); update_conf (env_config_file, fma_environment, "group", env_group); update_conf (env_config_file, fma_environment, "enabled", env_enabled); + update_conf (env_config_file, fma_environment, "log_threshold_file", "info"); + update_conf (env_config_file, fma_environment, "log_threshold_syslog", "info"); + update_conf (env_config_file, fma_environment, "log_threshold_stderr", "warning"); } if (reconfigure == FALSE) {