Mir
application_authorizer.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2016 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License version 2 or 3 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Alan Griffiths <alan@octopull.co.uk>
17  */
18 
19 #ifndef MIRAL_APPLICATION_AUTHORIZER_H
20 #define MIRAL_APPLICATION_AUTHORIZER_H
21 
22 #include <sys/types.h>
23 #include <functional>
24 #include <memory>
25 
26 namespace mir { class Server; }
27 namespace mir { namespace frontend { class SessionCredentials; } }
28 
29 namespace miral
30 {
32 {
33 public:
34  ApplicationCredentials(mir::frontend::SessionCredentials const& creds);
35 
36  pid_t pid() const;
37  uid_t uid() const;
38  gid_t gid() const;
39 
40 private:
41  ApplicationCredentials() = delete;
42 
43  mir::frontend::SessionCredentials const& creds;
44 };
45 
47 {
48 public:
49  ApplicationAuthorizer() = default;
50  virtual ~ApplicationAuthorizer() = default;
52  ApplicationAuthorizer& operator=(ApplicationAuthorizer const&) = delete;
53 
54  virtual bool connection_is_allowed(ApplicationCredentials const& creds) = 0;
55  virtual bool configure_display_is_allowed(ApplicationCredentials const& creds) = 0;
56  virtual bool set_base_display_configuration_is_allowed(ApplicationCredentials const& creds) = 0;
57  virtual bool screencast_is_allowed(ApplicationCredentials const& creds) = 0;
58  virtual bool prompt_session_is_allowed(ApplicationCredentials const& creds) = 0;
59  virtual bool configure_input_is_allowed(ApplicationCredentials const& creds) = 0;
60  virtual bool set_base_input_configuration_is_allowed(ApplicationCredentials const& creds) = 0;
61 };
62 
64 {
65 public:
66  explicit BasicSetApplicationAuthorizer(std::function<std::shared_ptr<ApplicationAuthorizer>()> const& builder);
68 
69  void operator()(mir::Server& server);
70  auto the_application_authorizer() const -> std::shared_ptr<ApplicationAuthorizer>;
71 
72 private:
73  struct Self;
74  std::shared_ptr<Self> self;
75 };
76 
77 template<typename Policy>
79 {
80 public:
81  template<typename ...Args>
82  explicit SetApplicationAuthorizer(Args const& ...args) :
83  BasicSetApplicationAuthorizer{[&args...]() { return std::make_shared<Policy>(args...); }} {}
84 
85  auto the_custom_application_authorizer() const -> std::shared_ptr<Policy>
86  { return std::static_pointer_cast<Policy>(the_application_authorizer()); }
87 };
88 }
89 
90 #endif //MIRAL_APPLICATION_AUTHORIZER_H
Definition: splash_session.h:24
Definition: application_authorizer.h:46
STL namespace.
auto the_custom_application_authorizer() const -> std::shared_ptr< Policy >
Definition: application_authorizer.h:85
SetApplicationAuthorizer(Args const &...args)
Definition: application_authorizer.h:82
Definition: application_authorizer.h:63
Definition: application_authorizer.h:78
Definition: application_authorizer.h:31
Mir Abstraction Layer.
Definition: floating_window_manager.h:29

Copyright © 2012-2022 Canonical Ltd.
Generated on Tue Feb 1 20:51:23 UTC 2022
This documentation is licensed under the GPL version 2 or 3.