sysctl: replaces some slashes with dots
It turns out that plain sysctl understands a.b/c syntax to write to /proc/sys/a/b.c. Support this for compatibility. https://bugs.freedesktop.org/show_bug.cgi?id=77466
This commit is contained in:
+16
-2
@@ -48,12 +48,26 @@ static const char conf_file_dirs[] =
|
||||
#endif
|
||||
;
|
||||
|
||||
static char *normalize_sysctl(char *s) {
|
||||
static char* normalize_sysctl(char *s) {
|
||||
char *n;
|
||||
|
||||
for (n = s; *n; n++)
|
||||
n = strpbrk(s, "/.");
|
||||
/* If the first separator is a slash, the path is
|
||||
* assumed to be normalized and slashes remain slashes
|
||||
* and dots remains dots. */
|
||||
if (!n || *n == '/')
|
||||
return s;
|
||||
|
||||
/* Otherwise, dots become slashes and slashes become
|
||||
* dots. Fun. */
|
||||
while (n) {
|
||||
if (*n == '.')
|
||||
*n = '/';
|
||||
else
|
||||
*n = '.';
|
||||
|
||||
n = strpbrk(n + 1, "/.");
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user