All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v3 1/1] dcron: new package
@ 2014-07-08 10:21 Alvaro G. M
  2014-07-15 18:56 ` Thomas Petazzoni
  0 siblings, 1 reply; 8+ messages in thread
From: Alvaro G. M @ 2014-07-08 10:21 UTC (permalink / raw)
  To: buildroot

Signed-off-by: Alvaro G. M <alvaro.gamez@hazent.com>
---
This patch addresses latests comments from Thomas P.

The package now includes previous considerations about typical use as help
text of the Config.in option.

It also solves the fact that it wasn't really installing anything at all,
sets busybox as dependency so it can overwrite busybox' cron and crontab files,
and modifies /etc/cron.d/system file after installing it so it uses run-parts
instead of 'run-cron', a file provided by upstream with the same purpose.
 

 package/Config.in       |  1 +
 package/dcron/Config.in | 19 +++++++++++++++++++
 package/dcron/dcron.mk  | 31 +++++++++++++++++++++++++++++++
 3 files changed, 51 insertions(+)
 create mode 100644 package/dcron/Config.in
 create mode 100644 package/dcron/dcron.mk

diff --git a/package/Config.in b/package/Config.in
index 95c0c8b..3f4384f 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1124,6 +1124,7 @@ menu "System tools"
 if BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
 	source "package/bootutils/Config.in"
 	source "package/coreutils/Config.in"
+	source "package/dcron/Config.in"
 endif
 	source "package/cpuload/Config.in"
 	source "package/dsp-tools/Config.in"
diff --git a/package/dcron/Config.in b/package/dcron/Config.in
new file mode 100644
index 0000000..37182de
--- /dev/null
+++ b/package/dcron/Config.in
@@ -0,0 +1,19 @@
+config BR2_PACKAGE_DCRON
+	bool "dcron"
+	help
+	  dcron is a time-based job scheduler with anacron-like features.
+	  It works as a background daemon that parses individual crontab
+	  files and executes commands on behalf of the users in question.
+
+	  Upon installation, this package will enable a system level cron
+	  daemon with hourly, daily, weekly and monthly crontabs.
+
+	  However, it doesn't allow non root users to create their own
+	  crontab file. This is because /var/spool/cron/crontabs is non
+	  user writable.
+
+	  Typically, a crontab group is created on the system and users
+	  allowed to create crontab entries are added into this group, while
+	  crontab executable is owned by root:crontab with sgid bit enabled.
+
+	  http://www.jimpryor.net/linux/dcron.html
diff --git a/package/dcron/dcron.mk b/package/dcron/dcron.mk
new file mode 100644
index 0000000..20dcf23
--- /dev/null
+++ b/package/dcron/dcron.mk
@@ -0,0 +1,31 @@
+################################################################################
+#
+# dcron
+#
+################################################################################
+
+DCRON_VERSION = 4.5
+DCRON_SITE = http://www.jimpryor.net/linux/releases/
+# The source code does not specify the version of the GPL that is used.
+DCRON_LICENSE = GPL
+
+ifeq ($(BR2_PACKAGE_BUSYBOX),y)
+DCRON_DEPENDENCIES = busybox
+endif
+
+define DCRON_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) $(TARGET_CONFIGURE_OPTS)
+endef
+
+define DCRON_INSTALL_TARGET_CMDS
+	$(INSTALL) -D -m0700 $(@D)/crond $(TARGET_DIR)/usr/sbin
+	$(INSTALL) -D -m4755 $(@D)/crontab $(TARGET_DIR)/usr/bin
+	$(INSTALL) -D -m0644 $(@D)/extra/root.crontab $(TARGET_DIR)/etc/cron.d/system
+	# Busybox provides run-parts, so there is no need to use nor install provided run-cron
+	$(SED) 's#/usr/sbin/run-cron#/bin/run-parts#g' $(TARGET_DIR)/etc/cron.d/system
+	$(INSTALL) -d -m0755 $(TARGET_DIR)/var/spool/cron/crontabs \
+	        $(TARGET_DIR)/etc/cron.daily $(TARGET_DIR)/etc/cron.hourly \
+	        $(TARGET_DIR)/etc/cron.monthly $(TARGET_DIR)/etc/cron.weekly
+endef
+
+$(eval $(generic-package))
-- 
2.0.0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH v3 1/1] dcron: new package
  2014-07-08 10:21 [Buildroot] [PATCH v3 1/1] dcron: new package Alvaro G. M
@ 2014-07-15 18:56 ` Thomas Petazzoni
  2014-07-15 19:10   ` Alvaro G. M.
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Petazzoni @ 2014-07-15 18:56 UTC (permalink / raw)
  To: buildroot

Dear Alvaro G. M,

On Tue,  8 Jul 2014 12:21:32 +0200, Alvaro G. M wrote:
> Signed-off-by: Alvaro G. M <alvaro.gamez@hazent.com>

I've applied your patch, but had to make a few changes. Moreover, your
package does not install any init script to start crond. Maybe you
should cook a followup patch that adds an init script, no?

> diff --git a/package/Config.in b/package/Config.in
> index 95c0c8b..3f4384f 100644
> --- a/package/Config.in
> +++ b/package/Config.in
> @@ -1124,6 +1124,7 @@ menu "System tools"
>  if BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
>  	source "package/bootutils/Config.in"
>  	source "package/coreutils/Config.in"
> +	source "package/dcron/Config.in"
>  endif
>  	source "package/cpuload/Config.in"

Alphabetic ordering not respected here.

>  	source "package/dsp-tools/Config.in"
> diff --git a/package/dcron/Config.in b/package/dcron/Config.in
> new file mode 100644
> index 0000000..37182de
> --- /dev/null
> +++ b/package/dcron/Config.in
> @@ -0,0 +1,19 @@
> +config BR2_PACKAGE_DCRON
> +	bool "dcron"

Missing dependency on BR2_USE_MMU, since the package uses the fork()
system call.

> +	help
> +	  dcron is a time-based job scheduler with anacron-like features.
> +	  It works as a background daemon that parses individual crontab
> +	  files and executes commands on behalf of the users in question.
> +
> +	  Upon installation, this package will enable a system level cron
> +	  daemon with hourly, daily, weekly and monthly crontabs.
> +
> +	  However, it doesn't allow non root users to create their own
> +	  crontab file. This is because /var/spool/cron/crontabs is non
> +	  user writable.
> +
> +	  Typically, a crontab group is created on the system and users
> +	  allowed to create crontab entries are added into this group, while
> +	  crontab executable is owned by root:crontab with sgid bit enabled.

Lines too long, I had to rewrap them.

> diff --git a/package/dcron/dcron.mk b/package/dcron/dcron.mk
> new file mode 100644
> index 0000000..20dcf23
> --- /dev/null
> +++ b/package/dcron/dcron.mk
> @@ -0,0 +1,31 @@
> +################################################################################
> +#
> +# dcron
> +#
> +################################################################################
> +
> +DCRON_VERSION = 4.5
> +DCRON_SITE = http://www.jimpryor.net/linux/releases/
> +# The source code does not specify the version of the GPL that is used.
> +DCRON_LICENSE = GPL
> +
> +ifeq ($(BR2_PACKAGE_BUSYBOX),y)

I added a short comment above this to explain why we're doing this.

> +DCRON_DEPENDENCIES = busybox
> +endif
> +
> +define DCRON_BUILD_CMDS
> +	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) $(TARGET_CONFIGURE_OPTS)
> +endef
> +
> +define DCRON_INSTALL_TARGET_CMDS
> +	$(INSTALL) -D -m0700 $(@D)/crond $(TARGET_DIR)/usr/sbin
> +	$(INSTALL) -D -m4755 $(@D)/crontab $(TARGET_DIR)/usr/bin

On both of those lines, it should have been a full path for the targets.

Thanks,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH v3 1/1] dcron: new package
  2014-07-15 18:56 ` Thomas Petazzoni
