Skip to content

Commit

Permalink
Feature/fix email From: w/ configurable "displayname" (#17)
Browse files Browse the repository at this point in the history
* WIP: add displayname option

Signed-off-by: Marco Emilio "sphakka" Poleggi <[email protected]>

* Fix configure.in

Signed-off-by: Marco Emilio "sphakka" Poleggi <[email protected]>

* Restored orig configure.in + displayname opt

Signed-off-by: Marco Emilio "sphakka" Poleggi <[email protected]>

* job.c: create_mail():

Process 'displayname', etc. via new function 'make_mailbox()' as per RFC5322.

Signed-off-by: Marco Emilio "sphakka" Poleggi <[email protected]>

* Fixed wrong formatting (tabs => spaces)

Signed-off-by: Marco Emilio "sphakka" Poleggi <[email protected]>

* dev(code, doc, test): displayname handling refactored over two functions.

* code: config handling of displayname moved to a new function
  'format_displayname()' in 'fcronconf.c'; buffer overflow check added. In
  'job.c': restored old "From:" mail header behavior if no displayname; buffer
  overflow check added.
* test: added prototype support in 'Makefile' and 'test/'
* doc: reviewed and cleaned 'en/fcron.conf.5.sgml'

Signed-off-by: Marco Emilio "sphakka" Poleggi <[email protected]>

* dev(code, test): @pr #17, 3rd round.

* Makefile(s): fixed alignement with spaces
* config.in: moved displayname in "Check for fcron..." section. Removed test
    install code.
* fcronconf.c: changed format_displayname()'s arg to avoid confusion with
    globals. Use stdbool. Use aux var when assigning from
    format_displayname().
* crondyn_svr.c, fileconf.c: minimal fixes to avoid conflict with stdbool.
* fcron.conf.in: added comment for possible displayname's future default value.
* global.h: added stdbool.
* job.c: changed make_mailbox_addr()'s arg to avoid confusion with
    globals. Use stdbool.
* test/mailbox_addr.c: rewritten with simpler explicit logic -- valgrinded
    again ;-)

Signed-off-by: Marco Emilio "sphakka" Poleggi <[email protected]>

---------

Signed-off-by: Marco Emilio "sphakka" Poleggi <[email protected]>
  • Loading branch information
sphakka authored Aug 24, 2024
1 parent 8236ae2 commit 2b18ac9
Show file tree
Hide file tree
Showing 14 changed files with 657 additions and 277 deletions.
160 changes: 84 additions & 76 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,95 +4,96 @@

# @configure_input@


# The following should not be edited manually (use configure options)
# If you must do it, BEWARE : some of the following is also defined
# in config.h, so you must modify config.h AND Makefile in order
# to set the same values in the two files.

FCRON_ALLOW = fcron.allow
FCRON_DENY = fcron.deny
FCRON_CONF = fcron.conf
# Please, keep assignments aligned with spaces.
FCRON_ALLOW = fcron.allow
FCRON_DENY = fcron.deny
FCRON_CONF = fcron.conf

SRCDIR := @srcdir@
SRCDIR := @srcdir@
# Useful to build packages
# you may want to use this var with a : 'make DESTDIR=dir install'
DESTDIR :=
DESTDIR :=

