Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 496870 - net-misc/dhcpcd: dhcpcd-run-hooks needs to be more dynamic
Summary: net-misc/dhcpcd: dhcpcd-run-hooks needs to be more dynamic
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: William Hubbs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-03 11:38 UTC by emil karlson
Modified: 2014-01-09 18:50 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Move init detection to dhcpcd-run-hooks (dhcpcd-init.diff,6.00 KB, patch)
2014-01-07 09:28 UTC, Roy Marples
Details | Diff
incremental diff for run-hooks (more.diff,934 bytes, patch)
2014-01-07 12:10 UTC, emil karlson
Details | Diff
Move init detection to dhcpcd-run-hooks (dhcpcd-init.diff,6.27 KB, patch)
2014-01-07 16:05 UTC, Roy Marples
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description emil karlson 2014-01-03 11:38:57 UTC
net-misc/dhcpcd-5.6.4 ntp hook tries to restart ntpd using openrc initscript under systemd

see /lib/dhcpcd/dhcpcd-hooks/50-ntp.conf

Jan 03 12:06:20 schur /etc/init.d/ntpd[1707]: You are attempting to run an openrc service on a
Jan 03 12:06:20 schur /etc/init.d/ntpd[1708]: system which openrc did not boot.
Jan 03 12:06:20 schur /etc/init.d/ntpd[1709]: You may be inside a chroot or you may have used
Jan 03 12:06:20 schur /etc/init.d/ntpd[1710]: another initialization system to boot this system.
Jan 03 12:06:20 schur /etc/init.d/ntpd[1711]: In this situation, you will get unpredictable results!
Jan 03 12:06:20 schur /etc/init.d/ntpd[1713]: If you really want to do this, issue the following command:
Jan 03 12:06:20 schur /etc/init.d/ntpd[1714]: touch /run/openrc/softlevel


Reproducible: Always

Steps to Reproduce:
1. install net-misc/ntp and run gentoo system under systemd using wicd to manage networks
2. check journalctl -b for errors



Portage 2.2.7 (default/linux/amd64/13.0/desktop/gnome/systemd, gcc-4.7.3, glibc-2.16.0, 3.12.6 x86_64)
=================================================================
System uname: Linux-3.12.6-x86_64-AMD_Phenom-tm-_II_X6_1090T_Processor-with-gentoo-2.2
KiB Mem:    16279632 total,  10044516 free
KiB Swap:   12069588 total,  12069588 free
Timestamp of tree: Fri, 03 Jan 2014 00:45:01 +0000
ld GNU ld (GNU Binutils) 2.23.2
app-shells/bash:          4.2_p45
dev-java/java-config:     2.1.12-r1
dev-lang/python:          2.7.5-r3, 3.2.5-r3, 3.3.2-r2
dev-util/cmake:           2.8.11.2
dev-util/pkgconfig:       0.28
sys-apps/baselayout:      2.2
sys-apps/openrc:          0.12.4
sys-apps/sandbox:         2.6-r1
sys-devel/autoconf:       2.13, 2.69
sys-devel/automake:       1.10.3, 1.11.6, 1.12.6, 1.13.4
sys-devel/binutils:       2.23.2
sys-devel/gcc:            4.7.3-r1
sys-devel/gcc-config:     1.7.3
sys-devel/libtool:        2.4.2
sys-devel/make:           3.82-r4
sys-kernel/linux-headers: 3.9 (virtual/os-headers)
sys-libs/glibc:           2.16.0
Repositories: gentoo gentoo-haskell x11 ke-shared
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA skype-eula"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe -march=native -g -gdwarf-4"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-O2 -pipe -march=native -g -gdwarf-4"
DISTDIR="/usr/local/distfiles/"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs compressdebug config-protect-if-modified distlocks ebuild-locks fail-clean fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms splitdebug strict unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="ftp://schur.dy.fi/                 http://trumpetti.atm.tut.fi/gentoo/ 		http://ftp.df.lth.se/pub/gentoo/"
LC_ALL="en_US.utf8"
LDFLAGS="-Wl,--as-needed -Wl,-O1"
MAKEOPTS="-j2"
PKGDIR="/usr/local/packages/"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/usr/local/tmp/"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/var/lib/layman/haskell /var/lib/layman/x11 /etc/shared/lib/portage/overlay"
SYNC="rsync://trumpetti.atm.tut.fi/gentoo-portage/"
USE="256-color X a52 aac accessibility acl acpi alisp alltargets alsa amd64 amr ansi apng bash-completion berkdb bluetooth branding btrfs bzip2 cairo caps cdda cdr cli clisp colord cracklib crypt cryptsetup cscope css cups curl cxx dbus dconf declarative dirac dri dts dvd dvdr eds emboss enca encode evo exif extra extras fam ffmpeg fftw firefox flac fontconfig fortran fortran95 ftp g3dvl gallium games gbm gcj gd gdbm gdu gif git glamor glib gmp gnome gnome-keyring gnome-online-accounts gnuplot go gold gpm graphics graphite gstreamer gtk gtk3 gudev hoogle hwdb iconv icu idn image imagemagick imlib inotify introspection iproute2 ipv6 jadetex java javascript jpeg jpeg2k kipi kmod kpathsea lapack laptop latex latex3 lcms ldap libkms libnotify libsecret llvm lto lxde lzma lzo mad math matroska md5sum midi minizip mmap mmx mng mod modplug mono mouse mp3 mp4 mpeg mpi mpi_njtree mplayer mudflap multilib multitarget musepack music nautilus ncurses net netpbm network networkmanager nls npp nptl nsplugin ntp ogg openexr opengl openmp opus pam pango pcre pdf perl plotutils png pnm policykit postscript ppds ps pstricks publishers pulseaudio python python3 qt3support qt4 readline reports romio rtmp rtsp samba schroedinger science sdl sdl-image secure-delete semantic-desktop server session smbclient smp sna socialweb sparse speex spell sqlite sse sse2 sse3 ssl ssse3 startup-notification static-libs stream subtitles subversion supernodal svg system-libs system-sqlite systemd systemtap tcpd tex4ht theora threads threadsafe tiff timidity tk toolbar trace truetype udev udis86 udisks unicode unlock-notify upower usb uxa vaapi vala vdpau vim vim-syntax vorbis wav wavpack weather webkit webkit2 wma x264 xattr xcb xcomposite xinerama xml xmp xosd xpm xrandr xv xvid zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CURL_SSL="nss" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="evdev synaptics wacom" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en fi en_GB" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_3" RUBY_TARGETS="ruby18 ruby19 ruby20" USERLAND="GNU" VIDEO_CARDS="vesa intel radeon fbdev" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON
Comment 1 William Hubbs gentoo-dev 2014-01-05 20:25:03 UTC
In dhcpcd-run-hooks, I see that the service_exists, service_cmd and
service_status functions are templates that are filled out at build
time.

