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 <miral/version.h>
23 
24 #include <sys/types.h>
25 #include <functional>
26 #include <memory>
27 
28 namespace mir { class Server; }
29 namespace mir { namespace frontend { class SessionCredentials; } }
30 
31 namespace miral
32 {
34 {
35 public:
36  ApplicationCredentials(mir::frontend::SessionCredentials const& creds);
37 
38  pid_t pid() const;
39  uid_t uid() const;
40  gid_t gid() const;
41 
42 private:
43  ApplicationCredentials() = delete;
44 
45  mir::frontend::SessionCredentials const& creds;
46 };
47 
49 {
50 public:
51  ApplicationAuthorizer() = default;
52  virtual ~ApplicationAuthorizer() = default;
54  ApplicationAuthorizer& operator=(ApplicationAuthorizer const&) = delete;
55 
56  virtual bool connection_is_allowed(ApplicationCredentials const& creds) = 0;
57  virtual bool configure_display_is_allowed(ApplicationCredentials const& creds) = 0;
58  virtual bool set_base_display_configuration_is_allowed(ApplicationCredentials const& creds) = 0;
59  virtual bool screencast_is_allowed(ApplicationCredentials const& creds) = 0;
60  virtual bool prompt_session_is_allowed(ApplicationCredentials const& creds) = 0;
61 };
62 
63 // Mir has introduced new functions. We can't introduce new functions to ApplicationAuthorizer
64 // without breaking ABI, but we can offer an extension interface:
66 {
67 public:
68  virtual bool configure_input_is_allowed(ApplicationCredentials const& creds) = 0;
69  virtual bool set_base_input_configuration_is_allowed(ApplicationCredentials const& creds) = 0;
70 
71 #if MIRAL_VERSION >= MIR_VERSION_NUMBER(2, 0, 0)
72 #error "We've presumably broken ABI - please roll this interface into ApplicationAuthorizer"
73 #endif
74 };
75 
77 {
78 public:
79  explicit BasicSetApplicationAuthorizer(std::function<std::shared_ptr<ApplicationAuthorizer>()> const& builder);
81 
82  void operator()(mir::Server& server);
83  auto the_application_authorizer() const -> std::shared_ptr<ApplicationAuthorizer>;
84 
85 private:
86  struct Self;
87  std::shared_ptr<Self> self;
88 };
89 
90 template<typename Policy>
92 {
93 public:
94  template<typename ...Args>
95  explicit SetApplicationAuthorizer(Args const& ...args) :
96  BasicSetApplicationAuthorizer{[&args...]() { return std::make_shared<Policy>(args...); }} {}
97 
98  auto the_custom_application_authorizer() const -> std::shared_ptr<Policy>
99  { return std::static_pointer_cast<Policy>(the_application_authorizer()); }
100 };
101 }
102 
103 #endif //MIRAL_APPLICATION_AUTHORIZER_H
AutoUnblockThread is a helper thread class that can gracefully shutdown at destruction time...
Definition: sw_splash.h:26
Definition: application_authorizer.h:48
STL namespace.
auto the_custom_application_authorizer() const -> std::shared_ptr< Policy >
Definition: application_authorizer.h:98
SetApplicationAuthorizer(Args const &...args)
Definition: application_authorizer.h:95
Definition: application_authorizer.h:65
Definition: application_authorizer.h:76
Definition: application_authorizer.h:91
Definition: application_authorizer.h:33
Mir Abstraction Layer.
Definition: floating_window_manager.h:32

Copyright © 2012-2018 Canonical Ltd.
Generated on Mon Feb 19 14:06:43 UTC 2018