助け合いフォーラム

LinuC

LinuC Lv1-102(Ver10.0)
問題ID : 15600
問題を開く
「/etc/cron.allow」と「/etc/cron.deny」ファイルが存在しない場合、cronを利用できるユーザについての説明として適切なものは次のうちどれか。

この問題はプレミアムコンテンツです。

上に戻る

「/etc/cron.allow」と「/etc/cron.deny」ファイルが存在しない場合

公開日 2023/02/06

回答では、「rootユーザのみが利用できる」が正解となっていますが、最近受けた講習会で、現在は、「全てのユーザが利用できる」のが正解と聞きました。どちらが正しいのでしょうか?

2023/02/06 17:54

「/etc/cron.allow」と「/etc/cron.deny」ファイルが存在しない場合の挙動は以前から議論のある内容のようですね。
https://ping-t.com/modules/forum/index.php?topic_id=4866
https://ping-t.com/modules/forum/index.php?topic_id=2749

事情が変わったのかなと思って MIRACLE LINUX 9(5.14.0-70.13.1.el9_0.x86_64)で確認してみましたが、
「どちらのファイルもない場合はrootだけ使用可能」は変わってませんでした。

[guest@ML9 ~]$ ls /etc/cron.allow /etc/cron.deny
ls: cannot access '/etc/cron.allow': No such file or directory
ls: cannot access '/etc/cron.deny': No such file or directory
[guest@ML9 ~]$ crontab -e
You (guest) are not allowed to use this program (crontab)  ★
See crontab(1) for more information

man 1 crontab にも以下の記述です。

If neither of these files exist, then only the super user is allowed to use crontab.

ただ、少し調べてみたところ、
LinuC の方(レベル1 102)の例題だと「どちらも存在しない場合は全ユーザが利用可能」となってたり、
https://linuc.org/study/samples/3341/

LPI Learning Materials だと「ディストリビューションごとに異なる」となってます。
https://learning.lpi.org/en/learning-materials/102-500/107/107.2/107.2_01/#_configure_access_to_job_scheduling

If neither of these files exist, the user’s access to cron job scheduling depends on the distribution used.

一応 MIRACLE LINUX の man 1 crontab では「POSIXに準拠している」とあったので、
POSIXを見てみると、以下のようにありました:(最新 POSIX:2008-2018)
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html

If neither file exists, only a process with appropriate privileges shall be allowed to submit a job.

「どっちのファイルもない場合は、適切な権限を持ったプロセスだけがジョブ登録できますよ」

それからUbuntu(Debian系)については以下に記述があります。
https://help.ubuntu.com/community/CronHowto#Allowing.2FDenying_User-Level_Cron

In the case where neither file exists, the default on current Ubuntu (and Debian, but not some other Linux and UNIX systems) is to allow all users to run jobs with crontab.
No cron.allow or cron.deny files exist in a standard Ubuntu install, so all users should have cron available by default, until one of those files is created. If a blank cron.deny file has been created, that will change to the standard behavior users of other operating systems might expect: cron only available to root or users in cron.allow.

「どっちのファイルもない場合は、(ほかの Linux とか UNIX とは違って)Ubuntu とか Debian では全ユーザが利用できます」
特に「that will change to the standard behavior users of other operating systems might expect(他のOSのユーザーが期待する標準的な動作に変更されます)」
を読む限りでは、標準的な動作とは異なるってことになるのかなと理解しました。

長くなりましたが、まとめると(個人的な理解で恐縮ですが)、
/etc/cron.allow、/etc/cron.deny の両方がない場合は、
標準(POSIX)の動作としては root だけが利用できる。
ただし Debian系(Ubuntuなど)では全ユーザが利用できる という例外もある。
ということでしょうか。出題時にどんな条件や選択肢で出題されるかがポイントかもです。

最新の事情などはわからないので、講習会の講師のかたに質問できるようでしたら是非してみていただきたいです。。


コメント

k kamosan

2023/02/06 22:31

丁寧な解説ありがとうございます。試験の出題みてもたぶん悩むような気がします。でもこの1問が外れたからって落ちるようならまだまだですね。^^;

この返信に対して
コメントを記入できます

この投稿に対して返信しませんか?