@ 2014-07-15 19:10   ` Alvaro G. M.
  2014-07-15 19:17     ` Thomas Petazzoni
  0 siblings, 1 reply; 8+ messages in thread
From: Alvaro G. M. @ 2014-07-15 19:10 UTC (permalink / raw)
  To: buildroot

Hi Thomas

Thank you for all your additional fixes. I'll try to make it easier for everyone next time, It seems clear there were too many errors on this small contribution.

I'll take a look at the init script. I hadn't thought about it because I tipically run it directly on inittab.

Regards

On Tue Jul 15 20:56:33 2014 Thomas Petazzoni <thomas.petazzoni@free-electrons.com> wrote:
> Dear Alvaro G. M,
> 
> On Tue,?  8 Jul 2014 12:21:32 +0200, Alvaro G. M wrote:
> > Signed-off-by: Alvaro G. M <alvaro.gamez@hazent.com>
> 
> I've applied your patch, but had to make a few changes. Moreover, your
> package does not install any init script to start crond. Maybe you
> should cook a followup patch that adds an init script, no?
> 
> > diff --git a/package/Config.in b/package/Config.in
> > index 95c0c8b..3f4384f 100644
> > --- a/package/Config.in
> > +++ b/package/Config.in
> > @@ -1124,6 +1124,7 @@ menu "System tools"
> > if BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
> > ??? source "package/bootutils/Config.in"
> > ??? source "package/coreutils/Config.in"
> > +??? source "package/dcron/Config.in"
> > endif
> > ??? source "package/cpuload/Config.in"
> 
> Alphabetic ordering not respected here.
> 
> > ??? source "package/dsp-tools/Config.in"
> > diff --git a/package/dcron/Config.in b/package/dcron/Config.in
> > new file mode 100644
> > index 0000000..37182de
> > --- /dev/null
> > +++ b/package/dcron/Config.in
> > @@ -0,0 +1,19 @@
> > +config BR2_PACKAGE_DCRON
> > +??? bool "dcron"
> 
> Missing dependency on BR2_USE_MMU, since the package uses the fork()
> system call.
> 
> > +??? help
> > +??? ?  dcron is a time-based job scheduler with anacron-like features.
> > +??? ?  It works as a background daemon that parses individual crontab
> > +??? ?  files and executes commands on behalf of the users in question.
> > +
> > +??? ?  Upon installation, this package will enable a system level cron
> > +??? ?  daemon with hourly, daily, weekly and monthly crontabs.
> > +
> > +??? ?  However, it doesn't allow non root users to create their own
> > +??? ?  crontab file. This is because /var/spool/cron/crontabs is non
> > +??? ?  user writable.
> > +
> > +??? ?  Typically, a crontab group is created on the system and users
> > +??? ?  allowed to create crontab entries are added into this group, while
> > +??? ?  crontab executable is owned by root:crontab with sgid bit enabled.
> 
> Lines too long, I had to rewrap them.
> 
> > diff --git a/package/dcron/dcron.mk b/package/dcron/dcron.mk
> > new file mode 100644
> > index 0000000..20dcf23
> > --- /dev/null
> > +++ b/package/dcron/dcron.mk
> > @@ -0,0 +1,31 @@
> > +################################################################################
> > +#
> > +# dcron
> > +#
> > +################################################################################
> > +
> > +DCRON_VERSION = 4.5
> > +DCRON_SITE = http://www.jimpryor.net/linux/releases/
> > +# The source code does not specify the version of the GPL that is
> > used. +DCRON_LICENSE = GPL
> > +
> > +ifeq ($(BR2_PACKAGE_BUSYBOX),y)
> 
> I added a short comment above this to explain why we're doing this.
> 
> > +DCRON_DEPENDENCIES = busybox
> > +endif
> > +
> > +define DCRON_BUILD_CMDS
> > +??? $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) $(TARGET_CONFIGURE_OPTS)
> > +endef
> > +
> > +define DCRON_INSTALL_TARGET_CMDS
> > +??? $(INSTALL) -D -m0700 $(@D)/crond $(TARGET_DIR)/usr/sbin
> > +??? $(INSTALL) -D -m4755 $(@D)/crontab $(TARGET_DIR)/usr/bin
> 
> On both of those lines, it should have been a full path for the targets.
> 
> Thanks,
> 
> Thomas
> -- 
> Thomas Petazzoni, CTO, Free Electrons
> Embedded Linux, Kernel and Android engineering
> http://free-electrons.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20140715/cafba3b2/attachment.html>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH v3 1/1] dcron: new package
  2014-07-15 19:10   ` Alvaro G. M.
@ 2014-07-15 19:17     ` Thomas Petazzoni
  2014-07-17  9:34       ` [Buildroot] [PATCH 1/1] dcron: provide init script Alvaro G. M
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Petazzoni @ 2014-07-15 19:17 UTC (permalink / raw)
  To: buildroot

Dear Alvaro G. M.,

On Tue, 15 Jul 2014 21:10:36 +0200, Alvaro G. M. wrote:

> Thank you for all your additional fixes. I'll try to make it easier
> for everyone next time, It seems clear there were too many errors on
> this small contribution.

That's perfectly fine, we can't expect all contributions from newcomers
to immediately be perfect. Your contributions are very welcome.

> I'll take a look at the init script. I hadn't thought about it
> because I tipically run it directly on inittab.

Ah, ok. Still, I believe an init script would be welcome, as we
typically bundle a basic init script in any package that has a daemon,
so that it kind of works out of the box for Buildroot users.

Thanks,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH 1/1] dcron: provide init script
  2014-07-15 19:17     ` Thomas Petazzoni
