|
|
| version 1.36, 2025/04/13 15:12:21 | version 1.43, 2026/03/24 00:25:36 |
|---|---|
| Line 24 | Line 24 |
| * along with FreeM. If not, see <https://www.gnu.org/licenses/>. | * along with FreeM. If not, see <https://www.gnu.org/licenses/>. |
| * | * |
| * $Log$ | * $Log$ |
| * Revision 1.43 2026/03/24 00:25:36 snw | |
| * Fix segfault when running \'fmadm status\' without a second argument | |
| * | |
| * Revision 1.42 2025/05/13 20:03:53 snw | |
| * Error-check fopen in fm_daemonctl | |
| * | |
| * Revision 1.41 2025/04/25 20:08:19 snw | |
| * Work on improving routine importer | |
| * | |
| * 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 | * Revision 1.36 2025/04/13 15:12:21 snw |
| * Fix transaction checkpoints on OS/2 [CLOSES #34] | * Fix transaction checkpoints on OS/2 [CLOSES #34] |
| * | * |
| Line 138 | Line 159 |
| #include "transact.h" | #include "transact.h" |
| #include "namespace.h" | #include "namespace.h" |
| #include "fs.h" | #include "fs.h" |
| #include "log.h" | |
| #ifdef HAVE_LIBREADLINE | #ifdef HAVE_LIBREADLINE |
| # if defined(HAVE_READLINE_READLINE_H) | # if defined(HAVE_READLINE_READLINE_H) |
| Line 198 extern char env_config_file[4096]; | Line 220 extern char env_config_file[4096]; |
| extern char env_user[255]; | extern char env_user[255]; |
| extern char env_group[255]; | extern char env_group[255]; |
| extern char env_enabled[10]; | extern char env_enabled[10]; |
| extern char shm_env[255]; | |
| int fm_shell(void); | int fm_shell(void); |
| void fm_checkperms(void); | void fm_checkperms(void); |
| Line 381 int main (int argc, char **argv) | Line 404 int main (int argc, char **argv) |
| snprintf (env_config_file, sizeof (env_config_file) - 1, "%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]); | //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); | //exit(1); |
| */ | |
| strncpy (shm_env, fma_environment, sizeof (shm_env) - 1); | |
| init_log (); | |
| /* override for fmadm configure and daemon stuff */ | /* override for fmadm configure and daemon stuff */ |
| if (got_action) { | if (got_action) { |
| Line 411 int main (int argc, char **argv) | Line 436 int main (int argc, char **argv) |
| obj = OBJ_DAEMON; | obj = OBJ_DAEMON; |
| goto process_args; | goto process_args; |
| } | } |
| else if (strcmp (argv[1], "status") == 0 && strcmp (argv[2], "environment") == 0) { | else if (strcmp (argv[1], "status") == 0) { |
| act = ACT_STATUS; | if (argc < 3) { |
| obj = OBJ_DAEMON; | fprintf (stderr, "fmadm: did you mean 'fmadm status environment'?\r\n"); |
| goto process_args; | exit (1); |
| } | |
| if (strcmp (argv[2], "environment") == 0) { | |
| act = ACT_STATUS; | |
| obj = OBJ_DAEMON; | |
| goto process_args; | |
| } | |
| else { | |
| fmadm_usage (); | |
| exit (1); | |
| } | |
| } | } |
| } | } |
| Line 564 act_switch: | Line 600 act_switch: |
| case ACT_IMPORT: | case ACT_IMPORT: |
| //printf ("opts[0] = %s\n", opts[0]); | |
| fmadm_exit (fm_import (obj, optc, opts)); | fmadm_exit (fm_import (obj, optc, opts)); |
| Line 1350 int fm_daemonctl (short action, short ob | Line 1387 int fm_daemonctl (short action, short ob |
| envlist = (char *) malloc (sizeof (char) * BIGSTR); | envlist = (char *) malloc (sizeof (char) * BIGSTR); |
| NULLPTRCHK(envlist,"fm_daemonctl"); | NULLPTRCHK(envlist,"fm_daemonctl"); |
| ef = fopen (env_config_file, "r"); | if ((ef = fopen (env_config_file, "r")) == NULL) { |
| logprintf (FM_LOG_FATAL, "fm_daemonctl: failed to open %s (error code %d [%s])", env_config_file, errno, strerror (errno)); | |
| } | |
| while (fgets (line, 254, ef)) { | while (fgets (line, 254, ef)) { |
| if (line[0] == '[') { | if (line[0] == '[') { |
| strncpy (env, &(line[1]), 255); | strncpy (env, &(line[1]), 255); |
| Line 1522 void fm_configure (void) | Line 1561 void fm_configure (void) |
| { | { |
| char rundir[4096]; | char rundir[4096]; |
| char varbase[4096]; | char varbase[4096]; |
| char vardir[4096]; | |
| char sysrtn[4096]; | char sysrtn[4096]; |
| char sysgbl[4096]; | char sysgbl[4096]; |
| char usrrtn[4096]; | char usrrtn[4096]; |
| char usrgbl[4096]; | char usrgbl[4096]; |
| char jnldir[4096]; | char jnldir[4096]; |
| char jnlfile[4096]; | char jnlfile[4096]; |
| char jnlmode[4]; | char jnlmode[4]; |
| char jnlhostid[4096]; | char jnlhostid[4096]; |
| char jnlcut[4096]; | char jnlcut[4096]; |
| char hostid[4096]; | char hostid[4096]; |
| char logdir[4096]; | |
| char confbase[4096]; | char confbase[4096]; |
| char envbase[4096]; | char envbase[4096]; |
| Line 1572 void fm_configure (void) | Line 1613 void fm_configure (void) |
| exit (1); | exit (1); |
| } | } |
| #endif | #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 (varbase, sizeof (varbase) - 1, "%s/freem", LOCALSTATEDIR); |
| snprintf (rundir, sizeof (rundir) - 1, "%s/freem/run", LOCALSTATEDIR); | snprintf (rundir, sizeof (rundir) - 1, "%s/freem/run", LOCALSTATEDIR); |
| snprintf (sysrtn, sizeof (sysrtn) - 1, "%s/freem/%s/SYSTEM/routines", LOCALSTATEDIR, fma_environment); | snprintf (sysrtn, sizeof (sysrtn) - 1, "%s/freem/%s/SYSTEM/routines", LOCALSTATEDIR, fma_environment); |
| Line 1639 void fm_configure (void) | Line 1682 void fm_configure (void) |
| } | } |
| /* check for existence of needed directories */ | /* 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) { | if (stat (SYSCONFDIR, &etcstat) == -1) { |
| fprintf (stderr, "fmadm: creating %s [SYSCONFDIR]\n", SYSCONFDIR); | fprintf (stderr, "fmadm: creating %s [SYSCONFDIR]\n", SYSCONFDIR); |
| mkdir (SYSCONFDIR, 0775); | mkdir (SYSCONFDIR, 0775); |
| Line 1651 void fm_configure (void) | Line 1700 void fm_configure (void) |
| set_permissions (confbase, username, groupname, 0775); | 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) { | if (stat (varbase, &etcstat) == -1) { |
| fprintf (stderr, "fmadm: creating %s [varbase]\n", varbase); | fprintf (stderr, "fmadm: creating %s [varbase]\n", varbase); |
| mkdir (varbase, 0775); | mkdir (varbase, 0775); |
| Line 1774 void fm_configure (void) | Line 1829 void fm_configure (void) |
| snprintf (buf, sizeof (buf) - 1, "env_path=%s/freem/%s", LOCALSTATEDIR, fma_environment); | snprintf (buf, sizeof (buf) - 1, "env_path=%s/freem/%s", LOCALSTATEDIR, fma_environment); |
| fm_write (fp, buf); | 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); | fclose (fp); |
| fprintf (stderr, "[OK]\n"); | fprintf (stderr, "[OK]\n"); |
| Line 1784 void fm_configure (void) | Line 1848 void fm_configure (void) |
| update_conf (env_config_file, fma_environment, "user", env_user); | 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, "group", env_group); |
| update_conf (env_config_file, fma_environment, "enabled", env_enabled); | 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) { | if (reconfigure == FALSE) { |