# Where should we install it ?
prefix = @prefix@
exec_prefix = @exec_prefix@
DESTSBIN = @sbindir@
DESTBIN = @bindir@
ETC = @sysconfdir@
FCRONTABS = @FCRONTABS@
PIDDIR = @PIDDIR@
FIFODIR = @FIFODIR@
PIDFILE = @PIDFILE@
REBOOT_LOCK = @REBOOT_LOCK@
SUSPEND_FILE = @SUSPEND_FILE@
FIFOFILE = @FIFOFILE@
FCRON_SHELL = @FCRON_SHELL@
SENDMAIL = @SENDMAIL@
FCRON_EDITOR = @FCRON_EDITOR@
OPTIM := @CFLAGS@
LDFLAGS := @LDFLAGS@
CPPFLAGS := @CPPFLAGS@ -I. -I${SRCDIR}
LIBS := @LIBS@
LIBOBJS := @LIBOBJS@
DEFS := @DEFS@
CC := @CC@
INSTALL := @INSTALL@
STRIP := @STRIP@
ROOTNAME := @ROOTNAME@
ROOTGROUP := @ROOTGROUP@
USERNAME := @USERNAME@
GROUPNAME := @GROUPNAME@
SYSFCRONTAB := @SYSFCRONTAB@
DEBUG := @DEBUG@
BOOTINSTALL := @BOOTINSTALL@
ANSWERALL := @ANSWERALL@
USEPAM := @USEPAM@
FCRONDYN := @FCRONDYN@
SYSTEMD_DIR := @SYSTEMD_DIR@
prefix = @prefix@
exec_prefix = @exec_prefix@
DESTSBIN = @sbindir@
DESTBIN = @bindir@
ETC = @sysconfdir@
FCRONTABS = @FCRONTABS@
PIDDIR = @PIDDIR@
FIFODIR = @FIFODIR@
PIDFILE = @PIDFILE@
REBOOT_LOCK = @REBOOT_LOCK@
SUSPEND_FILE = @SUSPEND_FILE@
FIFOFILE = @FIFOFILE@
FCRON_SHELL = @FCRON_SHELL@
SENDMAIL = @SENDMAIL@
FCRON_EDITOR = @FCRON_EDITOR@
OPTIM := @CFLAGS@
LDFLAGS := @LDFLAGS@
CPPFLAGS := @CPPFLAGS@ -I. -I${SRCDIR}
LIBS := @LIBS@
LIBOBJS := @LIBOBJS@
DEFS := @DEFS@
CC := @CC@
INSTALL := @INSTALL@
STRIP := @STRIP@
ROOTNAME := @ROOTNAME@
ROOTGROUP := @ROOTGROUP@
USERNAME := @USERNAME@
GROUPNAME := @GROUPNAME@
SYSFCRONTAB := @SYSFCRONTAB@
DEBUG := @DEBUG@
BOOTINSTALL := @BOOTINSTALL@
ANSWERALL := @ANSWERALL@
USEPAM := @USEPAM@
FCRONDYN := @FCRONDYN@
SYSTEMD_DIR := @SYSTEMD_DIR@
DISPLAYNAME := @DISPLAYNAME@

# Options
# -DDEBUG even more verbose
# -DCHECKJOBS send a mail containing the exact shell command
# for each execution of each job.
# -DFOREGROUND=[0|1] default run in foreground ?
#OPTION= -DCHECKJOBS
#OPTION= -O3 -mcpu=i686
OPTION :=
# -DDEBUG even more verbose
# -DCHECKJOBS send a mail containing the exact shell command
# for each execution of each job.
# -DFOREGROUND=[0|1] default run in foreground ?
#OPTION = -DCHECKJOBS
#OPTION = -O3 -mcpu=i686
OPTION :=


####################################
# Should not be changed under this #
####################################

VERSION := @VERSION@
CFLAGS += $(OPTIM) $(OPTION) $(DEFS) $(CPPFLAGS) $(LDFLAGS)
VERSION := @VERSION@
CFLAGS += $(OPTIM) $(OPTION) $(DEFS) $(CPPFLAGS) $(LDFLAGS)
ifeq ($(FCRONDYN), 1)
LIBOBJS := $(LIBOBJS)
LIBOBJS := $(LIBOBJS)
endif
OBJSD := fcron.o cl.o subs.o mem.o save.o temp_file.o log.o database.o job.o conf.o u_list.o exe_list.o lavg_list.o env_list.o fcronconf.o filesubs.o select.o fcrondyn_svr.o suspend.o $(LIBOBJS)
OBJSTAB := fcrontab.o cl.o subs.o mem.o save.o temp_file.o log.o fileconf.o allow.o read_string.o u_list.o env_list.o fcronconf.o filesubs.o
OBJSDYN := fcrondyn.o subs.o mem.o log.o allow.o read_string.o fcronconf.o filesubs.o
OBJCONV := convert-fcrontab.o cl.o subs.o mem.o save.o log.o u_list.o env_list.o fcronconf.o filesubs.o
OBJSIG := fcronsighup.o subs.o mem.o log.o allow.o fcronconf.o filesubs.o
HEADERSALL := config.h $(SRCDIR)/global.h $(SRCDIR)/cl.h $(SRCDIR)/log.h $(SRCDIR)/subs.h $(SRCDIR)/mem.h $(SRCDIR)/save.h $(SRCDIR)/option.h $(SRCDIR)/dyncom.h
OBJSD := fcron.o cl.o subs.o mem.o save.o temp_file.o log.o database.o job.o conf.o u_list.o exe_list.o lavg_list.o env_list.o fcronconf.o filesubs.o select.o fcrondyn_svr.o suspend.o $(LIBOBJS)
OBJSTAB := fcrontab.o cl.o subs.o mem.o save.o temp_file.o log.o fileconf.o allow.o read_string.o u_list.o env_list.o fcronconf.o filesubs.o
OBJSDYN := fcrondyn.o subs.o mem.o log.o allow.o read_string.o fcronconf.o filesubs.o
OBJCONV := convert-fcrontab.o cl.o subs.o mem.o save.o log.o u_list.o env_list.o fcronconf.o filesubs.o
OBJSIG := fcronsighup.o subs.o mem.o log.o allow.o fcronconf.o filesubs.o
HEADERSALL := config.h $(SRCDIR)/global.h $(SRCDIR)/cl.h $(SRCDIR)/log.h $(SRCDIR)/subs.h $(SRCDIR)/mem.h $(SRCDIR)/save.h $(SRCDIR)/option.h $(SRCDIR)/dyncom.h