@ 2014-07-17  9:34       ` Alvaro G. M
  2014-07-17 16:58         ` Yann E. MORIN
  2014-07-17 19:00         ` Thomas Petazzoni
  0 siblings, 2 replies; 8+ messages in thread
From: Alvaro G. M @ 2014-07-17  9:34 UTC (permalink / raw)
  To: buildroot

dcron doesn't create a pid file, so we run it in foreground but make
start-stop-daemon create the pidfile and move the daemon to background.

Give it a number greater than exim's init script, so job output email
can be sent.

Signed-off-by: Alvaro G. M <alvaro.gamez@hazent.com>
---
 package/dcron/S90dcron | 22 ++++++++++++++++++++++
 package/dcron/dcron.mk |  1 +
 2 files changed, 23 insertions(+)
 create mode 100644 package/dcron/S90dcron

diff --git a/package/dcron/S90dcron b/package/dcron/S90dcron
new file mode 100644
index 0000000..c2925fd
--- /dev/null
+++ b/package/dcron/S90dcron
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+case "$1" in
+	start)
+		echo -n "Starting cron ... "
+		start-stop-daemon -S -q -m -b -p /var/run/dcron.pid --exec /usr/sbin/crond -- -f
+		echo "done."
+		;;
+	stop)
+		echo -n "Stopping cron ..."
+		start-stop-daemon -K -q -p /var/run/dcron.pid
+		echo "done."
+		;;
+	restart)
+		$0 stop
+		sleep 1
+		$0 start
+		;;
+	*)
+		echo "usage: $0 {start|stop|restart}"
+		;;
+esac
diff --git a/package/dcron/dcron.mk b/package/dcron/dcron.mk
index 5174e38..e5a28f2 100644
--- a/package/dcron/dcron.mk
+++ b/package/dcron/dcron.mk
@@ -27,6 +27,7 @@ define DCRON_INSTALL_TARGET_CMDS
 	$(INSTALL) -d -m0755 $(TARGET_DIR)/var/spool/cron/crontabs \
 	        $(TARGET_DIR)/etc/cron.daily $(TARGET_DIR)/etc/cron.hourly \
 	        $(TARGET_DIR)/etc/cron.monthly $(TARGET_DIR)/etc/cron.weekly
+	$(INSTALL) -m 0755 -D package/dcron/S90dcron $(TARGET_DIR)/etc/init.d/S90dcron
 endef
 
 $(eval $(generic-package))
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH 1/1] dcron: provide init script
  2014-07-17  9:34       ` [Buildroot] [PATCH 1/1] dcron: provide init script Alvaro G. M
