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

fcron systab not loaded #25072

Closed
alunduil opened this issue Apr 21, 2017 · 3 comments
Closed

fcron systab not loaded #25072

alunduil opened this issue Apr 21, 2017 · 3 comments

Comments

@alunduil
Copy link
Contributor

Issue description

When using fcron, the systab gets generated from the system cron commands just like any of the other crons but the logic that updates that in fcron appears to have stopped working in 17.03. Looking in the module I see a commented out line that attempts to do it but when I run it by hand I receive an error about the file not being a regular file.

Steps to reproduce

  1. enable fcron—services.fcron.enable; services.cron.disable;
  2. add a system cron entry—services.cron.systemCronJobs = ...;
  3. after ensuring fcrontab is started check systab—fcrontab -l -u systab
  4. use the systab loading command in the fcron unit to attempt to install systab
  5. receive errors about not being a regular file
[root@elijah:~]# fcrontab -u systab /nix/store/zfcjd0hdl3slayqkghib8p5xnzx7c8c6-systab
2017-04-20 19:40:50 ERROR open_as_user(): file /nix/store/zfcjd0hdl3slayqkghib8p5xnzx7c8c6-systab is not a regular file: Success
2017-04-20 19:40:50 ERROR Could not open file /nix/store/zfcjd0hdl3slayqkghib8p5xnzx7c8c6-systab: Success
2017-04-20 19:40:50 ERROR fcron child aborted: this does not affect the main fcron daemon, but this may prevent a job from being run or an email from being sent.

Copying the file to another location via cat does make this work correctly so I'm not sure what the solution might be.

Technical details

  • System: 17.03.1016.c558d093ab (Gorilla)
  • Nix version: nix-env (Nix) 1.11.8
  • Nixpkgs version: "17.03.1016.c558d093ab"
@Mic92 Mic92 closed this as completed in 44c3726 Apr 23, 2017
Mic92 added a commit that referenced this issue Apr 23, 2017
fixes #25072

(cherry picked from commit 44c3726)
@Ekleog
Copy link
Member

Ekleog commented Oct 9, 2017

Hmm... I seem to be hitting this very same problem with fcron on 17.03.1890.41c9543f84 (Gorilla) (which should include the fixing commit):

  services.fcron = {
    enable = true;
    systab =
      ''
        1 /bin/sh -c echo
      '';
  };

gives me the following logs:

fcron-pre-start[20497]: 2017-10-09 02:47:23 ERROR open_as_user(): file /nix/store/8fyzdr1na1q1shl5693r7bm2y9cyipsk-systab is not a regular file: Success
fcron-pre-start[20497]: 2017-10-09 02:47:23 ERROR Could not open file /nix/store/8fyzdr1na1q1shl5693r7bm2y9cyipsk-systab: Success
fcron-pre-start[20497]: 2017-10-09 02:47:23 ERROR fcron child aborted: this does not affect the main fcron daemon, but this may prevent a job from being run or an email from being sent.
systemd[1]: Starting fcron daemon...
fcrontab[20499]: open_as_user(): file /nix/store/8fyzdr1na1q1shl5693r7bm2y9cyipsk-systab is not a regular file: Success
systemd[1]: Started fcron daemon.
fcrontab[20499]: Could not open file /nix/store/8fyzdr1na1q1shl5693r7bm2y9cyipsk-systab: Success
fcrontab[20499]: fcron child aborted: this does not affect the main fcron daemon, but this may prevent a job from being run or an email from being sent.
fcron[20503]: fcron[20503] 3.2.1 started
fcron[20503]: @reboot jobs will only be run at computer's startup.
fcron[20503]: updating configuration from /var/spool/fcron

Would anyone have a pointer as to what could be going wrong? I've checked and the fcrontab in the systemd unit is correctly the wrapped one.

@Mic92
Copy link
Member

Mic92 commented Oct 9, 2017

I also noticed fcrontab needs itself in PATH: e34e28e

the following works for me:

  services = {
    fcron = {
      enable = true;
      systab = ''
        @ 1 /bin/sh -c "echo hello world"
      '';
    };
 };
Oct 09 11:41:49 turingmachine systemd[1]: Starting fcron daemon...
Oct 09 11:41:49 turingmachine fcrontab[20907]: installing file /nix/store/dl89ilccp1clqx4zim3fjp7hy2acc5kv-systab for user systab
Oct 09 11:41:49 turingmachine fcron-pre-start[20900]: 2017-10-09 11:41:49  INFO installing file /nix/store/dl89ilccp1clqx4zim3fjp7hy2acc5kv-systab for user systab
Oct 09 11:41:49 turingmachine fcron-pre-start[20900]: fcron is not running :
Oct 09 11:41:49 turingmachine fcron-pre-start[20900]:   modifications will be taken into account at its next execution.
Oct 09 11:41:49 turingmachine fcron[20930]: fcron[20930] 3.2.1 started
Oct 09 11:41:49 turingmachine systemd[1]: Started fcron daemon.
Oct 09 11:41:49 turingmachine fcron[20930]: @reboot jobs will only be run at computer's startup.
Oct 09 11:41:49 turingmachine fcron[20930]: updating configuration from /var/spool/fcron
Oct 09 11:41:49 turingmachine fcron[20930]: adding file systab
Oct 09 11:41:49 turingmachine fcron[20930]: adding new file systab
Oct 09 11:42:49 turingmachine fcron[22735]: Job '/bin/sh -c "echo hello world"' started for user systab (pid 22737)
Oct 09 11:42:49 turingmachine fcron[22735]: Job '/bin/sh -c "echo hello world"' completed (mailing output)
Oct 09 11:42:49 turingmachine sSMTP[22735]: Creating SSL connection to host

@Ekleog
Copy link
Member

Ekleog commented Oct 9, 2017

I was hitting this issue due to the nix store being auto-optimized and thus using hard links for the systab: fcron refuses to open the file if it has a hard link, apparently for security reasons. (apart from the syntax error that arose during minification of the example, thanks for the feedback!)

See #30261 for a possible fix :)

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

No branches or pull requests

3 participants