summaryrefslogtreecommitdiff
path: root/sbin/dhclient/dhclient.c
AgeCommit message (Collapse)Author
2013-06-09Make route adding interface more flexible by passing flags to beKenneth R Westerback
used rather than deducing them. Use priv_add_route() to add the 127.0.0.1 address when adding an address.
2013-06-09Fix/clarify some comments. do memset()'s only when variable is goingKenneth R Westerback
to be used.
2013-06-09Re-apply static route and classless static route support -- this timeKenneth R Westerback
passing the correct destination for the default route, '0.0.0.0', rather than the new lease address. Populating egress group works this time. Problem found the hard way by Chris Smith.
2013-06-09Re-apply route adding code refactoring -- it wasn't the problem thatKenneth R Westerback
broke populating the egress group.
2013-06-09Backout static/classless route handling and default route refactoringKenneth R Westerback
since the former relies on the latter and the latter breaks 'egress' group populating.
2013-06-04Add support for static routes option (33) and classless staticKenneth R Westerback
routes option (121). ok sthen@
2013-06-01Refactor the default route adding code to use a general route addingKenneth R Westerback
function that will be reused for future work. ok claudio@
2013-05-05Add a flag to struct client_state (IS_RESPONSIBLE) to record whenKenneth R Westerback
the first expected RTM_NEWADDR arrives, which signals that a lease has been bound to the interface. Ignore RTM_NEWADDR and RTM_DELADDR messages until the flag has been set. Makes it more likely that the last dhclient started will be the last dhclient standing. Fixes the problem reported by David Higgs, where restarting an install in a vm consistantly caused the new dhclient to be the one that dies.
2013-05-02Bunch of comment/whitespace cleanup. Eliminate some misleading orKenneth R Westerback
pointless ones, make multiline comments readable, nuke '...' in favour of '.', etc.
2013-05-02Enough of the hand-rolling of queues. Turn client->leases andKenneth R Westerback
client->offered_leases into TAILQs.
2013-04-27Use same parse_date() and date writing logic as in dhcpd. i.e.Kenneth R Westerback
strptime() rather than handrolling parsing. Change date format in leases to same as dhcpd, fixing 'u' vs 'w' error made in initial strftime() introduction.
2013-04-25big int_t/time_t fixes; ok deraadt@ krw@Otto Moerbeek
2013-03-30Since deleting all the addresses on an interface removes all theKenneth R Westerback
relevant entries from the arp cache, don't bother asking for/processing arp entries in the route dumps. Thus allowing use of NET_RT_FLAGS with RTF_GATEWAY and AF_INET, to ask for only the routes dhclient wants to expunge rather than all routes in existance. Greatly shrinks and simplifies the code. No intentional functional change. Tested by sthen@.
2013-03-22Ignore client-identifier option in leases from a server. They're not supposedKenneth R Westerback
to be there! Instead, always record the client-identifier used to obtain the lease. Ignore recorded leases that have a different client-identifier than the one currently in force. If a client-identifier is not specified in the dhclient.conf file, construct one from the network type and MAC, like most other clients out there do these days. Thus, if one plugs in a different USB network adapter, renewing the previous lease (which upsets servers due to the MAC being different) is skipped and DISCOVER is attempted at once. Issue noted and fix tested by tedu@.
2013-02-27Avoid alignment errors when processing routing messages by readingKenneth R Westerback
the messages into dynamically allocated memory rather than a char array on the stack. Revealed by armish bus error when installing latest snap. ok deraadt@
2013-02-24When no acceptable offers are received within the allowed timeframe callKenneth R Westerback
state_panic() instead of state_init(). state_init() immediately issues a new DISCOVER message and neither checks dhclient.leases.IF nor daemonizes. state_panic() looks for a lease in dhclient.leases.IF, and if none are available, waits for 'retry' seconds before retarting the DISCOVER process. Most importantly it calls go_daemon() to take the process into the background, giving back the command prompt. Reported by otto@ and deraadt@. ok deraadt@.
2013-02-19Cancel any outstanding protocol timeout when a link goes away. WhenKenneth R Westerback
the link comes back we will start from scratch with DISCOVER. Stops pointless attempts to issue packets over a disconnected interface. Noticed by deraadt@
2013-02-18Rework log messages to be more useful. RenameKenneth R Westerback
IMGS_CLEANUP/imsg_cleanup/cleanup to IMSG_HUP/imsg_hup/sendhup to more accurately reflect intent of causing the privileged process to initiate restart. There should now be one and only one message logged at termination or restart, logged by the process initiating the termination or restart. As part of fixing this, remove duplicate cleanup attempts and exit after sending IMSG_HUP. These make logged messages more consistant and fix issues with incorrect cleanups. More prodding from deraadt@
2013-02-17Suppress some pointless debugging message:Kenneth R Westerback
1) If the pipe to the priv process is closed while waiting for something to happen in the non-priv dispatch() loop, assume the priv process issued an error message and exit without additional verbiage. 2) Ditto if the pipe to the priv process is closed when the flush of IMSG_CLEANUP is attempted. 3) No need to report when SIOCDIFADDR fails because the address is already gone. Start to ensure the priv process always issues a useful message before exiting by noting when it restarts due to the LLADDR having changed. Prodded by deraadt@ to clean this up.
2013-02-17Put the processes in the routing domain of the interface. TweakKenneth R Westerback
error message to show problematic table id and use clearer verbiage suggested by sthen@. Should fix (another!) problem reported by Andreas Bartelt, who noted that lease renewals did not work in a non-default routing domain. ok sthen@
2013-02-16Remove accidentally committed debug statement ("Got RTM_IFINFO").Kenneth R Westerback
2013-02-15Take more care to use the correct xid, rather than packet garbage.Kenneth R Westerback
ok beck@
2013-02-15Make code a tad less obscure by using sizeof() actual variable beingKenneth R Westerback
zeroed, rather than some other variable that may be the same type.
2013-02-15Even if no one uses it, record the seconds since we started in theKenneth R Westerback
correct field.
2013-02-15Unbreak DISCOVER by initializing xid from correct field.Kenneth R Westerback
2013-02-14When an interface generates an RTM_IFINFO message, it may be as theKenneth R Westerback
result of its LLADDR changing! Check said address and if it differs from what we think it is, simulate a SIGHUP to restart, getting the new address and a new lease for it. Spotted by, fix tested by, and ok beck@
2013-02-14Don't rely on the packet buffer (client->packet) being preserved betweenKenneth R Westerback
attempts to send DISCOVER or REQUEST packets. Some DHCP servers might NAK the DISCOVER, or other nefarious packets arrive, between attempts and overwrite the packet being sent. Create and use another buffer for packets being sent. Problem encountered by fgsch@, who noticed that once the DISCOVER was NAK'ed our dhclient sent a bunch of NAK's back to the server. Like it thought they were DISCOVER messages. ok beck@
2013-02-13Restore previous behaviour of not cleaning up in response to SIGTERM.Kenneth R Westerback
SIGTERM is used to make processes go away during system shutdown and NFS filesystems may be still be in use when it is received. So removing routes to the NFS servers is a bad thing. Problem discovered and fix tested by landry@.
2013-02-09As tedu@ pointed out a while ago, it makes little sense to discardKenneth R Westerback
an option list if it contains duplicate option names. Just ignore the duplicates.
2013-02-02Expunge unused variables and pointless construction of same inKenneth R Westerback
bind_lease().
2013-02-02Fix resolv.conf magic. Add identifying comment to generated resolv.confKenneth R Westerback
so it is easy to see which interface generated it.
2013-02-02Dereference correct pointer. Fix crash when checking whether resolv.confKenneth R Westerback
should be written. Bad cut 'n paste.
2013-02-01do not leak dn if there is no resolv.conf contents; found by llvmFlorian Obser
ok krw@
2013-02-01always initialize cur_time; found by llvmFlorian Obser
ok krw@
2013-02-01Increment size of buffer to accomodate terminating NUL *after* usingKenneth R Westerback
same variable to determine if cumulative lengths of strings to be put in buffer are > 0. Otherwise we always think here is something to put in buffer. Reported by florian@ and his friend llvm.
2013-02-01Handle a non-existant resolv.conf.tail without issuing an errorKenneth R Westerback
message. Handle an empty resolv.conf.tail without exiting. Don't leak an fd if fstat() on resolv.conf.tail fails. Make fstat() failure on successfully opened resolv.conf.tail a fatal error. From Tim van der Molen. Thanks!
2013-02-01Write out resolv.conf only if the default route is under the controlKenneth R Westerback
of the process binding the lease. Re-check the default route whenever a routing message arrives that might mean the default route has changed, and write out resolv.conf if appropriate. Reduces the chances that the name servers in resolv.conf are unreachable. Problem most eloquently explained, and solution suggested by beck@.
2013-01-27Refactor code a bit. Calculate resolv.conf contents once when binding aKenneth R Westerback
lease and reuse as required whenever resolv.conf is written. Use write_file() rather than a custom message/functions to write out resolv.conf.
2013-01-26Oops. Restore "no domain-name, no domain-name-seervers means don'tKenneth R Westerback
touch resolv.conf" behaviour.
2013-01-26Read /etc/resolv.conf.tail once on startup and save contents forKenneth R Westerback
application during subsequent resolv.conf building.
2013-01-22Whitespace nit. Better error messages.Kenneth R Westerback
2013-01-18-L before -l;Jason McIntyre
2013-01-18Add command line option '-L' that specifies an optional file into whichKenneth R Westerback
the most recent offer and effective leases will be written. Intended to allow access to dhcp option information that was formerly passed to dhclient-script.
2013-01-17Try harder to clear out default routes on the interface beingKenneth R Westerback
configured. Only exempt default routes labelled as being the property of another dhclient.
2013-01-16Unrevert last reversion. otto@ pointed out that it wasn't asprintf()Kenneth R Westerback
causing a problem, it was accessing uninitialized pointers.
2013-01-16Revert last. asprintf() breaks something.Kenneth R Westerback
2013-01-16Use the magic of asprintf() to produce more informative errorKenneth R Westerback
and log messages.
2013-01-16Don't tell the priviledged process to discard active_addr if there isKenneth R Westerback
a pending address addition. Should fix "routehandler: interface address added" messages and premature exiting of dhclient seen by henniing@ amoung others.
2013-01-15Add IMSG_WRITE_FILE and associated bits to allow the unprivilegedKenneth R Westerback
process to ask that a file be written by the privileged process. Not yet used.
2013-01-14First convert packet to lease, which validates option data andKenneth R Westerback
discards bad options. THEN check to see if any required options are missing and reject both OFFER and ACK packets that lack required options. Since it is the latter's lease we actual bind. Move required option check into packet_to_lease() instead of duplicating it.