@ 2014-07-17 16:58         ` Yann E. MORIN
  2014-07-17 18:35           ` Thomas Petazzoni
  2014-07-17 19:00         ` Thomas Petazzoni
  1 sibling, 1 reply; 8+ messages in thread
From: Yann E. MORIN @ 2014-07-17 16:58 UTC (permalink / raw)
  To: buildroot

Alvaro, All,

On 2014-07-17 11:34 +0200, Alvaro G. M spake thusly:
> dcron doesn't create a pid file, so we run it in foreground but make
> start-stop-daemon create the pidfile and move the daemon to background.
> 
> Give it a number greater than exim's init script, so job output email
> can be sent.
> 
> Signed-off-by: Alvaro G. M <alvaro.gamez@hazent.com>
> ---
>  package/dcron/S90dcron | 22 ++++++++++++++++++++++
>  package/dcron/dcron.mk |  1 +
>  2 files changed, 23 insertions(+)
>  create mode 100644 package/dcron/S90dcron
> 
> diff --git a/package/dcron/S90dcron b/package/dcron/S90dcron
> new file mode 100644
> index 0000000..c2925fd
> --- /dev/null
> +++ b/package/dcron/S90dcron
> @@ -0,0 +1,22 @@
> +#!/bin/sh
> +
> +case "$1" in
> +	start)
> +		echo -n "Starting cron ... "
> +		start-stop-daemon -S -q -m -b -p /var/run/dcron.pid --exec /usr/sbin/crond -- -f
> +		echo "done."
> +		;;
> +	stop)
> +		echo -n "Stopping cron ..."
> +		start-stop-daemon -K -q -p /var/run/dcron.pid
> +		echo "done."
> +		;;
> +	restart)
> +		$0 stop
> +		sleep 1
> +		$0 start
> +		;;
> +	*)
> +		echo "usage: $0 {start|stop|restart}"
> +		;;
> +esac
> diff --git a/package/dcron/dcron.mk b/package/dcron/dcron.mk
> index 5174e38..e5a28f2 100644
> --- a/package/dcron/dcron.mk
> +++ b/package/dcron/dcron.mk
> @@ -27,6 +27,7 @@ define DCRON_INSTALL_TARGET_CMDS
>  	$(INSTALL) -d -m0755 $(TARGET_DIR)/var/spool/cron/crontabs \
>  	        $(TARGET_DIR)/etc/cron.daily $(TARGET_DIR)/etc/cron.hourly \
>  	        $(TARGET_DIR)/etc/cron.monthly $(TARGET_DIR)/etc/cron.weekly
> +	$(INSTALL) -m 0755 -D package/dcron/S90dcron $(TARGET_DIR)/etc/init.d/S90dcron

This should be in a DCRON_INSTALL_INIT_SYSV macro, see:
    http://buildroot.org/downloads/manual/manual.html#_infrastructure_for_packages_with_specific_build_systems

Also provide the systemd unit file (if it is available in the package!)
with the DCRON_INSTALL_INIT_SYSTEMD macro.

Regards,
Yann E. MORIN.

>  endef
>  
>  $(eval $(generic-package))
> -- 
> 2.0.1
> 
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH 1/1] dcron: provide init script
  2014-07-17 16:58         ` Yann E. MORIN
@ 2014-07-17 18:35           ` Thomas Petazzoni
  0 siblings, 0 replies; 8+ messages in thread
From: Thomas Petazzoni @ 2014-07-17 18:35 UTC (permalink / raw)
  To: buildroot

Dear Yann E. MORIN,

On Thu, 17 Jul 2014 18:58:14 +0200, Yann E. MORIN wrote:

> This should be in a DCRON_INSTALL_INIT_SYSV macro, see:
>     http://buildroot.org/downloads/manual/manual.html#_infrastructure_for_packages_with_specific_build_systems

I'll fix this when applying.

> Also provide the systemd unit file (if it is available in the package!)
> with the DCRON_INSTALL_INIT_SYSTEMD macro.

I don't think there's a systemd unit file for dcron.

However, I remember there was one in the recently added upmpdcli
package, but since I don't know much about systemd, I didn't had
support for it. If anyone feel like adding support for upmpdcli systemd
unit file, don't hesitate to do it :-)

Cheers,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH 1/1] dcron: provide init script
  2014-07-17  9:34       ` [Buildroot] [PATCH 1/1] dcron: provide init script Alvaro G. M
  2014-07-17 16:58         ` Yann E. MORIN
@ 2014-07-17 19:00         ` Thomas Petazzoni
  1 sibling, 0 replies; 8+ messages in thread
From: Thomas Petazzoni @ 2014-07-17 19:00 UTC (permalink / raw)
  To: buildroot

Dear Alvaro G. M,

On Thu, 17 Jul 2014 11:34:08 +0200, Alvaro G. M wrote:
> dcron doesn't create a pid file, so we run it in foreground but make
> start-stop-daemon create the pidfile and move the daemon to background.
> 
> Give it a number greater than exim's init script, so job output email
> can be sent.
> 
> Signed-off-by: Alvaro G. M <alvaro.gamez@hazent.com>
> ---
>  package/dcron/S90dcron | 22 ++++++++++++++++++++++
>  package/dcron/dcron.mk |  1 +
>  2 files changed, 23 insertions(+)
>  create mode 100644 package/dcron/S90dcron

Thanks, applied with the change suggested by Yann.

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-07-17 19:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-08 10:21 [Buildroot] [PATCH v3 1/1] dcron: new package Alvaro G. M
2014-07-15 18:56 ` Thomas Petazzoni
2014-07-15 19:10   ` Alvaro G. M.
2014-07-15 19:17     ` Thomas Petazzoni
2014-07-17  9:34       ` [Buildroot] [PATCH 1/1] dcron: provide init script Alvaro G. M
2014-07-17 16:58         ` Yann E. MORIN
2014-07-17 18:35           ` Thomas Petazzoni
2014-07-17 19:00         ` Thomas Petazzoni

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.