It is possible that the user manually corrected a corrupt repo.
If a repo makes it past initialization reset the corrupt flag.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This allows for more advanced integration of LDAP databases that are not
covered by the default behaviour of is_active_directory.
Signed-off-by: Nick Douma <n.douma@nekoconeko.nl>
It that "git status" will not detect some repo issues, these are only
found after a fetch. When this condition is detected save the repo
state and report that the repo is corrupt and invalid.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
I'm playing with using git submodules to track my entire printer config,
and moonraker only works with separate clones as is. Using `.exists()`
instead of `.is_dir()` allows moonraker to control the submodules.
Signed-off-by: Franklyn Tackitt <git@frank.af>
The previous "/lost+found" is not available on all systems. Change to
"/root", which should be available.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Introduce a "raw" parameter for /server/info that defaults to False.
Front ends that do not wish to recieve warnings with html line breaks
may set this parameter to True, otherwise newlines will be replaced
with "<br/>".
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Don't raise an exception if the option in a path does not exist. Remove
the option and fall back to the default path location
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Prevent users from uploading files before validation is complete, as
this can populate one of the subfolders resulting in a failure when
attempting to symlink the original path.
When validating the config symlink the database first. This should
allow Moonraker to correctly move the database should an error
be encountered when validating the other config options.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Specifically check against the detected service unit, otherwise
allow a power device to bind to any available service.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Handle exceptions raised when adding a new watch. Warn
the user and skip adding the node to the watched tree.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Allow components to register reserved paths, then perform reserved
path validation it upon request. Reserved paths may be registered as
read-only or no access. Any request to modify an file/folder that is
either reserved or a child of a reserved path is rejected.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
The secrets module will now look for "moonraker.secrets"
in the data folder. If the file does not exist the deprecated
"secrets_path" option will be used as a fallback.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Deprecate the "database_path" option. If the database
does not exist, however the "database_path" does, it
will be used as a fallback.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
The config and logs paths are no longer configurable,
they all exist as folders or symbolic links within the primary
data folder. The gcode path no longer relies on Klipper to
specify the location, instead Klipper's virtual_sdcard path
shold be configured to the location of the "gcodes" folder
in the data path.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Prepare to move away from configurable paths. This will
resolve potential security vulnerabilities in the event that
a user's access is compromised.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Klipper now has the ability to report the current layer on
properly configured slicers. Prefer this value if available,
otherwise fall back to layer detection.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Users may specify a dedicated ambient sensor in the
[simplyprint] configuration. If the specified sensor is
invalid or no sensor is specified ambient detection
will fall back to an estimate using the extruder.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Its possible for the websocket client to disconnect before
read_message() returns None. Await all calls to write_message()
to handle websocket closed exceptions.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Moonraker requires that the configuration be parsed in 'strict' mode,
ie: duplicate sections are not allowed within the same file and duplicate
options are not allowed within the same section.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Query the detected url and make sure it redirects to the
expected url. This closes a security vulnerability
where a remote could be changed to an arbitrary repo's url.
The `moved_origin` option is no longer necessary, however it
is currently used as an additional check. In the future it will be
deprecated.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Close a security hole where an attacker could overwrite an existing repo
with any remote and run malicious code through an update.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
If the supplied python executable is a symbolic link attempt
to read the location at which it points. If this is a virtualenv
this should give us the correct pip location.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This adds initial support for connecting Moonraker to the SimplyPrint
service. Currently the connection defaults to SimplyPrint's dev/test
endpoint, this will be changed prior to official release.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Its possible for any component to request a configuration
option from another component. Don't overwrite the
inital value stored.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Process included files in the order they are added. This changes how
duplicate sections throughout included files are merged, options in
the last section to be parsed will take precedent.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
The webcam module allows users to enter webcam configuration through
moonraker.conf while keeping compatibility with frontends that
store webcam data in the database.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
In the future, an `Access-Control-Request-Private-Network` header will be sent with
these requests, and servers must respond with `Access-Control-Allow-Private-Network`.
This will start with the next Chrome version (104), and Mozilla has marked the
standard as "worth prototyping", which often leads to final implementation.
Signed-off-by: Franklyn Tackitt <git@frank.af>
Check for updates every 7 days rather than every 28 days. This
is in preparation of an upcoming beta release.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Python 3.10 deprecates "get_event_loop()", so it is necessary to
create a new loop and set it as active at startup. Previously
Moonraker only did this after a soft restart.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
For legacy purposes its possible that "initialize()" may be an
awaitable. Ignore the type as it consues mypy.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Remote devices, such as the tplink smartplug and http
based devices, may not be immediately available when
Moonraker starts. Previously this would result in an error.
Remote switches that requiring polling for state will now
reattempt initialization indefinitely. This behavior brings
them in line with devices that are updated asynchronously.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Override the paho-mqtt client "reconnect()" method with
a method capable of taking a connected socket. This allows
Moonraker to connect the socket asynchronously, then finish
establishing the connection.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Don't allow exceptions to propagate beyond a call to
_process_event(). Make sure the future is not marked
as done prior to setting the result.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
For the "Percent" preset the intensity controls the amount of the bar lit up 0-100
Work around issue when preset is re-enabled if sending intensity or speed while no preset is active
Removed control endpoint
Added missed toggle endpoint
Transition time to 0 for control changes
Signed-off-by: Richard Mitchell <richardjm+moonraker@gmail.com>
To accommodate access to multiple protocols Moonraker will always
require that the "params" field contain a dictionary, so reject any
other type as invalid. There is no need to expand keyword arguments,
simply pass the params dict to the callback.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Add basic support "agents", ie: unmanaged extensions. Connected
agents are granted a limited ability to emit websocket notifications
and process rpc requests from Moonraker.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
HTTP 404 and JSON-RPC -32601 are equivalent, so translate
where necessary. Any other JRPC code received outside of the
HTTP error range should be assigned a 500.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Handle exceptions should the attempt to fetch peer
credentials on the unix socket fail. This isn't a hard
requirement for connection and should not cause
the connection to abort.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This prevents a scenario where a request handler mutates
the arguments of a WebRequest, which could result in
changing the default "request_arguments" in
"InternalTransport.call_method()".
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This is a reimplementation of commit d61540cad5,
however this attempt provides a fallback for legacy configurations
that still have configuration in the server section.
This will change how `/server/config` reports configuration. Options
will always be reported in their respective component's field, even if
they are currently configured in the `[server]` section.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This isn't necessary as we don't add new sections to the
original config object when parsing supplemental data.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This replaces the previous "get_sd_directory()" method, allowing
consumers to get any registered root path.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This isn't necessary as we don't add new sections to the
original config object when parsing supplemental data.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Most core components have default options that allow them to
load without a section specified in moonraker.conf. This resulted
in those options showing up in the [server] section in the
"/server/config" response. These changes will make sure that those
values show up in the correct section.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Use git for-each-ref to retreive tags and their associated commit
hashes. This allows us to limit the amount of tags to 10 and
simplifies the code as the returned objects are already dereferenced.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Don't require the `app_params` argument, instead dynamically
generate the configuration from a dict. This simiplifies AppDeploy
initialization as the internally generated configurations can be
read in the same way as those supplied in moonraker.conf.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>