From: "Michael A. Kangin" <mak@complife.ru> To: ALT Linux Team development discussions <devel@lists.altlinux.org> Subject: [devel] set hostname in propagator Date: Fri, 24 Aug 2012 03:17:57 +0400 Message-ID: <5036BA25.8090209@complife.ru> (raw) [-- Attachment #1: Type: text/plain, Size: 546 bytes --] Здравствуйте. Озаботился тут установкой hostname, полученного по dhcp, в пропагаторе. Накатал патчик (см. аттач), вроде с виду все хорошо, пишет в логах: got hostname term-pg01 set hostname term-pg01 Однако, в итогово-загруженной системе hostname оказывается просто term. Из-за чего такое может быть, как бы пофиксить? -- wbr, Michael A. Kangin [-- Attachment #2: sethostname.patch --] [-- Type: text/x-patch, Size: 1935 bytes --] commit cee3c82eb493b5722dab8df94ed43c89507f2412 Author: Michael A. Kangin <prividen@altlinux.org> Date: Fri Aug 24 01:15:41 2012 +0400 fix hostnames diff --git a/dhcp.c b/dhcp.c index f903340..874f571 100644 --- a/dhcp.c +++ b/dhcp.c @@ -208,6 +208,7 @@ static void parse_reply(struct bootp_request * breq, struct interface_info * int { unsigned char * chptr; unsigned char option, length; + int retcode; memcpy(&intf->ip, &breq->yiaddr, 4); memcpy(&next_server, &breq->server_ip, 4); @@ -243,6 +244,12 @@ static void parse_reply(struct bootp_request * breq, struct interface_info * int tmp_str[length] = '\0'; domain = strdup(tmp_str); log_message("got domain %s", domain); + retcode = setdomainname(domain, sizeof(domain)); + if (retcode == 0) + log_message("set domain %s", domain); + else + log_message("could not set domain %s with ret %d", domain, retcode); + break; case BOOTP_OPTION_BROADCAST: @@ -260,6 +267,12 @@ static void parse_reply(struct bootp_request * breq, struct interface_info * int tmp_str[length] = '\0'; hostname = strdup(tmp_str); log_message("got hostname %s", hostname); + retcode = sethostname(hostname, sizeof(hostname)); + if (retcode == 0) + log_message("set hostname %s", hostname); + else + log_message("could not set hostname %s with ret %d", hostname, retcode); + break; case BOOTP_OPTION_ROOTPATH: @@ -591,6 +604,7 @@ enum return_type perform_dhcp(struct interface_info * intf) requested_options[num_options++] = BOOTP_OPTION_GATEWAY; requested_options[num_options++] = BOOTP_OPTION_DNS; requested_options[num_options++] = BOOTP_OPTION_DOMAIN; + requested_options[num_options++] = BOOTP_OPTION_HOSTNAME; requested_options[num_options++] = BOOTP_OPTION_ROOTPATH; requested_options[num_options++] = BOOTP_OPTION_BROADCAST; add_vendor_code(&breq, DHCP_OPTION_OPTIONREQ, num_options, requested_options);
next reply other threads:[~2012-08-23 23:17 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-08-23 23:17 Michael A. Kangin [this message] 2012-08-25 12:23 ` Michael A. Kangin 2012-08-28 13:21 ` Anton V. Boyarshinov 2012-08-28 18:27 ` Michael A. Kangin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=5036BA25.8090209@complife.ru \ --to=mak@complife.ru \ --cc=devel@lists.altlinux.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
ALT Linux Team development discussions This inbox may be cloned and mirrored by anyone: git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \ devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru public-inbox-index devel Example config snippet for mirrors. Newsgroup available over NNTP: nntp://lore.altlinux.org/org.altlinux.lists.devel AGPL code for this site: git clone https://public-inbox.org/public-inbox.git