5
0
mirror of git://git.proxmox.com/git/pve-common.git synced 2024-12-22 21:33:47 +03:00
Commit Graph

906 Commits

Author SHA1 Message Date
Wolfgang Bumiller
8733bb8078 fix #1766: compare task starttime numerically
Not only because <=> is correct, but using 'cmp' also has
the side effect that it adds a string version to the
variable and the API's json output turns into a string as
well, and this only happens once a task has completed
(while it's an integer while it's still running...)

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-05-18 15:01:58 +02:00
Dietmar Maurer
903ea3fff3 api_dump_remove_refs: prepare API tree for use with to_json($tree)
We want to use this with the extractapi.pl helper (pve-docs, pve-api-client).
2018-05-18 10:13:00 +02:00
Thomas Lamprecht
02548f7bb6 bump version to 5.0-31 2018-05-04 12:57:25 +02:00
Fabian Grünbichler
55ffa426f3 build: install ACME files
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2018-04-30 13:06:52 +02:00
Fabian Grünbichler
f6a70fbfdf acme: add challenge plugins
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2018-04-30 13:06:52 +02:00
Fabian Grünbichler
11c08f1472 acme: add ACME library
this implements those parts of draft-ietf-acme-acme-09 which are needed
to use Let's Encrypt's v2 API.

(based on an internal implement for the Let's Encrypt v1 API)
Co-Authored-By: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2018-04-27 15:18:02 +02:00
Fabian Grünbichler
4e0952c9e8 add Certificate helper
general purpose certificate related helper functions

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2018-04-27 15:18:02 +02:00
Dietmar Maurer
62635f9235 new helper PVE::Tools::du() - get disk usage
We simply call the external binary 'du', so that we can abort the command
when we run into a timeout.
2018-04-25 10:29:58 +02:00
Dominik Csapak
fd58bb2bff untaint df return values
since we sometimes use their length in a format string for printf

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Co-authored-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-04-24 10:42:13 +02:00
Thomas Lamprecht
1e83e254ed README.dev: inkscape no longer needed, s/git-core/git/ 2018-04-23 08:22:27 +02:00
Thomas Lamprecht
597320d761 README.dev: s/jessie/stretch 2018-04-23 08:22:27 +02:00
Dietmar Maurer
68ab3fce31 use ssh -X for upload target 2018-04-05 12:23:17 +02:00
Thomas Lamprecht
eb8ebfa0e5 bump version to 5.0-30
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-03-22 09:10:14 +01:00
Wolfgang Bumiller
c93778bca1 pty: fix read_password prototype
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-03-14 11:08:21 +01:00
Wolfgang Bumiller
c7171ff272 cli: more generic interactive parameter definition
Instead of hardcoding 'password' as a special case in the
JSONSchema's getopt handling, extend the new parameter
mapping to allow defining a parameters as 'interactive'.
They also take an optional argument on the command line
directly.

This effectively deprecates the password special case which
should be replaced in pct/pveum/... and then dropped in
pve-common.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-03-13 11:04:58 +01:00
Dietmar Maurer
3defa1690b bump version to 5.0-29 2018-03-09 08:56:27 +01:00
Thomas Lamprecht
f932646909 CLIHandler: fix command usage string generation
track our command string, i.e. everything which cannot be an argument
for a specific command, in resolve_cmd, as we go through the commando
definition there anyway and know if a ARGV element is part of the
command itself or its arguments.

Fixes a problem where a invalid command had all the passed parameter
attached in the resulting USAGE output.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-03-08 15:10:51 +01:00
Fabian Grünbichler
7c5eeae56a fix #1682: handle relative years absolutely
the timegm(gmtime()) and timelocal(localtime(()) constructs are
problematic in the following case: - $last is such that $year gets set
to a two-digit value (e.g., the referred to timestamp is somewhere in
the range of 1900-1999) - the current date is such that the value of
$year gets interpreted wrongly (e.g., anything other than 1950).

the exact breakage depends on the actual current date AND value of
$last, since localtime/gmtime will interpret two-digit years as (perldoc
Time::Local):
    [...] shorthand for years in the rolling "current century," defined
    as 50 years on either side of the current year. Thus, today, in
    1999, 0 would refer to 2000, and 45 to 2045, but 55 would refer to
    1955.  Twenty years from now, 55 would instead refer to 2055.

fix it by adding 1900 to force 4-digit $year values, as the localtime
documentation suggests.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2018-03-07 11:35:28 +01:00
Dietmar Maurer
c44ec0f663 use better name for string_param_file_mapping (param_mapping).
But keep old one for compatibility.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-03-06 08:47:00 +01:00
Dietmar Maurer
4e0214faae rename $can_read_pass to $read_password_func
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-03-06 08:47:00 +01:00
Dietmar Maurer
8d3eb3ce17 rename $pwcallback to $read_password_func
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-03-06 08:47:00 +01:00
Dietmar Maurer
94e0f9540f rename $can_str_param_fmap to $param_mapping_func
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-03-06 08:47:00 +01:00
Dietmar Maurer
b01af86160 rename $stringfilemap to $param_mapping_func
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-03-06 08:47:00 +01:00
Dietmar Maurer
dfc6cff8e3 introduce compute_param_mapping_hash helper
This allows us to specify a arbitrary mapping func for any param.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-03-06 08:47:00 +01:00
Fabian Grünbichler
e7ecadda06 bump version to 5.0-28 2018-02-19 11:41:34 +01:00
Wolfgang Bumiller
e9b54cc6cf replace brctl with iproute2 calls
And add a few helpers for the common cases.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-02-16 14:17:36 +01:00
Wolfgang Bumiller
2d167ad0d4 schema: add bwlimit standard option and format
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-02-05 09:49:21 +01:00
Wolfgang Bumiller
70ea225069 schema: allow ipv6 prefix lengths up to 128
There's no technical reason for *us* to limit this to 120.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-02-05 09:49:12 +01:00
Wolfgang Bumiller
edbdf0b240 net: remove flowid in traffic limit commands
We don't use them and iproute2 4.13.0 has an issue parsing
parameters after a policing description.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-02-05 09:48:32 +01:00
Wolfgang Bumiller
caf3f3a7a1 bump version to 5.0-27
Now breaks qemu-server<<5.0-21

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-01-22 15:10:05 +01:00
Dietmar Maurer
3b671d82b1 INotify.pm - new helper poll_changes
Useful to detect file changes.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-01-22 14:52:04 +01:00
Dietmar Maurer
04cba6c8c1 read_file: replace $versions->{$filename} with $cver
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2018-01-22 14:52:04 +01:00
Thomas Lamprecht
b8dc43668b CLIHandler: use resolved command definition
For sub commands we resolve the real $cmd, $def and its arguments,
thus we should also get the handler from the resolved $def, not the
global one.

No change for normal (consisting of only the first argument)
commands, for them $cmddef == $def.
This sneaked in in a respin/rebase of the series.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-01-22 11:07:23 +01:00
Wolfgang Bumiller
ca2835a1d4 bump version to 5.0-26
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-01-18 09:31:02 +01:00
Thomas Lamprecht
c1059f7c17 cli: document $cmddef structure
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Acked-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-01-18 08:59:34 +01:00
Thomas Lamprecht
6627ae09a0 cli: allow to pass sub commands to help as array
Improves usabillity by allowing to pass a sub copmmand unquoted to
the help command, e.g.:

 # pveum help user delete

without this only a quoted version worked, e.g.:
 # pveum help "user delete"

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Acked-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-01-18 08:59:34 +01:00
Thomas Lamprecht
50b89b88bb cli: allow specifying sub commands through $cmddef
allow to use sub commands alá
 # pveum user add

The new resolve_cmd traverses $cmddef, resolves one level of aliases
and returns the respective sub command, its cmddef, arguments and if
it was expanded (e.g., pveum u d ... => pveum user delete ...) which
allows quite easy integration in the usage/synopsis generator, bash
completion helper and command handler.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-01-18 08:59:34 +01:00
Thomas Lamprecht
4c802a572c cli: factor out generate usage string
reduce code reuse and prepare for sub commands

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-01-18 08:59:34 +01:00
Thomas Lamprecht
5fa768fc8d cli: refactor print_bash_completion
move variables nearer to where they actually used.
drop program name early from argv array
drop unnecessary variables

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-01-18 08:59:34 +01:00
Thomas Lamprecht
b21cf57546 JSONSchema: add fingerprint-sha256 standard option
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-01-11 12:20:22 +01:00
Wolfgang Bumiller
2311859b0d fork_worker: guard more setup code with eval
As it might die with an error which should end up in the
_exit() code path rather than bailing out into the upper
scope.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Reviewed-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-01-10 14:12:34 +01:00
Wolfgang Bumiller
4d9f4d62e4 fork_worker: use correct handle type for POSIX::write
$resfh can be a pipe from POSIX::pipe() or the upid output
handle, which is an IO::File, so we need to take its
fileno().

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Fixes: ed52a8435a ("fork_worker: use separate pipe for status messages")
Reviewed-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2018-01-10 14:12:34 +01:00
Thomas Lamprecht
918140af72 cli: factor out abort
will be reused in later patches too

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
Acked-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2017-12-29 11:51:20 +01:00
Thomas Lamprecht
7bac844eaa cli: refactor comand name helper
use shorter and also a bit faster methods to expand and get comand
names

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Acked-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2017-12-29 11:51:20 +01:00
Thomas Lamprecht
d204696c52 cli: factor out initialisation check
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
Acked-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2017-12-29 11:51:20 +01:00
Thomas Lamprecht
57e67ea354 cli: refactor and use $cmddef directly
passing one param less to the helper methods

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
Acked-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2017-12-29 11:51:20 +01:00
Thomas Lamprecht
4fdc9659e9 Tools/df: reuse run_fork_with_timeout
Use the later added run_fork_with_timeout for encapsulating df in a
safely manner.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2017-12-21 09:28:47 +01:00
Thomas Lamprecht
ed61b9d675 run_command: add 'quiet' parameter for omitting STD* prints
Without this patch we printed to STDOUT and STDERR, respectively, if
no $outfunc or $errfunc was passed.

Sometimes it's useful if one, or even both, of those prints can
be suppressed, currently this can only be done by either using an array
of arrays or a whole string for the command and redirecting STDOUT
and STDERR.

Add a 'quiet' option which allows to do this in an easier way.
It allows to silent STDERR or STDOUT or both.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2017-12-19 13:09:07 +01:00
Thomas Lamprecht
3e2da21600 fork_worker: factor out synced worker output mirroring
When running in sync (CLI environment) we mirror the workers output
to both, STDOUT and th task log file, a similar function as the unix
comand line tool tee provides, thus we borrow its name for the
factored out sub method.

This moves ~60 lines of code out of the big fork_worker sub and makes
it easier to read track what happens there.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2017-12-18 13:37:05 +01:00
Thomas Lamprecht
ed52a8435a fork_worker: use separate pipe for status messages
We forced line wise flushing of the workers STDOUT and STDERR to
capture the final status (TASK OK/TASK ERROR).
Thus, if the code executed in the worker wanted to flush explicitly,
e.g., when the last output wasn't new line terminated but needed to
reach the users eyes, the parent just ignored that.
This leads to confusing results in CLI handlers using fork_workers.

So remove the buffering logic completely and introduce a separate
pipe for sending the final status.
Said pipe gets once read after the child closes (EOF) its STDOUT.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2017-12-18 13:37:05 +01:00