Error skipping because parent directory has insecure permissions

Since Logrotate 3.8, which is default on Red Hat Enterprise Linux and CentOS 7, the parent permissions on your log directories play a vital role in whether or not logrotate will be able/willing to process your logs.

Since Logrotate 3.8, which is default on Red Hat Enterprise Linux and CentOS 7, the parent permissions on your log directories play a vital role in whether or not logrotate will be able/willing to process your logs.

If your permissions allow writes by a group that isn’t root, you may see the following error when logrotate tries to run.

$ logrotate /etc/logrotate.d/something

error: skipping "/var/www/vhosts/site.tld/logs/access.log" because parent directory has insecure permissions (It's world writable or writable by group which is not "root") Set "su" directive in config file to tell logrotate which user/group should be used for rotation.

error: skipping "/var/www/vhosts/site.tld/logs/error.log" because parent directory has insecure permissions (It's world writable or writable by group which is not "root") Set "su" directive in config file to tell logrotate which user/group should be used for rotation.

A default logrotate config, that looks like this, can cause that problem.

$ cat /etc/logrotate.d/something

/var/www/vhosts/site.tld/logs/access.log {
  create 0640 site_user httpd
  compress
  daily
  postrotate
    /sbin/service httpd reload > /dev/null 2>/dev/null || true
  endscript
}

It has the create statement, to recreate the logs with correct ownership/permissions, but that’s not sufficient for logrotate.

To resolve this problem, and have logrotate work properly again, you also have to add the su $user $group configuration. This causes logrotate to actually su - to that user and execute all logrotate actions as that user.

$ cat /etc/logrotate.d/something

/var/www/vhosts/site.tld/logs/access.log {
  create 0640 site_user httpd
  compress
  daily
  postrotate
    /sbin/service httpd reload > /dev/null 2>/dev/null || true
  endscript
  su site_user httpd
}

By adding a su site_user httpd in the example above, the same as the create config, logrotate can process the logs again with parent directories that have group permissions that allow groups other than root to write to those directories.

From https://github.com/logrotate/logrotate:

The logrotate utility is designed to simplify the administration of log files on a system which generates a lot of log files. Logrotate allows for the automatic rotation compression, removal and mailing of log files. Logrotate can be set to handle a log file daily, weekly, monthly or when the log file gets to a certain size.

By default, logrotate’s rotation consists of renaming existing log files with a numerical suffix, then recreating the original empty log file. For example, /var/log/syslog.log is renamed /var/log/syslog.log.1. If /var/log/syslog.log.1 already exists from a previous rotation, it is first renamed /var/log/syslog.log.2. (The number of backlogs to keep can be configured.)

Installation

Logrotate can be installed with the logrotate package.

By default, logrotate runs daily using a systemd timer: logrotate.timer.

Configuration

The primary configuration file for logrotate which sets default parameters is /etc/logrotate.conf; additional application-specific configuration files are included from the /etc/logrotate.d directory. Values set in application-specific configuration files override those same parameters in the primary configuration file. See logrotate.conf(5) for configuration examples and a reference of available directives.

To verify if logrotate works correctly, run it in debug mode, in this mode it does nothing except producing debug output:

logrotate --debug /etc/logrotate.conf

Compressing logs

Logrotate can compress logs with a custom command like zstd.

/etc/logrotate.conf
compress
compresscmd /usr/bin/zstd
compressext .zst
compressoptions -T0 --long
uncompresscmd /usr/bin/unzstd

See logrotate.conf(5) and zstd(1) for more details.

Usage

logrotate is usually run through the systemd service: logrotate.service.

To run logrotate manually:

# logrotate /etc/logrotate.conf

To rotate a single log file:

# logrotate /etc/logrotate.d/mylog

To simulate running your configuration file (dry run):

# logrotate --debug /etc/logrotate.d/mylog

To force running rotations even when conditions are not met, run:

# logrotate -vf /etc/logrotate.d/mylog

See logrotate(8) for more details.

Troubleshooting

exim log not rotated

If you have set the olddir variable in /etc/logrotate.conf, you will get a message such as:

error: failed to rename /var/log/exim/mainlog to /var/log/old/mainlog.1: Permission denied

To fix this, add the user exim to the group log. Then change the group of the olddir, usually /var/log/old, to log instead of the default root.

Check logrotate status

Logrotate rotations are usually logged to /var/lib/logrotate.status (the -s option allows you to specify another state file):

/var/lib/logrotate.status
"/var/log/mysql/query.log" 2016-3-20-5:0:0
"/var/log/samba/samba-smbd.log" 2016-3-21-5:0:0
"/var/log/httpd/access_log" 2016-3-20-5:0:0
...

Skipping log because parent directory has insecure permission

Configure which user and which group has to job /etc/logrotate.d/job to be run with:

file-to-be-rotated {
    su user group
    rotate 4
}

See also

  • Gentoo:Logrotate
  • logrotate(8) manual page
  • logrotate.conf(5) manual page
  • Печать

Страницы: [1]   Вниз

Тема: Обновление до 14.04 — не могу победить logrotate  (Прочитано 6154 раз)

0 Пользователей и 1 Гость просматривают эту тему.

Оффлайн
RustemNur

Обновил сервер с 12.04 до 14.04 (до этого 2 года назад обновлял его же с 10.04).
Поборол почти все косяки, за исключением logrotate. Для всех лог-файлов, настроенных в /etc/logrotate.conf, получаю сообщение:

error: skipping «/var/log/syslog» because parent directory has insecure permissions (It’s world writable or writable by group which is not «root») Set «su» directive in config file to tell logrotate which user/group should be used for rotation.

Предложенным в этом сообщениии способом (через указание su root syslog) удалось победить все логи, указанные в подкаталоге /etc/logrotate.d/, но логи из основного конфига так и не ротируются.
Вместо пары root syslog пробовал различные комбинации root syslog adm, но успеха не добился. Временно вынужден ротировать логи вручную, меняя права на папку /var/log на root root, далее запуская logrotate -f /etc/logrotate.conf и опять меняя права на root syslog.

Прошу помощи. Заранее благодарен.


Оффлайн
RustemNur

Ничего не нарыл, решил проблему тупо: в cron-е, откуда запускается logrotate, меняю права на папку /var/log и тут же возвращаю.


Оффлайн
fisher74

и опять меняя права на root syslog.

Эмммм…

~$ ls -ld /var/log
drwxr-xr-x 20 syslog adm 4096 сент.  5 06:27 /var/log


Оффлайн
RustemNur

fisher74, свежеустановленный с компашки 14.04-server:

ls -ld /var/log
drwxrwxr-x 9 root syslog 4096 сент.  7 06:37 /var/log

Но я сразу же писал, что пробовал и с adm:

Вместо пары root syslog пробовал различные комбинации root syslog adm, но успеха не добился.


Оффлайн
fisher74

Сегодня смог посмотреть в 14.04 виртуалке(подопытная, коробочная). Да, пермищны идентичны Вашим.
Я бы попробовал убрать write для группы. Я с английским практически не дружу, но по тексту понял, что именно это не нравится logrotate (у меня версии 3.8.7).


Пользователь решил продолжить мысль 08 Сентября 2014, 14:08:09:


https://bugs.launchpad.net/ubuntu/+source/logrotate/+bug/1278193

« Последнее редактирование: 08 Сентября 2014, 14:08:09 от fisher74 »


Оффлайн
baf

Да уж. Пока не дал на папку log группу root не мог победить эту заразу.
sudo chown root:root /var/log
только тогда все заработало, вот же ерунда, логов гиги накопились.


  • Печать

Страницы: [1]   Вверх

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Error size of array is too large
  • Error unable to access jarfile apachejmeter jar errorlevel 1
  • Error site test site does not exist
  • Error u8g was not declared in this scope
  • Error site does not exist a2ensite

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии