summaryrefslogtreecommitdiffstats
path: root/os-plugins/plugins/x11vnc/OpenSLX/OSPlugin/x11vnc.pm
blob: fe06648cc580cfc1c9bb91ad6f2a0cccdaa4cfa4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# Copyright (c) 2007, 2008 - OpenSLX GmbH
#
# This program is free software distributed under the GPL version 2.
# See http://openslx.org/COPYING
#
# If you have any feedback please consult http://openslx.org/feedback and
# send your suggestions, praise, or complaints to feedback@openslx.org
#
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# x11vnc.pm
# -----------------------------------------------------------------------------
package OpenSLX::OSPlugin::x11vnc;

use strict;
use warnings;

use base qw(OpenSLX::OSPlugin::Base);

use OpenSLX::Basics;
use OpenSLX::Utils;

sub new
{
    my $class = shift;
    my $self = {
        name => 'x11vnc',
    };

    return bless $self, $class;
}

sub getInfo
{
    my $self = shift;
    return {
        description => unshiftHereDoc(<<'        End-of-Here'),
            enables x11vnc server (user or xorg)
        End-of-Here
        # waits for xorg to add configuration if needed
        precedence => 70,
    };
}

sub getAttrInfo
{
    my $self = shift;

    return {
        'x11vnc::active' => {
            applies_to_systems => 1,
            applies_to_clients => 1,
            description => unshiftHereDoc(<<'            End-of-Here'),
                should the 'x11vnc' plugin be executed during boot?
            End-of-Here
            content_regex => qr{^(0|1)$},
            content_descr => '1 means active - 0 means inactive',
            default => '1',
        },

        'x11vnc::mode' => {
            applies_to_systems => 1,
            applies_to_clients => 0,
            description => unshiftHereDoc(<<'            End-of-Here'),
                set x11vnc to listen on Xorg user sessions (default), general
                access to the Xorg server (including displaymanager login) and
                console framebuffer.
            End-of-Here
            content_regex => qr{^(x11user|x11mod|fb)$},
            content_descr => 'x11user for user, x11mod for access via Xorg module or fb',
            default => 'x11user',
        },

        'x11vnc::scale' => {
            applies_to_systems => 1,
            applies_to_clients => 0,
            description => unshiftHereDoc(<<'            End-of-Here'),
                scale screen size (e.g. as fraction 2/3 or as decimal 0.5)
            End-of-Here
            content_regex => undef,
            content_descr => undef,
            default => '',
        },

        'x11vnc::shared' => {
            applies_to_systems => 1,
            applies_to_clients => 0,
            description => unshiftHereDoc(<<'            End-of-Here'),
                by default x11vnc is always called with the -shared option
            End-of-Here
            content_regex => qr{^(yes|no|1|0)$},
            content_descr => 'use 1 or yes to enable - 0 or no to disable',
            default => 'yes',
        },

        'x11vnc::force_viewonly' => {
            applies_to_systems => 1,
            applies_to_clients => 0,
            description => unshiftHereDoc(<<'            End-of-Here'),
                disable user interaction with vnc
            End-of-Here
            content_regex => qr{^(yes|no|1|0)$},
            content_descr => 'use 1 or yes to enable - 0 or no to disable',
            default => 'no',
        },

        'x11vnc::auth_type' => {
            applies_to_systems => 1,
            applies_to_clients => 0,
            description => unshiftHereDoc(<<'            End-of-Here'),
                set authentication type of the vnc connection. rfbauth is
                available for x11user and fb only.
            End-of-Here
            content_regex => qr{^(passwd|rfbauth|none)$},
            content_descr => 'choose: passwd, rfbauth, none',
            default => 'passwd',
        },

        'x11vnc::allowed_hosts' => {
            applies_to_systems => 1,
            applies_to_clients => 0,
            description => unshiftHereDoc(<<'            End-of-Here'),
                set allowed hosts (multiple hosts are seperated by semicolons, 
                (simple) subnets are possible too e.g. "192.168.")
            End-of-Here
            content_regex => undef,
            content_descr => undef,
            default => '',
        },

        'x11vnc::force_localhost' => {
            applies_to_systems => 1,
            applies_to_clients => 0,
            description => unshiftHereDoc(<<'            End-of-Here'),
                force x11vnc to only accept local connections and only listen
                on the loopback device
            End-of-Here
            content_regex => qr{^(1|0|yes|no)$},
            content_descr => 'use 1 or yes to enable - 0 or no to disable',
            default => 'no',
        },

        'x11vnc::pass' => {
            applies_to_systems => 1,
            applies_to_clients => 0,
            description => unshiftHereDoc(<<'            End-of-Here'),
                viewonly password (you can add multiple passwords seperated
                by semicolons, if you're using rfbauth only the first one is
                used)
            End-of-Here
            content_regex => undef,
            content_descr => undef,
            default => '',
        },

        'x11vnc::viewonlypass' => {
            applies_to_systems => 1,
            applies_to_clients => 0,
            description => unshiftHereDoc(<<'            End-of-Here'),
                viewonly password (you can add multiple passwords seperated by
                semicolons, disabled with rfb-auth)
            End-of-Here
            content_regex => undef,
            content_descr => undef,
            default => 'viewonly',
        },

        'x11vnc::logging' => {
            applies_to_systems => 1,
            applies_to_clients => 0,
            description => unshiftHereDoc(<<'            End-of-Here'),
                enable logging
            End-of-Here
            content_regex => qr{^(1|0|yes|no)$},
            content_descr => 'use 1 or yes to enable - 0 or no to disable',
            default => 'yes',
        },
    };
}

sub installationPhase
{
    my $self = shift;
    my $info = shift;
    
    my $pluginRepositoryPath = $info->{'plugin-repo-path'};
    my $pluginTempPath       = $info->{'plugin-temp-path'};
    my $openslxBasePath      = $info->{'openslx-base-path'};

    # should we distinguish between the two different packages!?
    # libvnc should be part of the xorg package!? (so no check needed)
    my $engine = $self->{'os-plugin-engine'};
    if (!isInPath('x11vnc')) {
        $engine->installPackages(
            $engine->getInstallablePackagesForSelection('x11vnc')
        );
    } else {
        vlog(3, "x11vnc is already installed");
    }

    # get path of files we need to install
    my $pluginFilesPath = "$openslxBasePath/lib/plugins/$self->{'name'}/files";
    my $script = $self->{distro}->fillRunlevelScript();

    # copy all needed files now
    copyFile("$pluginFilesPath/x11vnc-init", "$pluginRepositoryPath");

    spitFile("/etc/init.d/x11vnc", $script);
    chmod 0755, "/etc/init.d/x11vnc";

    vlog(3, "install init file");

}

sub removalPhase
{
    my $self = shift;
    my $info = shift;
}

1;