This doesn't work reliably, however, if the init system is changed or if
several init systems are installed.
It would be better if these functions were dynamic and able to work
out which init system was used to boot the system at runtime.

Thanks,

William
Comment 2 emil karlson 2014-01-05 21:57:48 UTC
Might be nice, as I don't think you can remove openrc/sysvinit on gentoo under typical conditions.
Comment 3 William Hubbs gentoo-dev 2014-01-06 03:46:21 UTC
(In reply to emil karlson from comment #2)
> Might be nice, as I don't think you can remove openrc/sysvinit on gentoo
> under typical conditions.

Correct, you can't right now, but that is being worked on.

Even if you can though, it the issue is that multiple init systems can be installed, so it is better to check for the one that is actually running.
Comment 4 Roy Marples 2014-01-07 09:28:21 UTC
Created attachment 367274 [details, diff]
Move init detection to dhcpcd-run-hooks

Please try this patch twice, once running OpenRC and once running systemd.
Hopefully it works!
Comment 5 Roy Marples 2014-01-07 09:29:53 UTC
I don't have any OS's that run systemd, so the patch is cut entirely from what online documentation I could find.
Comment 6 emil karlson 2014-01-07 12:10:25 UTC
Created attachment 367282 [details, diff]
incremental diff for run-hooks

1) systemctl path is not constant
2) append .service

see attachment

jkarlson@schur: ~
$ . run-hooks.sh 
jkarlson@schur: ~
$ detect_init 
jkarlson@schur: ~
$ echo $_service_exists; echo $_service_cmd; echo $_service_status
/usr/bin/systemctl --quiet is-enabled $1.service
/usr/bin/systemctl $2 $1.service
/usr/bin/systemctl --quiet is-active $1.service

schur dhcpcd # /usr/bin/systemctl --quiet is-enabled ntpd.service && echo aa
aa
schur dhcpcd # /usr/bin/systemctl restart ntpd.service
schur dhcpcd # /usr/bin/systemctl --quiet is-active ntpd.service && echo aa
aa

thanks

I didn't test in vivo until I get the approved form
Comment 7 Roy Marples 2014-01-07 16:05:00 UTC
Created attachment 367298 [details, diff]
Move init detection to dhcpcd-run-hooks

New patch.

