Page MenuHomeFreeBSD

Add a 'force' option for non-interactive crontab removal
ClosedPublic

Authored by sam_samgwydir.com on Dec 16 2016, 1:26 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 11, 1:14 PM
Unknown Object (File)
Tue, Apr 2, 7:43 PM
Unknown Object (File)
Tue, Apr 2, 5:57 PM
Unknown Object (File)
Mar 16 2024, 6:57 AM
Unknown Object (File)
Mar 16 2024, 6:57 AM
Unknown Object (File)
Mar 12 2024, 11:25 AM
Unknown Object (File)
Mar 12 2024, 11:25 AM
Unknown Object (File)
Mar 12 2024, 11:25 AM

Details

Summary

While converting a user provisioning tool from use in linux to FreeBSD it turned out crontab -r was interactive (requiring 'y' to remove). This diff adds a '-f' option to force crontab to be non-interactive.

Test Plan

Tested by adding a test user, creating a crontab for them and attempting to remove it with a without '-f' set.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

sam_samgwydir.com retitled this revision from to Add a 'force' option for non-interactive crontab removal.
sam_samgwydir.com updated this object.
sam_samgwydir.com edited the test plan for this revision. (Show Details)
sam_samgwydir.com set the repository for this revision to rS FreeBSD src repository - subversion.

Please upload a diff with full context (either use the arc tool, or generate a patch with diff -U9999999).

usr.sbin/cron/crontab/crontab.c
66 ↗(On Diff #22971)

Spacing between 'int' and 'fflag' looks off relative to other variables nearby.

sam_samgwydir.com edited edge metadata.

Added more context.

Also fixed spacing before 'fflag'

sam_samgwydir.com edited edge metadata.
sam_samgwydir.com removed rS FreeBSD src repository - subversion as the repository for this revision.
sam_samgwydir.com marked an inline comment as done.

Fixed spacing. There was an extra space that I did not account for.

cem added a reviewer: cem.

Do you have a commit bit, or do you need me to commit this for you? Thanks!

usr.sbin/cron/crontab/crontab.1
20 ↗(On Diff #22980)

In general, bump .Dd to the date you changed the manual page.

usr.sbin/cron/crontab/crontab.c
289 ↗(On Diff #22980)

I see. You could also workaround this by running crontab ... < /dev/null. I still like your -f flag, though.

This revision is now accepted and ready to land.Dec 16 2016, 1:56 AM
sam_samgwydir.com edited edge metadata.
sam_samgwydir.com set the repository for this revision to rS FreeBSD src repository - subversion.

Fixed date in manpage and no I don't have a bit -- if you could commit that would be great.

This revision now requires review to proceed.Dec 16 2016, 2:04 AM
cem edited edge metadata.
This revision is now accepted and ready to land.Dec 16 2016, 2:07 AM
sam_samgwydir.com edited edge metadata.
sam_samgwydir.com marked an inline comment as done.

Diff was broken -- now fixed.

This revision now requires review to proceed.Dec 16 2016, 4:36 PM
wblock added inline comments.
usr.sbin/cron/crontab/crontab.1
35 ↗(On Diff #23003)

This implies that -f is used instead of one of the other arguments. I suggest

{
.Fl l |
.Fl r Op Fl f
|
.Fl e
}
101 ↗(On Diff #23003)

This should probably not be a separate item, since it is only used with -r.

Add
.Fl f
to force the removal without a prompt for confirmation.
sam_samgwydir.com edited edge metadata.

Fixed man page according to feedback. Also fixed usage() to reflect those changes.

sam_samgwydir.com added inline comments.
usr.sbin/cron/crontab/crontab.c
289 ↗(On Diff #22980)

Yeah we were piping in yes but it wasn't until I got into the code I saw there was some way to make it non-interactive, but it's undocumented.

This patch is ready to go now -- if someone could commit it that'd be perfect.

This revision was automatically updated to reflect the committed changes.