Bug 217082 - app-misc/dnetc-2.9015.504 error in /etc/init.d/dnetc
Bug#: 217082 Product:  Gentoo Linux Version: 2005.1 Platform: x86
OS/Version: Linux Status: RESOLVED Severity: normal Priority: P2
Resolution: FIXED Assigned To: wolf31o2@gentoo.org Reported By: art-gt@broomstick.com
Component: Applications
URL: 
Summary: app-misc/dnetc-2.9015.504 error in /etc/init.d/dnetc
Keywords:  
Status Whiteboard: 
Opened: 2008-04-10 03:23 0000
Description:   Opened: 2008-04-10 03:23 0000
dnetc reports an error on startup:

/etc/init.d/dnetc: line 45: /sys/kernel/uids/104/cpu_share: No such file or
directory

Previous versions do not have this error.

The relevant lines in /etc/init.d/dnetc read:

  # fair group cpu scheduler
  [ -d /sys/kernel/uids/ ] && echo 2 > \
    /sys/kernel/uids/$(grep -w dnetc /etc/passwd | cut -d: -f3)/cpu_share

In this case the file /sys/kernel/uids/104/cpu_share exists:

# ls -Zd /sys /sys/kernel /sys/kernel/uids /sys/kernel/uids/104
/sys/kernel/uids/104/cpu_share
drwxr-xr-x  root root system_u:object_r:sysfs_t  /sys
drwxr-xr-x  root root system_u:object_r:sysfs_t  /sys/kernel
drwxr-xr-x  root root system_u:object_r:sysfs_t  /sys/kernel/uids
drwxr-xr-x  root root system_u:object_r:sysfs_t  /sys/kernel/uids/104
-rw-r--r--  root root system_u:object_r:sysfs_t  /sys/kernel/uids/104/cpu_share


Reproducible: Always




The problem appears to be that when no other dnetc processes exist, the
/sys/kernel/uids/{UID} directory doesn't exist either.

Suggested quick fix:

45,46c45,47
<       [ -d /sys/kernel/uids/ ] && echo 2 > \
<               /sys/kernel/uids/$(grep -w dnetc /etc/passwd | cut -d:
-f3)/cpu_share
---
>       uidpath="/sys/kernel/uids/`id -u dnetc`"
>       [ -d $uidpath ] && echo 2 >$uidpath
>       unset uidpath

(Apropos, the proposed fix also fixeds another bug:  grepping /etc/passwd is
wrong, because the actual user ID might be obtained through NIS or LDAP no
matter what the passwd entry states.  "id" is in coreutils, so no extra
dependencies would be needed.)

------- Comment #1 From Arthur Hagen 2008-04-10 03:24:36 0000 -------
Err.  The correct patch is:

45,46c45,47
<       [ -d /sys/kernel/uids/ ] && echo 2 > \
<               /sys/kernel/uids/$(grep -w dnetc /etc/passwd | cut -d:
-f3)/cpu_share
---
>       uidpath="/sys/kernel/uids/`id -u dnetc`"
>       [ -d $uidpath ] && echo 2 >$uidpath/cpu_share
>       unset uidpath

------- Comment #2 From Chris Gianelloni (RETIRED) 2008-04-10 05:42:49 0000 -------
Oops... It looked good, anyway... hehe

I've fixed this in CVS now.  Thanks...