Don't raise an exception if the authorization header contains an
invalid value, such as Basic auth. Ignore it and move on to the
next step in authentication.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Register all of the "access" endpoints with the websocket. Front
ends may now connect to the websocket without an oneshot token
and login. If the front end already has a JWT for the user it
can be passed to the "identify" endpoint to authenticate directly.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Include the reserved file check in the `can_access_path()` method. This
fixes a potential vulnerability in the notifier where it may be possible
to attach a reserved file to a notification.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Provides an API for front ends to archive a list of files and/or
folders into a single zipped file.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Move logger initialization out of the utils module into its own
module, loghelper.py. This manager class simplifies access to the
underlying logger implementation and the queue listener. Additionally
it allows for endpoint registration.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
On systems where Klipper is installed as a service allow a
manual log rollover. The rollover cannot be called while printing.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Several components throughout Moonraker determine whether or not
Klipper is printing or is ready before taking action. This centralizes
queries in one area. The checks do not query Klipper directly but
rather rely on subscriptions to push state to Moonraker.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This change allows the user to choose the strategy for publishing
klipper states to MQTT. The original strategy where all state
updates are published to a common topic is still the default, but
can be turned off using the "publish_combined_status" config option.
The newly added strategy is publishing individual state updates to
separate mqtt topics. It is disabled by default, and can be enabled
with the "publish_split_status" config option.
Signed-off-by: Matt White <m.w.white@gmail.com>
Wrap all callbacks in a coroutine that handles exceptions. This
should eliminate "task not retreived" errors.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
The "force" argument may be used turn on a device during a print
that is otherwise locked for normal requests.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
While the [update_manager client ...] naming convention is
deprecated it should not be disallowed. This fixes service restart
issues using the old naming convention.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Support unix connections with full access to all JSON-RPC APIs.
Internally these connections are treated as websocket connections,
however the underlying transport protocol is simplfied. Packets
are JSON encoded objects terminated with an ETX character.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Separate out code that applies to both standard websockets and the
future unix socket implementation.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Use the ConfigHelper's getpath() method to configure the
unix socket. The option may now be a template where the
datapath is passed into the context.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Do not add inotify watches for reserved paths that exclude
write acccess. Do not return include reserved paths in
file list requests without read access.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
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>