mirror of git://git.sv.gnu.org/nano.git
tweaks: transform the token DISABLE_OPERATINGDIR to ENABLE_OPERATINGDIR
This commit is contained in:
parent
a5974bd1ec
commit
028d12f4fb
12
configure.ac
12
configure.ac
|
@ -198,8 +198,13 @@ fi
|
||||||
|
|
||||||
AC_ARG_ENABLE(operatingdir,
|
AC_ARG_ENABLE(operatingdir,
|
||||||
AS_HELP_STRING([--disable-operatingdir], [Disable the setting of an operating directory]))
|
AS_HELP_STRING([--disable-operatingdir], [Disable the setting of an operating directory]))
|
||||||
if test "x$enable_operatingdir" = xno; then
|
if test "x$enable_tiny" = xyes; then
|
||||||
AC_DEFINE(DISABLE_OPERATINGDIR, 1, [Define this to disable the setting of an operating directory (a chroot of sorts).])
|
if test "x$enable_operatingdir" != xyes; then
|
||||||
|
enable_operatingdir=no
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if test "x$enable_operatingdir" != xno; then
|
||||||
|
AC_DEFINE(ENABLE_OPERATINGDIR, 1, [Define this to allow setting an operating directory (a chroot of sorts).])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AC_ARG_ENABLE(speller,
|
AC_ARG_ENABLE(speller,
|
||||||
|
@ -278,9 +283,6 @@ if test "x$enable_tiny" = xyes; then
|
||||||
if test "x$enable_libmagic" != xyes; then
|
if test "x$enable_libmagic" != xyes; then
|
||||||
enable_libmagic=no
|
enable_libmagic=no
|
||||||
fi
|
fi
|
||||||
if test "x$enable_operatingdir" != xyes; then
|
|
||||||
AC_DEFINE(DISABLE_OPERATINGDIR, 1, [Define this to disable the setting of an operating directory (a chroot of sorts).])
|
|
||||||
fi
|
|
||||||
if test "x$enable_speller" != xyes; then
|
if test "x$enable_speller" != xyes; then
|
||||||
AC_DEFINE(DISABLE_SPELLER, 1, [Define this to disable the spell-checker functions.])
|
AC_DEFINE(DISABLE_SPELLER, 1, [Define this to disable the spell-checker functions.])
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -243,7 +243,7 @@ char *do_browser(char *path)
|
||||||
sprintf(path, "%s%s", present_path, answer);
|
sprintf(path, "%s%s", present_path, answer);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef DISABLE_OPERATINGDIR
|
#ifdef ENABLE_OPERATINGDIR
|
||||||
if (outside_of_confinement(path, FALSE)) {
|
if (outside_of_confinement(path, FALSE)) {
|
||||||
/* TRANSLATORS: This refers to the confining effect of the
|
/* TRANSLATORS: This refers to the confining effect of the
|
||||||
* option --operatingdir, not of --restricted. */
|
* option --operatingdir, not of --restricted. */
|
||||||
|
@ -273,7 +273,7 @@ char *do_browser(char *path)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef DISABLE_OPERATINGDIR
|
#ifdef ENABLE_OPERATINGDIR
|
||||||
/* Note: The selected file can be outside the operating
|
/* Note: The selected file can be outside the operating
|
||||||
* directory if it's ".." or if it's a symlink to a
|
* directory if it's ".." or if it's a symlink to a
|
||||||
* directory outside the operating directory. */
|
* directory outside the operating directory. */
|
||||||
|
@ -372,7 +372,7 @@ char *do_browse_from(const char *inpath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef DISABLE_OPERATINGDIR
|
#ifdef ENABLE_OPERATINGDIR
|
||||||
/* If the resulting path isn't in the operating directory, use
|
/* If the resulting path isn't in the operating directory, use
|
||||||
* the operating directory instead. */
|
* the operating directory instead. */
|
||||||
if (outside_of_confinement(path, FALSE))
|
if (outside_of_confinement(path, FALSE))
|
||||||
|
|
12
src/files.c
12
src/files.c
|
@ -422,7 +422,7 @@ bool open_buffer(const char *filename, bool undoable)
|
||||||
/* Display newlines in filenames as ^J. */
|
/* Display newlines in filenames as ^J. */
|
||||||
as_an_at = FALSE;
|
as_an_at = FALSE;
|
||||||
|
|
||||||
#ifndef DISABLE_OPERATINGDIR
|
#ifdef ENABLE_OPERATINGDIR
|
||||||
if (outside_of_confinement(filename, FALSE)) {
|
if (outside_of_confinement(filename, FALSE)) {
|
||||||
statusline(ALERT, _("Can't read file from outside of %s"),
|
statusline(ALERT, _("Can't read file from outside of %s"),
|
||||||
operating_dir);
|
operating_dir);
|
||||||
|
@ -1069,7 +1069,7 @@ void do_insertfile(void)
|
||||||
execute ? &execute_history :
|
execute ? &execute_history :
|
||||||
#endif
|
#endif
|
||||||
NULL, edit_refresh, msg,
|
NULL, edit_refresh, msg,
|
||||||
#ifndef DISABLE_OPERATINGDIR
|
#ifdef ENABLE_OPERATINGDIR
|
||||||
operating_dir != NULL ? operating_dir :
|
operating_dir != NULL ? operating_dir :
|
||||||
#endif
|
#endif
|
||||||
"./");
|
"./");
|
||||||
|
@ -1401,7 +1401,7 @@ char *safe_tempfile(FILE **f)
|
||||||
return full_tempdir;
|
return full_tempdir;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef DISABLE_OPERATINGDIR
|
#ifdef ENABLE_OPERATINGDIR
|
||||||
/* Change to the specified operating directory, when it's valid. */
|
/* Change to the specified operating directory, when it's valid. */
|
||||||
void init_operating_dir(void)
|
void init_operating_dir(void)
|
||||||
{
|
{
|
||||||
|
@ -1564,7 +1564,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
|
||||||
|
|
||||||
realname = real_dir_from_tilde(name);
|
realname = real_dir_from_tilde(name);
|
||||||
|
|
||||||
#ifndef DISABLE_OPERATINGDIR
|
#ifdef ENABLE_OPERATINGDIR
|
||||||
/* If we're writing a temporary file, we're probably going outside
|
/* If we're writing a temporary file, we're probably going outside
|
||||||
* the operating directory, so skip the operating directory test. */
|
* the operating directory, so skip the operating directory test. */
|
||||||
if (!tmp && outside_of_confinement(realname, FALSE)) {
|
if (!tmp && outside_of_confinement(realname, FALSE)) {
|
||||||
|
@ -2418,7 +2418,7 @@ char **username_tab_completion(const char *buf, size_t *num_matches,
|
||||||
/* Cool, found a match. Add it to the list. This makes a
|
/* Cool, found a match. Add it to the list. This makes a
|
||||||
* lot more sense to me (Chris) this way... */
|
* lot more sense to me (Chris) this way... */
|
||||||
|
|
||||||
#ifndef DISABLE_OPERATINGDIR
|
#ifdef ENABLE_OPERATINGDIR
|
||||||
/* ...unless the match exists outside the operating
|
/* ...unless the match exists outside the operating
|
||||||
* directory, in which case just go to the next match. */
|
* directory, in which case just go to the next match. */
|
||||||
if (outside_of_confinement(userdata->pw_dir, TRUE))
|
if (outside_of_confinement(userdata->pw_dir, TRUE))
|
||||||
|
@ -2501,7 +2501,7 @@ char **cwd_tab_completion(const char *buf, bool allow_files, size_t
|
||||||
char *tmp = charalloc(strlen(dirname) + strlen(nextdir->d_name) + 1);
|
char *tmp = charalloc(strlen(dirname) + strlen(nextdir->d_name) + 1);
|
||||||
sprintf(tmp, "%s%s", dirname, nextdir->d_name);
|
sprintf(tmp, "%s%s", dirname, nextdir->d_name);
|
||||||
|
|
||||||
#ifndef DISABLE_OPERATINGDIR
|
#ifdef ENABLE_OPERATINGDIR
|
||||||
/* ...unless the match exists outside the operating
|
/* ...unless the match exists outside the operating
|
||||||
* directory, in which case just go to the next match. */
|
* directory, in which case just go to the next match. */
|
||||||
skip_match = outside_of_confinement(tmp, TRUE);
|
skip_match = outside_of_confinement(tmp, TRUE);
|
||||||
|
|
|
@ -169,7 +169,7 @@ const char *locking_prefix = ".";
|
||||||
const char *locking_suffix = ".swp";
|
const char *locking_suffix = ".swp";
|
||||||
/* Suffix of the vim-style lock file. */
|
/* Suffix of the vim-style lock file. */
|
||||||
#endif
|
#endif
|
||||||
#ifndef DISABLE_OPERATINGDIR
|
#ifdef ENABLE_OPERATINGDIR
|
||||||
char *operating_dir = NULL;
|
char *operating_dir = NULL;
|
||||||
/* The path to our confining "operating" directory, when given. */
|
/* The path to our confining "operating" directory, when given. */
|
||||||
#endif
|
#endif
|
||||||
|
@ -1785,7 +1785,7 @@ void thanks_for_all_the_fish(void)
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
free(backup_dir);
|
free(backup_dir);
|
||||||
#endif
|
#endif
|
||||||
#ifndef DISABLE_OPERATINGDIR
|
#ifdef ENABLE_OPERATINGDIR
|
||||||
free(operating_dir);
|
free(operating_dir);
|
||||||
#endif
|
#endif
|
||||||
free(answer);
|
free(answer);
|
||||||
|
|
18
src/nano.c
18
src/nano.c
|
@ -875,7 +875,7 @@ void usage(void)
|
||||||
print_opt("-m", "--mouse", N_("Enable the use of the mouse"));
|
print_opt("-m", "--mouse", N_("Enable the use of the mouse"));
|
||||||
#endif
|
#endif
|
||||||
print_opt("-n", "--noread", N_("Do not read the file (only write it)"));
|
print_opt("-n", "--noread", N_("Do not read the file (only write it)"));
|
||||||
#ifndef DISABLE_OPERATINGDIR
|
#ifdef ENABLE_OPERATINGDIR
|
||||||
print_opt(_("-o <dir>"), _("--operatingdir=<dir>"),
|
print_opt(_("-o <dir>"), _("--operatingdir=<dir>"),
|
||||||
N_("Set operating directory"));
|
N_("Set operating directory"));
|
||||||
#endif
|
#endif
|
||||||
|
@ -960,7 +960,7 @@ void version(void)
|
||||||
#ifdef ENABLE_MULTIBUFFER
|
#ifdef ENABLE_MULTIBUFFER
|
||||||
printf(" --enable-multibuffer");
|
printf(" --enable-multibuffer");
|
||||||
#endif
|
#endif
|
||||||
#ifndef DISABLE_OPERATINGDIR
|
#ifdef ENABLE_OPERATINGDIR
|
||||||
printf(" --enable-operatingdir");
|
printf(" --enable-operatingdir");
|
||||||
#endif
|
#endif
|
||||||
#ifndef DISABLE_SPELLER
|
#ifndef DISABLE_SPELLER
|
||||||
|
@ -1009,7 +1009,7 @@ void version(void)
|
||||||
#ifndef ENABLE_NANORC
|
#ifndef ENABLE_NANORC
|
||||||
printf(" --disable-nanorc");
|
printf(" --disable-nanorc");
|
||||||
#endif
|
#endif
|
||||||
#ifdef DISABLE_OPERATINGDIR
|
#ifndef ENABLE_OPERATINGDIR
|
||||||
printf(" --disable-operatingdir");
|
printf(" --disable-operatingdir");
|
||||||
#endif
|
#endif
|
||||||
#ifdef DISABLE_SPELLER
|
#ifdef DISABLE_SPELLER
|
||||||
|
@ -1940,7 +1940,7 @@ int main(int argc, char **argv)
|
||||||
{"mouse", 0, NULL, 'm'},
|
{"mouse", 0, NULL, 'm'},
|
||||||
#endif
|
#endif
|
||||||
{"noread", 0, NULL, 'n'},
|
{"noread", 0, NULL, 'n'},
|
||||||
#ifndef DISABLE_OPERATINGDIR
|
#ifdef ENABLE_OPERATINGDIR
|
||||||
{"operatingdir", 1, NULL, 'o'},
|
{"operatingdir", 1, NULL, 'o'},
|
||||||
#endif
|
#endif
|
||||||
{"preserve", 0, NULL, 'p'},
|
{"preserve", 0, NULL, 'p'},
|
||||||
|
@ -2157,7 +2157,7 @@ int main(int argc, char **argv)
|
||||||
case 'n':
|
case 'n':
|
||||||
SET(NOREAD_MODE);
|
SET(NOREAD_MODE);
|
||||||
break;
|
break;
|
||||||
#ifndef DISABLE_OPERATINGDIR
|
#ifdef ENABLE_OPERATINGDIR
|
||||||
case 'o':
|
case 'o':
|
||||||
operating_dir = mallocstrcpy(operating_dir, optarg);
|
operating_dir = mallocstrcpy(operating_dir, optarg);
|
||||||
break;
|
break;
|
||||||
|
@ -2252,7 +2252,7 @@ int main(int argc, char **argv)
|
||||||
#ifdef ENABLE_NANORC
|
#ifdef ENABLE_NANORC
|
||||||
if (!no_rcfiles) {
|
if (!no_rcfiles) {
|
||||||
/* Back up the command-line options, then read the rcfile(s). */
|
/* Back up the command-line options, then read the rcfile(s). */
|
||||||
#ifndef DISABLE_OPERATINGDIR
|
#ifdef ENABLE_OPERATINGDIR
|
||||||
char *operating_dir_cpy = operating_dir;
|
char *operating_dir_cpy = operating_dir;
|
||||||
#endif
|
#endif
|
||||||
#ifndef DISABLE_WRAPJUSTIFY
|
#ifndef DISABLE_WRAPJUSTIFY
|
||||||
|
@ -2274,7 +2274,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
memcpy(flags_cpy, flags, sizeof(flags_cpy));
|
memcpy(flags_cpy, flags, sizeof(flags_cpy));
|
||||||
|
|
||||||
#ifndef DISABLE_OPERATINGDIR
|
#ifdef ENABLE_OPERATINGDIR
|
||||||
operating_dir = NULL;
|
operating_dir = NULL;
|
||||||
#endif
|
#endif
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
|
@ -2296,7 +2296,7 @@ int main(int argc, char **argv)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* If the backed-up command-line options have a value, restore them. */
|
/* If the backed-up command-line options have a value, restore them. */
|
||||||
#ifndef DISABLE_OPERATINGDIR
|
#ifdef ENABLE_OPERATINGDIR
|
||||||
if (operating_dir_cpy != NULL) {
|
if (operating_dir_cpy != NULL) {
|
||||||
free(operating_dir);
|
free(operating_dir);
|
||||||
operating_dir = operating_dir_cpy;
|
operating_dir = operating_dir_cpy;
|
||||||
|
@ -2383,7 +2383,7 @@ int main(int argc, char **argv)
|
||||||
init_backup_dir();
|
init_backup_dir();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DISABLE_OPERATINGDIR
|
#ifdef ENABLE_OPERATINGDIR
|
||||||
/* Set up the operating directory. This entails chdir()ing there,
|
/* Set up the operating directory. This entails chdir()ing there,
|
||||||
* so that file reads and writes will be based there. */
|
* so that file reads and writes will be based there. */
|
||||||
if (operating_dir != NULL)
|
if (operating_dir != NULL)
|
||||||
|
|
|
@ -137,7 +137,7 @@ extern char *backup_dir;
|
||||||
extern const char *locking_prefix;
|
extern const char *locking_prefix;
|
||||||
extern const char *locking_suffix;
|
extern const char *locking_suffix;
|
||||||
#endif
|
#endif
|
||||||
#ifndef DISABLE_OPERATINGDIR
|
#ifdef ENABLE_OPERATINGDIR
|
||||||
extern char *operating_dir;
|
extern char *operating_dir;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -291,7 +291,7 @@ char *get_next_filename(const char *name, const char *suffix);
|
||||||
void do_insertfile_void(void);
|
void do_insertfile_void(void);
|
||||||
char *get_full_path(const char *origpath);
|
char *get_full_path(const char *origpath);
|
||||||
char *safe_tempfile(FILE **f);
|
char *safe_tempfile(FILE **f);
|
||||||
#ifndef DISABLE_OPERATINGDIR
|
#ifdef ENABLE_OPERATINGDIR
|
||||||
void init_operating_dir(void);
|
void init_operating_dir(void);
|
||||||
bool outside_of_confinement(const char *currpath, bool allow_tabcomp);
|
bool outside_of_confinement(const char *currpath, bool allow_tabcomp);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -63,7 +63,7 @@ static const rcoption rcopts[] = {
|
||||||
#ifdef ENABLE_WRAPPING
|
#ifdef ENABLE_WRAPPING
|
||||||
{"nowrap", NO_WRAP},
|
{"nowrap", NO_WRAP},
|
||||||
#endif
|
#endif
|
||||||
#ifndef DISABLE_OPERATINGDIR
|
#ifdef ENABLE_OPERATINGDIR
|
||||||
{"operatingdir", 0},
|
{"operatingdir", 0},
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_HISTORIES
|
#ifdef ENABLE_HISTORIES
|
||||||
|
@ -1102,7 +1102,7 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
|
||||||
specified_color_combo[FUNCTION_TAG] = option;
|
specified_color_combo[FUNCTION_TAG] = option;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#ifndef DISABLE_OPERATINGDIR
|
#ifdef ENABLE_OPERATINGDIR
|
||||||
if (strcasecmp(rcopts[i].name, "operatingdir") == 0)
|
if (strcasecmp(rcopts[i].name, "operatingdir") == 0)
|
||||||
operating_dir = option;
|
operating_dir = option;
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue