Re: [PATCH] reduce hostname length in order to follow procfs hostname implementation

2018-02-11 Thread Waldek Kozaczuk
I am a little bit reluctant to apply this patch. I do agree that we should 
be consistent (on other hand core/dhcp.cc uses 256 char long buffer - 
another place where it is different than 65). But I am afraid that some 
times especially in cloud environment what gets passed through cloud init 
may be full FQDN 
(https://en.wikipedia.org/wiki/Fully_qualified_domain_name) and OSv does 
not correctly differentiate between hostname and FQDN and 65 may not be 
enough. But maybe 65 is hard limit so we should be OK.

I also found something here 
- 
https://stackoverflow.com/questions/8724954/what-is-the-maximum-number-of-characters-for-a-host-name-in-unix.
  

On Friday, February 9, 2018 at 1:58:49 PM UTC-5, Geraldo Netto wrote:
>
> Signed-off-by: geraldo netto  
> --- 
>  modules/cloud-init/cloud-init.cc | 2 +- 
>  1 file changed, 1 insertion(+), 1 deletion(-) 
>
> diff --git a/modules/cloud-init/cloud-init.cc 
> b/modules/cloud-init/cloud-init.cc 
> index 5e05c82..ddb3a3a 100644 
> --- a/modules/cloud-init/cloud-init.cc 
> +++ b/modules/cloud-init/cloud-init.cc 
> @@ -24,7 +24,7 @@ extern "C" void dhcp_renew(bool wait); 
>  // If hostname changes, try to propagate the change to DHCP server too. 
>  void set_hostname_renew_dhcp(std::string hostname) { 
>  if (hostname.length() > 0) { 
> -char old_hostname[256] = ""; 
> +char old_hostname[65] = ""; 
>  gethostname(old_hostname, sizeof(old_hostname)); 
>  sethostname(hostname.c_str(), hostname.length()); 
>  if (hostname != old_hostname) { 
> -- 
> 2.7.4 
>
>

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[PATCH] reduce hostname length in order to follow procfs hostname implementation

2018-02-09 Thread geraldo netto
Signed-off-by: geraldo netto 
---
 modules/cloud-init/cloud-init.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/cloud-init/cloud-init.cc b/modules/cloud-init/cloud-init.cc
index 5e05c82..ddb3a3a 100644
--- a/modules/cloud-init/cloud-init.cc
+++ b/modules/cloud-init/cloud-init.cc
@@ -24,7 +24,7 @@ extern "C" void dhcp_renew(bool wait);
 // If hostname changes, try to propagate the change to DHCP server too.
 void set_hostname_renew_dhcp(std::string hostname) {
 if (hostname.length() > 0) {
-char old_hostname[256] = "";
+char old_hostname[65] = "";
 gethostname(old_hostname, sizeof(old_hostname));
 sethostname(hostname.c_str(), hostname.length());
 if (hostname != old_hostname) {
-- 
2.7.4

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.