[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-mcron] [PATCH 25/33] mcron: Rework comments.
From: |
Mathieu Lirzin |
Subject: |
[Bug-mcron] [PATCH 25/33] mcron: Rework comments. |
Date: |
Sun, 27 Sep 2015 23:00:36 +0200 |
* mcron.c: Rework comments.
---
mcron.c | 44 ++++++++++----------------------------------
1 file changed, 10 insertions(+), 34 deletions(-)
diff --git a/mcron.c b/mcron.c
index e60d1f4..ece6eb1 100644
--- a/mcron.c
+++ b/mcron.c
@@ -18,31 +18,9 @@
You should have received a copy of the GNU General Public License
along with GNU Mcron. If not, see <http://www.gnu.org/licenses/>. */
-/* This C code represents the thinnest possible wrapper around the Guile code
- which constitutes all the functionality of the mcron program. There are
- two plus one reasons why we need to do this, and one very unfortunate
- consequence.
-
- * Firstly, SUID does not work on an executable script. In the end, it is
- the execution of the translator, in our case guile, which determines the
- effective user, and it is not wise to make the system guile installation
- SUID root!
-
- * Secondly, executable scripts show up in ugly ways in listings of the
- system process table. Guile in particular, with its multi-line
- #! ...\ \n -s ...!#
- idiosyncracies shows up in process listings in a way that is difficult
- to determine what program is actually running.
-
- * A third reason for the C wrapper which might be mentioned is that a
- security-conscious system administrator can choose to only install a
- binary, thus removing the possibility of a user studying a guile script
- and working out ways of hacking it to his own ends, or worse still
- finding a way to modify it to his own ends.
-
- * Unfortunately, running the guile script from inside a C program means
- that the sigaction function does not work. Instead, it is necessary to
- perform the signal processing in C. */
+/* This C code represents a thin wrapper around the Guile code of Mcron. It
+ is needed because the crontab personality requires SUID which is not
+ permitted for executable scripts. */
#include <libguile.h>
#include <signal.h>
@@ -63,20 +41,20 @@ main (int argc, char **argv)
return EXIT_SUCCESS;
}
-/* The effective main function (i.e. the one that actually does some work).
- We register the function above with the guile system, and then execute the
- mcron guile program. */
+/* Launch the Mcron Guile main program. */
void
inner_main (void *closure, int argc, char **argv)
{
scm_set_current_module (scm_c_resolve_module ("mcron main"));
+ /* Register set_cron_signals to be called from Guile. */
scm_c_define_gsubr ("c-set-cron-signals", 0, 0, 0, set_cron_signals);
scm_c_eval_string ("(main)");
}
-/* This is a function designed to be callable from scheme, and sets up all the
- signal handlers required by the cron personality. */
+/* Set up all the signal handlers as required by the cron personality. This
+ is necessary to perform the signal processing in C because the sigaction
+ function won't work when called from Guile. */
SCM
set_cron_signals ()
@@ -93,10 +71,8 @@ set_cron_signals ()
return SCM_BOOL_T;
}
-/* This is a function designed to be installed as a signal handler, for
- signals which are supposed to initiate shutdown of this program. It calls
- the scheme procedure (see mcron.scm for details) to do all the work, and
- then exits. */
+/* Handle signal SIG and exit. All signals that mcron handles will produce
+ the same behavior so we don't need to use SIG in the implementation. */
void
react_to_terminal_signal (int sig)
- [Bug-mcron] [PATCH 27/33] main: Improve 'process-user-file' definition., (continued)
- [Bug-mcron] [PATCH 27/33] main: Improve 'process-user-file' definition., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 15/33] main: Add docstrings., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 26/33] mcron: Make functions 'static'., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 29/33] environment: Redefine 'modify-environment'., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 17/33] main: Add main., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 21/33] main: Remove obsolete debug option., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 22/33] redirect: Use module (ice-9 regex)., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 23/33] mcron: Add forward declarations., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 28/33] main: Remove unused 'regular-file?' procedure., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 24/33] mcron: Use symbolic constants., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 25/33] mcron: Rework comments.,
Mathieu Lirzin <=
- [Bug-mcron] [PATCH 20/33] build: Enable silent rules by default., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 13/33] main: Turn 'command-name' into a thunk., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 19/33] build: Compile and install '.go' files., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 18/33] main: Add (mcron main) module., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 30/33] Define directory-local variables for Emacs., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 31/33] main: Add 'proc-in-directory'., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 32/33] main: Remove 'valid-user'., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 33/33] core: Use SRFI-9 records for the job data structure., Mathieu Lirzin, 2015/09/27