Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 172452 Details for
Bug 235330
NetworkManager 0.7 version bump
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Defaults hostname to /etc/conf.d/hostname content
fix_system_hostname.patch (text/plain), 2.38 KB, created by
Marco Gulino
on 2008-11-20 11:24:11 UTC
(
hide
)
Description:
Defaults hostname to /etc/conf.d/hostname content
Filename:
MIME Type:
Creator:
Marco Gulino
Created:
2008-11-20 11:24:11 UTC
Size:
2.38 KB
patch
obsolete
>diff -ru NetworkManager-0.7.0.orig/src/NetworkManagerPolicy.c NetworkManager-0.7.0/src/NetworkManagerPolicy.c >--- NetworkManager-0.7.0.orig/src/NetworkManagerPolicy.c 2008-11-12 22:29:43.000000000 +0100 >+++ NetworkManager-0.7.0/src/NetworkManagerPolicy.c 2008-11-19 21:14:52.049100794 +0100 >@@ -24,6 +24,7 @@ > #include <errno.h> > #include <netdb.h> > #include <ctype.h> >+#include <regex.h> > > #include "NetworkManagerPolicy.h" > #include "NetworkManagerUtils.h" >@@ -332,6 +333,21 @@ > g_string_free (new_contents, TRUE); > return success; > } >+static char *findHostNameMatch(const char *inputString) { >+ if(!inputString) return NULL; >+ char pattern[50]="HOSTNAME[ ]*=[ \"]*([a-zA-z0-9]+)[\"]*"; >+ regmatch_t pmatch[2]; >+ int start=0, end=0; >+ regex_t predicate; >+ if(regcomp(&predicate, pattern, REG_EXTENDED) || >+ regexec(&predicate, inputString, 2, pmatch, 0) || >+ pmatch[1].rm_so < 0 || pmatch[1].rm_eo < 0 ) >+ return NULL; >+ start=pmatch[1].rm_so; >+ end=pmatch[1].rm_eo; >+ if(start>=end || end > strlen(inputString) ) return NULL; >+ return strndup(&inputString[start], end-start); >+} > > static void > set_system_hostname (const char *new_hostname, const char *msg) >@@ -339,6 +355,24 @@ > char old_hostname[HOST_NAME_MAX + 1]; > int ret = 0; > const char *name = new_hostname ? new_hostname : FALLBACK_HOSTNAME; >+ if (!new_hostname) { >+ static char* sysconf_hostname = NULL; >+ char *contents = NULL; >+ gsize contents_len; >+ GError *error = NULL; >+ if (!sysconf_hostname && !g_file_get_contents (SYSCONFDIR "/conf.d/hostname", &contents, &contents_len, &error)) { >+ nm_warning ("%s: couldn't read " SYSCONFDIR "/conf.d/hostname: (%d) %s", >+ __func__, error ? error->code : 0, >+ (error && error->message) ? error->message : "(unknown)"); >+ } else if (!sysconf_hostname) { >+ sysconf_hostname = g_strstrip(contents); >+ sysconf_hostname = strstr(sysconf_hostname, "HOSTNAME"); >+ sysconf_hostname = findHostNameMatch(sysconf_hostname); >+ } >+ if(sysconf_hostname) >+ name = sysconf_hostname; >+ } >+ > > old_hostname[HOST_NAME_MAX] = '\0'; > errno = 0;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 235330
:
167334
|
167336
|
167337
|
168000
|
170069
|
170071
| 172452 |
173256
|
173505
|
173993
|
174080