Diff for /freem/src/mumps.c between versions 1.23 and 1.26

version 1.23, 2025/04/16 05:33:15 version 1.26, 2025/04/16 17:36:12
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.26  2025/04/16 17:36:12  snw
    *   Add FreeBSD shm cleanup script
    *
    *   Revision 1.25  2025/04/16 05:57:42  snw
    *   Remove non-useful procctl calls
    *
    *   Revision 1.24  2025/04/16 05:37:06  snw
    *   Refine FreeBSD ASLR fix
    *
  *   Revision 1.23  2025/04/16 05:33:15  snw   *   Revision 1.23  2025/04/16 05:33:15  snw
  *   Try to use procctl function to fix ASLR problem on FreeBSD   *   Try to use procctl function to fix ASLR problem on FreeBSD
  *   *
Line 119 Line 128
 #include <pwd.h>  #include <pwd.h>
 #include <grp.h>  #include <grp.h>
 #include "log.h"  #include "log.h"
 #if defined(__FreeBSD__)  
 # include <sys/procctl.h>  
 #endif  
 #if defined(HAVE_GETOPT_H)  #if defined(HAVE_GETOPT_H)
 # include <getopt.h>  # include <getopt.h>
 #endif  #endif
Line 197  int main (int argc, char **argv, char ** Line 203  int main (int argc, char **argv, char **
     char cli_rtn_name[256];      char cli_rtn_name[256];
   
     char env_ena[25];      char env_ena[25];
   
 #if defined(__FreeBSD__)  
     int prcdta = PROC_ASLR_FORCE_DISABLE;  
     if (procctl (P_PID, getpid (), PROC_ASLR_CTL, &prcdta) == -1) {  
         fprintf (stderr, "freem:  could not disable address space layout randomization for pid %ld; program operation may be unreliable [error %s]\n", getpid(), strerror (errno));  
     }      
 #endif  
           
     routine_mode = FALSE;      routine_mode = FALSE;
     strcpy (m_dialect, "FREEM");      strcpy (m_dialect, "FREEM");
Line 222  int main (int argc, char **argv, char ** Line 221  int main (int argc, char **argv, char **
     strcpy (stack0, argv[0]);      strcpy (stack0, argv[0]);
     stcnv_c2m (stack0);      stcnv_c2m (stack0);
   
   
     /* strncpy (config_file, SYSCONFDIR"/freem.conf", 100); */      /* strncpy (config_file, SYSCONFDIR"/freem.conf", 100); */
   
   
Line 599  int main (int argc, char **argv, char ** Line 597  int main (int argc, char **argv, char **
                 }                  }
             }              }
   
               logprintf (FM_LOG_INFO, "environment:  privilege shedding complete");
   
         }          }
         else {          else {
             logprintf (FM_LOG_INFO, "environment:  not running as superuser; not shedding privileges");               logprintf (FM_LOG_INFO, "environment:  not running as superuser; not shedding privileges"); 
         }          }
   
           logprintf (FM_LOG_INFO, "environment:  reopening stdin, stdout, and stderr");
         freopen ("/dev/null", "r", stdin);          freopen ("/dev/null", "r", stdin);
         freopen ("/dev/null", "w+", stdout);          freopen ("/dev/null", "w+", stdout);
         freopen ("/dev/null", "w+", stderr);          freopen ("/dev/null", "w+", stderr);
           logprintf (FM_LOG_INFO, "environment:  stdin, stdout, and stderr reopened");
   
         run_daemon = TRUE;          run_daemon = TRUE;
         nofork = FALSE;                  nofork = FALSE;        
Line 620  int main (int argc, char **argv, char ** Line 622  int main (int argc, char **argv, char **
                           
             snprintf (pid_file_path, PATH_MAX - 1, "%s/freem/run/%s.pid", LOCALSTATEDIR, shm_env);              snprintf (pid_file_path, PATH_MAX - 1, "%s/freem/run/%s.pid", LOCALSTATEDIR, shm_env);
   
               logprintf (FM_LOG_INFO, "environment:  opening pid file %s", pid_file_path);
             pid_fd = open (pid_file_path, O_RDWR | O_CREAT, 0640);              pid_fd = open (pid_file_path, O_RDWR | O_CREAT, 0640);
             errsav = errno;              errsav = errno;
                           
Line 633  int main (int argc, char **argv, char ** Line 636  int main (int argc, char **argv, char **
             }              }
   
             sprintf (pidfile_buf, "%ld\n", (long) getpid ());              sprintf (pidfile_buf, "%ld\n", (long) getpid ());
               logprintf (FM_LOG_INFO, "environment:  writing pid file");
             write (pid_fd, pidfile_buf, strlen (pidfile_buf));              write (pid_fd, pidfile_buf, strlen (pidfile_buf));
   
         }          }
Line 761  int main (int argc, char **argv, char ** Line 765  int main (int argc, char **argv, char **
         else {          else {
             fm_initialized = TRUE;              fm_initialized = TRUE;
         }          }
     }      }    
   
     if (first_process == TRUE) {      if (first_process == TRUE) {
                   

Removed from v.1.23  
changed lines
  Added in v.1.26


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>