# this is a regular expression :
# do not ci automaticaly generated files and doc (done by doc's Makefile)
RCSNOCI:=.*\(.html\|VERSION\|MANIFEST\|configure\|install.sh\|config.log\|config.status\|config.h\|config.cache\|Makefile\|doc.*\|CVS.*\|.git.*\)
RCSNOCI := .*\(.html\|VERSION\|MANIFEST\|configure\|install.sh\|config.log\|config.status\|config.h\|config.cache\|Makefile\|doc.*\|CVS.*\|.git.*\)

RUN_NON_PRIVILEGED := @RUN_NON_PRIVILEGED@
ifeq ($(RUN_NON_PRIVILEGED), 1)
BINMODE:=711
BINMODESIGHUP:=711
BINMODE := 711
BINMODESIGHUP := 711
else
BINMODE:=6711
BINMODESIGHUP:=4710
BINMODE := 6711
BINMODESIGHUP := 4710
endif

ifeq ($(FCRONDYN), 1)
Expand Down Expand Up @@ -126,7 +127,7 @@ exe_list_test: exe_list.o u_list.o exe_list_test.o log.o subs.o
-DFCRONTABS="\"${FCRONTABS}\"" \
-DFCRON_ALLOW="\"${FCRON_ALLOW}\"" -DFCRON_DENY="\"${FCRON_DENY}\"" \
-DFCRON_SHELL="\"${FCRON_SHELL}\"" -DSENDMAIL="\"${SENDMAIL}\"" \
-DFCRON_EDITOR="\"${FCRON_EDITOR}\"" -DBINDIREX="\"${DESTBIN}\"" \
-DFCRON_EDITOR="\"${FCRON_EDITOR}\"" \-DDISPLAYNAME="\"${DISPLAYNAME}\"" -DBINDIREX="\"${DESTBIN}\"" \
-c $<

initscripts:
Expand All @@ -138,7 +139,12 @@ initscripts:
documentation:
$(MAKE) -C doc doc-if-none

install: install-staged strip perms
.PHONY: test
test:
$(MAKE) -C test tests


install: install-staged strip perms
ifeq ($(BOOTINSTALL), 1)
$(SRCDIR)/script/boot-install "$(INSTALL) -o $(ROOTNAME)" $(DESTSBIN) $(DEBUG) $(FCRONTABS) $(ANSWERALL) $(SRCDIR)
endif
Expand Down Expand Up @@ -180,16 +186,16 @@ endif
perms: install-staged strip
# Note : we don't use "chown user:group file" because some systems use ":"
# and others "." as separator.
chown $(ROOTNAME) $(DESTDIR)$(DESTSBIN)
chgrp $(ROOTGROUP) $(DESTDIR)$(DESTSBIN)
chown $(ROOTNAME) $(DESTDIR)$(DESTBIN)
chgrp $(ROOTGROUP) $(DESTDIR)$(DESTBIN)
chown $(ROOTNAME) $(DESTDIR)$(ETC)
chgrp $(ROOTGROUP) $(DESTDIR)$(ETC)
chown $(ROOTNAME) $(DESTDIR)$(FIFODIR)
chgrp $(ROOTGROUP) $(DESTDIR)$(FIFODIR)
chown $(ROOTNAME) $(DESTDIR)$(PIDDIR)
chgrp $(ROOTGROUP) $(DESTDIR)$(PIDDIR)
chown $(ROOTNAME) $(DESTDIR)$(DESTSBIN)
chgrp $(ROOTGROUP) $(DESTDIR)$(DESTSBIN)
chown $(ROOTNAME) $(DESTDIR)$(DESTBIN)
chgrp $(ROOTGROUP) $(DESTDIR)$(DESTBIN)
chown $(ROOTNAME) $(DESTDIR)$(ETC)
chgrp $(ROOTGROUP) $(DESTDIR)$(ETC)
chown $(ROOTNAME) $(DESTDIR)$(FIFODIR)
chgrp $(ROOTGROUP) $(DESTDIR)$(FIFODIR)
chown $(ROOTNAME) $(DESTDIR)$(PIDDIR)
chgrp $(ROOTGROUP) $(DESTDIR)$(PIDDIR)

# change spool dir mode
chown $(USERNAME) $(DESTDIR)$(FCRONTABS)
Expand Down Expand Up @@ -245,7 +251,7 @@ ifeq ($(FCRONDYN), 1)
endif
endif

install-boot: install
install-boot: install
$(SRCDIR)/script/boot-install "$(INSTALL) -o $(ROOTNAME)" $(DESTSBIN) $(DEBUG) $(FCRONTABS) $(ANSWERALL) $(SRCDIR)

install-restart: install
Expand All @@ -266,6 +272,7 @@ clean:
rm -f *.o core
rm -f fcron fcrontab fcrondyn fcronsighup convert-fcrontab files/fcron.conf
$(MAKE) -C doc clean
$(MAKE) -C test clean

ciclean: clean
find ./ -name "*~" -exec rm -f {} \;
Expand All @@ -276,6 +283,7 @@ vclean: ciclean
files/fcron.conf script/fcron.init.suse script/fcron.init.systemd script/fcron.init.systemd.reboot \
script/fcron.sh script/sysVinit-launcher
$(MAKE) -C doc clean
$(MAKE) -C test clean


files/fcron.conf: $(SRCDIR)/files/fcron.conf.in config.h
Expand All @@ -291,7 +299,7 @@ indent:
--dont-cuddle-else *.c *.h

