Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libloc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
libloc
Commits
1164d876
Commit
1164d876
authored
May 19, 2020
by
Michael Tremer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
python: Support passing two signing keys
Signed-off-by:
Michael Tremer
<
michael.tremer@ipfire.org
>
parent
5ce881d4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
11 deletions
+37
-11
src/python/location-importer.in
src/python/location-importer.in
+2
-1
src/python/writer.c
src/python/writer.c
+35
-10
No files found.
src/python/location-importer.in
View file @
1164d876
...
...
@@ -67,6 +67,7 @@ class CLI(object):
write
.
set_defaults
(
func
=
self
.
handle_write
)
write
.
add_argument
(
"file"
,
nargs
=
1
,
help
=
_
(
"Database File"
))
write
.
add_argument
(
"--signing-key"
,
nargs
=
"?"
,
type
=
open
,
help
=
_
(
"Signing Key"
))
write
.
add_argument
(
"--backup-signing-key"
,
nargs
=
"?"
,
type
=
open
,
help
=
_
(
"Backup Signing Key"
))
write
.
add_argument
(
"--vendor"
,
nargs
=
"?"
,
help
=
_
(
"Sets the vendor"
))
write
.
add_argument
(
"--description"
,
nargs
=
"?"
,
help
=
_
(
"Sets a description"
))
write
.
add_argument
(
"--license"
,
nargs
=
"?"
,
help
=
_
(
"Sets the license"
))
...
...
@@ -182,7 +183,7 @@ class CLI(object):
Compiles a database in libloc format out of what is in the database
"""
# Allocate a writer
writer
=
location
.
Writer
(
ns
.
signing_key
)
writer
=
location
.
Writer
(
ns
.
signing_key
,
ns
.
backup_signing_key
)
# Set all metadata
if
ns
.
vendor
:
...
...
src/python/writer.c
View file @
1164d876
...
...
@@ -39,31 +39,56 @@ static void Writer_dealloc(WriterObject* self) {
}
static
int
Writer_init
(
WriterObject
*
self
,
PyObject
*
args
,
PyObject
*
kwargs
)
{
PyObject
*
private_key
=
NULL
;
FILE
*
f
=
NULL
;
PyObject
*
private_key1
=
NULL
;
PyObject
*
private_key2
=
NULL
;
FILE
*
f1
=
NULL
;
FILE
*
f2
=
NULL
;
int
fd
;
// Parse arguments
if
(
!
PyArg_ParseTuple
(
args
,
"|O
"
,
&
private_key
))
if
(
!
PyArg_ParseTuple
(
args
,
"|O
O"
,
&
private_key1
,
&
private_key2
))
return
-
1
;
// Ignore None
if
(
private_key1
==
Py_None
)
{
Py_DECREF
(
private_key1
);
private_key1
=
NULL
;
}
if
(
private_key2
==
Py_None
)
{
Py_DECREF
(
private_key2
);
private_key2
=
NULL
;
}
// Convert into FILE*
if
(
private_key
&&
private_key
!=
Py_None
)
{
int
fd
=
PyObject_AsFileDescriptor
(
private_key
);
if
(
private_key
1
)
{
fd
=
PyObject_AsFileDescriptor
(
private_key1
);
if
(
fd
<
0
)
return
-
1
;
// Re-open file descriptor
f
=
fdopen
(
fd
,
"r"
);
if
(
!
f
)
{
f
2
=
fdopen
(
fd
,
"r"
);
if
(
!
f
2
)
{
PyErr_SetFromErrno
(
PyExc_IOError
);
return
-
1
;
}
}
// Create the writer object
int
r
=
loc_writer_new
(
loc_ctx
,
&
self
->
writer
,
f
,
NULL
);
if
(
private_key2
)
{
fd
=
PyObject_AsFileDescriptor
(
private_key2
);
if
(
fd
<
0
)
return
-
1
;
return
r
;
// Re-open file descriptor
f2
=
fdopen
(
fd
,
"r"
);
if
(
!
f2
)
{
PyErr_SetFromErrno
(
PyExc_IOError
);
return
-
1
;
}
}
// Create the writer object
return
loc_writer_new
(
loc_ctx
,
&
self
->
writer
,
f1
,
f2
);
}
static
PyObject
*
Writer_get_vendor
(
WriterObject
*
self
)
{
...
...
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