<?xml version="1.0" encoding="UTF-8" ?>

<bugzilla version="5.2"
          urlbase="https://bugzilla.altlinux.org/"
          
          maintainer="jenya@basealt.ru"
>

    <bug>
          <bug_id>38281</bug_id>
          
          <creation_ts>2020-03-26 18:32:26 +0300</creation_ts>
          <short_desc>altlinux-kmsg-loglevel fails in unprivileged containers</short_desc>
          <delta_ts>2020-03-26 18:32:26 +0300</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Development</classification>
          <product>Sisyphus</product>
          <component>systemd</component>
          <version>unstable</version>
          <rep_platform>all</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P5</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Arseny Maslennikov">arseny</reporter>
          <assigned_to name="Alexey Shabalin">shaba</assigned_to>
          <cc>arseny</cc>
    
    <cc>shaba</cc>
    
    <cc>vseleznv</cc>
          
          <qa_contact>qa-sisyphus</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>188844</commentid>
    <comment_count>0</comment_count>
    <who name="Arseny Maslennikov">arseny</who>
    <bug_when>2020-03-26 18:32:26 +0300</bug_when>
    <thetext>Юнит переходит в состояние failed в окружениях, в которых его бессмысленно пытаться запускать.

/bin/dmesg -n $LOGLEVEL вызывает klogctl(8, NULL, 3):

# strace -e trace=syslog dmesg -n 3
syslog(8 /* SYSLOG_ACTION_CONSOLE_LEVEL */, NULL, 3 /* LOGLEVEL_ERR */) = -1 EPERM (Operation not permitted)
dmesg: klogctl failed: Operation not permitted
+++ exited with 1 +++

man:klogctl(2) says:

All commands except 3 and 10 require privilege.  In Linux kernels before 2.6.37, command types 3 and 10 are allowed to unprivileged processes; since Linux 2.6.37, these commands are allowed to unprivileged processes only if /proc/sys/kernel/dmesg_restrict has the value 0. Before  Linux  2.6.37, &quot;privileged&quot;  means  that  the  caller  has  the  CAP_SYS_ADMIN  capability. Since Linux 2.6.37, &quot;privileged&quot; means that the caller has either the CAP_SYS_ADMIN capability (now deprecated for this purpose) or the (new) CAP_SYSLOG capability.

В достаточно непривилегированном lxc-контейнере таких капов нет.
Более того, если их выдать, dmesg всё равно работать не будет.

Предлагаю дописать туда в секцию [Unit]:
ConditionCapability=CAP_SYSLOG
ConditionCapability=|CAP_SYS_ADMIN

и, возможно:
ConditionVirtualization=!container

или предотвратить срабатывание сервиса в окружениях без доступа к /bin/dmesg -n $number как-то лучше.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>