configure: configure.in
# update configure script, then Makefile and config.h, and finally
# update configure script, then Makefile and config.h, and finally
# run make tar using the new Makefile (needed because the version
# is set in the configure.in file)
autoconf
Expand Down
38 changes: 21 additions & 17 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,18 @@ AC_CHECK_LIB(kstat, kstat_open, [kstat=1], [kstat=0])
if test $getloadavg -eq 1; then
dnl Nothing to do ...
AC_FUNC_GETLOADAVG
AC_MSG_CHECKING(function to use for lavg* options)
AC_MSG_CHECKING(function to use for lavg* options)
AC_MSG_RESULT(getloadavg())
elif test $kstat -eq 1; then
AC_MSG_CHECKING(function to use for lavg* options)
AC_MSG_CHECKING(function to use for lavg* options)
LIBS="$LIBS -lkstat"
AC_LIBOBJ([getloadavg])
AC_DEFINE_UNQUOTED(HAVE_KSTAT, 1)
AC_MSG_RESULT(kstat)
else
dnl Try to use the /proc/loadavg file ...
AC_FUNC_GETLOADAVG
AC_MSG_CHECKING(function to use for lavg* options)
AC_MSG_CHECKING(function to use for lavg* options)
AC_MSG_RESULT(/proc/loadavg)
fi
AC_CHECK_FUNCS(getcwd gettimeofday mktime putenv strerror setenv unsetenv gethostname)
Expand Down Expand Up @@ -167,7 +167,7 @@ dnl ---------------------------------------------------------------------
fcron_enable_checks=yes
AC_ARG_ENABLE(checks,
[ --disable-checks Don't verify that programs exist on the host ], dnl '
[ case "$enableval" in
[ case "$enableval" in
no)
fcron_enable_checks=no
;;
Expand All @@ -179,7 +179,11 @@ AC_ARG_ENABLE(checks,
;;
esac
])


DISPLAYNAME=
AC_MSG_RESULT([$DISPLAYNAME])
AC_SUBST([DISPLAYNAME])


dnl ---------------------------------------------------------------------
dnl Programs ...
Expand Down Expand Up @@ -287,6 +291,7 @@ fi
AC_MSG_RESULT([$FCRON_EDITOR])
AC_SUBST([FCRON_EDITOR])


dnl ---------------------------------------------------------------------
dnl Paths ...

Expand Down Expand Up @@ -364,7 +369,7 @@ AC_ARG_WITH(proc,
[ case "$withval" in
no)
AC_MSG_WARN([
Without proc, you won't be able to use the lavg* options
Without proc, you won't be able to use the lavg* options
])
AC_DEFINE(NOLOADAVG)
;;
Expand Down Expand Up @@ -450,7 +455,7 @@ AC_ARG_WITH(run-non-privileged,
AC_MSG_WARN([

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
WARNING :
WARNING :
This option allows a non privileged user to run fcron. When used,
fcron does not change its rights before running a job (i.e.,
if joe runs fcron, every job will run as joe).
Expand Down Expand Up @@ -558,7 +563,7 @@ AC_ARG_WITH(rootname,
*)
rootname=$withval
;;
esac
esac
])

if test $fcron_enable_checks = 'yes'; then
Expand Down Expand Up @@ -891,13 +896,13 @@ AC_ARG_WITH(pam,
AC_MSG_ERROR(Must be set to either "yes" or "no".)
;;
esac ],
if test "$usepam" = "1"; then
if test "$usepam" = "1"; then
AC_MSG_RESULT(yes)
AC_CHECK_LIB(pam, pam_acct_mgmt)
else
usepam=0
AC_MSG_RESULT(no)
fi
fi
)
if test "$usepam" != "0" && echo "$LIBS" | grep -- "-lpam" > /dev/null ; then
usepam=1
Expand Down Expand Up @@ -926,7 +931,7 @@ AC_ARG_WITH(selinux,
else
AC_MSG_RESULT(not available)
AC_MSG_ERROR([
You requested the use of SELinux, but SELinux is considered
You requested the use of SELinux, but SELinux is considered
as not available by configure script.
])
fi
Expand Down Expand Up @@ -966,7 +971,7 @@ AC_MSG_CHECKING(Looking for docbook2man converter)
AC_ARG_WITH(db2man,
[ --with-db2man=PATH(or 'no') set PATH to a docbook2man converter.],
[ case "$withval" in
no)
no)
DB2MAN=""
AC_MSG_RESULT(none)
;;
Expand Down Expand Up @@ -995,7 +1000,7 @@ AC_ARG_WITH(db2man-spec,
[ --with-db2man-spec=PATH set the PATH to docbook2man-spec file
(needed if no db2man converter is set).],
[ case "$withval" in
no)
no)
DB2MAN_SPEC=""
AC_MSG_RESULT(none)
;;
Expand Down Expand Up @@ -1037,7 +1042,7 @@ AC_MSG_CHECKING(Looking for dsssl stylsheets)
AC_ARG_WITH(dsssl-dir,
[ --with-dsssl-dir=DIR change the default location of DSSSL stylesheets.],
[ case "$withval" in
no)
no)
DSSSL_DIR=""
AC_MSG_RESULT(none)
;;
Expand Down Expand Up @@ -1069,7 +1074,7 @@ dnl Final settings
dnl ---------------------------------------------------------------------


AC_OUTPUT(Makefile doc/Makefile doc/stylesheets/fcron-doc.dsl)
AC_OUTPUT(Makefile doc/Makefile test/Makefile doc/stylesheets/fcron-doc.dsl)


dnl ---------------------------------------------------------------------
Expand Down Expand Up @@ -1169,8 +1174,7 @@ echo "sbin dir: $sbindir"
echo "spool dir: $sp"
echo "etc dir: $sysconfdir"
echo "doc dir: $docdir"
echo "man dir: $mandir "

echo "man dir: $mandir"

echo
echo "You can now run '$MAKE' to compile"
Expand Down
Loading

0 comments on commit 2b18ac9

Please sign in to comment.