--- freem/src/fmadm.c 2025/04/15 16:49:36 1.39 +++ freem/src/fmadm.c 2025/05/13 20:03:53 1.42 @@ -1,5 +1,5 @@ /* - * $Id: fmadm.c,v 1.39 2025/04/15 16:49:36 snw Exp $ + * $Id: fmadm.c,v 1.42 2025/05/13 20:03:53 snw Exp $ * FreeM Administration Tool * * @@ -24,6 +24,15 @@ * along with FreeM. If not, see . * * $Log: fmadm.c,v $ + * 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 * @@ -208,6 +217,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); @@ -391,10 +401,11 @@ int main (int argc, char **argv) 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]); - exit(1); -*/ + + //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 */ @@ -575,6 +586,7 @@ act_switch: case ACT_IMPORT: + //printf ("opts[0] = %s\n", opts[0]); fmadm_exit (fm_import (obj, optc, opts)); @@ -1361,8 +1373,10 @@ int fm_daemonctl (short action, short ob envlist = (char *) malloc (sizeof (char) * BIGSTR); 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)) { if (line[0] == '[') { strncpy (env, &(line[1]), 255); @@ -1538,7 +1552,7 @@ void fm_configure (void) char sysgbl[4096]; char usrrtn[4096]; char usrgbl[4096]; - + char jnldir[4096]; char jnlfile[4096]; char jnlmode[4];