--- freem/src/fmadm.c	2025/04/02 15:36:25	1.27
+++ freem/src/fmadm.c	2025/04/02 19:59:38	1.28
@@ -1,5 +1,5 @@
 /*
- *   $Id: fmadm.c,v 1.27 2025/04/02 15:36:25 snw Exp $
+ *   $Id: fmadm.c,v 1.28 2025/04/02 19:59:38 snw Exp $
  *    FreeM Administration Tool
  *
  *  
@@ -24,6 +24,9 @@
  *   along with FreeM.  If not, see <https://www.gnu.org/licenses/>.
  *
  *   $Log: fmadm.c,v $
+ *   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
  *
@@ -1482,7 +1485,7 @@ void fm_configure (void)
 
     char *username = env_user;
     char *groupname = env_group;
-   
+    
 #if !defined(__OS2__)
     if (geteuid () != 0) {
         fprintf (stderr, "fmadm:  not superuser\n");
@@ -1679,27 +1682,46 @@ void fm_configure (void)
         
     }
 
-    fp = fopen (env_config_file, "a+");
-
-    fprintf (stderr, "Creating %s... ", env_config_file);
-
-    snprintf (buf, 4095, "[%s]", fma_environment);
-    fm_write (fp, buf);
-
-    snprintf (buf, 4095, "user=%s", env_user);
-    fm_write (fp, buf);
-    
-    snprintf (buf, 4095, "group=%s", env_group);
-    fm_write (fp, buf);
+    if (fm_validate_environment (fma_environment) == FALSE) {
+        fp = fopen (env_config_file, "a+");
+        
+        fprintf (stderr, "Creating %s... ", env_config_file);
+        
+        snprintf (buf, 4095, "[%s]", fma_environment);
+        fm_write (fp, buf);
+        
+        snprintf (buf, 4095, "user=%s", env_user);
+        fm_write (fp, buf);
+        
+        snprintf (buf, 4095, "group=%s", env_group);
+        fm_write (fp, buf);
+        
+        snprintf (buf, 4095, "enabled=true");
+        fm_write (fp, buf);
+        
+        snprintf (buf, 4095, "env_path=%s/freem/%s", LOCALSTATEDIR, fma_environment);
+        fm_write (fp, buf);
+        
+        fclose (fp);
+        fprintf (stderr, "[OK]\n");
+    }
+    else {
+        char modtmp[255];
+        
+        fprintf (stderr, "Updating %s: \n", env_config_file);
+        
+        read_profile_string (env_config_file, fma_environment, "user", modtmp);
+        if (strcmp (env_user, modtmp) != 0) {
+            modify_profile_string (env_config_file, fma_environment, "user", env_user);
+            fprintf (stderr, "\tuser:   %s -> %s\n", modtmp, env_user);
+        }
 
-    snprintf (buf, 4095, "enabled=true");
-    fm_write (fp, buf);
-    
-    snprintf (buf, 4095, "env_path=%s/freem/%s", LOCALSTATEDIR, fma_environment);
-    fm_write (fp, buf);
-    
-    fclose (fp);
-    fprintf (stderr, "[OK]\n");
+        read_profile_string (env_config_file, fma_environment, "group", modtmp);
+        if (strcmp (env_group, modtmp) != 0) {
+            modify_profile_string (env_config_file, fma_environment, "group", env_group);
+            fprintf (stderr, "\tgroup:  %s -> %s\n", modtmp, env_group);
+        }
+    }
    
     fp = fopen (config_file, "a+");