I dislike using which or something like this in $PATH so I detect systemctl in /bin and /usr/bin.

Please re-test!
Comment 8 emil karlson 2014-01-07 16:39:05 UTC
seems to be ok on systemd-208-r2 on gentoo

Jan 07 18:36:17 schur dhcpcd[4376]: version 6.2.0 starting
Jan 07 18:36:17 schur dhcpcd[4376]: DUID 00:01:00:01:1a:5e:e8:ea:6c:f0:49:58:8f:75
Jan 07 18:36:17 schur dhcpcd[4376]: eth0: IAID 49:58:8f:75
Jan 07 18:36:17 schur dhcpcd[4376]: eth0: soliciting an IPv6 router
Jan 07 18:36:17 schur dhcpcd[4376]: eth0: ipv6nd_sendrsprobe: sendmsg: Cannot assign requested address
Jan 07 18:36:17 schur dhcpcd[4376]: eth0: soliciting a DHCP lease
Jan 07 18:36:20 schur ntpd[4230]: Deleting interface #3 eth0, 10.0.0.30#123, interface stats: received=0, sent=0, dropped=0, active_time=6 secs
Jan 07 18:36:20 schur ntpd[4230]: peers refreshed
Jan 07 18:36:23 schur dhcpcd[4376]: eth0: offered 80.220.74.212 from 80.220.64.1
Jan 07 18:36:23 schur dhcpcd[4376]: eth0: ignoring offer of 88.192.214.173 from 80.220.64.1
Jan 07 18:36:28 schur dhcpcd[4376]: eth0: leased 80.220.74.212 for 1800 seconds
Jan 07 18:36:28 schur dhcpcd[4376]: eth0: adding route to 80.220.64.0/19
Jan 07 18:36:28 schur dhcpcd[4376]: eth0: adding default route via 80.220.64.1
Jan 07 18:36:28 schur systemd[1]: Stopping Network Time Service...
Jan 07 18:36:28 schur ntpd[4230]: ntpd exiting on signal 15
Jan 07 18:36:28 schur systemd[1]: Starting Network Time Service...
Jan 07 18:36:28 schur systemd[1]: Started Network Time Service.
Jan 07 18:36:28 schur ntpd[4871]: ntpd 4.2.6p5@1.2349-o Sat Jan  4 11:47:31 UTC 2014 (1)
Jan 07 18:36:28 schur ntpd[4871]: proto: precision = 0.102 usec
Jan 07 18:36:28 schur ntpd[4871]: Listen and drop on 0 v4wildcard 0.0.0.0 UDP 123
Jan 07 18:36:28 schur dhcpcd[4376]: forked to background, child pid 4875
Jan 07 18:36:28 schur ntpd[4871]: Listen and drop on 1 v6wildcard :: UDP 123
Jan 07 18:36:28 schur ntpd[4871]: Listen normally on 2 lo 127.0.0.1 UDP 123
Jan 07 18:36:28 schur ntpd[4871]: Listen normally on 3 eth0 80.220.74.212 UDP 123
Jan 07 18:36:28 schur ntpd[4871]: Listen normally on 4 lo ::1 UDP 123
Jan 07 18:36:28 schur ntpd[4871]: Listen normally on 5 eth0 fe80::6ef0:49ff:fe58:8f75 UDP 123
Jan 07 18:36:28 schur ntpd[4871]: peers refreshed
Jan 07 18:36:28 schur ntpd[4871]: Listening on routing socket on fd #22 for interface updates
Comment 9 Roy Marples 2014-01-07 16:46:28 UTC
Great!
Can you also test booting OpenRC instead of Systemd please?
Hopefully dhcpcd should still reset ntp as shown.
Comment 10 emil karlson 2014-01-07 18:09:53 UTC
(In reply to Roy Marples from comment #9)
> Great!
> Can you also test booting OpenRC instead of Systemd please?
> Hopefully dhcpcd should still reset ntp as shown.

My openrc is most likely defunc as I am heavily using eg. systemd mount units instead of fstab.
Comment 11 Roy Marples 2014-01-08 11:12:51 UTC
It seems that my 1y old Gentoo installation cannot be upgraded so I can't really test it. Hopefully a Gentoo developer here can.
Comment 12 Roy Marples 2014-01-08 13:24:47 UTC
I was able to test the final cut of OpenRC I made, but not the current Gentoo flavour.

Committed here:
http://roy.marples.name/projects/dhcpcd/ci/f4b22ef0c4
Comment 13 William Hubbs gentoo-dev 2014-01-09 18:50:00 UTC
This is fixed in dhcpcd-6.2.0-r1, thanks for the report.