Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Michal Čihař
updater
Commits
de9b69fb
Verified
Commit
de9b69fb
authored
Jul 17, 2018
by
Karel Koci
🤘
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Drop internal:// uri
This uri is no longer used anywhere now.
parent
01ed0e9f
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
13 additions
and
91 deletions
+13
-91
doc/language.txt
doc/language.txt
+3
-6
src/lib/autoload/a_10_uri.lua
src/lib/autoload/a_10_uri.lua
+0
-25
src/lib/interpreter.c
src/lib/interpreter.c
+1
-20
src/lib/interpreter.h
src/lib/interpreter.h
+1
-4
src/opkg-trans/main.c
src/opkg-trans/main.c
+1
-1
src/pkgupdate/main.c
src/pkgupdate/main.c
+1
-1
tests/Makefile.dir
tests/Makefile.dir
+1
-7
tests/interpreter.c
tests/interpreter.c
+2
-8
tests/locks.c
tests/locks.c
+1
-1
tests/lunit-launch/Makefile.dir
tests/lunit-launch/Makefile.dir
+1
-6
tests/lunit-launch/main.c
tests/lunit-launch/main.c
+1
-4
tests/uri.lua
tests/uri.lua
+0
-8
No files found.
doc/language.txt
View file @
de9b69fb
...
...
@@ -105,7 +105,6 @@ These are the types of URIs supported:
* `http://`
* `https://`
* `data:`
* `internal:`
The remote ones (`http` and `https`) may need verification of the
integrity of its content. The other are considered secure and don't
...
...
@@ -115,14 +114,12 @@ The `data:` is slightly limited compared to what the standard (RFC
2397) allows. The media type and charset are irrelevant to the
updater and are therefore not supported.
The `internal:` URI is a non-standard scheme. The updater may contain
compiled-in resources (embedded files). Each such resource has a
unique name. The `internal:` scheme accesses these embedded files. The
colon is directly followed by the name.
Scripts with access level of `remote` or lower are not allowed to use
the `file://` and `internal:` schemes.
NOTE: In previous versions there was an `internal:` URI but that one is no longer
available and can't be used.
Verification
------------
...
...
src/lib/autoload/a_10_uri.lua
View file @
de9b69fb
...
...
@@ -42,7 +42,6 @@ local run_command = run_command
local
run_util
=
run_util
local
utils
=
require
"utils"
local
TRACE
=
TRACE
local
uri_internal_get
=
uri_internal_get
local
sha256
=
sha256
module
"uri"
...
...
@@ -129,24 +128,6 @@ local function handler_file(uri, err_cback, done_cback)
done_cback(content)
end
local function handler_internal(uri, err_cback, done_cback)
local iname = uri:match('^internal:(.*)')
if not iname then
return err_cback(utils.exception("
malformed
URI
", "
Not
a
internal
:
//
URI
"))
end
local ok
ok, iname = pcall(percent_decode, iname)
if not ok then
return err_cback(utils.exception("
malformed
URI
", "
Bad
URL
encoding
"))
end
local content
ok, content = pcall(uri_internal_get, iname)
if not ok then
return err_cback(utils.exception("
unreachable
", tostring(content)))
end
done_cback(content)
end
-- Actually, both for http and https
local function handler_http(uri, err_cback, done_cback, ca, crl, ocsp, use_ssl)
return download(function (status, answer)
...
...
@@ -179,12 +160,6 @@ local handlers = {
def_verif = 'none',
sec_level = 'Local'
},
internal = {
handler = handler_internal,
immediate = true,
def_verif = 'none',
sec_level = 'Local'
},
http = {
handler = handler_http,
def_verif = 'sig',
...
...
src/lib/interpreter.c
View file @
de9b69fb
...
...
@@ -806,23 +806,6 @@ static int lua_reexec(lua_State *L) {
return
0
;
}
// Stores pointer to internal files used as uri.
static
const
struct
file_index_element
*
uriinternal
;
static
int
lua_uri_internal_get
(
lua_State
*
L
)
{
int
param_count
=
lua_gettop
(
L
);
if
(
param_count
>
1
)
return
luaL_error
(
L
,
"Too many parameters to uri_internal_get: %d"
,
param_count
);
const
char
*
name
=
luaL_checkstring
(
L
,
1
);
if
(
!
uriinternal
)
return
luaL_error
(
L
,
"Internal uri is not supported."
,
name
);
const
struct
file_index_element
*
file
=
index_element_find
(
uriinternal
,
name
);
if
(
!
file
)
return
luaL_error
(
L
,
"No internal with name: %s"
,
name
);
lua_pushlstring
(
L
,
(
const
char
*
)
file
->
data
,
file
->
size
);
return
1
;
}
static
int
lua_system_reboot
(
lua_State
*
L
)
{
bool
stick
=
lua_toboolean
(
L
,
1
);
system_reboot
(
stick
);
...
...
@@ -877,7 +860,6 @@ static const struct injected_func injected_funcs[] = {
{
lua_sha256
,
"sha256"
},
{
lua_sha256_file
,
"sha256_file"
},
{
lua_reexec
,
"reexec"
},
{
lua_uri_internal_get
,
"uri_internal_get"
},
{
lua_system_reboot
,
"system_reboot"
},
{
lua_get_updater_version
,
"get_updater_version"
}
};
...
...
@@ -921,8 +903,7 @@ static void interpreter_load_coverage(struct interpreter *interpreter) {
}
#endif
struct
interpreter
*
interpreter_create
(
struct
events
*
events
,
const
struct
file_index_element
*
uriinter
)
{
uriinternal
=
uriinter
;
struct
interpreter
*
interpreter_create
(
struct
events
*
events
)
{
struct
interpreter
*
result
=
malloc
(
sizeof
*
result
);
lua_State
*
L
=
luaL_newstate
();
*
result
=
(
struct
interpreter
)
{
...
...
src/lib/interpreter.h
View file @
de9b69fb
...
...
@@ -33,11 +33,8 @@ struct events;
* then all the event-related functions ASSERT. The events
* structure is not owned by the interpreter, but if you provide
* one, it must stay alive for the whole life of the interpreter.
* uriinter is index of embedded files in executable to be used
* from lua as uri internal. You can provide NULL if this feature
* shouldn't be available.
*/
struct
interpreter
*
interpreter_create
(
struct
events
*
events
,
const
struct
file_index_element
*
uriinter
)
__attribute__
((
malloc
));
struct
interpreter
*
interpreter_create
(
struct
events
*
events
)
__attribute__
((
malloc
));
/*
* Run lua chunk in an interpreter. In case there's an error,
* the error is returned. The string is owned by the lua
...
...
src/opkg-trans/main.c
View file @
de9b69fb
...
...
@@ -62,7 +62,7 @@ int main(int argc, char *argv[]) {
struct
cmd_op
*
ops
=
cmd_args_parse
(
argc
,
argv
,
cmd_op_allows
);
struct
cmd_op
*
op
=
ops
;
// Prepare the interpreter and load it with the embedded lua scripts
struct
interpreter
*
interpreter
=
interpreter_create
(
events
,
NULL
);
struct
interpreter
*
interpreter
=
interpreter_create
(
events
);
const
char
*
error
=
interpreter_autoload
(
interpreter
);
if
(
error
)
{
fputs
(
error
,
stderr
);
...
...
src/pkgupdate/main.c
View file @
de9b69fb
...
...
@@ -216,7 +216,7 @@ int main(int argc, char *argv[]) {
state_dump
(
"startup"
);
struct
events
*
events
=
events_new
();
// Prepare the interpreter and load it with the embedded lua scripts
struct
interpreter
*
interpreter
=
interpreter_create
(
events
,
NULL
);
struct
interpreter
*
interpreter
=
interpreter_create
(
events
);
const
char
*
error
=
interpreter_autoload
(
interpreter
);
ASSERT_MSG
(
!
error
,
"%s"
,
error
);
...
...
tests/Makefile.dir
View file @
de9b69fb
...
...
@@ -50,16 +50,10 @@ clean-coverage:
# Ignore stacktraceplus and dumper, not our creation.
LUA_AUTOLOAD
:=
$(
filter-out
01_stacktraceplus 07_dumper,
$(
patsubst
a_%.lua,%,
$(
notdir
$(
wildcard
$(S)
/src/lib/autoload/a_
*
.lua
))))
TEST_URIINTERNAL
:=
$(
abspath
$(
wildcard
$(S)
/tests/internal/
*
))
$(O)/.gen/tests/uriinternal.embedlist
:
$(S)/src/lib/gen_embed.sh $(S)/src/lib/embed_types.h $(TEST_URIINTERNAL)
$(M)
GEN
$@
$(Q)
mkdir
-p
$(
dir
$@
)
$(Q)$<
""
uriinternal
$(S)
/src/lib/embed_types.h
$(TEST_URIINTERNAL)
>
$@
define
DO_C_TEST
BINARIES_NOTARGET
+=
tests/ctest-
$(1)
ctest-$(1)_MODULES
+=
$(1)
uriinternal.embed
ctest
ctest-$(1)_MODULES
+=
$(1)
ctest
ctest-$(1)_SYSTEM_LIBS
+=
m rt
ctest-$(1)_PKG_CONFIGS
+=
check
ctest-$(1)_LOCAL_LIBS
+=
updater
...
...
tests/interpreter.c
View file @
de9b69fb
...
...
@@ -50,7 +50,6 @@ const char *library[] = { "next({});", "getfenv();", "string.find('x', 'y');", "
const
char
*
autoloaded
[]
=
{
"testing.values();"
,
NULL
};
const
char
*
logging
[]
=
{
"log('DEBUG', 0, 'test')"
,
"log('INVALID', 0, 'test')"
,
"ERROR('test')"
,
"log('DEBUG', 0, nil)"
,
"log('DEBUG', 0, {'table'})"
,
NULL
};
const
char
*
pre_require
[]
=
{
"local m = require 'testing'; testing.values();"
,
NULL
};
const
char
*
uriinter_get
[]
=
{
"uri_internal_get('hello_txt')"
,
NULL
};
struct
loading_case
loading_cases
[]
=
{
{
"OK"
,
ok
,
1
,
false
},
...
...
@@ -72,13 +71,8 @@ struct loading_case loading_cases[] = {
{
"Missing logging"
,
logging
,
2
,
false
},
// Check the loading presets the package.loaded correctly, so further require works.
{
"pre_require"
,
pre_require
,
1
,
true
},
// Check if we can call uri_internal_get
{
"uri_internal_get"
,
uriinter_get
,
1
,
false
}
};
// From the embed file, embedded files to binary
extern
struct
file_index_element
uriinternal
[];
START_TEST
(
loading
)
{
/*
* Test that we can load some code into the interpreter.
...
...
@@ -93,7 +87,7 @@ START_TEST(loading) {
*/
struct
loading_case
*
c
=
&
loading_cases
[
_i
/
2
];
struct
events
*
events
=
events_new
();
struct
interpreter
*
interpreter
=
interpreter_create
(
events
,
uriinternal
);
struct
interpreter
*
interpreter
=
interpreter_create
(
events
);
if
(
c
->
autoload
)
ck_assert_msg
(
!
interpreter_autoload
(
interpreter
),
"Error autoloading"
);
mark_point
();
...
...
@@ -113,7 +107,7 @@ END_TEST
#define START_INTERPRETER_TEST(NAME) \
START_TEST(NAME) { \
struct events *events = events_new(); \
struct interpreter *interpreter = interpreter_create(events
, NULL
); \
struct interpreter *interpreter = interpreter_create(events); \
ck_assert_msg(!interpreter_autoload(interpreter), "Error autoloading"); \
mark_point();
...
...
tests/locks.c
View file @
de9b69fb
...
...
@@ -37,7 +37,7 @@
int
main
(
int
argc
__attribute__
((
unused
)),
char
*
argv
[]
__attribute__
((
unused
)))
{
struct
events
*
events
=
events_new
();
struct
interpreter
*
interpreter
=
interpreter_create
(
events
,
NULL
);
struct
interpreter
*
interpreter
=
interpreter_create
(
events
);
interpreter_autoload
(
interpreter
);
const
char
*
err
=
interpreter_call
(
interpreter
,
"mkdtemp"
,
NULL
,
""
);
ASSERT_MSG
(
!
err
,
"%s"
,
err
);
...
...
tests/lunit-launch/Makefile.dir
View file @
de9b69fb
...
...
@@ -4,11 +4,6 @@ $(O)/.gen/tests/lunit-launch/lunit.embedlist: $(S)/src/lib/gen_embed.sh $(S)/src
$(Q)
mkdir
-p
$(
dir
$@
)
$(Q)$<
.lua lunit_modules
$(S)
/src/lib/embed_types.h
$(LUNIT_LOAD)
>
$@
$(O)/.gen/tests/lunit-launch/uriinternal.embedlist
:
$(S)/src/lib/gen_embed.sh $(S)/src/lib/embed_types.h $(TEST_URIINTERNAL)
$(M)
GEN
$@
$(Q)
mkdir
-p
$(
dir
$@
)
$(Q)$<
""
uriinternal
$(S)
/src/lib/embed_types.h
$(TEST_URIINTERNAL)
>
$@
BINARIES_NOTARGET
+=
tests/lunit-launch/lulaunch
lulaunch_MODULES
:=
main lunit.embed
uriinternal.embed
lulaunch_MODULES
:=
main lunit.embed
lulaunch_LOCAL_LIBS
:=
updater
tests/lunit-launch/main.c
View file @
de9b69fb
...
...
@@ -29,9 +29,6 @@
// From the embed files, lua modules to run lunit.
extern
struct
file_index_element
lunit_modules
[];
// From the embed file, embedded files to binary
extern
struct
file_index_element
uriinternal
[];
// Our own fake require that loads the thing from embedded file
void
require
(
struct
interpreter
*
interpreter
,
const
char
*
name
)
{
char
*
index
=
strdup
(
name
);
...
...
@@ -53,7 +50,7 @@ int main(int argc __attribute__((unused)), char *argv[]) {
log_stderr_level
(
LL_UNKNOWN
);
// Get the interpreter
struct
events
*
events
=
events_new
();
struct
interpreter
*
interpreter
=
interpreter_create
(
events
,
uriinternal
);
struct
interpreter
*
interpreter
=
interpreter_create
(
events
);
const
char
*
error
=
interpreter_autoload
(
interpreter
);
ASSERT_MSG
(
!
error
,
"%s"
,
error
);
// Load the lunit modules
...
...
tests/uri.lua
View file @
de9b69fb
...
...
@@ -132,14 +132,6 @@ function test_file()
err_sync
(
"Local"
,
"file:///does/not/exist"
,
"unreachable"
)
end
function
test_internal
()
check_sync
(
"Local"
,
"internal:hello_txt"
,
"hello\n"
)
check_sync
(
"Local"
,
"internal:hello%5ftxt"
,
"hello\n"
)
assert_exception
(
function
()
uri
(
sandbox
.
new
(
"Remote"
),
"internal:hello_txt"
)
end
,
"access violation"
)
err_sync
(
"Local"
,
"internal:%ZZ"
,
"malformed URI"
)
err_sync
(
"Local"
,
"internal:does_not_exist"
,
"unreachable"
)
end
function
test_https
()
local
context
=
sandbox
.
new
(
"Remote"
)
local
u1
=
uri
(
context
,
"https://repo.turris.cz/"
,
{
verification
=
'none'
})
...
...
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