Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
cs24-19fa
git_rec_nano
Commits
028d12f4
Commit
028d12f4
authored
7 years ago
by
Benno Schulenberg
Browse files
Options
Download
Email Patches
Plain Diff
tweaks: transform the token DISABLE_OPERATINGDIR to ENABLE_OPERATINGDIR
parent
a5974bd1
master
feature/match-parens
refactor/readbility
No related merge requests found
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
configure.ac
+7
-5
configure.ac
src/browser.c
+3
-3
src/browser.c
src/files.c
+6
-6
src/files.c
src/global.c
+2
-2
src/global.c
src/nano.c
+9
-9
src/nano.c
src/proto.h
+2
-2
src/proto.h
src/rcfile.c
+2
-2
src/rcfile.c
with
31 additions
and
29 deletions
+31
-29
configure.ac
View file @
028d12f4
...
...
@@ -198,8 +198,13 @@ fi
AC_ARG_ENABLE(operatingdir,
AS_HELP_STRING([--disable-operatingdir], [Disable the setting of an operating directory]))
if test "x$enable_operatingdir" = xno; then
AC_DEFINE(DISABLE_OPERATINGDIR, 1, [Define this to disable the setting of an operating directory (a chroot of sorts).])
if test "x$enable_tiny" = xyes; then
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
AC_ARG_ENABLE(speller,
...
...
@@ -278,9 +283,6 @@ if test "x$enable_tiny" = xyes; then
if test "x$enable_libmagic" != xyes; then
enable_libmagic=no
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
AC_DEFINE(DISABLE_SPELLER, 1, [Define this to disable the spell-checker functions.])
fi
...
...
This diff is collapsed.
Click to expand it.
src/browser.c
View file @
028d12f4
...
...
@@ -243,7 +243,7 @@ char *do_browser(char *path)
sprintf
(
path
,
"%s%s"
,
present_path
,
answer
);
}
#if
n
def
DIS
ABLE_OPERATINGDIR
#ifdef
EN
ABLE_OPERATINGDIR
if
(
outside_of_confinement
(
path
,
FALSE
))
{
/* TRANSLATORS: This refers to the confining effect of the
* option --operatingdir, not of --restricted. */
...
...
@@ -273,7 +273,7 @@ char *do_browser(char *path)
continue
;
}
#if
n
def
DIS
ABLE_OPERATINGDIR
#ifdef
EN
ABLE_OPERATINGDIR
/* Note: The selected file can be outside the operating
* directory if it's ".." or if it's a symlink to a
* directory outside the operating directory. */
...
...
@@ -372,7 +372,7 @@ char *do_browse_from(const char *inpath)
}
}
#if
n
def
DIS
ABLE_OPERATINGDIR
#ifdef
EN
ABLE_OPERATINGDIR
/* If the resulting path isn't in the operating directory, use
* the operating directory instead. */
if
(
outside_of_confinement
(
path
,
FALSE
))
...
...
This diff is collapsed.
Click to expand it.
src/files.c
View file @
028d12f4
...
...
@@ -422,7 +422,7 @@ bool open_buffer(const char *filename, bool undoable)
/* Display newlines in filenames as ^J. */
as_an_at
=
FALSE
;
#if
n
def
DIS
ABLE_OPERATINGDIR
#ifdef
EN
ABLE_OPERATINGDIR
if
(
outside_of_confinement
(
filename
,
FALSE
))
{
statusline
(
ALERT
,
_
(
"Can't read file from outside of %s"
),
operating_dir
);
...
...
@@ -1069,7 +1069,7 @@ void do_insertfile(void)
execute
?
&
execute_history
:
#endif
NULL
,
edit_refresh
,
msg
,
#if
n
def
DIS
ABLE_OPERATINGDIR
#ifdef
EN
ABLE_OPERATINGDIR
operating_dir
!=
NULL
?
operating_dir
:
#endif
"./"
);
...
...
@@ -1401,7 +1401,7 @@ char *safe_tempfile(FILE **f)
return
full_tempdir
;
}
#if
n
def
DIS
ABLE_OPERATINGDIR
#ifdef
EN
ABLE_OPERATINGDIR
/* Change to the specified operating directory, when it's valid. */
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
);
#if
n
def
DIS
ABLE_OPERATINGDIR
#ifdef
EN
ABLE_OPERATINGDIR
/* If we're writing a temporary file, we're probably going outside
* the operating directory, so skip the operating directory test. */
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
* lot more sense to me (Chris) this way... */
#if
n
def
DIS
ABLE_OPERATINGDIR
#ifdef
EN
ABLE_OPERATINGDIR
/* ...unless the match exists outside the operating
* directory, in which case just go to the next match. */
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
);
sprintf
(
tmp
,
"%s%s"
,
dirname
,
nextdir
->
d_name
);
#if
n
def
DIS
ABLE_OPERATINGDIR
#ifdef
EN
ABLE_OPERATINGDIR
/* ...unless the match exists outside the operating
* directory, in which case just go to the next match. */
skip_match
=
outside_of_confinement
(
tmp
,
TRUE
);
...
...
This diff is collapsed.
Click to expand it.
src/global.c
View file @
028d12f4
...
...
@@ -169,7 +169,7 @@ const char *locking_prefix = ".";
const
char
*
locking_suffix
=
".swp"
;
/* Suffix of the vim-style lock file. */
#endif
#if
n
def
DIS
ABLE_OPERATINGDIR
#ifdef
EN
ABLE_OPERATINGDIR
char
*
operating_dir
=
NULL
;
/* The path to our confining "operating" directory, when given. */
#endif
...
...
@@ -1785,7 +1785,7 @@ void thanks_for_all_the_fish(void)
#ifndef NANO_TINY
free
(
backup_dir
);
#endif
#if
n
def
DIS
ABLE_OPERATINGDIR
#ifdef
EN
ABLE_OPERATINGDIR
free
(
operating_dir
);
#endif
free
(
answer
);
...
...
This diff is collapsed.
Click to expand it.
src/nano.c
View file @
028d12f4
...
...
@@ -875,7 +875,7 @@ void usage(void)
print_opt
(
"-m"
,
"--mouse"
,
N_
(
"Enable the use of the mouse"
));
#endif
print_opt
(
"-n"
,
"--noread"
,
N_
(
"Do not read the file (only write it)"
));
#if
n
def
DIS
ABLE_OPERATINGDIR
#ifdef
EN
ABLE_OPERATINGDIR
print_opt
(
_
(
"-o <dir>"
),
_
(
"--operatingdir=<dir>"
),
N_
(
"Set operating directory"
));
#endif
...
...
@@ -960,7 +960,7 @@ void version(void)
#ifdef ENABLE_MULTIBUFFER
printf
(
" --enable-multibuffer"
);
#endif
#if
n
def
DIS
ABLE_OPERATINGDIR
#ifdef
EN
ABLE_OPERATINGDIR
printf
(
" --enable-operatingdir"
);
#endif
#ifndef DISABLE_SPELLER
...
...
@@ -1009,7 +1009,7 @@ void version(void)
#ifndef ENABLE_NANORC
printf
(
" --disable-nanorc"
);
#endif
#ifdef
DIS
ABLE_OPERATINGDIR
#if
n
def
EN
ABLE_OPERATINGDIR
printf
(
" --disable-operatingdir"
);
#endif
#ifdef DISABLE_SPELLER
...
...
@@ -1940,7 +1940,7 @@ int main(int argc, char **argv)
{
"mouse"
,
0
,
NULL
,
'm'
},
#endif
{
"noread"
,
0
,
NULL
,
'n'
},
#if
n
def
DIS
ABLE_OPERATINGDIR
#ifdef
EN
ABLE_OPERATINGDIR
{
"operatingdir"
,
1
,
NULL
,
'o'
},
#endif
{
"preserve"
,
0
,
NULL
,
'p'
},
...
...
@@ -2157,7 +2157,7 @@ int main(int argc, char **argv)
case
'n'
:
SET
(
NOREAD_MODE
);
break
;
#if
n
def
DIS
ABLE_OPERATINGDIR
#ifdef
EN
ABLE_OPERATINGDIR
case
'o'
:
operating_dir
=
mallocstrcpy
(
operating_dir
,
optarg
);
break
;
...
...
@@ -2252,7 +2252,7 @@ int main(int argc, char **argv)
#ifdef ENABLE_NANORC
if
(
!
no_rcfiles
)
{
/* Back up the command-line options, then read the rcfile(s). */
#if
n
def
DIS
ABLE_OPERATINGDIR
#ifdef
EN
ABLE_OPERATINGDIR
char
*
operating_dir_cpy
=
operating_dir
;
#endif
#ifndef DISABLE_WRAPJUSTIFY
...
...
@@ -2274,7 +2274,7 @@ int main(int argc, char **argv)
memcpy
(
flags_cpy
,
flags
,
sizeof
(
flags_cpy
));
#if
n
def
DIS
ABLE_OPERATINGDIR
#ifdef
EN
ABLE_OPERATINGDIR
operating_dir
=
NULL
;
#endif
#ifndef NANO_TINY
...
...
@@ -2296,7 +2296,7 @@ int main(int argc, char **argv)
#endif
/* If the backed-up command-line options have a value, restore them. */
#if
n
def
DIS
ABLE_OPERATINGDIR
#ifdef
EN
ABLE_OPERATINGDIR
if
(
operating_dir_cpy
!=
NULL
)
{
free
(
operating_dir
);
operating_dir
=
operating_dir_cpy
;
...
...
@@ -2383,7 +2383,7 @@ int main(int argc, char **argv)
init_backup_dir
();
#endif
#if
n
def
DIS
ABLE_OPERATINGDIR
#ifdef
EN
ABLE_OPERATINGDIR
/* Set up the operating directory. This entails chdir()ing there,
* so that file reads and writes will be based there. */
if
(
operating_dir
!=
NULL
)
...
...
This diff is collapsed.
Click to expand it.
src/proto.h
View file @
028d12f4
...
...
@@ -137,7 +137,7 @@ extern char *backup_dir;
extern
const
char
*
locking_prefix
;
extern
const
char
*
locking_suffix
;
#endif
#if
n
def
DIS
ABLE_OPERATINGDIR
#ifdef
EN
ABLE_OPERATINGDIR
extern
char
*
operating_dir
;
#endif
...
...
@@ -291,7 +291,7 @@ char *get_next_filename(const char *name, const char *suffix);
void
do_insertfile_void
(
void
);
char
*
get_full_path
(
const
char
*
origpath
);
char
*
safe_tempfile
(
FILE
**
f
);
#if
n
def
DIS
ABLE_OPERATINGDIR
#ifdef
EN
ABLE_OPERATINGDIR
void
init_operating_dir
(
void
);
bool
outside_of_confinement
(
const
char
*
currpath
,
bool
allow_tabcomp
);
#endif
...
...
This diff is collapsed.
Click to expand it.
src/rcfile.c
View file @
028d12f4
...
...
@@ -63,7 +63,7 @@ static const rcoption rcopts[] = {
#ifdef ENABLE_WRAPPING
{
"nowrap"
,
NO_WRAP
},
#endif
#if
n
def
DIS
ABLE_OPERATINGDIR
#ifdef
EN
ABLE_OPERATINGDIR
{
"operatingdir"
,
0
},
#endif
#ifdef ENABLE_HISTORIES
...
...
@@ -1102,7 +1102,7 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
specified_color_combo
[
FUNCTION_TAG
]
=
option
;
else
#endif
#if
n
def
DIS
ABLE_OPERATINGDIR
#ifdef
EN
ABLE_OPERATINGDIR
if
(
strcasecmp
(
rcopts
[
i
].
name
,
"operatingdir"
)
==
0
)
operating_dir
=
option
;
else
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help