Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

systemd-crontab-generator generates cron.target.wants folder with nothing in it #115

Closed
Beethoven-n opened this issue Sep 7, 2023 · 24 comments
Labels

Comments

@Beethoven-n
Copy link

Beethoven-n commented Sep 7, 2023

>install systemd-cron
>crontab -e works, how nice!

PERSISTENT=yes
# min hour dom month dow command
  02  09   *   *     *   /usr/bin/redshift -PO 5800 -b 0.7
  30  23   *   *     *   /usr/bin/redshift -PO 5800 -b 0.5
@daily /usr/bin/redshift -PO 5800 -b 0.3

>ok, systemctl status cron-<tab>--
>huh. there's no cron-$USER-$USER-0.timer or cron-$USER-$USER-0.service
>okay, let's sudo systemctl daemon-reload; sudo systemctl daemon-reexec, that'll fix it
>systemctl list-timers --all lists all cron-$schedule.target units, but nothing corresponding to my user
>alright, let's sudo systemctl start cron-update.service
>nothing changes

>manually call /usr/lib/systemd/system-generators/systemd-crontab-generator ./
>get a folder, ./cron.target.wants/, with nothing from my crontab reflected

am i using the program wrong? there are literally no errors telling me anything is going wrong. even the exit code it returns 0, literally nothing is wrong, except for a non-generated timer/service pair

@nabijaczleweli
Copy link
Contributor

Version? Distributor? Did crontab -e actually persist something (stuff in crontab -l? crontab -s as root lists your username)? strace /usr/lib/systemd/system-generators/systemd-crontab-generator /tmp/tstout as root?

@Beethoven-n
Copy link
Author

Beethoven-n commented Sep 7, 2023

Distributor is arch linux, built with a fixed PKGBUILD to update to release 2.0.2

# Maintainer: Dwayne Bent <dbb@dbb.io>
pkgname=systemd-cron
pkgver=2.0.2
pkgrel=1
pkgdesc='systemd units to run cron scripts'
arch=(any)
url='https://github.com/systemd-cron/systemd-cron'
license=('MIT')
depends=('systemd>=236' 'run-parts' 'python')
optdepends=('smtp-forwarder: sending emails')
provides=('cron')
conflicts=('cron')
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/systemd-cron/${pkgname}/archive/refs/tags/v${pkgver}.tar.gz"
        'sysusers.conf')
install=${pkgname}.install
sha256sums=('SKIP'
            'SKIP')

prepare() {
	cd "${srcdir}/${pkgname}-${pkgver}"
	sed -i 's/print/echo/' ./configure # configure uses invalid shell cmds
}

build() {
    cd "${srcdir}/${pkgname}-${pkgver}"

    ./configure --prefix=/usr --confdir=/etc --libexecdir=/usr/lib \
        --enable-minutely --enable-quarterly --enable-semi_annually

    make
}

package() {
    cd "${srcdir}/${pkgname}-${pkgver}"

    make DESTDIR="${pkgdir}" install

    install -d "${pkgdir}"/etc/cron.{boot,minutely,hourly,daily,weekly,monthly,quarterly,semi-annually,yearly}
    install -dm775 "${pkgdir}/var/spool/cron"
    cat "${srcdir}/sysusers.conf" >> "${pkgdir}/usr/lib/sysusers.d/${pkgname}.conf"
}

crontab -l output does match the edits made in crontab -e

sudo crontab -s lists root and my user

strace output for command you asked:

execve("/usr/lib/systemd/system-generators/systemd-crontab-generator", ["/usr/lib/systemd/system-generato"..., "/tmp/tstout"], 0x7ffe7b2415e8 /* 89 vars */) = 0
brk(NULL)                               = 0x563c44094000
arch_prctl(0x3001 /* ARCH_??? */, 0x7ffde47b4ee0) = -1 EINVAL (Invalid argument)
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=254575, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 254575, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fade38be000
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/libcrypto.so.3", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 832) = 832
newfstatat(3, "", {st_mode=S_IFREG|0755, st_size=5218952, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fade38bc000
mmap(NULL, 5229408, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fade3200000
mmap(0x7fade32b1000, 3248128, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xb1000) = 0x7fade32b1000
mmap(0x7fade35ca000, 860160, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3ca000) = 0x7fade35ca000
mmap(0x7fade369c000, 385024, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x49c000) = 0x7fade369c000
mmap(0x7fade36fa000, 11104, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fade36fa000
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/libstdc++.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 832) = 832
newfstatat(3, "", {st_mode=S_IFREG|0755, st_size=21512640, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 2597056, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fade2e00000
mmap(0x7fade2e9c000, 1273856, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x9c000) = 0x7fade2e9c000
mmap(0x7fade2fd3000, 614400, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1d3000) = 0x7fade2fd3000
mmap(0x7fade3069000, 57344, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x269000) = 0x7fade3069000
mmap(0x7fade3077000, 12480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fade3077000
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 832) = 832
newfstatat(3, "", {st_mode=S_IFREG|0755, st_size=965016, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 966952, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fade37cf000
mmap(0x7fade37df000, 520192, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x10000) = 0x7fade37df000
mmap(0x7fade385e000, 376832, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x8f000) = 0x7fade385e000
mmap(0x7fade38ba000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xea000) = 0x7fade38ba000
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\220~\2\0\0\0\0\0"..., 832) = 832
pread64(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 784, 64) = 784
newfstatat(3, "", {st_mode=S_IFREG|0755, st_size=2366624, ...}, AT_EMPTY_PATH) = 0
pread64(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 784, 64) = 784
mmap(NULL, 2411920, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fade2a00000
mmap(0x7fade2a26000, 1437696, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x26000) = 0x7fade2a26000
mmap(0x7fade2b85000, 348160, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x185000) = 0x7fade2b85000
mmap(0x7fade2bda000, 417792, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1d9000) = 0x7fade2bda000
mmap(0x7fade2c40000, 52624, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fade2c40000
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 832) = 832
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=728120, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 147912, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fade37aa000
mmap(0x7fade37ae000, 110592, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x4000) = 0x7fade37ae000
mmap(0x7fade37c9000, 16384, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1f000) = 0x7fade37c9000
mmap(0x7fade37cd000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x22000) = 0x7fade37cd000
close(3)                                = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fade37a8000
mmap(NULL, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fade37a5000
arch_prctl(ARCH_SET_FS, 0x7fade37a5740) = 0
set_tid_address(0x7fade37a5a10)         = 415647
set_robust_list(0x7fade37a5a20, 24)     = 0
rseq(0x7fade37a6060, 0x20, 0, 0x53053053) = 0
mprotect(0x7fade2bda000, 409600, PROT_READ) = 0
mprotect(0x7fade37cd000, 4096, PROT_READ) = 0
mprotect(0x7fade38ba000, 4096, PROT_READ) = 0
mprotect(0x7fade3069000, 53248, PROT_READ) = 0
mprotect(0x7fade369c000, 372736, PROT_READ) = 0
mprotect(0x563c43b6c000, 4096, PROT_READ) = 0
mprotect(0x7fade392e000, 8192, PROT_READ) = 0
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
munmap(0x7fade38be000, 254575)          = 0
futex(0x7fade30776fc, FUTEX_WAKE_PRIVATE, 2147483647) = 0
getrandom("\x14\xb5\x74\x7e\xbe\xa6\x00\x17", 8, GRND_NONBLOCK) = 8
brk(NULL)                               = 0x563c44094000
brk(0x563c440b5000)                     = 0x563c440b5000
access("/usr/sbin/sendmail", X_OK)      = -1 ENOENT (No such file or directory)
access("/usr/lib/sendmail", X_OK)       = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=3052896, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 3052896, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fade2600000
close(3)                                = 0
openat(AT_FDCWD, "/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=2998, ...}, AT_EMPTY_PATH) = 0
read(3, "# Locale name alias data base.\n#"..., 4096) = 2998
read(3, "", 4096)                       = 0
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_IDENTIFICATION", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=258, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 258, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fade38fc000
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/gconv/gconv-modules.cache", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/gconv/gconv-modules", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=3916, ...}, AT_EMPTY_PATH) = 0
read(3, "# GNU libc iconv configuration.\n"..., 4096) = 3916
read(3, "", 4096)                       = 0
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/gconv/gconv-modules.d", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 3
newfstatat(3, "", {st_mode=S_IFDIR|0755, st_size=4096, ...}, AT_EMPTY_PATH) = 0
getdents64(3, 0x563c440ac860 /* 3 entries */, 32768) = 96
openat(AT_FDCWD, "/usr/lib/gconv/gconv-modules.d/gconv-modules-extra.conf", O_RDONLY|O_CLOEXEC) = 4
newfstatat(4, "", {st_mode=S_IFREG|0644, st_size=53974, ...}, AT_EMPTY_PATH) = 0
brk(0x563c440d6000)                     = 0x563c440d6000
read(4, "# GNU libc iconv configuration.\n"..., 4096) = 4096
read(4, "B1002//\tJUS_I.B1.002//\nmodule\tJU"..., 4096) = 4096
read(4, "59-5//\nalias\tISO_8859-5//\t\tISO-8"..., 4096) = 4096
read(4, "59-16//\t\tINTERNAL\t\tISO8859-16\t1\n"..., 4096) = 4096
read(4, "-SE-A\t1\nmodule\tINTERNAL\t\tEBCDIC-"..., 4096) = 4096
read(4, "97\t\t1\n\n#\tfrom\t\t\tto\t\t\tmodule\t\tcos"..., 4096) = 4096
read(4, "1\n\n#\tfrom\t\t\tto\t\t\tmodule\t\tcost\nal"..., 4096) = 4096
read(4, "6//\t\tIBM1046//\nalias\tCP1046//\t\tI"..., 4096) = 4096
read(4, "\tto\t\t\tmodule\t\tcost\nalias\tRUSCII/"..., 4096) = 4096
read(4, "03//\nmodule\tCSN_369103//\t\tINTERN"..., 4096) = 4096
read(4, "\tmodule\t\tcost\nalias\tISO-IR-8-1//"..., 4096) = 4096
read(4, "IBM1156\t\t1\n\n#\tfrom\t\t\tto\t\t\tmodule"..., 4096) = 4096
read(4, "\t\tIBM1166//\nalias\tCP1166//\t\tIBM1"..., 4096) = 4096
read(4, "alias\tROMAN9//\t\tHP-ROMAN9//\nalia"..., 4096) = 726
read(4, "", 4096)                       = 0
close(4)                                = 0
getdents64(3, 0x563c440ac860 /* 0 entries */, 32768) = 0
close(3)                                = 0
futex(0x7fade2c3f72c, FUTEX_WAKE_PRIVATE, 2147483647) = 0
openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_MEASUREMENT", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=23, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 23, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fade38fb000
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_TELEPHONE", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=47, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 47, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fade38fa000
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_ADDRESS", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=127, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 127, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fade38f9000
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_NAME", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=62, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 62, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fade38f8000
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_PAPER", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=34, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 34, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fade38f7000
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_MESSAGES", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFDIR|0755, st_size=4096, ...}, AT_EMPTY_PATH) = 0
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_MESSAGES/SYS_LC_MESSAGES", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=48, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 48, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fade38f6000
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_MONETARY", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=270, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 270, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fade38f5000
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_COLLATE", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=1406, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 1406, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fade38f4000
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_TIME", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=3360, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 3360, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fade38f3000
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_NUMERIC", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=50, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 50, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fade38f2000
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/locale/C.UTF-8/LC_CTYPE", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=357584, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 357584, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fade374d000
close(3)                                = 0
mkdir("/tmp", 0777)                     = -1 EEXIST (File exists)
mkdir("/tmp/tstout", 0777)              = 0
mkdir("/tmp/tstout/cron.target.wants", 0777) = 0
openat(AT_FDCWD, "/etc/crontab", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/cron.d", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (No such file or directory)
exit_group(0)                           = ?
+++ exited with 0 +++

yes, ./configure does actually use invalid shell commands. the shebang indicates sh as the intended shell runtime, but print (found at line 125) does not exist in

@Beethoven-n
Copy link
Author

gonna quickly try to system update, because if it's just that this whole time i'm gonna die. i banged my head against this for 2 hours

@nabijaczleweli
Copy link
Contributor

print is provided by mailcap, not strictly invalid, but it's baffling to me why it's used as an echo. Blame says 00eae1d, fixed locally.

@Beethoven-n
Copy link
Author

might poke the aur package maintainer about that, but they haven't updated since 1.16.7 so i don't expect a response

@nabijaczleweli
Copy link
Contributor

Or just don't pass --confdir.

The strace, very literally, does locale and iconv setup, then

mkdir("/tmp", 0777)                     = -1 EEXIST (File exists)
mkdir("/tmp/tstout", 0777)              = 0
mkdir("/tmp/tstout/cron.target.wants", 0777) = 0
openat(AT_FDCWD, "/etc/crontab", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/cron.d", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (No such file or directory)
exit_group(0)                           = ?
+++ exited with 0 +++

You're configured with run-parts (which you probably shouldn't be for a modern config btw!), and:

	if(!USE_RUNPARTS) {
		auto i = 0u;
		for(auto period : {"hourly"sv, "daily"sv, "weekly"sv, "monthly"sv, "yearly"sv}) {
			++i;
			auto directory = "/etc/cron."s += period;
			if(struct stat sb; stat(directory.c_str(), &sb) || !S_ISDIR(sb.st_mode))
				continue;
			for_each_file(directory.c_str(), [&](std::string_view basename) {
				if(is_masked(directory.c_str(), basename, {std::begin(PART2TIMER), std::end(PART2TIMER)}))
					return;
				if(is_backup(directory.c_str(), basename))
					return;
				auto filename            = (directory + '/') += basename;
				std::string_view command = filename;
				Job job{filename, filename};
				job.persistent = true;
				job.period     = period;
				job.start_hour = distro_start_hour[period];  // default 0
				job.boot_delay = i * 5;
				job.command    = {{&command, &command + 1}, {}};
				job.jobid      = (std::string{period} += '-') += basename;
				job.decode();  // ensure clean jobid
				job.generate_schedule();
				if(fallback_mailto && job.environment.find("MAILTO"sv) == std::end(job.environment))
					job.environment.emplace("MAILTO"sv, *fallback_mailto);
				job.unit_name = "cron-" + job.jobid;
				job.output();
			});
		}

		if(!parse_crontab("/etc/anacrontab", withuser_t::from_basename, /*monotonic=*/true, toplevel_mail_successful_output, toplevel_output_mail_format,
		                  [&](auto && job) {
			                  if(!job.valid) {
				                  log(Log::ERR, "truncated line in /etc/anacrontab: %.*s", FORMAT_SV(job.line));
				                  return;
			                  }
			                  generate_timer_unit(job);
		                  }))
			log(Log::ERR, "%s: %s", "/etc/anacrontab", std::strerror(errno));

		if(struct stat sb; !stat(STATEDIR, &sb) && S_ISDIR(sb.st_mode)) {
			// /var is available
			for_each_file(STATEDIR, [&](std::string_view basename) {
				if(basename.find('.') != std::string_view::npos)
					return;

				auto filename = (std::string{STATEDIR} += '/') += basename;
				if(!parse_crontab(filename, withuser_t::from_basename, /*monotonic=*/false, toplevel_mail_successful_output, toplevel_output_mail_format,
				                  [&](auto && job) { generate_timer_unit(job); }))
					log(Log::ERR, "%s: %s", filename.c_str(), std::strerror(errno));
			});
			vore::file::fd<false>{REBOOT_FILE, O_WRONLY | O_CREAT | O_CLOEXEC, 0666};
		} else {
			if(!workaround_var_not_mounted())
				log(Log::WARNING, "%s: %s", "cron-after-var.service", std::strerror(errno));
		}
	}

Which looks an awful lot like I fucked up reading the python and included run-parts as being a precondition for processing users' crontabs (STATEDIR) :v

@nabijaczleweli
Copy link
Contributor

@Beethoven-n
Copy link
Author

Will comment that i specifically updated to 2.0.2 and systemd-crontab-generator on my install is not a python script

@nabijaczleweli
Copy link
Contributor

nabijaczleweli commented Sep 7, 2023

Yes it's a trivial translation error on my part when converting the Python to C++. If you try the master branch (at least ded6dfc) it should be fixed.

@nabijaczleweli
Copy link
Contributor

nabijaczleweli commented Sep 7, 2023

(also, you should probably configure with --enable_runparts=no, this way you don't need run-parts and you'll get a systemd unit for each file in /etc/cron.{daily,weekly}, &c.. but please try with just the updated upstream first)

@Beethoven-n
Copy link
Author

build warning with the only PKGBUILD change being

depends=('systemd>=236' 'run-parts' 'python' 'mailcap')

error:

warning: directory permissions differ on /var/spool/cron/
filesystem: 1730  package: 775

also error is not fixed yet. will try to update build() with --enable_runparts=no to see if that fixes it

@Beethoven-n
Copy link
Author

==> Starting prepare()...
==> Starting build()...
configure: unrecognized option '--enable_runparts=no'
==> ERROR: A failure occurred in build().
    Aborting...

missing option?

@Beethoven-n
Copy link
Author

oh it has to be enable-runparts ok

@nabijaczleweli
Copy link
Contributor

nabijaczleweli commented Sep 7, 2023

Okay, in order:

  • don't depend on mailcap, this was clearly just a mistake on alexandre's part; I've s/print/echo/ed in f3a13b5
  • idk, i've never used arch so i don't know what that warning is. it should be 1730 or thereabouts
  • --enable-runparts=no, but try without it first

If it still doesn't work on ded6dfc-or-later, then post the strace-as-root output again.

@Beethoven-n
Copy link
Author

--enable-runparts=no fixed the problem!

will update pkgbuild to remove mailcap dependency, and figure out why the permissions are incorrect

@Beethoven-n
Copy link
Author

was just an incorrect arg in package(). warning is fixed by doing install -dm1730 ... instead of install -dm755 ...

@a-detiste
Copy link
Contributor

I just woke up 😁.
Will read tomorrow.

The print is of course a glitch.

Was /etc/cron.d already ok in run-parts mode ?

@Beethoven-n
Copy link
Author

i never checked actually but i kinda don't wanna rebuild again, i just wanna get to using the program already

@nabijaczleweli
Copy link
Contributor

nabijaczleweli commented Sep 8, 2023

I had

if(!USE_RUNPARTS) {
	for(auto period : {"hourly"sv, "daily"sv, "weekly"sv, "monthly"sv, "yearly"sv}) {
		// /etc/cron.period/...
	}

	if(!parse_crontab("/etc/anacrontab", ...)
		...;

	if(struct stat sb; !stat(STATEDIR, &sb) && S_ISDIR(sb.st_mode)) {
		// /var is avaible
		for_each_file(STATEDIR, [&](std::string_view basename) {
			// users' crontabs
	}
}

instead of

if(!USE_RUNPARTS) {
	for(auto period : {"hourly"sv, "daily"sv, "weekly"sv, "monthly"sv, "yearly"sv}) {
		// /etc/cron.period/...
	}
}

if(!parse_crontab("/etc/anacrontab", ...)
	...;

if(struct stat sb; !stat(STATEDIR, &sb) && S_ISDIR(sb.st_mode)) {
	// /var is avaible
	for_each_file(STATEDIR, [&](std::string_view basename) {
		// users' crontabs
}

And never noticed (curse you python blocks being indent-only), fixed in ded6dfc. Functionally they are fine.

The print thing is fixed in f3a13b5.

@a-detiste
Copy link
Contributor

might poke the aur package maintainer about that, but they haven't updated since 1.16.7 so i don't expect a response

Poke again :-)

@dbent , the aur maintainer did initiated systemd-cron and Arch was the first distro to ship it.

At first there weren't even a generator, only the static units with run-parts.

For these reasons only I think that run-parts support should be retained.

The lexical serialisation of jobs can also be really usefull in some settings.

There are still a few Arch-only lines in the Makefile,
but they are marked accordingly and are no-op
on other distro, so they can stay;
but it would be cleaner to move those to the AUR build.

# Arch linux specific
        if getent group cron > /dev/null 2>&1; then \
            chgrp cron $(DESTDIR)$(libexecdir)/systemd-cron/crontab_setgid ; \
            chmod 2755 $(DESTDIR)$(libexecdir)/systemd-cron/crontab_setgid ; \
        fi

@a-detiste
Copy link
Contributor

I had

For readability you can use as many single-use functions like workaround_var_not_mounted
as you want, they'll be inlined by the compiler anyway.

@dbent
Copy link
Member

dbent commented Sep 8, 2023

The lexical serialisation of jobs can also be really usefull in some settings.

I figured a major version number change was a good opportunity to disable run-parts, but didn't consider serialized dependencies between scripts. I've added a note to the installation to warn users of this change.

There are still a few Arch-only lines in the Makefile,
but they are marked accordingly and are no-op
on other distro, so they can stay;
but it would be cleaner to move those to the AUR build.

# Arch linux specific
        if getent group cron > /dev/null 2>&1; then \
           chgrp cron $(DESTDIR)$(libexecdir)/systemd-cron/crontab_setgid ; \
           chmod 2755 $(DESTDIR)$(libexecdir)/systemd-cron/crontab_setgid ; \
       fi

These at least are handled by the package's install script (which I'm now realizing there's no way to view on the AUR web interface... you have to clone the package repository), so that can be removed from the generic Makefile.

@nabijaczleweli
Copy link
Contributor

(arch stuff removed in 5d789e5)

@a-detiste
Copy link
Contributor

@dbent a new fixup release has been published

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants