X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Futils%2Flustre_cfg.c;h=f034eaca96b57e909e0e7d35eb93fd9ee2e815bf;hp=211328661caf72311032265d39c48e3fb9571a12;hb=51ed079112c9a9eeac37eaf680637a4d04dd3cc9;hpb=78b38388cc3aa8f2f9ed367bc812165f24cbdb6a diff --git a/lustre/utils/lustre_cfg.c b/lustre/utils/lustre_cfg.c index 2113286..f034eac 100644 --- a/lustre/utils/lustre_cfg.c +++ b/lustre/utils/lustre_cfg.c @@ -659,6 +659,30 @@ static void clean_path(char *path) } } +/* Supporting file paths creates perilous behavoir: LU-888. + * Path support is deprecated. + * If a path is supplied it must begin with /proc. */ +static void lprocfs_param_pattern(const char *cmd, const char *path, char *buf, + size_t buf_size) +{ + /* test path to see if it begins with '/proc/' */ + if (strncmp(path, "/proc/", strlen("/proc/")) == 0) { + static int warned; + if (!warned) { + fprintf(stderr, "%s: specifying parameters via " + "full paths is deprecated.\n", cmd); +#if LUSTRE_VERSION_CODE >= OBD_OCD_VERSION(2,6,50,0) +#warning "remove deprecated full path tunable access" +#endif + warned = 1; + } + snprintf(buf, buf_size, "%s", path); + } else { + snprintf(buf, buf_size, "/proc/{fs,sys}/{lnet,lustre}/%s", + path); + } +} + struct param_opts { int only_path:1; int show_path:1; @@ -735,7 +759,6 @@ static int listparam_display(struct param_opts *popt, char *pattern) int jt_lcfg_listparam(int argc, char **argv) { - int fp; int rc = 0, i; struct param_opts popt; char pattern[PATH_MAX]; @@ -754,15 +777,7 @@ int jt_lcfg_listparam(int argc, char **argv) clean_path(path); - /* If the entire path is specified as input */ - fp = open(path, O_RDONLY); - if (fp < 0) { - snprintf(pattern, PATH_MAX, "/proc/{fs,sys}/{lnet,lustre}/%s", - path); - } else { - strcpy(pattern, path); - close(fp); - } + lprocfs_param_pattern(argv[0], path, pattern, sizeof(pattern)); rc = listparam_display(&popt, pattern); if (rc < 0) @@ -876,7 +891,6 @@ static int getparam_display(struct param_opts *popt, char *pattern) int jt_lcfg_getparam(int argc, char **argv) { - int fp; int rc = 0, i; struct param_opts popt; char pattern[PATH_MAX]; @@ -891,15 +905,7 @@ int jt_lcfg_getparam(int argc, char **argv) clean_path(path); - /* If the entire path is specified as input */ - fp = open(path, O_RDONLY); - if (fp < 0) { - snprintf(pattern, PATH_MAX, "/proc/{fs,sys}/{lnet,lustre}/%s", - path); - } else { - strcpy(pattern, path); - close(fp); - } + lprocfs_param_pattern(argv[0], path, pattern, sizeof(pattern)); if (popt.only_path) rc = listparam_display(&popt, pattern); @@ -979,7 +985,6 @@ static int setparam_display(struct param_opts *popt, char *pattern, char *value) int jt_lcfg_setparam(int argc, char **argv) { - int fp; int rc = 0, i; struct param_opts popt; char pattern[PATH_MAX]; @@ -1007,15 +1012,7 @@ int jt_lcfg_setparam(int argc, char **argv) clean_path(path); - /* If the entire path is specified as input */ - fp = open(path, O_RDONLY); - if (fp < 0) { - snprintf(pattern, PATH_MAX, "/proc/{fs,sys}/{lnet,lustre}/%s", - path); - } else { - strcpy(pattern, path); - close(fp); - } + lprocfs_param_pattern(argv[0], path, pattern, sizeof(pattern)); rc = setparam_display(&popt, pattern, value); path = NULL; @@ -1026,3 +1023,4 @@ int jt_lcfg_setparam(int argc, char **argv) return 0; } +