Date: Mon, 26 Dec 2011 13:52:21 +0400 From: Eygene Ryabinkin <rea@freebsd.org> To: Doug Barton <dougb@FreeBSD.org> Cc: Pyun Yong-Hyeon <pyunyh@gmail.com>, d@delphij.net, Garrett Cooper <yanegomi@gmail.com>, Gleb Smirnoff <glebius@FreeBSD.org>, freebsd-rc@freebsd.org Subject: Re: Annoying ERROR: 'wlan0' is not a DHCP-enabled interface Message-ID: <LADID%2BnpQnFYUAFjVHNVYJzo%2BFg@g5jH1yj%2BTnAiSdLOy3xs5Jutvhc> In-Reply-To: <4EF83A59.8080008@FreeBSD.org> References: <n2Hlz4MXZMNcNzN56fSf6/or7Ig@YnbH/K3/Y1Z96RV2jTofcGuSPJI> <4EF6401E.3080902@FreeBSD.org> <20111224215649.GA12789@stack.nl> <4EF80CA7.3070303@FreeBSD.org> <ooDmUS7742YMCurT/5XDO19d%2BS4@g5jH1yj%2BTnAiSdLOy3xs5Jutvhc> <4EF82E3B.6040601@FreeBSD.org> <KjrN1twOoYYUBTKZXsHphbGonrU@g5jH1yj%2BTnAiSdLOy3xs5Jutvhc> <4EF833B7.9040704@FreeBSD.org> <0A59E5CD-3598-41B0-A707-6C5185E80043@gmail.com> <4EF83A59.8080008@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--+epxrXWOh++2HLjY Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Mon, Dec 26, 2011 at 01:11:53AM -0800, Doug Barton wrote: > On 12/26/2011 01:02, Garrett Cooper wrote: > > $ svn log -r 226879=20 > > ------------------------------------------------------------------------ > > > >=20 > r226879 | rea | 2011-10-27 23:03:38 -0700 (Thu, 27 Oct 2011) | 10 lines > >=20 > > Fix handling of rc_force in /etc/rc.d/dhclient > >=20 > > Variable 'rc_force' is accessible only at the time of > > rc_run_command, so it can't be examined from the script's main code. > >=20 > > Spotted by: hrs Reviewed by: hrs, des Approved by: des MFC after: 2 > > weeks=20 > > ------------------------------------------------------------------------ > > > > It simply didn't exist before this change; before it was just a > > 'return 1', which is illegal outside of functions, amongst other > > things. > > Ok, so I think here is some of the source of the confusion: Unlikely that the confusion will come from my side: I know how return acts (it terminates the current context and returns to the caller) and how exit acts -- it just terminates the current process. Why can I substitute 'return 1' for 'err 1' in this case is explained below. > "The syntax of the return command is >=20 > return [exitstatus] >=20 > It terminates the current executional scope, returning from the previous > nested function, sourced script, or shell instance, in that order. The > return command is implemented as a special built-in command." >=20 > It's actually used often'ish in rc.d where exit cannot be. The whole story is the following one. My original fix, http://svnweb.freebsd.org/base/head/etc/rc.d/dhclient?r1=3D226345&r2=3D226= 464 has 'return 1' from the top-level scope of dhclient script. At this scope it is just equal to 'exit 1', unless someone does ". /etc/rc.d/dhclie= nt" as /etc/rc used to do. But current version of run_rc_script does not source the scripts that aren't ended in .sh, but spawns the subprocess for each on= e. Moreover, script names ending in .sh are currently deprecated inside rc.sub= r. So, for this case 'return 1' =3D=3D 'exit 1': {{{ $ sh -x 1.sh || echo "failed" + trap 'echo Going away' 0 + return 1 + echo Going away Going away failed $ sh -x 2.sh || echo "failed" + trap 'echo Going away' 0 + exit 1 + echo Going away Going away failed }}} But r226464 wasn't good enough, because rc_force is set only when the rc.d command hooks are executed, thus it isn't set on the top-level context of rc.d scripts. So there goes r226879, http://svnweb.freebsd.org/base/head/etc/rc.d/dhclient?r1=3D226464&r2=3D22= 6879 that introduced dhclient_pre_check _and_ the "err" call we're arguing about. Here the historical retrospection ends. > > So I vote to just remove the message (convert the err 1 to a exit 1) >=20 > I haven't dug into it yet, but if it was a return previously it almost > certainly should not be an exit now. Doug, I may be blunt now, but how can one ever say something about the code that he hasn't digged into? I know about the common sense, but it alone can't be applied to the non-trivial problems with any hope for good results. > I'll dig into the original change more tomorrow, now that it's clear > what we're actually dealing with. Very good, thanks a lot! > Thanks to both of you for helping to make it clear. My pleasure ;)) --=20 Eygene Ryabinkin ,,,^..^,,, [ Life's unfair - but root password helps! | codelabs.ru ] [ 82FE 06BC D497 C0DE 49EC 4FF0 16AF 9EAE 8152 ECFB | freebsd.org ] --+epxrXWOh++2HLjY Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.18 (FreeBSD) iF4EAREIAAYFAk74Q9UACgkQFq+eroFS7PvOQAEAjd1oAqK8e6jyz8Ssx5UTWfbm aNX/O1Xat1a53UItDlwA/3htbnQdQ0CZ1LiFWWYOeE2f6j/r4tCFClVLHHRHn3LX =LgQc -----END PGP SIGNATURE----- --+epxrXWOh++2HLjY--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?LADID%2BnpQnFYUAFjVHNVYJzo%2BFg>