version 1.30, 2025/04/03 20:48:14
|
version 1.32, 2025/04/09 19:52:02
|
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.32 2025/04/09 19:52:02 snw |
|
* Eliminate as many warnings as possible while building with -Wall |
|
* |
|
* Revision 1.31 2025/04/04 19:43:18 snw |
|
* Switch to using environment catalog to determine user and group for environment, and remove -u and -g flags from freem |
|
* |
* Revision 1.30 2025/04/03 20:48:14 snw |
* Revision 1.30 2025/04/03 20:48:14 snw |
* Improve daemon error diagnostics and bump to 0.63.0-rc3 |
* Improve daemon error diagnostics and bump to 0.63.0-rc3 |
* |
* |
Line 1168 long fm_get_pid (char *env)
|
Line 1174 long fm_get_pid (char *env)
|
{ |
{ |
char pid_file[4096]; |
char pid_file[4096]; |
char tmp_pid[255]; |
char tmp_pid[255]; |
long res; |
|
|
|
FILE *fp; |
FILE *fp; |
|
|
snprintf (pid_file, 4095, "%s/freem/run/%s.pid", LOCALSTATEDIR, env); |
snprintf (pid_file, 4095, "%s/freem/run/%s.pid", LOCALSTATEDIR, env); |
Line 1213 int fm_validate_environment (char *env)
|
Line 1217 int fm_validate_environment (char *env)
|
return FALSE; |
return FALSE; |
} |
} |
|
|
int fm_start_environment (char *env, char *e_user, char *e_grp) |
int fm_start_environment (char *env) |
{ |
{ |
char basecmd[255]; |
char basecmd[255]; |
char cmd[4096]; |
char cmd[4096]; |
Line 1229 int fm_start_environment (char *env, cha
|
Line 1233 int fm_start_environment (char *env, cha
|
#endif |
#endif |
|
|
#if !defined(__OS2__) |
#if !defined(__OS2__) |
snprintf (cmd, 4095, "%s -d -e %s -u %s -g %s", basecmd, env, e_user, e_grp); |
snprintf (cmd, 4095, "%s -d -e %s", basecmd, env); |
#else |
#else |
sprintf (cmd, 4095, "%s -d -k -e %s -u %s -g %s", basecmd, env, e_user, e_grp); |
sprintf (cmd, 4095, "%s -d -k -e %s", basecmd, env); |
#endif |
#endif |
|
|
system (cmd); |
system (cmd); |
Line 1389 int fm_daemonctl (short action, short ob
|
Line 1393 int fm_daemonctl (short action, short ob
|
switch (action) { |
switch (action) { |
|
|
case ACT_START: |
case ACT_START: |
result = fm_start_environment (cur_env, e_user, e_grp); |
result = fm_start_environment (cur_env); |
if (result == TRUE) { |
if (result == TRUE) { |
fprintf (stderr, "[OK]\n"); |
fprintf (stderr, "[OK]\n"); |
} |
} |
Line 1411 int fm_daemonctl (short action, short ob
|
Line 1415 int fm_daemonctl (short action, short ob
|
|
|
case ACT_RESTART: |
case ACT_RESTART: |
if (fm_stop_environment (cur_env) == TRUE) { |
if (fm_stop_environment (cur_env) == TRUE) { |
result = fm_start_environment (cur_env, e_user, e_grp); |
result = fm_start_environment (cur_env); |
if (result == TRUE) { |
if (result == TRUE) { |
fprintf (stderr, "[OK]\n"); |
fprintf (stderr, "[OK]\n"); |
} |
} |
Line 1430 int fm_daemonctl (short action, short ob
|
Line 1434 int fm_daemonctl (short action, short ob
|
case ACT_STATUS: |
case ACT_STATUS: |
epid = fm_get_pid (cur_env); |
epid = fm_get_pid (cur_env); |
if (epid > -1) { |
if (epid > -1) { |
fprintf (stderr, " - %s environment daemon running as pid %d\n", cur_env, epid); |
fprintf (stderr, " - %s environment daemon running as pid %ld\n", cur_env, epid); |
} |
} |
else { |
else { |
fprintf (stderr, " - %s environment daemon does not appear to be running\n", cur_env); |
fprintf (stderr, " - %s environment daemon does not appear to be running\n", cur_env); |
Line 1456 void fm_checkperms(void)
|
Line 1460 void fm_checkperms(void)
|
void fm_reconfigure(void) |
void fm_reconfigure(void) |
{ |
{ |
char config_backup[4096]; |
char config_backup[4096]; |
char vers[4096]; |
|
|
|
int retval; |
int retval; |
|
|
Line 1535 void fm_configure (void)
|
Line 1538 void fm_configure (void)
|
int reconfigure = FALSE; |
int reconfigure = FALSE; |
|
|
struct stat etcstat; |
struct stat etcstat; |
int stat_result; |
|
|
|
DIR *dir; |
DIR *dir; |
struct dirent *ent; |
struct dirent *ent; |
Line 1546 void fm_configure (void)
|
Line 1548 void fm_configure (void)
|
char *groupname = env_group; |
char *groupname = env_group; |
|
|
#if !defined(__OS2__) |
#if !defined(__OS2__) |
|
struct group *d_grp; |
|
struct passwd *d_user; |
|
|
if (geteuid () != 0) { |
if (geteuid () != 0) { |
fprintf (stderr, "fmadm: not superuser\n"); |
fprintf (stderr, "fmadm: not superuser\n"); |
exit (1); |
exit (1); |
} |
} |
|
|
struct group *d_grp; |
|
struct passwd *d_user; |
|
gid_t d_gid; |
|
uid_t d_uid; |
|
|
|
if ((d_grp = getgrnam (groupname)) == NULL) { |
if ((d_grp = getgrnam (groupname)) == NULL) { |
fprintf (stderr, "fmadm: '%s' group must exist before configuring\n", groupname); |
fprintf (stderr, "fmadm: '%s' group must exist before configuring\n", groupname); |
exit (1); |
exit (1); |
} |
} |
d_gid = d_grp->gr_gid; |
|
|
|
if ((d_user = getpwnam (username)) == NULL) { |
if ((d_user = getpwnam (username)) == NULL) { |
fprintf (stderr, "fmadm: '%s' user must exist before configuring\n", username); |
fprintf (stderr, "fmadm: '%s' user must exist before configuring\n", username); |
exit (1); |
exit (1); |
} |
} |
d_uid = d_user->pw_uid; |
|
#endif |
#endif |
|
|
snprintf (varbase, 4095, "%s/freem", LOCALSTATEDIR); |
snprintf (varbase, 4095, "%s/freem", LOCALSTATEDIR); |
Line 1775 void fm_configure (void)
|
Line 1772 void fm_configure (void)
|
fprintf (stderr, "[OK]\n"); |
fprintf (stderr, "[OK]\n"); |
} |
} |
else { |
else { |
char modtmp[255]; |
|
|
|
fprintf (stderr, "\nUpdating %s: \n", env_config_file); |
fprintf (stderr, "\nUpdating %s: \n", env_config_file); |
|
|
update_conf (env_config_file, fma_environment, "user", env_user); |
update_conf (env_config_file, fma_environment, "user", env_user); |