Hi, Icecast server 2.4.0 running on Linux. I have a couple of shell scripts that send emails on connect and on disconnect. From the command line they work, but when called from icecast they do not. Here is the mount section of my icecast.xml: <mount type="normal"> ??????? <mount-name>/my_stream</mount-name> <fallback-mount>/fallbacks/my_fallback.mp3</fallback-mount> ??????? <fallback-override>1</fallback-override> ??????? <fallback-when-full>1</fallback-when-full> *<on-connect>/home/my_username/bin/email_onconnect.sh</on-connect>** **<on-disconnect>/home/my_username/bin/email_ondisconnect.sh</on-disconnect>* ??????? <no-yp>1</no-yp> ??? </mount> After putting the new <on-connect> and <on-disconnect> entries into icecast.xml I reloaded the config with /etc/init.d/icecast2 reload and there was no error written to /var/log/icecast2/error.log <on-connect> calls /home/my_username/bin/email_onconnect.sh which works from the command line. Likewise, <on-disconnect> calls a similar script which also works from the command line. I've tested them. The permissions for the two scripts: -rwxr-xr-x 1 my_username my_username 352 Jul 14 07:49 email_onconnect.sh -rwxr-xr-x 1 my_username my_username 375 Jul 14 07:49 email_ondisconnect.sh I'd like to get these functions working . . . ideas? Thank you! -- Jack Elliott Director of Classical Music Programming KPOV 88.9 FM High Desert Community Radio Bend, OR -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.xiph.org/pipermail/icecast/attachments/20220714/62b28a43/attachment.htm>
V?Thu, Jul 14, 2022 at 08:16:03AM -0700,?Jack Elliott napsal(a):> Hi, > > Icecast server 2.4.0 running on Linux. >Could you try upgrading Icecast? The latest version is 2.4.4 and there were some fixes in between.> I have a couple of shell scripts that send emails on connect and on > disconnect. From the command line they work, but when called from > icecast they do not.[...]> I'd like to get these functions working . . . ideas? >A problem is that Icecast does not log a failed execution of the scripts. Neither an exit code of the finished script. It can only log some fork errors and file permissions before executing them. And an attempt to execute a script is logged only if Icecast log level is set to debug: static void _run_script (event_exec_t *self, event_t *event) { pid_t pid, external_pid; /* do a fork twice so that the command has init as parent */ external_pid = fork(); switch (external_pid) { case 0: switch (pid = fork ()) { case -1: ICECAST_LOG_ERROR("Unable to fork %s (%s)", self->executable, strerror (errno)); break; case 0: /* child */ if (access(self->executable, R_OK|X_OK) != 0) { ICECAST_LOG_ERROR("Unable to run command %s (%s)", self->executable, strerror(errno)); exit(1); } ICECAST_LOG_DEBUG("Starting command %s", self->executable); __setup_empty_script_environment(self, event); execv(self->executable, __setup_argv(self, event)); exit(1); default: /* parent */ break; } exit (0); case -1: ICECAST_LOG_ERROR("Unable to fork %s", strerror (errno)); break; default: /* parent */ waitpid (external_pid, NULL, 0); break; } } You can use "strace" tool to check whether the scripts are actually executed. Something like "strace -fq -e execve -p PID_OF_THE_RUNNING_SERVER". The code is pretty terrible. access() does not answer whether a process can exucute a program. Also execv() can fail for various reasons: Different effective UID/GID, missing capabilities, violation of SELinux policy. And then there can be problems with the executed program itself, like a wrong magic number, unsupported architecture, a missing dynamic library, bad script interpreter etc. I recommend Icecast developers to remove the access() call and instead log errno after a failed execve. Also logging a status code of the terminated executable returned by waitpid() would be helpful. -- Petr -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <http://lists.xiph.org/pipermail/icecast/attachments/20220714/8416455d/attachment.sig>
Jordan Erickson
2022-Jul-15 05:14 UTC
[Icecast] <on-connect> / <on-disconnect> not working
Hi Jack, Does the user user actually running the Icecast process have access to the scripts within the /home/my_username/bin directory? Not sure if Icecast is running as $my_username from what you've said here. I'm also not sure if Icecast checks access to each script specified in the config for access during startup/reload. Cheers, Jordan -- Jordan Erickson SubJam, SPC -https://subj.am/ +1 360.603.5039 On 7/14/22 08:16, Jack Elliott wrote:> > Hi, > > Icecast server 2.4.0 running on Linux. > > I have a couple of shell scripts that send emails on connect and on > disconnect. From the command line they work, but when called from > icecast they do not. > > Here is the mount section of my icecast.xml: > > <mount type="normal"> > ??????? <mount-name>/my_stream</mount-name> > <fallback-mount>/fallbacks/my_fallback.mp3</fallback-mount> > ??????? <fallback-override>1</fallback-override> > ??????? <fallback-when-full>1</fallback-when-full> > *<on-connect>/home/my_username/bin/email_onconnect.sh</on-connect>** > **<on-disconnect>/home/my_username/bin/email_ondisconnect.sh</on-disconnect>* > ??????? <no-yp>1</no-yp> > ??? </mount> > > After putting the new <on-connect> and <on-disconnect> entries into > icecast.xml I reloaded the config with /etc/init.d/icecast2 reload and > there was no error written to /var/log/icecast2/error.log > > <on-connect> calls /home/my_username/bin/email_onconnect.sh which > works from the command line. Likewise, <on-disconnect> calls a similar > script which also works from the command line. I've tested them. > > The permissions for the two scripts: > > -rwxr-xr-x 1 my_username my_username 352 Jul 14 07:49 email_onconnect.sh > -rwxr-xr-x 1 my_username my_username 375 Jul 14 07:49 > email_ondisconnect.sh > > I'd like to get these functions working . . . ideas? > > Thank you! > > -- > Jack Elliott > Director of Classical Music Programming > KPOV 88.9 FM > High Desert Community Radio > Bend, OR > > _______________________________________________ > Icecast mailing list > Icecast at xiph.org > http://lists.xiph.org/mailman/listinfo/icecast-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.xiph.org/pipermail/icecast/attachments/20220714/46116ec0/attachment.htm>